PageSourceSearch

http://up-too-you.com/wp-content/themes/simplicity/javascript.js

js up-too-you.com collected 2026-10-07 06:21:32 UTC 12,818 bytes, 386 lines download raw bytes

1/////////////////////////////////
2//TOPへ戻るボタン
3/////////////////////////////////
4jQuery(function(){
5  jQuery(window).scroll(function(){
6    //最上部から現在位置までの距離を取得して、変数[now]に格納
7    var now = jQuery(window).scrollTop();
8    //最上部から現在位置までの距離(now)が600以上
9    if(now > 600){
10      //[#page-top]をゆっくりフェードインする
11      jQuery('#page-top').fadeIn('slow');
12      //それ以外だったらフェードアウトする
13    }else{
14      jQuery('#page-top').fadeOut('slow');
15    }
16    //console.log(wrapperTop);
17  });
18  //ボタン(id:move-page-top)のクリックイベント
19  jQuery('#move-page-top').click(function(){
20  //ページトップへ移動する
21    jQuery('body,html').animate({
22            scrollTop: 0
23        }, 800);
24  });
25});
26
27/////////////////////////////////
28//スクロール追従
29/////////////////////////////////
30var wrapperTop;//追従エリアのトップ位置を格納(追従開始位置
31var wrapperHeight;//追従エリアの高さを格納
32var sidebarHeight;//サイドバーの高さを格納
33// var wrapperHeightAtFirst;
34// var wrapperHeightDiff;
35// var sidebarHeightAtFirst;
36// var sidebarHeightDiff;
37//非同期ブログパーツがあっても追従開始位置がずれないように修正(無理やり)
38//スマートな良い方法があれば、ご教授お願いします。
39function getScrollAreaSettings(){
40  wrapperHeight = jQuery('#sidebar-scroll').outerHeight();
41  sidebarHeight = jQuery('#sidebar').outerHeight();
42  // wrapperHeightDiff = wrapperHeightAtFirst - wrapperHeight;
43  // sidebarHeightDiff = sidebarHeightAtFirst - sidebarHeight;
44  wrapperTop = sidebarHeight - wrapperHeight + 240;
45  // console.log(wrapperTop + ', ' + wrapperHeight + ', ' + sidebarHeight + ', ' + sidebarHeightAtFirst + ', ' + sidebarHeightDiff);
46}
47setInterval('getScrollAreaSettings()',2000);
48
49(function(jquery) {
50  jquery(document).ready(function() {
51    /*
52    Ads Sidewinder
53    by Hamachiya2. http://d.hatena.ne.jp/Hamachiya2/20120820/adsense_sidewinder
54    */
55    var main = jQuery('#main'); // メインカラムのID
56    var side = jQuery('#sidebar'); // サイドバーのID
57    var wrapper = jQuery('#sidebar-scroll'); // スクロール追従要素のID
58    var side_top_margin = 60;
59    if (!wrapper.size()) {return;}//スクロール追従エリアにウイジェットが入っていないときはスルー
60    if (side.css('clear') == 'both') {return;}//レスポンシブでサイドバーをページ下に表示しているときはスルー
61
62    if (main.length === 0 || side.length === 0 || wrapper.length === 0) {
63      return;
64    }
65
66    var w = jquery(window);
67    wrapperHeight = wrapper.outerHeight();
68    // wrapperHeightAtFirst =  wrapperHeight;
69    // sidebarHeightAtFirst =  side.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      sideHeight = side.outerHeight();
86      mainHeight = main.outerHeight();
87      mainAbs = main.offset().top + mainHeight;
88      var winTop = w.scrollTop()+side_top_margin;
89      winLeft = w.scrollLeft();
90      var winHeight = w.height();
91      var nf = (winTop > wrapperTop) && (mainHeight > sideHeight) ? true : false;
92      pos = !nf ? 'static' : (winTop + wrapperHeight) > mainAbs ? 'absolute' : 'fixed';
93      if (pos === 'fixed') {
94        side.css({
95          position: pos,
96          top: '',
97          bottom: winHeight - wrapperHeight,
98          left: sideLeft - winLeft,
99          margin: 0,
100          marginBottom: '-'+side_top_margin+'px'
101        });
102
103      } else if (pos === 'absolute') {
104        side.css({
105          position: pos,
106          top: mainAbs - sideHeight,
107          bottom: '',
108          left: sideLeft,
109          margin: 0,
110          marginBottom: '-'+side_top_margin+'px'
111        });
112
113      } else {
114        side.css({
115          position: pos,
116          marginTop: sideMargin.top,
117          marginRight: sideMargin.right,
118          marginBottom: sideMargin.bottom,
119          marginLeft: sideMargin.left
120        });
121      }
122    };
123
124    var resizeAdjust = function() {
125      side.css({
126        position:'static',
127        marginTop: sideMargin.top,
128        marginRight: sideMargin.right,
129        marginBottom: sideMargin.bottom,
130        marginLeft: sideMargin.left
131      });
132      sideLeft = side.offset().left;
133      winLeft = w.scrollLeft();
134      if (pos === 'fixed') {
135        side.css({
136          position: pos,
137          left: sideLeft - winLeft,
138          margin: 0,
139          marginBottom: '-'+side_top_margin+'px'
140        });
141
142      } else if (pos === 'absolute') {
143        side.css({
144          position: pos,
145          left: sideLeft,
146          margin: 0,
147          marginBottom: '-'+side_top_margin+'px'
148        });
149      }
150    };
151    w.on('load', scrollAdjust);
152    w.on('scroll', scrollAdjust);
153    w.on('resize', resizeAdjust);
154  });
155})(jQuery);
156
157/////////////////////////////////
158// メニューボタンの開閉
159/////////////////////////////////
160jQuery(document).ready(function() {
161  jQuery('#mobile-menu-toggle').click(function(){
162    header_menu = jQuery('#navi ul');
163    if (header_menu.css('display') == 'none') {
164      header_menu.slideDown();
165    } else{
166      header_menu.slideUp();
167    };
168  });
169
170});
171
172///////////////////////////////////
173// ソーシャルボタンカウントの非同期取得
174///////////////////////////////////
175jQuery(function(){
176  jQuery(window).scroll(function(){
177    //console.log(jQuery('#sidebar').css('clear'));
178    //最上部から現在位置までの距離を取得して、変数[now]に格納
179    var now = jQuery(window).scrollTop();
180    var sharebar = jQuery('#sharebar');
181    if (!sharebar.size()) {return;}
182    var main = jQuery('#main');
183    var sharebar_top = sharebar.offset().top;
184    var sharebar_h = sharebar.outerHeight();
185    var main_top = main.offset().top;
186    var main_h = main.outerHeight();
187
188    var bottom_line = main_h-400;
189    if(now < (main_h-sharebar_h)){
190      if (now > main_top) {
191        //sharebar.fadeIn('fast');
192        sharebar.css({
193          position: 'fixed',
194          top: '70px'
195        });
196      } else{
197        sharebar.css({
198          position: 'absolute',
199            top: main_top+70
200        });
201      };
202    }else{
203      //sharebar.fadeOut('fast');
204      sharebar.css({
205        position: 'absolute',
206        top: main_h-sharebar_h
207      });
208    }
209    //console.log(sharebar_h);
210
211  });
212});
213
214// Twitterのシェア数を取得
215function get_social_count_twitter(url, selcter) {
216  jQuery.ajax({
217  url:'//urls.api.twitter.com/1/urls/count.json',
218  dataType:'jsonp',
219  data:{
220    url:url
221  },
222  success:function(res){
223    jQuery( selcter ).text( res.count || 0 );
224  },
225  error:function(){
226    jQuery( selcter ).text('0');
227  }
228  });
229}
230
231//Facebookのシェア数を取得
232function get_social_count_facebook(url, selcter) {
233  jQuery.ajax({
234    url:'https://graph.facebook.com/',
235    dataType:'jsonp',
236    data:{
237      id:url
238    },
239    success:function(res){
240      jQuery( selcter ).text( res.shares || 0 );
241    },
242    error:function(){
243      jQuery( selcter ).text('0');
244    }
245  });
246}
247
248//Google+のシェア数を取得
249function get_social_count_googleplus(url, selcter) {
250  jQuery.ajax({
251    type: "get", dataType: "xml",
252    url: "//query.yahooapis.com/v1/public/yql",
253    data: {
254      q: "SELECT content FROM data.headers WHERE url='https://plusone.google.com/_/+1/fastbutton?hl=ja&url=" + url + "' and ua='#Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36'",
255      format: "xml",
256      env: "http://datatables.org/alltables.env"
257    },
258    success: function (data) {
259      var content = jQuery(data).find("content").text();
260      var match = content.match(/window\.__SSR[\s*]=[\s*]{c:[\s*](\d+)/i);
261      var count = (match != null) ? match[1] : 0;
262
263      jQuery( selcter ).text(count);
264    }
265  });
266}
267
268//はてなブックマークではてブ勝を取得
269function get_social_count_hatebu(url, selcter) {
270  jQuery.ajax({
271    url:'//api.b.st-hatena.com/entry.count?callback=?',
272    dataType:'jsonp',
273    data:{
274      url:url
275    },
276    success:function(res){
277      jQuery( selcter ).text( res || 0 );
278    },
279    error:function(){
280      jQuery( selcter ).text('0');
281    }
282  });
283}
284
285//ポケットのストック数を取得
286function get_social_count_pocket(url, selcter) {
287  jQuery.ajax({
288    type: "get", dataType: "xml",
289    url: "//query.yahooapis.com/v1/public/yql",
290    data: {
291      q: "SELECT content FROM data.headers WHERE url='https://widgets.getpocket.com/v1/button?label=pocket&count=vertical&v=1&url=" + url + "' and ua='#Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36'",
292      format: "xml",
293      env: "http://datatables.org/alltables.env"
294    },
295    success: function (data) {
296      var content = jQuery(data).find("content").text();
297      var match = content.match(/<em id="cnt">(\d+)<\/em>/i);
298      var count = (match != null) ? match[1] : 0;
299
300      jQuery( selcter ).text(count);
301    }
302  });
303}
304
305//feedlyの購読者数を取得
306function get_social_count_feedly(rss_url, selcter) {
307  //console.log('http://cloud.feedly.com/v3/feeds/feed%2F' + encodeURIComponent(rss_url));
308  jQuery.ajax({
309    type: "get", dataType: "json",
310    url: "//query.yahooapis.com/v1/public/yql",
311    data: {
312      q: "SELECT content FROM data.headers WHERE url='//cloud.feedly.com/v3/feeds/feed%2F" + encodeURIComponent(rss_url) + "' and ua='#Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36'",
313      format: "json",
314      env: "http://datatables.org/alltables.env"
315    },
316    success: function (data) {
317      //console.log(data);
318      count = data.query.results.resources.content.json['subscribers']
319
320      jQuery( selcter ).text(count);
321    }
322  });
323}
324
325function doMasonry() {
326  jQuery('#list').masonry({ //<!-- #listは記事一覧を囲んでる部分 -->
327    itemSelector: '.entry', //<!--.entryは各記事を囲んでる部分-->
328    isAnimated: true //<!--アニメーションON-->
329  });
330}
331
332jQuery(function(){
333  if (typeof social_count_config !== 'undefined') {
334    get_social_count_twitter(social_count_config.permalink, '.twitter-count');
335    get_social_count_facebook(social_count_config.permalink, '.facebook-count');
336    get_social_count_googleplus(social_count_config.permalink, '.googleplus-count');
337    get_social_count_hatebu(social_count_config.permalink, '.hatebu-count');
338    get_social_count_pocket(social_count_config.permalink, '.pocket-count');
339    //get_social_count_feedly(social_count_config.rss2_url, '.feedly-count');
340  }
341
342  if (typeof lazyload_config !== 'undefined') {
343    jQuery('img').lazyload(lazyload_config);
344  }
345});
346
347jQuery(window).load(function(){
348  if (typeof do_masonry !== 'undefined') {
349    doMasonry()
350  }
351});
352jQuery(function(){
353  if (typeof do_masonry !== 'undefined') {
354    doMasonry()
355  }
356});
357
358///////////////////////////////////
359// レスポンス表示時のメニューの挙動
360// メニューのスタイル表示崩れの防止
361///////////////////////////////////
362jQuery(function(){
363  jQuery(window).resize(function(){
364    if ( jQuery(window).width() > 1110 ) {
365      jQuery('#navi-in ul').removeAttr('style');
366    };
367  });
368});
369
370///////////////////////////////////
371// Facebookページいいねエリアのリサイズ(Androidブラウザ対応用)
372///////////////////////////////////
373function adjast_article_like_arrow_box() {
374  var w = jQuery('#main').width();
375  jQuery('#main .article-like-arrow-box').css('width', (w - 114) + 'px');
376  var w = jQuery('#sidebar').width();
377  jQuery('#sidebar .article-like-arrow-box').css('width', (w - 114) + 'px');
378  //console.log(w);
379}
380jQuery(window).resize(function() {
381  adjast_article_like_arrow_box()
382});
383
384jQuery(document).ready(function() {
385  adjast_article_like_arrow_box()
386});

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.