PageSourceSearch

https://www.hibino.com/view/asset/user-2-1-3-1fe6650b0b9c56037470ed3af42a333e.js

js hibino.com collected 2026-10-04 14:56:45 UTC 12,982 bytes, 349 lines download raw bytes

1// カテゴリー判別用変数
2let is_cate_brand = false;
3const category_ly1 = $('#category-ly1');
4if (category_ly1.length > 0) {
5    is_cate_brand = category_ly1.val() == '/view/category/brand';
6}
7
8// 全ページ共通の処理群
9const init_common = () => {
10    // 要素のコピー
11    (() => {
12        // (1)アイコンメニュー:追従メニュー → SPグローバルメニュー
13        const $copy_1 = $('.hd-sticky-menu .hd-icon-menu').clone();
14        const $target_1 = $('.sp-glb-menu .__inner');
15        $copy_1.addClass('sp-only');
16        $copy_1.prependTo($target_1);
17
18        // (2)会員情報:PCヘッダー → SPグローバルメニュー
19        const $copy_2 = $('.hd-member-info.pc-only').clone();
20        const $target_2 = $('.sp-glb-menu .__inner');
21        $copy_2.toggleClass('pc-only sp-only');
22        $copy_2.prependTo($target_2);
23
24        // (3)独自ブランドメニュー:PCヘッダー → SPカテゴリーメニュー
25        const $copy_3 = $('.pc-hd-cate .__ly1-item.--orig-brand').clone();
26        const $target_3A = $('.sp-glb-menu .cate-menu .__ly1-item.--bulk');
27        const $target_3B = $('.sp-glb-menu .cate-menu .__ly1');
28        if ($target_3A.length > 0) {
29            $copy_3.insertBefore($target_3A);
30        } else {
31            $copy_3.appendTo($target_3B);
32        }
33        $('.sp-glb-menu .__ly1-item.--orig-brand .__ly1-name').addClass('cate-acc-trig');
34
35        // (4)SPカテゴリーメニュー:SPグローバルメニュー → SP検索メニュー
36        const $copy_4 = $('.sp-glb-menu .cate-menu').clone();
37        const $target_4 = $('.sp-search-menu .__inner');
38        $copy_4.appendTo($target_4);
39
40        // (5)SPグローバルメニュー:SPヘッダー → PCサイドナビ
41        const $copy_5 = $('.sp-glb-menu .__inner').clone();
42        const $target_5 = $('.pc-multi-column');
43        if ($target_5.length > 0) {
44            $copy_5.find('.cate-menu').toggleClass('--sp --pc');
45            $copy_5.find('.sp-only').remove();
46            $copy_5.wrap('<nav class="pc-side-nav pc-only"></nav>');
47            $copy_5.parent().prependTo($target_5);
48        }
49    })();
50
51    // メニュー開閉
52    const $menu_sw = $('.menu-sw');
53    $menu_sw.on('click', function () {
54        const tgt_id = $(this).attr('data-menu-id');
55        $('[data-menu-id]').each(function () {
56            if ($(this).attr('data-menu-id') == tgt_id) {
57                $(this).toggleClass('--open');
58            } else {
59                $(this).removeClass('--open');
60            }
61        });
62
63        // 他方が開いている時の遅延設定
64        const delay_time = 300;
65        const $menu = $('[data-menu-id]:not(.menu-sw)');
66        if ($menu.filter('.--open').length > 0) {
67            $menu.filter(':not(.--open)').delay(delay_time).queue(function () {
68                $(this).addClass('--delay').dequeue();
69            });
70            $menu.filter('.--open').delay(delay_time).queue(function () {
71                $(this).removeClass('--delay').dequeue();
72            });
73        } else {
74            $menu.removeClass('--delay');
75        }
76    });
77
78    // カテゴリーメニューのアコーディオン開閉
79    const $pc_cate = $('.cate-menu.--pc');
80    const $sp_cate = $('.cate-menu.--sp');
81    // -- PC初期状態:
82    //      「ブランドから探す」配下のカテゴリーを開いていれば「ブランドから探す」を開く、
83    //    そうでなければ「カテゴリーから探す」を開く、それ以外は閉じている
84    if (is_cate_brand) {
85        $pc_cate.find('.__ly1-item.--code-brand .__ly1-name').addClass('--open');
86    } else {
87        $pc_cate.find('.__ly1-item.--code-category .__ly1-name').addClass('--open');
88    }
89    $pc_cate.find('.__ly1-name:not(.--open) + .__list-wrap').hide();
90    // -- SP初期状態:すべて閉じている
91    $sp_cate.find('.__ly1-item .__list-wrap').hide();
92    // -- クリック/タップ時の処理
93    $pc_cate.add($sp_cate).find('.cate-acc-trig').on('click', function () {
94        $(this).toggleClass('--open');
95        $(this).next('.__list-wrap').slideToggle(200);
96    });
97
98    // Enterキーで検索実行
99    $('.search-form').find('input').on('keypress', function (e) {
100        if (e.keyCode == 13) {
101            $(this).parents('.search-form').find('.__submit').get(0).click();
102        }
103    });
104
105    // 商品リスト用のSwiper設定
106    $('.item-list.--swiper').each(function (i) {
107        new Swiper($(this).find('.swiper').get(0), {
108            lazyPreloadPrevNext: 2,
109            slidesPerView: $(this).find('.__item').length > 2 ? 2.1 : 2,
110            spaceBetween: 11,
111            watchSlidesProgress: true,
112            freeMode: {
113                enabled: true,
114                momentumRatio: 0.5,
115                momentumVelocityRatio: 0.5,
116            },
117            navigation: {
118                enabled: false,
119                prevEl: $(this).find('.__btn.--prev').get(0),
120                nextEl: $(this).find('.__btn.--next').get(0),
121            },
122            scrollbar: {
123                enabled: true,
124                hide: false,
125                draggable: true,
126                el: $(this).find(' .__sb').get(0),
127            },
128            breakpoints: {
129                400: {
130                    slidesPerView: 4.1,
131                }
132            },
133            breakpoints: {
134                769: {
135                    slidesPerView: 5,
136                    spaceBetween: 20,
137                    freeMode: false,
138                    navigation: { enabled: true },
139                    scrollbar: { enabled: false },
140                }
141            },
142        });
143    });
144
145    // カレンダー日別内容配色
146    const $date_data = $(".calendar .__date-data");
147    $date_data.each(function () {
148        const month = $(this).attr("data-month");
149        const date = $(this).attr("data-date");
150        const color = $(this).attr("data-color");
151        $(".calendar .makeshop-calendar" + month + " .day" + date)
152            .css("--calendar-bg-color", color);
153    });
154    const $date_color = $(".calendar .__date-color:not(.--toady)");
155    $date_color.each(function () {
156        const color = $(this).attr("data-color");
157        $(this).css("background-color", color);
158    });
159
160    // 数量欄の処理
161    const $qty = $('.quantity .__qty');
162    if ($qty.length > 0) {
163        const min = $qty.eq(0).is('[data-min]') ? parseInt($qty.eq(0).attr('data-min')) : 1;
164        const max = $qty.eq(0).is('[data-max]') ? parseInt($qty.eq(0).attr('data-max')) : 999999;
165        // 数量欄変更時
166        $qty.on('change', function () {
167            const qty_val = parseInt($(this).val().replace(/[0-9]/g, (val) => {
168                return String.fromCharCode(val.charCodeAt(0) - 0xFEE0); // 元の値の全角数字を半角に置換
169            }));
170            const val = (() => {
171                if (isNaN(qty_val)) {
172                    return $(this).attr('value');
173                } else if (qty_val > max) {
174                    return max;
175                } else if (qty_val < min) {
176                    return min;
177                } else {
178                    return qty_val;
179                }
180            })();
181            $(this).val(val);
182        });
183
184        // 数量スピンボタン押下時
185        const $qty_btn = $('.quantity .__btn');
186        if ($qty_btn.length > 0) {
187            $qty_btn.on('click', function () {
188                const $tgt = $(this).parents('.quantity').find('.__qty');
189                let val = $tgt.val();
190                if ($(this).hasClass('--up') && val < max) {
191                    val++;
192                } else if ($(this).hasClass('--down') && val > min ) {
193                    val--;
194                }
195                $tgt.val(val);
196            });
197        }
198    }
199
200    // 上に戻る
201    const $btt = $('.back-to-top');
202    $(window).on('scroll', function () {
203        if ( $(this).scrollTop() < 200 ) {
204            $btt.removeClass('--show');
205        } else {
206            $btt.addClass('--show');
207        }
208    });
209
210    // ページ読み込み時 URLにアンカーがあればアンカー位置へ移動
211    if (window.location.hash) {
212        setTimeout(function(){
213            const hash = window.location.hash;
214            window.location.replace(hash);
215        }, 300);
216    }
217}
218
219$(function () {
220    init_common();
221});
222// オプション切替時の処理
223function MakeShop_afterItemOptionChange(data) {
224    // 在庫に応じてカートに入れるボタンの切り替え
225    if (data.isSoldout) {
226        // 品切れの場合
227        $('.item-cart-btn-wrap .--cv').addClass('--hide');
228        $('.item-cart-btn-wrap .--disable').removeClass('--hide');
229    } else {
230        // 在庫がある or オプショングループの場合
231        $('.item-cart-btn-wrap .--cv').removeClass('--hide');
232        $('.item-cart-btn-wrap .--disable').addClass('--hide');
233    }
234}
235
236// お気に入り追加・削除時の処理
237function MakeShop_afterFavoriteEntry(data) {
238    if (data.result) {
239        const $fav_wrap = $(`[href="${data.source}"]`).parent();
240        $fav_wrap.children('.--add').addClass('--hide');
241        $fav_wrap.children('.--remove').removeClass('--hide');
242    }
243}
244function MakeShop_afterFavoriteRemove(data) {
245    if (data.result) {
246        const $fav_wrap = $(`[href="${data.source}"]`).parent();
247        $fav_wrap.children('.--remove').addClass('--hide');
248        $fav_wrap.children('.--add').removeClass('--hide');
249    }
250}
251
252// カートに入れた時の処理
253function MakeShop_afterCartEntry(data) {
254    if (data.result) {
255        // ヘッダーの商品数バッジの更新
256        const $hd_cart_num = $('.hd-icon-menu .__cart-num');
257        $hd_cart_num.html(data.totalQuantity);
258        if (data.totalQuantity > 0) {
259            $hd_cart_num.addClass('--show');
260        } else {
261            $hd_cart_num.removeClass('--show');
262        }
263
264        // モーダルを表示
265        const $item_add_cart_modal = $('.item-add-cart-modal');
266        $item_add_cart_modal.addClass('--show');
267
268        // カート画面へ遷移させない
269        return false;
270    } else {
271        data.method.modal(data.error.message);
272    }
273}
274
275const item_init = () => {
276    // 商品画像用のSwiper設定
277    const $photo_multi = $('.item-photo.--multi');
278    if ($photo_multi.length > 0) {
279        const $thumb = $('.item-photo.--thumb .__photo');
280        new Swiper($photo_multi.find('.swiper').get(0), {
281            slidesPerView: 1,
282            on: {
283                afterInit: (swiper) => {
284                    $thumb.each(function (i) {
285                        $(this).on('click', () => swiper.slideTo(i));
286                    });
287                },
288            },
289        });
290    }
291
292    // SKU別ボタン オプション画像切り替え
293    $('.item-sku-hd .__photo-img').on('click', function () {
294        const src = $(this).attr('src');
295        $('.item-photo.--thumb').find(`img[src="${src}"]`)
296            .parent('.__photo').trigger('click');
297    });
298
299    // モーダルを閉じる
300    const $item_add_cart_modal_close = $('.item-add-cart-modal .close-modal');
301    $item_add_cart_modal_close.on('click', function() {
302        $(this).parents('.item-add-cart-modal').removeClass('--show');
303    });
304
305  // イーレコランキング用のSwiper設定
306  $('.item-ereco .item-list.--swiper').each(function (i) {
307      new Swiper($(this).find('.swiper').get(0), {
308          lazyPreloadPrevNext: 2,
309          slidesPerView: $(this).find('.__item').length > 2 ? 2.1 : 2,
310          spaceBetween: 11,
311          watchSlidesProgress: true,
312          freeMode: {
313              enabled: true,
314              momentumRatio: 0.5,
315              momentumVelocityRatio: 0.5,
316          },
317          navigation: {
318              enabled: false,
319              prevEl: $(this).find('.__btn.--prev').get(0),
320              nextEl: $(this).find('.__btn.--next').get(0),
321          },
322          scrollbar: {
323              enabled: true,
324              hide: false,
325              draggable: true,
326              el: $(this).find(' .__sb').get(0),
327          },
328          breakpoints: {
329              400: {
330                  slidesPerView: 4.1,
331              }
332          },
333          breakpoints: {
334              769: {
335                  slidesPerView: 5,
336                  spaceBetween: 20,
337                  freeMode: false,
338                  navigation: { enabled: true },
339                  scrollbar: { enabled: false },
340              }
341          },
342      });
343  });
344}
345
346setTimeout(function() {
347    item_init();
348}, 2000);
349

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.