PageSourceSearch

https://www.ishimura.co.jp/shop/html/template/default/assets/js/function.js?031229

js ishimura.co.jp collected 2026-09-24 18:12:37 UTC 6,840 bytes, 216 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() {
13
14    $('.pagetop').hide();
15
16    $(window).on('scroll', function() {
17        // ページトップフェードイン
18        if ($(this).scrollTop() > 300) {
19            $('.pagetop').fadeIn();
20        } else {
21            $('.pagetop').fadeOut();
22        }
23
24        // PC表示の時のみに適用
25        if (window.innerWidth > 767) {
26
27            if ($('#shopping-form').length) {
28
29                var side = $(".ec-orderRole__summary"),
30                    wrap = $("#shopping-form"),
31                    min_move = wrap.offset().top,
32                    max_move = wrap.height(),
33                    margin_bottom = max_move - min_move;
34
35                var scrollTop = $(window).scrollTop();
36                if (scrollTop > min_move && scrollTop < max_move) {
37                    var margin_top = scrollTop - min_move;
38                    side.css({"margin-top": margin_top});
39                } else if (scrollTop < min_move) {
40                    side.css({"margin-top": 0});
41                } else if (scrollTop > max_move) {
42                    side.css({"margin-top": margin_bottom});
43                }
44
45            }
46        }
47        return false;
48    });
49
50
51    $('.ec-headerNavSP').on('click', function() {
52        $('.ec-layoutRole').toggleClass('is_active');
53        $('.ec-drawerRole').toggleClass('is_active');
54        $('.ec-drawerRoleClose').toggleClass('is_active');
55        $('body').toggleClass('have_curtain');
56    });
57
58    $('.ec-overlayRole').on('click', function() {
59        $('body').removeClass('have_curtain');
60        $('.ec-layoutRole').removeClass('is_active');
61        $('.ec-drawerRole').removeClass('is_active');
62        $('.ec-drawerRoleClose').removeClass('is_active');
63    });
64
65    $('.ec-drawerRoleClose').on('click', function() {
66        $('body').removeClass('have_curtain');
67        $('.ec-layoutRole').removeClass('is_active');
68        $('.ec-drawerRole').removeClass('is_active');
69        $('.ec-drawerRoleClose').removeClass('is_active');
70    });
71
72    // TODO: カート展開時のアイコン変更処理
73    $('.ec-headerRole__cart').on('click', '.ec-cartNavi', function() {
74        // $('.ec-cartNavi').toggleClass('is-active');
75        $('.ec-cartNaviIsset').toggleClass('is-active');
76        $('.ec-cartNaviNull').toggleClass('is-active')
77    });
78
79    $('.ec-headerRole__cart').on('click', '.ec-cartNavi--cancel', function() {
80        // $('.ec-cartNavi').toggleClass('is-active');
81        $('.ec-cartNaviIsset').toggleClass('is-active');
82        $('.ec-cartNaviNull').toggleClass('is-active')
83    });
84
85    $('.ec-orderMail__link').on('click', function() {
86        $(this).siblings('.ec-orderMail__body').slideToggle();
87    });
88
89    $('.ec-orderMail__close').on('click', function() {
90        $(this).parent().slideToggle();
91    });
92
93    $('.is_inDrawer').each(function() {
94        var html = $(this).html();
95        $(html).appendTo('.ec-drawerRole');
96    });
97
98    $('.ec-blockTopBtn').on('click', function() {
99        $('html,body').animate({'scrollTop': 0}, 500);
100    });
101
102    // スマホのドロワーメニュー内の下層カテゴリ表示
103    // TODO FIXME スマホのカテゴリ表示方法
104    $('.ec-itemNav ul a').click(function() {
105        var child = $(this).siblings();
106        if (child.length > 0) {
107            if (child.is(':visible')) {
108                return true;
109            } else {
110                child.slideToggle();
111                return false;
112            }
113        }
114    });
115
116    // イベント実行時のオーバーレイ処理
117    // classに「load-overlay」が記述されていると画面がオーバーレイされる
118    $('.load-overlay').on({
119        click: function() {
120            loadingOverlay();
121        },
122        change: function() {
123            loadingOverlay();
124        }
125    });
126
127    // submit処理についてはオーバーレイ処理を行う
128    $(document).on('click', 'input[type="submit"], button[type="submit"]', function() {
129
130        // html5 validate対応
131        var valid = true;
132        var form = getAncestorOfTagType(this, 'FORM');
133
134        if (typeof form !== 'undefined' && !form.hasAttribute('novalidate')) {
135            // form validation
136            if (typeof form.checkValidity === 'function') {
137                valid = form.checkValidity();
138            }
139        }
140
141        if (valid) {
142            loadingOverlay();
143        }
144    });
145});
146
147$(window).on('pageshow', function() {
148    loadingOverlay('hide');
149});
150
151/**
152 * オーバーレイ処理を行う関数
153 */
154function loadingOverlay(action) {
155
156    if (action == 'hide') {
157        $('.bg-load-overlay').remove();
158    } else {
159        $overlay = $('<div class="bg-load-overlay">');
160        $('body').append($overlay);
161    }
162}
163
164/**
165 *  要素FORMチェック
166 */
167function getAncestorOfTagType(elem, type) {
168
169    while (elem.parentNode && elem.tagName !== type) {
170        elem = elem.parentNode;
171    }
172
173    return (type === elem.tagName) ? elem : undefined;
174}
175
176// anchorをクリックした時にformを裏で作って指定のメソッドでリクエストを飛ばす
177// Twigには以下のように埋め込む
178// <a href="PATH" {{ csrf_token_for_anchor() }} data-method="(put/delete/postのうちいずれか)" data-confirm="xxxx" data-message="xxxx">
179//
180// オプション要素
181// data-confirm : falseを定義すると確認ダイアログを出さない。デフォルトはダイアログを出す
182// data-message : 確認ダイアログを出す際のメッセージをデフォルトから変更する
183//
184$(function() {
185    var createForm = function(action, data) {
186        var $form = $('<form action="' + action + '" method="post"></form>');
187        for (input in data) {
188            if (data.hasOwnProperty(input)) {
189                $form.append('<input name="' + input + '" value="' + data[input] + '">');
190            }
191        }
192        return $form;
193    };
194
195    $('a[token-for-anchor]').click(function(e) {
196        e.preventDefault();
197        var $this = $(this);
198        var data = $this.data();
199        if (data.confirm != false) {
200            if (!confirm(data.message ? data.message : eccube_lang['common.delete_confirm'] )) {
201                return false;
202            }
203        }
204
205        // 削除時はオーバーレイ処理を入れる
206        loadingOverlay();
207
208        var $form = createForm($this.attr('href'), {
209            _token: $this.attr('token-for-anchor'),
210            _method: data.method
211        }).hide();
212
213        $('body').append($form); // Firefox requires form to be on the page to allow submission
214        $form.submit();
215    });
216});

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.