Ignore:
Timestamp:
2013/08/14 20:33:02 (11 years ago)
Author:
pineray
Message:

#2342 JavaScript?のグローバルな宣言を減らす
フォーム関連残り.

Location:
branches/version-2_13-dev/html
Files:
2 edited

Legend:

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

    r23063 r23064  
    2121 */ 
    2222 
    23 // ページナビで使用する。 
    24 function fnNaviPage(pageno) { 
    25     document.form1['pageno'].value = pageno; 
    26     document.form1.submit(); 
    27 } 
    28  
    29 function fnSearchPageNavi(pageno) { 
    30     document.form1['pageno'].value = pageno; 
    31     document.form1['mode'].value = 'search'; 
    32     document.form1.submit(); 
    33 } 
    34  
    35 function fnSubmit(){ 
    36     document.form1.submit(); 
    37 } 
    38  
    39 // ポイント入力制限。 
    40 function fnCheckInputPoint() { 
    41     if(document.form1['point_check']) { 
    42         list = new Array( 
    43             'use_point' 
    44         ); 
    45  
    46         if(!document.form1['point_check'][0].checked) { 
    47             color = "#dddddd"; 
    48             flag = true; 
    49         } else { 
    50             color = ""; 
    51             flag = false; 
    52         } 
    53  
    54         len = list.length 
    55         for(i = 0; i < len; i++) { 
    56             if(document.form1[list[i]]) { 
    57                 var current_color = document.form1[list[i]].style.backgroundColor; 
    58                 if (color != "#dddddd" && (current_color == "#ffe8e8" || current_color == "rgb(255, 232, 232)")) 
    59                 { 
    60                     continue; 
    61                 } 
    62                 document.form1[list[i]].disabled = flag; 
    63                 document.form1[list[i]].style.backgroundColor = color; 
    64             } 
    65         } 
    66     } 
    67 } 
    68  
    69 // 別のお届け先入力制限。 
    70 function fnCheckInputDeliv() { 
    71     if(!document.form1) { 
    72         return; 
    73     } 
    74     if(document.form1['deliv_check']) { 
    75         list = new Array( 
    76             'shipping_name01', 
    77             'shipping_name02', 
    78             'shipping_kana01', 
    79             'shipping_kana02', 
    80             'shipping_pref', 
    81             'shipping_zip01', 
    82             'shipping_zip02', 
    83             'shipping_addr01', 
    84             'shipping_addr02', 
    85             'shipping_tel01', 
    86             'shipping_tel02', 
    87             'shipping_tel03' 
    88         ); 
    89  
    90         if(!document.form1['deliv_check'].checked) { 
    91             fnChangeDisabled(list, '#dddddd'); 
    92         } else { 
    93             fnChangeDisabled(list, ''); 
    94         } 
    95     } 
    96 } 
    97  
    98 // 最初に設定されていた色を保存しておく。 
    99 var g_savecolor = []; 
    100  
    101 function fnChangeDisabled(list, color) { 
    102     len = list.length; 
    103  
    104     for(i = 0; i < len; i++) { 
    105         if(document.form1[list[i]]) { 
    106             if(color == "") { 
    107                 // 有効にする。 
    108                 document.form1[list[i]].disabled = false; 
    109                 document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]]; 
    110             } else { 
    111                 // 無効にする。 
    112                 document.form1[list[i]].disabled = true; 
    113                 g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor; 
    114                 document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0"; 
    115             } 
    116         } 
    117     } 
    118 } 
    119  
    120 // ログイン時の入力チェック 
    121 function fnCheckLogin(formname) { 
    122     var lstitem = []; 
    123  
    124     lstitem[0] = 'login_email'; 
    125     lstitem[1] = 'login_pass'; 
    126  
    127     var max = lstitem.length; 
    128     var errflg = false; 
    129     var cnt = 0; 
    130  
    131     // 必須項目のチェック 
    132     for(cnt = 0; cnt < max; cnt++) { 
    133         if(document.forms[formname][lstitem[cnt]].value == "") { 
    134             errflg = true; 
    135             break; 
    136         } 
    137     } 
    138  
    139     // 必須項目が入力されていない場合 
    140     if(errflg == true) { 
    141         alert('メールアドレス/パスワードを入力して下さい。'); 
    142         return false; 
    143     } else { 
    144         return true; 
    145     } 
    146 } 
    147  
    148 start_time = new Date(); 
    149  
    150 //親ウィンドウのページを変更する. 
    151 function fnUpdateParent(url) { 
    152     // 親ウィンドウの存在確認 
    153     if(eccube.common.isOpener()) { 
    154         window.opener.location.href = url; 
    155     } else { 
    156         window.close(); 
    157     } 
    158 } 
    159  
    160 //文字数をカウントする。 
    161 //引数1:フォーム名称 
    162 //引数2:文字数カウント対象 
    163 //引数3:カウント結果格納対象 
    164 function fnCharCount(form,sch,cnt) { 
    165     document.forms[form][cnt].value= document.forms[form][sch].value.length; 
    166 } 
    167  
    168 // テキストエリアのサイズを変更する. 
    169 function ChangeSize(buttonSelector, textAreaSelector, max, min) { 
    170     if ($(textAreaSelector).attr('rows') <= min) { 
    171         $(textAreaSelector).attr('rows', max); 
    172         $(buttonSelector).text('縮小'); 
    173     } else { 
    174         $(textAreaSelector).attr('rows', min); 
    175         $(buttonSelector).text('拡大'); 
    176     } 
    177 } 
    178  
    17923$(function() { 
    18024    // 規格1選択時 
     
    512356    }; 
    513357 
     358    // ページナビで使用する。 
     359    common.movePage = function(pageno, mode, form) { 
     360        if (typeof form !== 'undefined') { 
     361            form = 'form1'; 
     362        } 
     363        document.forms[form]['pageno'].value = pageno; 
     364        if (typeof mode !== 'undefined') { 
     365            document.forms[form]['mode'].value = 'search'; 
     366        } 
     367        document.forms[form].submit(); 
     368    }; 
     369 
     370    common.submitForm = function(form){ 
     371        if (typeof form !== 'undefined') { 
     372            form = 'form1'; 
     373        } 
     374        document.forms[form].submit(); 
     375    } 
     376 
     377    // ポイント入力制限。 
     378    common.togglePointForm = function() { 
     379        if(document.form1['point_check']) { 
     380            var list = ['use_point']; 
     381            var color; 
     382            var flag; 
     383 
     384            if(!document.form1['point_check'][0].checked) { 
     385                color = "#dddddd"; 
     386                flag = true; 
     387            } else { 
     388                color = ""; 
     389                flag = false; 
     390            } 
     391 
     392            var len = list.length; 
     393            for(i = 0; i < len; i++) { 
     394                if(document.form1[list[i]]) { 
     395                    var current_color = document.form1[list[i]].style.backgroundColor; 
     396                    if (color != "#dddddd" && (current_color == "#ffe8e8" || current_color == "rgb(255, 232, 232)")) 
     397                    { 
     398                        continue; 
     399                    } 
     400                    document.form1[list[i]].disabled = flag; 
     401                    document.form1[list[i]].style.backgroundColor = color; 
     402                } 
     403            } 
     404        } 
     405    } 
     406 
     407    // 別のお届け先入力制限。 
     408    common.toggleDeliveryForm = function() { 
     409        if(!document.form1) { 
     410            return; 
     411        } 
     412        if(document.form1['deliv_check']) { 
     413            var list = [ 
     414                'shipping_name01', 
     415                'shipping_name02', 
     416                'shipping_kana01', 
     417                'shipping_kana02', 
     418                'shipping_pref', 
     419                'shipping_zip01', 
     420                'shipping_zip02', 
     421                'shipping_addr01', 
     422                'shipping_addr02', 
     423                'shipping_tel01', 
     424                'shipping_tel02', 
     425                'shipping_tel03' 
     426            ]; 
     427 
     428            if(!document.form1['deliv_check'].checked) { 
     429                eccube.common.changeDisabled(list, '#dddddd'); 
     430            } else { 
     431                eccube.common.changeDisabled(list, ''); 
     432            } 
     433        } 
     434    }; 
     435 
     436    // 最初に設定されていた色を保存しておく。 
     437    common.savedColor = []; 
     438 
     439    common.changeDisabled = function(list, color) { 
     440        var len = list.length; 
     441 
     442        for(i = 0; i < len; i++) { 
     443            if(document.form1[list[i]]) { 
     444                if(color == "") { 
     445                    // 有効にする。 
     446                    document.form1[list[i]].disabled = false; 
     447                    document.form1[list[i]].style.backgroundColor = eccube.common.savedColor[list[i]]; 
     448                } else { 
     449                    // 無効にする。 
     450                    document.form1[list[i]].disabled = true; 
     451                    eccube.common.savedColor[list[i]] = document.form1[list[i]].style.backgroundColor; 
     452                    document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0"; 
     453                } 
     454            } 
     455        } 
     456    }; 
     457 
     458    // ログイン時の入力チェック 
     459    common.checkLoginFormInputted = function(form, emailKey, passKey) { 
     460        var checkItems = []; 
     461 
     462        if (typeof emailKey === 'undefined') { 
     463            checkItems[0] = 'login_email'; 
     464        } else { 
     465            checkItems[0] = emailKey; 
     466        } 
     467        if (typeof passKey === 'undefined') { 
     468            checkItems[1] = 'login_pass'; 
     469        } else { 
     470            checkItems[1] = passKey; 
     471        } 
     472 
     473        var max = checkItems.length; 
     474        var errorFlag = false; 
     475 
     476        // 必須項目のチェック 
     477        for(var cnt = 0; cnt < max; cnt++) { 
     478            if(document.forms[form][checkItems[cnt]].value == "") { 
     479                errorFlag = true; 
     480                break; 
     481            } 
     482        } 
     483 
     484        // 必須項目が入力されていない場合 
     485        if(errorFlag == true) { 
     486            alert('メールアドレス/パスワードを入力して下さい。'); 
     487            return false; 
     488        } else { 
     489            return true; 
     490        } 
     491    }; 
     492 
     493    //親ウィンドウのページを変更する. 
     494    common.changeParentUrl = function(url) { 
     495        // 親ウィンドウの存在確認 
     496        if(eccube.common.isOpener()) { 
     497            window.opener.location.href = url; 
     498        } else { 
     499            window.close(); 
     500        } 
     501    }; 
     502 
     503    //文字数をカウントする。 
     504    //引数1:フォーム名称 
     505    //引数2:文字数カウント対象 
     506    //引数3:カウント結果格納対象 
     507    common.countChars = function(form,sch,cnt) { 
     508        document.forms[form][cnt].value= document.forms[form][sch].value.length; 
     509    }; 
     510 
     511    // テキストエリアのサイズを変更する. 
     512    common.toggleRows = function(buttonSelector, textAreaSelector, max, min) { 
     513        if ($(textAreaSelector).attr('rows') <= min) { 
     514            $(textAreaSelector).attr('rows', max); 
     515            $(buttonSelector).text('縮小'); 
     516        } else { 
     517            $(textAreaSelector).attr('rows', min); 
     518            $(buttonSelector).text('拡大'); 
     519        } 
     520    }; 
     521 
    514522    // 名前空間の重複を防ぐ 
    515523    if (window.eccube === undefined) { 
  • branches/version-2_13-dev/html/user_data/packages/admin/js/admin.js

    r23063 r23064  
    2020 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
    2121 */ 
    22  
    23 //親ウィンドウのページを変更する。 
    24 function fnUpdateParent(url) { 
    25     // 親ウィンドウの存在確認 
    26     if(eccube.common.isOpener()) { 
    27         window.opener.location.href = url; 
    28     } else { 
    29         window.close(); 
    30     } 
    31 } 
    3222 
    3323// 親ウィンドウをポストさせる。 
     
    198188            ); 
    199189        if(document.form1['stock_unlimited'].checked) { 
    200             fnChangeDisabled(list, icolor); 
     190            eccube.common.changeDisabled(list, icolor); 
    201191            document.form1['stock'].value = ""; 
    202192        } else { 
    203             fnChangeDisabled(list, ''); 
     193            eccube.common.changeDisabled(list, ''); 
    204194        } 
    205195    } 
     
    330320            ); 
    331321        if(document.form1[elem2].checked) { 
    332             fnChangeDisabled(list, icolor); 
     322            eccube.common.changeDisabled(list, icolor); 
    333323            document.form1[elem1].value = ""; 
    334324        } else { 
    335             fnChangeDisabled(list, ''); 
    336         } 
    337     } 
    338 } 
     325            eccube.common.changeDisabled(list, ''); 
     326        } 
     327    } 
     328} 
Note: See TracChangeset for help on using the changeset viewer.