source: branches/version-2_13-dev/html/js/eccube.legacy.js @ 23112

Revision 23112, 19.8 KB checked in by pineray, 11 years ago (diff)

#2342 JavaScript?のグローバルな宣言を減らす
後方互換性対策.
追加忘れ.

Line 
1/*
2 * This file is part of EC-CUBE
3 *
4 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
5 *
6 * http://www.lockon.co.jp/
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 */
22
23function chgImg(fileName,img){
24    if (typeof(img) == "object") {
25        img.src = fileName;
26    } else {
27        document.images[img].src = fileName;
28    }
29}
30
31function chgImgImageSubmit(fileName,imgObj){
32    imgObj.src = fileName;
33}
34
35function win01(URL,Winname,Wwidth,Wheight){
36    var WIN;
37    WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=no,resizable=no,toolbar=no,location=no,directories=no,status=no");
38    WIN.focus();
39}
40
41function win02(URL,Winname,Wwidth,Wheight){
42    var WIN;
43    WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
44    WIN.focus();
45}
46
47function win03(URL,Winname,Wwidth,Wheight){
48    var WIN;
49    WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no");
50    WIN.focus();
51}
52
53function winSubmit(URL,formName,Winname,Wwidth,Wheight){
54    var WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no");
55    document.forms[formName].target = Winname;
56    WIN.focus();
57}
58
59// 親ウィンドウの存在確認.
60function fnIsopener() {
61    var ua = navigator.userAgent;
62    if( !!window.opener ) {
63        if( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) {
64            return !window.opener.closed;
65        } else {
66            return typeof window.opener.document == 'object';
67        }
68    } else {
69        return false;
70    }
71}
72
73// 郵便番号入力呼び出し.
74function fnCallAddress(php_url, tagname1, tagname2, input1, input2) {
75    zip1 = document.form1[tagname1].value;
76    zip2 = document.form1[tagname2].value;
77
78    if(zip1.length == 3 && zip2.length == 4) {
79        $.get(
80            php_url,
81            {zip1: zip1, zip2: zip2, input1: input1, input2: input2},
82            function(data) {
83                arrdata = data.split("|");
84                if (arrdata.length > 1) {
85                    fnPutAddress(input1, input2, arrdata[0], arrdata[1], arrdata[2]);
86                } else {
87                    alert(data);
88                }
89            }
90        );
91    } else {
92        alert("郵便番号を正しく入力して下さい。");
93    }
94}
95
96// 郵便番号から検索した住所を渡す.
97function fnPutAddress(input1, input2, state, city, town) {
98    if(state != "") {
99        // 項目に値を入力する.
100        document.form1[input1].selectedIndex = state;
101        document.form1[input2].value = city + town;
102    }
103}
104
105function fnOpenNoMenu(URL) {
106    window.open(URL,"nomenu","scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
107}
108
109function fnOpenWindow(URL,name,width,height) {
110    window.open(URL,name,"width="+width+",height="+height+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=no");
111}
112
113function fnSetFocus(name) {
114    if(document.form1[name]) {
115        document.form1[name].focus();
116    }
117}
118
119// セレクトボックスに項目を割り当てる.
120function fnSetSelect(name1, name2, val) {
121    sele1 = document.form1[name1];
122    sele2 = document.form1[name2];
123
124    if(sele1 && sele2) {
125        index=sele1.selectedIndex;
126
127        // セレクトボックスのクリア
128        count=sele2.options.length
129        for(i = count; i >= 0; i--) {
130            sele2.options[i]=null;
131        }
132
133        // セレクトボックスに値を割り当てる。
134        len = lists[index].length
135        for(i = 0; i < len; i++) {
136            sele2.options[i]=new Option(lists[index][i], vals[index][i]);
137            if(val != "" && vals[index][i] == val) {
138                sele2.options[i].selected = true;
139            }
140        }
141    }
142}
143
144// Enterキー入力をキャンセルする。(IEに対応)
145function fnCancelEnter()
146{
147    if (gCssUA.indexOf("WIN") != -1 && gCssUA.indexOf("MSIE") != -1) {
148        if (window.event.keyCode == 13)
149        {
150            return false;
151        }
152    }
153    return true;
154}
155
156// モードとキーを指定してSUBMITを行う。
157function fnModeSubmit(mode, keyname, keyid) {
158    switch(mode) {
159        case 'delete_category':
160            if(!window.confirm('選択したカテゴリとカテゴリ内の全てのカテゴリを削除します')){
161                return;
162            }
163            break;
164        case 'delete':
165            if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){
166                return;
167            }
168            break;
169        case 'confirm':
170            if(!window.confirm('登録しても宜しいですか')){
171                return;
172            }
173            break;
174        case 'delete_all':
175            if(!window.confirm('検索結果を全て削除しても宜しいですか')){
176                return;
177            }
178            break;
179        default:
180            break;
181    }
182    document.form1['mode'].value = mode;
183    if(keyname != "" && keyid != "") {
184        document.form1[keyname].value = keyid;
185    }
186    document.form1.submit();
187}
188
189function fnFormModeSubmit(form, mode, keyname, keyid) {
190    switch(mode) {
191        case 'delete':
192            if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){
193                return;
194            }
195            break;
196        case 'confirm':
197            if(!window.confirm('登録しても宜しいですか')){
198                return;
199            }
200            break;
201        case 'regist':
202            if(!window.confirm('登録しても宜しいですか')){
203                return;
204            }
205            break;
206        default:
207            break;
208    }
209    document.forms[form]['mode'].value = mode;
210    if(keyname != "" && keyid != "") {
211        document.forms[form][keyname].value = keyid;
212    }
213    document.forms[form].submit();
214}
215
216function fnSetFormSubmit(form, key, val) {
217    document.forms[form][key].value = val;
218    document.forms[form].submit();
219    return false;
220}
221
222function fnSetVal(key, val) {
223    fnSetFormVal('form1', key, val);
224}
225
226function fnSetFormVal(form, key, val) {
227    document.forms[form][key].value = val;
228}
229
230function fnChangeAction(url) {
231    document.form1.action = url;
232}
233
234// ページナビで使用する。
235function fnNaviPage(pageno) {
236    document.form1['pageno'].value = pageno;
237    document.form1.submit();
238}
239
240function fnSearchPageNavi(pageno) {
241    document.form1['pageno'].value = pageno;
242    document.form1['mode'].value = 'search';
243    document.form1.submit();
244}
245
246function fnSubmit(){
247    document.form1.submit();
248}
249
250// ポイント入力制限。
251function fnCheckInputPoint() {
252    if(document.form1['point_check']) {
253        list = new Array(
254            'use_point'
255        );
256
257        if(!document.form1['point_check'][0].checked) {
258            color = "#dddddd";
259            flag = true;
260        } else {
261            color = "";
262            flag = false;
263        }
264
265        len = list.length
266        for(i = 0; i < len; i++) {
267            if(document.form1[list[i]]) {
268                var current_color = document.form1[list[i]].style.backgroundColor;
269                if (color != "#dddddd" && (current_color == "#ffe8e8" || current_color == "rgb(255, 232, 232)"))
270                {
271                    continue;
272                }
273                document.form1[list[i]].disabled = flag;
274                document.form1[list[i]].style.backgroundColor = color;
275            }
276        }
277    }
278}
279
280// 別のお届け先入力制限。
281function fnCheckInputDeliv() {
282    if(!document.form1) {
283        return;
284    }
285    if(document.form1['deliv_check']) {
286        list = new Array(
287            'shipping_name01',
288            'shipping_name02',
289            'shipping_kana01',
290            'shipping_kana02',
291            'shipping_pref',
292            'shipping_zip01',
293            'shipping_zip02',
294            'shipping_addr01',
295            'shipping_addr02',
296            'shipping_tel01',
297            'shipping_tel02',
298            'shipping_tel03'
299        );
300
301        if(!document.form1['deliv_check'].checked) {
302            fnChangeDisabled(list, '#dddddd');
303        } else {
304            fnChangeDisabled(list, '');
305        }
306    }
307}
308
309// 最初に設定されていた色を保存しておく。
310var g_savecolor = new Array();
311
312function fnChangeDisabled(list, color) {
313    len = list.length;
314
315    for(i = 0; i < len; i++) {
316        if(document.form1[list[i]]) {
317            if(color == "") {
318                // 有効にする。
319                document.form1[list[i]].disabled = false;
320                document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]];
321            } else {
322                // 無効にする。
323                document.form1[list[i]].disabled = true;
324                g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor;
325                document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0";
326            }
327        }
328    }
329}
330
331// ログイン時の入力チェック
332function fnCheckLogin(formname) {
333    var lstitem = new Array();
334
335    lstitem[0] = 'login_email';
336    lstitem[1] = 'login_pass';
337
338    var max = lstitem.length;
339    var errflg = false;
340    var cnt = 0;
341
342    // 必須項目のチェック
343    for(cnt = 0; cnt < max; cnt++) {
344        if(document.forms[formname][lstitem[cnt]].value == "") {
345            errflg = true;
346            break;
347        }
348    }
349
350    // 必須項目が入力されていない場合
351    if(errflg == true) {
352        alert('メールアドレス/パスワードを入力して下さい。');
353        return false;
354    } else {
355        return true;
356    }
357}
358
359// 時間の計測.
360function fnPassTime(){
361    end_time = new Date();
362    time = end_time.getTime() - start_time.getTime();
363    alert((time/1000));
364}
365start_time = new Date();
366
367//親ウィンドウのページを変更する.
368function fnUpdateParent(url) {
369    // 親ウィンドウの存在確認
370    if(fnIsopener()) {
371        window.opener.location.href = url;
372    } else {
373        window.close();
374    }
375}
376
377//特定のキーをSUBMITする.
378function fnKeySubmit(keyname, keyid) {
379    if(keyname != "" && keyid != "") {
380        document.form1[keyname].value = keyid;
381    }
382    document.form1.submit();
383}
384
385//文字数をカウントする。
386//引数1:フォーム名称
387//引数2:文字数カウント対象
388//引数3:カウント結果格納対象
389function fnCharCount(form,sch,cnt) {
390    document.forms[form][cnt].value= document.forms[form][sch].value.length;
391}
392
393// テキストエリアのサイズを変更する.
394function ChangeSize(buttonSelector, textAreaSelector, max, min) {
395    if ($(textAreaSelector).attr('rows') <= min) {
396        $(textAreaSelector).attr('rows', max);
397        $(buttonSelector).text('縮小');
398    } else {
399        $(textAreaSelector).attr('rows', min);
400        $(buttonSelector).text('拡大');
401    }
402}
403
404/**
405 * 規格2のプルダウンを設定する.
406 */
407function setClassCategories($form, product_id, $sele1, $sele2, selected_id2) {
408    if ($sele1 && $sele1.length) {
409        var classcat_id1 = $sele1.val() ? $sele1.val() : '';
410        if ($sele2 && $sele2.length) {
411            // 規格2の選択肢をクリア
412            $sele2.children().remove();
413
414            var classcat2;
415
416            // 商品一覧時
417            if (typeof productsClassCategories != 'undefined') {
418                classcat2 = productsClassCategories[product_id][classcat_id1];
419            }
420            // 詳細表示時
421            else {
422                classcat2 = classCategories[classcat_id1];
423            }
424
425            // 規格2の要素を設定
426            for (var key in classcat2) {
427                var id = classcat2[key]['classcategory_id2'];
428                var name = classcat2[key]['name'];
429                var option = $('<option />').val(id ? id : '').text(name);
430                if (id == selected_id2) {
431                    option.attr('selected', true);
432                }
433                $sele2.append(option);
434            }
435            checkStock($form, product_id, $sele1.val() ? $sele1.val() : '__unselected2',
436                $sele2.val() ? $sele2.val() : '');
437        }
438    }
439}
440
441/**
442 * 規格の選択状態に応じて, フィールドを設定する.
443 */
444function checkStock($form, product_id, classcat_id1, classcat_id2) {
445
446    classcat_id2 = classcat_id2 ? classcat_id2 : '';
447
448    var classcat2;
449
450    // 商品一覧時
451    if (typeof productsClassCategories != 'undefined') {
452        classcat2 = productsClassCategories[product_id][classcat_id1]['#' + classcat_id2];
453    }
454    // 詳細表示時
455    else {
456        classcat2 = classCategories[classcat_id1]['#' + classcat_id2];
457    }
458
459    // 商品コード
460    var $product_code_default = $form.find('[id^=product_code_default]');
461    var $product_code_dynamic = $form.find('[id^=product_code_dynamic]');
462    if (classcat2
463        && typeof classcat2['product_code'] != 'undefined') {
464        $product_code_default.hide();
465        $product_code_dynamic.show();
466        $product_code_dynamic.text(classcat2['product_code']);
467    } else {
468        $product_code_default.show();
469        $product_code_dynamic.hide();
470    }
471
472    // 在庫(品切れ)
473    var $cartbtn_default = $form.find('[id^=cartbtn_default]');
474    var $cartbtn_dynamic = $form.find('[id^=cartbtn_dynamic]');
475    if (classcat2 && classcat2['stock_find'] === false) {
476
477        $cartbtn_dynamic.text('申し訳ございませんが、只今品切れ中です。').show();
478        $cartbtn_default.hide();
479    } else {
480        $cartbtn_dynamic.hide();
481        $cartbtn_default.show();
482    }
483
484    // 通常価格
485    var $price01_default = $form.find('[id^=price01_default]');
486    var $price01_dynamic = $form.find('[id^=price01_dynamic]');
487    if (classcat2
488        && typeof classcat2['price01'] != 'undefined'
489        && String(classcat2['price01']).length >= 1) {
490
491        $price01_dynamic.text(classcat2['price01']).show();
492        $price01_default.hide();
493    } else {
494        $price01_dynamic.hide();
495        $price01_default.show();
496    }
497
498    // 販売価格
499    var $price02_default = $form.find('[id^=price02_default]');
500    var $price02_dynamic = $form.find('[id^=price02_dynamic]');
501    if (classcat2
502        && typeof classcat2['price02'] != 'undefined'
503        && String(classcat2['price02']).length >= 1) {
504
505        $price02_dynamic.text(classcat2['price02']).show();
506        $price02_default.hide();
507    } else {
508        $price02_dynamic.hide();
509        $price02_default.show();
510    }
511
512    // ポイント
513    var $point_default = $form.find('[id^=point_default]');
514    var $point_dynamic = $form.find('[id^=point_dynamic]');
515    if (classcat2
516        && typeof classcat2['point'] != 'undefined'
517        && String(classcat2['point']).length >= 1) {
518
519        $point_dynamic.text(classcat2['point']).show();
520        $point_default.hide();
521    } else {
522        $point_dynamic.hide();
523        $point_default.show();
524    }
525
526    // 商品規格
527    var $product_class_id_dynamic = $form.find('[id^=product_class_id]');
528    if (classcat2
529        && typeof classcat2['product_class_id'] != 'undefined'
530        && String(classcat2['product_class_id']).length >= 1) {
531
532        $product_class_id_dynamic.val(classcat2['product_class_id']);
533    } else {
534        $product_class_id_dynamic.val('');
535    }
536}
537
538gCssUA = navigator.userAgent.toUpperCase();
539gCssBrw = navigator.appName.toUpperCase();
540
541with (document) {
542    write("<style type=\"text/css\"><!--");
543
544    //WIN-IE
545    if (gCssUA.indexOf("WIN") != -1 && gCssUA.indexOf("MSIE") != -1) {
546        write(".fs10 {font-size: 62.5%; line-height: 150%; letter-spacing:1px;}");
547        write(".fs12 {font-size: 75%; line-height: 150%; letter-spacing:1.5px;}");
548        write(".fs14 {font-size: 87.5%; line-height: 150%; letter-spacing:2px;}");
549        write(".fs18 {font-size: 117.5%; line-height: 130%; letter-spacing:2.5px;}");
550        write(".fs22 {font-size: 137.5%; line-height: 130%; letter-spacing:3px;}");
551        write(".fs24 {font-size: 150%; line-height: 130%; letter-spacing:3px;}");
552        write(".fs30 {font-size: 187.5%; line-height: 125%; letter-spacing:3.5px;}");
553        write(".fs10n {font-size: 62.5%; letter-spacing:1px;}");
554        write(".fs12n {font-size: 75%; letter-spacing:1.5px;}");
555        write(".fs14n {font-size: 87.5%; letter-spacing:2px;}");
556        write(".fs18n {font-size: 117.5%; letter-spacing:2.5px;}");
557        write(".fs22n {font-size: 137.5%; letter-spacing:1px;}");
558        write(".fs24n {font-size: 150%; letter-spacing:1px;}");
559        write(".fs30n {font-size: 187.5%; letter-spacing:1px;}");
560        write(".fs12st {font-size: 75%; line-height: 150%; letter-spacing:1.5px; font-weight: bold;}");
561    }
562
563    //WIN-NN
564    if (gCssUA.indexOf("WIN") != -1 && gCssBrw.indexOf("NETSCAPE") != -1) {
565        write(".fs10 {font-size:72%; line-height:130%;}");
566        write(".fs12 {font-size: 75%; line-height: 150%;}");
567        write(".fs14 {font-size: 87.5%; line-height: 140%;}");
568        write(".fs18 {font-size: 117.5%; line-height: 130%;}");
569        write(".fs22 {font-size: 137.5%; line-height: 130%;}");
570        write(".fs24 {font-size: 150%; line-height: 130%;}");
571        write(".fs30 {font-size: 187.5%; line-height: 120%;}");
572        write(".fs10n {font-size:72%;}");
573        write(".fs12n {font-size: 75%;}");
574        write(".fs14n {font-size: 87.5%;}");
575        write(".fs18n {font-size: 117.5%;}");
576        write(".fs22n {font-size: 137.5%;}");
577        write(".fs24n {font-size: 150%;}");
578        write(".fs30n {font-size: 187.5%;}");
579        write(".fs12st {font-size: 75%; line-height: 150%; font-weight: bold;}");
580    }
581
582    //WIN-NN4.x
583    if ( navigator.appName == "Netscape" && navigator.appVersion.substr(0,2) == "4." ) {
584        write(".fs10 {font-size:90%; line-height: 130%;}");
585        write(".fs12 {font-size: 100%; line-height: 140%;}");
586        write(".fs14 {font-size: 110%; line-height: 135%;}");
587        write(".fs18 {font-size: 130%; line-height: 175%;}");
588        write(".fs24 {font-size: 190%; line-height: 240%;}");
589        write(".fs30 {font-size: 240%; line-height: 285%;}");
590        write(".fs10n {font-size:90%;}");
591        write(".fs12n {font-size: 100%;}");
592        write(".fs14n {font-size: 110%;}");
593        write(".fs18n {font-size: 130%;}");
594        write(".fs24n {font-size: 190%;}");
595        write(".fs30n {font-size: 240%;}");
596        write(".fs12st {font-size: 100%; line-height: 140%; font-weight: bold;}");
597    }
598
599    //MAC
600    if (gCssUA.indexOf("MAC") != -1) {
601        write(".fs10 {font-size: 10px; line-height: 14px;}");
602        write(".fs12 {font-size: 12px; line-height: 18px;}");
603        write(".fs14 {font-size: 14px; line-height: 18px;}");
604        write(".fs18 {font-size: 18px; line-height: 23px;}");
605        write(".fs22 {font-size: 22px; line-height: 27px;}");
606        write(".fs24 {font-size: 24px; line-height: 30px;}");
607        write(".fs30 {font-size: 30px; line-height: 35px;}");
608        write(".fs10n {font-size: 10px;}");
609        write(".fs12n {font-size: 12px;}");
610        write(".fs14n {font-size: 14px;}");
611        write(".fs18n {font-size: 18px;}");
612        write(".fs22n {font-size: 22px;}");
613        write(".fs24n {font-size: 24px;}");
614        write(".fs30n {font-size: 30px;}");
615        write(".fs12st {font-size: 12px; line-height: 18px; font-weight: bold;}");
616    }
617
618    write("--></style>");
619}
Note: See TracBrowser for help on using the repository browser.