-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkoluhms.min.js
8 lines (7 loc) · 1.65 KB
/
koluhms.min.js
1
2
3
4
5
6
7
8
/*!
* Koluhms
* An automated column [kol-uh m] solution with support for height balancing, responsive styles and more. Configurable right in your HTML and CSS.
* Version: 1.1 (October 6th, 2015)
* requires jQuery
*/
var koluhms;$(function(){var t=function(){this.makeColumns=function(){$("[data-columns]").each(function(){var t=$(this).data("columns");t&&(t=t.toString().split(","));var e=0,n=$(this).data("breaks");if(n){n=n.toString().split(",");for(var i=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,a=0;a<n.length;a++)i>=parseInt(n[a],10)&&(e=parseInt(t[a],10))}else e=parseInt(t[0]);t=e;var r=$(this).data("selector"),h=$(this).data("column-element"),o=$(this).data("balance"),s=$(this).children(r),d=$(this).parent(),l=$(this).data("identifier");if(d.find("."+l).length!=t){if(d.find("."+l).remove(),0===t)return void $(this).show();for(var a=0;t>a;a++){var u=" "+l+"-"+(a+1);0===a?u+=" "+l+"-first":a===t-1&&(u+=" "+l+"-last"),d.append("<"+h+' class="'+l+u+'"></'+h+">")}var c=0;s.each(function(){var e=$($(this)[0].outerHTML);d.find("."+l+":eq("+c+")").append(e),c++,c>=t&&(c=0)});var f=function(){for(var e=[],n=0;t>n;n++)e[n]={eq:n,height:d.find("."+l+":eq("+n+")").outerHeight()};return e.sort(function(t,e){return t.height-e.height}),e},m=function(){var t=d.find("."+l+":eq("+v[0].eq+")");return $(this).detach().appendTo(t),t.outerHeight()>=g.outerHeight()?void t.children(r+":last").detach().appendTo(g):(v=f(),p=v.length,!1)};if(o)for(var v=f(),p=v.length-1;p>0;p--){var g=d.find("."+l+":eq("+v[t-p].eq+")");g.children(r).each(m)}$(this).hide()}})}};koluhms=new t,$(window).on("resize",koluhms.makeColumns),koluhms.makeColumns()});