mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
30 lines
6.0 KiB
JavaScript
30 lines
6.0 KiB
JavaScript
/*! Widget: lazyload (BETA) - 4/1/2016 (v2.25.7) */
|
|
!function(t,e){"use strict";var o=t.tablesorter;o.lazyload={init:function(l,a){"scrollstop"!==a.lazyload_event||o.addScrollStopDone||(o.addScrollStop(),o.addScrollStopDone=!0,t.event.special.scrollstop.latency=a.lazyload_latency||250),o.lazyload.update(l,a);var i=l.namespace+"lazyload ",n=[a.lazyload_update,"pagerUpdate",a.columnSelector_updated||"columnUpdate",""].join(i);l.$table.on(n,function(){o.lazyload.update(l,l.widgetOptions)}).on("filterEnd"+i,function(){t(e).scroll()})},update:function(o,l){var a=(/(\.|#)/.test(l.lazyload_imageClass)?"":".")+l.lazyload_imageClass;o.$table.find(a).lazyload({threshold:l.lazyload_threshold,failure_limit:l.lazyload_failure_limit,event:l.lazyload_event,effect:l.lazyload_effect,container:l.lazyload_container,data_attribute:l.lazyload_data_attribute,skip_invisible:l.lazyload_skip_invisible,appear:l.lazyload_appear,load:l.lazyload_load,placeholder:l.lazyload_placeholder}),setTimeout(function(){t(e).scroll()},1)},remove:function(t,e){t.$table.off(t.namespace+"lazyload")}},o.addWidget({id:"lazyload",options:{lazyload_imageClass:"lazy",lazyload_update:"lazyloadUpdate",lazyload_latency:250,lazyload_threshold:0,lazyload_failure_limit:0,lazyload_event:"scrollstop",lazyload_effect:"show",lazyload_container:e,lazyload_data_attribute:"original",lazyload_skip_invisible:!0,lazyload_appear:null,lazyload_load:null,lazyload_placeholder:"data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="},init:function(t,e,l,a){o.lazyload.init(l,a)},remove:function(t,e,l){o.lazyload.remove(e,l)}}),o.addScrollStop=function(){var e=t.event.dispatch||t.event.handle,o=t.event.special,l="D"+ +new Date,a="D"+(+new Date+1);o.scrollstart={setup:function(a){var i,n=t.extend({latency:o.scrollstop.latency},a),r=function(t){var o=this,l=arguments;i?clearTimeout(i):(t.type="scrollstart",e.apply(o,l)),i=setTimeout(function(){i=null},n.latency)};t(this).bind("scroll",r).data(l,r)},teardown:function(){t(this).unbind("scroll",t(this).data(l))}},o.scrollstop={latency:250,setup:function(l){var i,n=t.extend({latency:o.scrollstop.latency},l),r=function(t){var o=this,l=arguments;i&&clearTimeout(i),i=setTimeout(function(){i=null,t.type="scrollstop",e.apply(o,l)},n.latency)};t(this).bind("scroll",r).data(a,r)},teardown:function(){t(this).unbind("scroll",t(this).data(a))}}}}(jQuery,window),/*!
|
|
* Lazy Load - jQuery plugin for lazy loading images
|
|
*
|
|
* Copyright (c) 2007-2015 Mika Tuupola
|
|
*
|
|
* Licensed under the MIT license:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
*
|
|
* Project home:
|
|
* http://www.appelsiini.net/projects/lazyload
|
|
*
|
|
* Version: 1.9.7
|
|
*
|
|
*/
|
|
function(t,e,o,l){var a=t(e);t.fn.lazyload=function(l){function i(){var e=0;r.each(function(){var o=t(this);if(!d.skip_invisible||o.is(":visible"))if(t.abovethetop(this,d)||t.leftofbegin(this,d));else if(t.belowthefold(this,d)||t.rightoffold(this,d)){if(++e>d.failure_limit)return!1}else o.trigger("appear"),e=0})}var n,r=this,d={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:e,data_attribute:"original",skip_invisible:!1,appear:null,load:null,placeholder:"data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="};/*!
|
|
* Lazy Load - jQuery plugin for lazy loading images
|
|
*
|
|
* Copyright (c) 2007-2015 Mika Tuupola
|
|
*
|
|
* Licensed under the MIT license:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
*
|
|
* Project home:
|
|
* http://www.appelsiini.net/projects/lazyload
|
|
*
|
|
* Version: 1.9.7
|
|
*
|
|
*/
|
|
return l&&(void 0!==l.failurelimit&&(l.failure_limit=l.failurelimit,delete l.failurelimit),void 0!==l.effectspeed&&(l.effect_speed=l.effectspeed,delete l.effectspeed),t.extend(d,l)),n=void 0===d.container||d.container===e?a:t(d.container),0===d.event.indexOf("scroll")&&n.bind(d.event,function(){return i()}),this.each(function(){var e=this,o=t(e);e.loaded=!1,void 0!==o.attr("src")&&!1!==o.attr("src")||o.is("img")&&o.attr("src",d.placeholder),o.one("appear",function(){if(!this.loaded){if(d.appear){var l=r.length;d.appear.call(e,l,d)}t("<img />").bind("load",function(){var l=o.attr("data-"+d.data_attribute);o.hide(),o.is("img")?o.attr("src",l):o.css("background-image","url('"+l+"')"),o[d.effect](d.effect_speed),e.loaded=!0;var a=t.grep(r,function(t){return!t.loaded});if(r=t(a),d.load){var i=r.length;d.load.call(e,i,d)}}).attr("src",o.attr("data-"+d.data_attribute))}}),0!==d.event.indexOf("scroll")&&o.bind(d.event,function(){e.loaded||o.trigger("appear")})}),a.bind("resize",function(){i()}),/(?:iphone|ipod|ipad).*os 5/gi.test(navigator.appVersion)&&a.bind("pageshow",function(e){e.originalEvent&&e.originalEvent.persisted&&r.each(function(){t(this).trigger("appear")})}),t(o).ready(function(){i()}),this},t.belowthefold=function(o,l){return(void 0===l.container||l.container===e?(e.innerHeight?e.innerHeight:a.height())+a.scrollTop():t(l.container).offset().top+t(l.container).height())<=t(o).offset().top-l.threshold},t.rightoffold=function(o,l){return(void 0===l.container||l.container===e?a.width()+a.scrollLeft():t(l.container).offset().left+t(l.container).width())<=t(o).offset().left-l.threshold},t.abovethetop=function(o,l){return(void 0===l.container||l.container===e?a.scrollTop():t(l.container).offset().top)>=t(o).offset().top+l.threshold+t(o).height()},t.leftofbegin=function(o,l){return(void 0===l.container||l.container===e?a.scrollLeft():t(l.container).offset().left)>=t(o).offset().left+l.threshold+t(o).width()},t.inviewport=function(e,o){return!(t.rightoffold(e,o)||t.leftofbegin(e,o)||t.belowthefold(e,o)||t.abovethetop(e,o))},t.extend(t.expr[":"],{"below-the-fold":function(e){return t.belowthefold(e,{threshold:0})},"above-the-top":function(e){return!t.belowthefold(e,{threshold:0})},"right-of-screen":function(e){return t.rightoffold(e,{threshold:0})},"left-of-screen":function(e){return!t.rightoffold(e,{threshold:0})},"in-viewport":function(e){return t.inviewport(e,{threshold:0})},"above-the-fold":function(e){return!t.belowthefold(e,{threshold:0})},"right-of-fold":function(e){return t.rightoffold(e,{threshold:0})},"left-of-fold":function(e){return!t.rightoffold(e,{threshold:0})}})}(jQuery,window,document); |