Ignore:
Timestamp:
2013/08/15 08:54:40 (11 years ago)
Author:
pineray
Message:

#2342 JavaScript?のグローバルな宣言を減らす
eccubeオブジェクト内の階層を減らす.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/html/js/eccube.js

    r23065 r23066  
    2323(function( window, undefined ){ 
    2424 
    25     var common = {}; 
    26  
    27     common.win01 = function(URL,Winname,Wwidth,Wheight){ 
     25 
     26    // 名前空間の重複を防ぐ 
     27    if (window.eccube === undefined) { 
     28        window.eccube = {}; 
     29    } 
     30 
     31    var eccube = window.eccube; 
     32 
     33    eccube.win01 = function(URL,Winname,Wwidth,Wheight){ 
    2834        var WIN; 
    2935        WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=no,resizable=no,toolbar=no,location=no,directories=no,status=no"); 
     
    3137    }; 
    3238 
    33     common.win02 = function(URL,Winname,Wwidth,Wheight){ 
     39    eccube.win02 = function(URL,Winname,Wwidth,Wheight){ 
    3440        var WIN; 
    3541        WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no"); 
     
    3743    }; 
    3844 
    39     common.win03 = function(URL,Winname,Wwidth,Wheight){ 
     45    eccube.win03 = function(URL,Winname,Wwidth,Wheight){ 
    4046        var WIN; 
    4147        WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no"); 
     
    4349    }; 
    4450 
    45     common.winSubmit = function(URL,formName,Winname,Wwidth,Wheight){ 
     51    eccube.winSubmit = function(URL,formName,Winname,Wwidth,Wheight){ 
    4652        var WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no"); 
    4753        document.forms[formName].target = Winname; 
     
    4955    }; 
    5056 
    51     common.openWindow = function(URL,name,width,height) { 
     57    eccube.openWindow = function(URL,name,width,height) { 
    5258        window.open(URL,name,"width="+width+",height="+height+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=no"); 
    5359    }; 
    5460 
    5561    // 親ウィンドウの存在確認. 
    56     common.isOpener = function() { 
     62    eccube.isOpener = function() { 
    5763        var ua = navigator.userAgent; 
    5864        if( !!window.opener ) { 
     
    6773    }; 
    6874 
    69     common.chgImg = function(fileName,img){ 
     75    eccube.chgImg = function(fileName,img){ 
    7076        if (typeof(img) == "object") { 
    7177            img.src = fileName; 
     
    7581    }; 
    7682 
    77     common.chgImgImageSubmit = function(fileName,imgObj){ 
     83    eccube.chgImgImageSubmit = function(fileName,imgObj){ 
    7884        imgObj.src = fileName; 
    7985    }; 
    8086 
    8187    // 郵便番号入力呼び出し. 
    82     common.getAddress = function(php_url, tagname1, tagname2, input1, input2) { 
     88    eccube.getAddress = function(php_url, tagname1, tagname2, input1, input2) { 
    8389        var zip1 = document.form1[tagname1].value; 
    8490        var zip2 = document.form1[tagname2].value; 
     
    9197                    var arrData = data.split("|"); 
    9298                    if (arrData.length > 1) { 
    93                         eccube.common.putAddress(input1, input2, arrData[0], arrData[1], arrData[2]); 
     99                        eccube.putAddress(input1, input2, arrData[0], arrData[1], arrData[2]); 
    94100                    } else { 
    95101                        alert(data); 
     
    103109 
    104110    // 郵便番号から検索した住所を渡す. 
    105     common.putAddress = function(input1, input2, state, city, town) { 
     111    eccube.putAddress = function(input1, input2, state, city, town) { 
    106112        if(state != "") { 
    107113            // 項目に値を入力する. 
     
    111117    }; 
    112118 
    113     common.setFocus = function(name) { 
     119    eccube.setFocus = function(name) { 
    114120        if(document.form1[name]) { 
    115121            document.form1[name].focus(); 
     
    118124 
    119125    // モードとキーを指定してSUBMITを行う。 
    120     common.setModeAndSubmit = function(mode, keyname, keyid) { 
     126    eccube.setModeAndSubmit = function(mode, keyname, keyid) { 
    121127        switch(mode) { 
    122128            case 'delete_category': 
     
    150156    }; 
    151157 
    152     common.fnFormModeSubmit = function(form, mode, keyname, keyid) { 
     158    eccube.fnFormModeSubmit = function(form, mode, keyname, keyid) { 
    153159        switch(mode) { 
    154160            case 'delete': 
     
    177183    }; 
    178184 
    179     common.setValueAndSubmit = function(form, key, val) { 
     185    eccube.setValueAndSubmit = function(form, key, val) { 
    180186        document.forms[form][key].value = val; 
    181187        document.forms[form].submit(); 
     
    183189    }; 
    184190 
    185     common.setValue = function(key, val, form) { 
     191    eccube.setValue = function(key, val, form) { 
    186192        if (typeof form === 'undefined') { 
    187193            form = 'form1'; 
     
    190196    }; 
    191197 
    192     common.changeAction = function(url) { 
     198    eccube.changeAction = function(url) { 
    193199        document.form1.action = url; 
    194200    }; 
    195201 
    196202    // ページナビで使用する。 
    197     common.movePage = function(pageno, mode, form) { 
     203    eccube.movePage = function(pageno, mode, form) { 
    198204        if (typeof form !== 'undefined') { 
    199205            form = 'form1'; 
     
    206212    }; 
    207213 
    208     common.submitForm = function(form){ 
     214    eccube.submitForm = function(form){ 
    209215        if (typeof form !== 'undefined') { 
    210216            form = 'form1'; 
    211217        } 
    212218        document.forms[form].submit(); 
    213     } 
     219    }; 
    214220 
    215221    // ポイント入力制限。 
    216     common.togglePointForm = function() { 
     222    eccube.togglePointForm = function() { 
    217223        if(document.form1['point_check']) { 
    218224            var list = ['use_point']; 
     
    241247            } 
    242248        } 
    243     } 
     249    }; 
    244250 
    245251    // 別のお届け先入力制限。 
    246     common.toggleDeliveryForm = function() { 
     252    eccube.toggleDeliveryForm = function() { 
    247253        if(!document.form1) { 
    248254            return; 
     
    265271 
    266272            if(!document.form1['deliv_check'].checked) { 
    267                 eccube.common.changeDisabled(list, '#dddddd'); 
     273                eccube.changeDisabled(list, '#dddddd'); 
    268274            } else { 
    269                 eccube.common.changeDisabled(list, ''); 
     275                eccube.changeDisabled(list, ''); 
    270276            } 
    271277        } 
     
    273279 
    274280    // 最初に設定されていた色を保存しておく。 
    275     common.savedColor = []; 
    276  
    277     common.changeDisabled = function(list, color) { 
     281    eccube.savedColor = []; 
     282 
     283    eccube.changeDisabled = function(list, color) { 
    278284        var len = list.length; 
    279285 
     
    283289                    // 有効にする。 
    284290                    document.form1[list[i]].disabled = false; 
    285                     document.form1[list[i]].style.backgroundColor = eccube.common.savedColor[list[i]]; 
     291                    document.form1[list[i]].style.backgroundColor = eccube.savedColor[list[i]]; 
    286292                } else { 
    287293                    // 無効にする。 
    288294                    document.form1[list[i]].disabled = true; 
    289                     eccube.common.savedColor[list[i]] = document.form1[list[i]].style.backgroundColor; 
     295                    eccube.savedColor[list[i]] = document.form1[list[i]].style.backgroundColor; 
    290296                    document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0"; 
    291297                } 
     
    295301 
    296302    // ログイン時の入力チェック 
    297     common.checkLoginFormInputted = function(form, emailKey, passKey) { 
     303    eccube.checkLoginFormInputted = function(form, emailKey, passKey) { 
    298304        var checkItems = []; 
    299305 
     
    330336 
    331337    //親ウィンドウのページを変更する. 
    332     common.changeParentUrl = function(url) { 
     338    eccube.changeParentUrl = function(url) { 
    333339        // 親ウィンドウの存在確認 
    334         if(eccube.common.isOpener()) { 
     340        if(eccube.isOpener()) { 
    335341            window.opener.location.href = url; 
    336342        } else { 
     
    343349    //引数2:文字数カウント対象 
    344350    //引数3:カウント結果格納対象 
    345     common.countChars = function(form,sch,cnt) { 
     351    eccube.countChars = function(form,sch,cnt) { 
    346352        document.forms[form][cnt].value= document.forms[form][sch].value.length; 
    347353    }; 
    348354 
    349355    // テキストエリアのサイズを変更する. 
    350     common.toggleRows = function(buttonSelector, textAreaSelector, max, min) { 
     356    eccube.toggleRows = function(buttonSelector, textAreaSelector, max, min) { 
    351357        if ($(textAreaSelector).attr('rows') <= min) { 
    352358            $(textAreaSelector).attr('rows', max); 
     
    361367     * 規格2のプルダウンを設定する. 
    362368     */ 
    363     common.setClassCategories = function($form, product_id, $sele1, $sele2, selected_id2) { 
     369    eccube.setClassCategories = function($form, product_id, $sele1, $sele2, selected_id2) { 
    364370        if ($sele1 && $sele1.length) { 
    365371            var classcat_id1 = $sele1.val() ? $sele1.val() : ''; 
     
    389395                    $sele2.append(option); 
    390396                } 
    391                 eccube.common.checkStock($form, product_id, $sele1.val() ? $sele1.val() : '__unselected2', 
     397                eccube.checkStock($form, product_id, $sele1.val() ? $sele1.val() : '__unselected2', 
    392398                    $sele2.val() ? $sele2.val() : ''); 
    393399            } 
     
    398404     * 規格の選択状態に応じて, フィールドを設定する. 
    399405     */ 
    400     common.checkStock = function($form, product_id, classcat_id1, classcat_id2) { 
     406    eccube.checkStock = function($form, product_id, classcat_id1, classcat_id2) { 
    401407 
    402408        classcat_id2 = classcat_id2 ? classcat_id2 : ''; 
     
    492498    }; 
    493499 
    494     // 名前空間の重複を防ぐ 
    495     if (window.eccube === undefined) { 
    496         window.eccube = {}; 
    497     } 
    498500    // グローバルに使用できるようにする 
    499     window.eccube.common = common; 
     501    window.eccube = eccube; 
    500502 
    501503    /** 
     
    513515                // 規格1のみの場合 
    514516                if (!$sele2.length) { 
    515                     eccube.common.checkStock($form, product_id, $sele1.val(), '0'); 
     517                    eccube.checkStock($form, product_id, $sele1.val(), '0'); 
    516518                    // 規格2ありの場合 
    517519                } else { 
    518                     eccube.common.setClassCategories($form, product_id, $sele1, $sele2); 
     520                    eccube.setClassCategories($form, product_id, $sele1, $sele2); 
    519521                } 
    520522            }); 
     
    527529                var $sele1 = $form.find('select[name=classcategory_id1]'); 
    528530                var $sele2 = $(this); 
    529                 eccube.common.checkStock($form, product_id, $sele1.val(), $sele2.val()); 
     531                eccube.checkStock($form, product_id, $sele1.val(), $sele2.val()); 
    530532            }); 
    531533    }); 
Note: See TracChangeset for help on using the changeset viewer.