forked from germanysbestkeptsecret/Wookmark-jQuery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.wookmark.min.js
More file actions
11 lines (11 loc) · 2.92 KB
/
jquery.wookmark.min.js
File metadata and controls
11 lines (11 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
/*!
jQuery Wookmark plugin 1.0.1
@name jquery.wookmark.js
@author Christoph Ono (chri@sto.ph or @gbks)
@version 1.0.1
@date 1/27/2013
@category jQuery plugin
@copyright (c) 2009-2013 Christoph Ono (www.wookmark.com)
@license Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*/
$.fn.wookmark=function(a){if(!this.wookmarkOptions){this.wookmarkOptions=$.extend({align:"center",container:$("body"),offset:2,autoResize:false,itemWidth:$(this[0]).outerWidth(),resizeDelay:50},a)}else{if(a){this.wookmarkOptions=$.extend(this.wookmarkOptions,a)}}if(!this.wookmarkColumns){this.wookmarkColumns=null;this.wookmarkContainerWidth=null}this.wookmarkLayout=function(){var e=this.wookmarkOptions.itemWidth+this.wookmarkOptions.offset;var d=this.wookmarkOptions.container.width();var c=Math.floor((d+this.wookmarkOptions.offset)/e);var f;switch(this.wookmarkOptions.align){case"left":case"right":f=Math.floor((c/e+this.wookmarkOptions.offset)/2);break;case"center":default:f=Math.round((d-(c*e-this.wookmarkOptions.offset))/2);break}var b=0;if(this.wookmarkColumns!=null&&this.wookmarkColumns.length==c){b=this.wookmarkLayoutColumns(e,f)}else{b=this.wookmarkLayoutFull(e,c,f)}this.wookmarkOptions.container.css("height",b+"px")};this.wookmarkLayoutFull=function(e,g,j){var n=[];while(n.length<g){n.push(0)}this.wookmarkColumns=[];while(this.wookmarkColumns.length<g){this.wookmarkColumns.push([])}var p,o,f,l=0,h=0,d=this.length,m=null,c=null,b=0;for(;l<d;l++){p=$(this[l]);m=null;c=0;for(h=0;h<g;h++){if(m==null||n[h]<m){m=n[h];c=h}}p.css({position:"absolute",top:m+"px"});if(this.wookmarkOptions.align=="right"){p.css("right",(c*e+j)+"px")}else{p.css("left",(c*e+j)+"px")}n[c]=m+p.outerHeight()+this.wookmarkOptions.offset;b=Math.max(b,n[c]);this.wookmarkColumns[c].push(p)}return b};this.wookmarkLayoutColumns=function(c,g){var l=[];while(l.length<this.wookmarkColumns.length){l.push(0)}var j=0,d=this.wookmarkColumns.length,e;var f=0,h,m;var b=0;for(;j<d;j++){e=this.wookmarkColumns[j];h=e.length;for(f=0;f<h;f++){m=e[f];m.css({top:l[j]+"px"});if(this.wookmarkOptions.align=="right"){m.css("right",(j*c+g)+"px")}else{m.css("left",(j*c+g)+"px")}l[j]+=m.outerHeight()+this.wookmarkOptions.offset;b=Math.max(b,l[j])}}return b};this.wookmarkResizeTimer=null;if(!this.wookmarkResizeMethod){this.wookmarkResizeMethod=null}if(this.wookmarkOptions.autoResize){this.wookmarkOnResize=function(b){if(this.wookmarkResizeTimer){clearTimeout(this.wookmarkResizeTimer)}this.wookmarkResizeTimer=setTimeout($.proxy(this.wookmarkLayout,this),this.wookmarkOptions.resizeDelay)};if(!this.wookmarkResizeMethod){this.wookmarkResizeMethod=$.proxy(this.wookmarkOnResize,this)}$(window).resize(this.wookmarkResizeMethod)}this.wookmarkClear=function(){if(this.wookmarkResizeTimer){clearTimeout(this.wookmarkResizeTimer);this.wookmarkResizeTimer=null}if(this.wookmarkResizeMethod){$(window).unbind("resize",this.wookmarkResizeMethod)}};this.wookmarkLayout();this.show()};