source: tmp/version-2_5-test/html/user_data/packages/default/js/site.js @ 18609

Revision 18609, 10.1 KB checked in by kajiwara, 14 years ago (diff)

正式版にナイトリービルド版をマージしてみるテスト

Line 
1/*
2 * This file is part of EC-CUBE
3 *
4 * Copyright(c) 2000-2007 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 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 {
55        alert("郵便番号を正しく入力して下さい。");
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) {
69    window.open(URL,"nomenu","scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
70}
71
72function fnOpenWindow(URL,name,width,height) {
73    window.open(URL,name,"width="+width+",height="+height+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=no");
74}
75
76function fnSetFocus(name) {
77    if(document.form1[name]) {
78        document.form1[name].focus();
79    }
80}
81
82// セレクトボックスに項目を割り当てる.
83function fnSetSelect(name1, name2, val) {
84    sele1 = document.form1[name1];
85    sele2 = document.form1[name2];
86
87    if(sele1 && sele2) {
88        index=sele1.selectedIndex;
89
90        // セレクトボックスのクリア
91        count=sele2.options.length
92        for(i = count; i >= 0; i--) {
93            sele2.options[i]=null;
94        }
95
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    }
105}
106
107// Enterキー入力をキャンセルする。(IEに対応)
108function fnCancelEnter()
109{
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;
117}
118
119// モードとキーを指定してSUBMITを行う。
120function fnModeSubmit(mode, keyname, keyid) {
121    switch(mode) {
122    case 'delete_category':
123        if(!window.confirm('選択したカテゴリとカテゴリ内のすべてのカテゴリを削除します')){
124            return;
125        }
126        break;
127    case 'delete':
128        if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){
129            return;
130        }
131        break;
132    case 'confirm':
133        if(!window.confirm('登録しても宜しいですか')){
134            return;
135        }
136        break;
137    case 'delete_all':
138        if(!window.confirm('検索結果をすべて削除しても宜しいですか')){
139            return;
140        }
141        break;
142    default:
143        break;
144    }
145    document.form1['mode'].value = mode;
146    if(keyname != "" && keyid != "") {
147        document.form1[keyname].value = keyid;
148    }
149    document.form1.submit();
150}
151
152function fnFormModeSubmit(form, mode, keyname, keyid) {
153    switch(mode) {
154    case 'delete':
155        if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){
156            return;
157        }
158        break;
159    case 'confirm':
160        if(!window.confirm('登録しても宜しいですか')){
161            return;
162        }
163        break;
164    case 'regist':
165        if(!window.confirm('登録しても宜しいですか')){
166            return;
167        }
168        break;
169    default:
170        break;
171    }
172    document.forms[form]['mode'].value = mode;
173    if(keyname != "" && keyid != "") {
174        document.forms[form][keyname].value = keyid;
175    }
176    document.forms[form].submit();
177}
178
179function fnSetFormSubmit(form, key, val) {
180    document.forms[form][key].value = val;
181    document.forms[form].submit();
182    return false;
183}
184
185function fnSetVal(key, val) {
186    fnSetFormVal('form1', key, val);
187}
188
189function fnSetFormVal(form, key, val) {
190    document.forms[form][key].value = val;
191}
192
193function fnChangeAction(url) {
194    document.form1.action = url;
195}
196
197// ページナビで使用する。
198function fnNaviPage(pageno) {
199    document.form1['pageno'].value = pageno;
200    document.form1.submit();
201}
202
203function fnSearchPageNavi(pageno) {
204    document.form1['pageno'].value = pageno;
205    document.form1['mode'].value = 'search';
206    document.form1.submit();
207    }
208
209function fnSubmit(){
210    document.form1.submit();
211}
212
213// ポイント入力制限。
214function fnCheckInputPoint() {
215    if(document.form1['point_check']) {
216        list = new Array(
217                        'use_point'
218                        );
219
220        if(!document.form1['point_check'][0].checked) {
221            color = "#dddddd";
222            flag = true;
223        } else {
224            color = "";
225            flag = false;
226        }
227
228        len = list.length
229        for(i = 0; i < len; i++) {
230            if(document.form1[list[i]]) {
231                document.form1[list[i]].disabled = flag;
232                document.form1[list[i]].style.backgroundColor = color;
233            }
234        }
235    }
236}
237
238// 別のお届け先入力制限。
239function fnCheckInputDeliv() {
240    if(!document.form1) {
241        return;
242    }
243    if(document.form1['deliv_check']) {
244        list = new Array(
245                        'deliv_name01',
246                        'deliv_name02',
247                        'deliv_kana01',
248                        'deliv_kana02',
249                        'deliv_pref',
250                        'deliv_zip01',
251                        'deliv_zip02',
252                        'deliv_addr01',
253                        'deliv_addr02',
254                        'deliv_tel01',
255                        'deliv_tel02',
256                        'deliv_tel03'
257                        );
258
259        if(!document.form1['deliv_check'].checked) {
260            fnChangeDisabled(list, '#dddddd');
261        } else {
262            fnChangeDisabled(list, '');
263        }
264    }
265}
266
267// 最初に設定されていた色を保存しておく。
268var g_savecolor = new Array();
269
270function fnChangeDisabled(list, color) {
271    len = list.length;
272
273    for(i = 0; i < len; i++) {
274        if(document.form1[list[i]]) {
275            if(color == "") {
276                // 有効にする。
277                document.form1[list[i]].disabled = false;
278                document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]];
279            } else {
280                // 無効にする。
281                document.form1[list[i]].disabled = true;
282                g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor;
283                document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0";
284            }
285        }
286    }
287}
288
289
290// ログイン時の入力チェック
291function fnCheckLogin(formname) {
292    var lstitem = new Array();
293
294    if(formname == 'login_mypage'){
295    lstitem[0] = 'mypage_login_email';
296    lstitem[1] = 'mypage_login_pass';
297    }else{
298    lstitem[0] = 'login_email';
299    lstitem[1] = 'login_pass';
300    }
301    var max = lstitem.length;
302    var errflg = false;
303    var cnt = 0;
304
305    // 必須項目のチェック
306    for(cnt = 0; cnt < max; cnt++) {
307        if(document.forms[formname][lstitem[cnt]].value == "") {
308            errflg = true;
309            break;
310        }
311    }
312
313    // 必須項目が入力されていない場合
314    if(errflg == true) {
315        alert('メールアドレス/パスワードを入力して下さい。');
316        return false;
317    }
318}
319
320// 時間の計測.
321function fnPassTime(){
322    end_time = new Date();
323    time = end_time.getTime() - start_time.getTime();
324    alert((time/1000));
325}
326start_time = new Date();
327
328//親ウィンドウのページを変更する.
329function fnUpdateParent(url) {
330    // 親ウィンドウの存在確認
331    if(fnIsopener()) {
332        window.opener.location.href = url;
333    } else {
334        window.close();
335    }
336}
337
338//特定のキーをSUBMITする.
339function fnKeySubmit(keyname, keyid) {
340    if(keyname != "" && keyid != "") {
341        document.form1[keyname].value = keyid;
342    }
343    document.form1.submit();
344}
345
346//文字数をカウントする。
347//引数1:フォーム名称
348//引数2:文字数カウント対象
349//引数3:カウント結果格納対象
350function fnCharCount(form,sch,cnt) {
351    document.forms[form][cnt].value= document.forms[form][sch].value.length;
352}
353
354
355// テキストエリアのサイズを変更する.
356function ChangeSize(button, TextArea, Max, Min, row_tmp){
357
358    if(TextArea.rows <= Min){
359        TextArea.rows=Max; button.value="小さくする"; row_tmp.value=Max;
360    }else{
361        TextArea.rows =Min; button.value="大きくする"; row_tmp.value=Min;
362    }
363}
364
365// お届け時間のリアル反映
366function fnSetDelivTime(mode, r_key, s_id) {
367    var f_key, f_val;
368    var f_cnt = document.form1.length;
369    var f_data = "mode=" + mode;
370
371    // formデータの形成
372    for (i = 0; i < f_cnt; i++) {
373        f_key = document.form1[i].name;
374        f_val = document.form1[i].value;
375        if (f_key != "mode") {
376            if (f_key == r_key) {
377                if (document.form1[i].checked === true) {
378                    f_data += "&" + f_key + "=" + f_val;
379                }
380            } else {
381                f_data += "&" + f_key + "=" + f_val;
382            }
383        }
384    }
385
386    // AJAX
387    $.ajax({
388        type: "POST",
389        url: document.form1.action,
390        data: f_data,
391        dataType: "json",
392        success: function(data) {
393            var elm_s = "select#" + s_id;
394            var elm_o = elm_s + " option";
395            $(elm_o).remove();
396            $(elm_s).append($('<option>').attr({value: ""}).text("指定なし"));
397            for (i = 0; i < data.length; i++) {
398                if (data[i].time_id > 0) {
399                    $(elm_s).append($('<option>').attr({value: data[i].time_id}).text(data[i].deliv_time));
400                    $(elm_s).width();
401                }
402            }
403        }
404    });
405}
Note: See TracBrowser for help on using the repository browser.