1 |
19040
|
thanos.pap
|
/* Copyright (C) YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */
|
2 |
|
|
|
3 |
|
|
(function(b,a){var e=function(a,b,e){var d;return function(){var g=this,h=arguments;d?clearTimeout(d):e&&a.apply(g,h);d=setTimeout(function(){e||a.apply(g,h);d=null},b||150)}};jQuery.fn[a]=function(b){return b?this.bind("resize",e(b)):this.trigger(a)}})(jQuery,"smartresize");
|
4 |
|
|
(function(b){b.Gal=function(a,e){this.element=b(e);this._init(a)};b.Gal.settings={selector:".item",width:225,gutter:20,animate:!1,animationOptions:{speed:200,duration:300,effect:"fadeInOnAppear",queue:!0,complete:function(){}}};b.Gal.prototype={_init:function(a){var e=this;this.name=this._setName(5);this.gridArr=[];this.gridArrAppend=[];this.gridArrPrepend=[];this.setGrid=this.setArr=!1;this.setOptions;this.prependCount=this.itemCount=this.cols=0;this.isPrepending=!1;this.appendCount=0;this.ifCallback=
|
5 |
|
|
this.resetCount=!0;this.box=this.element;this.options=b.extend(!0,{},b.Gal.settings,a);this.gridArr=b.makeArray(this.box.find(this.options.selector));this.isResizing=!1;this.w=0;this.boxArr=[];this._setCols();this._renderGrid("append");b(this.box).addClass("gridalicious");var c=0;b(window).smartresize(function(){var a=b(window).width();b(window).width()!=c&&(e.resize(),c=a)})},_setName:function(a,b){b=b?b:"";return a?this._setName(--a,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".charAt(Math.floor(60*
|
6 |
|
|
Math.random()))+b):b},_setCols:function(){this.cols=Math.floor(this.box.width()/this.options.width);diff=(this.box.width()-this.cols*this.options.width-this.options.gutter)/this.cols;this.w=w=100*((this.options.width+diff)/this.box.width());this.cols||(this.cols=1);for(var a=0;a<this.cols;a++){var e=b("<div></div>").addClass("galcolumn").attr("id","item"+a+this.name).css({width:w+"%",paddingLeft:this.options.gutter,paddingBottom:this.options.gutter,"float":"left","-webkit-box-sizing":"border-box",
|
7 |
|
|
"-moz-box-sizing":"border-box","-o-box-sizing":"border-box","box-sizing":"border-box"});this.box.append(e)}this.box.find(b("#clear"+this.name)).remove();a=b("<div></div>").css({clear:"both",height:"0",width:"0",display:"block"}).attr("id","clear"+this.name);this.box.append(a)},_renderGrid:function(a,e,c){var j=[],f=[],d=0,g=this.appendCount,h=this.options.gutter,k=this.cols,l=this.name;b(".galcolumn").width();e?(f=e,"append"==a&&(g+=c,d=this.appendCount),"prepend"==a&&(this.isPrepending=!0,d=Math.round(c%
|
8 |
|
|
k),0>=d&&(d=k)),"renderAfterPrepend"==a&&(g+=c,d=c)):(f=this.gridArr,g=b(this.gridArr).size());b.each(f,function(e,c){var f=b(c),m="100%";f.hasClass("not-responsive")&&(m="auto");f.css({marginBottom:h,zoom:"1",opacity:"0"}).find("img, object, embed, iframe").css({width:m,height:"auto",display:"block","margin-left":"auto","margin-right":"auto"});"prepend"==a?(d--,b("#item"+d+l).prepend(f),j.push(f),0==d&&(d=k)):(b("#item"+d+l).append(f),j.push(f),d++,d>=k&&(d=0),g>=k&&(g-=k))});this.appendCount=g;
|
9 |
|
|
this.itemCount=d;"append"==a||"prepend"==a?("prepend"==a&&this._updateAfterPrepend(this.gridArr,f),this._renderItem(j),this.isPrepending=!1):this._renderItem(this.gridArr)},_collectItems:function(){var a=[];b(this.box).find(this.options.selector).each(function(){a.push(b(this))});return a},_renderItem:function(a){var e=this.options.animationOptions.speed,c=this.options.animationOptions.effect,j=this.options.animationOptions.duration,f=this.options.animationOptions.queue,d=this.options.animationOptions.complete,
|
10 |
|
|
g=0,h=0;!0===this.options.animate&&!this.isResizing?(!0===f&&"fadeInOnAppear"==c?(this.isPrepending&&a.reverse(),b.each(a,function(c,f){setTimeout(function(){b(f).animate({opacity:"1.0"},j);h++;h==a.length&&d.call(void 0,a)},g*e);g++})):!1===f&&"fadeInOnAppear"==c&&(this.isPrepending&&a.reverse(),b.each(a,function(c,f){b(f).animate({opacity:"1.0"},j);h++;h==a.length&&this.ifCallback&&d.call(void 0,a)})),!0===f&&!c&&b.each(a,function(f,c){b(c).css({opacity:"1"});h++;h==a.length&&this.ifCallback&&d.call(void 0,
|
11 |
|
|
a)})):(b.each(a,function(a,c){b(c).css({opacity:"1"})}),this.ifCallback&&d.call(a))},_updateAfterPrepend:function(a,e){var c=this.gridArr;b.each(e,function(a,b){c.unshift(b)});this.gridArr=c},resize:function(){this.box.find(".galcolumn").remove();this._setCols();this.ifCallback=!1;this.isResizing=!0;this._renderGrid("append");this.ifCallback=!0;this.isResizing=!1},append:function(a){var e=this.gridArr,c=this.gridArrPrepend;b.each(a,function(a,b){e.push(b);c.push(b)});this._renderGrid("append",a,b(a).size())},
|
12 |
|
|
prepend:function(a){this.ifCallback=!1;this._renderGrid("prepend",a,b(a).size());this.ifCallback=!0}};b.fn.gridalicious=function(a,e){"string"===typeof a?this.each(function(){var c=b.data(this,"gridalicious");c[a].apply(c,[e])}):this.each(function(){b.data(this,"gridalicious",new b.Gal(a,this))});return this}})(jQuery);
|