source: branches/version-2_12-multilang/html/js/site.js @ 22205

Revision 22205, 10.2 KB checked in by m_uehara, 12 years ago (diff)

#2004 郵便番号を2カラムから1カラムに変更しました。

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
RevLine 
[19712]1/*
2 * This file is part of EC-CUBE
3 *
[21867]4 * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved.
[19712]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 fnIsopener() {
24    var ua = navigator.userAgent;
25    if( !!window.opener ) {
26        if( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) {
27            return !window.opener.closed;
28        } else {
29            return typeof window.opener.document == 'object';
30        }
31    } else {
32        return false;
33    }
34}
35
36// 郵便番号入力呼び出し.
37function fnCallAddress(php_url, tagname1, tagname2, input1, input2) {
38    zip1 = document.form1[tagname1].value;
39    zip2 = document.form1[tagname2].value;
40
41    if(zip1.length == 3 && zip2.length == 4) {
42        $.get(
43            php_url,
44            {zip1: zip1, zip2: zip2, input1: input1, input2: input2},
45            function(data) {
46                arrdata = data.split("|");
47                if (arrdata.length > 1) {
48                    fnPutAddress(input1, input2, arrdata[0], arrdata[1], arrdata[2]);
49                } else {
50                    alert(data);
51                }
52            }
53        );
54    } else {
[22183]55        alert(fnT('j_site_001'));
[19712]56    }
57}
58
59// 郵便番号から検索した住所を渡す.
60function fnPutAddress(input1, input2, state, city, town) {
61    if(state != "") {
62        // 項目に値を入力する.
63        document.form1[input1].selectedIndex = state;
64        document.form1[input2].value = city + town;
65    }
66}
67
68function fnOpenNoMenu(URL) {
[20566]69    window.open(URL,"nomenu","scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
[19712]70}
71
72function fnOpenWindow(URL,name,width,height) {
[20566]73    window.open(URL,name,"width="+width+",height="+height+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=no");
[19712]74}
75
76function fnSetFocus(name) {
[20566]77    if(document.form1[name]) {
78        document.form1[name].focus();
79    }
[19712]80}
81
82// セレクトボックスに項目を割り当てる.
83function fnSetSelect(name1, name2, val) {
[20566]84    sele1 = document.form1[name1];
85    sele2 = document.form1[name2];
[19712]86
[20566]87    if(sele1 && sele2) {
88        index=sele1.selectedIndex;
[19712]89
[20566]90        // セレクトボックスのクリア
91        count=sele2.options.length
92        for(i = count; i >= 0; i--) {
93            sele2.options[i]=null;
94        }
[19712]95
[20566]96        // セレクトボックスに値を割り当てる。
97        len = lists[index].length
98        for(i = 0; i < len; i++) {
99            sele2.options[i]=new Option(lists[index][i], vals[index][i]);
100            if(val != "" && vals[index][i] == val) {
101                sele2.options[i].selected = true;
102            }
103        }
104    }
[19712]105}
106
107// Enterキー入力をキャンセルする。(IEに対応)
108function fnCancelEnter()
109{
[20566]110    if (gCssUA.indexOf("WIN") != -1 && gCssUA.indexOf("MSIE") != -1) {
111        if (window.event.keyCode == 13)
112        {
113            return false;
114        }
115    }
116    return true;
[19712]117}
118
119// モードとキーを指定してSUBMITを行う。
120function fnModeSubmit(mode, keyname, keyid) {
[20566]121    switch(mode) {
122    case 'delete_category':
[22183]123        if(!window.confirm(fnT('j_site_002'))){
[20566]124            return;
125        }
126        break;
127    case 'delete':
[22183]128        if(!window.confirm(fnT('j_site_003'))){
[20566]129            return;
130        }
131        break;
132    case 'delete_order':
[22183]133        if(!window.confirm(fnT('j_site_004'))){
[20566]134            return;
135        }
[19712]136        mode = 'delete';
[20566]137        break;
138    case 'confirm':
[22183]139        if(!window.confirm(fnT('j_site_005'))){
[20566]140            return;
141        }
142        break;
143    case 'delete_all':
[22183]144        if(!window.confirm(fnT('j_site_006'))){
[20566]145            return;
146        }
147        break;
148    default:
149        break;
150    }
151    document.form1['mode'].value = mode;
152    if(keyname != "" && keyid != "") {
153        document.form1[keyname].value = keyid;
154    }
155    document.form1.submit();
[19712]156}
157
158function fnFormModeSubmit(form, mode, keyname, keyid) {
[20566]159    switch(mode) {
160    case 'delete':
[22183]161        if(!window.confirm(fnT('j_site_007'))){
[20566]162            return;
163        }
164        break;
165    case 'confirm':
[22183]166        if(!window.confirm(fnT('j_site_008'))){
[20566]167            return;
168        }
169        break;
170    case 'regist':
[22183]171        if(!window.confirm(fnT('j_site_009'))){
[20566]172            return;
173        }
174        break;
175    default:
176        break;
177    }
178    document.forms[form]['mode'].value = mode;
179    if(keyname != "" && keyid != "") {
180        document.forms[form][keyname].value = keyid;
181    }
182    document.forms[form].submit();
[19712]183}
184
185function fnSetFormSubmit(form, key, val) {
[20566]186    document.forms[form][key].value = val;
187    document.forms[form].submit();
188    return false;
[19712]189}
190
191function fnSetVal(key, val) {
[20566]192    fnSetFormVal('form1', key, val);
[19712]193}
194
195function fnSetFormVal(form, key, val) {
[20566]196    document.forms[form][key].value = val;
[19712]197}
198
199function fnChangeAction(url) {
[20566]200    document.form1.action = url;
[19712]201}
202
203// ページナビで使用する。
204function fnNaviPage(pageno) {
[20566]205    document.form1['pageno'].value = pageno;
206    document.form1.submit();
[19712]207}
208
209function fnSearchPageNavi(pageno) {
[20566]210    document.form1['pageno'].value = pageno;
211    document.form1['mode'].value = 'search';
212    document.form1.submit();
213    }
[19712]214
215function fnSubmit(){
[20566]216    document.form1.submit();
[19712]217}
218
219// ポイント入力制限。
220function fnCheckInputPoint() {
[20566]221    if(document.form1['point_check']) {
222        list = new Array(
223                        'use_point'
224                        );
[19712]225
[20566]226        if(!document.form1['point_check'][0].checked) {
227            color = "#dddddd";
228            flag = true;
229        } else {
230            color = "";
231            flag = false;
232        }
[19712]233
[20566]234        len = list.length
235        for(i = 0; i < len; i++) {
236            if(document.form1[list[i]]) {
[20702]237                var current_color = document.form1[list[i]].style.backgroundColor;
238                if (color != "#dddddd" && (current_color == "#ffe8e8" || current_color == "rgb(255, 232, 232)"))
239                {
240                    continue;
241                }
[20566]242                document.form1[list[i]].disabled = flag;
243                document.form1[list[i]].style.backgroundColor = color;
244            }
245        }
246    }
[19712]247}
248
249// 別のお届け先入力制限。
250function fnCheckInputDeliv() {
[20566]251    if(!document.form1) {
252        return;
253    }
254    if(document.form1['deliv_check']) {
255        list = new Array(
256                        'shipping_name01',
257                        'shipping_name02',
258                        'shipping_kana01',
259                        'shipping_kana02',
260                        'shipping_pref',
261                        'shipping_zip01',
262                        'shipping_zip02',
[22205]263                        'shipping_zipcode',
[20566]264                        'shipping_addr01',
265                        'shipping_addr02',
266                        'shipping_tel01',
267                        'shipping_tel02',
268                        'shipping_tel03'
269                        );
[19712]270
[20566]271        if(!document.form1['deliv_check'].checked) {
272            fnChangeDisabled(list, '#dddddd');
273        } else {
274            fnChangeDisabled(list, '');
275        }
276    }
[19712]277}
278
279// 最初に設定されていた色を保存しておく。
280var g_savecolor = new Array();
281
282function fnChangeDisabled(list, color) {
[20566]283    len = list.length;
[19712]284
[20566]285    for(i = 0; i < len; i++) {
286        if(document.form1[list[i]]) {
287            if(color == "") {
288                // 有効にする。
289                document.form1[list[i]].disabled = false;
290                document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]];
291            } else {
292                // 無効にする。
293                document.form1[list[i]].disabled = true;
294                g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor;
295                document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0";
296            }
297        }
298    }
[19712]299}
300
301
302// ログイン時の入力チェック
303function fnCheckLogin(formname) {
[20566]304    var lstitem = new Array();
[19712]305
[20566]306    lstitem[0] = 'login_email';
307    lstitem[1] = 'login_pass';
[21929]308
[20566]309    var max = lstitem.length;
310    var errflg = false;
311    var cnt = 0;
[19712]312
[20566]313    // 必須項目のチェック
314    for(cnt = 0; cnt < max; cnt++) {
315        if(document.forms[formname][lstitem[cnt]].value == "") {
316            errflg = true;
317            break;
318        }
319    }
[19712]320
[20566]321    // 必須項目が入力されていない場合
322    if(errflg == true) {
[22183]323        alert(fnT('j_site_010'));
[20566]324        return false;
[21929]325    } else {
326        return true;
[20566]327    }
[19712]328}
329
330// 時間の計測.
331function fnPassTime(){
[20566]332    end_time = new Date();
333    time = end_time.getTime() - start_time.getTime();
334    alert((time/1000));
[19712]335}
336start_time = new Date();
337
338//親ウィンドウのページを変更する.
339function fnUpdateParent(url) {
[20566]340    // 親ウィンドウの存在確認
341    if(fnIsopener()) {
342        window.opener.location.href = url;
343    } else {
344        window.close();
345    }
[19712]346}
347
348//特定のキーをSUBMITする.
349function fnKeySubmit(keyname, keyid) {
[20566]350    if(keyname != "" && keyid != "") {
351        document.form1[keyname].value = keyid;
352    }
353    document.form1.submit();
[19712]354}
355
356//文字数をカウントする。
357//引数1:フォーム名称
358//引数2:文字数カウント対象
359//引数3:カウント結果格納対象
360function fnCharCount(form,sch,cnt) {
[20566]361    document.forms[form][cnt].value= document.forms[form][sch].value.length;
[19712]362}
363
364
365// テキストエリアのサイズを変更する.
[19914]366function ChangeSize(buttonSelector, textAreaSelector, max, min) {
[19712]367
[19914]368    if ($(textAreaSelector).attr('rows') <= min) {
369        $(textAreaSelector).attr('rows', max);
[22183]370        $(buttonSelector).text(fnT('j_site_011'));
[19914]371    } else {
372        $(textAreaSelector).attr('rows', min);
[22183]373        $(buttonSelector).text(fnT('j_site_012'));
[19914]374    }
[19712]375}
Note: See TracBrowser for help on using the repository browser.