-
Notifications
You must be signed in to change notification settings - Fork 4
/
jquery.wrecker.min.js
11 lines (11 loc) · 1.7 KB
/
jquery.wrecker.min.js
1
2
3
4
5
6
7
8
9
10
11
/**
* jQuery Wrecker v0.2
* Responsive Equal-Height Columns and Rows
* http://www.svachon.com/blog/wrecker-responsive-equal-height-columns-and-rows
*
* Licensed under the MIT license.
* Copyright 2013 Steven Vachon
*/
(function(d){d.Wrecker=function(){function a(){for(var j=g.maxColumns,a=d(window).innerWidth(),c=0,h=g.responsiveColumns.length;c<h;c++){var l=g.responsiveColumns[c],f;for(f in l)f>=a&&(j=l[f])}j!=b&&0<j&&(m=b,b=j,e())}function f(a){d.support.leadingWhitespace||(a.responsiveColumns=[]);g=d.extend(g,a)}function k(){a()}function e(){c.children("div.wrecker-row").children().unwrap();var a=c.children(g.itemSelector);if(1<b){var f=a.length,e=0,h=0;a.each(function(c){1==++h&&(e=c);if(h>=b||c>=f-1)a.slice(e,
c+1).wrapAll('<div class="wrecker-row" style="display:table-row"/>'),h=0;1>=m&&d(this).addClass("wrecker-cell").css({display:"table-cell",float:"none"})});c.addClass("wrecker").css("display","table")}else a.removeClass("wrecker-cell").css({display:"",float:""}),c.removeClass("wrecker").css("display","")}var b=0,c,m=0,g={itemSelector:"",maxColumns:1,responsiveColumns:[]};this.changeSettings=f;this.destroy=function(){d(window).off("resize",k);b=0;e();c.removeData("wrecker")};this.reload=e;(function(b,
e){c=d(e);f(b);d(window).on("resize",k);a()}).apply(this,arguments)};d.fn.wrecker=function(a){var f="string"===typeof a,k=Array.prototype.slice.call(arguments,1);this.each(function(){var e=d(this),b=e.data("wrecker");f?b?d.isFunction(b[a])?b[a].apply(b,k):console.error('No such Wrecker method "'+a+'"'):console.error('Cannot call Wrecker methods prior to initialization; attempted to call method "'+a+'"'):(a=a||{},b?b.changeSettings(a):e.data("wrecker",new d.Wrecker(a,this)))});return this}})(jQuery);