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