3 lines
17 KiB
JavaScript
3 lines
17 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./foundation.core.utils"),require("./foundation.core"),require("jquery"),require("./foundation.util.keyboard"),require("./foundation.util.mediaQuery"),require("./foundation.util.motion"),require("./foundation.core.plugin")):"function"==typeof define&&define.amd?define(["./foundation.core.utils","./foundation.core","jquery","./foundation.util.keyboard","./foundation.util.mediaQuery","./foundation.util.motion","./foundation.core.plugin"],t):"object"==typeof exports?exports["foundation.reveal"]=t(require("./foundation.core.utils"),require("./foundation.core"),require("jquery"),require("./foundation.util.keyboard"),require("./foundation.util.mediaQuery"),require("./foundation.util.motion"),require("./foundation.core.plugin")):(e.__FOUNDATION_EXTERNAL__=e.__FOUNDATION_EXTERNAL__||{},e.__FOUNDATION_EXTERNAL__["foundation.reveal"]=t(e.__FOUNDATION_EXTERNAL__["foundation.core"],e.__FOUNDATION_EXTERNAL__["foundation.core"],e.jQuery,e.__FOUNDATION_EXTERNAL__["foundation.util.keyboard"],e.__FOUNDATION_EXTERNAL__["foundation.util.mediaQuery"],e.__FOUNDATION_EXTERNAL__["foundation.util.motion"],e.__FOUNDATION_EXTERNAL__["foundation.core"]))}(window,function(i,n,o,s,r,a,l){return function(i){var n={};function o(e){if(n[e])return n[e].exports;var t=n[e]={i:e,l:!1,exports:{}};return i[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=i,o.c=n,o.d=function(e,t,i){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__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 i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(i,n,function(e){return t[e]}.bind(null,n));return i},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=14)}({"./foundation.core":function(e,t){e.exports=n},"./foundation.core.plugin":function(e,t){e.exports=l},"./foundation.core.utils":function(e,t){e.exports=i},"./foundation.util.keyboard":function(e,t){e.exports=s},"./foundation.util.mediaQuery":function(e,t){e.exports=r},"./foundation.util.motion":function(e,t){e.exports=a},"./js/entries/plugins/foundation.reveal.js":function(e,t,i){"use strict";i.r(t);var n=i("./foundation.core");i.d(t,"Foundation",function(){return n.Foundation});var o=i("./js/foundation.reveal.js");i.d(t,"Reveal",function(){return o.Reveal}),n.Foundation.plugin(o.Reveal,"Reveal")},"./js/foundation.reveal.js":function(e,t,i){"use strict";i.r(t),i.d(t,"Reveal",function(){return v});var n=i("jquery"),r=i.n(n),s=i("./foundation.core.utils"),a=i("./foundation.util.keyboard"),l=i("./foundation.util.mediaQuery"),c=i("./foundation.util.motion"),u=i("./foundation.core.plugin"),d=i("./js/foundation.util.triggers.js");function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function h(e,t){return!t||"object"!==o(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var v=function(e){function i(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),h(this,p(i).apply(this,arguments))}var t,n,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&g(e,t)}(i,u["Plugin"]),t=i,(n=[{key:"_setup",value:function(e,t){this.$element=e,this.options=r.a.extend({},i.defaults,this.$element.data(),t),this.className="Reveal",this._init(),d.Triggers.init(r.a),a.Keyboard.register("Reveal",{ESCAPE:"close"})}},{key:"_init",value:function(){var e=this;l.MediaQuery._init(),this.id=this.$element.attr("id"),this.isActive=!1,this.cached={mq:l.MediaQuery.current},this.$anchor=r()('[data-open="'.concat(this.id,'"]')).length?r()('[data-open="'.concat(this.id,'"]')):r()('[data-toggle="'.concat(this.id,'"]')),this.$anchor.attr({"aria-controls":this.id,"aria-haspopup":!0,tabindex:0}),(this.options.fullScreen||this.$element.hasClass("full"))&&(this.options.fullScreen=!0,this.options.overlay=!1),this.options.overlay&&!this.$overlay&&(this.$overlay=this._makeOverlay(this.id)),this.$element.attr({role:"dialog","aria-hidden":!0,"data-yeti-box":this.id,"data-resize":this.id}),this.$overlay?this.$element.detach().appendTo(this.$overlay):(this.$element.detach().appendTo(r()(this.options.appendTo)),this.$element.addClass("without-overlay")),this._events(),this.options.deepLink&&window.location.hash==="#".concat(this.id)&&(this.onLoadListener=Object(s.onLoad)(r()(window),function(){return e.open()}))}},{key:"_makeOverlay",value:function(){var e="";return this.options.additionalOverlayClasses&&(e=" "+this.options.additionalOverlayClasses),r()("<div></div>").addClass("reveal-overlay"+e).appendTo(this.options.appendTo)}},{key:"_updatePosition",value:function(){var e,t=this.$element.outerWidth(),i=r()(window).width(),n=this.$element.outerHeight(),o=r()(window).height(),s=null;e="auto"===this.options.hOffset?parseInt((i-t)/2,10):parseInt(this.options.hOffset,10),"auto"===this.options.vOffset?s=o<n?parseInt(Math.min(100,o/10),10):parseInt((o-n)/4,10):null!==this.options.vOffset&&(s=parseInt(this.options.vOffset,10)),null!==s&&this.$element.css({top:s+"px"}),this.$overlay&&"auto"===this.options.hOffset||(this.$element.css({left:e+"px"}),this.$element.css({margin:"0px"}))}},{key:"_events",value:function(){var i=this,n=this;this.$element.on({"open.zf.trigger":this.open.bind(this),"close.zf.trigger":function(e,t){if(e.target===n.$element[0]||r()(e.target).parents("[data-closable]")[0]===t)return i.close.apply(i)},"toggle.zf.trigger":this.toggle.bind(this),"resizeme.zf.trigger":function(){n._updatePosition()}}),this.options.closeOnClick&&this.options.overlay&&this.$overlay.off(".zf.reveal").on("click.zf.reveal",function(e){e.target!==n.$element[0]&&!r.a.contains(n.$element[0],e.target)&&r.a.contains(document,e.target)&&n.close()}),this.options.deepLink&&r()(window).on("hashchange.zf.reveal:".concat(this.id),this._handleState.bind(this))}},{key:"_handleState",value:function(e){window.location.hash!=="#"+this.id||this.isActive?this.close():this.open()}},{key:"_disableScroll",value:function(e){e=e||r()(window).scrollTop(),r()(document).height()>r()(window).height()&&r()("html").css("top",-e)}},{key:"_enableScroll",value:function(e){e=e||parseInt(r()("html").css("top")),r()(document).height()>r()(window).height()&&(r()("html").css("top",""),r()(window).scrollTop(-e))}},{key:"open",value:function(){var e=this,t="#".concat(this.id);this.options.deepLink&&window.location.hash!==t&&(window.history.pushState?this.options.updateHistory?window.history.pushState({},"",t):window.history.replaceState({},"",t):window.location.hash=t),this.$activeAnchor=r()(document.activeElement).is(this.$anchor)?r()(document.activeElement):this.$anchor,this.isActive=!0,this.$element.css({visibility:"hidden"}).show().scrollTop(0),this.options.overlay&&this.$overlay.css({visibility:"hidden"}).show(),this._updatePosition(),this.$element.hide().css({visibility:""}),this.$overlay&&(this.$overlay.css({visibility:""}).hide(),this.$element.hasClass("fast")?this.$overlay.addClass("fast"):this.$element.hasClass("slow")&&this.$overlay.addClass("slow")),this.options.multipleOpened||this.$element.trigger("closeme.zf.reveal",this.id),this._disableScroll();var i=this;if(this.options.animationIn){this.options.overlay&&c.Motion.animateIn(this.$overlay,"fade-in"),c.Motion.animateIn(this.$element,this.options.animationIn,function(){e.$element&&(e.focusableElements=a.Keyboard.findFocusable(e.$element),i.$element.attr({"aria-hidden":!1,tabindex:-1}).focus(),i._addGlobalClasses(),a.Keyboard.trapFocus(i.$element))})}else this.options.overlay&&this.$overlay.show(0),this.$element.show(this.options.showDelay);this.$element.attr({"aria-hidden":!1,tabindex:-1}).focus(),a.Keyboard.trapFocus(this.$element),this._addGlobalClasses(),this._addGlobalListeners(),this.$element.trigger("open.zf.reveal")}},{key:"_addGlobalClasses",value:function(){var e=function(){r()("html").toggleClass("zf-has-scroll",!!(r()(document).height()>r()(window).height()))};this.$element.on("resizeme.zf.trigger.revealScrollbarListener",function(){return e()}),e(),r()("html").addClass("is-reveal-open")}},{key:"_removeGlobalClasses",value:function(){this.$element.off("resizeme.zf.trigger.revealScrollbarListener"),r()("html").removeClass("is-reveal-open"),r()("html").removeClass("zf-has-scroll")}},{key:"_addGlobalListeners",value:function(){var t=this;this.$element&&(this.focusableElements=a.Keyboard.findFocusable(this.$element),this.options.overlay||!this.options.closeOnClick||this.options.fullScreen||r()("body").on("click.zf.reveal",function(e){e.target!==t.$element[0]&&!r.a.contains(t.$element[0],e.target)&&r.a.contains(document,e.target)&&t.close()}),this.options.closeOnEsc&&r()(window).on("keydown.zf.reveal",function(e){a.Keyboard.handleKey(e,"Reveal",{close:function(){t.options.closeOnEsc&&t.close()}})}))}},{key:"close",value:function(){if(!this.isActive||!this.$element.is(":visible"))return!1;var t=this;function e(){var e=parseInt(r()("html").css("top"));0===r()(".reveal:visible").length&&t._removeGlobalClasses(),a.Keyboard.releaseFocus(t.$element),t.$element.attr("aria-hidden",!0),t._enableScroll(e),t.$element.trigger("closed.zf.reveal")}if(this.options.animationOut?(this.options.overlay&&c.Motion.animateOut(this.$overlay,"fade-out"),c.Motion.animateOut(this.$element,this.options.animationOut,e)):(this.$element.hide(this.options.hideDelay),this.options.overlay?this.$overlay.hide(0,e):e()),this.options.closeOnEsc&&r()(window).off("keydown.zf.reveal"),!this.options.overlay&&this.options.closeOnClick&&r()("body").off("click.zf.reveal"),this.$element.off("keydown.zf.reveal"),this.options.resetOnClose&&this.$element.html(this.$element.html()),this.isActive=!1,t.options.deepLink&&window.location.hash==="#".concat(this.id))if(window.history.replaceState){var i=window.location.pathname+window.location.search;this.options.updateHistory?window.history.pushState({},"",i):window.history.replaceState("",document.title,i)}else window.location.hash="";this.$activeAnchor.focus()}},{key:"toggle",value:function(){this.isActive?this.close():this.open()}},{key:"_destroy",value:function(){this.options.overlay&&(this.$element.appendTo(r()(this.options.appendTo)),this.$overlay.hide().off().remove()),this.$element.hide().off(),this.$anchor.off(".zf"),r()(window).off(".zf.reveal:".concat(this.id)),this.onLoadListener&&r()(window).off(this.onLoadListener),0===r()(".reveal:visible").length&&this._removeGlobalClasses()}}])&&f(t.prototype,n),o&&f(t,o),i}();v.defaults={animationIn:"",animationOut:"",showDelay:0,hideDelay:0,closeOnClick:!0,closeOnEsc:!0,multipleOpened:!1,vOffset:"auto",hOffset:"auto",fullScreen:!1,overlay:!0,resetOnClose:!1,deepLink:!1,updateHistory:!1,appendTo:"body",additionalOverlayClasses:""}},"./js/foundation.util.triggers.js":function(e,t,i){"use strict";i.r(t),i.d(t,"Triggers",function(){return u});var n=i("jquery"),s=i.n(n),o=i("./foundation.core.utils"),r=i("./foundation.util.motion");function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var l=function(){for(var e=["WebKit","Moz","O","Ms",""],t=0;t<e.length;t++)if("".concat(e[t],"MutationObserver")in window)return window["".concat(e[t],"MutationObserver")];return!1}(),c=function(t,i){t.data(i).split(" ").forEach(function(e){s()("#".concat(e))["close"===i?"trigger":"triggerHandler"]("".concat(i,".zf.trigger"),[t])})},u={Listeners:{Basic:{},Global:{}},Initializers:{}};function d(t,e,i){var n,o=Array.prototype.slice.call(arguments,3);s()(window).off(e).on(e,function(e){n&&clearTimeout(n),n=setTimeout(function(){i.apply(null,o)},t||10)})}u.Listeners.Basic={openListener:function(){c(s()(this),"open")},closeListener:function(){s()(this).data("close")?c(s()(this),"close"):s()(this).trigger("close.zf.trigger")},toggleListener:function(){s()(this).data("toggle")?c(s()(this),"toggle"):s()(this).trigger("toggle.zf.trigger")},closeableListener:function(e){e.stopPropagation();var t=s()(this).data("closable");""!==t?r.Motion.animateOut(s()(this),t,function(){s()(this).trigger("closed.zf")}):s()(this).fadeOut().trigger("closed.zf")},toggleFocusListener:function(){var e=s()(this).data("toggle-focus");s()("#".concat(e)).triggerHandler("toggle.zf.trigger",[s()(this)])}},u.Initializers.addOpenListener=function(e){e.off("click.zf.trigger",u.Listeners.Basic.openListener),e.on("click.zf.trigger","[data-open]",u.Listeners.Basic.openListener)},u.Initializers.addCloseListener=function(e){e.off("click.zf.trigger",u.Listeners.Basic.closeListener),e.on("click.zf.trigger","[data-close]",u.Listeners.Basic.closeListener)},u.Initializers.addToggleListener=function(e){e.off("click.zf.trigger",u.Listeners.Basic.toggleListener),e.on("click.zf.trigger","[data-toggle]",u.Listeners.Basic.toggleListener)},u.Initializers.addCloseableListener=function(e){e.off("close.zf.trigger",u.Listeners.Basic.closeableListener),e.on("close.zf.trigger","[data-closeable], [data-closable]",u.Listeners.Basic.closeableListener)},u.Initializers.addToggleFocusListener=function(e){e.off("focus.zf.trigger blur.zf.trigger",u.Listeners.Basic.toggleFocusListener),e.on("focus.zf.trigger blur.zf.trigger","[data-toggle-focus]",u.Listeners.Basic.toggleFocusListener)},u.Listeners.Global={resizeListener:function(e){l||e.each(function(){s()(this).triggerHandler("resizeme.zf.trigger")}),e.attr("data-events","resize")},scrollListener:function(e){l||e.each(function(){s()(this).triggerHandler("scrollme.zf.trigger")}),e.attr("data-events","scroll")},closeMeListener:function(e,t){var i=e.namespace.split(".")[0];s()("[data-".concat(i,"]")).not('[data-yeti-box="'.concat(t,'"]')).each(function(){var e=s()(this);e.triggerHandler("close.zf.trigger",[e])})}},u.Initializers.addClosemeListener=function(e){var t=s()("[data-yeti-box]"),i=["dropdown","tooltip","reveal"];if(e&&("string"==typeof e?i.push(e):"object"===a(e)&&"string"==typeof e[0]?i.concat(e):console.error("Plugin names must be strings")),t.length){var n=i.map(function(e){return"closeme.zf.".concat(e)}).join(" ");s()(window).off(n).on(n,u.Listeners.Global.closeMeListener)}},u.Initializers.addResizeListener=function(e){var t=s()("[data-resize]");t.length&&d(e,"resize.zf.trigger",u.Listeners.Global.resizeListener,t)},u.Initializers.addScrollListener=function(e){var t=s()("[data-scroll]");t.length&&d(e,"scroll.zf.trigger",u.Listeners.Global.scrollListener,t)},u.Initializers.addMutationEventsListener=function(e){if(!l)return!1;var t=e.find("[data-resize], [data-scroll], [data-mutate]"),i=function(e){var t=s()(e[0].target);switch(e[0].type){case"attributes":"scroll"===t.attr("data-events")&&"data-events"===e[0].attributeName&&t.triggerHandler("scrollme.zf.trigger",[t,window.pageYOffset]),"resize"===t.attr("data-events")&&"data-events"===e[0].attributeName&&t.triggerHandler("resizeme.zf.trigger",[t]),"style"===e[0].attributeName&&(t.closest("[data-mutate]").attr("data-events","mutate"),t.closest("[data-mutate]").triggerHandler("mutateme.zf.trigger",[t.closest("[data-mutate]")]));break;case"childList":t.closest("[data-mutate]").attr("data-events","mutate"),t.closest("[data-mutate]").triggerHandler("mutateme.zf.trigger",[t.closest("[data-mutate]")]);break;default:return!1}};if(t.length)for(var n=0;n<=t.length-1;n++){new l(i).observe(t[n],{attributes:!0,childList:!0,characterData:!1,subtree:!0,attributeFilter:["data-events","style"]})}},u.Initializers.addSimpleListeners=function(){var e=s()(document);u.Initializers.addOpenListener(e),u.Initializers.addCloseListener(e),u.Initializers.addToggleListener(e),u.Initializers.addCloseableListener(e),u.Initializers.addToggleFocusListener(e)},u.Initializers.addGlobalListeners=function(){var e=s()(document);u.Initializers.addMutationEventsListener(e),u.Initializers.addResizeListener(),u.Initializers.addScrollListener(),u.Initializers.addClosemeListener()},u.init=function(e,t){Object(o.onLoad)(e(window),function(){!0!==e.triggersInitialized&&(u.Initializers.addSimpleListeners(),u.Initializers.addGlobalListeners(),e.triggersInitialized=!0)}),t&&(t.Triggers=u,t.IHearYou=u.Initializers.addGlobalListeners)}},14:function(e,t,i){e.exports=i("./js/entries/plugins/foundation.reveal.js")},jquery:function(e,t){e.exports=o}})});
|
|
//# sourceMappingURL=foundation.reveal.min.js.map
|