PageSourceSearch

https://courrier.jp/wp-content/themes/courrier/js/header.js?ver=cab9f095c09de36c0a2630b552593900

js courrier.jp collected 2026-09-24 18:44:52 UTC 17,086 bytes, 429 lines download raw bytes

1jQuery(document).ready(function ($) {
2    $('.drawer').drawer();
3
4    fixScroll();
5
6    // ページのTOPへ戻る
7    var init_collision_fade_in = false;
8    var bottom_height = 2750;
9    var top_height = 500;
10    var top_height_article = 10;
11    var menu_timeout = null;
12    var scroll_height = 0;
13    var gl_sheight = $(window).scrollTop();
14    var ready_for_close = false;
15    var ep_display = false;
16    var ep_close = false;
17    // tippyの設定
18    var tooltip_instance_pc = tippy('[data-pc-tippy]',
19        {
20            placement: 'left',
21            flip: true,
22            arrow: true,
23            arrowType: 'sharp',
24            trigger: 'manual',
25            theme: 'courrier',
26            size: 'small',
27        }
28    );
29    var tooltip_instance_sp = tippy('[data-sp-tippy]',
30        {
31            placement: 'top',
32            arrow: true,
33            arrowType: 'sharp',
34            trigger: 'manual',
35            theme: 'courrier',
36            sticky: true,
37        }
38    );
39    // const share_template = document.getElementById('example')
40    // const share_container = document.createElement('div')
41    // share_container.appendChild(document.importNode(share_template.content, true))
42    var tooltip_instance_sp_share = tippy('[data-sp-tippy-share]',
43        {
44            placement: 'top',
45            arrow: true,
46            arrowType: 'sharp',
47            trigger: 'click',
48            theme: 'share',
49            sticky: true,
50            interactive: true,
51            content: '<div style="margin:14px 0"><a style="text-decoration:none" data-trigger="facebook" href="javascript:void(0)"><i style="font-size: 25px; color:#3b5998;" class="icon-facebook"></i></a></div><div style="margin-bottom:14px"><a style="text-decoration:none" data-trigger="twitter" href="javascript:void(0)"><i style="font-size: 25px; color:#1da1f2;" class="icon-twitter"></i></a></div><div style="margin-bottom:14px"><a style="display:block; border-radius: 3.7px; margin:5px; background-color:#00a4de; height:25px; width: 25px;" href="javascript:void(0)" data-trigger="hatena"><i class="icon-hatena"></i></a></div>'
52        }
53    );
54    var sp_first_show = true;
55    var is_editors_pick_list_shown = false;
56    // SP版のサイズで開いた後にPC版にした時と PCç‰
56ˆã‹ã‚‰SP版にした時に該当divに処理を加える
57    $(window).on('resize', function() {
58        var $longread = $('#longread_editors_pick');
59        if (window.matchMedia('(max-width:1000px)').matches) {
60            // SPの処理
61            if($($longread).length > 0) {
62                $($longread).hide();
63            }
64        } else {
65            // PCの処理
66            if($($longread).length > 0) {
67                var sheight = $(window).scrollTop();
68                // 画面の高さの1/3を取得
69                var ed_height = $('*').height() / 3;
70                if($($longread).children('a').length === 0 && !is_editors_pick_list_shown && sheight > ed_height) {
71                    get_editors_pick_info();
72                    is_editors_pick_list_shown = true;
73                }
74                if(!ep_close && sheight > ed_height) {
75                    $($longread).show();
76                }
77            }
78        }
79        // 1265px以下 で ヘッダーメニューの処理を行う。
80        // toggle で出しているので、要素に直接当たってしまっている。
81        if (window.matchMedia('(max-width:1264px)').matches) {
82            if($('.header_user_menue').is(':visible')) {
83                $('.header_user_menue').hide();
84            }
85        } else {
86            if($('#courrier_search_area').is(':visible')) {
87                // $('#courrier_search_area').hide();
88            }
89            $('.header_user_menue').show();
90        }
91    });
92    // main image height
93    if($('.article_catch_image_area').height() > 0){
94        top_height_article += $('.article_catch_image_area').height();
95    }
96
97    if(!$('.related_area')[0]){
98        // 関連リンクエリアの存在チェック
99        bottom_height = 900;
100    }
101    if($('[data-sp-tippy]').length > 0 && $('[data-sp-tippy]').is(':visible')) {
102        tooltip_instance_sp[0].show(1000);
103        setTimeout(function(){
104            tooltip_instance_sp[0].hide(1000);
105        }, 3000);
106    }
107    $(window).scroll(function () {
108
109        var sheight = $(window).scrollTop();
110        var prev_sheight = Math.abs(gl_sheight - sheight);
111
112        if (sheight > top_height) {
113            $('#page_top').fadeIn();
114        } else {
115            $('#page_top').fadeOut();
116        }
117
118        if (($(document).height() - sheight) < bottom_height || sheight <= top_height_article) {
119            $('#fixed_sns_area_pc').addClass('v-hide');
120            // tooltip_instance_pc[0].hide(0);
121        } else {
122            if(!init_collision_fade_in){
123                $('#fixed_sns_area_pc').fadeIn(10);
124                $('#fixed_sns_area_pc').removeClass('v-hide');
125                if(is_innerwidth_for_pc()) {
126                    if(tooltip_instance_pc.length > 0){
127                      tooltip_instance_pc[0].show(1000);
128                      // 表示後、n 秒で消える
129                      setTimeout(function(){
130                        tooltip_instance_pc[0].hide(1000);
131                      }, 3000);
132                    }
133                }
134                init_collision_fade_in = true;
135            }
136        }
137
138        // 画面の高さの1/3を取得
139        var ed_height = $('*').height() / 3;
140        // スクロールしたらeditors Pickを表示
141        if (!ep_close && window.matchMedia('(min-width:999px)').matches){
142            if (sheight > ed_height) {
143                $('#longread_editors_pick').fadeIn();
144                ep_display = true;
145            }
146        }
147
148    });
149
150    // 衝突検知によるメニュー表示
151    if($('#fixed_sns_area_pc')[0]){
152        var collision_out_nums = 0;
153        var collision_in_nums = 0;
154        setInterval(function() {
155            var sheight = $(window).scrollTop();
156            if (($(document).height() - sheight) < bottom_height || sheight <= top_height) {
157            } else {
158                // SNSシェアボタンが特定の要素と衝突しているかを取得
159                var collisions = $("#fixed_sns_area_pc").collision(".aligncenter,.alignleft,.wp-post-image,.left-caption,.left-caption-vertical,.article_caption,.mt-left-caption,article > div >img,article > div > div > img, .recommend_area, .editors_picks, footer");
160                //var collisions = $("#fixed_sns_area_pc").collision(".alignleft,.left-caption,.left-caption-vertical");
161                if(collisions.length > 0){
162                    collision_in_nums++;
163                    collision_out_nums = 0;
164                }else{
165                    collision_in_nums = 0;
166                    collision_out_nums++;
167                }
168                if(collision_out_nums >= 2 && sheight >= top_height_article){
169                    $('#fixed_sns_area_pc').fadeIn(1000);
170                    $('#fixed_sns_area_pc').removeClass('v-hide');
171                    collision_out_nums = 0;
172                    collision_in_nums = 0;
173                }else if(collision_in_nums >= 2){
174                    //$('#fixed_sns_area_pc').fadeOut(100);
175                    $('#fixed_sns_area_pc').addClass('v-hide');
176                    collision_out_nums = 0;
177                    collision_in_nums = 0;
178                }
179            }
180        }, 100);
181
182        setInterval(function() {
183            gl_sheight = $(window).scrollTop();
184        }, 1500);
185    }
186
187    // 衝突検知によるメニュー表示
188    if($('#longread_editors_pick')[0]){
189        var collision_out_nums_ep = 0;
190        var collision_in_nums_ep = 0;
191        setInterval(function() {
192            var sheight_ep = $(window).scrollTop();
193            if (($(document).height() - sheight_ep) < bottom_height || sheight_ep <= top_height) {
194            } else {
195                // collisionに渡したクラスに衝突しているかを取得
196                var collisions_ep = $("#longread_editors_pick").collision(".max,.recommend_area");
197
198                if(collisions_ep.length > 0){
199                    // 衝突している場合
200                    collision_in_nums_ep++;
201                    collision_out_nums_ep = 0;
202                }else{
203                    collision_in_nums_ep = 0;
204                    collision_out_nums_ep++;
205                }
206                if(collision_out_nums_ep >= 2 && sheight_ep >= top_height_article && !ep_close && ep_display){
207                    $('#longread_editors_pick').fadeIn(1000);
208                    $('#longread_editors_pick').removeClass('v-hide');
209                    collision_out_nums_ep = 0;
210                    collision_in_nums_ep = 0;
211                }else if(collision_in_nums_ep >= 2 && !ep_close && ep_display){
212                    // 衝突しているかつ、EPの×ボタンが押されていないかつ、EP初期表示後の場合
213                    $('#longread_editors_pick').addClass('v-hide');
214                    collision_out_nums_ep = 0;
215                    collision_in_nums_ep = 0;
216                }
217            }
218        }, 100);
219
220        setInterval(function() {
221            gl_sheight = $(window).scrollTop();
222        }, 1500);
223    }
224
225
226    $(document).on('click', 'div.search-button > a, #courrier_search_area > div.menu_area', function (courrier_header_pc_width) {
227
228        if(window.innerWidth < 1189) {
229            // $('header div.search_box').hide();
230            $('header div.header_search_menu span.search_word').hide();
231            $('#courrier_search_area').animate(
232                {height: "toggle", opacity: "toggle"},
233                "slow"
234            );
235            $('body > header div.header_search_menu div.search-button').show();
236        } else {
237            $('body > header div.header_search_menu div.search-button').toggle();
238            if($('body > header div.header_search_menu div.search-button').is(':visible')) {
239                $('header div.search_box').toggle();
240                $('.header_user_menue').animate(
241                    {width: "toggle", opacity: "toggle"},
242                    "slow"
243                );
244            } else {
245                $('.header_user_menue').animate(
246                    {width: "toggle", opacity: "toggle"},
247                    "slow"
248                );
249                $('header div.search_box').animate(
250                    {width: "toggle", opacity: "toggle"},
251                    "slow"
252                );
253                $('header div.search_box input').focus();
254            }
255        }
256        // console.log('header div.search_box').show(slow);
257    });
258    // focusout で 検索メニューを閉じる準備をする。
259    $(document).on('focusout', 'header div. input', function(event) {
260        ready_for_close = true;
261    });
262    // 検索バー以外のクリックを判断して、閉じる必要があれば検索バーを閉じる。
263    $(document).on('click', function(event) {
264        if(ready_for_close) {
265            if(event.target.closest('header div.search_box span') === null && event.target.closest('header div.search_box button') === null && event.target.closest('header div.search_box .gsc-input') === null) {
266                ready_for_close = false;
267                $('div.search-button > a').click();
268            }
269        }
270    });
271
272    // editors Pickを閉じる
273    $(document).on('click', '.sw-close', function() {
274        $('#longread_editors_pick').fadeOut()
275        ep_close = true;
276    });
277
278    // スクロールを無効にする
279
280    // カテゴリ一覧、ユーザーメニューの展開(出したままということだったのでコメントアウト)
281    $(document).on('click', 'a.category_open', function () {
282        dropdown('li.categories', '45px','a.category_open > i');
283    });
284
285    // 地域別一覧、ユーザーメニューの展開(出したままということだったのでコメントアウト)
286    $(document).on('click', 'a.area_open', function () {
287        dropdown('li.areas', '45px','a.area_open > i');
288    });
289
290    $(document).on('click', 'a.user_menu_open', function () {
291        dropdown('li.user_menu', '45px','a.user_menu_open > i');
292    });
293
294    if($('#longread_editors_pick').length > 0) {
295        if(window.innerWidth > 1000) {
296            get_editors_pick_info();
297            is_editors_pick_list_shown = true;
298        }
299    }
300
301    function dropdown(target,height,button){
302        if ($(target).css('display') === 'none') {
303            $(target).show();
304            if(button !== null){
305                $(button).addClass('open');
306            }
307            $(target).animate({"height": height}, 250, function () {
308                $('.drawer').drawer('refresh');
309            });
310        } else {
311            if(button !== null) {
312                $(button).removeClass('open');
313            }
314            $(target).animate({"height": "0"}, 250, function () {
315                $(target).hide();
316                $('.drawer').drawer('refresh');
317            });
318        }
319    }
320
321    // ドロワーのスクロール挙動を修正する。
322    function fixScroll(){
323        var disablescroll = function (e) {
324            e.preventDefault();
325        };
326
327        $('.drawer').on('drawer.opened', function(){
328            document.addEventListener('touchmove', disablescroll, {
329                passive: false
330            });
331        });
332
333        $('.drawer').on('drawer.closed', function(){
334            document.removeEventListener('touchmove', disablescroll, {
335                passive: false
336            });
337        });
338
339    }
340    // 表示領域(横)がPC用か否か確認する。
341    function is_innerwidth_for_pc() {
342        if(window.innerWidth >= 768) {
343            return true;
344        } else {
345            return false;
346        }
347    }
348    function get_editors_pick_info(is_editors_pick_list_shown) {
349        $.ajax({
350            url:'/get_editors_pick/',
351            type:'POST'
352        })
353        // Ajaxリクエストが成功した時発動
354        .done( function(data) {
355                if(data !== false) {
356                    var $prepend_flag = false;
357                    var $div = '<span class="sw-close"></span><div class="editors_picks_title"><b><span>EDITORS’ PICKS</span></b></div>';  
358                    var $ed_posts = '<div class="ed_posts"></div>'
359                    $.each(data, function(index, editorspick) {
360                        if(editorspick !=="") {
361                            $ed_posts = $($ed_posts).append(editorspick);
362                            $prepend_flag = true;
363                        }
364                    });
365                    if($prepend_flag) {
366                        $('#longread_editors_pick').append($ed_posts);
367                        $('#longread_editors_pick').prepend($div);
368                    }
369                }
370                // alert("通信に失敗しました。\nページを一度更新して再度お試しください。");
371        })
372        // Ajaxリクエストが失敗した時発動
373        .fail( function(data) {
374            // alert("通信に失敗しました。\nページを一度更新して再度お試しください。");
375        })
376        .always( function() {
377        });
378    }
379    function openInNewTab(url) {
380        var win = window.open(url, '_blank');
381        win.focus();
382    }
383    function createUrlBytrigger(who) {
384        var url = null;
385        var current_url = $(location).attr('hostname') + $(location).attr('pathname');
386        var current_href = $(location).attr('href');
387        var current_title = $('html head title').html();
388        switch(who) {
389            case 'facebook':
390            url = 'http://www.facebook.com/share.php?u=' + encodeURI(current_href);
391            break;
392            case 'twitter':
393            url = "https://twitter.com/intent/tweet?url=" + encodeURI(current_href) +"&" +"text=" + encodeURI(current_title);
394            break;
395            case 'line':
396            url = "http://line.me/R/msg/text/?" + current_href;
397            break;
398            case 'hatena':
399            url = "http://b.hatena.ne.jp/entry/s/" + current_url;
400            break;
401        }
402        return url;
403    }
404    $(document).on('click', '[data-trigger="facebook"],[data-trigger="twitter"],[data-trigger="line"],[data-trigger="hatena"]', function(event) {
405        var target_url = createUrlBytrigger($(event.currentTarget).data('trigger'));
406        if(target_url.length > 0) {
407            openInNewTab(target_url);
408        }
409    });
410
411     //虫眼鏡を押すと入力画面表示
412    $('.search_pc .pc_search_icon img').on('click', function(){
413        if ($(window).width() > 1265) {
414            $('.search_bar').addClass('fadein-up');
415            $('#search_overlay').show();
416            return false;
417        } else {
418            $('.drawer').drawer('open');
419        }
420    })
421    $('#search_overlay , .pc_search_icon_close').on('click', function(){
422        $('.search_bar').removeClass('fadein-up');
423        $('#search_overlay').hide();
424    })
425
426});
427
428
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.