!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(function(){return"undefined"!=typeof jquery?jquery:"undefined"!=typeof zepto?zepto:$}())}(function(a){function b(a,b){window.console&&"undefined"!=typeof a&&a&&"undefined"!=typeof b&&b&&(a=a.tolowercase(),"error"==a?console.error(b):"log"==a?console.log(b):console.error('"'+a+'" is not supported as console type.'))}function c(b){return b=a.trim(b.tostring()),"auto"===b.tolowercase()?b:parsefloat(b)}function d(a,b){var c=a.tostring().match(/(-*)+\d+/)[0];return"px"==e(a)?0>a?0:a>b?b:a:"%"==e(a)?0>c?"0%":c>100?"100%":a:void 0}function e(b){var c=b.tostring().match(/\d+(.*)/i);if(c)switch(a.trim(c[1])){case"":return"px";case"px":return"px";case"%":return"%"}return""}function f(b,c){a.fn[i].defaults=a.extend({},y,a.fn[i].defaults),this.element=b,this.settings=a.extend({},a.fn[i].defaults,c),this.settings.ondemandevent=this.settings.ondemandevent.tolowercase(),this.settings.threshold=this.settings.threshold.tostring().replace(/px/gi,""),this.settings.width=this.settings.width.tostring().replace(/px/gi,""),this.settings.height=this.settings.height.tostring().replace(/px/gi,""),this.settings.width||(c.width=y.width,this.settings.width=y.width),this.settings.height||(c.height=y.height,this.settings.height=y.height),this.settings.position.y=d(this.settings.position.y,this.settings.width),this.settings.position.x=d(this.settings.position.x,this.settings.height),this.settings.zoom=this.settings.zoom<0?0:this.settings.zoom,"string"==typeof c?"kill"==c.tolowercase()&&this.kill(this.element):(a(this.element).data(r,this.settings),this.init(this.element,this.settings))}var g=function(){var a=document.createelement("div"),b="khtml ms o moz webkit".split(" ");b.length;return function(c){if(c in a.style)return!0;c=c.replace(/^[a-z]/,function(a){return a.touppercase()});for(var d in b)if(b[d]+c in a.style)return!0;return!1}}();a.fn.outerheight&&a.fn.outerwidth||("function"!=typeof array.prototype.foreach&&(array.prototype.foreach=function(a){for(var b=0;bf.right+d||g.bottomf.bottom+d)},i="jqthumb",j=a(window),k=function(){for(var a=["scroll","resize","scrolltop"],b={},c=0;c").css({width:c(h)+e(h),height:c(j)+e(j),display:"none",position:"relative",overflow:"hidden"}).addclass(f.classname).data(i,i),g=a("
").css({width:"100%",height:"100%","background-image":'url("'+q+'")',"background-repeat":"no-repeat","background-position":c(l)+e(l)+" "+c(m)+e(m),"background-size":"cover"}).appendto(d),"after"===f.renderposition.tolowercase()?d.insertafter(b.oriimg):d.insertbefore(b.oriimg),d.show(),g.css({width:parsefloat(100*k)+"%",height:parsefloat(100*k)+"%",position:"absolute"}).css({top:function(){var a=d.height(),b=g.height();return"%"==e(m)?"-"+parsefloat((b-a)/a*100/(100/c(m)))+"%":void 0}(),left:function(){var a=d.width(),b=g.width();return"%"==e(l)?"-"+parsefloat((b-a)/a*100/(100/c(l)))+"%":void 0}()}),d.hide(),"function"==typeof b.done&&b.done(d)}function l(b){function d(){var b=0;if(l>m?(h.css({width:"auto","max-height":99999999,"min-height":0,"max-width":99999999,"min-width":0,height:g.height()+"px"}),b=h.height()/h.width(),h.width()p){var d=a("
");d.css({width:parsefloat(c(n.tostring())*p)+e(n.tostring()),height:parsefloat(c(o.tostring())*p)+e(o.tostring()),position:"relative",overflow:"hidden"}).appendto(h.parent()),h.appendto(d)}h.css({position:"absolute",left:function(){var a=0;return"%"==e(q)?(a=parsefloat((h.width()-h.parent().width())/100*c(q)),0>=a?a+"px":"-"+a+"px"):"px"==e(q)||isnan(q)===!1?c(q)+"px":void 0}(),top:function(){var a=0;return"%"==e(r)?(a=parsefloat((h.height()-h.parent().height())/100*c(r)),0>=a?a+"px":"-"+a+"px"):"px"==e(r)||isnan(r)===!1?c(r)+"px":void 0}()})}var g,h,l=b.tmpimgdom.width,m=b.tmpimgdom.height,n="auto"===a.trim(f.width.tostring().tolowercase())?l.tostring():f.width,o="auto"===a.trim(f.height.tostring().tolowercase())?m.tostring():f.height,p=f.zoom,q=f.position.x,r=f.position.y,s=e(n),t=e(o),u=f.responsive;h=a(b.tmpimgdom),g=a("
"),"after"===f.renderposition.tolowercase()?g.insertafter(b.oriimg):g.insertbefore(b.oriimg),g.append(h).css({position:"relative",overflow:"hidden",width:c(n)+(s?s:"px"),height:c(o)+(t?t:"px")}).data(i,i),d(),!isnan(u)&&u>0&&(a(b.oriimage).data(v,function(){settimeout(function(){d()},u)}),j.bind(k.resize,a(b.oriimage).data(v))),g.hide().addclass(f.classname),"function"==typeof b.done&&b.done(g)}f.before.apply(d,[d]);var m=this,n=a(d),q=n.attr(f.source),r=function(a){return"auto"==a?g("backgroundsize")===!1?l:h:"modern"==a?h:"native"==a?l:void b("error",'invalid method. only "auto", "modern" and "native" are allowed.')}(f.method.tostring().tolowercase());r?(n.data(p,n.attr("style")),n.data(o,f.renderposition),n.hide(),f.ondemand===!0?m.demand(d,f,q,r):(n.data(w,new image),m.lazyload(m,d,f,function(a){m.processimg(d,f,a,r),n.removedata(w)}))):(n.data(s,"error"),m.kill(n))},demand:function(b,d,f,g){var i=this,o=a(b);if("scroll"===d.ondemandevent){o.wrap("
");var p=o.parent();p.css({width:d.width?c(d.width)+e(d.width):o.width()+"px",height:d.height?c(d.height)+e(d.height):o.height()+"px"}),o.data(u,function(){h(p,d.threshold)&&(j.unbind(l,o.data(u)),o.removedata(u),o.unwrap(),o.data(w,new image),i.lazyload(i,b,d,function(a){i.processimg(b,d,a,g),o.removedata(w)}))}),j.bind(l,o.data(u)).triggerhandler(k.scroll)}else if("click"===d.ondemandevent||"mouseenter"===d.ondemandevent){var r=o.parent(),s="click"===d.ondemandevent?m:n;o.data(t,function(){r.unbind(s,o.data(t)),o.removedata(t),o.data(w,new image),i.lazyload(i,b,d,function(a){i.processimg(b,d,a,g),o.removedata(w)}),o.data(q,!0)}),r.bind(s,o.data(t))}},updateglobal:function(b,c,d){b.global.outputelems.push(a(c)[0]),b.global.elemcounter++,x.outputelems.push(a(c)[0]),b.global.elemcounter==b.global.inputelems.length&&d.done.apply(b,[b.global.outputelems])}},a.fn[i]=function(c){var d={},e={elemcounter:0,outputelems:[],inputelems:function(b){for(var c=a(b),d=c.length,e=[],f=0;d>f;f++)e.push(c.get(f));return e}(a(this))};return d[i]=function(c){return"undefined"==typeof c?void b("error","please specify an action like $."+i+'("killall")'):(c=c.tolowercase(),void("killall"==c&&a.each(x.inputelems,function(){new f(this,"kill")})))},a.extend(a,d),this.each(function(){var b=a(this);this.global=e,x.inputelems.push(b),"string"==typeof c?new f(this,c):(b.data(w)&&b.data(w).complete===!1&&(b.data(w).src="",new f(this,"kill")),b.data(i)?b.data(r)&&b.data(r).reinit===!0&&(new f(this,"kill"),b.data(i,new f(this,c))):b.data(i,new f(this,c)))})},a.fn[i].defaults=y});