1 | /* |
---|
2 | * This file is part of EC-CUBE |
---|
3 | * |
---|
4 | * Copyright(c) 2000-2013 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 | |
---|
23 | // セレクトボックスに項目を割り当てる. |
---|
24 | function fnSetSelect(name1, name2, val) { |
---|
25 | sele1 = document.form1[name1]; |
---|
26 | sele2 = document.form1[name2]; |
---|
27 | |
---|
28 | if(sele1 && sele2) { |
---|
29 | index=sele1.selectedIndex; |
---|
30 | |
---|
31 | // セレクトボックスのクリア |
---|
32 | count=sele2.options.length |
---|
33 | for(i = count; i >= 0; i--) { |
---|
34 | sele2.options[i]=null; |
---|
35 | } |
---|
36 | |
---|
37 | // セレクトボックスに値を割り当てる。 |
---|
38 | len = lists[index].length |
---|
39 | for(i = 0; i < len; i++) { |
---|
40 | sele2.options[i]=new Option(lists[index][i], vals[index][i]); |
---|
41 | if(val != "" && vals[index][i] == val) { |
---|
42 | sele2.options[i].selected = true; |
---|
43 | } |
---|
44 | } |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | // モードとキーを指定してSUBMITを行う。 |
---|
49 | function fnModeSubmit(mode, keyname, keyid) { |
---|
50 | switch(mode) { |
---|
51 | case 'delete_category': |
---|
52 | if(!window.confirm('選択したカテゴリとカテゴリ内の全てのカテゴリを削除します')){ |
---|
53 | return; |
---|
54 | } |
---|
55 | break; |
---|
56 | case 'delete': |
---|
57 | if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){ |
---|
58 | return; |
---|
59 | } |
---|
60 | break; |
---|
61 | case 'confirm': |
---|
62 | if(!window.confirm('登録しても宜しいですか')){ |
---|
63 | return; |
---|
64 | } |
---|
65 | break; |
---|
66 | case 'delete_all': |
---|
67 | if(!window.confirm('検索結果を全て削除しても宜しいですか')){ |
---|
68 | return; |
---|
69 | } |
---|
70 | break; |
---|
71 | default: |
---|
72 | break; |
---|
73 | } |
---|
74 | document.form1['mode'].value = mode; |
---|
75 | if(keyname != "" && keyid != "") { |
---|
76 | document.form1[keyname].value = keyid; |
---|
77 | } |
---|
78 | document.form1.submit(); |
---|
79 | } |
---|
80 | |
---|
81 | function fnFormModeSubmit(form, mode, keyname, keyid) { |
---|
82 | switch(mode) { |
---|
83 | case 'delete': |
---|
84 | if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){ |
---|
85 | return; |
---|
86 | } |
---|
87 | break; |
---|
88 | case 'confirm': |
---|
89 | if(!window.confirm('登録しても宜しいですか')){ |
---|
90 | return; |
---|
91 | } |
---|
92 | break; |
---|
93 | case 'regist': |
---|
94 | if(!window.confirm('登録しても宜しいですか')){ |
---|
95 | return; |
---|
96 | } |
---|
97 | break; |
---|
98 | default: |
---|
99 | break; |
---|
100 | } |
---|
101 | document.forms[form]['mode'].value = mode; |
---|
102 | if(keyname != "" && keyid != "") { |
---|
103 | document.forms[form][keyname].value = keyid; |
---|
104 | } |
---|
105 | document.forms[form].submit(); |
---|
106 | } |
---|
107 | |
---|
108 | function fnSetFormSubmit(form, key, val) { |
---|
109 | document.forms[form][key].value = val; |
---|
110 | document.forms[form].submit(); |
---|
111 | return false; |
---|
112 | } |
---|
113 | |
---|
114 | function fnSetVal(key, val) { |
---|
115 | fnSetFormVal('form1', key, val); |
---|
116 | } |
---|
117 | |
---|
118 | function fnSetFormVal(form, key, val) { |
---|
119 | document.forms[form][key].value = val; |
---|
120 | } |
---|
121 | |
---|
122 | function fnChangeAction(url) { |
---|
123 | document.form1.action = url; |
---|
124 | } |
---|
125 | |
---|
126 | // ページナビで使用する。 |
---|
127 | function fnNaviPage(pageno) { |
---|
128 | document.form1['pageno'].value = pageno; |
---|
129 | document.form1.submit(); |
---|
130 | } |
---|
131 | |
---|
132 | function fnSearchPageNavi(pageno) { |
---|
133 | document.form1['pageno'].value = pageno; |
---|
134 | document.form1['mode'].value = 'search'; |
---|
135 | document.form1.submit(); |
---|
136 | } |
---|
137 | |
---|
138 | function fnSubmit(){ |
---|
139 | document.form1.submit(); |
---|
140 | } |
---|
141 | |
---|
142 | // ポイント入力制限。 |
---|
143 | function fnCheckInputPoint() { |
---|
144 | if(document.form1['point_check']) { |
---|
145 | list = new Array( |
---|
146 | 'use_point' |
---|
147 | ); |
---|
148 | |
---|
149 | if(!document.form1['point_check'][0].checked) { |
---|
150 | color = "#dddddd"; |
---|
151 | flag = true; |
---|
152 | } else { |
---|
153 | color = ""; |
---|
154 | flag = false; |
---|
155 | } |
---|
156 | |
---|
157 | len = list.length |
---|
158 | for(i = 0; i < len; i++) { |
---|
159 | if(document.form1[list[i]]) { |
---|
160 | var current_color = document.form1[list[i]].style.backgroundColor; |
---|
161 | if (color != "#dddddd" && (current_color == "#ffe8e8" || current_color == "rgb(255, 232, 232)")) |
---|
162 | { |
---|
163 | continue; |
---|
164 | } |
---|
165 | document.form1[list[i]].disabled = flag; |
---|
166 | document.form1[list[i]].style.backgroundColor = color; |
---|
167 | } |
---|
168 | } |
---|
169 | } |
---|
170 | } |
---|
171 | |
---|
172 | // 別のお届け先入力制限。 |
---|
173 | function fnCheckInputDeliv() { |
---|
174 | if(!document.form1) { |
---|
175 | return; |
---|
176 | } |
---|
177 | if(document.form1['deliv_check']) { |
---|
178 | list = new Array( |
---|
179 | 'shipping_name01', |
---|
180 | 'shipping_name02', |
---|
181 | 'shipping_kana01', |
---|
182 | 'shipping_kana02', |
---|
183 | 'shipping_pref', |
---|
184 | 'shipping_zip01', |
---|
185 | 'shipping_zip02', |
---|
186 | 'shipping_addr01', |
---|
187 | 'shipping_addr02', |
---|
188 | 'shipping_tel01', |
---|
189 | 'shipping_tel02', |
---|
190 | 'shipping_tel03' |
---|
191 | ); |
---|
192 | |
---|
193 | if(!document.form1['deliv_check'].checked) { |
---|
194 | fnChangeDisabled(list, '#dddddd'); |
---|
195 | } else { |
---|
196 | fnChangeDisabled(list, ''); |
---|
197 | } |
---|
198 | } |
---|
199 | } |
---|
200 | |
---|
201 | // 最初に設定されていた色を保存しておく。 |
---|
202 | var g_savecolor = []; |
---|
203 | |
---|
204 | function fnChangeDisabled(list, color) { |
---|
205 | len = list.length; |
---|
206 | |
---|
207 | for(i = 0; i < len; i++) { |
---|
208 | if(document.form1[list[i]]) { |
---|
209 | if(color == "") { |
---|
210 | // 有効にする。 |
---|
211 | document.form1[list[i]].disabled = false; |
---|
212 | document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]]; |
---|
213 | } else { |
---|
214 | // 無効にする。 |
---|
215 | document.form1[list[i]].disabled = true; |
---|
216 | g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor; |
---|
217 | document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0"; |
---|
218 | } |
---|
219 | } |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | // ログイン時の入力チェック |
---|
224 | function fnCheckLogin(formname) { |
---|
225 | var lstitem = []; |
---|
226 | |
---|
227 | lstitem[0] = 'login_email'; |
---|
228 | lstitem[1] = 'login_pass'; |
---|
229 | |
---|
230 | var max = lstitem.length; |
---|
231 | var errflg = false; |
---|
232 | var cnt = 0; |
---|
233 | |
---|
234 | // 必須項目のチェック |
---|
235 | for(cnt = 0; cnt < max; cnt++) { |
---|
236 | if(document.forms[formname][lstitem[cnt]].value == "") { |
---|
237 | errflg = true; |
---|
238 | break; |
---|
239 | } |
---|
240 | } |
---|
241 | |
---|
242 | // 必須項目が入力されていない場合 |
---|
243 | if(errflg == true) { |
---|
244 | alert('メールアドレス/パスワードを入力して下さい。'); |
---|
245 | return false; |
---|
246 | } else { |
---|
247 | return true; |
---|
248 | } |
---|
249 | } |
---|
250 | |
---|
251 | start_time = new Date(); |
---|
252 | |
---|
253 | //親ウィンドウのページを変更する. |
---|
254 | function fnUpdateParent(url) { |
---|
255 | // 親ウィンドウの存在確認 |
---|
256 | if(eccube.common.isOpener()) { |
---|
257 | window.opener.location.href = url; |
---|
258 | } else { |
---|
259 | window.close(); |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | //文字数をカウントする。 |
---|
264 | //引数1:フォーム名称 |
---|
265 | //引数2:文字数カウント対象 |
---|
266 | //引数3:カウント結果格納対象 |
---|
267 | function fnCharCount(form,sch,cnt) { |
---|
268 | document.forms[form][cnt].value= document.forms[form][sch].value.length; |
---|
269 | } |
---|
270 | |
---|
271 | // テキストエリアのサイズを変更する. |
---|
272 | function ChangeSize(buttonSelector, textAreaSelector, max, min) { |
---|
273 | if ($(textAreaSelector).attr('rows') <= min) { |
---|
274 | $(textAreaSelector).attr('rows', max); |
---|
275 | $(buttonSelector).text('縮小'); |
---|
276 | } else { |
---|
277 | $(textAreaSelector).attr('rows', min); |
---|
278 | $(buttonSelector).text('拡大'); |
---|
279 | } |
---|
280 | } |
---|
281 | |
---|
282 | $(function() { |
---|
283 | // 規格1選択時 |
---|
284 | $('select[name=classcategory_id1]') |
---|
285 | .change(function() { |
---|
286 | var $form = $(this).parents('form'); |
---|
287 | var product_id = $form.find('input[name=product_id]').val(); |
---|
288 | var $sele1 = $(this); |
---|
289 | var $sele2 = $form.find('select[name=classcategory_id2]'); |
---|
290 | |
---|
291 | // 規格1のみの場合 |
---|
292 | if (!$sele2.length) { |
---|
293 | checkStock($form, product_id, $sele1.val(), '0'); |
---|
294 | // 規格2ありの場合 |
---|
295 | } else { |
---|
296 | setClassCategories($form, product_id, $sele1, $sele2); |
---|
297 | } |
---|
298 | }); |
---|
299 | |
---|
300 | // 規格2選択時 |
---|
301 | $('select[name=classcategory_id2]') |
---|
302 | .change(function() { |
---|
303 | var $form = $(this).parents('form'); |
---|
304 | var product_id = $form.find('input[name=product_id]').val(); |
---|
305 | var $sele1 = $form.find('select[name=classcategory_id1]'); |
---|
306 | var $sele2 = $(this); |
---|
307 | checkStock($form, product_id, $sele1.val(), $sele2.val()); |
---|
308 | }); |
---|
309 | }); |
---|
310 | /** |
---|
311 | * 規格2のプルダウンを設定する. |
---|
312 | */ |
---|
313 | function setClassCategories($form, product_id, $sele1, $sele2, selected_id2) { |
---|
314 | if ($sele1 && $sele1.length) { |
---|
315 | var classcat_id1 = $sele1.val() ? $sele1.val() : ''; |
---|
316 | if ($sele2 && $sele2.length) { |
---|
317 | // 規格2の選択肢をクリア |
---|
318 | $sele2.children().remove(); |
---|
319 | |
---|
320 | var classcat2; |
---|
321 | |
---|
322 | // 商品一覧時 |
---|
323 | if (typeof productsClassCategories != 'undefined') { |
---|
324 | classcat2 = productsClassCategories[product_id][classcat_id1]; |
---|
325 | } |
---|
326 | // 詳細表示時 |
---|
327 | else { |
---|
328 | classcat2 = classCategories[classcat_id1]; |
---|
329 | } |
---|
330 | |
---|
331 | // 規格2の要素を設定 |
---|
332 | for (var key in classcat2) { |
---|
333 | var id = classcat2[key]['classcategory_id2']; |
---|
334 | var name = classcat2[key]['name']; |
---|
335 | var option = $('<option />').val(id ? id : '').text(name); |
---|
336 | if (id == selected_id2) { |
---|
337 | option.attr('selected', true); |
---|
338 | } |
---|
339 | $sele2.append(option); |
---|
340 | } |
---|
341 | checkStock($form, product_id, $sele1.val() ? $sele1.val() : '__unselected2', |
---|
342 | $sele2.val() ? $sele2.val() : ''); |
---|
343 | } |
---|
344 | } |
---|
345 | } |
---|
346 | |
---|
347 | /** |
---|
348 | * 規格の選択状態に応じて, フィールドを設定する. |
---|
349 | */ |
---|
350 | function checkStock($form, product_id, classcat_id1, classcat_id2) { |
---|
351 | |
---|
352 | classcat_id2 = classcat_id2 ? classcat_id2 : ''; |
---|
353 | |
---|
354 | var classcat2; |
---|
355 | |
---|
356 | // 商品一覧時 |
---|
357 | if (typeof productsClassCategories != 'undefined') { |
---|
358 | classcat2 = productsClassCategories[product_id][classcat_id1]['#' + classcat_id2]; |
---|
359 | } |
---|
360 | // 詳細表示時 |
---|
361 | else { |
---|
362 | classcat2 = classCategories[classcat_id1]['#' + classcat_id2]; |
---|
363 | } |
---|
364 | |
---|
365 | // 商品コード |
---|
366 | var $product_code_default = $form.find('[id^=product_code_default]'); |
---|
367 | var $product_code_dynamic = $form.find('[id^=product_code_dynamic]'); |
---|
368 | if (classcat2 |
---|
369 | && typeof classcat2['product_code'] != 'undefined') { |
---|
370 | $product_code_default.hide(); |
---|
371 | $product_code_dynamic.show(); |
---|
372 | $product_code_dynamic.text(classcat2['product_code']); |
---|
373 | } else { |
---|
374 | $product_code_default.show(); |
---|
375 | $product_code_dynamic.hide(); |
---|
376 | } |
---|
377 | |
---|
378 | // 在庫(品切れ) |
---|
379 | var $cartbtn_default = $form.find('[id^=cartbtn_default]'); |
---|
380 | var $cartbtn_dynamic = $form.find('[id^=cartbtn_dynamic]'); |
---|
381 | if (classcat2 && classcat2['stock_find'] === false) { |
---|
382 | |
---|
383 | $cartbtn_dynamic.text('申し訳ございませんが、只今品切れ中です。').show(); |
---|
384 | $cartbtn_default.hide(); |
---|
385 | } else { |
---|
386 | $cartbtn_dynamic.hide(); |
---|
387 | $cartbtn_default.show(); |
---|
388 | } |
---|
389 | |
---|
390 | // 通常価格 |
---|
391 | var $price01_default = $form.find('[id^=price01_default]'); |
---|
392 | var $price01_dynamic = $form.find('[id^=price01_dynamic]'); |
---|
393 | if (classcat2 |
---|
394 | && typeof classcat2['price01'] != 'undefined' |
---|
395 | && String(classcat2['price01']).length >= 1) { |
---|
396 | |
---|
397 | $price01_dynamic.text(classcat2['price01']).show(); |
---|
398 | $price01_default.hide(); |
---|
399 | } else { |
---|
400 | $price01_dynamic.hide(); |
---|
401 | $price01_default.show(); |
---|
402 | } |
---|
403 | |
---|
404 | // 販売価格 |
---|
405 | var $price02_default = $form.find('[id^=price02_default]'); |
---|
406 | var $price02_dynamic = $form.find('[id^=price02_dynamic]'); |
---|
407 | if (classcat2 |
---|
408 | && typeof classcat2['price02'] != 'undefined' |
---|
409 | && String(classcat2['price02']).length >= 1) { |
---|
410 | |
---|
411 | $price02_dynamic.text(classcat2['price02']).show(); |
---|
412 | $price02_default.hide(); |
---|
413 | } else { |
---|
414 | $price02_dynamic.hide(); |
---|
415 | $price02_default.show(); |
---|
416 | } |
---|
417 | |
---|
418 | // ポイント |
---|
419 | var $point_default = $form.find('[id^=point_default]'); |
---|
420 | var $point_dynamic = $form.find('[id^=point_dynamic]'); |
---|
421 | if (classcat2 |
---|
422 | && typeof classcat2['point'] != 'undefined' |
---|
423 | && String(classcat2['point']).length >= 1) { |
---|
424 | |
---|
425 | $point_dynamic.text(classcat2['point']).show(); |
---|
426 | $point_default.hide(); |
---|
427 | } else { |
---|
428 | $point_dynamic.hide(); |
---|
429 | $point_default.show(); |
---|
430 | } |
---|
431 | |
---|
432 | // 商品規格 |
---|
433 | var $product_class_id_dynamic = $form.find('[id^=product_class_id]'); |
---|
434 | if (classcat2 |
---|
435 | && typeof classcat2['product_class_id'] != 'undefined' |
---|
436 | && String(classcat2['product_class_id']).length >= 1) { |
---|
437 | |
---|
438 | $product_class_id_dynamic.val(classcat2['product_class_id']); |
---|
439 | } else { |
---|
440 | $product_class_id_dynamic.val(''); |
---|
441 | } |
---|
442 | } |
---|
443 | |
---|
444 | (function( window, undefined ){ |
---|
445 | |
---|
446 | var common = {}; |
---|
447 | |
---|
448 | common.win01 = function(URL,Winname,Wwidth,Wheight){ |
---|
449 | var WIN; |
---|
450 | WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=no,resizable=no,toolbar=no,location=no,directories=no,status=no"); |
---|
451 | WIN.focus(); |
---|
452 | }; |
---|
453 | |
---|
454 | common.win02 = function(URL,Winname,Wwidth,Wheight){ |
---|
455 | var WIN; |
---|
456 | WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no"); |
---|
457 | WIN.focus(); |
---|
458 | }; |
---|
459 | |
---|
460 | common.win03 = function(URL,Winname,Wwidth,Wheight){ |
---|
461 | var WIN; |
---|
462 | WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no"); |
---|
463 | WIN.focus(); |
---|
464 | }; |
---|
465 | |
---|
466 | common.winSubmit = function(URL,formName,Winname,Wwidth,Wheight){ |
---|
467 | var WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no"); |
---|
468 | document.forms[formName].target = Winname; |
---|
469 | WIN.focus(); |
---|
470 | }; |
---|
471 | |
---|
472 | common.openWindow = function(URL,name,width,height) { |
---|
473 | window.open(URL,name,"width="+width+",height="+height+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=no"); |
---|
474 | }; |
---|
475 | |
---|
476 | // 親ウィンドウの存在確認. |
---|
477 | common.isOpener = function() { |
---|
478 | var ua = navigator.userAgent; |
---|
479 | if( !!window.opener ) { |
---|
480 | if( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) { |
---|
481 | return !window.opener.closed; |
---|
482 | } else { |
---|
483 | return typeof window.opener.document == 'object'; |
---|
484 | } |
---|
485 | } else { |
---|
486 | return false; |
---|
487 | } |
---|
488 | }; |
---|
489 | |
---|
490 | common.chgImg = function(fileName,img){ |
---|
491 | if (typeof(img) == "object") { |
---|
492 | img.src = fileName; |
---|
493 | } else { |
---|
494 | document.images[img].src = fileName; |
---|
495 | } |
---|
496 | }; |
---|
497 | |
---|
498 | common.chgImgImageSubmit = function(fileName,imgObj){ |
---|
499 | imgObj.src = fileName; |
---|
500 | }; |
---|
501 | |
---|
502 | // 郵便番号入力呼び出し. |
---|
503 | common.getAddress = function(php_url, tagname1, tagname2, input1, input2) { |
---|
504 | var zip1 = document.form1[tagname1].value; |
---|
505 | var zip2 = document.form1[tagname2].value; |
---|
506 | |
---|
507 | if(zip1.length == 3 && zip2.length == 4) { |
---|
508 | $.get( |
---|
509 | php_url, |
---|
510 | {zip1: zip1, zip2: zip2, input1: input1, input2: input2}, |
---|
511 | function(data) { |
---|
512 | var arrData = data.split("|"); |
---|
513 | if (arrData.length > 1) { |
---|
514 | eccube.common.putAddress(input1, input2, arrData[0], arrData[1], arrData[2]); |
---|
515 | } else { |
---|
516 | alert(data); |
---|
517 | } |
---|
518 | } |
---|
519 | ); |
---|
520 | } else { |
---|
521 | alert("郵便番号を正しく入力して下さい。"); |
---|
522 | } |
---|
523 | }; |
---|
524 | |
---|
525 | // 郵便番号から検索した住所を渡す. |
---|
526 | common.putAddress = function(input1, input2, state, city, town) { |
---|
527 | if(state != "") { |
---|
528 | // 項目に値を入力する. |
---|
529 | document.form1[input1].selectedIndex = state; |
---|
530 | document.form1[input2].value = city + town; |
---|
531 | } |
---|
532 | }; |
---|
533 | |
---|
534 | common.setFocus = function(name) { |
---|
535 | if(document.form1[name]) { |
---|
536 | document.form1[name].focus(); |
---|
537 | } |
---|
538 | }; |
---|
539 | |
---|
540 | // 名前空間の重複を防ぐ |
---|
541 | if (window.eccube === undefined) { |
---|
542 | window.eccube = {}; |
---|
543 | } |
---|
544 | // グローバルに使用できるようにする |
---|
545 | window.eccube.common = common; |
---|
546 | })(window); |
---|
547 | |
---|