Advertisement
Guest User

Untitled

a guest
Oct 30th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.44 KB | None | 0 0
  1. function windowResize() {
  2. if ("Fixed" == _4ORMAT_DATA.theme.menu_alignment && "Left" == _4ORMAT_DATA.theme.menu_position && $("#content").css("margin-left", $(".nav-wrapper").outerWidth() + parseInt($(".nav-wrapper").css("margin-right"))), Menu.setHeight(), $("#gallery_window").is(":visible") && ($(".lightbox-wrapper").height($(window).height()), Lightbox.resizeLoadedAsset()), window.matchMedia("(max-width: 767px)").matches && ($("aside.mobileMenu.mobile-content-top").outerHeight() > 95 ? $("#content").css("padding-top", $("aside.mobileMenu.mobile-content-top").outerHeight() + 5 + "px") : $("#content").css("padding-top", "95px"), $("aside.mobileMenu.mobile-content-top h1 a").hide().fadeIn(1)), $("body").hasClass("gallery") && "Columns" == _4ORMAT_DATA.theme.gallery_thumbnail_layout && Gallery.recalculateGallery(), $("body").hasClass("gallery") && "Rows" == _4ORMAT_DATA.theme.gallery_thumbnail_layout) {
  3. var e = Math.round($("#content").width() / $(".grid-sizer").width());
  4. $.each($(".asset-video img"), function(e, t) {
  5. $(t).css("margin-left", ($(".asset-video").width() - $(t).width()) / 2)
  6. }), $(".last-col").removeClass("last-col"), $.each($(".asset").not(".asset-title"), function(t, i) {
  7. $(i).position().left > $(".grid-sizer").width() * (e - 1) && $(i).addClass("last-col")
  8. })
  9. }
  10. window.matchMedia("(max-width: 767px)").matches && ($(window).width() > $(window).height() ? ($("#gallery_window").hasClass("video") || $("#gallery_window").hasClass("image")) && ($("#bottomGradient").length && $("#bottomGradient").addClass("landscape"), $("#copy_holder").hasClass("noCopy") || $("#copy_holder").show().addClass("landscape")) : ($("#gallery_window").hasClass("video") || $("#gallery_window").hasClass("image")) && ($("#bottomGradient").length && ($("#bottomGradient").removeClass("landscape"), $("#bottomGradient .button").removeClass("fade")), $("#copy_holder").hide().removeClass("landscape")))
  11. }
  12. var features;
  13. ! function(e, t) {
  14. t.transitions = "transition" in e || "webkitTransition" in e || "MozTransition" in e || "msTransition" in e || "OTransition" in e
  15. }(document.createElement("div").style, features || (features = {}));
  16. var App = {
  17. scrollerWidth: 0,
  18. init: function() {
  19. Array.prototype.indexOf || (Array.prototype.indexOf = function(e) {
  20. var t = this.length >>> 0,
  21. i = Number(arguments[1]) || 0;
  22. for (i = i < 0 ? Math.ceil(i) : Math.floor(i), i < 0 && (i += t); i < t; i++)
  23. if (i in this && this[i] === e) return i;
  24. return -1
  25. }), this.scrollerWidth = Helpers.getScrollerWidth(), Menu.init(), $("body").hasClass("listing") && (Listing.resize(), Listing.init(), Listing.animationCascade()), $("body").hasClass("gallery") && (Gallery.init(), Lightbox.init1(), 0 != window.location.hash.substring(1).length && Lightbox.loadAsset1(window.location.hash.substring(1), !0)), $(window).on("throttledresize", windowResize), window.matchMedia("(max-width: 767px)").matches && ($("aside.mobileMenu.mobile-content-top").outerHeight() > 95 ? $("#content").css("padding-top", $("aside.mobileMenu.mobile-content-top").outerHeight() + 5 + "px") : $("#content").css("padding-top", "95px"))
  26. }
  27. },
  28. Menu = {
  29. init: function() {
  30. "Scrolling" == _4ORMAT_DATA.theme.menu_alignment && ($(".nav-wrapper>.wrapper").css("margin-top", .04 * $(window).width()), setTimeout(function() {
  31. $(".nav-wrapper").height($(document).height())
  32. }, 100)), $(".nav-wrapper>.wrapper").fadeIn(500), "Fixed" == _4ORMAT_DATA.theme.menu_alignment && "Left" == _4ORMAT_DATA.theme.menu_position && $("#content").css({
  33. "margin-left": $(".nav-wrapper").outerWidth() + parseInt($(".nav-wrapper").css("margin-right")),
  34. display: "block"
  35. }), $("#content").show(), this.setHeight(), $(".category>a").on("click", function() {
  36. window.matchMedia("(min-width: 768px)").matches && $(this).parent().toggleClass("active")
  37. }), this.mobile.init()
  38. },
  39. mobile: {
  40. $aside: $("aside"),
  41. $header: $("header"),
  42. $body: $("body"),
  43. left_state: "hidden",
  44. lastScrollTop: 0,
  45. touchStateY: -1,
  46. touchState: "displayed",
  47. touchMargin: 30,
  48. init: function() {
  49. this.duplicateHeader(), this.$aside.find(".mobile-menu-close").click(this.onCloseClick.bind(this)), this.$aside.find(".mobile-menu-trigger").click(this.onTriggerClick.bind(this)), $(document).bind("touchstart", this.onTouchStart.bind(this)), $(document).bind("touchmove", this.onScrollMove.bind(this)), $(document).bind("scroll", this.onScrollMove.bind(this)), this.$aside.addClass("anim"), this.$header.addClass("anim"), this.blogPagination(), this.blogVideoHeight(), this.logoPadding()
  50. },
  51. logoPadding: function() {
  52. var e = $(".wrapper.closed h1").outerHeight();
  53. window.matchMedia("(max-width: 767px)").matches && (e < 95 ? $(".nav-wrapper.anim .wrapper").css("padding-top", "95px") : $(".nav-wrapper.anim .wrapper").css("padding-top", e + "px"))
  54. },
  55. duplicateHeader: function() {
  56. var e = this.$aside.find(".container > .wrapper").clone();
  57. e.removeClass("open").addClass("closed").find(".mobile-menu-trigger").text("X").removeClass("mobile-menu-trigger").addClass("mobileMenu mobile-menu-close"), this.$aside.find(".container").append(e)
  58. },
  59. onScrollMove: function() {
  60. var e = $(document).scrollTop();
  61. "displayed" != this.left_state && (e > this.lastScrollTop + 10 && e > 55 && "displayed" == this.touchState ? (this.$aside.find(".container").addClass("hide"), this.touchState = "hidden") : e < this.lastScrollTop - 10 && "hidden" == this.touchState && (this.$aside.find(".container").removeClass("hide"), this.touchState = "displayed"), this.lastScrollTop = e)
  62. },
  63. onTouchStart: function(e) {
  64. this.touchStateY = e.originalEvent.touches[0].clientY
  65. },
  66. onTriggerClick: function() {
  67. this.$body.toggleClass("mobile-menu-opened").height($("header .wrapper").outerHeight()), this.left_state = "hidden" == this.left_state ? "displayed" : "hidden"
  68. },
  69. onCloseClick: function() {
  70. return this.$body.removeClass("mobile-menu-opened").css("height", "auto"), this.left_state = "hidden", !1
  71. },
  72. blogPagination: function() {
  73. $(".f_blog_navigation span.f_blog_body_typography").next().addClass("blog-nav-next").prev().prev().addClass("blog-nav-prev"), $(".f_blog_navigation a:first-child").addClass("first"), $(".f_blog_navigation a:last-child").addClass("last")
  74. },
  75. blogVideoHeight: function() {
  76. $("body.simple iframe").each(function() {
  77. var e = $(this),
  78. t = e.attr("height"),
  79. i = e.attr("width"),
  80. a = t / i;
  81. e.css("max-height", a * ($(window).width() - 50))
  82. })
  83. }
  84. },
  85. setHeight: function() {
  86. if ("Fixed" == _4ORMAT_DATA.theme.menu_alignment) $(".nav-wrapper").height($(window).height());
  87. else {
  88. $(".nav-wrapper>.wrapper").css("margin-top", .04 * $(window).width());
  89. var e;
  90. $("body").hasClass("gallery") ? (e = $(".assets-container").outerHeight() + parseInt($(".nav-wrapper>.wrapper").css("margin-top")) + 10, e < $(window).height() && (e = $(window).height()), $(".nav-wrapper").height(e)) : (e = $("#content").outerHeight() + parseInt($(".nav-wrapper>.wrapper").css("margin-top")) + 10, e < $(window).height() && (e = $(window).height()), $(".nav-wrapper").height(e))
  91. }
  92. }
  93. },
  94. Listing = {
  95. init: function() {
  96. $(".masonry").length && $(".masonry").masonry()
  97. },
  98. resize: function() {
  99. var e, t = $(".masonry, .grid"),
  100. i = ["two-columns", "three-columns", "four-columns", "five-columns"],
  101. a = i.join(" "),
  102. o = ["Large", "Medium", "Small", "Auto"],
  103. s = [0, 500, 700, 900],
  104. n = o.indexOf(_4ORMAT_DATA.theme.listing_thumbnail_size) + 1,
  105. l = t.width(),
  106. r = e;
  107. if (l > s[n]) e = n;
  108. else
  109. for (var d = 0; d < 3; d++)
  110. if (l >= s[d] && l <= s[d + 1]) {
  111. e = d;
  112. break
  113. }
  114. r != e && (t.removeClass(a), t.addClass(i[e]), r = e)
  115. },
  116. animationCascade: function() {
  117. "listing" == _4ORMAT_DATA.page.type && ($("._4ORMAT_content_wrapper").removeClass("content-loaded"), $(".page-asset, .title").each(function(e) {
  118. var t = $(this);
  119. setTimeout(function() {
  120. t.addClass("asset-loaded")
  121. }, 100 * e)
  122. }))
  123. }
  124. },
  125. Gallery = {
  126. HIGH_RES_IMAGE_SIZE: 1400,
  127. container: null,
  128. assets: null,
  129. gallerySize: 0,
  130. init: function() {
  131. this.gallerySize = _4ORMAT_DATA.page.assets.length, this.container = $(".assets-container"), this.assets = _4ORMAT_DATA.page.assets, "Columns" == _4ORMAT_DATA.theme.gallery_thumbnail_layout && Gallery.buildGallery(), $(document).on("lazybeforeunveil", function(e) {
  132. $(e.target).siblings(".icon").fadeIn(300);
  133. var t = $(e.target).siblings(".overlay").css("filter");
  134. $(e.target).siblings(".overlay").fadeIn(300, function() {
  135. t && $(this).css("filter", t)
  136. }), $(e.target).parent().parent().removeClass("loading")
  137. })
  138. },
  139. recalculateGallery: function() {
  140. var e, t, i, a = $(".grid-sizer").width(),
  141. o = $(".gutter-sizer").width(),
  142. s = 0,
  143. n = Math.floor(($("#content").width() + o) / a);
  144. n > 4 && (n -= 1);
  145. for (var l = new Array(n), r = new Array(n), d = 0; d < n; d++) l[d] = 0, r[d] = 0;
  146. if (null != _4ORMAT_DATA.page.title && 1 == _4ORMAT_DATA.theme.gallery_title_style) s = n, e = 0;
  147. else if (null != _4ORMAT_DATA.page.title) switch (n) {
  148. case 4:
  149. !_4ORMAT_DATA.page.title.image_url && _4ORMAT_DATA.page.title.copy ? (s = 2, $(".asset-title").width(2 * a + o)) : _4ORMAT_DATA.page.title.image_url && (s = 3, $(".asset-title").width(3 * a + 2 * o));
  150. break;
  151. case 3:
  152. !_4ORMAT_DATA.page.title.image_url && _4ORMAT_DATA.page.title.copy ? (s = 2, $(".asset-title").width(2 * a + o)) : _4ORMAT_DATA.page.title.image_url && (s = 0, $(".asset-title").width(3 * a + 2 * o));
  153. break;
  154. case 2:
  155. $(".asset-title").width(2 * a + o), s = 0, e = 0
  156. }
  157. 0 != e && (e = $(".asset-title").outerWidth() + o), t = $(".asset-title").outerHeight() + o, i = new Array(n);
  158. for (var d = 0; d < n; d++) d < s || n < 3 || 3 == n && null != _4ORMAT_DATA.page.title && _4ORMAT_DATA.page.title.image_url ? (i[d] = t, r[d] += t) : i[d] = 0;
  159. null != _4ORMAT_DATA.page.title && _4ORMAT_DATA.page.title.image_url && (2 != n ? $(".asset-title").width(3 * a + 2 * o) : $(".asset-title").width(2 * a + o)), $(".asset").not(".asset-title").width(a), s = r.indexOf(Math.min.apply(Math, r));
  160. for (var h, d = 0; d < this.gallerySize; d++) asset = $('.asset[data-asset-id="' + d + '"]'), "image" == this.assets[d].type ? (h = Helpers.calculateImageSizeW(_4ORMAT_DATA.page.assets[d].image_dimensions_300x0, a), xOffset = s * h[0] + s * o, yOffset = r[s]) : "text" == this.assets[d].type ? (h = [a, a], xOffset = s * h[0] + s * o, yOffset = r[s]) : ("vimeo" == this.assets[d].source ? h = Helpers.calculateImageSizeW([this.assets[d].video_width, this.assets[d].video_height], a) : "youtube" == this.assets[d].source && (h = Helpers.calculateImageSizeW([this.assets[d].video_width, this.assets[d].video_height], a)), xOffset = s * h[0] + s * o, yOffset = r[s]), r[s] += h[1] + o, asset.height(h[1]).css({
  161. top: yOffset,
  162. left: xOffset
  163. }), s = r.indexOf(Math.min.apply(Math, r));
  164. for (d = 0; d < n; d++) l[d] += i[d];
  165. $(".assets-container").height(Math.max.apply(Math, r)), window.lazySizes && lazySizes.autoSizer.checkElems()
  166. },
  167. buildGallery: function() {
  168. for (var e = this, t = "", i = $(".grid-sizer").width(), a = 0; a < this.gallerySize; a++) {
  169. if (asset = _4ORMAT_DATA.page.assets[a], t += '<div data-asset-id="' + a + '" class="loading asset asset-' + asset.type + '">', "image" == asset.type) {
  170. var o = asset.image_url_550x0,
  171. s = asset.image_url_300x0 + "?300 " + asset.image_dimensions_300x0[0] + "w, " + asset.image_url_400x0 + "?400 " + asset.image_dimensions_400x0[0] + "w, " + asset.image_url_550x0 + "?550 " + asset.image_dimensions_550x0[0] + "w, " + asset.image_url_700x0 + "?700 " + asset.image_dimensions_700x0[0] + "w," + asset.image_url_1200x0 + "?1200 " + asset.image_dimensions_1200x0[0] + "w";
  172. t += '<a href="#" data-asset-id="' + a + '">', t += '<img class="lazy-asset lazyload" data-sizes="auto" alt="' + asset.alt_text + '" data-srcset="' + s + '" data-src="' + o + '" nopin="true" sizes="' + i + '"/><div class="overlay"></div>', _4ORMAT_DATA.theme.gallery_image_thumbnail_icon_visibility ? t += '<i class="icon"></i></a>' : t += "</a>"
  173. } else if ("text" == asset.type) {
  174. var n = asset.copy.replace("<p>", "").replace("</p>", ""),
  175. l = n.length,
  176. r = 0;
  177. r = "Two" == _4ORMAT_DATA.theme.gallery_columns ? 200 : "Three" == _4ORMAT_DATA.theme.gallery_columns ? 100 : 60;
  178. var d = l > r ? "..." : "";
  179. t += '<a data-asset-id="' + a + '"><div class="text-plus-icon"><svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 17 17"><path fill="#000000" fill-rule="evenodd" d="M9,8 L17,8 L17,9 L9,9 L9,17 L8,17 L8,9 L0,9 L6.123234e-17,8 L8,8 L8,0 L9,0 L9,8 Z"/></svg></div><span>' + $("<div />").html(asset.copy).text().substr(0, r) + d + "</span></a>"
  180. } else t += '<a href="' + asset.iframe_url + '" data-asset-id="' + a + '">', t += '<img class="lazy-asset lazyload" data-src="' + asset.thumbnail_url_0x550 + '" nopin="true" /><div class="overlay"></div><i class="icon"></i></a>', t += '<div class="video_holder" style="">' + asset.embed + "</div>";
  181. t += "</div>"
  182. }
  183. this.container.append(t), null !== _4ORMAT_DATA.page.title && _4ORMAT_DATA.page.title.image_url ? $(".asset-title img").on("lazyloaded", function() {
  184. e.recalculateGallery()
  185. }) : setTimeout(function() {
  186. e.recalculateGallery()
  187. })
  188. }
  189. },
  190. Lightbox = {
  191. lightboxWindow: null,
  192. lightboxWindowinner: null,
  193. activeAssetId: null,
  194. init1: function() {
  195. this.bindEvents1(), this.lightboxWindow = $("#gallery_window")
  196. },
  197. init: function() {
  198. this.bindEvents(), this.lightboxWindow = $("#gallery_window")
  199. },
  200. closeCaption: function() {
  201. window.matchMedia("(max-width: 767px)").matches && $("#copy_holder").hide()
  202. },
  203. loadNextAsset: function() {
  204. $("#gallery_window").removeAttr("class"), $("#bottomGradient").remove();
  205. var e = $(".current");
  206. if (parseInt(this.activeAssetId) + 1 == Gallery.assets.length) var t = $('.asset[data-asset-id="0"] a');
  207. else var t = e.next().find("a");
  208. $(t).click(), null == $("#gallery_window").attr("class") ? ($("#copy_holder").show(), $("#bottomGradient").remove()) : this.closeCaption()
  209. },
  210. loadPrevAsset: function() {
  211. $("#gallery_window").removeAttr("class"), $("#bottomGradient").remove();
  212. var e = ($(".current"), this.activeAssetId - 1 < 0 ? Gallery.assets.length - 1 : this.activeAssetId - 1),
  213. t = $('.asset[data-asset-id="' + e + '"] a');
  214. $(t).click(), null == $("#gallery_window").attr("class") ? ($("#copy_holder").show(), $("#bottomGradient").remove()) : this.closeCaption()
  215. },
  216. close: function() {
  217. window.matchMedia("(max-width: 767px)").matches && ($("#content").show(), $("header.nav-wrapper").show()), $("#gallery_window, #overlay, .lightbox-wrapper").fadeOut(200, function() {
  218. $("body").height() > $(window).height() && $("body").css("border-right", ""), $("body").removeClass("lightbox-active")
  219. }), $("#copy_holder .inner").html(""), $("#gallery_window").find("img").remove(), $("#window_inner").html(""), $("#bottomGradient").remove(), history.pushState("", document.title, window.location.pathname), this.closeCaption()
  220. },
  221. closestEdge: function(e, t) {
  222. var i = t.getBoundingClientRect(),
  223. a = i.left,
  224. o = i.right,
  225. s = e.pageX,
  226. n = (e.pageY, Math.abs(a - s)),
  227. l = Math.abs(o - s);
  228. switch (Math.min(n, l)) {
  229. case n:
  230. return "left";
  231. case l:
  232. return "right"
  233. }
  234. },
  235. gallerySwipe: function(e) {
  236. function t(e) {
  237. return e.touches || e.originalEvent.touches
  238. }
  239.  
  240. function i(e) {
  241. if (a) {
  242. var i = t(e)[0].clientX;
  243. a - i > 0 ? Lightbox.loadNextAsset() : Lightbox.loadPrevAsset(), a = null
  244. }
  245. }
  246. $("#window_inner").on("touchmove", function(e) {
  247. i(e)
  248. });
  249. var a = null;
  250. a = t(e)[0].clientX
  251. },
  252. bindEvents1: function() {
  253. var e = this;
  254. $(".asset").not(".asset-title").on("click", "a", function(t) {
  255. return $("body").css("border-right", App.scrollerWidth), t.preventDefault(), window.location.hash = $(this).attr("data-asset-id"), $("body").hasClass("lightbox-active") ? e.loadAsset1($(this).attr("data-asset-id"), !1) : e.loadAsset1($(this).attr("data-asset-id"), !0), !1
  256. }), $(".lightbox-wrapper").scroll(function() {
  257. var e = $(".lightbox-wrapper").scrollTop();
  258. $("#gallery_window").outerHeight() + parseInt($("#gallery_window").css("top")) - $(window).height() - e < 25 ? $("#bottomGradient").removeClass("open") : $("#bottomGradient").addClass("open")
  259. }), $(document).on("click", "#bottomGradient .button", function() {
  260. $("#gallery_window").removeClass("loading"), $(this).hasClass("fade") ? ($(this).removeClass("fade"), $("body").scrollTop(0), $(".lightbox-wrapper").stop().animate({
  261. scrollTop: 0
  262. }, "slow", function() {
  263. $("#bottomGradient").removeClass("open"), $("#gallery_window").outerHeight(), $("#bottomGradient").outerHeight(), parseInt($("#gallery_window").css("top")), $(window).height()
  264. }), $("#copy_holder").fadeOut("slow")) : ($("#gallery_window").css("margin-bottom", "0px"), $("body").scrollTop(0), $(this).addClass("fade"), $("#copy_holder").fadeIn(200, function() {
  265. $(".lightbox-wrapper").stop().animate({
  266. scrollTop: $("#copy_holder").outerHeight() + 90
  267. }, "slow")
  268. }), $("#gallery_window").outerHeight() + parseInt($("#gallery_window").css("top")) > $(window).height() ? $("#bottomGradient").addClass("open") : $("#bottomGradient").removeClass("open"))
  269. }), $(".close").on("click", function(t) {
  270. t.preventDefault(), e.close1()
  271. }), $(".lightbox-wrapper").on("click", function(t) {
  272. ($(t.target).hasClass("window-wrapper") || $(t.target).hasClass("lightbox-wrapper")) && e.close1()
  273. }), $("#gallery_window").on("touchstart", function(t) {
  274. e.gallerySwipe(t)
  275. }), $("#window_inner").on("mousemove", function(t) {
  276. var i = e.closestEdge(t, this);
  277. $(this).removeClass("mouse-left mouse-right").addClass("mouse-" + i)
  278. }), $("#window_inner").on("mouseleave", function() {
  279. $(this).removeClass("mouse-left mouse-right")
  280. }), $("#window_inner").on("click", function(t) {
  281. var i = e.closestEdge(t, this);
  282. if ($(t.target).is("a")) return !0;
  283. "left" == i ? e.loadPrevAsset() : e.loadNextAsset()
  284. }), $(document).keydown(function(t) {
  285. if (Gallery.assets.length >= 1 && $("#overlay").is(":visible")) {
  286. if (37 == t.which) return Lightbox.loadPrevAsset(), !1;
  287. if (39 == t.which) return Lightbox.loadNextAsset(), !1;
  288. if (27 == t.which || 32 == t.which) return e.close(), !1
  289. }
  290. }), _4ORMAT.ImageProtection.is_enabled() && $("body").on("contextmenu", ".asset-image a[data-asset-id]", _4ORMAT.ImageProtection.trap)
  291. },
  292. loadAsset1: function(e, t) {
  293. this.activeAssetId = e;
  294. var i = Gallery.assets[e],
  295. a = i.image_dimensions_1600x1200,
  296. o = Math.round(.7 * $(window).width());
  297. $(window).height();
  298. if ($(".lightbox-wrapper").height($(window).height()), $("#copy_holder").removeClass("text"), i.copy ? ($("#copy_holder .inner").html(i.copy), $("#copy_holder").removeClass("noCopy")) : ($("#copy_holder .inner").html(""), $("#copy_holder").addClass("noCopy").css("")), $(".current").removeClass("current"), $('.asset[data-asset-id="' + e + '"]').addClass("current"), $("#window_inner").html(""), window.matchMedia("(max-width: 767px)").matches ? ($("#overlay").addClass("loading"), $(".lightbox-wrapper").addClass("tL")) : ($("#gallery_window").addClass("loading"), $(".lightbox-wrapper").removeClass("tL")), "image" == i.type) {
  299. var s = Helpers.fitImage(a, o);
  300. $("#window_inner").html('<img alt="' + i.alt_text + '" data-src="' + i.image_url_1600x1200 + '" class="lazy-asset lazyload" />'), $("#gallery_window").addClass(i.type), $("#copy_holder").hasClass("noCopy") ? $("#bottomGradient").remove() : ($("#gallery_window").append('<div id="bottomGradient"><div class="button"></div></div></div>'), $("#bottomGradient").fadeIn(), $(window).width() > $(window).height() ? ($("#bottomGradient").addClass("landscape"), $("#copy_holder").show().addClass("landscape")) : ($("#bottomGradient").removeClass("landscape"), $("#copy_holder").removeClass("landscape"))), $(".lightbox-wrapper, #overlay").fadeIn(200), $("#gallery_window").fadeIn(200), $("#copy_holder").css({
  301. bottom: -$("#copy_holder").height()
  302. }), $("#window_inner").height(s[1]), t ? ($("#gallery_window").height(s[1] + $("#copy_holder").height()), $("#gallery_window").width(s[0]), $("#gallery_window").css({
  303. "margin-left": s[0] / -2 - 54,
  304. top: $(window).height() / 2 - s[1] / 2 - 54
  305. }), Helpers.updateLightboxSpacing()) : $("#gallery_window").stop(!0, !0).animate({
  306. height: s[1] + $("#copy_holder").height(),
  307. width: s[0],
  308. "margin-left": s[0] / -2 - 54,
  309. top: $(window).height() / 2 - s[1] / 2 - 54
  310. }, function() {
  311. Helpers.updateLightboxSpacing()
  312. }), $(window).height() / 2 - s[1] / 2 - 54, $("#copy_holder").stop(!0, !0).animate({
  313. bottom: 25
  314. }), $("#copy_holder").css("margin-left", -$("#copy_holder").width() / 2);
  315. var n = parseInt($("#gallery_window").css("top"));
  316. n += 100, window.matchMedia("(max-width: 767px)").matches && ($("#copy_holder").hasClass("noCopy") ? $("#window_inner img").css("max-height", "calc(100vh - 10px") : $("#window_inner img").css("max-height", "calc(100vh - " + n + "px"))
  317. } else if ("text" == i.type) {
  318. window.matchMedia("(max-width: 767px)").matches ? $("#overlay").removeClass("loading") : $("#gallery_window").removeClass("loading"), $("#copy_holder").show().addClass("text").css({
  319. "margin-left": "",
  320. bottom: ""
  321. }), $(".lightbox-wrapper").removeClass("tL"), $("#window_inner").html("").height(""), $(".lightbox-wrapper, #overlay").fadeIn(200);
  322. var l = o > 420 ? 420 : o;
  323. $("#gallery_window").fadeIn(200), t ? ($("#gallery_window").height($("#copy_holder").height()), $("#gallery_window").width(l).css({
  324. "margin-left": l / -2 - 54,
  325. top: 60
  326. }), Helpers.updateLightboxSpacing()) : $("#gallery_window").stop(!0, !0).animate({
  327. height: $("#copy_holder").height(),
  328. width: l,
  329. "margin-left": -l / 2 - 54,
  330. top: 60
  331. }, function() {
  332. Helpers.updateLightboxSpacing()
  333. }), 60, Helpers.onlyCaptionGalleryMobile()
  334. } else s = Lightbox.getVideoSize(i), mobileDimmension = s[1] / s[0] * ($(window).width() - 50), mobileVerticalDimension = s[0] / s[1] * ($(window).height() - 100), window.matchMedia("(max-width: 767px)").matches ? $(window).width() > $(window).height() ? $("#window_inner").append('<div class="video_inner" style="width:' + mobileVerticalDimension + "px !important; height:" + mobileDimmension + 'px; max-height: calc(100vh - 100px); margin: 0 auto;">' + i.embed + "</div>") : $("#window_inner").append('<div class="video_inner" style="width:' + s[0] + "px; height:" + mobileDimmension + 'px;">' + i.embed + "</div>") : $("#window_inner").append('<div class="video_inner" style="width:' + s[0] + "px; height:" + s[1] + 'px;">' + i.embed + "</div>"), $(".lightbox-wrapper, #overlay").fadeIn(200), $("#gallery_window").addClass(i.type).fadeIn(200, function() {
  335. Helpers.captionButton()
  336. }), $("#gallery_window").removeClass("loading"), t ? ($("#gallery_window").height(s[1] + $("#copy_holder").height()), $("#gallery_window").width(s[0]), $("#gallery_window").css({
  337. "margin-left": s[0] / -2 - 54,
  338. top: $(window).height() / 2 - s[1] / 2 - 54
  339. }), Helpers.updateLightboxSpacing()) : $("#gallery_window").animate({
  340. height: s[1] + $("#copy_holder").height(),
  341. width: s[0],
  342. "margin-left": s[0] / -2 - 54,
  343. top: $(window).height() / 2 - s[1] / 2 - 54
  344. }, function() {
  345. Helpers.updateLightboxSpacing()
  346. }), $(window).height() / 2 - s[1] / 2 - 54, $("#copy_holder").css({
  347. bottom: -$("#copy_holder").height(),
  348. "margin-left": -$("#copy_holder").width() / 2
  349. }).animate({
  350. bottom: 25
  351. }).css("opacity", 1), $(".lightbox-wrapper").removeClass("tL"), $(window).width() > $(window).height() && $("#copy_holder").fadeIn();
  352. $("body").addClass("lightbox-active"), Helpers.updateLightboxSpacing()
  353. },
  354. close1: function() {
  355. window.matchMedia("(max-width: 767px)").matches && ($("#content").show(), $("header.nav-wrapper").show()), $("#gallery_window, #overlay, .lightbox-wrapper").fadeOut(200, function() {
  356. $("body").css("border-right", ""), $("body").removeClass("lightbox-active")
  357. }), $("#copy_holder .inner").html(""), $("#gallery_window").attr("class", "").find("img").remove(), $("#window_inner").html(""), $("#bottomGradient").remove(), history.pushState("", document.title, window.location.pathname), this.closeCaption()
  358. },
  359. resizeLoadedAsset: function() {
  360. var e = $("#window_inner"),
  361. t = .7 * $(window).width(),
  362. i = .8 * $(window).height();
  363. if (e.find("img").length) {
  364. var a = Helpers.fitImage(Gallery.assets[Lightbox.activeAssetId].image_dimensions_1600x1200);
  365. e.find("img").width(a[0]).height(a[1]), Helpers.setWindowGallerySize(a[0], a[1])
  366. } else if (e.find(".text_inner").length) t > 450 && (t = 450), Helpers.setWindowGallerySize(t, i);
  367. else if (e.find(".video_inner").length) {
  368. var o = Lightbox.getVideoSize(Gallery.assets[Lightbox.activeAssetId]);
  369. Helpers.setWindowGallerySize(o[0], o[1])
  370. }
  371. },
  372. getVideoSize: function(e) {
  373. var t = .7 * $(window).width(),
  374. i = $(window).height();
  375. return t / e.video_ratio > i ? [(i - 150) * e.video_ratio, i - 150] : [t, t / e.video_ratio]
  376. }
  377. },
  378. Helpers = {
  379. getScrollerWidth: function() {
  380. var e = null,
  381. t = null,
  382. i = 0,
  383. a = 0;
  384. return e = document.createElement("div"), e.style.position = "absolute", e.style.top = "-1000px", e.style.left = "-1000px", e.style.width = "100px", e.style.height = "50px", e.style.overflow = "hidden", t = document.createElement("div"), t.style.width = "100%", t.style.height = "200px", e.appendChild(t), document.body.appendChild(e), i = t.offsetWidth, e.style.overflow = "auto", a = t.offsetWidth, document.body.removeChild(document.body.lastChild), i - a
  385. },
  386. captionButton: function() {
  387. $("#copy_holder").hasClass("noCopy") ? $("#bottomGradient").remove() : ($("#gallery_window").append('<div id="bottomGradient"><div class="button"></div></div></div>'), $("#bottomGradient").fadeIn(), $(window).width() > $(window).height() ? $("#bottomGradient").addClass("landscape") : $("#bottomGradient").removeClass("landscape"))
  388. },
  389. onlyCaptionGalleryMobile: function() {
  390. window.matchMedia("(max-width: 767px)").matches && ($(window).height() > $("#copy_holder").height() ? $("#copy_holder").css({
  391. top: $(window).height() / 2 - $("#copy_holder").height() / 2 - 95
  392. }) : $("#copy_holder").css({
  393. top: 0
  394. }))
  395. },
  396. calculateImageSizeW: function(e, t) {
  397. var i, a = e[0],
  398. o = e[1];
  399. return i = a / t, o = Math.round(o / i), [t, o]
  400. },
  401. fitImage: function(e) {
  402. var t, i, a, o, s = .7 * $(window).width();
  403. s = s < 1600 ? s : 1600;
  404. var n = .8 * $(window).height();
  405. n = n < 1200 ? n : 1200;
  406. a = t = e[0], o = i = e[1];
  407. for (var l = !1; !l;) t > s ? (t = s, i = o / a * t) : i > n ? (i = n, t = a / o * i) : l = !0;
  408. return i = Math.round(i), t = Math.round(t), [t, i]
  409. },
  410. setWindowGallerySize: function(e, t) {
  411. var i = ($(window).height() - t) / 2 - 54;
  412. i < 0 && (i = 0), "text" == Gallery.assets[Lightbox.activeAssetId].type ? $("#window_inner").height("") : ($("#window_inner").height(t), $("#copy_holder").width() >= $("#window_inner").width() ? ($("#copy_holder").width($("#window_inner").width()), $("#copy_holder").css("margin-left", -$("#copy_holder").width() / 2)) : ($("#copy_holder").width(""), $("#copy_holder").css("margin-left", -$("#copy_holder").width() / 2))), 0 != $("#window_inner .video_inner").length && $("#window_inner .video_inner").height(t).width(e), $(".lightbox-wrapper").height($(window).height()), window.matchMedia("(max-width: 767px)").matches ? $("#overlay").removeClass("loading") : $("#gallery_window").removeClass("loading"), "text" == Gallery.assets[Lightbox.activeAssetId].type ? ($("#gallery_window").height(""), $("#gallery_window").stop(!0, !0).animate({
  413. width: e,
  414. "margin-left": -e / 2 - 54,
  415. top: i
  416. }, 0, function() {
  417. Helpers.updateLightboxSpacing()
  418. })) : Gallery.assets[Lightbox.activeAssetId].copy ? $("#gallery_window").stop(!0, !0).animate({
  419. width: e,
  420. height: $("#window_inner").height() + $("#copy_holder .inner").height(),
  421. "margin-left": -e / 2 - 54,
  422. top: i
  423. }, 0, function() {
  424. Helpers.updateLightboxSpacing()
  425. }) : $("#gallery_window").stop(!0, !0).animate({
  426. width: e,
  427. height: $("#window_inner").height(),
  428. "margin-left": -e / 2 - 54,
  429. top: i
  430. }, 0, function() {
  431. Helpers.updateLightboxSpacing(), $(this).find("img, .text_inner, .video_inner").animate({
  432. opacity: 1
  433. })
  434. })
  435. },
  436. updateLightboxSpacing: function() {
  437. $("#gallery_window").outerHeight() + $("#gallery_window").position().top > $(window).height() ? $(".lightbox-wrapper .window-wrapper").height($("#gallery_window").outerHeight() + $("#gallery_window").position().top).css("margin-bottom", $("#gallery_window").position().top) : $(".lightbox-wrapper .window-wrapper").height("")
  438. }
  439. };
  440. $(function() {
  441. "use strict";
  442. App.init()
  443. }), $(window).resize(function() {
  444. Listing.resize()
  445. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement