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