/** * jquery masonry v2.1.07 * a dynamic layout plugin for jquery * the flip-side of css floats * http://masonry.desandro.com * * licensed under the mit license. * copyright 2012 david desandro */ (function(a, b, c) { "use strict"; var d = b.event, e = b.event.handle ? "handle" : "dispatch", f; d.special.smartresize = { setup: function() { b(this).bind("resize", d.special.smartresize.handler) }, teardown: function() { b(this).unbind("resize", d.special.smartresize.handler) }, handler: function(a, b) { var c = this, g = arguments; a.type = "smartresize", f && cleartimeout(f), f = settimeout(function() { d[e].apply(c, g) }, b === "execasap" ? 0 : 100) } }, b.fn.smartresize = function(a) { return a ? this.bind("smartresize", a) : this.trigger("smartresize", ["execasap"]) }, b.mason = function(a, c) { this.element = b(c), this._create(a), this._init() }, b.mason.settings = { isresizable: !0, isanimated: !1, animationoptions: { queue: !1, duration: 500 }, gutterwidth: 0, isrtl: !1, isfitwidth: !1, containerstyle: { position: "relative" } }, b.mason.prototype = { _filterfindbricks: function(a) { var b = this.options.itemselector; return b ? a.filter(b).add(a.find(b)) : a }, _getbricks: function(a) { var b = this._filterfindbricks(a).css({ position: "absolute" }).addclass("masonry-brick"); return b }, _create: function(c) { this.options = b.extend(!0, {}, b.mason.settings, c), this.stylequeue = []; var d = this.element[0].style; this.originalstyle = { height: d.height || "" }; var e = this.options.containerstyle; for (var f in e) this.originalstyle[f] = d[f] || ""; this.element.css(e), this.horizontaldirection = this.options.isrtl ? "right" : "left"; var g = this.element.css("padding-" + this.horizontaldirection), h = this.element.css("padding-top"); this.offset = { x: g ? parseint(g, 10) : 0, y: h ? parseint(h, 10) : 0 }, this.isfluid = this.options.columnwidth && typeof this.options.columnwidth == "function"; var i = this; settimeout(function() { i.element.addclass("masonry") }, 0), this.options.isresizable && b(a).bind("smartresize.masonry", function() { i.resize() }), this.reloaditems() }, _init: function(a) { this._getcolumns(), this._relayout(a) }, option: function(a, c) { b.isplainobject(a) && (this.options = b.extend(!0, this.options, a)) }, layout: function(a, b) { for (var c = 0, d = a.length; c < d; c++) this._placebrick(a[c]); var e = {}; e.height = math.max.apply(math, this.colys); if (this.options.isfitwidth) { var f = 0; c = this.cols; while (--c) { if (this.colys[c] !== 0) break; f++ } e.width = (this.cols - f) * this.columnwidth - this.options.gutterwidth } this.stylequeue.push({ $el: this.element, style: e }); var g = this.islaidout ? this.options.isanimated ? "animate" : "css" : "css", h = this.options.animationoptions, i; for (c = 0, d = this.stylequeue.length; c < d; c++) i = this.stylequeue[c], i.$el[g](i.style, h); this.stylequeue = [], b && b.call(a), this.islaidout = !0 }, _getcolumns: function() { var a = this.options.isfitwidth ? this.element.parent() : this.element, b = a.width(); this.columnwidth = this.isfluid ? this.options.columnwidth(b) : this.options.columnwidth || this.$bricks.outerwidth(!0) || b, this.columnwidth += this.options.gutterwidth, this.cols = math.floor((b + this.options.gutterwidth) / this.columnwidth), this.cols = math.max(this.cols, 1) }, _placebrick: function(a) { var c = b(a), d, e, f, g, h; d = math.ceil(c.outerwidth(!0) / this.columnwidth), d = math.min(d, this.cols); if (d === 1) f = this.colys; else { e = this.cols + 1 - d, f = []; for (h = 0; h < e; h++) g = this.colys.slice(h, h + d), f[h] = math.max.apply(math, g) } var i = math.min.apply(math, f), j = 0; for (var k = 0, l = f.length; k < l; k++) if (f[k] === i) { j = k; break } var m = { top: i + this.offset.y }; m[this.horizontaldirection] = this.columnwidth * j + this.offset.x, this.stylequeue.push({ $el: c, style: m }); var n = i + c.outerheight(!0), o = this.cols + 1 - l; for (k = 0; k < o; k++) this.colys[j + k] = n }, resize: function() { var a = this.cols; this._getcolumns(), (this.isfluid || this.cols !== a) && this._relayout() }, _relayout: function(a) { var b = this.cols; this.colys = []; while (b--) this.colys.push(0); this.layout(this.$bricks, a) }, reloaditems: function() { this.$bricks = this._getbricks(this.element.children()) }, reload: function(a) { this.reloaditems(), this._init(a) }, appended: function(a, b, c) { if (b) { this._filterfindbricks(a).css({ top: this.element.height() }); var d = this; settimeout(function() { d._appended(a, c) }, 1) } else this._appended(a, c) }, _appended: function(a, b) { var c = this._getbricks(a); this.$bricks = this.$bricks.add(c), this.layout(c, b) }, remove: function(a) { this.$bricks = this.$bricks.not(a), a.remove() }, destroy: function() { this.$bricks.removeclass("masonry-brick").each(function() { this.style.position = "", this.style.top = "", this.style.left = "" }); var c = this.element[0].style; for (var d in this.originalstyle) c[d] = this.originalstyle[d]; this.element.unbind(".masonry").removeclass("masonry").removedata("masonry"), b(a).unbind(".masonry") } }, b.fn.imagesloaded = function(a) { function h() { a.call(c, d) } function i(a) { var c = a.target; c.src !== f && b.inarray(c, g) === -1 && (g.push(c), --e <= 0 && (settimeout(h), d.unbind(".imagesloaded", i))) } var c = this, d = c.find("img").add(c.filter("img")), e = d.length, f = "data:image/gif;base64,r0lgodlhaqabaiaaaaaaap///ywaaaaaaqabaaacauwaow==", g = []; return e || h(), d.bind("load.imagesloaded error.imagesloaded", i).each(function() { var a = this.src; this.src = f, this.src = a }), c }; var g = function(b) { a.console && a.console.error(b) }; b.fn.masonry = function(a) { if (typeof a == "string") { var c = array.prototype.slice.call(arguments, 1); this.each(function() { var d = b.data(this, "masonry"); if (!d) { g("cannot call methods on masonry prior to initialization; attempted to call method '" + a + "'"); return } if (!b.isfunction(d[a]) || a.charat(0) === "_") { g("no such method '" + a + "' for masonry instance"); return } d[a].apply(d, c) }) } else this.each(function() { var c = b.data(this, "masonry"); c ? (c.option(a || {}), c._init()) : b.data(this, "masonry", new b.mason(a, this)) }); return this } })(window, jquery);