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