policybot/fassets/js/plugins.lightbox.js

249 lines
26 KiB
JavaScript
Raw Normal View History

2021-11-30 10:56:55 +00:00
/*! Magnific Popup - v1.1.0 - 2016-02-20
* http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2016 Dmitry Semenov; */
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(window.jQuery||window.Zepto)}(function(e){var t,i,n,o,a,r,s=function(){},l=!!window.jQuery,c=e(window),d=function(e,i){t.ev.on("mfp"+e+".mfp",i)},p=function(t,i,n,o){var a=document.createElement("div");return a.className="mfp-"+t,n&&(a.innerHTML=n),o?i&&i.appendChild(a):(a=e(a),i&&a.appendTo(i)),a},u=function(i,n){t.ev.triggerHandler("mfp"+i,n),t.st.callbacks&&(i=i.charAt(0).toLowerCase()+i.slice(1),t.st.callbacks[i]&&t.st.callbacks[i].apply(t,e.isArray(n)?n:[n]))},f=function(i){return i===r&&t.currTemplate.closeBtn||(t.currTemplate.closeBtn=e(t.st.closeMarkup.replace("%title%",t.st.tClose)),r=i),t.currTemplate.closeBtn},m=function(){e.magnificPopup.instance||((t=new s).init(),e.magnificPopup.instance=t)};s.prototype={constructor:s,init:function(){var i=navigator.appVersion;t.isLowIE=t.isIE8=document.all&&!document.addEventListener,t.isAndroid=/android/gi.test(i),t.isIOS=/iphone|ipad|ipod/gi.test(i),t.supportsTransition=function(){var e=document.createElement("p").style,t=["ms","O","Moz","Webkit"];if(void 0!==e.transition)return!0;for(;t.length;)if(t.pop()+"Transition"in e)return!0;return!1}(),t.probablyMobile=t.isAndroid||t.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),n=e(document),t.popupsCache={}},open:function(i){var o;if(!1===i.isObj){t.items=i.items.toArray(),t.index=0;var r,s=i.items;for(o=0;o<s.length;o++)if((r=s[o]).parsed&&(r=r.el[0]),r===i.el[0]){t.index=o;break}}else t.items=e.isArray(i.items)?i.items:[i.items],t.index=i.index||0;if(!t.isOpen){t.types=[],a="",i.mainEl&&i.mainEl.length?t.ev=i.mainEl.eq(0):t.ev=n,i.key?(t.popupsCache[i.key]||(t.popupsCache[i.key]={}),t.currTemplate=t.popupsCache[i.key]):t.currTemplate={},t.st=e.extend(!0,{},e.magnificPopup.defaults,i),t.fixedContentPos="auto"===t.st.fixedContentPos?!t.probablyMobile:t.st.fixedContentPos,t.st.modal&&(t.st.closeOnContentClick=!1,t.st.closeOnBgClick=!1,t.st.showCloseBtn=!1,t.st.enableEscapeKey=!1),t.bgOverlay||(t.bgOverlay=p("bg").on("click.mfp",function(){t.close()}),t.wrap=p("wrap").attr("tabindex",-1).on("click.mfp",function(e){t._checkIfClose(e.target)&&t.close()}),t.container=p("container",t.wrap)),t.contentContainer=p("content"),t.st.preloader&&(t.preloader=p("preloader",t.container,t.st.tLoading));var l=e.magnificPopup.modules;for(o=0;o<l.length;o++){var m=l[o];m=m.charAt(0).toUpperCase()+m.slice(1),t["init"+m].call(t)}u("BeforeOpen"),t.st.showCloseBtn&&(t.st.closeBtnInside?(d("MarkupParse",function(e,t,i,n){i.close_replaceWith=f(n.type)}),a+=" mfp-close-btn-in"):t.wrap.append(f())),t.st.alignTop&&(a+=" mfp-align-top"),t.fixedContentPos?t.wrap.css({overflow:t.st.overflowY,overflowX:"hidden",overflowY:t.st.overflowY}):t.wrap.css({top:c.scrollTop(),position:"absolute"}),(!1===t.st.fixedBgPos||"auto"===t.st.fixedBgPos&&!t.fixedContentPos)&&t.bgOverlay.css({height:n.height(),position:"absolute"}),t.st.enableEscapeKey&&n.on("keyup.mfp",function(e){27===e.keyCode&&t.close()}),c.on("resize.mfp",function(){t.updateSize()}),t.st.closeOnContentClick||(a+=" mfp-auto-cursor"),a&&t.wrap.addClass(a);var g=t.wH=c.height(),v={};if(t.fixedContentPos&&t._hasScrollBar(g)){var h=t._getScrollbarSize();h&&(v.marginRight=h)}t.fixedContentPos&&(t.isIE7?e("body, html").css("overflow","hidden"):v.overflow="hidden");var C=t.st.mainClass;return t.isIE7&&(C+=" mfp-ie7"),C&&t._addClassToMFP(C),t.updateItemHTML(),u("BuildControls"),e("html").css(v),t.bgOverlay.add(t.wrap).prependTo(t.st.prependTo||e(document.body)),t._lastFocusedEl=document.activeElement,setTimeout(function(){t.content?(t._addClassToMFP("mfp-ready"),t._setFocus()):t.bgOverlay.addClass("mfp-ready"),n.on("focusin.mfp",t._onFocusIn)},16),t.isOpen=!0,t.updateSize(g),u("Open"),i}t.updateItemHTML()},close:function(){t.isOpen&&(u("BeforeClose"),t.isOpen=!1,t.st.removalDelay&&!t.isLowIE&&t.supportsTransition?(t._addClassToMFP("mfp-removing"),setTimeout(function(){t._close()},t.st.removalDelay)):t._close())},_close:function(){u("
window.SEMICOLON_lightboxInit = function( $lightboxEl ){
$lightboxEl = $lightboxEl.filter(':not(.customjs)');
if( $lightboxEl.length < 1 ){
return true;
}
$lightboxEl.each( function(){
let element = $(this),
elType = element.attr('data-lightbox'),
elCloseButton = element.attr('data-close-button') || 'outside',
elDisableUnder = element.attr('data-disable-under') || 600,
$body = $('body');
if( elCloseButton == 'inside' ) {
elCloseButton = true;
} else {
elCloseButton = false;
}
if( elType == 'image' ) {
element.magnificPopup({
type: 'image',
closeOnContentClick: true,
closeBtnInside: elCloseButton,
fixedContentPos: true,
mainClass: 'mfp-no-margins mfp-fade', // class to remove default margin from left and right side
image: {
verticalFit: true
}
});
}
if( elType == 'gallery' ) {
if( element.find('a[data-lightbox="gallery-item"]').parent('.clone').hasClass('clone') ) {
element.find('a[data-lightbox="gallery-item"]').parent('.clone').find('a[data-lightbox="gallery-item"]').attr('data-lightbox','');
}
if( element.find('a[data-lightbox="gallery-item"]').parents('.cloned').hasClass('cloned') ) {
element.find('a[data-lightbox="gallery-item"]').parents('.cloned').find('a[data-lightbox="gallery-item"]').attr('data-lightbox','');
}
element.magnificPopup({
delegate: 'a[data-lightbox="gallery-item"]',
type: 'image',
closeOnContentClick: true,
closeBtnInside: elCloseButton,
fixedContentPos: true,
mainClass: 'mfp-no-margins mfp-fade', // class to remove default margin from left and right side
image: {
verticalFit: true
},
gallery: {
enabled: true,
navigateByImgClick: true,
preload: [0,1] // Will preload 0 - before current, and 1 after the current image
}
});
}
if( elType == 'iframe' ) {
element.magnificPopup({
disableOn: Number( elDisableUnder ),
type: 'iframe',
removalDelay: 160,
preloader: false,
fixedContentPos: false
});
}
if( elType == 'inline' ) {
element.magnificPopup({
type: 'inline',
mainClass: 'mfp-no-margins mfp-fade',
closeBtnInside: elCloseButton,
fixedContentPos: true,
overflowY: 'scroll'
});
}
if( elType == 'ajax' ) {
element.magnificPopup({
type: 'ajax',
closeBtnInside: elCloseButton,
autoFocusLast: false,
callbacks: {
ajaxContentAdded: function(mfpResponse) {
SEMICOLON.widget.loadFlexSlider();
SEMICOLON.initialize.resizeVideos();
SEMICOLON.widget.masonryThumbs();
},
open: function() {
$body.addClass('ohidden');
},
close: function() {
$body.removeClass('ohidden');
}
}
});
}
if( elType == 'ajax-gallery' ) {
element.magnificPopup({
delegate: 'a[data-lightbox="ajax-gallery-item"]',
type: 'ajax',
closeBtnInside: elCloseButton,
autoFocusLast: false,
gallery: {
enabled: true,
preload: 0,
navigateByImgClick: false
},
callbacks: {
ajaxContentAdded: function(mfpResponse) {
SEMICOLON.widget.loadFlexSlider();
SEMICOLON.initialize.resizeVideos();
SEMICOLON.widget.masonryThumbs();
},
open: function() {
$body.addClass('ohidden');
},
close: function() {
$body.removeClass('ohidden');
}
}
});
}
element.on( 'mfpOpen', function(){
let lightboxItem = $.magnificPopup.instance.currItem.el,
lightboxClass = $( lightboxItem ).attr('data-lightbox-class'),
lightboxBgClass = $( lightboxItem ).attr('data-lightbox-bg-class');
if( lightboxClass != '' ) {
$( $.magnificPopup.instance.container ).addClass( lightboxClass );
}
if( lightboxBgClass != '' ) {
$( $.magnificPopup.instance.bgOverlay ).addClass( lightboxBgClass );
}
});
});
};
window.SEMICOLON_modalInit = function( $modalEl ){
$modalEl = $modalEl.filter(':not(.customjs)');
if( $modalEl.length < 1 ){
return true;
}
$modalEl.each( function(){
let element = $(this),
elTarget = element.attr('data-target'),
elTargetValue = elTarget.split('#')[1],
elDelay = element.attr('data-delay') || 500,
elTimeout = element.attr('data-timeout'),
elAnimateIn = element.attr('data-animate-in'),
elAnimateOut = element.attr('data-animate-out'),
elBgClick = element.attr('data-bg-click'),
elCloseBtn = element.attr('data-close-btn'),
elCookies = element.attr('data-cookies'),
elCookiePath = element.attr('data-cookie-path'),
elCookieExp = element.attr('data-cookie-expire');
if( elCookies == "false" ) { Cookies.remove( elTargetValue ); }
if( elCookies == 'true' ) {
let elementCookie = Cookies.get( elTargetValue );
if( typeof elementCookie !== 'undefined' && elementCookie == '0' ) {
return true;
}
}
if( elBgClick == 'false' ) {
elBgClick = false;
} else {
elBgClick = true;
}
if( elCloseBtn == 'false' ) {
elCloseBtn = false;
} else {
elCloseBtn = true;
}
elDelay = Number(elDelay) + 500;
setTimeout(function() {
$.magnificPopup.open({
items: { src: elTarget },
type: 'inline',
mainClass: 'mfp-no-margins mfp-fade',
closeBtnInside: false,
fixedContentPos: true,
closeOnBgClick: elBgClick,
showCloseBtn: elCloseBtn,
removalDelay: 500,
callbacks: {
open: function(){
if( elAnimateIn != '' ) {
$(elTarget).addClass( elAnimateIn + ' animated' );
}
},
beforeClose: function(){
if( elAnimateOut != '' ) {
$(elTarget).removeClass( elAnimateIn ).addClass( elAnimateOut );
}
},
afterClose: function() {
if( elAnimateIn != '' || elAnimateOut != '' ) {
$(elTarget).removeClass( elAnimateIn + ' ' + elAnimateOut + ' animated' );
}
if( elCookies == 'true' ) {
let cookieOps = {};
if( elCookieExp ) {
cookieOps.expires = Number( elCookieExp );
}
if( elCookiePath ) {
cookieOps.path = elCookiePath;
}
Cookies.set( elTargetValue, '0', cookieOps );
}
}
}
}, 0);
}, elDelay );
if( elTimeout != '' ) {
setTimeout(function() {
$.magnificPopup.close();
}, elDelay + Number(elTimeout) );
}
});
};