PageSourceSearch

http://www.allnightnippon.com/new_data/js/global.js

js allnightnippon.com collected 2026-10-02 02:43:50 UTC 5,193 bytes, 178 lines download raw bytes

1// global.js
2
3// ロード時の処理 ===================================
4$(function(){
5	winClass();	// 現在のウインドウ幅に応じた処理
6	selectNav();	// プルダウンメニュー
7	globalNav();	// スマホ版グローバルナビ
8	pagescroll();	// 汎用ページスクローラー
9    limit(); // 文字数制限
10    //foot_icon(); // ページ下部アイコンスタイル
11    outbrain(); // Outbrain
12	ReLayout(); //リサイズ終了時のみリロードする
13	caption(); // 記事画像キャプション設定
14	bxslider_link(); // bxsliderのリンクがChromeで効かない現象の対策
15});
16
17// リサイズ時の処理 ===================================
18$(window).resize(function(){
19	winClass(); // 現在のウインドウ幅に応じた処理
20});
21
22//リサイズ終了時のみリロードする
23function ReLayout() {
24    var userAgent = navigator.userAgent;
25    var timer = false;
26
27    // スマートフォンの場合はorientationchangeイベントを監視する
28    if (userAgent.indexOf("iPhone") >= 0 || userAgent.indexOf("iPad") >= 0 || userAgent.indexOf("Android") >= 0)
29        window.addEventListener("orientationchange", resizeHandler);
30    else
31        window.addEventListener("resize", resizeHandler);
32
33    function resizeHandler() {
34        if (timer !== false) {
35            clearTimeout(timer);
36        }
37        timer = setTimeout(function() {
38            location.reload();
39        }, 200);
40    }
41}
42
43// 現在のウインドウ幅に応じた処理
44function winClass() {
45	var winwidth = $(window).width();
46	if (winwidth < 768) {
47		if(!jQuery.support.opacity){
48			return;	// IE8以前はレスポンシブさせない
49		} else {
50			$("body").removeClass("mode_pc").addClass("mode_sp");
51			var bodyclass = $("body").attr("class"); // デバッグ用変数
52			imgResize();	// 汎用レスポンシブイメージ
53		}
54	} else {
55		if(!jQuery.support.opacity){
56			return;	// IE8以前はレスポンシブさせない
57		} else {
58			$("body").removeClass("mode_sp").addClass("mode_pc");
59			var bodyclass = $("body").attr("class"); // デバッグ用変数
60			imgResize();	// 汎用レスポンシブイメージ
61		}
62	}
63}
64
65// 汎用レスポンシブイメージ(winClass()から呼び出す)
66function imgResize() {
67	if ($("body").hasClass("mode_pc")) {
68		$(".imgrsp").each(function(){
69			var dataSrc = $(this).attr("src").replace("_sp.","_pc.");
70			$(this).attr("src",dataSrc);
71		});
72	}
73	if ($("body").hasClass("mode_sp")) {
74		$(".imgrsp").each(function(){
75			var dataSrc = $(this).attr("src").replace("_pc.","_sp.");
76			$(this).attr("src",dataSrc);
77		});
78	}
79}
80
81// プルダウンメニュー
82function selectNav() {
83	$(".pagenav_selectmenu").find("select").change(function(){
84		var ChangeTxt = $(this).find("option:selected").text();
85		$(".pagenav_select_txt").text(ChangeTxt);
86	});
87}
88
89// スマホ版グローバルナビ
90function globalNav() {
91	$(".globalnav_btn").find("a").click(function(){
92		$("header").toggleClass("header_on_sp");
93		$(".globalnav").slideToggle();
94	});
95	$(".globalnav_close").find("a").click(function(){
96		$("header").removeClass("header_on_sp");
97		$(".globalnav").slideUp();
98	});
99}
100
101// 汎用ページスクローラー
102function pagescroll() {
103	$('.footer_pagetop a,a.footer_pagetop').click(function(){
104		$('html,body').animate({scrollTop: 0},1000,'easeOutExpo');
105		return false;
106	});
107	$('a.scroll,.scroll a').click(function(){
108		var tagname = $(this).attr('href');
109		var tagpotion = $(tagname).offset().top;
110		$('html,body').animate({scrollTop: tagpotion},1000,'easeOutExpo');
111		return false;
112	});
113}
114
115// 広告動画出し分け
116//$(window).load(function(){
117//    if($("#ULIZA_INERAD_PLAYER:empty")){
118//        $('.prlink_movie_movie').remove();
119//        $('.footer_banner').css({width: 'auto',float: 'none'});
120//    }
121//}
122
123// 文字数制限
124function limit() {
125      $(".news_doc").each(function(){
126      var size = 53;
127      var txt = $(this).text();
128      var suffix = '…';
129      var b = 0;
130      for(var i = 0; i < txt.length; i++) {
131        b += txt.charCodeAt(i) <= 255 ? 0.5 : 1;
132        if (b > size) {
133          txt = txt.substr(0, i) + suffix;
134          break;
135        }
136      }
137      $(this).text(txt);
138    });
139}
140
141// ページ下部アイコンスタイル
142function foot_icon() {
143    var icon = $(".footer_icon li").length;
144    if(icon === 3 || icon === 6){
145        $(".prlink .footer_icon li").css({ width : 33 + '%' });
146    }else if(icon === 4 || icon === 7 || icon === 8 || icon === 11 || icon === 12){
147        $(".prlink .footer_icon li").css({ width : 25 + '%' });
148    }
149}
150
151// Outbrain
152function outbrain() {
153    $('.OUTBRAIN').attr('data-widget-id', "AR_1");
154}
155
156// 記事画像キャプション設定
157function caption() {
158	if($(".wp-caption-text").length){
159		$(".wp-caption-text").prev("img").css({
160			margin: '0 auto 10px',
161			display: 'block'
162		});
163	}
164}
165
166// bxsliderのリンクがChromeで効かない現象の対策
167function bxslider_link() {
168	$(document).on('mousedown','.bx-viewport a',function(){
169		var $this = $(this),
170			myHref = $this.attr('href'),
171			myTarget = $this.attr('target');
172		if(myTarget === '_blank'){
173		  window.open(myHref);
174		}else{
175		  window.location.href = myHref;
176		}
177	});
178}

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.