1var Sys = jQuery.noConflict(true); 2 3/** 4 * ã¦ã¼ã¶ã¼ã¨ã¼ã¸ã§ã³ã 5 */ 6Sys.fn.userAgent = function(){ 7 return window.navigator.userAgent.toLowerCase(); 8}; 9 10Sys(document).ready(function() 11{ 12 // 屿§å¤ã®ãµãã¼ãç¢ºèª 13 var supportsInputAttribute = function (attr) { 14 var input = document.createElement('input'); 15 return attr in input; 16 }; 17 18 // placeholder 屿§ã®å¦ç 19 if(supportsInputAttribute('placeholder')){ 20 Sys(".placeholder").hide(); 21 } 22 23 Sys("form").submit(function(){ 24 // äºéæç¨¿é²æ¢ 25 Sys(this).find("input[type=submit]").attr("disabled","disabled"); 26 window.addEventListener('pageshow', (event) => { 27 if (event.persisted) { 28 const submitButton = this.querySelector("input[type=submit]"); 29 if (submitButton) { 30 submitButton.disabled = false; 31 } 32 } 33 }); 34 }); 35}); 36 37// æ©è½ãã¼ããä¼å¡ãã°ã¤ã³ãã®ãã§ãã¯ããã¯ã¹IDã®é£çªãæ¯ãç´ã 38(function () { 39 function assignAutoLoginIds() { 40 var containers = document.querySelectorAll('.sysFuncMemberLogin'); 41 containers.forEach(function (container, index) { 42 var checkbox = container.querySelector('input[id^="is_use_auto_login"]'); 43 if (!checkbox) { 44 return; 45 } 46 var newId = 'is_use_auto_login' + index; 47 if (checkbox.id !== newId) { 48 checkbox.id = newId; 49 } 50 container.querySelectorAll('label[for]').forEach(function (label) { 51 var currentFor = label.getAttribute('for'); 52 if (!currentFor || !/^is_use_auto_login\d*$/.test(currentFor)) { 53 return; 54 } 55 if (currentFor !== newId) { 56 label.setAttribute('for', newId); 57 } 58 }); 59 }); 60 } 61 62 function runAutoLoginIdAssignment() { 63 assignAutoLoginIds(); 64 } 65 66 window.ensureUniqueAutoLoginIds = function ensureUniqueAutoLoginIds() { 67 runAutoLoginIdAssignment(); 68 }; 69 70 if (document.readyState === 'loading') { 71 document.addEventListener('DOMContentLoaded', runAutoLoginIdAssignment); 72 } else { 73 runAutoLoginIdAssignment(); 74 } 75 76 window.addEventListener('onSysAsyncElementLoaded', runAutoLoginIdAssignment); 77})(); 78 79/** 80 * ã¢ã³ã¼ãã£ãªã³ 81 */ 82Sys(document).ready(function() 83{ 84 Sys(document).on('click', '.sysAccordion', function(){ 85 Sys(this).next().toggle(); 86 Sys(this).toggleClass('sysAccordionHide'); 87 }); 88}); 89 90/** 91 * ã«ã«ã¼ã»ã« 92 */ 93Sys(document).ready(function() 94{ 95 // å·¦å³ãã 96 Sys(".sysCarrouselCtl div:first").click(function(){ 97 var parent_left = Sys(".sysCarrousel").parent().offset().left; 98 var parent_width = Sys(".sysCarrousel").parent().width(); 99 var carrousel_left = Sys(".sysCarrousel").offset().left; 100 var carrousel_width = Sys(".sysCarrousel").width(); 101 if(carrousel_left != parent_left){ 102 var offset = "-=" + parent_width + "px"; 103 Sys(".sysCarrousel").animate({right: offset}); 104 } 105 }); 106 Sys(".sysCarrouselCtl div:last").click(function(){ 107 var parent_left = Sys(".sysCarrousel").parent().offset().left; 108 var parent_width = Sys(".sysCarrousel").parent().width(); 109 var carrousel_left = Sys(".sysCarrousel").offset().left; 110 var carrousel_width = Sys(".sysCarrousel").width(); 111 if(carrousel_left + carrousel_width != parent_width + parent_left){ 112 var offset = "+=" + parent_width + "px"; 113 Sys(".sysCarrousel").animate({right: offset}); 114 } 115 }); 116 window.onresize = function() { 117 Sys(".sysCarrousel").animate({right: "0px"}); 118 } 119 120 // ä¸å¤®ãã 121 Sys(".sysCarrousel div").each(function(){ 122 Sys(".sysCarrouselCtl div:nth-child(2)").append("â"); 123 }); 124}); 125 126/** 127 * ååä¸è¦§ã®è¡¨ç¤ºæ¹æ³åãæ¿ã 128 */ 129Sys(function () { 130 Sys(document).on('click', '.sysItemListDisp [name="view_type"]', function () { 131 changeViewType(Sys(this).val()); 132 Sys.cookie('item_list_view_type', Sys(this).val(), {secure:true, sameSite: "lax"}); 133 }); 134
135 var cookieViewType = Sys.cookie('item_list_view_type'); 136 changeViewType(cookieViewType); 137 Sys(".sysItemListDisp [name='view_type']").val([cookieViewType]); 138 139 function changeViewType(viewType) { 140 var target = Sys('.sysThumbnail, .sysList'); 141 target.removeClass('sysList'); 142 target.removeClass('sysThumbnail'); 143 target.addClass(viewType == '1' ? 'sysThumbnail' : 'sysList'); 144 } 145}); 146 147/** 148 * 使æ¤ç´¢ 149 */ 150Sys(function() { 151 var Driver = new Array(); 152 Driver.searchAddress = function(Event) { 153 var zipcode = Sys(Event.target).parents('form').find('input[name=zipcode]').val(); 154 if (zipcode.length == 7) { 155 Sys.post('/api/front/getAddressFromZipcode', { zipcode:zipcode }, function(data) { 156 var param = eval('('+data+')'); 157 if (param.pref_state_id == '' ) { 158 Sys('.SysInvalidZipcodeError').text('ç¡å¹ãªéµä¾¿çªå·ã§ãã'); 159 } 160 if (param.pref_state_id != '') { 161 Sys('[name=pref_state_id]').val(param.pref_state_id); 162 Sys('.SysInvalidZipcodeError').text(''); 163 } 164 if (param.address1 != '') { 165 Sys('[name=address1]').val(param.address1); 166 } 167 if (param.address2 != '') { 168 Sys('[name=address2]').val(param.address2); 169 } 170 }); 171 } 172 Event.stopPropagation(); 173 Event.preventDefault(); 174 }; 175 176 Sys('[name=searchAddress]').off('click'); 177 Sys('[name=searchAddress]').on('click', Driver.searchAddress); 178 179 Sys('[name=zipcode]').off('keyup'); 180 Sys('[name=zipcode]').on('keyup', Driver.searchAddress); 181 Sys('[name=zipcode]').on('input', Driver.searchAddress); 182}); 183 184/** 185 * ããªã¼ãã©ã¼ã å 使æ¤ç´¢ 186 */ 187Sys(function() { 188 var Driver = new Array(); 189 Driver.getAddress = function(Event) { 190 var zipcode = Sys('[name=getAddress]').siblings('input').val(); 191 if (zipcode.length == 7) { 192 Sys.post('/api/front/getAddressFromZipcode', { zipcode:zipcode }, function(data) { 193 var param = eval('('+data+')'); 194 if (param.pref_state_id != '') { 195 Sys('[name$="[item_type]"][value="pref"]').siblings('.sysFormField').children('select').val(param.pref_state_id); 196 } 197 if (param.address1 != '') { 198 Sys('[name$="[item_type]"][value="address1"]').siblings('.sysFormField').children('input').val(param.address1); 199 } 200 if (param.address2 != '') { 201 Sys('[name$="[item_type]"][value="address2"]').siblings('.sysFormField').children('input').val(param.address2); 202 } 203 }); 204 } 205 Event.stopPropagation(); 206 Event.preventDefault(); 207 }; 208 209 Sys('[name=getAddress]').off('click'); 210 Sys('[name=getAddress]').on('click', Driver.getAddress); 211 212 Sys('[name=getAddress]').siblings('input').off('keyup'); 213 Sys('[name=getAddress]').siblings('input').on('keyup', Driver.getAddress); 214 Sys('[name=getAddress]').siblings('input').on('input', Driver.getAddress); 215}); 216 217/** 218 * ããªã¼ãã©ã¼ã å ä¼ç¤¾ä½ææ¤ç´¢ 219 */ 220Sys(function() { 221 var Driver = new Array(); 222 Driver.getCompanyAddress = function(Event) { 223 var zipcode = Sys('[name=getCompanyAddress]').siblings('input').val(); 224 if (zipcode.length == 7) { 225 Sys.post('/api/front/getAddressFromZipcode', { zipcode:zipcode }, function(data) { 226 var param = eval('('+data+')'); 227 if (param.pref_state_id != '') { 228 Sys('[name$="[item_type]"][value="company_pref"]').siblings('.sysFormField').children('select').val(param.pref_state_id); 229 } 230 if (param.address1 != '') { 231 Sys('[name$="[item_type]"][value="company_address1"]').siblings('.sysFormField').children('input').val(param.address1); 232 } 233 if (param.address2 != '') { 234 Sys('[name$="[item_type]"][value="company_address2"]').siblings('.sysFormField').children('input').val(param.address2); 235 } 236 }); 237 } 238 Event.stopPropagation(); 239 Event.preventDefault(); 240 }; 241 242 Sys('[name=getCompanyAddress]').off('click'); 243 Sys('[name=getCompanyAddress]').on('click', Driver.getCompanyAddress); 244 245 Sys('[name=getCompanyAddress]').siblings('input').off('keyup'); 246 Sys('[name=getCompanyAddress]').siblings('input').on('keyup', Driver.getCompanyAddress); 247 Sys('[name=getCompanyAddress]').siblings('input').on('input', Driver.getCompanyAddress); 248}); 249 250/** 251 * ãã°ã¤ã³ç¶æ³ 252 * 253 * Sys().isMemberLogin() 254 */ 255Sys.fn.isMemberLogin = function(){ 256 if (Sys("body").is("[data-member-login='true']")) { 257 return true; 258 } else { 259 return false;
260 } 261}; 262 263/** 264 * åå詳細ãã¼ã¸ãååç»åï¼ãµã ãã¤ã«ï¼ 265 */ 266(function () { 267 const SELECTOR = 'img, video'; 268 const ItemImageList = { 269 init() { 270 // æåã®ç»åã»åç»ããµã ãã¤ã«ã¨ãã¦å¤§ãã表示 271 document.querySelectorAll('.sysImageList').forEach(list => { 272 const firstMedia = list.querySelector(SELECTOR); 273 if (firstMedia) { 274 ItemImageList.updateMain(firstMedia); 275 } 276 }); 277 }, 278 279 updateMain(current) { 280 if (!(current instanceof Element)) return; 281 282 const parent = current.closest('.sysItemImages'); 283 if (!parent) return; 284 285 parent.querySelectorAll('li.sysCurrent').forEach(li => li.classList.remove('sysCurrent')); 286 const p = current.parentElement; 287 if (p) p.classList.add('sysCurrent'); 288 289 const isVideo = current.tagName && current.tagName.toLowerCase() === 'video'; 290 const mainMedia = document.createElement(isVideo ? 'video' : 'img'); 291 const src = current.getAttribute('src') || ''; 292 const title = current.getAttribute('title') || ''; 293 const alt = current.getAttribute('alt') || current.getAttribute('aria-label') || ''; 294 const poster = current.getAttribute('poster') || ''; 295 296 // imgã»videoã¿ã°å ±éã®å±æ§å¯¾å¿ 297 if (src) mainMedia.setAttribute('src', src); 298 if (title) mainMedia.setAttribute('title', title); 299 if (!isVideo && alt) { 300 mainMedia.setAttribute('alt', alt); 301 } else if (isVideo && alt) { 302 mainMedia.setAttribute('aria-label', alt); 303 } 304 305 // videoã¿ã°ã®åç»åçã®å±æ§å¯¾å¿ 306 if (isVideo) { 307 mainMedia.muted = true; 308 mainMedia.playsInline = true; 309 mainMedia.autoplay = true; 310 mainMedia.loop = true; 311 mainMedia.preload = 'metadata'; 312 mainMedia.setAttribute('muted', ''); 313 mainMedia.setAttribute('playsinline', ''); 314 mainMedia.setAttribute('autoplay', ''); 315 mainMedia.setAttribute('loop', ''); 316 mainMedia.setAttribute('preload', 'metadata'); 317 // autoplayæã®ã¡ãã¤ãåé¿ã®ãããåæè¡¨ç¤ºã§ã¯posterãä»ä¸ããªã 318 319 // ããã©ã«ãã®åç»ã¿ã°ã®ã¤ãã³ããç¡è¦ãã¦è¦ªã®ã¤ãã³ããçºç« (ã¢ã¼ãã«ç»é¢è¡¨ç¤ºå¯¾å¿) 320 // ã³ã³ããã¼ã«æä½ãå¿ è¦ã«ãªã£ããå¤ãåæã®å¯¾å¿ã 321 mainMedia.style.pointerEvents = 'none'; 322 } 323 324 const a = document.createElement('a'); 325 if (src) a.setAttribute('href', src); 326 a.appendChild(mainMedia); 327 328 const mainWrap = parent.querySelector('.sysMainImage'); 329 if (mainWrap) { 330 mainWrap.replaceChildren(a); 331 if (isVideo) { 332 // appendå¾ã«ç¢ºå®ã«åçãéå§ 333 mainMedia.play().catch(function () { 334 // autoplayå¶éã§åç失æããå ´åã®ã¿posterãå¾ä»ããã¦é»ç»é¢ãé¿ãã 335 if (poster) { 336 mainMedia.setAttribute('poster', poster); 337 } 338 }); 339 } 340 } 341 342 const desc = parent.querySelector('.sysImageDescription'); 343 if (desc) { 344 desc.innerHTML = alt || ''; 345 } 346 } 347 }; 348 349 document.addEventListener('DOMContentLoaded', () => { 350 ItemImageList.init(); 351 352 document.addEventListener('click', (e) => { 353 const media = e.target.closest(`.sysImageList ${SELECTOR}`); 354 if (!media) return; 355 ItemImageList.updateMain(media); 356 }); 357 }); 358})(); 359 360/** 361 * åå詳細ãã¼ã¸ãããªã¨ã¼ã·ã§ã³ç»å â ãµã ãã¤ã«ï¼ã¡ã¤ã³ç»åã®é£ååæ¿ 362 * .sysImageList å ã®ãµã ãã¤ã«ãã¯ãªãã¯ãããå½¢ã§ãæ¢åã®é¸æç¶æ (sysCurrent)æ´æ°ã¨ 363 * ã¡ã¤ã³ç»åå·®æ¿ãåæã«è¡ããthumbnail 表示ã¡ã½ããã®å ´åã®ã
363¿åä½ããã 364 * - æãåããã¦è¡¨ç¤ºï¼ã«ã¼ããã¿ã³ONï¼è¡ã¯ãªãã¯ã§åæ¿ï¼ã«ã¼ãæå ¥æä½ã¯é¤ãï¼ 365 * - åé ç®ãåãã¦è¡¨ç¤ºï¼ç»åå´ã©ã¸ãªå¤æ´ã§åæ¿ãç»åæªè¨å®ã®é¸æè¢ã§å¾©å¸° 366 */ 367(function () { 368 const VariationMainImage = { 369 _defaultMedia: null, 370 _isShowingVariation: false, 371 372 _findThumbByPath(path) { 373 const list = document.querySelector('.sysImageList'); 374 if (!list) return null; 375 const items = list.querySelectorAll('li'); 376 for (const li of items) { 377 const media = li.querySelector('img, video'); 378 if (media && media.getAttribute('src') === path) { 379 return media; 380 } 381 } 382 return null; 383 }, 384 385 _captureDefault() { 386 const list = document.querySelector('.sysImageList'); 387 if (!list) return; 388 const currentLi = list.querySelector('li.sysCurrent'); 389 this._defaultMedia = currentLi ? currentLi.querySelector('img, video') : null; 390 }, 391 392 set(path) { 393 if (!path) return; 394 const matching = this._findThumbByPath(path); 395 if (!matching) return; 396 if (!this._isShowingVariation) { 397 this._captureDefault(); 398 this._isShowingVariation = true; 399 } 400 matching.click(); 401 }, 402 403 restore() { 404 if (!this._isShowingVariation) return; 405 if (this._defaultMedia) { 406 this._defaultMedia.click(); 407 } 408 this._isShowingVariation = false; 409 }, 410 }; 411 412 document.addEventListener('change', (e) => { 413 if (!(e.target instanceof Element)) return; 414 const radio = e.target.closest('input[type="radio"][data-variation-image-select="1"]'); 415 if (!radio) return; 416 const path = radio.getAttribute('data-variation-image-path'); 417 if (path) { 418 VariationMainImage.set(path); 419 } else { 420 VariationMainImage.restore(); 421 } 422 }); 423})(); 424 425/** 426 * åå詳細ãã¼ã¸ãããªã¨ã¼ã·ã§ã³ï¼åé ç®ãåãã¦è¡¨ç¤ºï¼ 427 * 428 * 鏿ä¸ã®é¸æè¢åãé ç®ã©ãã«æ¨ªï¼.sysVariationImageSelectLabelValueï¼ã«è¡¨ç¤ºããã 429 * ç»å鏿è¢ï¼ç»åã®ã¿ã§æåãæããªãï¼ã»ããã¹ãã«ã¼ãã©ã¡ãã®é¸æã«ã対å¿ã 430 * åæå¤ã¯ãµã¼ãå´ã§æç»æ¸ã¿ã®ãããããã§ã¯å¤æ´æã®æ´æ°ã®ã¿è¡ãã 431 */ 432(function () { 433 // åæ±ãªãçµã¿åããã®å¤å®ç¨ããããåå¾ããã 434 function getHandlingMap(root) { 435 if (root._variationHandlingMap !== undefined) { 436 return root._variationHandlingMap; 437 } 438 const raw = root.getAttribute('data-variation-handling-map') || '{}'; 439 try { 440 root._variationHandlingMap = JSON.parse(raw); 441 } catch (e) { 442 root._variationHandlingMap = {}; 443 } 444 return root._variationHandlingMap; 445 } 446 447 // çµã¿åãããã¨ã®å¨åº«åãå¤å®ç¨ããããåå¾ããã 448 function getStockMap(root) { 449 if (root._variationStockMap !== undefined) { 450 return root._variationStockMap; 451 } 452 const raw = root.getAttribute('data-variation-stock-map') || '{}'; 453 try { 454 root._variationStockMap = JSON.parse(raw); 455 } catch (e) { 456 root._variationStockMap = {}; 457 } 458 return root._variationStockMap; 459 } 460 461 // å¨åº«ãããã®å¤ããå¨åº«åããã表ãã¦ãããå¤å®ããã 462 function isSoldOutValue(value) { 463 return value === 1 || value === true || value === '1'; 464 } 465 466 // æå®ãããããªã¨ã¼ã·ã§ã³é ç®å ã§ç¾å¨é¸æããã¦ããradioãåå¾ããã 467 function getCheckedRadio(root, selectIndex) { 468 return root.querySelector('input[type="radio"][data-variation-select-index="' + selectIndex + '"]:checked'); 469 } 470 471 // æå®ãããããªã¨ã¼ã·ã§ã³é ç®ãç»é¢ä¸ã«åå¨ãããå¤å®ããã 472 function hasSelectIndex(root, selectIndex) { 473 return root.querySelector('input[type="radio"][data-variation-select-index="' + selectIndex + '"]') !== null; 474 } 475 476 // åæ±ãªããããã®å¤ããåæ±ãªããã表ãã¦ãããå¤å®ããã 477 function isNotHandledValue(value) { 478 return value === 1 || value === true || value === '1'; 479 } 480
481 // 対象radioã®é¸æè¢ããç¸æè»¸ã®ç¾å¨é¸æã«å¯¾ãã¦åæ±ãªãããå¤å®ããï¼ç¸æè»¸é£åã®æç·è¡¨ç¤ºã«ä½¿ãï¼ã 482 // å¨åº«åãï¼isCombinationOutOfStockï¼ã¨åããã¸ãã¯ã§ã鏿è¢èªä½ã¯é¸æå¯è½ãªã¾ã¾ã 483 function isCombinationNotHandled(root, radio) { 484 const map = getHandlingMap(root); 485 const selectIndex = radio.getAttribute('data-variation-select-index'); 486 487 // ç¸æè»¸ããªãï¼1軸ååï¼ã®å ´åã¯ããã®é¸æè¢èªä½ã®åæ±ãªããè¦ãã 488 if (!hasSelectIndex(root, '2')) { 489 const value = map[radio.value] ? map[radio.value][''] : undefined; 490 return value === undefined ? false : isNotHandledValue(value); 491 } 492 493 // ç¸æè»¸ã®ç¾å¨é¸æãåå¾ãããã®çµã¿åããã®åæ±ãªããã©ã°ãè¦ãã 494 const otherIndex = selectIndex === '1' ? '2' : '1'; 495 const otherRadio = getCheckedRadio(root, otherIndex); 496 if (!otherRadio) { 497 return false; 498 } 499 const option1 = selectIndex === '1' ? radio.value : otherRadio.value; 500 const option2 = selectIndex === '1' ? otherRadio.value : radio.value; 501 if (map[option1] === undefined || map[option1][option2] === undefined) { 502 return false; 503 } 504 return isNotHandledValue(map[option1][option2]); 505 } 506 507 // 対象radioã®é¸æè¢ããç¸æè»¸ã®ç¾å¨é¸æã«å¯¾ãã¦å¨åº«åãããå¤å®ããï¼ç¸æè»¸é£åã®æç·è¡¨ç¤ºã«ä½¿ãï¼ã 508 function isCombinationOutOfStock(root, radio) { 509 const map = getStockMap(root); 510 const selectIndex = radio.getAttribute('data-variation-select-index'); 511 512 // ç¸æè»¸ããªãï¼1軸ååï¼ã®å ´åã¯ããã®é¸æè¢èªä½ã®å¨åº«ãè¦ãã 513 if (!hasSelectIndex(root, '2')) { 514 const value = map[radio.value] ? map[radio.value][''] : undefined; 515 return value === undefined ? false : isSoldOutValue(value); 516 } 517 518 // ç¸æè»¸ã®ç¾å¨é¸æãåå¾ãããã®çµã¿åããã®å¨åº«åããã©ã°ãè¦ãã 519 const otherIndex = selectIndex === '1' ? '2' : '1'; 520 const otherRadio = getCheckedRadio(root, otherIndex); 521 if (!otherRadio) { 522 return false; 523 } 524 const option1 = selectIndex === '1' ? radio.value : otherRadio.value; 525 const option2 = selectIndex === '1' ? otherRadio.value : radio.value; 526 if (map[option1] === undefined || map[option1][option2] === undefined) { 527 return false; 528 } 529 return isSoldOutValue(map[option1][option2]); 530 } 531 532 // 対象radioã®é¸æè¢ãå«ãçµã¿åããããã©ã®ç¸æè»¸ã§ãå ¨ã¦åæ±ãªãããå¤å®ããï¼ç¸æè»¸ã®ç¾å¨é¸æã«ä¾åããªãï¼ã 533 function isAllCombinationNotHandled(root, radio) { 534 const map = getHandlingMap(root); 535 const selectIndex = radio.getAttribute('data-variation-select-index'); 536 537 if (!hasSelectIndex(root, '2')) { 538 const value = map[radio.value] ? map[radio.value][''] : undefined; 539 return value === undefined ? false : isNotHandledValue(value); 540 } 541 542 // 1ã¤ã§ãåæ±ããã®çµã¿åãããããã°åæ±ãªãæ±ãã«ããªãã 543 let matched = false; 544 if (selectIndex === '1') {
545 const select1Map = map[radio.value]; 546 if (select1Map === undefined) { 547 return false; 548 } 549 for (const option2 in select1Map) { 550 matched = true; 551 if (!isNotHandledValue(select1Map[option2])) { 552 return false; 553 } 554 } 555 } else { 556 for (const option1 in map) { 557 if (map[option1] === undefined || map[option1][radio.value] === undefined) { 558 continue; 559 } 560 matched = true; 561 if (!isNotHandledValue(map[option1][radio.value])) { 562 return false; 563 } 564 } 565 } 566 return matched; 567 } 568 569 // 対象radioã®é¸æè¢ãå«ãåæ±ããã®çµã¿åããããå ¨ã¦å¨åº«åãããå¤å®ããï¼ç¸æè»¸ã®ç¾å¨é¸æã«ä¾åããªãï¼ã 570 // 1ã¤ã§ãå¨åº«ã®ããçµã¿åãããããã°å¨åº«åãæ±ãã«ããªãã 571 function isAllCombinationOutOfStock(root, radio) { 572 const stockMap = getStockMap(root); 573 const handlingMap = getHandlingMap(root); 574 const selectIndex = radio.getAttribute('data-variation-select-index'); 575 576 if (!hasSelectIndex(root, '2')) { 577 const notHandled = handlingMap[radio.value] ? handlingMap[radio.value][''] : undefined; 578 if (notHandled !== undefined && isNotHandledValue(notHandled)) { 579 return false; 580 } 581 const value = stockMap[radio.value] ? stockMap[radio.value][''] : undefined; 582 return value === undefined ? false : isSoldOutValue(value); 583 } 584 585 // åæ±ãªãã¯å¨åº«å¤å®ã®å¯¾è±¡å¤ã¨ããã 586 let matched = false; 587 if (selectIndex === '1') { 588 const select1Stock = stockMap[radio.value]; 589 if (select1Stock === undefined) { 590 return false; 591 } 592 for (const option2 in select1Stock) { 593 const notHandled = handlingMap[radio.value] ? handlingMap[radio.value][option2] : undefined; 594 if (notHandled !== undefined && isNotHandledValue(notHandled)) { 595 continue; 596 } 597 matched = true; 598 if (!isSoldOutValue(select1Stock[option2])) { 599 return false; 600 } 601 } 602 } else { 603 for (const option1 in stockMap) { 604 if (stockMap[option1] === undefined || stockMap[option1][radio.value] === undefined) { 605 continue; 606 } 607 const notHandled = handlingMap[option1] ? handlingMap[option1][radio.value] : undefined; 608 if (notHandled !== undefined && isNotHandledValue(notHandled)) { 609 continue; 610 } 611 matched = true; 612 if (!isSoldOutValue(stockMap[option1][radio.value])) { 613 return false; 614 } 615 } 616 } 617 return matched; 618 } 619 620 // ç¾å¨é¸æä¸ã®çµã¿åãããå¨åº«åããå¤å®ããï¼ã«ã¼ãæå ¥å¯å¦ã®å¤å®ã«ä½¿ãï¼ã 621 function isCurrentCombinationOutOfStock(root) { 622 const map = getStockMap(root); 623 const select1Radio = getCheckedRadio(root, '1'); 624 if (!select1Radio) { 625 return false; 626 } 627 const option1 = select1Radio.value; 628 const option2 = hasSelectIndex(root, '2') 629 ? (getCheckedRadio(root, '2') ? getCheckedRadio(root, '2').value : '') 630 : ''; 631 if (hasSelectIndex(root, '2') && !option2) { 632 return false; 633 } 634 if (map[option1] === undefined || map[option1][option2] === undefined) { 635 return false; 636 } 637 return isSoldOutValue(map[option1][option2]); 638 } 639 640 // ç¾å¨é¸æä¸ã®çµã¿åãããåæ±ãªããå¤å®ããï¼ã«ã¼ãæå ¥å¯å¦ã®å¤å®ã«ä½¿ãï¼ã 641 function isCurrentCombinationNotHandled(root) { 642 const map = getHandlingMap(root); 643 const select1Radio = getCheckedRadio(root, '1'); 644 if (!select1Radio) { 645 return false;
646 } 647 const option1 = select1Radio.value; 648 const option2 = hasSelectIndex(root, '2') 649 ? (getCheckedRadio(root, '2') ? getCheckedRadio(root, '2').value : '') 650 : ''; 651 if (hasSelectIndex(root, '2') && !option2) { 652 return false; 653 } 654 if (map[option1] === undefined || map[option1][option2] === undefined) { 655 return false; 656 } 657 return isNotHandledValue(map[option1][option2]); 658 } 659 660 // 鏿ä¸ã®é¸æè¢åãé ç®ã©ãã«ã«åæ ããã 661 function updateLabels(root) { 662 root.querySelectorAll('.sysVariationImageSelectGroup').forEach((group) => { 663 const label = group.querySelector('.sysVariationImageSelectLabelValue'); 664 if (!label) return; 665 const radio = group.querySelector('input[type="radio"]:checked'); 666 label.textContent = radio ? (radio.getAttribute('data-option-name') || '') : ''; 667 }); 668 } 669 670 // å¨åº«åãã»åæ±ãªãã«å¿ãã¦æç·è¡¨ç¤ºãæ´æ°ããã鏿ã¯å¯è½ãªã¾ã¾ï¼disableããªãï¼ã 671 // ç»å軸ï¼ã«ã©ã¼çï¼ã¯ç¸æè»¸ã®é¸æã«ä¾åãããè²·ããçµã¿åããã1ã¤ãç¡ãå ´åã®ã¿æç·ã«ããã 672 // éç»å軸ï¼ãµã¤ãºçï¼ã¯é¸æä¸ã®ç¸æè»¸ã¨ã®çµã¿åããã§å¤å®ããã 673 function updateDisabledState(root) { 674 root.querySelectorAll('.sysVariationImageSelectGroup input[type="radio"]').forEach((radio) => { 675 const label = radio.closest('.sysVariationImageSelectOption'); 676 const isImageSide = radio.closest('.sysVariationImageSelectGroupImage') !== null; 677 const isOutOfStock = isImageSide 678 ? isAllCombinationOutOfStock(root, radio) 679 : isCombinationOutOfStock(root, radio); 680 const isNotHandled = isImageSide 681 ? isAllCombinationNotHandled(root, radio) 682 : isCombinationNotHandled(root, radio); 683 684 radio.setAttribute('data-variation-out-of-stock', isOutOfStock ? '1' : '0'); 685 radio.setAttribute('data-variation-not-handled', isNotHandled ? '1' : '0'); 686 if (label) { 687 // æç·ï¼æã¡æ¶ãï¼ã®è¦ãç®ã¯å¨åº«åãã»åæ±ãªãã®ä¸¡æ¹ã«ä»ããã 688 label.classList.toggle('sysVariationImageSelectOptionDisabled', isOutOfStock || isNotHandled); 689 label.classList.toggle('sysVariationImageSelectOptionOutOfStock', isOutOfStock); 690 label.classList.toggle('sysVariationImageSelectOptionNotHandled', isNotHandled); 691 } 692 }); 693 694 updateLabels(root); 695 } 696 697 // ç¾å¨é¸æä¸ã®çµã¿åãããåæ±ãªãã»å¨åº«åãã®å ´åãã«ã¼ãæå ¥ãã¿ã³ãæ¼ä¸ä¸å¯ã«ããã 698 function updateCartButtonState(root) { 699 const form = root.closest('form') || document; 700 const cartButton = form.querySelector('.sysCartButton'); 701 if (!cartButton) { 702 return; 703 } 704 const isNotHandled = isCurrentCombinationNotHandled(root); 705 const isOutOfStock = isCurrentCombinationOutOfStock(root); 706 cartButton.disabled = isNotHandled || isOutOfStock; 707 cartButton.classList.toggle('sysVariationCombinationNotHandled', isNotHandled); 708 cartButton.classList.toggle('sysVariationCombinationOutOfStock', isOutOfStock); 709 } 710 711 // 鏿è¢ã®disabledç¶æ ã¨ãç¾å¨ã®çµã¿åããã«å¿ããã«ã¼ããã¿ã³ã®ç¶æ ãæ´ããã 712 function refreshVariationImageSelects(root) { 713 updateDisabledState(root); 714 updateCartButtonState(root); 715 } 716 717 // åæè¡¨ç¤ºã»Ajaxå·®ãæ¿ãå¾ã®ããªã¨ã¼ã·ã§ã³ç»åUIãåæåããã 718 function initializeVariationImageSelects(context) { 719 context.querySelectorAll('.sysVariationImageSelects').forEach((root) => { 720 refreshVariationImageSelects(root); 721 }); 722 } 723 724 document.addEventListener('change', (e) => { 725 if (!(e.target instanceof Element)) return; 726 const radio = e.target.closest('.sysVariationImageSelectGroup input[type="radio"]'); 727 728 if (!radio || !radio.checked) return; 729 const root = radio.closest('.sysVariationImageSelects'); 730 731 if (!root) return; 732 733 // 鏿è¢ã®disabledç¶æ ï¼åºå®å¤å®ï¼ã¨ã«ã¼ããã¿ã³ã®ç¶æ ãæ´æ°ããã 734 refreshVariationImageSelects(root); 735 }, true); 736 737 // JSèªè¾¼æç¹ã§DOMContentLoadedæ¸ã¿ã®å ´åã§ããåædisabledç¶æ ãå¿ ãæ´ããã 738 if (document.readyState === 'loading') { 739 document.addEventListener('DOMContentLoaded', () => initializeVariationImageSelects(document)); 740 } else { 741 initializeVariationImageSelects(document); 742 } 743 744 // Ajaxå·®ãæ¿ãå¾ã®åå詳細ãã¼ãã«ãåãåæåãé©ç¨ããã 745 addEventListener('onSysAsyncElementLoaded', () => initializeVariationImageSelects(document)); 746})(); 747 748/** 749 * åå詳細ãã¼ã¸ãååç»åï¼ã¹ã©ã¤ãï¼ 750 */ 751Sys.event.add(window, "load", function(){ 752 var ItemImagesSlide = {}; 753 ItemImagesSlide._size = 0; 754 ItemImagesSlide._now = 1; 755 ItemImagesSlide._slide_width = 0; 756 ItemImagesSlide._getCurrentMedia = function(index){ 757 var target = Sys(".sysItemImagesSlideList li:eq(" + index + ")"); 758 if (!target.length) { 759 return null; 760 } 761 var media = target.find('img, video').eq(0); 762 return media.length ? media : null; 763 }; 764 ItemImagesSlide._updateImageDescription = function(){ 765 var eq = ItemImagesSlide._now -1; 766 var media = ItemImagesSlide._getCurrentMedia(eq); 767 var description = media ? (media.attr("alt") || media.attr('aria-label') || '') : ''; 768 Sys(".sysItemImagesSlideCtl + .sysImageDescription").html(description); 769 }; 770 ItemImagesSlide._slide = function(way){ 771 var slide = {marginLeft:way + "=" + ItemImagesSlide._slide_width + "px"}; 772 Sys(".sysItemImagesSlideList").animate(slide,"normal"); 773 } 774 ItemImagesSlide.init = function(){ 775 Sys(".sysItemImagesSlideList").each(function(){ 776 Sys(this).attr("data-size", Sys("li", this).length); 777 ItemImagesSlide._size = Sys("li", this).length; 778 }); 779 780 if (ItemImagesSlide._size == 0) { 781 return null; 782 } 783 784 ItemImagesSlide._slide_width = Sys(".sysItemImagesSlide").width(); 785 Sys(".sysItemImagesSlideList").width(ItemImagesSlide._slide_width * ItemImagesSlide._size); 786 var image_width = 100 / ItemImagesSlide._size; 787 Sys(".sysItemImagesSlideList li").width(image_width + "%"); 788 789 var height = Sys(".sysItemImagesSlide").height(); 790 Sys(".sysItemImagesSlideList li").height(height); 791 Sys(".sysItemImagesSlidePrev").height(height);
792 Sys(".sysItemImagesSlidePrev").css({lineHeight: height + "px"}); 793 Sys(".sysItemImagesSlideNext").height(height); 794 Sys(".sysItemImagesSlideNext").css({lineHeight: height + "px"}); 795 Sys(".sysItemImagesSlideList li").height(height); 796 Sys(".sysItemImagesSlideList li").css({lineHeight: height + "px"}); 797 798 ItemImagesSlide._updateImageDescription(); 799 800 if (ItemImagesSlide._now <= 1) { 801 Sys(".sysItemImagesSlidePrev span").addClass("sysItemImagesSlideNone"); 802 } 803 if (ItemImagesSlide._size <= 1) { 804 Sys(".sysItemImagesSlideNext span").addClass("sysItemImagesSlideNone"); 805 } 806 }; 807 ItemImagesSlide.next = function(){ 808 if (Sys(this).is(".sysItemImagesSlideNone")) { 809 return null; 810 } 811 ItemImagesSlide._now++; 812 ItemImagesSlide._slide("-"); 813 ItemImagesSlide._updateImageDescription(); 814 if (ItemImagesSlide._now >= ItemImagesSlide._size) { 815 Sys(this).addClass("sysItemImagesSlideNone"); 816 } 817 if (ItemImagesSlide._now > 1) { 818 Sys('.sysItemImagesSlidePrev span').removeClass("sysItemImagesSlideNone"); 819 } 820 }; 821 ItemImagesSlide.prev = function(){ 822 if (Sys(this).is(".sysItemImagesSlideNone")) { 823 return null; 824 } 825 ItemImagesSlide._now--; 826 ItemImagesSlide._slide("+"); 827 ItemImagesSlide._updateImageDescription(); 828 if (ItemImagesSlide._now <= 1) { 829 Sys(this).addClass("sysItemImagesSlideNone"); 830 } 831 if (ItemImagesSlide._now < ItemImagesSlide._size) { 832 Sys('.sysItemImagesSlideNext span').removeClass("sysItemImagesSlideNone"); 833 } 834 }; 835 ItemImagesSlide.init(); 836 Sys(window).resize(ItemImagesSlide.init); 837 Sys(document).on('click', '.sysItemImagesSlidePrev span', ItemImagesSlide.prev); 838 Sys(document).on('click', '.sysItemImagesSlideNext span', ItemImagesSlide.next); 839}); 840 841/** 842 * ã»ãã·ã§ã³ã¹ãã¬ã¼ã¸ã«å¤ãã»ãã 843 * @param {string} key ã»ãã·ã§ã³ãã¼ 844 * @param {object} saveObject ä¿æãããå 容 845 */ 846function setSessionStorage(key, saveObject) { 847 if (window.sessionStorage) { 848 try { 849 sessionStorage.setItem(key, JSON.stringify(saveObject)); 850 } catch (err) { 851 // ã¨ã©ã¼ãçºçããå ´åã¯å¦çãã¹ã«ã¼ãã 852 // safariã®ãã©ã¤ãã¼ããã©ã¦ãºãlocalStorageã«å¯¾å¿ãã¦ããªããã 853 console.error(err); 854 } 855 } 856} 857 858/** 859 * ã»ãã·ã§ã³ã¹ãã¬ã¼ã¸ããå¤ãåå¾ 860 * @param {string} key ã»ãã·ã§ã³ãã¼ 861 * @return {string|boolean} å¤ããããã¯falseãè¿ã 862 */ 863function getSessionStorage(key) { 864 var savedObject = sessionStorage[key]; 865 if (savedObject === undefined) { 866 return false; 867 } 868 savedObject = JSON.parse(savedObject); 869 if (savedObject.expire === false || savedObject.expire > (new Date).getTime()) { 870 return savedObject.value; 871 } else { 872 sessionStorage.removeItem(key); 873 return false; 874 } 875} 876 877/** 878 * ã¬ã³ã¿ã«åå 879 */ 880Sys(function() { 881 //ã¬ã³ã¿ã«ã«ã¬ã³ãé¢é£ã®è¦ªclassããªããã°ã¬ã³ã¿ã«ç»é¢ã¨ã¯è¦ãªããªã 882 if (Sys('.sysRentalSchedules').length === 0) { 883 return; 884 } 885 886 var sysRentalSchedulesDays = []; 887 888 // ã»ãã·ã§ã³ãã鏿æ¥ä»ãåå¾ 889 var sessionSelectedDate = getSessionStorage("sessionSelectedDate"); 890 var selectedDate; 891 if (sessionSelectedDate) { 892 selectedDate = sessionSelectedDate; 893 } 894 895 // ã»ãã·ã§ã³ããç¾å¨æ¥ä»ä¿®æ£ææ°ãåå¾ï¼ã»ãã·ã§ã³ããåå¾ã§ããªããã°data-monthmodifyããåå¾ï¼ 896 var sessionCurrentMonthModify = getSessionStorage("sessionCurrentMonthModify"); 897 var currentMonthModify = sessionCurrentMonthModify ? sessionCurrentMonthModify : Sys("[data-monthmodify]").attr("data-monthmodify"); 898 899 // ã»ãã·ã§ã³ãã鏿æ¥ä»ãåå¾ã§ããå ´å 900 if (selectedDate) { 901 902 // ã«ã¬ã³ãã¼ãååå¾
903 getRentalCalendar(); 904 // ã¬ã³ã¿ã«éå§æ¥ãåå¾ãã¦ãã©ã¼ã å¤ã«ã»ããï¼<input type="hidden">ã®é ç®ï¼ 905 Sys("[name='rental_start_date']").val(selectedDate); 906 // 䏿¦ã«ã¬ã³ãã¼ä¸ãããã¬ã³ã¿ã«éå§æ¥ã®å±æ§ãåé¤ 907 Sys(".sysRentalSchedulesCalendar td").removeAttr('data-rental-select-date'); 908 // ã¯ãªãã¯ããæ¥ä»ã«ã¬ã³ã¿ã«éå§æ¥ã®å±æ§ãã»ãã 909 Sys(this).attr('data-rental-select-date', 'selected'); 910 // ãçºéæ¥ãçã®é ç®ã表示 911 Sys(".sysRentalSendDay, .sysRentalReachDay, .sysRentalUseDays, .sysRentalReturnDay").show(); 912 // ã«ã¬ã³ãã¼ä¸ã®æ¥ä»ã«é ç®ãã¨ã®ã¯ã©ã¹ã®ã»ãããããçºéæ¥ï¼2016å¹´03æ18æ¥ãçã®æ¥ä»ã夿´ 913 setRentalSchedules(selectedDate); 914 updateRetailPrice(); 915 } 916 917 Sys(".sysCalendarLoading").hide(); 918 919 // ã¬ã³ã¿ã«å©ç¨å¯è½æ¥ãã¯ãªãã¯ããæ 920 Sys(document).on("click", ".sysRentalSchedulesValid:not(.reserved)", function() { 921 // ã¯ãªãã¯ããæ¥ä»ï¼ã¬ã³ã¿ã«éå§æ¥ï¼ãåå¾ 922 selectedDate = Sys(this).attr("data-rentalstartdate"); 923 var sessionExpire = 1800; 924 var sessionUpperLimit = (new Date).getTime() + (sessionExpire * 1000); 925 // ã¬ã³ã¿ã«éå§æ¥ãã»ãã·ã§ã³ã«ä¿å 926 var sessionSelectedDateObj = { 927 expire: sessionUpperLimit, 928 value: selectedDate 929 }; 930 setSessionStorage("sessionSelectedDate", sessionSelectedDateObj); 931 // ã¬ã³ã¿ã«è¡¨ç¤ºæ - 彿ã®å¤ãã»ãã·ã§ã³ã«ä¿å 932 var sessionCurrentMonthModifyObj = { 933 expire: sessionUpperLimit, 934 value: currentMonthModify 935 }; 936 setSessionStorage("sessionCurrentMonthModify", sessionCurrentMonthModifyObj); 937 // ã¬ã³ã¿ã«éå§æ¥ãåå¾ãã¦ãã©ã¼ã å¤ã«ã»ããï¼<input type="hidden">ã®é ç®ï¼ 938 Sys("[name='rental_start_date']").val(selectedDate); 939 // 䏿¦ã«ã¬ã³ãã¼ä¸ãããã¬ã³ã¿ã«éå§æ¥ã®å±æ§ãåé¤ 940 Sys(".sysRentalSchedulesCalendar td").removeAttr('data-rental-select-date'); 941 // ã¯ãªãã¯ããæ¥ä»ã«ã¬ã³ã¿ã«éå§æ¥ã®å±æ§ãã»ãã 942 Sys(this).attr('data-rental-select-date', 'selected'); 943 // ãçºéæ¥ãçã®é ç®ã表示 944 Sys(".sysRentalSendDay, .sysRentalReachDay, .sysRentalUseDays, .sysRentalReturnDay").show(); 945 // ã«ã¬ã³ãã¼ä¸ã®æ¥ä»ã«é ç®ãã¨ã®ã¯ã©ã¹ã®ã»ãããããçºéæ¥ï¼2016å¹´03æ18æ¥ãçã®æ¥ä»ã夿´ 946 setRentalSchedules(selectedDate); 947 updateRetailPrice(); 948 }); 949 950 // 鏿ããã¦ããã¬ã³ã¿ã«éå§æ¥ãã¯ãªãã¯ãããå ´åã表示ãªã»ãã 951 Sys(document).on("click", "[data-rental-select-date='selected']", reset); 952 953 // å»¶é·æ¥ã夿´ãããæ 954 Sys(document).on("change", "[name='rental_extend_date']", function(){ 955 // ã¬ã³ã¿ã«éå§æ¥ãåå¾ 956 selectedDate = Sys("[name='rental_start_date']").val(); 957 // ã¬ã³ã¿ã«éå§æ¥ãæå®ãã¦ããã°ãã«ã¬ã³ãã¼ä¸ã®æ¥ä»ã®è²å¤æ´ããçºéæ¥ï¼2016å¹´03æ18æ¥ãçã®æ¥ä»ã夿´ 958 if (selectedDate) { 959 setRentalSchedules(selectedDate); 960 } 961 updateRetailPrice(); 962 }); 963 964 /** 965 * 次æãã¿ã³æ¼ä¸ã¤ãã³ã 966 */ 967 Sys(document).on("click", ".sysNextCalendar", function(){ 968 currentMonthModify = parseInt(currentMonthModify) + 1;
969 getRentalCalendar(); 970 }); 971 972 /** 973 * åæãã¿ã³æ¼ä¸ã¤ãã³ã 974 */ 975 Sys(document).on("click", ".sysPrevCalendar", function(){ 976 currentMonthModify = parseInt(currentMonthModify) - 1; 977 getRentalCalendar(); 978 }); 979 980 /** 981 * ã¬ã³ã¿ã«ã«ã¬ã³ãã¼ã®å¹´æãã«ãã¦ã³å¤æ´ã¤ãã³ã 982 */ 983 Sys(document).on("change", ".sysMonthSelect", function(){ 984 if (Sys(this).val()) { 985 currentMonthModify = Sys(this).val(); 986 getRentalCalendar(); 987 } 988 }); 989 990 function number_format(number) { 991 number = new String(number).replace(/,/g, ""); 992 while (number != (number = number.replace(/^(-?\d+)(\d{3})/, "$1,$2"))); 993 return number; 994 } 995 996 /** 997 * ã«ã¬ã³ãã¼ãéåæã§åå¾ 998 */ 999 function getRentalCalendar() { 1000 1001 // ã«ã¬ã³ãã¼ãé ãã¦Loadingã表示 1002 Sys(".sysRentalSchedulesCalendars").hide(); 1003 Sys(".sysCalendarLoading").fadeIn(); 1004 1005 // ã«ã¬ã³ãã¼ãéåæã§åå¾ 1006 var url = "/api/front/item/getRentalScheduleCalendar"; 1007 url += "?item_no=" + Sys(".sysRentalSchedules [data-itemno]").attr("data-itemno"); 1008 url += "&month_modify=" + currentMonthModify; 1009 Sys.get(url, function(html){ 1010 1011 // Loadingãé ãã¦ã«ã¬ã³ãã¼ã表示 1012 Sys(".sysCalendarLoading").hide(); 1013 Sys(".sysRentalSchedulesCalendars").fadeIn(); 1014 1015 // sysRentalSchedulesCalendarsé ä¸ãä¸åº¦åé¤ãã¦å·®ãæ¿ãã 1016 var parent = Sys(".sysRentalSchedulesCalendars").parent(); 1017 Sys(parent).children('.sysRentalSchedulesCalendars').remove(); 1018 Sys(parent).append(Sys(html)); 1019 1020 // ã¬ã³ã¿ã«éå§æ¥ãåå¾ 1021 selectedDate = Sys("[name='rental_start_date']").val(); 1022 // ã¬ã³ã¿ã«éå§æ¥ãæå®ãã¦ããã°ãã«ã¬ã³ãã¼ä¸ã®æ¥ä»ã®è²å¤æ´ããçºéæ¥ï¼2016å¹´03æ18æ¥ãçã®æ¥ä»ã夿´ 1023 if (selectedDate) { 1024 // ã«ã¬ã³ãã¼ã®æ¥ä»ã«ã¬ã³ã¿ã«éå§æ¥ã®å±æ§ãã»ãã 1025 Sys("[data-rentalstartdate='" + selectedDate + "']").attr('data-rental-select-date', 'selected'); 1026 setRentalSchedules(selectedDate); 1027 } 1028 1029 // ãã«ãã¦ã³ã鏿 1030 Sys('.sysMonthSelect').val(currentMonthModify); 1031 }); 1032 } 1033 1034 /** 1035 * ã¬ã³ã¿ã«ã®ã¹ã±ã¸ã¥ã¼ã«ããã©ã¦ã¶ã«ã»ãããã 1036 * @param {string} selectedDate ã¬ã³ã¿ã«éå§æ¥ï¼ä¾ï¼2016-03-17ï¼ 1037 */ 1038 function setRentalSchedules(selectedDate) { 1039 // 䏿¦ã¬ã³ã¿ã«ç¨ã®ã¯ã©ã¹ãå ¨ã¦å¤ã 1040 Sys(".sysRentalSchedulesCalendar td").removeClass('sysRentalSchedulesSend sysRentalSchedulesReach sysRentalSchedulesDays sysRentalSchedulesReturn sysRentalSchedulesExtend'); 1041 1042 // ã¬ã³ã¿ã«éå§æ¥ã®ã¯ã©ã¹åãåå¾ 1043 var rentalStartDateClassName = Sys("[data-rentalstartdate='" + selectedDate + "']").attr("class"); 1044 // ã¬ã³ã¿ã«éå§æ¥ãã¬ã³ã¿ã«ä¸å¯æ¥ã§ããã°ã¬ã³ã¿ã«ã®ã¹ã±ã¸ã¥ã¼ã«ããã©ã¦ã¶ããã¯ãªã¢ããï¼ã»ãã·ã§ã³ã¯æ®ãï¼ 1045 if (rentalStartDateClassName === "sysRentalSchedulesInvalid" || rentalStartDateClassName === "sysRentalSchedulesReserved") { 1046 reset(); 1047 } else { 1048 /** ã¬ã³ã¿ã«éå§æ¥ãã¬ã³ã¿ã«å¯è½æ¥ã§ããã°ã¬ã³ã¿ã«ã®ã¹ã±ã¸ã¥ã¼ã«ããã©ã¦ã¶ã«ã»ãããã */ 1049 // ãâå¹´âæâæ¥ãã«å¤æ 1050 var selectedDateAry = selectedDate.split("-"); 1051 var selectedDateToString = selectedDateAry[0] + "å¹´" + selectedDateAry[1] + "æ" + selectedDateAry[2] + "æ¥"; 1052 1053 /** çºéæ¥ */ 1054 // è¨å®ãåå¾ï¼ä¾ï¼3æ¥åãªãã-3ãï¼ 1055 var sendDay = parseInt(Sys("[data-rentalsendday]").attr("data-rentalsendday"), 10); 1056 // çºéæ¥ãè¨å®ãã¦ããå ´å 1057 if (sendDay) { 1058 var sendDateObj = createDateObj(selectedDate, sendDay); 1059 // ãçºéæ¥ï¼ãã«å¹´ææ¥ãã»ãã 1060 Sys(".sysRentalSendDay .sysRentalDate").html(toStringDate(sendDateObj)); 1061 // ã¯ã©ã¹ãã»ãã 1062 var sendDate = sendDateObj.year + "-" + sendDateObj.month + "-" + sendDateObj.day; 1063 Sys("[data-rentalstartdate='" + sendDate + "']").addClass("sysRentalSchedulesSend"); 1064 } 1065 1066 /** ãå±ãäºå®æ¥ */ 1067 // è¨å®ãåå¾ï¼ä¾ï¼1æ¥åãªãã-1ãï¼ 1068 var reachDay = parseInt(Sys("[data-rentalreachday]").attr("data-rentalreachday"), 10); 1069 // ãå±ãäºå®æ¥ãè¨å®ãã¦ããå ´å 1070 if (reachDay) { 1071 var reachDateObj = createDateObj(selectedDate, reachD
1071ay); 1072 // ããå±ãäºå®æ¥ï¼ãã«å¹´ææ¥ãã»ãã 1073 Sys(".sysRentalReachDay .sysRentalDate").html(toStringDate(reachDateObj)); 1074 // ã¯ã©ã¹ãã»ãã 1075 var reachDate = reachDateObj.year + "-" + reachDateObj.month + "-" + reachDateObj.day; 1076 Sys("[data-rentalstartdate='" + reachDate + "']").addClass("sysRentalSchedulesReach"); 1077 } 1078 1079 /** ãå©ç¨æ¥ */ 1080 var usePeriodToString; 1081 var useDate; 1082 // ãå©ç¨æ¥ã®æ¥æ°ãåå¾ï¼ä¾ï¼1æ¥ãªãã1ãï¼ 1083 var useDayPeriod = parseInt(Sys("[data-rentalusedays]").attr('data-rentalusedays'), 10); 1084 // ã¯ã©ã¹ãã»ããï¼ã¬ã³ã¿ã«éå§æ¥ã®æ¥ä»ã ãï¼ 1085 Sys("[data-rentalstartdate='" + selectedDate + "']").addClass("sysRentalSchedulesDays"); 1086 // ã¬ã³ã¿ã«ä¸å¯æ¥ï¼åååå¥ï¼ã®ã¯ã©ã¹åãå®ç¾© 1087 var rentalSchedulesReserved = "sysRentalSchedulesReserved sysRentalSchedulesDays"; 1088 // ã¬ã³ã¿ã«ä¸å¯æ¥ï¼é¸æä¸å¯æ¥ï¼ã®ã¯ã©ã¹åãå®ç¾© 1089 var rentalSchedulesInvalid = "sysRentalSchedulesInvalid sysRentalSchedulesDays"; 1090 // ãå©ç¨æ¥ã1æ¥ãè¶ ããå ´å 1091 if (useDayPeriod > 1) { 1092 // ãå©ç¨æéã®æçµæ¥ãåå¾ 1093 var useEndDateObj = createDateObj(selectedDate, useDayPeriod - 1); 1094 // ãâå¹´âæâæ¥ãâ³å¹´â³æâ³æ¥ãã«ãã 1095 usePeriodToString = selectedDateToString + "ï½" + toStringDate(useEndDateObj); 1096 var useDateObj; 1097 // ã¯ã©ã¹ãã»ãã 1098 for (i = 1; i < useDayPeriod; i++) { 1099 useDateObj = createDateObj(selectedDate, i); 1100 useDate = useDateObj.year + "-" + useDateObj.month + "-" + useDateObj.day; 1101 Sys("[data-rentalstartdate='" + useDate + "']").addClass("sysRentalSchedulesDays"); 1102 } 1103 } 1104 // ãå©ç¨æ¥ã1æ¥ã ããªãã¬ã³ã¿ã«éå§æ¥ã®ã¿ãå©ç¨æ¥ã¨ãã 1105 usePeriodToString = usePeriodToString || selectedDateToString; 1106 // 1æ¥ã®å ´åéå§æ¥ãè¤æ°æ¥ã®å ´åæçµæ¥ãä»£å ¥ 1107 useDate = useDate || selectedDate; 1108 // ãå©ç¨æ¥ãããå©ç¨æ¥ï¼ãã«ã»ãã 1109 Sys(".sysRentalUseDays .sysRentalDate").html(usePeriodToString); 1110 1111 // ã¬ã³ã¿ã«å»¶é·æéãåå¾ï¼ä¾ï¼2æ¥å»¶é·ãªãã2ãï¼ 1112 var rentalExtendPeriod = parseInt(Sys("[name='rental_extend_date']").val(), 10); 1113 // å»¶é·ããå ´å 1114 if (rentalExtendPeriod) { 1115 var extendDate; 1116 var extendDateObj; 1117 // ã¯ã©ã¹ãã»ãã 1118 for (i = 1; i <= rentalExtendPeriod; i++) { 1119 extendDateObj = createDateObj(useDate, i); 1120 extendDate = extendDateObj.year + "-" + extendDateObj.month + "-" + extendDateObj.day; 1121 Sys("[data-rentalstartdate='" + extendDate + "']").addClass("sysRentalSchedulesExtend"); 1122 } 1123 } 1124 1125 /** è¿å´æ¥ */ 1126 // è¨å®ãåå¾ï¼ä¾ï¼3æ¥å¾ãªãã3ãï¼ 1127 var returnDay = parseInt(Sys("[data-rentalreturnday]").attr('data-rentalreturnday'), 10); 1128 // è¿å´æ¥ãè¨å®ãã¦ããå ´å 1129 if (returnDay) { 1130 var returnDateObj = createDateObj(selectedDate, rentalExtendPeriod + returnDay); 1131 // ãè¿å´æ¥ï¼ãã«å¹´ææ¥ãã»ãã 1132 Sys(".sysRentalReturnDay .sysRentalDate").html(toStringDate(returnDateObj)); 1133 // ã¯ã©ã¹ãã»ãã 1134 var returnDate = returnDateObj.year + "-" + returnDateObj.month + "-" + returnDateObj.day; 1135 Sys("[data-rentalstartdate='" + returnDate + "']").addClass("sysRentalSchedulesReturn"); 1136 } 1137 } 1138 } 1139 1140 /** 1141 * åãåã£ãæ¥æ°ã§å æ¸ç®ããå¹´ææ¥ããªãã¸ã§ã¯ãã§è¿ã 1142 * @param {string} selectedDay ãå©ç¨éå§æ¥ï¼ä¾ï¼2016-03-28ï¼ 1143 * @param {int} addDay å æ¸ç®ããæ¥æ°ï¼ä¾ï¼2æ¥åãªãã-2ãã1æ¥å¾ãªãã1ãï¼ 1144 * @return {{year: number, month: string, day: string}} 1145 */ 1146 function createDateObj(selectedDay, addDay) { 1147 // ãå©ç¨éå§æ¥ã['å¹´', 'æ', 'æ¥']ã®é åã«ãã 1148 var selectedDayArr = selectedDay.split("-"); 1149 // æ¥ä»ãå æ¸ç®ããå¾ãDateãªãã¸ã§ã¯ãã«å¤æ 1150 var dateObj = modifyDate(parseInt(selectedDayArr[0], 10), parseInt(selectedDayArr[1], 10), 1151 parseInt(selectedDayArr[2], 10), parseInt(addDay, 10)); 1152 // Dateãªãã¸ã§ã¯ãããå¹´ã4æ¡ã§åå¾ 1153 var year = dateObj.getFullYear(); 1154 // Dateãªãã¸ã§ã¯ãããæã2æ¡ã§åå¾ï¼1æãªãã01ãï¼
1155 var month = ('00' + (dateObj.getMonth() + 1)).slice(-2); 1156 // Dateãªãã¸ã§ã¯ãããæ¥ã2æ¡ã§åå¾ï¼1æ¥ãªãã01ãï¼ 1157 var day = ('00' + dateObj.getDate()).slice(-2); 1158 1159 return {year:year, month:month, day:day}; 1160 } 1161 1162 /** 1163 * å¹´ææ¥ã®ãªãã¸ã§ã¯ãããâå¹´âæâæ¥ãã«å¤æ 1164 * @param {object} dayObj {{year: number, month: string, day: string}} 1165 * @returns {string} 1166 */ 1167 function toStringDate(dayObj) { 1168 return dayObj.year + "å¹´" + dayObj.month + "æ" + dayObj.day + "æ¥"; 1169 } 1170 1171 // @TODO parseInt()ã«åºæ°ãè¨å®ãã 1172 function updateRetailPrice() { 1173 if (Sys(".sysRetailPriceValue").length == 0) { 1174 return null; 1175 } 1176 1177 var new_price; 1178 var new_price_with_tax; 1179 var selectedDate = Sys("[data-rental-select-date='selected']"); 1180 if (selectedDate.attr("data-rentalprice")) { 1181 new_price = parseInt(selectedDate.attr("data-rentalprice")); 1182 new_price_with_tax = parseInt(selectedDate.attr("data-rentalpricewithtax")); 1183 } else { 1184 new_price = parseInt(Sys("[data-originprice]").attr("data-originprice")); 1185 new_price_with_tax = parseInt(Sys("[data-originpricewithtax]").attr("data-originpricewithtax")); 1186 } 1187 1188 // ã¬ã³ã¿ã«æéã®å»¶é·æé 1189 var extend_price = parseInt(Sys("[name='rental_extend_date'] option:selected").attr("data-rentalextendfee")); 1190 var extend_price_with_tax = parseInt(Sys("[name='rental_extend_date'] option:selected").attr("data-rentalextendfeewithtax")); 1191 1192 new_price = new_price + extend_price; 1193 new_price = number_format(new_price); 1194 1195 new_price_with_tax = new_price_with_tax + extend_price_with_tax; 1196 new_price_with_tax = number_format(new_price_with_tax); 1197 1198 Sys(".sysRetailPrice").each(function(){ 1199 var target = Sys(this).find(".sysRetailPriceValue"); 1200 var price_text = target.html(); 1201 if (target.attr("data-taxincludednonincludeddisplaysetting") == 1) { 1202 // ç¨è¾¼æãç¨æä¾¡æ ¼ã¨ç¨è¾¼ä¾¡æ ¼ã®ä¸¡æ¹ã表示 1203 target.html(price_text.replace(/[0-9,]+/, new_price)); 1204 var price_with_tax_text = target.find(".sysRetailPriceTaxIncluded").html(); 1205 target.find(".sysRetailPriceTaxIncluded").html(price_with_tax_text.replace(/[0-9,]+/, new_price_with_tax)); 1206 } else if (target.attr("data-taxincludeddisplaysetting") == 1) { 1207 // ç¨æ 1208 target.html(price_text.replace(/[0-9,]+/, new_price)); 1209 } else { 1210 // ç¨è¾¼ 1211 target.html(price_text.replace(/[0-9,]+/, new_price_with_tax)); 1212 } 1213 }); 1214 } 1215 1216 /** 1217 * é¸æç¶æ ã®ã¬ã³ã¿ã«éå§æ¥ããªã»ãã 1218 */ 1219 function reset() { 1220 var rentalStartDateClassName = Sys("[data-rentalstartdate='" + selectedDate + "']").attr("class"); 1221 // 鏿ããæ¥ä»ãã¬ã³ã¿ã«å¯è½ãªæ¥ã ã£ãå ´åã¯ã»ãã·ã§ã³ãã鏿æ¥ã»ã«ã¬ã³ãã¼è¡¨ç¤ºæãåé¤ 1222 if (rentalStartDateClassName === "sysRentalSchedulesValid sysRentalSchedulesDays") { 1223 sessionStorage.removeItem("sessionSelectedDate"); 1224 sessionStorage.removeItem("sessionCurrentMonthModify"); 1225 } 1226 // ãçºéæ¥ãçã®é ç®ãéè¡¨ç¤ºãæ¥ä»ã空ã«ãã 1227 Sys(".sysRentalSendDay, .sysRentalReachDay, .sysRentalUseDays, .sysRentalReturnDay").hide(); 1228 Sys(".sysRentalScheduleInfo .sysRentalDate").text(""); 1229 // ã¬ã³ã¿ã«éå§æ¥ã®å±æ§ãå¤ã 1230 Sys(this).removeAttr('data-rental-select-date'); 1231 // ã¬ã³ã¿ã«ã¹ã±ã¸ã¥ã¼ã«é¢é£ã®ã¯ã©ã¹ãå¤ã 1232 Sys(".sysRentalSchedulesCalendar td").removeClass("sysRentalSchedulesSend sysRentalSchedulesReach sysRentalSchedulesDays sysRentalSchedulesReturn sysRentalSchedulesExtend"); 1233 Sys("[name='rental_start_date']").val(""); 1234 Sys(".sysRetailPrice").each(function(){ 1235 var origin_price = Sys("[data-originprice]").attr("data-originprice");
1236 origin_price = number_format(origin_price); 1237 var origin_price_with_tax = Sys("[data-originpricewithtax]").attr("data-originpricewithtax"); 1238 origin_price_with_tax = number_format(origin_price_with_tax); 1239 var target = Sys(this).find(".sysRetailPriceValue"); 1240 if (Sys(this).find(".sysRetailPriceValue").length > 0) { 1241 var price_text = target.html(); 1242 if (target.attr("data-taxincludednonincludeddisplaysetting") == 1) { 1243 target.html(price_text.replace(/[0-9,]+/, origin_price)); 1244 var price_with_tax_text = target.find(".sysRetailPriceTaxIncluded").html(); 1245 target.find(".sysRetailPriceTaxIncluded").html(price_with_tax_text.replace(/[0-9,]+/, origin_price_with_tax)); 1246 } else if (target.attr("data-taxincludeddisplaysetting") == 1) { 1247 target.html(price_text.replace(/[0-9,]+/, origin_price)); 1248 } else { 1249 target.html(price_text.replace(/[0-9,]+/, origin_price_with_tax)); 1250 } 1251 } 1252 1253 }); 1254 } 1255 1256 // month ã«1è¶³ãå¿ è¦ãã 1257 function modifyDate(year, month, day, add) { 1258 var dt = new Date(year, month - 1, day); 1259 var baseSec = dt.getTime(); 1260 var addSec = add * 86400000; 1261 var targetSec = baseSec + addSec; 1262 dt.setTime(targetSec); 1263 return dt; 1264 } 1265}); 1266 1267/** 1268 * ååããªã¨ã¼ã·ã§ã³åæå¦ç 1269*/ 1270Sys(function () { 1271 addEventListener('onSysAsyncElementLoaded', () => { 1272 document.querySelectorAll(".sysCartInForm").forEach(function (variationForm) { 1273 variationForm.addEventListener("change", () => { 1274 const combineForm = variationForm.querySelector("#variation"); 1275 if (combineForm !== null && !isNaN(combineForm.value) && combineForm.value !== undefined) { 1276 variationForm.dispatchEvent(new CustomEvent('variationUpdated', { detail: { variationNo: combineForm.value } })); 1277 return; 1278 } 1279 1280 const tableForm = variationForm.querySelector("input[id='variationTable']:checked"); 1281 if (tableForm !== null && !isNaN(tableForm.value) && tableForm.value !== undefined) { 1282 variationForm.dispatchEvent(new CustomEvent('variationUpdated', { detail: { variationNo: tableForm.value } })); 1283 } 1284 1285 const option1 = variationForm.querySelector("#variation_select1, input[type='radio'][name='variation[selects][select1OptionNo][value]']:checked"); 1286 const option2 = variationForm.querySelector("#variation_select2, input[type='radio'][name='variation[selects][select2OptionNo][value]']:checked"); 1287 if (option1 !== null && !isNaN(option1.value) && option1.value !== undefined) { 1288 var option1Value = option1.value; 1289 var option2Value = null; 1290 if (option2 !== null && !isNaN(option2.value) && option2.value !== undefined) { 1291 var option2Value = option2.value; 1292 } 1293 variationForm.dispatchEvent(new CustomEvent('variationUpdated', { 1294 detail: { 1295 variationSelect1: option1Value, 1296 variationSelect2: option2Value, 1297 } 1298 })); 1299 } 1300 }); 1301 1302 variationForm.addEventListener('variationUpdated', (event) => { 1303 getVariationPrice( 1304 event.detail.variationNo, 1305 event.detail.variationSelect1, 1306 event.detail.variationSelect2, 1307 ).then((variationPrices) => { 1308 setVariationPriceIfSuccess(variationPrices); 1309 variationForm.dispatchEvent(new CustomEvent("variationPriceUpdated")); 1310 }) 1311 .catch((error) => { 1312 console.error(error); 1313 setVariationPriceIfError(); 1314 }); 1315 }); 1316 }); 1317 }) 1318 1319 const getVariationPrice = async (variationNo, optionNo1, optionNo2) => { 1320 var payload = []; 1321 if (variationNo) { 1322 payload = { 1323 variation_no: variationNo, 1324 }; 1325 } else if (optionNo2) { 1326 payload = { 1327 "option_no1": optionNo1, 1328 "option_no2": optionNo2, 1329 }; 1330 } else { 1331 payload = { 1332 "option_no1": optionNo1, 1333 }; 1334 } 1335 1336 const endpoint = variationNo ? "/api/front/item/getVariationPriceByVariationNo" : "/api/front/item/getVariationPriceByOptionNo"; 1337 const query = new URLSearchParams(payload); 1338 const uri = endpoint + "?" + query; 1339 const response = await fetch( 1340 uri, 1341 { 1342 method: "GET", 1343 headers: { 1344 "X-Requested-With": "XMLHttpRequest" 1345 }, 1346 } 1347 ).then((response) => { 1348 if (!response.ok) return null; 1349 return response.json(); 1350 }); 1351 1352 return {
1353 yamiPrice: response.yami_price, 1354 retailPrice: response.retail_price, 1355 resolvedRetailPrice: response.resolved_retail_price, 1356 taxIncludedYamiPrice: response.tax_included_yami_price, 1357 taxIncludedRetailPrice: response.tax_included_retail_price, 1358 taxIncludedResolvedRetailPrice: response.tax_included_resolved_retail_price, 1359 isYamiCategory: response.is_yami_category, 1360 isUseYamiPrice: response.is_use_yami_price, 1361 isUseTradeRate: response.is_use_trade_rate, 1362 discountRate: response.discount_rate, 1363 isUseVariationPrice: response.is_use_variation_price, 1364 }; 1365 } 1366 1367 /** 1368 * Ajaxéä¿¡æåæã«ããªã¨ã¼ã·ã§ã³ä¾¡æ ¼ãã»ãããã 1369 * @param resp 1370 */ 1371 function setVariationPriceIfSuccess(resp) { 1372 var yamiPrice = resp.yamiPrice; 1373 var retailPrice = resp.retailPrice; 1374 var resolvedRetailPrice = resp.resolvedRetailPrice; 1375 var taxIncludedYamiPrice = resp.taxIncludedYamiPrice; 1376 var taxIncludedRetailPrice = resp.taxIncludedRetailPrice; 1377 var taxIncludedResolvedRetailPrice = resp.taxIncludedResolvedRetailPrice; 1378 // isYamiCategory ã¯åååä½ã§ã®å¤å®ã®ããã鏿ããªã¨ã¼ã·ã§ã³ã§ã®éå¸é©ç¨å¯å¦ã¯ isUseYamiPrice ã§å¤æãã 1379 var isUseYamiPrice = resp.isUseYamiPrice; 1380 var isUseTradeRate = resp.isUseTradeRate; 1381 var discountRate = resp.discountRate; 1382 var isUseVariationPrice = resp.isUseVariationPrice; 1383 1384 if (isUseVariationPrice === '0') { 1385 // ããªã¨ã¼ã·ã§ã³ä¾¡æ ¼ã使ç¨ããªãå ´åã¯ä½ãããªã 1386 return false; 1387 } 1388 1389 // è²©å£²ä¾¡æ ¼è¡¨ç¤ºæè¨ 1390 var retailPriceMsg = ""; 1391 // éå¸ä¾¡æ ¼è¡¨ç¤ºæè¨ 1392 var yamiPriceMsg = ""; 1393 // åå¼ç¨®å¥é©ç¨å¾ä¾¡æ ¼è¡¨ç¤ºæè¨ 1394 var resolvedRetailPriceMsg = ""; 1395 1396 var $retailPriceElem = Sys(".sysRetailPriceValue"); 1397 var taxation = Sys("[name='data-taxation']").val(); 1398 1399 if ($retailPriceElem.attr("data-taxincludednonincludeddisplaysetting") === "1") { 1400 // ç¨è¾¼æã«ç¨æä¾¡æ ¼ã¨ç¨è¾¼ä¾¡æ ¼ã®ä¸¡æ¹ã表示ãã 1401 retailPriceMsg = 1402 formatNumber(retailPrice) + "å" 1403 + "<span class ='sysRetailPriceTaxIncluded'>ï¼ç¨è¾¼ " + formatNumber(taxIncludedRetailPrice + "åï¼</span>"); 1404 yamiPriceMsg = 1405 formatNumber(yamiPrice) + "å" 1406 + "<span class ='sysRetailPriceTaxIncluded'>ï¼ç¨è¾¼ " + formatNumber(taxIncludedYamiPrice + "åï¼</span>"); 1407 resolvedRetailPriceMsg = 1408 formatNumber(resolvedRetailPrice) + "å" 1409 + "<span class ='sysRetailPriceTaxIncluded'>ï¼ç¨è¾¼ " + formatNumber(taxIncludedResolvedRetailPrice + "åï¼</span>"); 1410 } else if ($retailPriceElem.attr("data-taxincludeddisplaysetting") === "1") { 1411 // ç¨æè¡¨ç¤ºãã 1412 retailPriceMsg = formatNumber(retailPrice) + "å" + taxation; 1413 yamiPriceMsg = formatNumber(yamiPrice) + "å" + taxation; 1414 resolvedRetailPriceMsg = formatNumber(resolvedRetailPrice) + "å" + taxation; 1415 } else { 1416 // ç¨è¾¼è¡¨ç¤ºãã 1417 retailPriceMsg = formatNumber(taxIncludedRetailPrice) + "å" + taxation; 1418 yamiPriceMsg = formatNumber(taxIncludedYamiPrice) + "å" + taxation; 1419 resolvedRetailPriceMsg = formatNumber(taxIncludedResolvedRetailPrice) + "å" + taxation; 1420 } 1421 1422 Sys(".sysVariationRetailPriceValue").html(retailPriceMsg); 1423 // é©ç¨å¾ä¾¡æ ¼(éå¸ > åå¼ç¨®å¥)ããã以å¤ã¯ç©ºæ¬ã«æ»ã 1424 if (isUseYamiPrice) { 1425 Sys(".sysVariationYamiPriceValue").html(yamiPriceMsg); 1426 Sys(".sysYamiPriceName").html("âé©ç¨å¾ä¾¡æ ¼"); 1427 } else if (isUseTradeRate) { 1428 Sys(".sysVariationYamiPriceValue").html(resolvedRetailPriceMsg); 1429 Sys(".sysYamiPriceName").html("â " + discountRate + "%å¼ã"); 1430 } else { 1431 Sys(".sysVariationYamiPriceValue").html(""); 1432 Sys(".sysYamiPriceName").html(""); 1433 } 1434 1435 if (isUseYamiPrice) { 1436 Sys("span[data-retail-price]").attr("data-retail-price", taxIncludedYamiPrice); 1437 } else if (isUseTradeRate) { 1438 // åå¼ç¨®å¥ã®æãç/åå¥ä¾¡æ ¼ãåæ ããé©ç¨å¾å価 1439 // 注: æ¢åã®éå¸¸ä¾¡æ ¼åå²ã¯åå hidden input ã®åç §ã»ã¬ã¯ã¿ã誤ã£ã¦ãã(name='data-tax-after-discount' 1440 // ãè¦ç´ 屿§ã¨ãã¦èµ°æ»ãã¦ãã)ããããªã
1440ã«ã¹ã¿ã è¨å®ã®å¤å®ã常㫠false ã«ãªãæ¢ç¥ãã°ãããã 1441 // æ¬åå²ã®ã¿æ£ããã»ã¬ã¯ã¿ã«æããã 1442 if (Sys("input[name='data-tax-after-discount']").val() === "1") { 1443 // ãããªãã«ã¹ã¿ã è¨å® 1444 Sys("span[data-retail-price]").attr("data-retail-price", resolvedRetailPrice); 1445 } else { 1446 Sys("span[data-retail-price]").attr("data-retail-price", taxIncludedResolvedRetailPrice); 1447 } 1448 } else { 1449 if (Sys("input[data-tax-after-discount]").attr("data-tax-after-discount") === "1") { 1450 // ãããªãã«ã¹ã¿ã è¨å® 1451 Sys("span[data-retail-price]").attr("data-retail-price", retailPrice); 1452 } else { 1453 Sys("span[data-retail-price]").attr("data-retail-price", taxIncludedRetailPrice); 1454 } 1455 } 1456 } 1457 1458 /** 1459 * Ajaxé信失ææã«ããªã¨ã¼ã·ã§ã³ä¾¡æ ¼ãã»ãããã 1460 */ 1461 function setVariationPriceIfError() { 1462 Sys(".sysVariationRetailPriceValue").html("ããªã¨ã¼ã·ã§ã³ä¾¡æ ¼ã®åå¾ã«å¤±æãã¾ããã"); 1463 Sys(".sysVariationYamiPriceValue").html("ããªã¨ã¼ã·ã§ã³ä¾¡æ ¼ã®åå¾ã«å¤±æãã¾ããã"); 1464 } 1465 1466 /** 1467 * æ°å¤ãã«ã³ãåºåããã 1468 * @param num 1469 * @return {string | *} 1470 */ 1471 function formatNumber(num) { 1472 num = num.toString().replace(/,/g, ""); 1473 while (num !== (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2"))); 1474 return num; 1475 } 1476}); 1477 1478/** 1479 * åå詳細ãã¼ã¸ãä¾¡æ ¼ã¾ããã®è«¸ã 1480 */ 1481Sys(function() { 1482 addEventListener('onSysAsyncElementLoaded', () => { 1483 if (isVariationSelected() && Sys("input[data-use-variation-price]").attr("data-use-variation-price") === "1") { 1484 // åæè¡¨ç¤ºæã«ããªã¨ã¼ã·ã§ã³ã鏿ããã¦ãã ã㤠ããªã¨ã¼ã·ã§ã³ä¾¡æ ¼ã使ç¨ããå ´å 1485 getDiscountPrice(1); 1486 } 1487 1488 document.querySelectorAll(".sysCartInForm").forEach((cartInForm) => { 1489 if (cartInForm.querySelector(".sysSubtotalPrice") !== null) { 1490 subTotal(Sys(cartInForm)); 1491 } 1492 }); 1493 1494 if (Sys('#sysItemDetail #sysGetPoint').length) { 1495 getPoint(this); 1496 } 1497 1498 if (isVariationSelected() && Sys('.variation_stock_quantity').length) { 1499 // é¸æç¶æ ã®æã ããå¨åº«æ°ã表示 1500 getVariationStock(this, ''); 1501 } 1502 1503 document.querySelectorAll(".sysCartInForm").forEach((cartInForm) => { 1504 Sys(cartInForm).change(function (e) { 1505 if (Sys(".sysDiscountedItemPrice").length || Sys(".sysDiscountPrice").length) { 1506 getDiscountPrice(Sys("[name='num']", this).val()); 1507 } 1508 1509 if (cartInForm.querySelector(".sysSubtotalPrice") !== null) { 1510 subTotal(this); 1511 } 1512 1513 if (Sys('#sysItemDetail #sysGetPoint').length) { 1514 getPoint(this); 1515 } 1516 1517 if (Sys('.variation_stock_quantity').length) { 1518 getVariationStock(this, e.target.id); 1519 } 1520 }); 1521 }); 1522 }); 1523 1524 1525 /** 1526 * ããªã¨ã¼ã·ã§ã³é¸æè¢ã鏿ããã¦ããã 1527 * @return {*} 1528 */ 1529 function isVariationSelected() { 1530 return Sys('#variation').val() 1531 || Sys('#variation_select1').val() || Sys('#variation_select2').val() 1532 || Sys("input[type='radio'][name='variation[selects][select1OptionNo][value]']:checked").val() 1533 || Sys("input[type='radio'][name='variation[selects][select2OptionNo][value]']:checked").val() 1534 || Sys("input[id='variationTable']:checked").val(); 1535 } 1536 1537 /** 1538 * å²å¼ä¾¡æ ¼ãåå¾ 1539 */ 1540 function getDiscountPrice(num) { 1541 Sys('.sysDiscountedItemPrice > span').html("Loading..."); 1542 Sys('.sysDiscountPrice > span').html("Loading..."); 1543 if (num === "undefined" || isNaN(num)) { 1544 num = Sys("[name='num']", this).val(); 1545 } 1546 Sys.ajax({ 1547 type: "GET", 1548 url: "/api/front/item/getDiscountItemPrice", 1549 data: { 1550 "itemNo": Sys("[name='itemNo']").val(), 1551 'num': num, 1552 }, 1553 dataType: "json", 1554 success: function(resp) { 1555 var discountPriceText = resp.discount_price_text; 1556 var discountPrice = resp.discount_price; 1557 Sys(".sysCartInForm").each(function() { 1558 Sys('.sysDiscountPrice > span').html(discountPriceText); 1559 Sys('#sysDiscountPrice').attr('data-discount-price', discountPrice); 1560 }); 1561 discountedPrice(num); 1562 }, 1563 error: function() { 1564 Sys('#sysDiscountPrice').html("å²å¼ä¾¡æ ¼ã®åå¾ã«å¤±æãã¾ããã"); 1565 } 1566 }); 1567 } 1568 1569 /** 1570 * åå詳細ãã¼ã¸ãå²å¼å¾ä¾¡æ ¼åæ 1571 */ 1572 function discountedPrice(num) { 1573 var retail_price = Sys("[data-retail-price]").attr("data-retail-price"); 1574 var taxation = Sys('[name=data-taxation]').val(); 1575 var price = retail_price;
1576 Sys("option:selected, input:checked", this).each(function(){ 1577 var adjust = 0; 1578 var rate = Sys(this).attr("data-rate"); 1579 var length_or_persent = Sys(this).attr("data-length-or-persent"); 1580 var calculation_type = Sys(this).attr("data-calculation-type"); 1581 var excluded_selects = Sys(this).attr("data-excluded-selects"); 1582 if (length_or_persent == 1) { 1583 var other_option_price = 0; 1584 if(calculation_type == 1) { 1585 Sys(this).parents(".sysCartInForm").find("option:selected, input:checked").each(function(){ 1586 var other_option_rate = Sys(this).attr("data-rate"); 1587 var other_option_length_or_persent = Sys(this).attr("data-length-or-persent"); 1588 var other_option_calculation_type = Sys(this).attr("data-calculation-type"); 1589 var other_option_select_no = Sys(this).attr("data-select-no"); 1590 1591 if(other_option_calculation_type == 0) { 1592 var flag = true; 1593 if (excluded_selects){ 1594 var excluded_selects_obj = Sys.parseJSON(excluded_selects); 1595 for(var i = 0; i < excluded_selects_obj.length; i++){ 1596 if(excluded_selects_obj[i] == other_option_select_no){ 1597 flag = false; 1598 break; 1599 } 1600 } 1601 } 1602 if(flag) { 1603 if (other_option_length_or_persent == 1) { 1604 other_option_price += parseInt(retail_price) * parseInt(other_option_rate) / 100; 1605 } else { 1606 other_option_price += parseInt(other_option_rate); 1607 } 1608 } 1609 } 1610 }); 1611 } 1612 adjust = Math.ceil((parseInt(retail_price) + parseInt(other_option_price)) * parseInt(rate) / 100); 1613 } else { 1614 adjust = rate; 1615 } 1616 if (typeof(adjust) != "undefined") { 1617 price = parseInt(price) + parseInt(adjust); 1618 } 1619 }); 1620 var data_discount = document.getElementById("sysDiscountPrice") 1621 if (!data_discount) { 1622 data_discount = document.getElementById("sysHiddenDiscountPrice"); 1623 } 1624 if (data_discount) { 1625 price = price * num; 1626 price = price - data_discount.getAttribute("data-discount-price"); 1627 price = Math.floor(price / num); 1628 } 1629 1630 price = addTaxAfterDiscount(data_discount, price, price, num); 1631 price = String(price).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); 1632 if (Sys(".sysRetailPrice").is(":contains('å')")) { 1633 Sys(".sysDiscountedItemPrice > span").html(price + "å" + taxation); 1634 } else { 1635 Sys(".sysDiscountedItemPrice > span").html( "¥" + price + taxation); 1636 } 1637 } 1638 1639 1640 function addTaxAfterDiscount(data_discount, price, single_item_price, num){ 1641 if (Sys('[name=data-tax-after-discount]').val() == 1) { 1642 price = parseInt(price); 1643 var tax_percentage = Sys('[name=data-tax-percentage]').val() / 100; 1644 if (data_discount) { 1645 var tax_price = Math.floor(price * tax_percentage); 1646 } else { 1647 var tax_price = Math.floor(single_item_price * tax_percentage); 1648 tax_price = tax_price * num; 1649 } 1650 price = price + tax_price; 1651 } 1652 return price; 1653 } 1654 1655 /** 1656 * ç²å¾äºå®ãã¤ã³ããç®åº 1657 */ 1658 function getPoint(element) { 1659 var data = { 1660 'itemNo' : Sys("[name='itemNo']", element).val(), 1661 'num': Sys('[name=num]', element).val(), 1662 'options': getOptions(element), 1663 'variationViewType': Sys('[name=variation_view_type]', element).val(), 1664 'variations': getVariations(element), 1665 }; 1666 Sys.ajax({ 1667 'type': 'GET', 1668 'url': '/api/front/item/getPoint', 1669 'data': data, 1670 }).done(function (resp) { 1671 var point = resp.point; 1672 if (point > 0) { 1673 var message = resp.is_login 1674 ? 'ç²å¾ãã¤ã³ãï¼<span class="get_point">' + point + '</span>' 1675 : '<span class="message">ä¼å¡ç»é²ãã¦è³¼å ¥ããã¨<span class="get_point">' + point + 'ãã¤ã³ã</span>ç²å¾ã§ãã¾ãã</span>'; 1676 Sys(element).find('#sysGetPoint').html(message); 1677 } else { 1678 Sys(element).find('#sysGetPoint').hide(); 1679 } 1680 }).fail(function () { 1681 Sys(element).find('#sysGetPoint').html('<span class="get_point">ç²å¾äºå®ãã¤ã³ãã表示ã§ãã¾ãã</span>'); 1682 }); 1683 } 1684 1685 /**
1686 * åå詳細ãã¼ã¸ãå°è¨åæ 1687 */ 1688 if (Sys("#sysSubtotal").length) { 1689 Sys(".sysCartInForm").each(function() { 1690 var self = this; 1691 // ãã©ã¼ã ã®å¤æ´ãæ¤ç¥ãã¦ãå°è¨ãåè¨ç® 1692 Sys(self).on('click', '.sysRentalSchedulesValid', function() { 1693 subTotal(self); 1694 }); 1695 }); 1696 } 1697 1698 /** 1699 * å°è¨ãç®åº 1700 */ 1701 function subTotal(element) { 1702 Sys.ajax({ 1703 type: 'GET', 1704 url: '/api/front/template/subtotal', 1705 contentType: 'application/json', 1706 data: { 1707 'itemNo': Sys("[name='itemNo']", element).val(), 1708 'num': Sys('[name=num]', element).val() || 0, 1709 'options': getOptions(element), 1710 'variationViewType': Sys('[name=variation_view_type]', element).val(), 1711 'variations': getVariations(element), 1712 'rentalStartDate': Sys("[data-rental-select-date='selected']").attr("data-rentalstartdate"), 1713 'rentalExtend': Sys("[name='rental_extend_date'] option:selected").val(), 1714 }, 1715 }).done(function (resp) { 1716 var title = Sys(element).find("[data-subtotal-name]").attr("data-subtotal-name"); 1717 Sys(element).find(".sysSubtotalPrice").html(title + resp['subTotal']); 1718 }).fail(function (resp) { 1719 Sys(element).find(".sysSubtotalPrice").html('å°è¨ã®åå¾ã«å¤±æãã¾ããã'); 1720 }).always(function (resp) { 1721 // 1722 }); 1723 } 1724 1725 /** 1726 * 鏿ä¸ã®ããªã¨ã¼ã·ã§ã³å¨åº«æ°ãåå¾ 1727 */ 1728 function getVariationStock(element, id) { 1729 // åæè¡¨ç¤ºæã¯ã¤ãã³ãçºç«ã®idè¦ç´ ã¯ç©ºæå® 1730 if ((id == '' && Sys("[name='variation_view_type']").val() !== '2') 1731 || (Sys("[name='variation_view_type']").val()=='0' && id=='variation') 1732 || (Sys("[name='variation_view_type']").val()=='1' && (id =='variation_select1' || id=='variation_select2')) 1733 || (Sys("[name='variation_view_type']").val()=='2' && id=='variationTable') 1734 ) { 1735 Sys('.sysStockQuantity > .variation_stock_quantity').html("Loading..."); 1736 } 1737 1738 var variationNoTable = Sys("input[id='variationTable']:checked").val(); 1739 var data = { 1740 'item_no': Sys("[name='itemNo']", element).val(), 1741 'option_no1': Sys('#variation_select1').val() || Sys("input[type='radio'][name='variation[selects][select1OptionNo][value]']:checked").val(), 1742 'option_no2': Sys('#variation_select2').val() || Sys("input[type='radio'][name='variation[selects][select2OptionNo][value]']:checked").val(), 1743 'variation_no': Sys('#variation').val(), 1744 'variation_no_table': variationNoTable == undefined ? 0 : variationNoTable, 1745 'variation_view_type': Sys('[name=variation_view_type]', element).val(), 1746 }; 1747 1748 Sys.ajax({ 1749 'type': 'GET', 1750 'url': '/api/front/item/getVariationStockQuantity', 1751 'data': data, 1752 }).done(function (resp) { 1753 var json = resp; 1754 if (json.length == 0) { 1755 Sys('.variation_stock_quantity').html("å¨åº«ã®åå¾ã«å¤±æãã¾ããã"); 1756 } 1757 if (json.variationStockQuantity <= json.stockDisplayQuantity) { 1758 if (json.variationStockQuantity === 0) { 1759 Sys('.variation_stock_quantity').html("Ã"); 1760 } else { 1761 Sys('.variation_stock_quantity').html("â³"); 1762 } 1763 } else { 1764 if (json.stockDisplayMethod === 2) { 1765 Sys('.variation_stock_quantity').html("â"); 1766 } else if (json.stockDisplayMethod === 1) { 1767 Sys('.variation_stock_quantity').html(json.variationStockQuantity); 1768 } 1769 } 1770 }).fail(function (resp) { 1771 Sys('.variation_stock_quantity').html("å¨åº«ã®åå¾ã«å¤±æãã¾ããã"); 1772 }); 1773 } 1774 1775 1776 1777 1778 1779 /** 1780 * 鏿ä¸ã®ãªãã·ã§ã³é¸æè¢ãåå¾ 1781 */ 1782 function getOptions(element) { 1783 var options = []; 1784 Sys('#sysSelections option:selected, #sysSelections input:checked', element).each(function () { 1785 options.push(Sys(this).val()); 1786 }); 1787 return options; 1788 } 1789 1790 /** 1791 * 鏿ä¸ã®ããªã¨ã¼ã·ã§ã³é¸æè¢ãåå¾ 1792 */ 1793 function getVariations(element) { 1794 var variationViewType = Sys('[name=variation_view_type]', element).val(); 1795 var variations = []; 1796 // åé ç®ãæãåããã¦è¡¨ç¤º 1797 if (variationViewType == 0) { 1798 if (Sys('#variation', element).val()) { 1799 // ã«ã¼ãã«å ¥ãããã¿ã³é表示 1800 variations.push(Sys('#variation', element).val()); 1801 } else { 1802 // ã«ã¼ãã«å ¥ãããã¿ã³è¡¨ç¤º 1803 // æ°ãã¶ã¤ã³ï¼ããªã¨ã¼ã·ã§ã³ç»åï¼ã¯ã³ã³ããidã #sysVariationWithImage ã®ãã両æ¹ã対象ã«ãã 1804 variations.push(Sys('#sysVariation input[name="variation[value]"], #sysVariationWithImage input[name="variation[value]"]', element).val()); 1805 } 1806 } 1807 // åé ç®ãåãã¦è¡¨ç¤º 1808 if (variationViewType == 1) { 1809 Sys('#sysVariation option:selected, #sysVariation input[type="radio"][name^="variation[selects]"]:checked, #sysVariationWithImage option:selected, #sysVariationWithImage input[type="radio"][name^="variation[selects]"]:checked', element).each(function () { 1810 variations.push(Sys(this).val()); 1811 }); 1812 } 1813 // 表çµã¿(ãã¼ãã«)表示 1814 if (variationViewType == 2) { 1815 if (Sys('#sysVariation input[name="variation[value]"]:checked, #sysVariationWithImage input[name="variation[value]"]:checked', element).val() != null) { 1816 variations.push(Sys('#sysVariation input[name="variation[value]"]:checked, #sysVariationWithImage input[name="variation[value]"]:checked', element).val()); 1817 } else { 1818 variations.push(Sys('#sysVariation input[name="variation[value]"], #sysVariationWithImage input[name="variation[value]"]', element).val()); 1819 } 1820 } 1821 return variations; 1822 } 1823 1824 /** 1825 * åå詳細ãã¼ã¸ã®å¯¾å¿ 1826 * å®æè³¼å ¥ã»éå¸ãèæ ®ãã¦ããªãã®ã§è¦æ³¨æ 1827 */ 1828 if (Sys("#sysSubtotal").length || Sys(".sysRetailPrice").length) { 1829 Sys(".sysCartInForm").change(addSetPrice); 1830 } 1831 1832 function addSetPrice() { 1833 var item_no = Sys("[name='itemNo']").val(); 1834 var num = Sys("[name='num']", this).val(); 1835 var taxation = "ï¼ç¨è¾¼ï¼"; 1836 Sys.ajax({ 1837 type: "GET", 1838 url: "/api/front/item/getItemSetPrice", 1839 data: { 1840 "item_no": item_no, 1841 "num": num, 1842 }, 1843 dataType: "json", 1844 error: function() { 1845 }, 1846 success: function(data) { 1847 if (data.length === 0) {return;} 1848 if (data.sub_item_price == 'current') { 1849 if (Sys('.sysSetRetailPrice')[0] || 1850 Sys('.sysSetSubtotalPrice')[0]) { 1851 Sys(".sysSetSubtotalPrice").remove(); 1852 Sys(".sysSetRetailPrice").remove(); 1853 } 1854 return; 1855 } 1856 1857 price = String(data.sub_total_price).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); 1858 item_price = String(data.sub_item_price).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); 1859 var set_price = "ã»ããä¾¡æ ¼" + Sys("[data-subtotal-name]").attr("data-subtotal-name"); 1860 var set_item_price = "ã»ããå価"; 1861 1862 if (Sys(".sysRetailPrice").is(":contains('å')")) { 1863 set_item_price += item_price + "å"; 1864 set_price += price + "å"; 1865 } else { 1866 set_item_price += "¥" + item_price; 1867 set_price += "¥" + price; 1868 } 1869 1870 set_item_price += taxation; 1871 set_price += taxation; 1872 1873 if (Sys('.sysSetRetailPrice')[0] || 1874 Sys('.sysSetSubtotalPrice')[0]) { 1875 Sys(".sysSetSubtotalPrice").html(set_price); 1876 Sys(".sysSetRetailPrice").html(set_item_price); 1877 } else { 1878 Sys(".sysSubtotalPrice").after("<span class='sysSetSubtotalPrice'>" + set_price + "</span>"); 1879 Sys(".sysRetailPriceValue").after("<span class='sysSetRetailPrice'>" + set_item_price + "</span>"); 1880 } 1881 } 1882 }); 1883 } 1884}); 1885 1886/** 1887 * åå詳細ãã¼ã¸ã®ååæ¹æ³é¸æ 1888 */ 1889Sys(function () { 1890 addEventListener('onSysAsyncElementLoaded', () => { 1891 var receiveStoreDetails = window.receiveStoreDetails; 1892 var hasReceiveStoreGroup = window.hasReceiveStoreGroup; 1893 1894 var receiveStoreGroupSelect = Sys("#receiveStoreGroup"); 1895 var receiveStoreSelect = Sys("#receiveStoreSelect"); 1896 var receiveDateSelect = Sys("#receiveDateSelect"); 1897 var receiveTimeSelect = Sys("#receiveTimeSelect"); 1898 var storeDescription = Sys("#storeDescription"); 1899 1900 var selectedReceiveStoreId = null; 1901 var sessionCartReceiveDate = ''; 1902 var sessionCartReceiveTime = ''; 1903 1904 if (window.sessionCartReceiveConditions) { 1905 selectedReceiveStoreId = window.sessionCartReceiveConditions.selectedReceiveStoreId; 1906 sessionCartReceiveDate = window.sessionCartReceiveConditions.selectedReceiveDate; 1907 sessionCartReceiveTime = window.sessionCartReceiveConditions.selectedReceiveTime; 1908 } 1909 1910 // ã»ã¬ã¯ãããã¯ã¹ã®åæè¡¨ç¤º 1911 var placeholderOption = '<option value="">--鏿ãã¦ãã ãã--</option>'; 1912 1913 onReceiveStoreGroupChange(); 1914 onReceiveStoreChange(); 1915 onReceiveDateChange(); 1916 onReceiveTimeChange(); 1917 1918 if (selectedReceiveStoreId) { 1919 // ã«ã¼ãå ã«åºèååã®ååãããå ´å 1920 displayMatchedReceiveStore(); 1921 return; 1922 } 1923 1924 if (hasReceiveStoreGroup) { 1925 initReceiveStoreGroupSelect(); 1926 } else { 1927 initReceiveStoreSelect(); 1928 } 1929 1930 // ã«ã¼ãå ã§åºèã鏿æ¸ã¿ã®åºèã表示ãã 1931 function displayMatchedReceiveStore() { 1932 var matchedStore = null; 1933 1934 receiveStoreDetails.some(function (group) { 1935 return group.receiveStores.some(function (store) { 1936 if (store.id == selectedReceiveStoreId) { 1937 matchedStore = store; 1938 return true; 1939 } 1940 return false;
1941 }); 1942 }); 1943 1944 var container = Sys('.selectedReceiveStore'); 1945 container.empty(); 1946 1947 if (matchedStore) { 1948 // ã«ã¼ãã§é¸ææ¸ã¿ã®åºèã§è³¼å ¥ã§ããååãªãåºèåã表示 1949 var label = Sys('<div>').addClass('sysReceiveStoreLabel').text('åºèåï¼'); 1950 var name = Sys('<span>').addClass('sysSelectedReceiveStoreName').text(matchedStore.name); 1951 var hiddenInput = Sys('<input type="hidden">').attr('name', 'receiveStoreId').val(matchedStore.id); 1952 1953 container.append(label).append(name).append(hiddenInput); 1954 1955 updateReceiveDateOptions(matchedStore, sessionCartReceiveDate); 1956 updateReceiveTimeOptions(matchedStore, sessionCartReceiveTime); 1957 updateStoreDescription(matchedStore); 1958 } else { 1959 var warning = Sys('<div>').html( 1960 'ã«ã¼ãã§é¸æä¸ã®åºèã§ã¯åãåããªãååã§ã<br>夿´ãããå ´åã¯ã«ã¼ãå ã®ååãåé¤ãã¦ãã ãã' 1961 ); 1962 container.append(warning); 1963 } 1964 } 1965 1966 // åºèã°ã«ã¼ãã®ã»ã¬ã¯ãããã¯ã¹ã表示ãã 1967 function initReceiveStoreGroupSelect() { 1968 receiveStoreGroupSelect.html(placeholderOption); 1969 1970 receiveStoreDetails.forEach(function (group, i) { 1971 var text = group.receiveStoreGroup || 'ãã®ä»'; 1972 receiveStoreGroupSelect.append(Sys('<option>').val(i).text(text)); 1973 }); 1974 1975 // 鏿è¢ã1ä»¶ã ããªãèªå鏿 1976 if (receiveStoreDetails.length === 1) { 1977 receiveStoreGroupSelect.val(0).trigger('change'); 1978 } 1979 }; 1980 1981 // åºèã°ã«ã¼ãã®ã»ã¬ã¯ãããã¯ã¹ã表示ããªã 1982 function initReceiveStoreSelect() { 1983 var group = null; 1984 //åºèã°ã«ã¼ããæªè¨å®ã®åºèãããªãå ´å 1985 if (Array.isArray(receiveStoreDetails)) { 1986 group = receiveStoreDetails.find(function (group) { 1987 return group.receiveStoreGroup === ""; 1988 }); 1989 } 1990 //åºèã°ã«ã¼ãã®è¨å®ããªãå ´å 1991 if (group && Array.isArray(group.receiveStores)) { 1992 group.receiveStores.forEach(function (store) { 1993 var option = Sys("<option>").val(store.id).text(store.name); 1994 receiveStoreSelect.append(option); 1995 }); 1996 // 鏿è¢ã1ä»¶ã ããªãèªå鏿 1997 if (group.receiveStores.length === 1) { 1998 receiveStoreSelect.val(group.receiveStores[0].id); 1999 receiveStoreSelect.trigger("change"); 2000 } 2001 } 2002 }; 2003 2004 // åºèã°ã«ã¼ãã®å¤æ´ 2005 function onReceiveStoreGroupChange() { 2006 receiveStoreGroupSelect.on("change", function () { 2007 var selectedIndex = parseInt(Sys(this).val(), 10); 2008 receiveStoreSelect.html(placeholderOption); 2009 if (isNaN(selectedIndex) || !receiveStoreDetails[selectedIndex]) return; 2010 2011 var stores = receiveStoreDetails[selectedIndex].receiveStores; 2012 2013 stores.forEach(function (store) { 2014 var option = Sys("<option>").val(store.id).text(store.name); 2015 receiveStoreSelect.append(option); 2016 }); 2017 2018 // 鏿è¢ã1ã¤ã ããªãèªå鏿 2019 if (stores.length === 1) { 2020 receiveStoreSelect.val(stores[0].id).trigger("change"); 2021 } 2022 }); 2023 } 2024 2025 // åååºèã®æ´æ° 2026 function onReceiveStoreChange() { 2027 receiveStoreSelect.on("change", function () { 2028 var currentReceiveStoreId = Sys(this).val(); 2029 var selectedIndex = receiveStoreGroupSelect.val(); 2030 2031 var selectedGroup = null; 2032 if (hasReceiveStoreGroup) { 2033 if (selectedIndex !== "" && receiveStoreDetails[selectedIndex]) { 2034 selectedGroup = receiveStoreDetails[selectedIndex]; 2035 } 2036 } else { 2037 // åºèã°ã«ã¼ããåå¨ããªãå ´å 2038 selectedGroup = receiveStoreDetails.find(function (group) { 2039 return group.receiveStoreGroup === ""; 2040 }); 2041 } 2042 2043 var receiveStoreDetail = null; 2044 2045 if (selectedGroup) { 2046 receiveStoreDetail = selectedGroup.receiveStores.find(function (store) { 2047 return store.id == currentReceiveStoreId; 2048 }); 2049 } 2050 2051 updateReceiveDateOptions(receiveStoreDetail, sessionCartReceiveDate); 2052 updateReceiveTimeOptions(receiveStoreDetail, sessionCartReceiveTime); 2053 updateStoreDescription(receiveStoreDetail); 2054 }); 2055 } 2056 2057 // ååæ¥ã®æ´æ° 2058 function updateReceiveDateOptions(receiveStoreDetail, sessionCartReceiveDate) { 2059 receiveDateSelect.html(placeholderOption); 2060 if (receiveStoreDetail) { 2061 const receiveDates = Object.entries(receiveStoreDetail.receiveDates);
2062 receiveDates.forEach(function ([date, label]) { 2063 var option = Sys('<option>').val(date).text(label); 2064 if (date == sessionCartReceiveDate) { 2065 option.prop('selected', true); 2066 } 2067 receiveDateSelect.append(option); 2068 }); 2069 2070 // 鏿è¢ã1ã¤ã ããªãèªå鏿 2071 if (receiveDates.length === 1) { 2072 receiveDateSelect.val(receiveDates[0][0]).trigger("change"); 2073 } 2074 } 2075 } 2076 2077 // ååæéã®æ´æ° 2078 function updateReceiveTimeOptions(receiveStoreDetail, sessionCartReceiveTime) { 2079 receiveTimeSelect.html(placeholderOption); 2080 if (receiveStoreDetail) { 2081 receiveStoreDetail.receiveTimes.forEach(function (time) { 2082 var option = Sys('<option>').val(time).text(time); 2083 if (time == sessionCartReceiveTime) { 2084 option.prop('selected', true); 2085 } 2086 receiveTimeSelect.append(option); 2087 }); 2088 2089 // 鏿è¢ã1ã¤ã ããªãèªå鏿 2090 if (receiveStoreDetail.receiveTimes.length === 1) { 2091 receiveTimeSelect.val(receiveStoreDetail.receiveTimes[0]).trigger("change"); 2092 } 2093 } 2094 } 2095 2096 // åèã®æ´æ° 2097 function updateStoreDescription(receiveStoreDetail) { 2098 storeDescription.html(''); 2099 if (receiveStoreDetail && receiveStoreDetail.description_for_site) { 2100 storeDescription.html(receiveStoreDetail.description_for_site); 2101 } 2102 } 2103 2104 // å忥ã®å¤æ´ 2105 function onReceiveDateChange() { 2106 receiveDateSelect.on("change", function () { 2107 if (!sessionCartReceiveDate) return; 2108 validateReceiveDateSelection(); 2109 }); 2110 } 2111 2112 //ã«ã¼ãå ã®å忥ã¨ç°ãªãå忥ã鏿ãããå ´åã«æ³¨éã表示 2113 function validateReceiveDateSelection() { 2114 var currentSelectedReceiveDate = receiveDateSelect.val(); 2115 var receiveDateChangeMessage = receiveDateSelect.next(".receiveDateChangeMessage"); 2116 2117 if (currentSelectedReceiveDate != sessionCartReceiveDate){ 2118 if (receiveDateChangeMessage.length == 0) { 2119 var $errorMsg = Sys('<p class="receiveDateChangeMessage">').text("ã«ã¼ãå ã®ååã®å忥ãåæã«å¤æ´ããã¾ã"); 2120 receiveDateSelect.after($errorMsg); 2121 } 2122 } else { 2123 if (receiveDateChangeMessage.length > 0) { 2124 receiveDateChangeMessage.remove(); 2125 } 2126 } 2127 } 2128 2129 // ååæéã®å¤æ´ 2130 function onReceiveTimeChange() { 2131 receiveTimeSelect.on("change", function () { 2132 if (!sessionCartReceiveDate) return; 2133 validateReceiveTimeSelection(); 2134 }); 2135 } 2136 2137 //ã«ã¼ãå ã®ååæéã¨ç°ãªãååæéã鏿ãããå ´åã«æ³¨éã表示 2138 function validateReceiveTimeSelection() { 2139 var currentSelectedReceiveTime = receiveTimeSelect.val(); 2140 var receiveTimeChangeMessage = receiveTimeSelect.next(".receiveTimeChangeMessage"); 2141 2142 if (currentSelectedReceiveTime != sessionCartReceiveTime) { 2143 if (receiveTimeChangeMessage.length == 0) { 2144 var $errorMsg = Sys('<p class="receiveTimeChangeMessage">').text("ã«ã¼ãå ã®ååã®ååæéãåæã«å¤æ´ããã¾ã"); 2145 receiveTimeSelect.after($errorMsg); 2146 } 2147 } else { 2148 if (receiveTimeChangeMessage.length > 0) { 2149 receiveTimeChangeMessage.remove(); 2150 } 2151 } 2152 } 2153 }); 2154}); 2155 2156/** 2157 * åå詳細ãã¼ã¸ã®ååæ¹æ³é¸æã®è¡¨ç¤ºåæ¿ 2158 */ 2159Sys(function () { 2160 addEventListener('onSysAsyncElementLoaded', () => { 2161 function toggleContent() { 2162 2163 var receiveAtStoreContent = Sys('#receiveAtStoreContent'); 2164 var socialGiftContent = Sys('#socialGiftContent'); 2165 2166 var receiveAtStoreType = window.receiveAtStoreType; 2167 var isOnlySocialGift = window.isOnlySocialGift 2168 2169 if (isOnlySocialGift) { 2170 receiveAtStoreContent.hide(); 2171 socialGiftContent.show(); 2172 return; 2173 } 2174 2175 if (receiveAtStoreType == 3) { 2176 receiveAtStoreContent.show(); 2177 socialGiftContent.hide(); 2178 return; 2179 } 2180 2181 var isDelivery = Sys('#delivery').prop('checked');
2182 var isReceiveAtStore = Sys('#receiveAtStore').prop('checked'); 2183 var isSocialGift = Sys('#socialGift').prop('checked'); 2184 2185 if (isDelivery) { 2186 receiveAtStoreContent.hide(); 2187 socialGiftContent.hide(); 2188 } 2189 else if (isReceiveAtStore) { 2190 receiveAtStoreContent.show(); 2191 socialGiftContent.hide(); 2192 } else if (isSocialGift) { 2193 receiveAtStoreContent.hide(); 2194 socialGiftContent.show(); 2195 } else { 2196 receiveAtStoreContent.hide(); 2197 socialGiftContent.hide(); 2198 } 2199 } 2200 Sys('#receiveAtStore, #delivery, #socialGift').on('change', toggleContent); 2201 toggleContent(); 2202 }); 2203}); 2204 2205/** 2206 * åå詳細ãã¼ã¸ã®é éäºå®æ¥ 2207 */ 2208Sys(function() { 2209 document.querySelectorAll(".sysDeliveryDateForm").forEach((deliveryDateForm) => { 2210 Sys(deliveryDateForm).change(function () { 2211 // å¤ã夿´ãããæã®å¦ç 2212 deliveryDate(this); 2213 }); 2214 }); 2215 2216 /** 2217 * é éäºå®æ¥ãåå¾ 2218 */ 2219 function deliveryDate(element) { 2220 Sys.ajax({ 2221 type: 'GET', 2222 url: '/api/front/template/deliveryDate', 2223 contentType: 'application/json', 2224 data: { 2225 'itemNo': Sys("[name='itemNo']", element).val(), 2226 'prefStateId': Sys("#prefStateId option:selected", element).val(), 2227 }, 2228 }).done(function (resp) { 2229 var sysDeliveryDateString = Sys(element).find(".sysDeliveryDateString"); 2230 var sysNoAvailableDatesMessage = Sys(element).find(".sysDeliveryDateNoAvailableDatesMessage"); 2231 2232 if (resp['deliveryDate'] != '') { 2233 Sys(element).find(".sysDeliveryDateEarliestDeliveryDate").text(resp['deliveryDate']); 2234 sysDeliveryDateString.show(); 2235 sysNoAvailableDatesMessage.hide(); 2236 } else { 2237 sysDeliveryDateString.hide(); 2238 sysNoAvailableDatesMessage.show(); 2239 } 2240 }).fail(function (resp) { 2241 Sys(element).find(".sysDeliveryDateString").hide(); 2242 Sys(element).find(".sysDeliveryDateNoAvailableDatesMessage").hide(); 2243 Sys(".sysDeliveryDateArea").html("é éäºå®æ¥ã®åå¾ã«å¤±æãã¾ãã"); 2244 }); 2245 } 2246}); 2247/** 2248 * ååã®æ°éã®ï¼ï¼ 2249 */ 2250Sys(function(){ 2251 Sys('[data-num-plus]').off('click'); 2252 Sys('[data-num-minus]').off('click'); 2253 Sys('[name=num]').off('change'); 2254 2255 Sys(document).on('click', '[data-num-plus]', function() { 2256 var mythis = Sys(this).parents(".sysCartInForm"); 2257 var num = mythis.find('[name*=num]'); 2258 if (num.children().last().val() != num.val()) { 2259 num.val(parseInt(num.val())+1); 2260 num.change(); 2261 } 2262 }); 2263 2264 Sys(document).on('click', '[data-num-minus]', function() { 2265 var mythis = Sys(this).parents(".sysCartInForm"); 2266 var num = mythis.find('[name*=num]'); 2267 if (num.children().first().val() != num.val()) { 2268 num.val(parseInt(num.val())-1); 2269 num.change(); 2270 } 2271 }); 2272 2273}); 2274 2275/** 2276 * ã«ã¼ãã«å ¥ããéåæå¦ç 2277 * 2278 * IE ã¯ã¯ãã¹ãã¡ã¤ã³ã® ajax ã§ããªãã®ã§å²æ 2279 * .sysSelectCartButton .sysCartInButton .sysAddGoCartButton .sysGoCartButton 2280 */ 2281Sys(function(){ 2282 Sys(document).on('click', '.sysSelectCartButton, .sysCartInButton', function(event){ 2283 if (Sys().userAgent().indexOf('msie') != -1) { return null; } 2284 2285 event.preventDefault(); 2286 event.stopPropagation(); 2287 var context = this; 2288 2289 var loader = Sys("<div><img src='/base/img/ajax-loader-indicator.gif' style=\"width: 16px; height: 16px;\" /></div>"); 2290 Sys(document).ajaxSend(function() { 2291 Sys(context).before(loader); 2292 }); 2293 Sys(document).ajaxComplete(function() { 2294 loader.remove(); 2295 Sys(document).off("ajaxSend"); 2296 }); 2297 if (Sys(context).is('.sysSelectCartButton')) { 2298 if (Sys(context).is('.sysItemSelection')) { 2299 Sys.ajax(clickSelectCartButtonWithItemSelection(context)); 2300 } 2301 if (Sys(context).is(".sysStockTypeVariation")) { 2302 Sys.ajax(clickSelectCartButtonWithStockTypeVariation(context)); 2303 } 2304 } else if (Sys(context).is(".sysCartInButton")) { 2305 Sys.ajax(clickCartInButton(context)); 2306 } 2307 }); 2308 2309 // åå¥ååãªãã·ã§ã³ 2310 var clickSelectCartButtonWithItemSelection = function(context) { 2311 var isReorder = Sys(context).is('.sysReorderButton') ? 1 : 0; 2312 var itemNo = Sys(context).siblings('input[name="itemNo"]').val(); 2313 var data = { 2314 url: '/api/front/template/formSelection', 2315 is_reorder: isReorder, 2316 item_no: itemNo, 2317 ajax_flag: 1 2318 }; 2319 2320 return { 2321 type: 'GET', 2322 url: data['url'], 2323 data: data, 2324 success: function(response) { 2325 // éå¸ååã®ãã鏿è¢ãåå¾ã§ããªãå ´åã¯ã¡ãã»ã¼ã¸ãåºã 2326 var errorMessage = response.sysErrorMessage; 2327 if (!errorMessage) { 2328 var toggleButton = Sys(context).parents('form').find('.sysItemSelection'); 2329 toggleButton.val('ã«ã¼ãã«å ¥ãã'); 2330 toggleButton.removeClass('sysSelectCartButton'); 2331 if (Sys(context).parents('form').find('[name=ajaxFlag]').val() != 0) { 2332 toggleButton.addClass('sysCartInButton'); 2333 } 2334 toggleButton.before('<div class="sysAddSelection">' + response + '</div>'); 2335 if (window.fromOpc) { 2336 Sys(context).parents('form').append('<input name="fromOpc" value="true" type="hidden" />'); 2337 Sys(context).parents('form').append('<input name="skipToUpdateConsitencyKey" value="true" type="hidden"/>'); 2338 } 2339 } else { 2340 // éå¸ååã®å ´åã¯ã¡ãã»ã¼ã¸ãåºã 2341 var message = Sys('<p class="sysCartInDone"><span>' + errorMessage + '</span></p>'); 2342 Sys(context).before(message); 2343 setTimeout(function() { 2344 message.fadeOut('slow', function() { message.remove(); }); 2345 }, 3000); 2346 } 2347 }, 2348 error: function(response) { 2349 catchCartInDoneError(context, response); 2350 } 2351 }; 2352 }; 2353 2354 // ããªã¨ã¼ã·ã§ã³å¨åº« 2355 var clickSelectCartButtonWithStockTypeVariation = function(context) { 2356 var isReorder = Sys(context).is('.sysReorderButton') ? 1 : 0; 2357 var itemNo = Sys(context).siblings('input[name="itemNo"]').val(); 2358 2359 var data = { 2360 is_reorder: isReorder, 2361 item_no: itemNo, 2362 ajax_flag: 1 2363 }; 2364 return { 2365 type: 'GET', 2366 url: '/api/front/template/formVariationViewType/0', 2367 data: data, 2368 success: function(response) { 2369 // éå¸ååã®ãã鏿è¢ãåå¾ã§ããªãå ´åã¯ã¡ãã»ã¼ã¸ãåºã 2370 var errorMessage = response.sysErrorMessage; 2371 if (!errorMessage) { 2372 var toggleButton = Sys(context).parents('form').find('.sysStockTypeVariation'); 2373 toggleButton.val('ã«ã¼ãã«å ¥ãã'); 2374 toggleButton.removeClass('sysSelectCartButton'); 2375 if (Sys(context).parents('form').find('[name=ajaxFlag]').val() != 0) { 2376 toggleButton.addClass('sysCartInButton'); 2377 } 2378 2379 toggleButton.before('<div class="sysAddVariation">' + response + '</div>'); 2380 2381 var $variation = Sys(context).closest("form").find("div.sysAddVariation > select#variation"); 2382 if ($variation.val()) {
2383 updateVariationPriceByVariationNo($variation.val(), $variation); 2384 } 2385 2386 $variation.on("change", function () { 2387 if (Sys(this).val()) { 2388 updateVariationPriceByVariationNo(Sys(this).val(), Sys(this)); 2389 } 2390 }); 2391 2392 if (window.fromOpc) { 2393 Sys(context).parents('form').append('<input name="fromOpc" value="true" type="hidden" />'); 2394 Sys(context).parents('form').append('<input name="skipToUpdateConsitencyKey" value="true" type="hidden"/>'); 2395 } 2396 } else { 2397 // éå¸ååã®å ´åã¯ã¡ãã»ã¼ã¸ãåºã 2398 var message = Sys('<p class="sysCartInDone"><span>' + errorMessage + '</span></p>'); 2399 Sys(context).before(message); 2400 setTimeout(function() { 2401 message.fadeOut('slow', function() { message.remove(); }); 2402 }, 3000); 2403 } 2404 }, 2405 error: function(response) { 2406 catchCartInDoneError(context, response); 2407 } 2408 }; 2409 } 2410 2411 /** 2412 * ã«ã¼ãã«å ¥ãããã¿ã³ãæ¼ä¸ 2413 */ 2414 // åå詳細ãã¼ã¸ã§ãã¡ã¤ã«ãæ·»ä»ãã¦ã«ã¼ãã¤ã³ã
2414§ãããããFormDataãç¨ãã¦multipart/form-dataã§éä¿¡ãã 2415 var clickCartInButton = function(context) { 2416 var form = Sys(context).parents('form')[0]; 2417 var formData = new FormData(form); 2418 2419 // ããªã¨ã¼ã·ã§ã³åå¥ãã©ã¼ã ã®å ´åããã¡ã¤ã«inputãform屿§ã§ã¡ã¤ã³ãã©ã¼ã ã« 2420 // ç´ã¥ãã¦ããããFormDataã«å«ã¾ããªããæåã§è¿½å ããã 2421 var fileInput = document.getElementById('sysAttachedFileInput'); 2422 if (fileInput && fileInput.files.length > 0 && !formData.has('attachedFile')) { 2423 formData.append('attachedFile', fileInput.files[0]); 2424 } 2425 2426 return { 2427 type: 'POST', 2428 url: '/api/front/cart/cartIn', 2429 data: formData, 2430 contentType: false, // FormDataãèªåè¨å®ããmultipart/form-dataããjQueryãapplication/x-www-urlencodedã«ä¸æ¸ãããã®ãé²ã 2431 processData: false, // FormDataãªãã¸ã§ã¯ããURLã¨ã³ã³ã¼ãæååã«å¤æãããªã 2432 success: function(response) { 2433 error_message = response; 2434 if (error_message == null || (Array.isArray(error_message) && error_message.length === 0)) { 2435 var message = Sys("<p class='sysCartInDone'><span>ã«ã¼ãã«å ¥ãã¾ããã</span></p>"); 2436 // ãã¿ã³ã®åãæ¿ã 2437 changeCartButton(Sys(context).parents("form")); 2438 // éåæã®éã«ã¼ãã«å ¥ããæã®ååãªãã·ã§ã³ãããªã¨ã¼ã·ã§ã³å¨åº«é ç®ã¨ãã¿ã³æå 2439 var boolVariation = Sys(context).is('.sysStockTypeVariation'); 2440 var boolSelection = Sys(context).is('.sysItemSelection'); 2441 var boolReorder = Sys(context).is('.sysReorderButton'); 2442 var ToggleButton = Sys(context).parents("form").find(".sysCartInButton"); 2443 if (boolReorder) { 2444 ToggleButton.val("åæ³¨æãã"); 2445 if (Sys(context).parents("form").find(".sysAddVariation").length) { 2446 Sys(context).parents("form").find(".sysAddVariation").remove(); 2447 } 2448 if (Sys(context).parents("form").find(".sysAddSelection").length) { 2449 Sys(context).parents("form").find(".sysAddSelection").remove(); 2450 } 2451 ToggleButton.removeClass("sysCartInButton").addClass("sysSelectCartButton"); 2452 } else if (boolVariation || boolSelection) { 2453 if (Sys(context).parents("form").find(".sysAddVariation").length) { 2454 Sys(context).parents("form").find(".sysAddVariation").remove(); 2455 ToggleButton.val("ããªã¨ã¼ã·ã§ã³é¸æ"); 2456 } 2457 if (Sys(context).parents("form").find(".sysAddSelection").length) { 2458 Sys(context).parents("form").find(".sysAddSelection").remove(); 2459 ToggleButton.val("ãªãã·ã§ã³é¸æ"); 2460 } 2461 ToggleButton.removeClass("sysCartInButton").addClass("sysSelectCartButton"); 2462 } 2463 2464 dispatchEvent(new CustomEvent('cartupdated')); 2465 if (window.fromOpc) { 2466 app.onCartin(); 2467 } 2468 } else { 2469 var message = Sys("<p class='sysCartInDone'><span>" + error_message.join('<br>') + "</span></p>"); 2470 } 2471 Sys(context).before(message); 2472 setTimeout(function(){ 2473 message.fadeOut('slow', function(){ message.remove(); }); 2474 }, 3000); 2475 }, 2476 error: function(response) { 2477 catchCartInDoneError(context, response); 2478 } 2479 }; 2480 }; 2481 2482 var catchCartInDoneError = function(context, response) { 2483 resp = JSON.parse(response.responseText); 2484 let message = ''; 2485 if (resp && resp.message) { 2486 message = Sys("<p class='sysCartInDone'><span>"+resp.message+"</span></p>"); 2487 } else { 2488 message = Sys("<p class='sysCartInDone'><span>ã¨ã©ã¼ãçºçãã¾ããã</span></p>"); 2489 } 2490 Sys(context).before(message); 2491 setTimeout(function(){ 2492 message.fadeOut('slow', function(){ message.remove(); }); 2493 }, 2000); 2494 }; 2495 2496 /** 2497 * ãã¿ã³ãåãæ¿ããï¼ã«ã¼ãã«å ¥ãã â ã«ã¼ããè¦ãï¼ 2498 */ 2499 function changeCartButton(element) { 2500 var cartInButton = element.find(".sysCartInButton"); 2501 if (!cartInButton.is(".sysAddGoCartButton")) { 2502 cartInButton.hide(); 2503 } 2504 if (element.find(".sysGoCartButton").length == 0) { 2505 var goCartButton = Sys('<input>', { 2506 type: 'submit', 2507 value: 'ã«ã¼ããè¦ã', 2508 class: 'sysCartButton sysGoCartButton' 2509 }); 2510 var wrappedButton = Sys('<div></div>').append(goCartButton); 2511 Sys(cartInButton).after(wrappedButton); 2512 } 2513 } 2514 2515 /** 2516 * ãã¿ã³ãåãæ¿ããï¼ã«ã¼ããè¦ããã¿ã³æ¼ä¸ï¼ 2517 */ 2518 Sys(document).on('click', '.sysGoCartButton', function(e) { 2519 e.preventDefault(); 2520 window.location.href = '/cart/basket.html'; 2521 }); 2522 2523 /** 2524 * æ°å¤ãã«ã³ãåºåããã 2525 * @param num æ°å¤ 2526 * @return {string | *} 2527 */ 2528 function formatNumber(num) { 2529 num = num.toString().replace(/,/g, ""); 2530 while (num !== (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2"))); 2531 return num; 2532 } 2533 2534 /** 2535 * ããªã¨ã¼ã·ã§ã³ä¾¡æ ¼ãæ´æ°ãã 2536 * @param variationNo ããªã¨ã¼ã·ã§ã³No 2537 */ 2538 function updateVariationPriceByVariationNo(variationNo, variationSelect) { 2539 Sys.ajax({ 2540 type: "GET", 2541 url: '/api/front/item/getVariationPriceByVariationNo', 2542 async: false, 2543 data: { 2544 "variation_no": variationNo 2545 } 2546 }) 2547 .done(function (resp) { 2548 var isUseVariationPrice = resp.is_use_variation_price; 2549 if (isUseVariationPrice === '0') { 2550 // ããªã¨ã¼ã·ã§ã³ä¾¡æ ¼ã使ç¨ããªãå ´åã¯ä½ãããªã 2551 return false;
2552 } 2553 2554 var $li = variationSelect.closest("li"); 2555 var taxation = $li.find("input[name='displayed_taxation']").val(); 2556 // éå¸è¡¨ç¤ºè¨å®(Category/Search ã®ã¿ä»ä¸ãååãããã¯ã¯å±æ§ãªã=false æ±ã) 2557 var isDisplayYamiPrice = $li.attr("data-is-display-yami-price") === "1"; 2558 2559 // åå¼ç¨®å¥ã silently åæ ããä¾¡æ ¼(éå¸ã¯å«ããªã) 2560 // ååãããã¯ã Category/Search é常ã¢ã¼ãã¯éå¸ã表ã«åºããªãæ¹éã®ãããã¡ãã使ã 2561 var silentPrice = resp.is_use_trade_rate 2562 ? resp.tax_included_resolved_retail_price 2563 : resp.tax_included_retail_price; 2564 var silentPriceMsg = formatNumber(silentPrice) + "å" + taxation; 2565 2566 // é©ç¨å¾ä¾¡æ ¼(éå¸ > åå¼ç¨®å¥ > é常 ã®åªå é ) 2567 // éå¸ã¯ is_display_yami_price ON ã®ã¨ãã®ã¿æ¡ç¨ãã 2568 var effectivePrice; 2569 if (resp.is_use_yami_price && isDisplayYamiPrice) { 2570 effectivePrice = resp.tax_included_yami_price; 2571 } else if (resp.is_use_trade_rate) { 2572 effectivePrice = resp.tax_included_resolved_retail_price; 2573 } else { 2574 effectivePrice = resp.tax_included_retail_price; 2575 } 2576 var effectivePriceMsg = formatNumber(effectivePrice) + "å" + taxation; 2577 2578 // å ä¾¡æ ¼(æã¡æ¶ãç·ä½µè¨ç¨) 2579 var retailPriceMsg = formatNumber(resp.tax_included_retail_price) + "å" + taxation; 2580 2581 // ååããã㯠(éå¸é表示æ¹éãåå¼ç¨®å¥ã®ã¿ silently åæ ) 2582 $li.find("div.sysItemPrice").html( 2583 '<span class="sysItemBlockVariationPrice">' + silentPriceMsg + '</span>' 2584 ); 2585 2586 // Category/Search é常ã¢ã¼ã (sysRetailPrice ã®ã¿åå¨ãé©ç¨å¾è¡¨ç¤ºãªã) 2587 // éå¸ã¯åºãããåå¼ç¨®å¥ silently åæ 2588 $li.find("div.sysRetailPrice .sysItemBlockVariationPrice").html(silentPriceMsg); 2589 2590 // Category/Search é©ç¨å¾ã¢ã¼ã (sysOriginRetailPrice æã¡æ¶ãç· + é©ç¨å¾) 2591 $li.find("div.sysOriginRetailPrice .sysItemBlockVariationPrice").html(retailPriceMsg); 2592 $li.find(".sysItemBlockVariationYamiPrice").html(effectivePriceMsg); 2593 }) 2594 .fail(function () { 2595 variationSelect.closest("li").find("div.sysItemPrice").html( 2596 '<span class="sysItemBlockVariationPrice">' + "ããªã¨ã¼ã·ã§ã³ä¾¡æ ¼ã®åå¾ã«å¤±æãã¾ããã" + '</span>' 2597 ); 2598 }); 2599 } 2600}); 2601 2602/** 2603 * ååç»åã¢ã¼ãã«è¡¨ç¤º 2604 */ 2605Sys(function(){ 2606 2607 var ItemImageList = {}; 2608 ItemImageList.mainclick = function(event){ 2609 event.preventDefault(); 2610 event.stopPropagation(); 2611 2612 var contents = Sys("<div>").attr('class', 'sysModalItemImages'); 2613 var main = Sys("<div>").attr('class', 'sysModalMainImage'); 2614 var list = Sys("<ul>").attr('class', 'sysModalImageList'); 2615 2616 var parent = Sys(this).closest('.sysItemImages'); 2617 Sys(parent).find("li").each(function(){ 2618 var media = Sys(this).find('img, video').eq(0); 2619 if (!media.length) { 2620 return; 2621 } 2622 var isVideo = media.prop('tagName') && media.prop('tagName').toLowerCase() === 'video'; 2623 var srcAttr = media.attr('src'); 2624 var titleAttr = media.attr('title') || ''; 2625 var altAttr = media.attr('alt') || media.attr('aria-label') || ''; 2626 var listItem = Sys("<li>"); 2627 if (isVideo) { 2628 var posterAttr = media.attr('poster') || ''; 2629 var playbackProps = {muted: true, playsInline: true, preload: 'metadata'}; 2630 var videoAttrs = { 2631 'src': srcAttr, 2632 'title': titleAttr, 2633 'aria-label': altAttr 2634 }; 2635 if (posterAttr) { 2636 videoAttrs['poster'] = posterAttr; 2637 } 2638 var video = Sys("<video>").attr(videoAttrs).attr(playbackProps).prop(playbackProps); 2639 listItem.append(video); 2640 } else { 2641 var img = Sys("<img>").attr({ 2642 'src': srcAttr, 2643 'title': titleAttr, 2644 'alt': altAttr 2645 }); 2646 listItem.append(img); 2647 } 2648 list.append(listItem); 2649 2650 }); 2651 contents.append(main); 2652 contents.append(list); 2653 ModalWindow.open(contents); 2654 var index = Sys(parent).find(".sysCurrent").index(); 2655 ModalItemImageList.init(index); 2656 //location.hash = 'openItemImage'; 2657 }; 2658 2659 var ModalItemImageList = {}; 2660 ModalItemImageList.init = function(index){ 2661 Sys('.sysModalImageList img, .sysModalImageList video').eq(index).trigger("click"); 2662 }; 2663 ModalItemImageList.click = function(){ 2664 ModalItemImageList.updateMain(Sys(this)); 2665 }; 2666 ModalItemImageList.updateMain = function(current){ 2667 var parent = current.closest('.sysModalItemImages'); 2668 parent.find('li').removeClass('sysCurrent'); 2669 current.parent().addClass('sysCurrent'); 2670 var isVideo = current.prop('tagName') && current.prop('tagName').toLowerCase() === 'video'; 2671 var mainMedia; 2672 if (isVideo) { 2673 var posterAttr = current.attr('poster') || '';
2674 var playbackProps = {muted: true, playsInline: true, autoplay: true, loop: true, preload: 'metadata'}; 2675 var videoAttrs = { 2676 'src': current.attr('src'), 2677 'title': current.attr('title') || '', 2678 'aria-label': current.attr('aria-label') || '' 2679 }; 2680 // autoplayæã®ã¡ãã¤ãåé¿ã®ãããåæè¡¨ç¤ºã§ã¯posterãä»ä¸ããªã 2681 mainMedia = Sys('<video/>').attr(videoAttrs).attr(playbackProps).prop(playbackProps); 2682 } else { 2683 mainMedia = Sys('<img/>').attr({ 2684 'src': current.attr('src'), 2685 'title': current.attr('title'), 2686 'alt': current.attr('alt') 2687 }); 2688 } 2689 parent.find('.sysModalMainImage').html(mainMedia); 2690 if (isVideo) { 2691 var videoElement = mainMedia.get(0); 2692 if (videoElement && typeof videoElement.play === 'function') { 2693 videoElement.play().catch(function () { 2694 // autoplayå¶éã§åç失æããå ´åã®ã¿posterãå¾ä»ããã¦é»ç»é¢ãé¿ãã 2695 if (posterAttr) { 2696 videoElement.setAttribute('poster', posterAttr); 2697 } 2698 }); 2699 } 2700 } 2701 //parent.find('.sysImageDescription').html(current.attr('alt')); 2702 }; 2703 Sys(document).on('click', '.sysMainImageModal img, .sysMainImageModal video, .sysMainImageModal', ItemImageList.mainclick); 2704 Sys(document).on('click', '.sysModalImageList img, .sysModalImageList video', ModalItemImageList.click); 2705}); 2706 2707/** 2708 * ã¢ã¼ãã«è¡¨ç¤º 2709 * 2710 */ 2711Sys(function(){ 2712 ModalWindow = new Array(); 2713 2714 ModalWindow.bind = function(){ 2715 Sys(document).on('click', "a[href='#closeModalWindow']", function(){ 2716 ModalWindow.close(); 2717 return false; 2718 }); 2719 Sys(document).on('click', "#sysModalWindow", function(event){ 2720 if (Sys(event.target).is('#sysModalWindow')) { 2721 ModalWindow.close(); 2722 return false; 2723 } 2724 }); 2725 Sys(window).on('hashchange', function(){ 2726 if (location.hash == '' ) { 2727 ModalWindow.close(); 2728 } 2729 }); 2730 }; 2731 2732 ModalWindow.isOpen = false; 2733 2734 ModalWindow.open = function(html){ 2735 var modalWindow = Sys("<div>").attr('id', 'sysModalWindow'); 2736 var close_btn = Sys('<a>'); 2737 close_btn.attr('href', '#closeModalWindow'); 2738 close_btn.addClass('sysRemoveElement'); 2739 var content = Sys("<div>").addClass('sysModalContent'); 2740 content.append(close_btn); 2741 var body = Sys("<div>").addClass('sysModalBody').html(html); 2742 content.append(body); 2743 modalWindow.append(content); 2744 Sys('body').append(modalWindow); 2745 //Sys.disableMouseScroll(); 2746 this.isOpen = true; 2747 }; 2748 2749 ModalWindow.close = function(){ 2750 Sys('#sysModalWindow').remove(); 2751 this.isOpen = false; 2752 Sys('body').trigger('modalClose'); 2753 }; 2754 2755 ModalWindow.content = function(html){ 2756 return Sys('#sysModalWindow .sysModalBody').html(html); 2757 }; 2758 2759 ModalWindow.bind(); 2760}); 2761 2762/* MDLï¼OPCã¯å¥ã®å°ç¨JSãã¡ã¤ã«ã«è¨è¼ï¼ 2763 ------------------------------------------*/ 2764Sys(function() { 2765 /* ããã¹ãããã¯ã¹ */ 2766 Sys('input[type="text"].mdl_required').blur(function () { 2767 checkMdlRequiredInput(Sys(this)); 2768 }); 2769 2770 /* ã»ã¬ã¯ãããã¯ã¹ã®å ´å㯠checkMdlRequiredSelect() ãé©å®å¼ã³åºãã¦ãã ããï¼changeã¤ãã³ããã¶ã¤ããããï¼ */ 2771}); 2772 2773/** 2774 * å¿ é ãã§ãã¯ï¼å ¥åç³»ï¼ 2775 * @param {jQuery} ele :ãã§ãã¯å¯¾è±¡ã®è¦ç´ ï¼<input>ã<select>ãªã©ï¼ 2776 */ 2777function checkMdlRequiredInput(ele) 2778{ 2779 if (ele.val() === '') { 2780 ele.parent().addClass('is-invalid'); 2781 ele.parent().find('.mdl-textfield__error').text('å ¥åãã¦ãã ããã'); 2782 } 2783} 2784 2785/** 2786 * å¿ é ãã§ãã¯ï¼é¸æç³»ï¼ 2787 * @param {jQuery} ele :ãã§ãã¯å¯¾è±¡ã®è¦ç´ ï¼<input>ã<select>ãªã©ï¼ 2788 * @param {jQuery} eleParent :.is-invalidãä»ãããè¦ç´ ï¼eleã¨mdlErrorEleãå ¥ã£ã¦ãã親è¦ç´ ï¼ 2789 * @param {jQuery} mdlErrorEle :ã¨ã©ã¼å 容ã表示ããè¦ç´ 2790 */ 2791function checkMdlRequiredSelect(ele, eleParent, mdlErrorEle) 2792{ 2793 if (ele.val() === '') { 2794 eleParent.addClass('is-invalid'); 2795 mdlErrorEle.text('鏿ãã¦ãã ããã'); 2796 } 2797} 2798 2799/** 2800 * <input type="hidden">ã®è¦ç´ ã使ãã¦è¿½å 2801 * @param {string} name :id屿§ãname屿§ã«å ¥ãããæåå 2802 * @param {string|number} val :å¤ 2803 * @param {element} addEle :<input>ãå ¥ãããè¦ç´ 2804 * 2805 */ 2806function setInputHiddenEle(name, val, addEle) 2807{ 2808 var selector = 'input[name="' + name + '"]'; 2809 var ele = document.querySelector(selector); 2810 if (ele === null) { 2811 // è¦ç´ ãã¾ã ãªããã°ä½ãï¼ãã¼ã¯ã³åå¾2åç®ä»¥éã¯æ¢ã«ä½æããã¦ããï¼ 2812 ele = document.createElement('input'); 2813 ele.type = 'hidden'; 2814 ele.name = name; 2815 } 2816 ele.value = val; 2817 2818 // 確èªç»é¢ã§ã¯è¿½å ç®æã1ãã¼ã¸ä¸ã§2ç®æããããjQueryã§å¯¾å¿ 2819 Sys(addEle).append(Sys(ele)); 2820}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.