PageSourceSearch

https://solution-next.tohoku-epco.co.jp/files/user/js/common.js?v=1790645003

js tohoku-epco.co.jp collected 2026-10-02 03:24:06 UTC 9,984 bytes, 328 lines download raw bytes

1/* ==========================================================
2[ 目次 ]
3
4<body>クラス設定
5スムース スクロール
6nav height
7hover menu
8sp menu
9Current Tab by Hash
10ticker
11objectFitImages
12accordion
13Select customize
14
15========================================================== */
16
17/* ---------------------------------------------
18*   <body>クラス設定
19--------------------------------------------- */
20/**
21 * <body>要素に、ユーザーのOS・デバイスとブラウザ等に関数情報をクラスとして付与する
22 * OS・デバイス: ios, iphone, ipad, android, androidphone, androidtablet, windows, mac
23 * ブラウザ: ie, edge, chrome, firefox, safari
24 */
25$(function () {
26    'use strict';
27
28    $('body').addClass(function () {
29        var bodyClasses = '';
30
31        // プラットフォーム判定
32        if (is.ios()) {
33            bodyClasses += ' ios';
34
35            if (is.iphone()) {
36                bodyClasses += ' iphone';
37            } else if (is.ipad()) {
38                bodyClasses += ' ipad';
39            }
40        } else if (
41            window.navigator.userAgent.toLowerCase().indexOf('macintosh') >
42                -1 &&
43            'ontouchend' in document
44        ) {
45            bodyClasses += ' ipad';
46        } else if (is.android()) {
47            bodyClasses += ' android';
48
49            if (is.androidPhone()) {
50                bodyClasses += ' androidphone';
51            } else if (is.androidTablet()) {
52                bodyClasses += ' androidtablet';
53            }
54        } else if (is.windows()) {
55            bodyClasses += ' windows';
56        } else if (is.mac()) {
57            bodyClasses += ' mac';
58        }
59
60        // ブラウザ判定
61        if (is.ie()) {
62            bodyClasses += ' ie';
63
64            if (is.ie(10)) {
65                bodyClasses += ' ie10';
66            } else if (is.ie(11)) {
67                bodyClasses += ' ie11';
68            }
69        } else if (
70            is.edge() ||
71            window.navigator.userAgent.toLowerCase().indexOf('edg') > -1
72        ) {
73            bodyClasses += ' edge';
74        } else if (is.chrome()) {
75            bodyClasses += ' chrome';
76        } else if (is.firefox()) {
77            bodyClasses += ' firefox';
78        } else if (is.safari()) {
79            bodyClasses += ' safari';
80        }
81
82        return bodyClasses;
83    });
84});
85
86/* ---------------------------------------------
87*   スムース スクロール
88--------------------------------------------- */
89$(function () {
90    'use strict';
91
92    $('a[href^="#"]').on('click.smoothScroll', function () {
93        var href = $(this).attr('href');
94        var $target;
95
96        if (is.ie(9) || is.ie(10)) {
97            $target = $(href === '#' ? 'body' : href);
98        } else {
99            $target = $(href === '#' ? 'html' : href);
100        }
101
102        var offset = 0;
103
104        // スクロール位置をずらす場合は、
105        // ここで条件分岐等を行う
106
107        $target.velocity('scroll', {
108            duration: 400,
109            easing: 'swing',
110            offset: offset
111        });
112
113        return false;
114    });
115});
116
117/* ---------------------------------------------
118*   nav height
119--------------------------------------------- */
120$(window).on('load resize scroll', function () {
121    var windowHeight = $(window).height(),
122        headerHeight = $('.header-container').height(),
123        btnHeight = $('.global-nav__register').height(),
124        navHeight = windowHeight - headerHeight,
125        navInnerHeight = navHeight - btnHeight,
126        windowWidth = $(window).width();
127
128    if (windowWidth <= 668) {
129        $('.global-nav').css('height', navHeight);
130        $('.global-nav__inner').css('height', 'auto');
131    } else {
132        if (windowHeight <= 714) {
133            $('.header').addClass('low-vh');
134        } else {
135            $('.header').removeClass('low-vh');
136            $('.global-nav').css('height', navHeight);
137            $('.global-nav__inner').css('height', navInnerHeight);
138        }
139    }
140});
141
142/* ---------------------------------------------
143*   hover menu
144--------------------------------------------- */
145$(function () {
146    var $trigger = $('.js-trigger');
147
148    $trigger.hover(
149        function () {
150            var $target = $(this).find('.js-target');
151            $target.stop().fadeIn();
152            $('body').addClass('is-opened');
153        },
154        function () {
155            var $target = $(this).find('.js-target');
156            $target.stop().fadeOut();
157            $('body').removeClass('is-opened');
158        }
159    );
160});
161
162/* ---------------------------------------------
163*   sp menu
164--------------------------------------------- */
165$(function () {
166    var $body = $('body');
167    var $trigger = $('.js-spmenu-trigger');
168    var $content = $('.js-sp-menu-target');
169    var openClass = 'js-sp-menu-opened';
170
171    $trigger.on('click.spmenu', function () {
172        var isOpened = $body.hasClass(openClass);
173        var contantAnimName = isOpened ? 'slideUp' : 'slideDown';
174        var params = {
175            duration: 500,
176            easing: 'easeInOutQuart'
177        };
178
179        if (!$content.hasClass('velocity-animating')) {
180            $body.toggleClass(openClass);
181            $content.velocity('stop').velocity(contantAnimName, params);
182        }
183    });
184});
185
186/* ---------------------------------------------
187*   Current Tab by Hash
188--------------------------------------------- */
189$(function () {
190    var trigger = '.js-tab-trigger',
191        triggerScope = '.js-tab-trigger-scope',
192        target = '.js-tab-target',
193        targetScope = '.js-tab-target-scope',
194        currentClass = 'is-current';
195
196    $(trigger).on('click', function () {
197        var tagId = $(this).data('id'),
198            $thisTriggerScope = $(this).closest(triggerScope),
199            $thisTargetScope = $('#' + tagId).closest(targetScope);
200
201        $thisTriggerScope.find(trigger).removeClass(currentClass);
202        $thisTargetScope.find(target).removeClass(currentClass);
203        $(this).addClass(currentClass);
204        $('#' + tagId).addClass(currentClass);
205
206        if ($(trigger).hasClass('global-nav__menu-sub-link')) {
207            if (tagId == 'select1') {
208                $(trigger).removeClass(currentClass);
209                $('[data-id="select1"]').addClass(currentClass);
210            } else if (tagId == 'select2') {
211                $(trigger).removeClass(currentClass);
212                $('[data-id="select2"]').addClass(currentClass);
213            }
214        }
215    });
216
217    var tabId = location.hash;
218    if (tabId) {
219        $(tabId).click();
220    }
221});
222
223/* ---------------------------------------------
224*   ticker
225--------------------------------------------- */
226/*$(function () {
227    $('.js-telop').webTicker({
228        speed: 40,
229        duplicate: true
230    });
231});*/
232
233/* ---------------------------------------------
234*   objectFitImages
235--------------------------------------------- */
236$(function () {
237    objectFitImages();
238});
239
240/* ---------------------------------------------
241*   accordion
242--------------------------------------------- */
243$(function () {
244    'use strict';
245    var scope = '.js-acc-scope',
246        trigger = '.js-acc-trigger',
247        target = '.js-acc-target';
248
249    $(trigger).on('click', function () {
250        var $thisScope = $(this).closest(scope);
251        var $thisTarget = $thisScope.find(target);
252        $(this).toggleClass('is-opened');
253        $thisTarget.slideToggle();
254    });
255});
256
257/* ---------------------------------------------
258*   Select customize
259--------------------------------------------- */
260$(function () {
261    'use strict';
262    var scope = '.js-select-custom',
263        trigger = '.js-select-custom__selected',
264        target = '.js-select-custom__options',
265        option = 'input[type="radio"]',
266        optionChecked = 'input[type="radio"]:checked',
267        showClass = 'show-options',
268        currentClass = 'current-options',
269        $this;
270
271    // 初期値のcheckedに対応
272    $(scope).each(function () {
273        $this = $(this);
274        var val = $this.find(optionChecked).val();
275
276        if (val) {
277            $this.find(trigger).text(val);
278            $this.find(optionChecked).parent('label').addClass(currentClass);
279        } else {
280            var unselectedText = $this.find(trigger).data('unselected');
281
282            $this.find(trigger).text(unselectedText);
283        }
284    });
285
286    // プルダウンに関する処理
287    $(trigger).on('click', function () {
288        var $this = $(this),
289            $thisTarget = $this.closest(scope).find(target);
290
291        $thisTarget.toggleClass(showClass);
292    });
293
294    // 選択した値に関する処理
295    $(scope)
296        .find(option)
297        .on('change', function () {
298            var $this = $(this),
299                val = $this.val(),
300                $thisTrigger = $this.closest(scope).find(trigger);
301
302            if (val) {
303                $thisTrigger.text(val);
304                $this.closest(scope).find('label').removeClass(currentClass);
305                $this.parent('label').addClass(currentClass);
306
307                if ($this.data('onchange')) {
308                    if (window === window.parent) {
309                        // iframeの中での実行ではない場合はそのまま遷移させる
310                        window.location.href = $this.data('onchange');
311                    } else {
312                        // iframeの中での実行である場合は親ページを遷移させる
313                        parent.location.href = $this.data('onchange');
314                    }
315                }
316            } else {
317                $thisTrigger.text($thisTrigger.data('unselected'));
318                $this.closest(scope).find('label').removeClass(currentClass);
319            }
320            $this.closest(scope).find(target).removeClass(showClass);
321        });
322
323    $(document).on('click touchend', function (event) {
324        if (!$(event.target).closest(trigger).length) {
325            $(target).removeClass(showClass);
326        }
327    });
328});

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.