PageSourceSearch

https://biotop.ne.jp/html/template/biotop/assets/js/eccube.js

js biotop.ne.jp collected 2026-10-04 04:22:14 UTC 8,820 bytes, 222 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
100            // 通常価格
101            var $price01 = $form.parent().find('.price01-default').first();
102            if (typeof this.price01_origin === 'undefined') {
103                // 初期値を保持しておく
104                this.price01_origin = $price01.html();
105            }
106            $price01.html(this.price01_origin);
107
108            // 販売価格
109            var $price02 = $form.parent().find('.price02-default').first();
110            if (typeof price02_origin[product_id] === 'undefined') {
111                // 初期値を保持しておく
112                price02_origin[product_id] = $price02.html();
113            }
114            $price02.html(price02_origin[product_id]);
115
116            // 商品規格
117            var $product_class_id_dynamic = $form.find('[id^=ProductClass]');
118            $product_class_id_dynamic.val('');
119
120        } else {
121            // 商品コード
122            var $product_code = $('.product-code-default');
123            if (classcat2 && typeof classcat2.product_code !== 'undefined') {
124                $product_code.text(classcat2.product_code);
125            } else {
126                $product_code.text(this.product_code_origin);
127            }
128
129            // 在庫(品切れ)
130            var $cartbtn = $form.parent().find('.add-cart').first();
131            if (typeof this.product_cart_origin === 'undefined') {
132                // 初期値を保持しておく
133                this.product_cart_origin = $cartbtn.html();
134            }
135            if (classcat2 && classcat2.stock_find === false) {
136                $cartbtn.prop('disabled', true);
137                $cartbtn.text(eccube_lang['front.product.out_of_stock']);
138            } else {
139                $cartbtn.prop('disabled', false);
140                $cartbtn.html(this.product_cart_origin);
141            }
142
143            // 通常価格
144            var $price01 = $form.parent().find('.price01-default').first();
145            if (typeof this.price01_origin === 'undefined') {
146                // 初期値を保持しておく
147                this.price01_origin = $price01.html();
148            }
149            if (classcat2 && typeof classcat2.price01_inc_tax !== 'undefined' && String(classcat2.price01_inc_tax).length >= 1) {
150                $price01.text(classcat2.price01_inc_tax_with_currency);
151            } else {
152                $price01.html(this.price01_origin);
153            }
154
155            // 販売価格
156            var $price02 = $form.parent().find('.price02-default').first();
157            if (typeof price02_origin[product_id] === 'undefined') {
158                // 初期値を保持しておく
159                price02_origin[product_id] = $price02.html();
160            }
161            if (classcat2 && typeof classcat2.price02_inc_tax !== 'undefined' && String(classcat2.price02_inc_tax).length >= 1) {
162                $price02.text(classcat2.price02_inc_tax_with_currency);
163            } else {
164                $price02.html(price02_origin[product_id]);
165            }
166
167            // ポイント
168            var $point_default = $form.find('[id^=point_default]');
169            var $point_dynamic = $form.find('[id^=point_dynamic]');
170            if (classcat2 && typeof classcat2.point !== 'undefined' && String(classcat2.point).length >= 1) {
171
172                $point_dynamic.text(classcat2.point).show();
173                $point_default.hide();
174            } else {
175                $point_dynamic.hide();
176                $point_default.show();
177            }
178
179            // 商品規格
180            var $product_class_id_dynamic = $form.find('[id^=ProductClass]');
181            if (classcat2 && typeof classcat2.product_class_id !== 'undefined' && String(classcat2.product_class_id).length >= 1) {
182                $product_class_id_dynamic.val(classcat2.product_class_id);
183            } else {
184                $product_class_id_dynamic.val('');
185            }
186        }
187    };
188
189
190    /**
191     * Initialize.
192     */
193    $(function() {
194        // 無限スクロール等で後から追加された要素にも効くようイベント委譲する
195        // 規格1選択時
196        $(document)
197            .on('change', 'select[name=classcategory_id1]', function() {
198                var $form = $(this).parents('form');
199                var product_id = $form.find('input[name=product_id]').val();
200                var $sele1 = $(this);
201                var $sele2 = $form.find('select[name=classcategory_id2]');
202
203                // 規格1のみの場合
204                if (!$sele2.length) {
205                    eccube.checkStock($form, product_id, $sele1.val(), null);
206                    // 規格2ありの場合
207                } else {
208                    eccube.setClassCategories($form, product_id, $sele1, $sele2);
209                }
210            });
211
212        // 規格2選択時
213        $(document)
214            .on('change', 'select[name=classcategory_id2]', function() {
215                var $form = $(this).parents('form');
216                var product_id = $form.find('input[name=product_id]').val();
217                var $sele1 = $form.find('select[name=classcategory_id1]');
218                var $sele2 = $(this);
219                eccube.checkStock($form, product_id, $sele1.val(), $sele2.val());
220            });
221    });
222})(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.