PageSourceSearch

https://sports.niu.ac.jp/assets/templates/niusports/js/add.js

js niu.ac.jp collected 2026-10-02 14:42:11 UTC 5,901 bytes, 192 lines download raw bytes

1$(window).on('load resize', function() {
2  resizeEvent();
3});
4
5window.addEventListener('DOMContentLoaded', function() {
6
7  //ie11のobjectfit対応
8  if(!Modernizr.cssobjectfit && window.matchMedia('(min-width:721px)').matches){
9    const nofit_obj = document.querySelectorAll('.objectfit-cover');
10    for( var i=0; i<nofit_obj.length; i++ ){
11      var obj = nofit_obj[i];
12      var prop = obj.querySelector('img').getAttribute('src');
13      
14      if(prop){
15        obj.style.backgroundImage = 'url(' + prop + ')';
16      }
17    }
18  }
19
20  if($(".edit-block").length){
21    $(".edit-block table").wrap('<div class="table-scroll">');
22  }
23
24  createObserver();
25});
26
27function resizeEvent(){
28  var windowWidth,windowHeight;
29  windowWidth = $(window).width();
30  windowHeight = $(window).height();
31  
32  //メニューをpc表示に変更
33  if( window.matchMedia('(max-width:720px)').matches ){
34    $('.container-gnav').attr("style","");
35    $(".sp-menu-btn").attr('aria-pressed', 'false');
36    $('.sp-menu-block').attr('aria-hidden', 'false');
37  }
38  else{
39    $('.sp-menu-block').attr('aria-hidden', 'true');
40  }
41
42  // //観戦カレンター
43  // if($("#calendar-box.expand-container").length>0){
44  //   if( !window.matchMedia('(max-width:720px)').matches ){
45  //     var maxheight = $(".expand__child:nth-child(1)").innerHeight() + $(".expand__child:nth-child(4)").innerHeight()+90;
46  //   }
47  //   else{
48  //     var maxheight = $(".expand__child:nth-child(1)").innerHeight() + $(".expand__child:nth-child(2)").innerHeight() + $(".cal-list__item:nth-child(3)").innerHeight() +110;
49  //   }
50  //   $(".expand-container").css("max-height",maxheight);
51  // }
52  //newsの隠す高さを設定
53  if($("#news-list-box.expand-container").length>0){
54    if( window.matchMedia('(max-width:720px)').matches ){
55      var maxheight = $(".expand__child:nth-child(1)").innerHeight() + $(".expand__child:nth-child(2)").innerHeight() + $(".expand__child:nth-child(3)").innerHeight()+108;
56      $(".expand-container").css("max-height",maxheight);
57    }
58  }
59}
60
61function createObserver() {
62  const observerTarget = document.querySelectorAll('.observer-point');
63  const footerTarget = document.querySelector('.footer');
64
65  const options = {
66    root: null, // 今回はビューポートをルート要素とする
67    rootMargin: "-30% 0px", // ビューポートの中心やや上を判定基準にする
68    threshold: 0 // 閾値は0
69  };
70
71  const observer = new IntersectionObserver(pagetopDisplay, options);
72  const footerobserver = new IntersectionObserver(handleIntersectFooter, {
73    root: null,
74    rootMargin: '0px 0px 0px 0px',
75    threshold: [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8, 1.0],
76  });
77
78  for( var i=0; i<observerTarget.length; i++ ){
79    var obj = observerTarget[i];
80    observer.observe(obj);
81  }
82
83  footerobserver.observe(footerTarget);
84}
85
86function pagetopDisplay(entries) {
87  for( var i=0; i<entries.length; i++ ){
88    var entry = entries[i];
89    if (entry.isIntersecting) {
90      $(".btn-pagetop").fadeOut();
91      $(".header-bg").removeClass('header-bg-alpha');
92    }
93    else{
94      $(".btn-pagetop").fadeIn();
95      $(".header-bg").addClass('header-bg-alpha');      
96    }
97  }
98}
99
100//footerの位置でストプ
101function handleIntersectFooter(entries) {
102  for( var i=0; i<entries.length; i++ ){
103    var entry = entries[i];
104    if (entry.isIntersecting) {
105      $(".container-pagetop").addClass('abs');
106    }
107    else {
108      $(".container-pagetop").removeClass('abs');
109    }
110  }
111}
112
113//---------------------------------------------------------------------- 
114//ページスクロール
115$('[href^="#"]').on('click', function(event) {
116  event.preventDefault();
117  var href= $(this).attr("href");
118  var target = $(href == "#" || href == "" ? 'html' : href);
119  var position = target.offset().top - 100;//header height
120  $('body,html').animate({scrollTop:position}, 400, 'swing');
121});
122
123$('[aria-controls="header"]').on('click', function(event) {
124  event.preventDefault();
125  $('body,html').animate({scrollTop:0}, 400, 'swing');
126});
127
128
129
130//+アイコンクリック メニュー開閉
131$(".container-gnav").on("click", ".slideicon", function(event) {
132  if($(this).attr('aria-pressed')=='true') {
133    $(this).attr('aria-pressed', 'false');
134    $(this).next().attr('aria-hidden', 'true');
135  }else{
136    $(this).attr('aria-pressed', 'true');
137    $(this).next().attr('aria-hidden', 'false');
138  }       
139  return false;
140});
141
142$('.sp-menu-block').on('click', function(event) {
143  if($(".sp-menu-btn").attr('aria-pressed')=='true') {
144    $(".sp-menu-btn").attr('aria-pressed', 'false');
145    $('.container-gnav').fadeOut();           
146  }     
147  else{
148    $('.container-gnav').fadeIn();
149    $(".sp-menu-btn").attr('aria-pressed', 'true'); 
150  }
151  return false;
152});
153
154
155if(! window.matchMedia('(max-width:720px)').matches ){
156  $('.container-gnav').on({ 
157    'mouseenter': function(e){
158      if($(this).find('.nav-sub').attr('aria-hidden')=='true') {
159        $(this).find('.nav-sub').attr('aria-hidden', 'false');
160        $(this).attr('aria-expanded', 'true');
161      }
162    },
163    'mouseleave': function(e){
164      if($(this).find(".nav-sub").attr('aria-hidden')=='false') {
165        $(this).find('.nav-sub').attr('aria-hidden', 'true');
166        $(this).attr('aria-expanded', 'false');
167      }
168    },
169  },".nav__item:has(.nav-sub)");
170}
171
172
173$('.btn[aria-pressed]').on('click', function() {
174  if( $(this).attr('aria-pressed')=='false') {
175    $(this).attr('aria-pressed','true');
176    var target = $(this).attr('aria-controls');
177    $('#'+target).attr('aria-expanded', 'true');
178    if($(this).hasClass('text-toggle')){
179      $(this).text('close');
180    }
181  }     
182  else if( $(this).attr('aria-pressed')=='true') {
183    $(this).attr('aria-pressed','false');
184    var target = $(this).attr('aria-controls');
185    $('#'+target).attr('aria-expanded', 'false');
186    if($(this).hasClass('text-toggle')){
187      $(this).text('more');
188    }
189  }    
190});
191
192

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.