PageSourceSearch

https://www.niken.jp/assets/js/script.js

js niken.jp collected 2026-10-02 14:34:53 UTC 12,037 bytes, 429 lines download raw bytes

1var BRK = 767;
2var w = window.innerWidth;
3var ios;
4
5$(function(){
6
7  //iOS対策
8  ios = false;
9  var userAgent = window.navigator.userAgent.toLowerCase();
10  if (userAgent.indexOf('ipad') != -1 || userAgent.indexOf('iphone') != -1) {
11    $('body').addClass('ios');
12    ios = true;
13  }
14
15  //グローバルナビ
16  gnaviInit();
17  gnaviSpInit();
18  //追従ナビ
19  naviBarBottom();
20  //アコーディオン(グロナビ)
21  actionAccordion('#gnavi_sp','.acd_title .icon');
22  //アコーディオン(学科一覧)
23  actionAccordion('#fnavi','.acd_title .icon');
24  //アコーディオン(コンポーネント)
25  actionAccordion('.block');
26  //matchHeight
27  $('#search_window .btn_list> li').matchHeight();
28  //タブボックス
29  actionTabBox();
30  //検索フォーム
31  //observeSearchInput();
32
33});
34
35/* スクリーン判定
36----------------------------------------------- */
37function callScreen(){
38  w = window.innerWidth;
39  if( w > BRK ){
40    return 'pc';
41  }else{
42    return 'sp';
43  }
44}
45
46/* ua判定
47----------------------------------------------- */
48function callUA() {
49  var ua = navigator.userAgent;
50  if (ua.indexOf('iPhone') > 0 || ua.indexOf('iPod') > 0 || (ua.indexOf('Android') > 0) && (ua.indexOf('Mobile') > 0) || ua.indexOf('Windows Phone') > 0) {
51    return 'sp';
52  }else if (ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0) {
53    return 'tab';
54  } else {
55    return 'pc';
56  }
57}
58
59/* Global Navi
60----------------------------------------------- */
61function gnaviInit(){
62
63  var beginning = true;
64  var search = false;
65  var spd = 300;
66
67  //検索窓内ボタンの初期設定(展開時には更新)
68  $('#search_window .list_trend> li').matchHeight();
69
70  //読み込み時に先頭でなければ閉じる
71  $(window).on('load', function(){
72    if ( beginning && $(this).scrollTop() ) {
73      beginning = false;
74      toggleMenu('close');
75    }
76  });
77
78  //スクロールしたら閉じる
79  $(window).on('scroll touchmove', function(){
80    if (beginning) {
81      beginning = false;
82      toggleMenu('close');
83    }
84  });
85
86  //スマホ→PCサイズに変更時のフッタバグ回避
87  $(window).on('resize', function(){
88    if( callScreen() === 'pc' ){
89      $('#fnavi .accordion').removeClass('on');
90      $('#fnavi .acd_detail').removeAttr('style');
91    }
92  });
93
94  //MENUボタンクリックで開く
95  $('#gnavi_open').on('click', function(){
96    if (beginning) {
97      beginning = false;
98    }
99    toggleMenu('open');
100  });
101
102  //マウスアウトで閉じる
103  $('#gnavi .menu_container').mouseleave(function(){
104    //if (!beginning && !search) {
105    if (!beginning && !search) {
106      toggleMenu('close');
107    }
108  });
109
110  //下層展開
111  $('#gnavi .list_item').mouseenter(function(){
112    if($(this).attr('open-type') === 'hover'){
113      $(this).children('.cat_inner').addClass('active');
114      $(this).children('.submenu_container').stop().fadeIn(spd);
115    }
116  }).mouseleave(function(){
117    if($(this).attr('open-type') === 'hover'){
118      $(this).children('.item_inner').removeClass('active');
119      $(this).children('.submenu_container').stop().fadeOut(spd);
120    }
121  });
122
123  //検索窓を開く
124  $('#gnavi .single .search').on('click', function(){
125    if (!search) {
126      search = true;
127      $(this).addClass('active');
128      $('#modal_bg, #search_window').fadeIn(spd);
129      //matchHeight更新
130      $.fn.matchHeight._update();
131    }
132  });
133
134  //検索窓を閉じる
135  $('#search_window .close, #modal_bg').on('click', function(){
136    if (search) {
137      search = false;
138      $('#gnavi .item07 .item_inner').removeClass('active');
139      $('#search_window, #modal_bg').fadeOut(spd);
140      //閉じたら中身を消す
141      $('#search_window .input_text').val('').addClass('hold');
142      //メインメニューを畳む
143      if (!beginning) {
144        toggleMenu('close');
145      }
146    }
147  });
148
149  //グロナビ開閉本体
150  function toggleMenu(order){
151    if ( order === 'open' ){
152      $('#gnavi .list').stop().slideDown(spd);
153      $('#gnavi_open').stop().slideUp(spd);
154    } else if ( order === 'close' ){
155      $('#gnavi .list').stop().slideUp(spd);
156      $('#gnavi_open').stop().slideDown(spd);
157    }
158  }
159
160}
161
162/* Global Navi (SP)
163----------------------------------------------- */
164function gnaviSpInit(){
165
166  var scrollpos;
167  var spd = 300;
168
169  //メニューを開く
170  $('#gnavi_sp_open').on('click', function(){
171    $('#gnavi_sp_open').fadeOut(spd);
172    $('#gnavi_sp').fadeIn(spd);
173    //本文スクロール禁止
174    scrollpos = $(window).scrollTop();
175    stopScroll(scrollpos);
176  });
177
178  //メニューを閉じる
179  $('#gnavi_sp, #gnavi_sp_close').on('click', function(){
180    $('#gnavi_sp_open').fadeIn(spd);
181    $('#gnavi_sp').fadeOut(spd, function(){
182      //アコーディオンをリセット
183      resetAccordion('#gnavi_sp');
184    });
185    //本文スクロール解禁
186    allowScroll(scrollpos);
187    $('.menu').removeClass('open');
188  });
189
190  //バブリング制御
191  $('#gnavi_sp .list').on('click', function(e){
192    e.stopPropagation();
193  });
194
195  //box08高さ揃え
196  $('.box08 .sublist li').matchHeight();
197}
198
199//本文スクロール禁止
200function stopScroll(posY){
201  $('body').addClass('fixed').css({'top': -posY});
202}
203
204//本文スクロール解禁
205function allowScroll(posY){
206  $('body').removeClass('fixed').css({'top': 0});
207  window.scrollTo( 0, posY );
208}
209
210	/* pageTopボタン スクロール位置を判定して表示制御
211	----------------------------------------------- */
212	$(window).bind("scroll", function() {
213	// ドキュメントの高さ
214	scrollHeight = $(document).height();
215	// スクロールした高さ
216	scrollTop = $(window).scrollTop();
217	// ウィンドウの高さ+スクロールした高さ→ 現在のトップからの位置
218	//scrollPosition = $(window).height() + $(window).scrollTop();
219	scrollPosition = $(window).height() + scrollTop;
220	// フッターの高さ
221	footHeight = $("footer").height();
222
223	// スクロール位置が指定位置に来たら
224	if ( scrollTop  >= 200 ) {
225		// 位置をずらして表示
226		$(".gotop.for_pc").removeClass('hide');
227	} else {
228		// 位置をずらして非表示
229		$(".gotop.for_pc").addClass('hide');
230		}
231
232	// スクロール位置がフッターまで来たら
233	if ( scrollHeight - scrollPosition  <= footHeight ) {
234		// フッターに固定
235		$(".gotop.for_pc").css({"position":"absolute","top": "20px","bottom": "auto"});
236	} else {
237		// 右下に固定
238		$(".gotop.for_pc").css({"position":"fixed","top": "auto","bottom": "15px"});
239		}
240	});
241	
242
243
244/* 追従メニュー (SP)
245----------------------------------------------- */
246function naviBarBottom(){
247
248  var beginning = true;
249  var spd = 300;
250
251  //ロード時に先頭でなければ表示
252  $(window).on('load', function(){
253    if( callScreen() === 'sp' && $(this).scrollTop() ) {
254      beginning = false;
255      $('#navi_bar_bottom').stop().slideDown(spd);
256    }
257  });
258
259  //スクロールしたら表示
260  $(window).on('scroll touchmove', function(){
261    if ( beginning ) {
262      beginning = false;
263      $('#navi_bar_bottom').stop().slideDown(spd);
264    }
265  });
266
267}
268
269/* アコーディオン汎用
270----------------------------------------------- */
271function actionAccordion(area,selector){
272  if(area === undefined) area = '.wrapper'; //対象範囲
273  if(selector === undefined) selector = '.acd_title'; //展開セレクタ
274  var $area = $(area);
275  var spd = 300;
276  $area.find(selector).on('click', function(){
277    var state = false;
278    var $group = $(this).closest(area);
279    var $this = $(this).closest('.accordion');
280    //選択先の開閉判定
281    if( !$this.hasClass('on') ){
282      state = true;
283    }
284    //グループ内ですべて閉じる
285    $group.find('.accordion').removeClass('on');
286    $group.find('.acd_detail').stop().slideUp(spd);
287    //選択先が閉じていた場合は開く
288    if( state ){
289      $this.addClass('on');
290      $this.children('.acd_detail').stop().slideDown(spd);
291    }
292  });
293}
294
295//初期化
296function resetAccordion(area){
297  if(area === undefined) area = '.wrapper'; //対象範囲
298  var $area = $(area);
299  $area.find('.accordion').removeClass('on');
300  $area.find('.acd_detail').hide();
301}
302
303/* 検索フォーム入力監視(不使用中)
304----------------------------------------------- */
305function observeSearchInput(){
306  $('.input_text').change(function(){
307    var val = $(this).val();
308    //背景表示切替
309    if(val === ''){
310      $(this).addClass('hold');
311    }else{
312      $(this).removeClass('hold');
313    }
314  });
315}
316
317/* List Uplift
318----------------------------------------------- */
319function actionUpliftPanel(type){
320
321  var ua = callUA();
322  var $box = $('.list_uplift .box');
323  var spd = 300;
324  var defHeight,boxHeight;
325  var extra = false;
326
327  if(type === 'special') {
328    /* NIKKENを知るindex */
329    defHeight = 110;
330  }else if( type === 'meeting'){
331    /* クロストーク */
332    defHeight = 90;
333    extra = true;
334  }else{
335    defHeight = 0;
336  }
337
338  //PC
339  if(ua === 'pc'){
340    $box.on('mouseenter', function(){
341      boxHeight = $(this).height();
342      $(this).find('.caption').stop().animate({height:boxHeight+'px'}, spd);
343      if(extra){
344        $(this).find('.profile').stop().slideDown(spd);
345      }
346    }).on('mouseleave', function(){
347      $(this).find('.caption').stop().animate({height:defHeight+'px'}, spd);
348      if(extra){
349        $(this).find('.profile').stop().slideUp(spd);
350      }
351    });
352  }
353
354  //tablet & smartphone
355  if( ua !== 'pc' && extra ){
356    $box.on('click', function(){
357      if($(this).hasClass('active')){
358        $(this).removeClass('active');
359        $(this).find('.caption').stop().animate({height:'41%'}, spd);
360        $(this).find('.profile').stop().slideUp(spd);
361      }else{
362        $box.removeClass('active');
363        $box.find('.caption').stop().animate({height:'41%'}, spd);
364        $box.find('.profile').stop().slideUp(spd);
365        $(this).addClass('active');
366        $(this).find('.caption').stop().animate({height:'100%'}, spd);
367        $(this).find('.profile').stop().slideDown(spd);
368      }
369    });
370  }
371}
372
373/* TabBox
374----------------------------------------------- */
375function actionTabBox(){
376  $('.block_tabbox .tab').on('click', function(){
377    var spd = 160;
378    var $parent = $(this).closest('.block_tabbox');
379    var $tabs = $parent.find('.tab');
380    var $wrap = $parent.find('.box_detail_wrap');
381    var $details = $parent.find('.detail');
382    var idx = $parent.find('.tab').index(this);
383    var $target = $parent.find('.detail').eq(idx);
384    $tabs.removeClass('active');
385    $(this).addClass('active');
386    $details.animate({opacity:0}
386, spd, function(){
387      $(this).removeAttr('style').removeClass('active').hide();
388      $target.fadeIn(spd).addClass('active');
389    });
390    //console.log('idx='+idx);
391  });
392}
393
394/* iOS時のGoogleMap不具合対策(access.html)
395----------------------------------------------- */
396function accessMapForiOS(){
397  if(ios){
398    $('html,body').css({
399      'height': '100%',
400      'overflow': 'auto',
401      '-webkit-overflow-scrolling': 'touch',
402    });
403  }
404}
405
406/* 追従メニュー(SP)の表示制御
407----------------------------------------------- */
408
409function HdStickMove(){
410  if( callScreen() === 'sp' ){
411    var scroll = $(window).scrollTop();//scroll値を取得
412    if (scroll >= 20){//scrollが20を上回ったとき
413      $('.hd_stick .btn_link').addClass('close');//UpMoveを追加
414    }else{
415      $('.hd_stick .btn_link').removeClass('close');
416    }
417  }
418}
419$(window).scroll(function () {
420  HdStickMove();
421});
422
423$(window).on('load', function () {
424  HdStickMove();
425});
426
427$(".hd_stick .btn").click(function(){
428  $(this).parents('.btn_link').toggleClass("close");
429});

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.