/* jquery.poptrox.js v2.5.1 | (c) n33 | n33.co | mit licensed */ !function (e) { e.fn.poptrox_disableselection = function () { return e(this).css("user-select", "none").css("-khtml-user-select", "none").css("-moz-user-select", "none").css("-o-user-select", "none").css("-webkit-user-select", "none") }, e.fn.poptrox = function (o) { function t() { p = e(window).width(), s = e(window).height() + r.windowheightpad; var o = math.abs(x.width() - x.outerwidth()), t = math.abs(x.height() - x.outerheight()), i = (w.width(), w.height(), p - 2 * r.windowmargin - o), n = s - 2 * r.windowmargin - t; x.css("min-width", r.popupwidth).css("min-height", r.popupheight), v.children().css("max-width", i).css("max-height", n) } if (0 == this.length) return e(this); if (this.length > 1) { for (var i = 0; i < this.length; i++) e(this[i]).poptrox(o); return e(this) } var p, s, r = e.extend({ preload: !1, basezindex: 1e3, fadespeed: 300, overlaycolor: "#000000", overlayopacity: .6, overlayclass: "poptrox-overlay", windowmargin: 50, windowheightpad: 0, selector: "a", caption: null, parent: "body", popupspeed: 300, popupwidth: 200, popupheight: 100, popupisfixed: !1, usebodyoverflow: !1, usepopupeasyclose: !0, usepopupforceclose: !1, usepopuploader: !0, usepopupcloser: !0, usepopupcaption: !1, usepopupnav: !1, usepopupdefaultstyling: !0, popupbackgroundcolor: "#ffffff", popuptextcolor: "#000000", popuploadertextsize: "2em", popupcloserbackgroundcolor: "#000000", popupclosertextcolor: "#ffffff", popupclosertextsize: "20px", popuppadding: 10, popupcaptionheight: 60, popupcaptiontextsize: null, popupblankcaptiontext: "(untitled)", popupclosertext: "×", popuploadertext: "••••", popupclass: "poptrox-popup", popupselector: null, popuploaderselector: ".loader", popupcloserselector: ".closer", popupcaptionselector: ".caption", popupnavpreviousselector: ".nav-previous", popupnavnextselector: ".nav-next", onpopupclose: null, onpopupopen: null }, o), n = e(this), a = e("body"), l = e('
'), u = e(window), d = [], h = 0, g = !1, f = new array; r.usepopuploader || (r.popuploaderselector = null), r.usepopupcloser || (r.popupcloserselector = null), r.usepopupcaption || (r.popupcaptionselector = null), r.usepopupnav || (r.popupnavpreviousselector = null, r.popupnavnextselector = null); var x; x = e(r.popupselector ? r.popupselector : '
' + (r.popuploaderselector ? '
' + r.popuploadertext + "
" : "") + '
' + (r.popupcaptionselector ? '
' : "") + (r.popupcloserselector ? '' + r.popupclosertext + "" : "") + (r.popupnavpreviousselector ? '' : "") + (r.popupnavnextselector ? '' : "") + "
"); var v = x.find(".pic"), w = e(), b = x.find(r.popuploaderselector), m = x.find(r.popupcaptionselector), y = x.find(r.popupcloserselector), s = x.find(r.popupnavnextselector), c = x.find(r.popupnavpreviousselector), p = s.add(c); if (r.usepopupdefaultstyling && (x.css("background", r.popupbackgroundcolor).css("color", r.popuptextcolor).css("padding", r.popuppadding + "px"), m.length > 0 && (x.css("padding-bottom", r.popupcaptionheight + "px"), m.css("position", "absolute").css("left", "0").css("bottom", "0").css("width", "100%").css("text-align", "center").css("height", r.popupcaptionheight + "px").css("line-height", r.popupcaptionheight + "px"), r.popupcaptiontextsize && m.css("font-size", popupcaptiontextsize)), y.length > 0 && y.html(r.popupclosertext).css("font-size", r.popupclosertextsize).css("background", r.popupcloserbackgroundcolor).css("color", r.popupclosertextcolor).css("display", "block").css("width", "40px").css("height", "40px").css("line-height", "40px").css("text-align", "center").css("position", "absolute").css("text-decoration", "none").css("outline", "0").css("top", "0").css("right", "-40px"), b.length > 0 && b.html("").css("position", "relative").css("font-size", r.popuploadertextsize).on("startspinning", function (o) { var t = e("
" + r.popuploadertext + "
"); t.css("height", math.floor(r.popupheight / 2) + "px").css("overflow", "hidden").css("line-height", math.floor(r.popupheight / 2) + "px").css("text-align", "center").css("margin-top", math.floor((x.height() - t.height() + (m.length > 0 ? m.height() : 0)) / 2)).css("color", r.popuptextcolor ? r.popuptextcolor : "").on("xfin", function () { t.fadeto(300, .5, function () { t.trigger("xfout") }) }).on("xfout", function () { t.fadeto(300, .05, function () { t.trigger("xfin") }) }).trigger("xfin"), b.append(t) }).on("stopspinning", function (e) { var o = b.find("div"); o.remove() }), 2 == p.length)) { p.css("font-size", "75px").css("text-align", "center").css("color", "#fff").css("text-shadow", "none").css("height", "100%").css("position", "absolute").css("top", "0").css("opacity", "0.35").css("cursor", "pointer").css("box-shadow", "inset 0px 0px 10px 0px rgba(0,0,0,0)").poptrox_disableselection(); var k, t; r.usepopupeasyclose ? (k = "100px", t = "100px") : (k = "75%", t = "25%"), s.css("right", "0").css("width", k).html('
>
'), c.css("left", "0").css("width", t).html('
<
') } return u.on("resize orientationchange", function () { t() }), m.on("update", function (e, o) { o && 0 != o.length || (o = r.popupblankcaptiontext), m.html(o) }), y.css("cursor", "pointer").on("click", function (e) { return e.preventdefault(), e.stoppropagation(), x.trigger("poptrox_close"), !0 }), s.on("click", function (e) { e.stoppropagation(), e.preventdefault(), x.trigger("poptrox_next") }), c.on("click", function (e) { e.stoppropagation(), e.preventdefault(), x.trigger("poptrox_previous") }), l.css("position", "fixed").css("left", 0).css("top", 0).css("z-index", r.basezindex).css("width", "100%").css("height", "100%").css("text-align", "center").css("cursor", "pointer").appendto(r.parent).prepend('
').append('
').hide().on("touchmove", function (e) { return !1 }).on("click", function (e) { e.preventdefault(), e.stoppropagation(), x.trigger("poptrox_close") }), x.css("display", "inline-block").css("vertical-align", "middle").css("position", "relative").css("z-index", 1).css("cursor", "auto").appendto(l).hide().on("poptrox_next", function () { var e = h + 1; e >= d.length && (e = 0), x.trigger("poptrox_switch", [e]) }).on("poptrox_previous", function () { var e = h - 1; 0 > e && (e = d.length - 1), x.trigger("poptrox_switch", [e]) }).on("poptrox_reset", function () { t(), x.data("width", r.popupwidth).data("height", r.popupheight), b.hide().trigger("stopspinning"), m.hide(), y.hide(), p.hide(), v.hide(), w.attr("src", "").detach() }).on("poptrox_open", function (e, o) { return g ? !0 : (g = !0, r.usebodyoverflow && a.css("overflow", "hidden"), r.onpopupopen && r.onpopupopen(), void l.fadeto(r.fadespeed, 1, function () { x.trigger("poptrox_switch", [o, !0]) })) }).on("poptrox_switch", function (o, i, p) { var s; if (!p && g) return !0; if (g = !0, x.css("width", x.data("width")).css("height", x.data("height")), m.hide(), w.attr("src") && w.attr("src", ""), w.detach(), s = d[i], w = s.object, w.off("load"), v.css("text-indent", "-9999px").show().append(w), "ajax" == s.type ? e.get(s.src, function (e) { w.html(e), w.trigger("load") }) : w.attr("src", s.src), "image" != s.type) { var n, a; n = s.width, a = s.height, "%" == n.slice(-1) && (n = parseint(n.substring(0, n.length - 1)) / 100 * u.width()), "%" == a.slice(-1) && (a = parseint(a.substring(0, a.length - 1)) / 100 * u.height()), w.css("position", "relative").css("outline", "0").css("z-index", r.basezindex + 100).width(n).height(a) } b.trigger("startspinning").fadein(300), x.show(), r.popupisfixed ? (x.width(r.popupwidth).height(r.popupheight), w.load(function () { w.off("load"), b.hide().trigger("stopspinning"), m.trigger("update", [s.captiontext]).fadein(r.fadespeed), y.fadein(r.fadespeed), v.css("text-indent", 0).hide().fadein(r.fadespeed, function () { g = !1 }), h = i, p.fadein(r.fadespeed) })) : w.load(function () { t(), w.off("load"), b.hide().trigger("stopspinning"); var e = w.width(), o = w.height(), p = function () { m.trigger("update", [s.captiontext]).fadein(r.fadespeed), y.fadein(r.fadespeed), v.css("text-indent", 0).hide().fadein(r.fadespeed, function () { g = !1 }), h = i, p.fadein(r.fadespeed), x.data("width", e).data("height", o).css("width", "auto").css("height", "auto") }; e == x.data("width") && o == x.data("height") ? p() : x.animate({ width: e, height: o }, r.popupspeed, "swing", p) }), "image" != s.type && w.trigger("load") }).on("poptrox_close", function () { return g && !r.usepopupforceclose ? !0 : (g = !0, x.hide().trigger("poptrox_reset"), r.onpopupclose && r.onpopupclose(), void l.fadeout(r.fadespeed, function () { r.usebodyoverflow && a.css("overflow", "auto"), g = !1 })) }).trigger("poptrox_reset"), r.usepopupeasyclose ? (m.on("click", "a", function (e) { e.stoppropagation() }), x.css("cursor", "pointer").on("click", function (e) { e.stoppropagation(), e.preventdefault(), x.trigger("poptrox_close") })) : x.on("click", function (e) { e.stoppropagation() }), u.keydown(function (e) { if (x.is(":visible")) switch (e.keycode) { case 37: case 32: if (r.usepopupnav) return x.trigger("poptrox_previous"), !1; break; case 39: if (r.usepopupnav) return x.trigger("poptrox_next"), !1; break; case 27: return x.trigger("poptrox_close"), !1 } }), n.find(r.selector).each(function (o) { var t, i, p = e(this), s = p.find("img"), n = p.data("poptrox"); if ("ignore" != n && p.attr("href")) { if (t = { src: p.attr("href"), captiontext: s.attr("title"), width: null, height: null, type: null, object: null, options: null }, r.caption) { if ("function" == typeof r.caption) c = r.caption(p); else if ("selector" in r.caption) { var a; a = p.find(r.caption.selector), "attribute" in r.caption ? c = a.attr(r.caption.attribute) : (c = a.html(), r.caption.remove === !0 && a.remove()) } } else c = s.attr("title"); if (t.captiontext = c, n) { var l = n.split(","); 0 in l && (t.type = l[0]), 1 in l && (i = l[1].match(/([0-9%]+)x([0-9%]+)/), i && 3 == i.length && (t.width = i[1], t.height = i[2])), 2 in l && (t.options = l[2]) } if (!t.type) switch (i = t.src.match(/\/\/([a-z0-9\.]+)\/.*/), (!i || i.length < 2) && (i = [!1]), i[1]) { case "api.soundcloud.com": t.type = "soundcloud"; break; case "youtu.be": t.type = "youtube"; break; case "vimeo.com": t.type = "vimeo"; break; case "wistia.net": t.type = "wistia"; break; case "bcove.me": t.type = "bcove"; break; default: t.type = "image" } switch (i = t.src.match(/\/\/[a-z0-9\.]+\/(.*)/), t.type) { case "iframe": t.object = e(''), t.object.on("click", function (e) { e.stoppropagation() }).css("cursor", "auto"), t.width && t.height || (t.width = "600", t.height = "400"); break; case "ajax": t.object = e('
'), t.object.on("click", function (e) { e.stoppropagation() }).css("cursor", "auto").css("overflow", "auto"), t.width && t.height || (t.width = "600", t.height = "400"); break; case "soundcloud": t.object = e(''), t.src = "//w.soundcloud.com/player/?url=" + escape(t.src) + (t.options ? "&" + t.options : ""), t.width = "600", t.height = "166"; break; case "youtube": t.object = e(''), t.src = "//www.youtube.com/embed/" + i[1] + (t.options ? "?" + t.options : ""), t.width && t.height || (t.width = "800", t.height = "480"); break; case "vimeo": t.object = e(''), t.src = "//player.vimeo.com/video/" + i[1] + (t.options ? "?" + t.options : ""), t.width && t.height || (t.width = "800", t.height = "480"); break; case "wistia": t.object = e(''), t.src = "//fast.wistia.net/" + i[1] + (t.options ? "?" + t.options : ""), t.width && t.height || (t.width = "800", t.height = "480"); break; case "bcove": t.object = e(''), t.src = "//bcove.me/" + i[1] + (t.options ? "?" + t.options : ""), t.width && t.height || (t.width = "640", t.height = "360"); break; default: if (t.object = e(''), r.preload) { var i = document.createelement("img"); i.src = t.src, f.push(i) } t.width = p.attr("width"), t.height = p.attr("height") } "file:" == window.location.protocol && t.src.match(/^\/\//) && (t.src = "http:" + t.src), d.push(t), s.attr("title", ""), p.attr("href", "").css("outline", 0).on("click", function (e) { e.preventdefault(), e.stoppropagation(), x.trigger("poptrox_open", [o]) }) } }), e(this) } }(jquery);