syriastreet.com/assets/js/lib/remodal.js

1 line
7.1 KiB
JavaScript
Raw Normal View History

2023-10-06 21:29:45 +00:00
!function(n,e){"function"==typeof define&&define.amd?define(["jquery"],function(t){return e(n,t)}):"object"==typeof exports?e(n,require("jquery")):e(n,n.jQuery||n.Zepto)}(this,function(t,s){"use strict";var o,r,d="remodal",i=t.REMODAL_GLOBALS&&t.REMODAL_GLOBALS.NAMESPACE||d,c=s.map(["animationstart","webkitAnimationStart","MSAnimationStart","oAnimationStart"],function(t){return t+"."+i}).join(" "),l=s.map(["animationend","webkitAnimationEnd","MSAnimationEnd","oAnimationEnd"],function(t){return t+"."+i}).join(" "),p=s.extend({hashTracking:!0,closeOnConfirm:!0,closeOnCancel:!0,closeOnEscape:!0,closeOnOutsideClick:!0,modifier:"",appendTo:null},t.REMODAL_GLOBALS&&t.REMODAL_GLOBALS.DEFAULTS),m={CLOSING:"closing",CLOSED:"closed",OPENING:"opening",OPENED:"opened"},u="confirmation",f="cancellation",g=void 0!==(t=document.createElement("div").style).animationName||void 0!==t.WebkitAnimationName||void 0!==t.MozAnimationName||void 0!==t.msAnimationName||void 0!==t.OAnimationName,h=/iPad|iPhone|iPod/.test(navigator.platform);function v(t){if(g&&"none"===t.css("animation-name")&&"none"===t.css("-webkit-animation-name")&&"none"===t.css("-moz-animation-name")&&"none"===t.css("-o-animation-name")&&"none"===t.css("-ms-animation-name"))return 0;for(var n,e=t.css("animation-duration")||t.css("-webkit-animation-duration")||t.css("-moz-animation-duration")||t.css("-o-animation-duration")||t.css("-ms-animation-duration")||"0s",a=t.css("animation-delay")||t.css("-webkit-animation-delay")||t.css("-moz-animation-delay")||t.css("-o-animation-delay")||t.css("-ms-animation-delay")||"0s",i=t.css("animation-iteration-count")||t.css("-webkit-animation-iteration-count")||t.css("-moz-animation-iteration-count")||t.css("-o-animation-iteration-count")||t.css("-ms-animation-iteration-count")||"1",e=e.split(", "),a=a.split(", "),i=i.split(", "),o=0,s=e.length,r=Number.NEGATIVE_INFINITY;o<s;o++)r<(n=parseFloat(e[o])*parseInt(i[o],10)+parseFloat(a[o]))&&(r=n);return r}function $(){var t,n,e;return s(document.body).height()<=s(window).height()?0:(t=document.createElement("div"),e=document.createElement("div"),t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t),n=t.offsetWidth,t.style.overflow="scroll",e.style.width="100%",t.appendChild(e),e=e.offsetWidth,t.parentNode.removeChild(t),n-e)}function a(){var t,n,e,a;h||(t=s("html"),n=E("is-locked"),t.hasClass(n)&&(a=s(document.body),e=parseInt(a.css("padding-right"),10)-$(),a.css("padding-right",e+"px"),t.removeClass(n)))}function C(t,n,e,a){var i=E("is",n),o=[E("is",m.CLOSING),E("is",m.OPENING),E("is",m.CLOSED),E("is",m.OPENED)].join(" ");t.$bg.removeClass(o).addClass(i),t.$overlay.removeClass(o).addClass(i),t.$wrapper.removeClass(o).addClass(i),t.$modal.removeClass(o).addClass(i),t.state=n,e||t.$modal.trigger({type:n,reason:a},[{reason:a}])}function y(t,n,e){function a(t){t.target===this&&o++}function i(t){t.target===this&&0==--o&&(s.each(["$bg","$overlay","$wrapper","$modal"],function(t,n){e[n].off(c+" "+l)}),n())}var o=0;s.each(["$bg","$overlay","$wrapper","$modal"],function(t,n){e[n].on(c,a).on(l,i)}),t(),0===v(e.$bg)&&0===v(e.$overlay)&&0===v(e.$wrapper)&&0===v(e.$modal)&&(s.each(["$bg","$overlay","$wrapper","$modal"],function(t,n){e[n].off(c+" "+l)}),n())}function O(e){e.state!==m.CLOSED&&(s.each(["$bg","$overlay","$wrapper","$modal"],function(t,n){e[n].off(c+" "+l)}),e.$bg.removeClass(e.settings.modifier),e.$overlay.removeClass(e.settings.modifier).hide(),e.$wrapper.hide(),a(),C(e,m.CLOSED,!0))}function E(){for(var t=i,n=0;n<arguments.length;++n)t+="-"+arguments[n];return t}function n(){var t,n=location.hash.replace("#","");if(n){try{t=s("[data-"+d+'-id="'+n+'"]')}catch(t){}t&&t.length&&(n=s[d].lookup[t.data(d)])&&n.settings.hashTracking&&n.open()}else o&&o.state===m.OPENED&&o.settings.hashTracking&&o.close()}function w(t,n){var e=s(document.body),a=this;a.settings=s.extend({},p,n),a.index=s[d].lookup.push(a)-1,a.state=m.CLOSED,a.$overlay=s("."+E("overlay")),null!==a.settings.appendTo&&a.settings.appendTo.length&&(e=s(a.settings.appendTo)),a.$overlay.length||(a.$overlay=s("<div>"