/** * jQuery VGrid v0.1.7 - variable grid layout plugin * * Terms of Use - jQuery VGrid * under the MIT (http://www.opensource.org/licenses/mit-license.php) License. * * Copyright 2009-2011 xlune.com All rights reserved. * (http://blog.xlune.com/2009/09/jqueryvgrid.html) */ (function(g){function i(a){var b=a.data("_vgchild"),f=[[0,a.width(),0]],h=0,e,c,j;b.each(function(){e=g(this);var a=e.width(),d=e.height();a+=Number(e.css("margin-left").replace("px",""))+Number(e.css("padding-left").replace("px",""))+Number(e.get(0).style.borderLeftWidth.replace("px",""))+Number(e.css("margin-right").replace("px",""))+Number(e.css("padding-right").replace("px",""))+Number(e.get(0).style.borderRightWidth.replace("px",""));d+=Number(e.css("margin-top").replace("px",""))+Number(e.css("padding-top").replace("px", ""))+Number(e.get(0).style.borderTopWidth.replace("px",""))+Number(e.css("margin-bottom").replace("px",""))+Number(e.css("padding-bottom").replace("px",""))+Number(e.get(0).style.borderBottomWidth.replace("px",""));c=[a,d];a:{for(var a=c[0],d=f.concat().sort(q),b=d[d.length-1][2],k=0,o=d.length;k=b)break;if(d[k][1]-d[k][0]>=a){j=[d[k][0],d[k][2]];break a}}j=[0,b]}d=j;a=f.concat().sort(q);d=[d[0],d[0]+c[0],d[1]+c[1]];b=0;for(k=a.length;b=m[0]&&l[0]=m[0]&&l[1]=m[0]&&l[0]0&&d[d.length-1][1]==a[b][0]&&d[d.length-1][2]==a[b][2]?d[d.length-1][1]=a[b][1]:d.push(a[b]));f=d;h=Math.max(h,j[1]+c[1]);e.data("_vgleft",j[0]);e.data("_vgtop",j[1])});a.data("_vgwrapheight",h);t(a)}function q(a,b){return!a||!b?0:a[2]==b[2]&&a[0]>b[0]||a[2]>b[2]?1:-1}function s(a,b){return!a||!b?0:a[0]> b[0]?1:-1}function t(a){var b=a.data("_vgchild").length*(a.data("_vgopt").delay||0)+a.data("_vgopt").time||500;a.stop();a.height()").text(" ").attr("id","_vgridspan").hide().appendTo("body");f.data("size",f.css("font-size")); f.data("timer",setInterval(function(){f.css("font-size")!=f.data("size")&&(f.data("size",f.css("font-size")),b(a))},1E3))}function r(a,b){a.data("vgrid-image-event-added")||(a.data("vgrid-image-event-added",1),a.bind("vgrid-added",function(){a.find("img").each(function(){var e=g(this);e.data("vgrid-image-handler")||(e.data("vgrid-image-handler",1),e.bind("load",function(){b(a)}))})}));a.trigger("vgrid-added");var f=a.append,h=a.prepend;a.append=function(){f.apply(a,arguments);a.trigger("vgrid-added")}; a.prepend=function(){h.apply(a,arguments);a.trigger("vgrid-added")}}g.fn.extend({vgrid:function(a){var b=g(this),f=a||{};b.each(function(){var a=g(this);a.data("_vgopt",f);a.data("_vgchild",a.find("> *"));a.data("_vgdefchild",a.data("_vgchild"));a.css({position:"relative",width:"auto"});a.data("_vgchild").css("position","absolute");i(a);u(a.data("_vgchild"));if(a.data("_vgopt").fadeIn){var b=typeof a.data("_vgopt").fadeIn=="object"?a.data("_vgopt").fadeIn:{time:a.data("_vgopt").fadeIn};a.data("_vgchild").each(function(a){var f= g(this);f.css("display","none");setTimeout(function(){f.fadeIn(b.time||250)},a*(b.delay||0))})}g(window).resize(function(){n(a)});f.useLoadImageEvent&&r(a,n);f.useFontSizeListener&&v(a,n)});return b},vgrefresh:function(a,b,f,h){var e=g(this);e.each(function(){var c=g(this),e=c.data("_vgopt")||{};c.data("_vgchild")&&(c.data("_vgchild",c.find("> *")),c.data("_vgchild").css("position","absolute"),i(c),b=typeof b=="number"?b:c.data("_vgopt").time||500,f=typeof f=="number"?f:c.data("_vgopt").delay||0, p(c.data("_vgchild"),a||c.data("_vgopt").easeing||"linear",b,f),typeof h=="function"&&setTimeout(h,c.data("_vgchild").length*f+b));e.useLoadImageEvent&&r(c,n)});return e},vgsort:function(a,b,f,h){var e=g(this);e.each(function(){var c=g(this);c.data("_vgchild")&&(c.data("_vgchild",c.data("_vgchild").sort(a)),c.data("_vgchild").each(function(){g(this).appendTo(c)}),i(c),p(c.data("_vgchild"),b||c.data("_vgopt").easeing||"linear",typeof f=="number"?f:c.data("_vgopt").time||500,typeof h=="number"?h:c.data("_vgopt").delay|| 0))});return e}})})(jQuery);