PageSourceSearch

https://nayacafe.net/js/theme_oneplate/init.js?20151028

js nayacafe.net collected 2026-10-06 10:25:46 UTC 8,989 bytes, 315 lines download raw bytes

1'use strict';
2
3/**
4 * Oneplate
5 * init.js
6 * ver.202007200000
7 */
8
9/**
10 * デバイス制御
11*/
12var viewMode = {
13    set: function() {
14        var target = $('#container');
15        var classList = 'pc-view tablet-view phone-view';
16
17        // pc
18        if ($('#header #button_navi').css('display') === 'none') {
19            target.removeClass(classList).addClass('pc-view');
20
21        // スマホ
22        } else if ($('h2.page_title').css('margin-top') === '40px') {
23            target.removeClass(classList).addClass('phone-view');
24
25        // タブレット
26        } else {
27            target.removeClass(classList).addClass('tablet-view');
28        }
29    },
30
31    get: function(classname) {
32        return $('#container').hasClass(classname);
33    }
34};
35
36/**
37 * ブラウザ判定
38*/
39var browser = {
40    set: function() {
41        var u = window.navigator.userAgent.toLowerCase();
42
43        // ie
44        if (u.match(/(MSIE|msie)/) || u.match(/(T|t)rident/) || u.match(/(E|e)dge/)) {
45            $('#container').addClass('ie');
46        }
47    }
48};
49
50/**
51 * header制御
52*/
53var header = {
54    actFlag: false,
55    headerHeight: 0,
56
57    getHeight: function() {
58        header.headerHeight = $('#header').height();
59        return this;
60    },
61
62    init: function() {
63        header.getHeight();
64        // スクロール可能量がヘッダ高*2以下なら制御無し
65        header.actFlag = ($(document).height() - $(window).height()) > header.headerHeight * 2;
66        return this;
67    },
68
69    scroll: function() {
70        if (header.actFlag) {
71            var target = $('.cd-header');
72            var winY = $(window).scrollTop();
73
74            // ヘッダ高 < スクロール量
75            if (header.headerHeight < winY) {
76                if (!$('.clone-header').length) {
77                    target.clone().insertBefore(target).removeClass('cd-header').addClass('clone-header').css('visibility', 'hidden');
78                }
79                target.removeClass('hide').addClass('is-scroll');
80
81            // ヘッダ高*0.75 < スクロール量 < ヘッダ高
82            } else if ((header.headerHeight * 0.75) < winY && winY < header.headerHeight) {
83                $('.clone-header').remove();
84                target.removeClass('is-scroll').addClass('hide');
85
86            // スクロール量0
87            } else {
88                $('.clone-header').remove();
89                target.removeClass('is-scroll hide');
90            }
91        }
92        return this;
93    }
94};
95
96$(function(){
97    header.init();
98});
99
100$(window).on('scroll', function() {
101    header.scroll();
102});
103
104$(window).on('load resize', function() {
105    header.init().scroll();
106});
107
108/**
109 * Initialize
110*/
111$(function() {
112    // デバイス制御init
113    viewMode.set();
114    browser.set();
115
116    // ナビclone
117    $('.navi.pc .navi_list').clone(true).appendTo($('.navi.mobile'));
118
119    // ナビ制御
120    $('#button_navi .navi_trigger, .navi.mobile').on('click', function() {
121        var isOpened, yPos;
122        var $target = $('#header');
123        var scrollbarW = window.innerWidth - document.body.clientWidth;
124
125        // 状態フラグ取得
126        isOpened = ($target.hasClass('open'));
127
128        // ナビY座標
129        yPos = (!isOpened) ? $(window).scrollTop().top : 0;
130
131        // ナビclose -> open
132        if (!isOpened) {
133            // ナビアイコン変更
134            $('#button_navi i').removeClass('fa-navicon').addClass('fa-close');
135
136            // ナビ高をウィンドウ高にfit
137            $('.navi.mobile').css({
138                'height': '100%',
139                'position': 'fixed'
140            });
141
142            $('#button_navi').css({
143                'right': scrollbarW + 20 + 'px'
144            });
145
146            // headerY座標セット
147            $target.css({
148                'top': yPos + 'px',
149                'padding-right': scrollbarW + 'px'
150            });
151
152            // bodyスクロールバー非表示
153            $('body').css({
154                'overflow-y': 'hidden'
155            });
156
157            // ナビopenアクション
158            $('.navi.mobile').css('overflow-y', 'scroll').animate({opacity: 'show'}, {duration: 200, easing: 'swing'});
159
160        // ナビopen -> close
161        } else {
162            // ナビアイコン変更
163            $('#button_navi i').removeClass('fa-close').addClass('fa-navicon');
164
165            // ナビcloseアクション
166            $('.navi.mobile').css('overflow-y', 'hidden').animate({opacity: 'hide'}, {duration: 100, easing: 'swing'});
167
168            $('#button_navi').css({
169                'right': 20 + 'px'
170            });
171
172            // bodyスクロールバー非表示
173            $('body').css({
174                'overflow-y': 'scroll'
175            });
176
177            // headerY座標セット
178            $target.css({
179                'top': 0,
180                'padding-right': 0
181            });
182        }
183
184        // 状態フラグ(class)セット
185        $target.toggleClass('open');
186        $('body').toggleClass('navi-open');
187    });
188
189    // ボタン外click時の制御
190    $('.navi.mobile ul').on('click', function(event) {
191        event.stopPropagation();
192    });
193
194    // ページタイトルにリンク付加(top, free, minne-gallery以外)
195    var bodyId = $('body').attr('id');
196    var siteURL = $('#header .logo a').attr('href') + '/' + bodyId;
197
198    if (bodyId !== 'free' && bodyId !== 'top' && bodyId !== 'minne-gallery' && bodyId !== 'event-reservation') {
199        $('<a>'+ $('.page_title span').text() + '</a>').appendTo('.page_title').attr('href', siteURL);
200        $('.page_title span').remove();
201    }
202
203    // 電話番号タップ対応
204    if (!viewMode.get('pc-view') && $('.shop_tel').css('display') === 'block') {
205        $('.shop_tel > div').wrap('<a href="tel:' + $('.shop_tel').data('shoptel') + '"></a>');
206    }
207
208    // pager(next・prev)をfont-awesomeに置換
209    $('.pager .prev').text('').attr('class', 'prev fa fa-angle-left');
210    $('.pager .next').text('').attr('class', 'next fa fa-angle-right');
211
212    // navi_parts(バナー/ウィジェット)を抽出して移動
213    var naviparts = $('#navi_parts');
214
215    if (naviparts.children().length !== 0) {
216        $('.gadgets .inner').append(naviparts);
217    } else {
218        $('.gadgets').remove();
219    }
220
221    // Schedule, Counter, QRコードstyle
222    $('.sidebar .block').each(function() {
223        if ($(this).css('display') === 'block') {
224            $(this).css('display', 'inline-block');
225        } else {
226            $(this).remove();
227        }
228    });
229
230    // Scheduleが0件なら領域削除
231    if ($('.today_area dd').length === 0) {
232        $('.today_area').remove();
233    }
234
235    // Schedule, Counter, QRコードが全て非表示なら領域削除
236    if ($('.sidebar .block').children().length === 0) {
237        $('.sidebar').remove();
238    }
239
240    // Socialボタンが全て非表示なら領域削除
241    if ($('.social .inner').children().length === 0) {
242        $('.social').remove();
243    }
244
245    // facebookページウィジェットの手前に改行付加
246    $('.social_widget_facebook_likebox').before('<br />');
247
248    if ( $('.commoncontent').children().length === 0 ) {
249        $('.commoncontent').remove();
250    }
251
252    // Powered byをinlineに
253    if ($('.powered').css('display') === 'block') {
254        $('.powered').css('display', 'inline');
255    }
256
257    // RSSをinlineに
258    if ($('.shop_rss').css('display') === 'block') {
259        $('.shop_rss').css('display', 'inline');
260
261        if ($('.powered').css('display') !== 'none') {
262            $('.shop_rss span').css('display', 'inline');
263        }
264    }
265
266    // colorbox(求人ページ・メルマガ・フォトアルバム除外)
267    $('.thickbox').not('.navi_recruit, .navi_melmaga, .js-colorbox-html').each(function() {
268        $(this).colorbox({
269            rel: $(this).attr('rel'),
270            className: 'cb',
271            width: '90%',
272            height: '90%',
273            transition: 'fade',
274            previous: '<i class="fa fa-angle-left"></i>',
275            next: '<i class="fa fa-angle-right"></i>',
276            close: '<i class="fa fa-close"></i>',
277            fixed: true
278        });
279    });
280
281    $(document).on('cbox_open cbox_closed', function() {
282        $('body').toggleClass('modal-open');
283    });
284
285    // back to topボタン
286    var $pagetop = $('.totop .button');
287
288    $(window).on('scroll', function() {
289        if ($(this).scrollTop() > 100) {
290            $pagetop.addClass('is-visible');
291        } else {
292            $pagetop.removeClass('is-visible');
293        }
294    });
295
296    $pagetop.on('click', function() {
297        $('body, html').animate({ scrollTop: 0 }, 500);
298        return false;
299    });
300});
301
302/**
303 * Window Load, Resize
304*/
305$(window).on('load resize', function() {
306    // デバイス制御reinit
307    viewMode.set();
308
309    // Schedule, Counter, QRコード領域高さ揃え
310    if (!viewMode.get('phone-view')) {
311        $('.sidebar .block').tile();
312    } else {
313        $('.sidebar .block').css('height', 'auto');
314    }
315});

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.