PageSourceSearch

https://www.hondacars-gunmanishi.co.jp/assets/js/common.js?094718

js hondacars-gunmanishi.co.jp collected 2026-10-09 00:47:30 UTC 17,545 bytes, 573 lines download raw bytes

1'use strict';
2
3/*
4Šeƒy[ƒWŒÂ•Êjs‚ÅŠg’£
5
6Eon load
7MutJs.loaded = function() {}
8
9Escroll
10MutJs.scrolled = function() {}
11
12Eresize
13MutJs.resized = function() {}
14
15E‰æ‘œ’x‰„ƒ[ƒhŽž
16MutJs.LazyImg.loaded = function() {}
17*/
18
19var MutJs = {
20    // for throttle
21    ticking: false,
22    loadingTimer: null,
23    isDesktopW: true,
24    winW: 0,
25    winH: 0,
26    scrTop: 0,
27    isLoaded: false,
28
29    init: function () {
30        this.sizeUpdate();
31        this.setDOM();
32        this.LazyImg.init();
33        this.setHeaderFunc();
34        this.setClickEvent();
35        this.setModal();
36        this.removeLoaderTimer();
37
38        if (!this.isLoaded) {
39            $(window).on('load', () => {
40                this.commonLoaded();
41            });
42        } else {
43            this.commonLoaded();
44        }
45
46        document.addEventListener('scroll', this.scrolling.bind(this), {
47            passive: true,
48        })
49        window.addEventListener('resize', this.resizing.bind(this), {
50            passive: true,
51        })
52    },
53    commonLoaded: function () {
54        this.isLoaded = true;
55        this.LazyImg.set();
56        this.setIntersection();
57        this.setSlider();
58        this.loaded();
59        this.removeLoader();
60        this.setHashAnchor();
61        this.commonResized();
62        this.commonScrolled();
63    },
64    commonScrolled: function() {
65        this.scrTop = $(window).scrollTop();
66
67        $(".js-x-scroll").css("left", "-"+ $(window).scrollLeft() +"px");
68
69        this.setPagetop();
70        this.scrolled();
71    },
72    commonResized: function() {
73        this.sizeUpdate();
74        this.resized();
75    },
76    setViewport: function() {
77        // !mutUA.Desktop‚¾‚¯‚¾‚ÆiOS13ˆÈã‚ÌiPad‚ªE‚¦‚È‚¢‚̂Ō•ʂɔ»’è
78        var ua = window.navigator.userAgent.toLowerCase();
79        var isPortable = !mutUA.Desktop || (ua.indexOf('macintosh') && 'ontouchend' in document);
80        if (isPortable && this.winW <= 375) {
81            $('meta[name="viewport"]').attr('content', 'width=375');
82        } else if (isPortable && this.winW >= 768 && this.winW <= 1080) {
83            $('meta[name="viewport"]').attr('content', 'width=1080');
84        } else {
85            $('meta[name="viewport"]').attr('content', 'width=device-width, initial-scale=1');
86        }
87    },
88    setDOM: function() {
89        if (mutUA.Mobile && !mutUA.Desktop) {
90            $('.js-tel').each(function() {
91                $(this).addClass('_active');
92                if (!$(this).attr('href')) {
93                    $(this).attr('href', 'tel:' + $(this).text().replace(/-/g, ''));
94                }
95            });
96        } else {
97            $('.js-tel').addClass('_inactive').removeAttr('href');
98        }
99    },
100    setSlider: function() {
101        $('.js-slider').each(function(){
102            var $thisSlider = $(this);
103            $thisSlider.parent().append('<div class="slick-arrow-holder"></div>');
104            $thisSlider.slick({
105                dots: true,
106                arrows: true,
107                autoplay: true,
108                slidesToShow: 1,
109                appendArrows: $thisSlider.parent().find('.slick-arrow-holder')
110            });
111        });
112    },
113    setPagetop: function() {
114        var pagetop = $('#js-pagetop');
115
116        if (this.scrTop > 60) {
117            pagetop.addClass('is-visible');
118        } else {
119            pagetop.removeClass('is-visible');
120        }
121
122        // if (this.scrTop + $(window).height() > pagetop.offset().top + pagetop.innerHeight()) {
123        //  pagetop.addClass('is-static');
124        // } else {
125        //  pagetop.removeClass('is-static');
126        // }
127    },
128    scrolling: function () {
129        var that = this
130        this.ticking = false;
131
132        if (!this.ticking) {
133            requestAnimationFrame(function () {
134                that.ticking = false;
135                that.commonScrolled();
136            })
137            this.ticking = true;
138        }
139    },
140    resizing: function () {
141        var that = this;
142        this.ticking = false;
143        if (!this.ticking) {
144            requestAnimationFrame(function () {
145                that.ticking = false;
146                that.commonResized();
147            })
148            this.ticking = true;
149        }
150    },
151    loaded: function () {
152        // console.log('common loaded');
153    },
154    scrolled: function() {
155        // console.log('common scrolled');
156    },
157    resized: function() {
158        // console.log('common resized');
159    },
160    sizeUpdate: function() {
161        this.winW = $(window).innerWidth();
162        this.winH = $(window).innerHeight();
163        this.isDesktopW = window.matchMedia('(min-width: 768px)').matches;
164        this.setViewport();
165
166        let vh = window.innerHeight * 0.01;
167        document.documentElement.style.setProperty('--vh', `${vh}px`);
168    },
169    setHeaderFunc: function() {
170        var that = this;
171
172        $('.js-header-toggle').on('click', function(e) {
173            e.preventDefault();
174            $('body').toggleClass('is-header-nav-open');
175        });
176
177        $('.js-header-nav-anchor').on('click', function(e) {
178            e.preventDefault();
179            $(this).toggleClass('is-open').next().slideToggle();
180        });
181    },
182    setModal: function() {
183        var that = this;
184        var $modal = $('#js-modal');
185
186        $('body').on('click', 'a[data-modal-nav]', function(e) {
187            e.preventDefault();
188
189            if (!that.isDesktopW && $(this).hasClass('js-header-nav-anchor')) {
190                return false;
191            }
192
193            var target = $(this).data('modal-nav');
194            $modal.addClass('is-show')
195            $modal.find('*[data-modal="'+ target +'"]').addClass('is-show');
196        });
197
198        $('.js-modal-close').on('click', function(e) {
199            e.preventDefault();
200            $modal.removeClass('is-show');
201            $modal.find('*[data-modal]').removeClass('is-show');
202        });
203    },
204    setIntersection: function() {
205        // oŒ»ƒAƒjƒ[ƒVƒ‡ƒ“—p
206        $('.c-section').attr('data-intersection', 'once');
207
208        // observe‚µ‚½‚Æ‚«‚Ìaction’è‹`
209        const action = (entry) => {
210            // entry.target ‚ÉŒŸo‚µ‚½DOM‚ª“ü‚Á‚Ä‚­‚é
211            // entry.isIntersecting ‚ɉæ–Ê“à‚©‚Ç‚¤‚©‚ª“ü‚Á‚Ä‚­‚é
212            const $target = $(entry.target);
213
214            if (!$target.attr('data-intersection')) {
215                $target.attr('data-intersection', 'once');
216            }
217
218            // once‚̐ݒ肾‚Á‚½‚çtrue‚ðÁ‚³‚È‚¢
219            if ($target.attr('data-intersection') != 'repeat' && $target.attr('data-intersecting') == 'true') {
220                return false;
221            }
222
223            $target.attr('data-intersecting', entry.isIntersecting);
224        }
225
226        // IntersectionObserver‚Ì—˜—p
227        const observer = new IntersectionObserver(entries => {
228            entries.forEach(entry => {
229                action(entry);
230            });
231        }, {
232            rootMargin: '0px 0px -30px 0px'
233        });
234
235        // observe‚·‚éDOM‚ðŽæ“¾
236        const $targets = $('*[data-intersection]');
237
238        $targets.each(function(j, el){
239            observer.observe(el);
240        });
241    },
242    removeLoaderTimer: function() {
243        this.loadingTimer = setTimeout(() => {
244            this.removeLoader();
245        }, 3000);
246    },
247    removeLoader: function() {
248        $('body').addClass('is-loaded');
249        clearTimeout(this.loadingTimer);
250    },
251    anchorScroll: function(hash) {
252        var speed = 500;
253        var hdrH  = $('#js-header').height();
254
255        if (hash == "#" || hash == "") {
256            var $target = $('html');
257        } else {
258            var $target = $('*[data-anchor-id="'+ hash.slice(1) +'"]');
259        }
260
261        if ($target.length) {
262            var position = $target.offset().top;
263
264            if ($target.hasClass('c-section') && !$target.hasClass('_bg')) {
265                position = $target.prev().offset().top + $target.prev().innerHeight();
266            }
267
268            var anchorPosition = position - hdrH;
269            $("html, body").animate({
270                scrollTop: anchorPosition
271            }, speed, "easeOutSine");
272        }
273    },
274    setHashAnchor: function() {
275        if (location.hash && location.hash.indexOf('#wp') == -1) {
276            this.anchorScroll(location.hash);
277        }
278    },
279    setClickEvent: function() {
280        var that = this;
281
282        // ƒAƒ“ƒJ[ƒXƒNƒ[ƒ‹
283        $(document).on('click','.js-scroll', function(e) {
284            e.preventDefault();
285            that.anchorScroll($(this).attr("href"));
286        });
287
288        // toggle
289        $(document).on('click','.js-next-toggle', function(e) {
290            $(this).toggleClass('is-open').next().slideToggle(300);
291        });
292
293        $(document).on('click', '.js-sitemap-toggle', function(e){
294            $(this).toggleClass('is-open').parent().next().slideToggle(300);
295        });
296
297        // ”Ä—ptoggle
298        $(document).on('click','*[data-toggle-for]', function(e) {
299            e.preventDefault();
300            var toggleId = $(this).data('toggle-for');
301            $(this).toggleClass('is-show');
302            $('*[data-toggle-id="'+ toggleId +'"]').toggleClass('is-show').slideToggle();
303        });
304    },
305    LazyImg: {
306        image: $('img[data-src]'),
307        imageLen: $('img[data-src]').length,
308        loadedLen: 0,
309        init: function() {
310            this.image.attr('src','');
311
312            var isLazyLoaded = setTimeout(() => {
313                this.desvg();
314                this.loaded();
315            }, 7500);
316
317            this.image.bind('load', () => {
318                this.loadedLen++;
319                if (this.loadedLen == this.imageLen) {
320                    this.desvg();
321                    this.loaded();
322                    clearTimeout(isLazyLoaded);
323                }
324            });
325
326        },
327        set: function() {
328            this.image.each(function(i){
329                $(this).attr('src', $(this).attr('data-src'));
330            });
331        },
332        desvg: function() {
333            desvg('[src$=".svg"]', true);
334        },
335        loaded: function() {
336            return false;
337        }
338    }
339};
340
341document.addEventListener('DOMContentLoaded', function(){
342    MutJs.init();
343    MutCalendar.init();
344});
345
346$(window).on('load', () => {
347    MutJs.isLoaded = true;
348});
349
350
351// svgƒtƒ@ƒCƒ‹‚̐F•Ï‚¦—p‚É“WŠJ‚·‚é
352function desvg(selector, removeInlineCss) {
353    removeInlineCss = removeInlineCss || false;
354
355    var images,
356        imagesLength,
357        sortImages = {},
358
359        // load svg file
360        loadSvg = function (imgURL, replaceImages) {
361            // set up the AJAX request
362            var xhr = new XMLHttpRequest();
363            xhr.open('GET', imgURL, true);
364
365            xhr.onload = function() {
366                var xml,
367                    svg,
368                    paths,
369                    replaceImagesLength;
370
371                // get the response in XML format
372                xml = xhr.responseXML;
373                replaceImagesLength = replaceImages.length;
374
375                // bail if no XML
376                if (!xml) {
377                    return;
378                }
379
380                // this will be the <svg />
381                svg = xml.documentElement;
382
383                // get all the SVG paths
384                paths = svg.querySelectorAll('path');
385
386                if (removeInlineCss) {
387                    // if `removeInlineCss` is true then remove the style attributes from the SVG paths
388                    for (var i = 0; i < paths.length; i++) {
389                        paths[i].removeAttribute('style');
390                    }
391                }
392                svg.removeAttribute('xmlns:a');
393
394                while(replaceImagesLength--) {
395                    replaceImgWithSvg(replaceImages[replaceImagesLength], svg.cloneNode(true));
396                }
397            };
398
399            xhr.send();
400        },
401
402        // replace the original <img /> with the new <svg />
403        replaceImgWithSvg = function (img, svg) {
404            var imgID = img.id,
405                imgClasses = img.getAttribute('class');
406
407            if (imgID) {
408                // re-assign the ID attribute from the <img />
409                svg.id = imgID;
410            }
411
412            if (imgClasses) {
413                // re-assign the class attribute from the <img />
414                svg.setAttribute('class', imgClasses + ' replaced-svg');
415            }
416
417            svg.setAttribute('data-src', img.getAttribute('src'));
418
419            img.parentNode.replaceChild(svg, img);
420        };
421
422
423
424    // grab all the elements from the document matching the passed in selector
425    images = document.querySelectorAll(selector);
426    imagesLength = images.length;
427
428    // sort images array by image url
429    while (imagesLength--) {
430        var _img = images[imagesLength],
431          _imgURL;
432
433        if (_img.getAttribute('data-src')) {
434          _imgURL = _img.getAttribute('data-src')
435        } else {
436          _imgURL = _img.getAttribute('src')
437        }
438
439        if (sortImages[_imgURL]) {
440            sortImages[_imgURL].push(_img);
441        } else {
442            sortImages[_imgURL] = [_img];
443        }
444    }
445
446    // loops over the matched urls
447    for (var key in sortImages) {
448        if (sortImages.hasOwnProperty(key)) {
449            loadSvg(key, sortImages[key]);
450        }
451    }
452}
453
454var infoSlider = {
455    initSlider: function initSlider() {
456    var now = new Date();
457    var now = !checkDate ? new Date() : new Date(checkDate);
458    var start = new Date('2026/07/23 00:00:00'); // •\ަŠJŽn“úŽž  
459    var end = new Date('2026/08/20 00:00:00'); // •\ަI—¹“úŽž
460    if (now < start || now >= end) {
461        $('#js-long_vacation').remove();
462    } else if (now >= start && now < end) {
463        $('#js-long_vacation').css('display', 'block');
464    }
465
466    var _this = this;
467
468    $('#js-info-slider').slick({
469      slidesToShow: 1,
470      slidesToScroll: 1,
471      autoplay: true,
472      arrows: true,
473      dots: true,
474      appendArrows: $('#js-info-slider-nav'),
475      appendDots: $('#js-info-slider-nav'),
476      prevArrow: `<button type="button" class="slick-arrow slick-prev">
477        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13.562 11.78">
477<path fill="currentColor" fill-rule="evenodd" d="M-.007 5.88a.846.846 0 0 1 .847-.84h9.816L7.018 1.43a.837.837 0 0 1 0-1.19.851.851 0 0 1 1.2 0l5.083 5.05a.838.838 0 0 1 0 1.19l-5.083 5.05a.851.851 0 0 1-1.2 0 .837.837 0 0 1 0-1.19l3.638-3.62H.84a.84.84 0 0 1-.847-.84Z"/></svg>
478      </button>`,
479      nextArrow: `<button type="button" class="slick-arrow slick-next">
480        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13.562 11.78"><path fill="currentColor" fill-rule="evenodd" d="M-.007 5.88a.846.846 0 0 1 .847-.84h9.816L7.018 1.43a.837.837 0 0 1 0-1.19.851.851 0 0 1 1.2 0l5.083 5.05a.838.838 0 0 1 0 1.19l-5.083 5.05a.851.851 0 0 1-1.2 0 .837.837 0 0 1 0-1.19l3.638-3.62H.84a.84.84 0 0 1-.847-.84Z"/></svg>
481      </button>`,
482    });
483  },
484  init: function() {
485    this.initSlider();
486  }
487};
488
489
490var MutCalendar = MutCalendar || {};
491
492/* calendar
493=============================== */
494
495MutCalendar.init = function(){
496  cal_init();
497  MutCalendar.updatePagerState();
498};
499
500MutCalendar.close = function(){
501  $('body').removeClass('is-modal');
502  $('#js-calendar').removeClass('is-visible');
503};
504
505MutCalendar.open = function(){
506  $('body').addClass('is-modal');
507  $('#js-calendar').addClass('is-visible');
508};
509
510MutCalendar.toggle = function(){
511  if ( $('#js-calendar').hasClass('is-visible') ) {
512    this.close();
513  } else {
514    this.open();
515  }
516};
517
518/**
519 * •\ަ’†‚̃JƒŒƒ“ƒ_[”NŒŽ‚ɉž‚¶‚āA‘O‚Ö/ŽŸ‚Öƒ{ƒ^ƒ“‚Ì—LŒøó‘Ô‚ðØ‚è‘Ö‚¦‚é
520 */
521MutCalendar.updatePagerState = function() {
522  const today = new Date();
523  const minAbsMonth = today.getFullYear() * 12 + (today.getMonth() + 1);
524  const maxAbsMonth = minAbsMonth + 2;
525
526  const $table = $('#cal0 > table');
527  const classStr = $table.attr('class') ?? '';
528  const yearMatch = classStr.match(/year(\d+)/);
529  const monthMatch = classStr.match(/month(\d+)/);
530
531  if (yearMatch && monthMatch) {
532    const currentAbsMonth = parseInt(yearMatch[1], 10) * 12 + parseInt(monthMatch[1], 10);
533
534    if (currentAbsMonth <= minAbsMonth) {
535      $('#js-calendar-prev').addClass('is-disabled');
536    } else {
537      $('#js-calendar-prev').removeClass('is-disabled');
538    }
539
540    if (currentAbsMonth >= maxAbsMonth) {
541      $('#js-calendar-next').addClass('is-disabled');
542    } else {
543      $('#js-calendar-next').removeClass('is-disabled');
544    }
545  }
546};
547
548MutCalendar.pager = function(direction){
549  if (direction === "prev") {
550    cal_prev();
551  }
552  if (direction === "next") {
553    cal_next();
554  }
555  
556  MutCalendar.updatePagerState();
557};
558
559$(document).on('click','#js-calendar', function(e) {
560    e.preventDefault();
561    MutCalendar.toggle();
562});
563$(document).on('click','#js-calendar-box', function(e) {
564    e.stopPropagation();
565});
566$(document).on('click','#js-calendar-prev', function(e) {
567  e.preventDefault();
568  MutCalendar.pager('prev');
569});
570$(document).on('click','#js-calendar-next', function(e) {
571  e.preventDefault();
572  MutCalendar.pager('next');
573});

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.