mirror of
https://github.com/a2nt/meta-lightbox.git
synced 2024-10-22 17:05:53 +02:00
3 lines
11 KiB
JavaScript
3 lines
11 KiB
JavaScript
/*! For license information please see app.js.LICENSE.txt */
|
|
!function(t){var e={};function o(a){if(e[a])return e[a].exports;var i=e[a]={i:a,l:!1,exports:{}};return t[a].call(i.exports,i,i.exports,o),i.l=!0,i.exports}o.m=t,o.c=e,o.d=function(t,e,a){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},o.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(o.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(a,i,function(e){return t[e]}.bind(null,i));return a},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="/mnt/data/srv/dist/repositories/meta-lightbox/dist",o(o.s="./src/js/app.js")}({"./src/js/app.js":function(t,e,o){"use strict";o.r(e);o("./src/scss/app.scss"),o("./src/js/meta-lightbox.js")},"./src/js/meta-lightbox.js":function(t,e){function o(t){return(o="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t,e,a){var i={effect:"fade",theme:"default",keyboardNav:!0,clickOverlayToClose:!0,onInit:function(){},beforeShowLightbox:function(){},afterShowLightbox:function(t){},beforeHideLightbox:function(){},afterHideLightbox:function(){},onPrev:function(t){},onNext:function(t){},errorMessage:"The requested content cannot be loaded. Please try again later."};function n(e,o){this.options=t.extend({},i,o),this._defaults=i,this._name="metaLightbox",this.init()}n.prototype={init:function(){var e=this,o=t("html");this.ajaxLoaded=!1,a.MetaLightbox=this,o.hasClass("meta-lightbox-notouch")||o.addClass("meta-lightbox-notouch"),"ontouchstart"in a&&o.removeClass("meta-lightbox-notouch"),t(a).on("click",'[data-toggle="lightbox"],[data-lightbox-gallery]',(function(t){return t.preventDefault(),t.stopPropagation(),e.showLightbox(this),!1})),this.options.keyboardNav&&t("body").off("keyup").on("keyup",(function(o){var a=o.keyCode?o.keyCode:o.which;27===a&&e.destructLightbox(),37===a&&t(".meta-lightbox-prev").trigger("click"),39===a&&t(".meta-lightbox-next").trigger("click")})),this.options.onInit.call(this)},showLightbox:function(e){this.el=e,this.$el=t(this.el);var o,a,i,n,s=this;this.options.beforeShowLightbox.call(this),(o=this.constructLightbox())&&(a=o.find(".meta-lightbox-content"))&&(i=this.$el,t("body").addClass("meta-lightbox-body-effect-".concat(this.options.effect)),this.processContent(a,i),this.$el.data("lightbox-gallery")&&(1===(n=t('[data-lightbox-gallery="'.concat(this.$el.data("lightbox-gallery"),'"]'))).length?t(".meta-lightbox-nav").hide():t(".meta-lightbox-nav").show(),t(".meta-lightbox-prev").off("click").on("click",(function(e){e.preventDefault();var o=n.index(i);i=n.eq(o-1),t(i).length||(i=n.last()),s.processContent(a,i),s.options.onPrev.call(this,[i])})),t(".meta-lightbox-next").off("click").on("click",(function(e){e.preventDefault();var o=n.index(i);i=n.eq(o+1),t(i).length||(i=n.first()),s.processContent(a,i),s.options.onNext.call(this,[i])}))),setTimeout((function(){o.addClass("meta-lightbox-open"),s.options.afterShowLightbox.call(this,[o])}),1))},processContent:function(i,n){var s,l,r,c,h,g,f=this;href=n.attr("href"),href||(href=n.data("href")),i.html("").addClass("meta-lightbox-loading"),this.isHidpi()&&n.data("lightbox-hidpi")&&(href=n.data("lightbox-hidpi")),null!=href.match(/\.(jpeg|jpg|gif|png)$/i)?((s=t("<img>",{src:href})).on("load",(function(){var o=t('<div class="meta-lightbox-image"></div>'),a=t(".meta-lightbox-content"),n=t('<span class="meta-lightbox-zoom-wrapper"></span>');n.append(s),o.append(n),o.css({"line-height":"".concat(a.height(),"px"),height:"".concat(a.height(),"px")}),t(e).resize((function(){o.css({"line-height":"".concat(a.height(),"px"),height:"".concat(a.height(),"px")})})),"undefined"!==typeof n.zoom&&n.zoom(),i.html(o).removeClass("meta-lightbox-loading"),f.contentLoaded()})),s.on("error",(function(){var e=t('<div class="meta-lightbox-error"><p>'.concat(f.options.errorMessage,"</p></div>"));i.html(e).removeClass("meta-lightbox-loading"),f.contentLoaded()})),n.data("title")?f.setTitle(n.data("title")):n.attr("title")?f.setTitle(n.attr("title")):t(".meta-lightbox-title-wrap").html(""),"function"===typeof ga&&ga("send","event","meta","Image Click",href)):(l=href.match(/(youtube|youtube-nocookie|youtu|vimeo)\.(com|be)\/(watch\?v=([\w-]+)|([\w-]+))/))?(r="",c="meta-lightbox-video","youtube"==l[1]&&(r="https://www.youtube.com/embed/".concat(l[4]),c="meta-lightbox-youtube"),"youtu"==l[1]&&(r="https://www.youtube.com/embed/".concat(l[3]),c="meta-lightbox-youtube"),"youtube-nocookie"==l[1]&&(r="https://www.youtube-nocookie.com/embed/".concat(l[4]),c="nivo-lightbox-youtube"),"vimeo"==l[1]&&(r="https://player.vimeo.com/video/".concat(l[3]),c="meta-lightbox-vimeo"),r&&(h=t("<iframe>",{src:r,class:c,frameborder:0,vspace:0,hspace:0,scrolling:"auto"}),i.html(h),h.on("load",(function(){i.removeClass("meta-lightbox-loading"),f.contentLoaded()}))),n.data("title")?f.setTitle(n.data("title")):n.attr("title")?f.setTitle(n.attr("title")):t(".meta-lightbox-title-wrap").html(""),"function"===typeof ga&&ga("send","event","meta","Video Click",l)):"#"==href.substring(0,1)?(t(href).length?((g=t('<div class="meta-lightbox-inline" />')).append(t(href).clone().show()),g.outerHeight()<i.height()&&g.css({position:"relative",top:"50%","margin-top":"".concat(-g.outerHeight()/2,"px")}),t(e).resize((function(){g.outerHeight()<i.height()&&g.css({position:"relative",top:"50%","margin-top":"".concat(-g.outerHeight()/2,"px")})})),i.html(g).removeClass("meta-lightbox-loading"),f.contentLoaded()):(g=t('<div class="meta-lightbox-error"><p>'.concat(f.options.errorMessage,"</p></div>")),i.html(g).removeClass("meta-lightbox-loading"),f.contentLoaded()),t(".meta-lightbox-title-wrap").html(""),"function"===typeof ga&&ga("send","event","meta","inline HTML click",href)):t.ajax({sync:!1,async:!0,url:href,dataType:"html",method:"GET",cache:!1,statusCode:{404:function(){console.log("page not found"),e.location.href=url},302:function(){console.log("redirect 302"),e.location.href=url}},error:function(e){console.log("AJAX request failure.".concat(e.statusText));var o=t('<div class="meta-lightbox-error"><p>'.concat(f.options.errorMessage,"</p></div>"));i.html(o).removeClass("meta-lightbox-loading"),f.contentLoaded(),"function"===typeof ga&&ga("send","event","error","AJAX ERROR",e.statusText)},success:function(n,s,l){try{var r=t.parseJSON(n);if("object"===o(r)){if("object"===o(r.regions)&&"undefinded"!==typeof r.regions.LayoutAjax)(g=t('<div class="meta-lightbox-ajax" />')).html(r.regions.LayoutAjax),i.html(g).removeClass("meta-lightbox-loading");var c=l.getResponseHeader("X-Title"),h=l.getResponseHeader("X-Link");c&&c.length&&h&&h.length&&h!==e.location.href&&h.substring(0,h.indexOf("#"))!==e.location.href.replace(t("base").attr("href"),"/")&&(t(".meta-lightbox-ajax").data("curr-title",a.title),t(".meta-lightbox-ajax").data("curr-link",e.location.href),"undefined"!==typeof e.localStorage&&"/"!==h&&e.localStorage.setItem("current-page",h),a.URL!==h&&a.URL!==t("base").attr("href")+h&&a.URL!=="".concat(t("base").attr("href"),"/").concat(h)&&e.history.pushState({title:c,page:h,ajax:"true"},c,h),t(".meta-lightbox-title-wrap").html(""),"function"===typeof ga&&(ga("set",{page:h.replace(t("base").attr("href"),""),title:c}),ga("send","pageview")))}}catch(d){var g;(g=t('<div class="meta-lightbox-ajax" />')).append(n),i.html(g).removeClass("meta-lightbox-loading")}g.outerHeight()<i.height()&&g.css({position:"relative",top:"50%","margin-top":"".concat(-g.outerHeight()/2,"px")}),t(e).resize((function(){g.outerHeight()<i.height()&&g.css({position:"relative",top:"50%","margin-top":"".concat(-g.outerHeight()/2,"px")})})),setTimeout((function(){t(e).resize(),"function"===typeof e.imagesLoaded&&e.imagesLoaded().then((function(){t(e).resize()}))}),500),f.contentLoaded()}})},setTitle:function(e){var o=t("<div>",{class:"meta-lightbox-title"});o.text(e),t(".meta-lightbox-title-wrap").html(o)},contentLoaded:function(){setTimeout((function(){t(e).trigger("meta-lightbox-loaded")}),1),setTimeout((function(){t("body").addClass("meta-lightbox-body-effect-fade")}),600)},constructLightbox:function(){var e=this,o=t("<div>",{class:"meta-lightbox-overlay meta-lightbox-theme-".concat(this.options.theme," meta-lightbox-effect-").concat(this.options.effect)}),a=t("<div>",{class:"meta-lightbox-wrap"}),i=t("<div>",{class:"meta-lightbox-content"}),n=t('<a href="#" class="meta-lightbox-nav meta-lightbox-prev"><i class="fas fa fa-chevron-left"></i> <span class="sr-only">Previous</span></a><a href="#" class="meta-lightbox-nav meta-lightbox-next"><i class="fa fas fa-chevron-right"></i> <span class="sr-only">Next</span></a>'),s=t('<a href="#" class="meta-lightbox-close fas fa fa-times" title="Close"><span class="sr-only">Close</span></a>'),l=t("<div>",{class:"meta-lightbox-title-wrap"}),r=t(".meta-lightbox-overlay");return r.length?r:(a.append(i),a.append(l),o.append(a),o.append(n),o.append(s),t("body").append(o),e.options.clickOverlayToClose&&o.on("click",(function(o){var a=t(o.target);(a.hasClass("meta-lightbox-zoom-wrapper")||a.hasClass("meta-lightbox-content")||a.hasClass("meta-lightbox-wrap")||a.hasClass("meta-lightbox-image")||a.hasClass("meta-lightbox-overlay"))&&e.destructLightbox()})),s.on("click",(function(t){t.preventDefault(),e.destructLightbox()})),o)},destructLightbox:function(){var o=t(".meta-lightbox-overlay");this.options.beforeHideLightbox.call(this);var i=t(".meta-lightbox-ajax").data("curr-title"),n=t(".meta-lightbox-ajax").data("curr-link");i&&n&&("undefined"!==typeof e.localStorage&&"/"!==n&&e.localStorage.setItem("current-page",n),a.URL!==n&&a.URL!==t("base").attr("href")+n&&a.URL!=="".concat(t("base").attr("href"),"/").concat(n)&&e.history.replaceState({title:i,page:n,ajax:"true"},i,n)),o.removeClass("meta-lightbox-open"),t(".meta-lightbox-nav").hide(),t("body").removeClass("meta-lightbox-body-effect-".concat(this.options.effect)),t(".meta-lightbox-content .meta-lightbox-zoom-wrapper").trigger("zoom.destroy"),t(".meta-lightbox-prev").off("click"),t(".meta-lightbox-next").off("click"),t(".meta-lightbox-content").empty(),t("body").removeClass("meta-lightbox-body-effect-fade"),this.options.afterHideLightbox.call(this)},isHidpi:function(){return e.devicePixelRatio>1||e.matchMedia&&e.matchMedia("(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)").matches}},t.fn.metaLightbox=function(e){return this.each((function(){t.data(this,"metaLightbox")||t.data(this,"metaLightbox",new n(this,e))}))},t(a).metaLightbox()}(jQuery,this,document)},"./src/scss/app.scss":function(t,e,o){}});
|
|
//# sourceMappingURL=app.js.map
|