PageSourceSearch

https://hairbilancia.com/blog/wp-content/themes/simplicity2/javascript.js

js hairbilancia.com collected 2026-10-05 04:59:32 UTC 17,927 bytes, 568 lines download raw bytes

1/////////////////////////////////
2//TOPへ戻るボタン
3/////////////////////////////////
4(function($){
5  var prevScrollTop = -1;
6  var $window = $(window);
7  $window.scroll(function(){
8    //最上部から現在位置までの距離を取得して、変数[scrollTop]に格納
9    var scrollTop = $window.scrollTop();
10    var threashold = 600;
11    var s1 = (prevScrollTop > threashold);
12    var s2 = (scrollTop > threashold);
13
14    // スレッショルドを跨いだ時のみ処理をする
15    if (s1 ^ s2) {
16      if (s2) {
17        //[#page-top]をゆっくりフェードインする
18        $('#page-top').fadeIn('slow');
19      } else {
20        //それ以外だったらフェードアウトする
21        $('#page-top').fadeOut('slow');
22      }
23    }
24
25    prevScrollTop = scrollTop;
26  });
27  //ボタン(id:move-page-top)のクリックイベント
28  $('#move-page-top').click(function(){
29  //ページトップへ移動する
30    $('body,html').animate({
31            scrollTop: 1
32        }, 800);
33  });
34})(jQuery);
35
36/////////////////////////////////
37//スクロール追従
38/////////////////////////////////
39var wrapperTop;//追従エリアのトップ位置を格納(追従開始位置
40var wrapperHeight;//追従エリアの高さを格納
41var sidebarHeight;//サイドバーの高さを格納
42
43//非同期ブログパーツがあっても追従開始位置がずれないように修正(無理やり)
44//スマートな良い方法があれば、ご教授お願いします。
45setInterval(function (){
46  wrapperHeight = jQuery('#sidebar-scroll').outerHeight();
47  sidebarHeight = jQuery('#sidebar').outerHeight();
48  wrapperTop = sidebarHeight - wrapperHeight + 240;
49}, 2000);
50
51(function($) {
52  $(document).ready(function() {
53    /*
54    Ads Sidewinder
55    by Hamachiya2. http://d.hatena.ne.jp/Hamachiya2/20120820/adsense_sidewinder
56    */
57    var main = $('#main'); // メインカラムのID
58    var side = $('#sidebar'); // サイドバーのID
59    var wrapper = $('#sidebar-scroll'); // スクロール追従要素のID
60    var side_top_margin = 60;
61    if (!wrapper.size()) {return;}//スクロール追従エリアにウイジェットが入っていないときはスルー
62    if (side.css('clear') == 'both') {return;}//レスポンシブでサイドバーをページ下に表示しているときはスルー
63
64    if (main.length === 0 || side.length === 0 || wrapper.length === 0) {
65      return;
66    }
67
68    var w = $(window);
69    wrapperHeight = wrapper.outerHeight();
70    wrapperTop = wrapper.offset().top;//とりあえずドキュメントを読み込んだ時点でスクロール追従領域の
70高さを取得
71    var sideLeft = side.offset().left;
72    //console.log(wrapperTop);
73
74    var sideMargin = {
75      top: side.css('margin-top') ? side.css('margin-top') : 0,
76      right: side.css('margin-right') ? side.css('margin-right') : 0,
77      bottom: side.css('margin-bottom') ? side.css('margin-bottom') : 0,
78      left: side.css('margin-left') ? side.css('margin-left') : 0
79    };
80
81    var winLeft;
82    var pos;
83
84    var scrollAdjust = function() {
85      var
86        sideHeight = side.outerHeight(),
87        mainHeight = main.outerHeight(),
88        mainAbs = main.offset().top + mainHeight,
89        winTop = w.scrollTop()+side_top_margin,
90        winLeft = w.scrollLeft(),
91        winHeight = w.height();
92      var nf = (winTop > wrapperTop) && (mainHeight > sideHeight) ? true : false;
93      pos = !nf ? 'static' : (winTop + wrapperHeight) > mainAbs ? 'absolute' : 'fixed';
94      if (pos === 'fixed') {
95        side.css({
96          position: pos,
97          top: '',
98          bottom: winHeight - wrapperHeight,
99          left: sideLeft - winLeft,
100          margin: 0,
101          marginBottom: '-'+side_top_margin+'px'
102        });
103
104      } else if (pos === 'absolute') {
105        side.css({
106          position: pos,
107          top: mainAbs - sideHeight,
108          bottom: '',
109          left: sideLeft,
110          margin: 0,
111          marginBottom: '-'+side_top_margin+'px'
112        });
113
114      } else {
115        side.css({
116          position: pos,
117          marginTop: sideMargin.top,
118          marginRight: sideMargin.right,
119          marginBottom: sideMargin.bottom,
120          marginLeft: sideMargin.left
121        });
122      }
123    };
124
125    var resizeAdjust = function() {
126      side.css({
127        position:'static',
128        marginTop: sideMargin.top,
129        marginRight: sideMargin.right,
130        marginBottom: sideMargin.bottom,
131        marginLeft: sideMargin.left
132      });
133      sideLeft = side.offset().left;
134      winLeft = w.scrollLeft();
135      if (pos === 'fixed') {
136        side.css({
137          position: pos,
138          left: sideLeft - winLeft,
139          margin: 0,
140          marginBottom: '-'+side_top_margin+'px'
141        });
142
143      } else if (pos === 'absolute') {
144        side.css({
145          position: pos,
146          left: sideLeft,
147          margin: 0,
148          marginBottom: '-'+side_top_margin+'px'
149        });
150      }
151    };
152    w.on('load', scrollAdjust);
153    w.on('scroll', scrollAdjust);
154    w.on('resize', resizeAdjust);
155  });
156})(jQuery);
157
158/////////////////////////////////
159// メニューボタンの開閉
160/////////////////////////////////
161(function($){
162  $(document).ready(function() {
163    $('#mobile-menu-toggle').click(function(){
164      var header_menu = $('#navi ul');
165      if (header_menu.css('display') == 'none') {
166        header_menu.slideDown();
167      } else{
168        header_menu.slideUp();
169      }
170    });
171  });
172})(jQuery);
173
174///////////////////////////////////
175// ソーシャルボタンカウントの非同期取得
176///////////////////////////////////
177(function($){
178  $(window).scroll(function(){
179    //console.log($('#sidebar').css('clear'));
180    //最上部から現在位置までの距離を取得して、変数[now]に格納
181    var now = $(window).scrollTop();
182    var sharebar = $('#sharebar');
183    if (!sharebar.size()) {return;}
184    var main = $('#main');
185    var sharebar_top = sharebar.offset().top;
186    var sharebar_h = sharebar.outerHeight();
187    var main_top = main.offset().top;
188    var main_h = main.outerHeight();
189
190    var bottom_line = main_h-400;
191    if(now < (main_h-sharebar_h)){
192      if (now > main_top) {
193        sharebar.css({
194          position: 'fixed',
195          top: '70px'
196        });
197      } else{
198        sharebar.css({
199          position: 'absolute',
200            top: main_top+70
201        });
202      }
203    }else{
204      sharebar.css({
205        position: 'absolute',
206        top: main_h-sharebar_h
207      });
208    }
209  });
210})(jQuery);
211
212// // Twitterのシェア数を取得
213// function fetch_twitter_count(url, selector) {
214//   jQuery.ajax({
215//     url:'//urls.api.twitter.com/1/urls/count.json',
216//     dataType:'jsonp',
217//     timeout: 10000, //10sec
218//     data:{
219//       url:url
220//     }
221//   }).done(function(res){
222//     jQuery( selector ).text( res.count || 0 );
223//   }).fail(function(){
224//     jQuery( selector ).html('<span class="fa fa-exclamation"></span>');
225//   });
226// }
227
228// //Twitterのシェア数を取得(自分のサーバーからPHPで取得)
229// function fetch_twitter_count(url, selector) {
230//   jQuery.ajax({
231//     url: social_count_config.theme_url+'/lib/fetch-twitter.php?url='+url,
232//     dataType:'text',
233//     timeout: 10000, //10sec
234//   }).done(function(res){
235//     jQuery( selector ).text( res || 0 );
236//   }).fail(function(){
237//     jQuery( selector ).html('<span class="fa fa-exclamation"></span>');
238//   });
239// }
240
241//count.jsoonからTwitterのツイート数を取得
242function fetch_twitter_count_from_count_jsoon(url, selector) {
243  jQuery.ajax({
244    url:'//jsoon.digitiminimi.com/twitter/count.json',
245    dataType:'jsonp',
246    timeout: 10000, //10sec
247    data:{
248      url:url
249  },
250  success:function(res){
251    jQuery( selector ).html( res.count || 0 );
252  },
253  error:function(){
254    jQuery( selector ).html('error');
255  }
256  });
257}
258
259
260//Facebookのシェア数を取得
261function fetch_facebook_count(url, selector) {
262  jQuery.ajax({
263    url:'https://graph.facebook.com/',
264    dataType:'jsonp',
265    timeout: 10000, //10sec
266    data:{ id:url }
267  }).done(function(res){
268    //console.log(res);
269    if ( res.share && res.share.share_count ) {
270      jQuery( selector ).text( res.share.share_count );
271    } else {
272      jQuery( selector ).text( 0 );
273    }
274  }).fail(function(){
275    jQuery( selector ).html('<span class="fa fa-exclamation"></span>');
276  });
277}
278
279//Google+のシェア数を取得
280function fetch_google_plus_count(url, selector) {
281  jQuery.ajax({
282    url: social_count_config.theme_url+'/lib/fetch-google-plus.php?url='+url,
283    dataType:'text',
284    timeout: 10000, //10sec
285  }).done(function(res){
286    jQuery( selector ).text( res || 0 );
287  }).fail(function(){
288    jQuery( selector ).html('<span class="fa fa-exclamation"></span>');
289  });
290}
291
292//はてなブックマークではてブ数を取得
293function fetch_hatebu_count(url, selector) {
294  jQuery.ajax({
295    url:'//b.hatena.ne.jp/entry.count?callback=?',
296    //url:'//api.b.st-hatena.com/entry.count?callback=?',
297    dataType:'jsonp',
298    timeout: 10000, //10sec
299    data:{
300      url:url
301    }
302  }).done(function(res){
303    jQuery( selector ).text( res || 0 );
304  }).fail(function(){
305    jQuery( selector ).html('<span class="fa fa-exclamation"></span>');
306  });
307}
308
309//ポケットのストック数を取得
310function fetch_pocket_count(url, selector) {
311  jQuery.ajax({
312    url: social_count_config.theme_url+'/lib/fetch-pocket.php?url='+url,
313    dataType:'text',
314    timeout: 10000, //10sec
315  }).done(function(res){
316    jQuery( selector ).text( res || 0 );
317  }).fail(function(){
318    jQuery( selector ).html('<span class="fa fa-exclamation"></span>');
319  });
320}
321
322//feedlyの購読者数を取得
323function fetch_feedly_count(rss_url, selector) {
324  jQuery.ajax({
325    url: social_count_config.theme_url+'/lib/fetch-feedly.php?url='+rss_url,
326    dataType:'text',
327    timeout: 10000, //10sec
328  }).done(function(res){
329    jQuery( selector ).text( res || 0 );
330  }).fail(function(){
331    jQuery( selector ).html('<span class="fa fa-exclamation"></span>');
332  });
333}
334
335//Push7で購読者数を取得
336function fetch_push7_count(app_no, selector) {
337  url = 'https://api.push7.jp/api/v1/'+app_no+'/head';
338  jQuery.ajax({
339    url:url,
340    dataType:'json',
341    timeout: 10000, //10sec
342    data:{
343      url:url
344    }
345  }).done(function(res){
346    jQuery( selector ).text( res.subscribers || 0 );
347  }).fail(function(){
348    jQuery( selector ).html('<span class="fa fa-exclamation"></span>');
349  });
350}
351
352jQuery(function(){
353  if (typeof social_count_config !== 'undefined') {
354    //console.log(social_count_config.all_sns_share_btns_visible);
355    //シェアボタンを全部表示しているとき
356    if ( social_count_config.all_sns_share_btns_visible &&
357         social_count_config.all_share_count_visible ) {
358
359      //Twitterカウントの取得
360      if ( social_count_config.twitter_btn_visible ){
361        fetch_twitter_count_from_count_jsoon(social_count_config.permalink, '.twitter-count');
362      }
363
364      //Facebookカウントの取得
365      if ( social_count_config.facebook_btn_visible ){
366        fetch_facebook_count(social_count_config.permalink, '.facebook-count');
367      }
368      //Google+カウントの取得
369      if ( social_count_config.google_plus_btn_visible ){
370        fetch_google_plus_count(social_count_config.permalink, '.googleplus-count');
371      }
372      //はてブカウントの取得
373      if ( social_count_config.hatena_btn_visible ){
374        fetch_hatebu_count(social_count_config.permalink, '.hatebu-count');
375      }
376      //Pocketカウントの取得
377      if ( social_count_config.pocket_btn_visible ){
378        fetch_pocket_count(social_count_config.permalink, '.pocket-count');
379      }
380      //feedlyカウントの取得
381      if ( social_count_config.feedly_btn_visible ){
382        fetch_feedly_count(social_count_config.rss2_url, '.feedly-count');
383      }
384      //push7カウントの取得
385      if ( social_count_config.push7_btn_visible ){
386        fetch_push7_count(social_count_config.push7_app_no, '.push7-count');
387      }
388
389    }
390
391  }
392
393  if (typeof lazyload_config !== 'undefined') {
394    jQuery('img').lazyload(lazyload_config);
395  }
396});
397
398function doMasonry() {
399  jQuery('#list').masonry({ //<!-- #listは記事一覧を囲んでる部分 -->
400    itemSelector: '.entry', //<!--.entryは各記事を囲んでる部分-->
401    isAnimated: false //<!--アニメーションON-->
402  });
403}
404
405jQuery(window).load(function(){
406  if (typeof do_masonry !== 'undefined') {
407    doMasonry()
408  }
409});
410jQuery(function(){
411  if (typeof do_masonry !== 'undefined') {
412    doMasonry()
413  }
414});
415
416///////////////////////////////////
417// レスポンス表示時のメニューの挙動
418// メニューのスタイル表示崩れの防止
419///////////////////////////////////
420(function($){
421  $(window).resize(function(){
422    if ( $(window).width() > 1110 ) {
423      $('#navi-in ul').removeAttr('style');
424    }
425  });
426})(jQuery);
427
428///////////////////////////////////
429// Facebookページいいねエリアのリサイズ(Androidブラウザ対応用)
430///////////////////////////////////
431function adjast_article_like_arrow_box() {
432  var w = jQuery('#main').width();
433  jQuery('#main .article-like-arrow-box').css('width', (w - 114) + 'px');
434  w = jQuery('#sidebar').width();
435  jQuery('#sidebar .article-like-arrow-box').css('width', (w - 114) + 'px');
436  //console.log(w);
437}
438jQuery(window).resize(function() {
439  adjast_article_like_arrow_box()
440});
441
442jQuery(document).ready(function() {
443  adjast_article_like_arrow_box()
444});
445
446// ///////////////////////////////////
447// // Twitterのツイート数取得関数を呼び出す
448// ///////////////////////////////////
449// jQuery(function(){
450//   if (typeof social_count_config !== 'undefined') {
451//     //シェアボタンを全部表示しているとき
452//     if ( social_count_config.all_sns_share_btns_visible &&
453//          social_count_config.all_share_count_visible &&
454//          social_count_config.twitter_count_visible ) {
455//       fetch_twitter_count_from_count_jsoon('http://nelog.jp/google-map-to-amp', '.twitter-count');
456//     }
457//   }
458// });
459
460/////////////////////////////////
461// 折り畳み式アーカイブウィジェット
462/////////////////////////////////
463(function($) {
464  $(function() {
465    var wgts = $(".widget_archive");//アーカイブウィジェット全てを取得
466    //アーカイブウィジェットを1つずつ処理する
467    wgts.each(function(i, el) {
468      var wgt = $(el);
469
470      //日付表示+投稿数か
471      var has_date_count = wgt.text().match(/\d+年\d+月\s\(\d+\)/);
472      //日付表示だけか
473      var has_date_only = wgt.text().match(/\d+年\d+月/) && !has_date_count;
474
475      //日付表示されているとき(ドロップダウン表示でない時)
476      if ( has_date_count || has_date_only ) {
477        var
478          clone = wgt.clone(),//アーカイブウィジェットの複製を作成
479          year = [];
480        //クローンはウィジェットが後にに挿入。クローンはcssで非表示
481        wgt.after(clone);
482        clone.attr("class", "archive_clone").addClass('hide');
483
484        var
485          acv = wgt, //ウィジェット
486          acvLi = acv.find("li"); //ウィジェット内のli全て
487        //ul.yearsをアーカイブウィジェット直下に追加してそのDOMを取得
488        var acv_years =  acv.append('<ul class="years"></ul>').find("ul.years");
489
490        //liのテキストから年がどこからあるかを調べる
491        acvLi.each(function(i) {
492          var reg = /(\d+)年(\d+)月/;
493          //日付表示+投稿数か
494          if ( has_date_count ) {
495            reg = /(\d+)年(\d+)月\s\((\d+)\)/;
496          }
497          var dt = $(this).text().match(reg);
498          year.push(dt[1]);
499
500        });
501        $.unique(year); //重複削除
502
503        acvLi.unwrap(); //liの親のulを解除
504
505        //投稿年があるだけ中にブロックを作る
506        var
507          yearCount = year.length,
508          ii = 0;
509        while (ii < yearCount) {
510          acv_years.append("<li class='year_" + year[ii] + "'><a class='year'>" + year[ii] + "å¹´</a><ul class='month'></ul></li>");
511          ii++;
512        }
513
514        //作ったブロック内のulに内容を整形して移動
515        //オリジナルのクローンは順番に削除
516        var j = 0;
517        acvLi.each(function(i, el) {
518          var reg = /(\d+)年(\d+)月/;
519          //日付表示+投稿数か
520          if ( has_date_count ) {
521            reg = /(\d+)年(\d+)月\s\((\d+)\)/;
522          }
523          var
524            dt = $(this).text().match(reg),
525            href = $(this).find("a").attr("href");
526
527          //月の追加
528          var rTxt = "<li><a href='" + href + "'>" + "" + dt[2] + "月</a>";
529          //日付表示+投稿数か
530          if ( has_date_count ) {
531            rTxt += " (" + dt[3] + ")" + "</li>"; //投稿数の追加
532          }
533
534          //作成した月のHTMLを追加、不要なものは削除
535          if (year[j] === dt[1]) {
536            acv_years.find(".year_" + year[j] + " ul").append(rTxt);
537            $(this).remove();
538          } else {
539            j++;
540            acv_years.find(".year_" + year[j] + " ul").append(rTxt);
541            $(this).remove();
542          }
543        });
544
545        //クローン要素を削除
546        clone.remove();
547
548        //直近の年の最初以外は.hide
549        acv.find("ul.years ul:not(:first)").addClass("hide");
550
551        //年をクリックでトグルshow
552        acv.find("a.year").on("click", function() {
553          $(this).next().toggleClass("hide");
554        });
555      }//if has_date_count || has_date_only
556    });//wgts.each
557
558  });
559
560})(jQuery);
561
562/////////////////////////////////
563//テーブルにレスポンシブ用のラップを追加する
564/////////////////////////////////
565// (function($){
566//   $('table:not(.table-wrap table)').wrap('<div class="table-wrap"></div>');
567// })(jQuery);
568

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.