PageSourceSearch

https://www.tuftclub.jp/store/html/template/default/assets/js/eccube.js

js tuftclub.jp collected 2026-10-04 20:18:06 UTC 9,029 bytes, 227 lines download raw bytes

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    var 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            var classcat_id1 = $sele1.val() ? $sele1.val() : '';
30            if ($sele2 && $sele2.length) {
31                // 規格2の選択肢をクリア
32                $sele2.children().remove();
33
34                var classcat2;
35
36                if (eccube.hasOwnProperty('productsClassCategories')) {
37                    // 商品一覧時
38                    classcat2 = eccube.productsClassCategories[product_id][classcat_id1];
39                } else {
40                    // 詳細表示時
41                    classcat2 = eccube.classCategories[classcat_id1];
42                }
43
44                // 規格2の要素を設定
45                for (var key in classcat2) {
46                    if (classcat2.hasOwnProperty(key)) {
47                        var id = classcat2[key].classcategory_id2;
48                        var name = classcat2[key].name;
49                        var option = $('<option />').val(id ? id : '').text(name);
50                        if (id === selected_id2) {
51                            option.attr('selected', true);
52                        }
53                        $sele2.append(option);
54                    }
55                }
56                eccube.checkStock($form, product_id, $sele1.val() ? $sele1.val() : '__unselected2',
57                    $sele2.val() ? $sele2.val() : '');
58            }
59        }
60    };
61
62    /**
63     * 規格の選択状態に応じて, フィールドを設定する.
64     */
65    var price02_origin = [];
66    eccube.checkStock = function($form, product_id, classcat_id1, classcat_id2) {
67
68        classcat_id2 = classcat_id2 ? classcat_id2 : '';
69
70        var classcat2;
71
72        if (eccube.hasOwnProperty('productsClassCategories')) {
73            // 商品一覧時
74            classcat2 = eccube.productsClassCategories[product_id][classcat_id1]['#' + classcat_id2];
75        } else {
76            // 詳細表示時
77            if (typeof eccube.classCategories[classcat_id1] !== 'undefined') {
78                classcat2 = eccube.classCategories[classcat_id1]['#' + classcat_id2];
79            }
80        }
81
82        if (typeof classcat2 === 'undefined') {
83            // 商品コード
84            var $product_code = $('.product-code-default');
85            if (typeof this.product_code_origin === 'undefined') {
86                // 初期値を保持しておく
87                this.product_code_origin = $product_code.text();
88            }
89            $product_code.text(this.product_code_origin);
90
91            // 在庫(品切れ)
92            var $cartbtn = $form.parent().find('.add-cart').first();
93            if (typeof this.product_cart_origin === 'undefined') {
94                // 初期値を保持しておく
95                this.product_cart_origin = $cartbtn.html();
96            }
97            $cartbtn.prop('disabled', false);
98            $cartbtn.html(this.product_cart_origin);
99            $cartbtn.removeClass('btn -bnw -soldout add-cart');
100            $cartbtn.addClass('btn -red -icon -cart add-cart');
101
102            // 通常価格
103            var $price01 = $form.parent().find('.price01-default').first();
104            if (typeof this.price01_origin === 'undefined') {
105                // 初期値を保持しておく
106                this.price01_origin = $price01.html();
107            }
108            $price01.html(this.price01_origin);
109
110            // 販売価格
111            var $price02 = $form.parent().find('.price02-default').first();
112            if (typeof price02_origin[product_id] === 'undefined') {
113                // 初期値を保持しておく
114                price02_origin[product_id] = $price02.html();
115            }
116            $price02.html(price02_origin[product_id]);
117
118            // 商品規格
119            var $product_class_id_dynamic = $form.find('[id^=ProductClass]');
120            $product_class_id_dynamic.val('');
121
122        } else {
123            // 商品コード
124            var $product_code = $('.product-code-default');
125            if (classcat2 && typeof classcat2.product_code !== 'undefined') {
126                $product_code.text(classcat2.product_code);
127            } else {
128                $product_code.text(this.product_code_origin);
129            }
130
131            // 在庫(品切れ)
132            var $cartbtn = $form.parent().find('.add-cart').first();
133            if (typeof this.product_cart_origin === 'undefined') {
134                // 初期値を保持しておく
135                this.product_cart_origin = $cartbtn.html();
136            }
137            if (classcat2 && classcat2.stock_find === false) {
138                $cartbtn.prop('disabled', true);
139                $cartbtn.removeClass('btn -red -icon -cart add-cart');
140                $cartbtn.addClass('btn -bnw -soldout add-cart');
141                $cartbtn.text(eccube_lang['front.product.out_of_stock']);
142            } else {
143                $cartbtn.prop('disabled', false);
144                $cartbtn.removeClass('btn -bnw -soldout add-cart');
145                $cartbtn.addClass('btn -red -icon -cart add-cart');
146                $cartbtn.html(this.product_cart_origin);
147            }
148
149            // 通常価格
150            var $price01 = $form.parent().find('.price01-default').first();
151            if (typeof this.price01_origin === 'undefined') {
152                // 初期値を保持しておく
153                this.price01_origin = $price01.html();
154            }
155            if (classcat2 && typeof classcat2.price01 !== 'undefined' && String(classcat2.price01).length >= 1) {
156                $price01.text(classcat2.price01_with_currency);
157            } else {
158                $price01.html(this.price01_origin);
159            }
160
161            // 販売価格
162            var $price02 = $form.parent().find('.price02-default').first();
163            if (typeof price02_origin[product_id] === 'undefined') {
164                // 初期値を保持しておく
165                price02_origin[product_id] = $price02.html();
166            }
167            if (classcat2 && typeof classcat2.price02 !== 'undefined' && String(classcat2.price02).length >= 1) {
168                $price02.text(classcat2.price02_with_currency);
169            } else {
170                $price02.html(price02_origin[product_id]);
171            }
172
173            // ポイント
174            var $point_default = $form.find('[id^=point_default]');
175            var $point_dynamic = $form.find('[id^=point_dynamic]');
176            if (classcat2 && typeof classcat2.point !== 'undefined' && String(classcat2.point).length >= 1) {
177
178                $point_dynamic.text(classcat2.point).show();
179                $point_default.hide();
180            } else {
181                $point_dynamic.hide();
182                $point_default.show();
183            }
184
185            // 商品規格
186            var $product_class_id_dynamic = $form.find('[id^=ProductClass]');
187            if (classcat2 && typeof classcat2.product_class_id !== 'undefined' && String(classcat2.product_class_id).length >= 1) {
188                $product_class_id_dynamic.val(classcat2.product_class_id);
189            } else {
190                $product_class_id_dynamic.val('');
191            }
192        }
193    };
194
195
196    /**
197     * Initialize.
198     */
199    $(function() {
200        // 規格1選択時
201        $('select[name=classcategory_id1]')
202            .change(function() {
203                var $form = $(this).parents('form');
204                var product_id = $form.find('input[name=product_id]').val();
205                var $sele1 = $(this);
206                var $sele2 = $form.find('select[name=classcategory_id2]');
207
208                // 規格1のみの場合
209                if (!$sele2.length) {
210                    eccube.checkStock($form, product_id, $sele1.val(), null);
211                    // 規格2ありの場合
212                } else {
213                    eccube.setClassCategories($form, product_id, $sele1, $sele2);
214                }
215            });
216
217        // 規格2選択時
218        $('select[name=classcategory_id2]')
219            .change(function() {
220                var $form = $(this).parents('form');
221                var product_id = $form.find('input[name=product_id]').val();
222                var $sele1 = $form.find('select[name=classcategory_id1]');
223                var $sele2 = $(this);
224                eccube.checkStock($form, product_id, $sele1.val(), $sele2.val());
225            });
226    });
227})(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.