source: branches/version-2_5-dev/html/js/site.js @ 19914

Revision 19914, 9.2 KB checked in by nanasess, 13 years ago (diff)

#382(管理画面XHTMLに変更)

  • 拡大/縮小ボタンが動作しなくなっていたのを修正
Line 
1/*
2 * This file is part of EC-CUBE
3 *
4 * Copyright(c) 2000-2010 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 'delete_order':
133        if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?\n\n※ 在庫数は手動で戻してください。')){
134            return;
135        }
136        mode = 'delete';
137        break;
138    case 'confirm':
139        if(!window.confirm('登録しても宜しいですか')){
140            return;
141        }
142        break;
143    case 'delete_all':
144        if(!window.confirm('検索結果をすべて削除しても宜しいですか')){
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();
156}
157
158function fnFormModeSubmit(form, mode, keyname, keyid) {
159    switch(mode) {
160    case 'delete':
161        if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){
162            return;
163        }
164        break;
165    case 'confirm':
166        if(!window.confirm('登録しても宜しいですか')){
167            return;
168        }
169        break;
170    case 'regist':
171        if(!window.confirm('登録しても宜しいですか')){
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();
183}
184
185function fnSetFormSubmit(form, key, val) {
186    document.forms[form][key].value = val;
187    document.forms[form].submit();
188    return false;
189}
190
191function fnSetVal(key, val) {
192    fnSetFormVal('form1', key, val);
193}
194
195function fnSetFormVal(form, key, val) {
196    document.forms[form][key].value = val;
197}
198
199function fnChangeAction(url) {
200    document.form1.action = url;
201}
202
203// ページナビで使用する。
204function fnNaviPage(pageno) {
205    document.form1['pageno'].value = pageno;
206    document.form1.submit();
207}
208
209function fnSearchPageNavi(pageno) {
210    document.form1['pageno'].value = pageno;
211    document.form1['mode'].value = 'search';
212    document.form1.submit();
213    }
214
215function fnSubmit(){
216    document.form1.submit();
217}
218
219// ポイント入力制限。
220function fnCheckInputPoint() {
221    if(document.form1['point_check']) {
222        list = new Array(
223                        'use_point'
224                        );
225
226        if(!document.form1['point_check'][0].checked) {
227            color = "#dddddd";
228            flag = true;
229        } else {
230            color = "";
231            flag = false;
232        }
233
234        len = list.length
235        for(i = 0; i < len; i++) {
236            if(document.form1[list[i]]) {
237                document.form1[list[i]].disabled = flag;
238                document.form1[list[i]].style.backgroundColor = color;
239            }
240        }
241    }
242}
243
244// 別のお届け先入力制限。
245function fnCheckInputDeliv() {
246    if(!document.form1) {
247        return;
248    }
249    if(document.form1['deliv_check']) {
250        list = new Array(
251                        'shipping_name01',
252                        'shipping_name02',
253                        'shipping_kana01',
254                        'shipping_kana02',
255                        'shipping_pref',
256                        'shipping_zip01',
257                        'shipping_zip02',
258                        'shipping_addr01',
259                        'shipping_addr02',
260                        'shipping_tel01',
261                        'shipping_tel02',
262                        'shipping_tel03'
263                        );
264
265        if(!document.form1['deliv_check'].checked) {
266            fnChangeDisabled(list, '#dddddd');
267        } else {
268            fnChangeDisabled(list, '');
269        }
270    }
271}
272
273// 最初に設定されていた色を保存しておく。
274var g_savecolor = new Array();
275
276function fnChangeDisabled(list, color) {
277    len = list.length;
278
279    for(i = 0; i < len; i++) {
280        if(document.form1[list[i]]) {
281            if(color == "") {
282                // 有効にする。
283                document.form1[list[i]].disabled = false;
284                document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]];
285            } else {
286                // 無効にする。
287                document.form1[list[i]].disabled = true;
288                g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor;
289                document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0";
290            }
291        }
292    }
293}
294
295
296// ログイン時の入力チェック
297function fnCheckLogin(formname) {
298    var lstitem = new Array();
299
300    if(formname == 'login_mypage'){
301    lstitem[0] = 'mypage_login_email';
302    lstitem[1] = 'mypage_login_pass';
303    }else{
304    lstitem[0] = 'login_email';
305    lstitem[1] = 'login_pass';
306    }
307    var max = lstitem.length;
308    var errflg = false;
309    var cnt = 0;
310
311    // 必須項目のチェック
312    for(cnt = 0; cnt < max; cnt++) {
313        if(document.forms[formname][lstitem[cnt]].value == "") {
314            errflg = true;
315            break;
316        }
317    }
318
319    // 必須項目が入力されていない場合
320    if(errflg == true) {
321        alert('メールアドレス/パスワードを入力して下さい。');
322        return false;
323    }
324}
325
326// 時間の計測.
327function fnPassTime(){
328    end_time = new Date();
329    time = end_time.getTime() - start_time.getTime();
330    alert((time/1000));
331}
332start_time = new Date();
333
334//親ウィンドウのページを変更する.
335function fnUpdateParent(url) {
336    // 親ウィンドウの存在確認
337    if(fnIsopener()) {
338        window.opener.location.href = url;
339    } else {
340        window.close();
341    }
342}
343
344//特定のキーをSUBMITする.
345function fnKeySubmit(keyname, keyid) {
346    if(keyname != "" && keyid != "") {
347        document.form1[keyname].value = keyid;
348    }
349    document.form1.submit();
350}
351
352//文字数をカウントする。
353//引数1:フォーム名称
354//引数2:文字数カウント対象
355//引数3:カウント結果格納対象
356function fnCharCount(form,sch,cnt) {
357    document.forms[form][cnt].value= document.forms[form][sch].value.length;
358}
359
360
361// テキストエリアのサイズを変更する.
362function ChangeSize(buttonSelector, textAreaSelector, max, min) {
363
364    if ($(textAreaSelector).attr('rows') <= min) {
365        $(textAreaSelector).attr('rows', max);
366        $(buttonSelector).text('縮小');
367    } else {
368        $(textAreaSelector).attr('rows', min);
369        $(buttonSelector).text('拡大');
370    }
371}
Note: See TracBrowser for help on using the repository browser.