source: branches/version-2_12-dev/html/js/site.js @ 21867

Revision 21867, 10.7 KB checked in by nakanishi, 12 years ago (diff)

#1831 Copyright Update

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
Line 
1/*
2 * This file is part of EC-CUBE
3 *
4 * Copyright(c) 2000-2012 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                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                }
242                document.form1[list[i]].disabled = flag;
243                document.form1[list[i]].style.backgroundColor = color;
244            }
245        }
246    }
247}
248
249// 別のお届け先入力制限。
250function fnCheckInputDeliv() {
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',
263                        'shipping_addr01',
264                        'shipping_addr02',
265                        'shipping_tel01',
266                        'shipping_tel02',
267                        'shipping_tel03'
268                        );
269
270        if(!document.form1['deliv_check'].checked) {
271            fnChangeDisabled(list, '#dddddd');
272        } else {
273            fnChangeDisabled(list, '');
274        }
275    }
276}
277
278// 最初に設定されていた色を保存しておく。
279var g_savecolor = new Array();
280
281function fnChangeDisabled(list, color) {
282    len = list.length;
283
284    for(i = 0; i < len; i++) {
285        if(document.form1[list[i]]) {
286            if(color == "") {
287                // 有効にする。
288                document.form1[list[i]].disabled = false;
289                document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]];
290            } else {
291                // 無効にする。
292                document.form1[list[i]].disabled = true;
293                g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor;
294                document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0";
295            }
296        }
297    }
298}
299
300
301// ログイン時の入力チェック
302function fnCheckLogin(formname) {
303    var lstitem = new Array();
304
305    if(formname == 'login_mypage'){
306    lstitem[0] = 'mypage_login_email';
307    lstitem[1] = 'mypage_login_pass';
308    }else{
309    lstitem[0] = 'login_email';
310    lstitem[1] = 'login_pass';
311    }
312    var max = lstitem.length;
313    var errflg = false;
314    var cnt = 0;
315
316    // 必須項目のチェック
317    for(cnt = 0; cnt < max; cnt++) {
318        if(document.forms[formname][lstitem[cnt]].value == "") {
319            errflg = true;
320            break;
321        }
322    }
323
324    // 必須項目が入力されていない場合
325    if(errflg == true) {
326        alert('メールアドレス/パスワードを入力して下さい。');
327        return false;
328    }
329}
330
331// 時間の計測.
332function fnPassTime(){
333    end_time = new Date();
334    time = end_time.getTime() - start_time.getTime();
335    alert((time/1000));
336}
337start_time = new Date();
338
339//親ウィンドウのページを変更する.
340function fnUpdateParent(url) {
341    // 親ウィンドウの存在確認
342    if(fnIsopener()) {
343        window.opener.location.href = url;
344    } else {
345        window.close();
346    }
347}
348
349//特定のキーをSUBMITする.
350function fnKeySubmit(keyname, keyid) {
351    if(keyname != "" && keyid != "") {
352        document.form1[keyname].value = keyid;
353    }
354    document.form1.submit();
355}
356
357//文字数をカウントする。
358//引数1:フォーム名称
359//引数2:文字数カウント対象
360//引数3:カウント結果格納対象
361function fnCharCount(form,sch,cnt) {
362    document.forms[form][cnt].value= document.forms[form][sch].value.length;
363}
364
365
366// テキストエリアのサイズを変更する.
367function ChangeSize(buttonSelector, textAreaSelector, max, min) {
368
369    if ($(textAreaSelector).attr('rows') <= min) {
370        $(textAreaSelector).attr('rows', max);
371        $(buttonSelector).text('縮小');
372    } else {
373        $(textAreaSelector).attr('rows', min);
374        $(buttonSelector).text('拡大');
375    }
376}
Note: See TracBrowser for help on using the repository browser.