1/* 2 * This file is part of EC-CUBE 3 * 4 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. 5 * 6 * http://www.ec-cube.co.jp/ 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10*/ 11 12(function(window, undefined) { 13 14 // åå空éã®éè¤ãé²ã 15 if (window.eccube === undefined) { 16 window.eccube = {}; 17 } 18 19 let eccube = window.eccube; 20 21 // ã°ãã¼ãã«ã«ä½¿ç¨ã§ããããã«ãã 22 window.eccube = eccube; 23 24 /** 25 * è¦æ ¼2ã®ãã«ãã¦ã³ãè¨å®ãã. 26 */ 27 eccube.setClassCategories = function($form, product_id, $sele1, $sele2, selected_id2) { 28 if ($sele1 && $sele1.length) { 29 let classcat_id1 = $sele1.val() ? $sele1.val() : ''; 30 if ($sele2 && $sele2.length) { 31 let classcat2; 32 33 if (eccube.hasOwnProperty('productsClassCategories')) { 34 // ååä¸è¦§æ 35 classcat2 = eccube.productsClassCategories[product_id][classcat_id1]; 36 } else { 37 // 詳細表示æ 38 classcat2 = eccube.classCategories[classcat_id1]; 39 } 40 // è¦æ ¼2ã®è¦ç´ ãè¨å® 41 for (let key in classcat2) { 42 if (classcat2.hasOwnProperty(key)) { 43 let id = classcat2[key].classcategory_id2; 44 let name = classcat2[key].name; 45 let classCategoryCode = classcat2[key].code; 46 let div = $('<div/>').addClass('form__radio').css('margin-left', '20px'); 47 let input = $('<input>').attr('type', 'radio').attr('name', 'classcategory_id2').attr('id', 'product_'+product_id+'_cat1_' + classcat_id1 + 'cat2_' + id).val(id ? id : ''); 48 let label = $('<label/>').attr('for', id).attr('for', 'product_'+product_id+'_cat1_' + classcat_id1 + 'cat2_' + id).html(classCategoryCode + ' ' + name); 49 if (eccube.stockShow === "1" && eccube.stocks !== undefined) { 50 let span = $('<span/>').html(eccube.stocks[product_id][$sele1.val()]['#' + id].stock); 51 label.append(span); 52 } 53 if (eccube.stockShow === "1" && eccube.stocks !== undefined) { 54 if (eccube.stocks[product_id][$sele1.val()]['#' + id].stockButton === 'disabled') { 55 $(input).attr('disabled', 'disabled'); 56 } 57 } 58 div.append(input).append(label); 59 $sele2.append(div); 60 } 61 } 62 eccube.checkStock($form, product_id, $sele1.val() ? $sele1.val() : '__unselected2', 63 $sele2.val() ? $sele2.val() : ''); 64 } 65 } 66 }; 67 68 /** 69 * è¦æ ¼ã®é¸æç¶æ ã«å¿ãã¦, ãã£ã¼ã«ããè¨å®ãã. 70 */ 71 let price02_origin = []; 72 eccube.checkStock = function($form, product_id, classcat_id1, classcat_id2) { 73 74 classcat_id2 = classcat_id2 ? classcat_id2 : ''; 75 76 let classcat2; 77 78 if (eccube.hasOwnProperty('productsClassCategories')) { 79 // ååä¸è¦§æ 80 classcat2 = eccube.productsClassCategories[product_id][classcat_id1]['#' + classcat_id2]; 81 } else { 82 // 詳細表示æ 83 if (typeof eccube.classCategories[classcat_id1] !== 'undefined') { 84 classcat2 = eccube.classCategories[classcat_id1]['#' + classcat_id2]; 85 } 86 } 87 88 if (typeof classcat2 === 'undefined') { 89 // ååã³ã¼ã 90 let $product_code = $('.product-code-default'); 91 if (typeof this.product_code_origin === 'undefined') { 92 // åæå¤ãä¿æãã¦ãã 93 this.product_code_origin = $product_code.text(); 94 } 95 $product_code.text(this.product_code_origin); 96 97 // éå¸¸ä¾¡æ ¼ 98 let $price01 = $form.parent().find('.price01-default').first(); 99 if (typeof this.price01_origin === 'undefined') { 100 // åæå¤ãä¿æãã¦ãã 101 this.price01_origin = $price01.text(); 102 } 103 $price01.text(this.price01_origin); 104 105 // è²©å£²ä¾¡æ ¼ 106 let $price02 = $form.parent().find('.price02-default').first(); 107 if (typeof price02_origin[product_id] === 'undefined') { 108 // åæå¤ãä¿æãã¦ãã 109 price02_origin[product_id] = $price02.text(); 110 } 111 $price02.text(price02_origin[product_id]); 112 113 // ååè¦æ ¼ 114 let $product_class_id_dynamic = $form.find('[id^=ProductClass]'); 115 $product_class_id_dynamic.val(''); 116 117 } else { 118 // ååã³ã¼ã 119 let $product_code = $('.product-code-default'); 120 if (classcat2 && typeof classcat2.product_code !== 'undefined') { 121 $product_code.text(classcat2.product_code); 122 } else { 123 $product_code.text(this.product_code_origin); 124 } 125 126 // éå¸¸ä¾¡æ ¼ 127 let $price01 = $form.parent().find('.price01-default').first(); 128 if (typeof this.price01_origin === 'undefined') { 129 // åæå¤ãä¿æãã¦ãã 130 this.price01_origin = $price01.text(); 131 } 132 if (classcat2 && typeof classcat2.price01_inc_tax !== 'undefined' && String(classcat2.price01_inc_tax).length >= 1) { 133 $price01.text('ï¿¥' + classcat2.price01_inc_tax); 134 } else { 135 $price01.text(this.price01_origin); 136 } 137 138 // è²©å£²ä¾¡æ ¼ 139 let $price02 = $form.parent().find('.price02-default').first(); 140 if (typeof price02_origin[product_id] === 'undefined') { 141 // åæå¤ãä¿æãã¦ãã 142 price02_origin[product_id] = $price02.text(); 143 } 144 if (classcat2 && typeof classcat2.price02_inc_tax !== 'undefined' && String(classcat2.price02_inc_tax).length >= 1) { 145 $price02.text('ï¿¥' + classcat2.price02_inc_tax); 146 } else { 147 $price02.text(price02_origin[product_id]); 148 } 149 150 // ãã¤ã³ã 151 let $point_default = $form.find('[id^=point_default]'); 152 let $point_dynamic = $form.find('[id^=point_dynamic]'); 153 if (classcat2 && typeof classcat2.point !== 'undefined' && String(classcat2.point).length >= 1) { 154 155 $point_dynamic.text(classcat2.point).show(); 156 $point_default.hide(); 157 } else { 158 $point_dynamic.hide(); 159 $point_default.show(); 160 } 161 162 // ååè¦æ ¼ 163 let $product_class_id_dynamic = $form.find('[id^=ProductClass]'); 164 if (classcat2 && typeof classcat2.product_class_id !== 'undefined' && String(classcat2.product_class_id).length >= 1) { 165 $product_class_id_dynamic.val(classcat2.product_class_id); 166 } else { 167 $product_class_id_dynamic.val(''); 168 } 169 } 170 }; 171 172 173 /** 174 * Initialize. 175 */ 176 $(function() { 177 // è¦æ ¼1鏿æ 178 $('input[name=classcategory_id1]') 179 .change(function() { 180 let $form = $(this).parents('form'); 181 let product_id = $form.find('input[name=product_id]').val(); 182 let $sele1 = $(this); 183 let $sele2 = $form.find('div[id=classcategory_id1_' + $($sele1).val() + '_classcategory_id2]'); 184 // è¦æ ¼2ã®é¸æè¢ãã¯ãªã¢ 185 let classcategory_id2_box = $form.find('.classcategory_id2_box'); 186 for (let i = 0; i < classcategory_id2_box.length; i++) { 187 $(classcategory_id2_box[i]).empty(); 188 } 189 // è¦æ ¼1ã®ã¿ã®å ´å 190 if (!$sele2.length) { 191 eccube.checkStock($form, product_id, $sele1.val(), null); 192 // è¦æ ¼2ããã®å ´å 193 } else { 194 eccube.setClassCategories($form, product_id, $sele1, $sele2); 195 } 196 }); 197 198 // è¦æ ¼2鏿æ 199 $('.ec-blockRadio').on('change', 'input[name=classcategory_id2]',function () { 200 let $form = $(this).parents('form'); 201 let product_id = $form.find('input[name=product_id]').val(); 202 let $sele1 = $form.find('input[name=classcategory_id1]:checked'); 203 let $sele2 = $(this); 204 eccube.checkStock($form, product_id, $sele1.val(), $sele2.val()); 205 }) 206 }); 207})(window);
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.