foundation-sites
Version:
The most advanced responsive front-end framework in the world.
3 lines (2 loc) • 12.9 kB
JavaScript
((t,e)=>{"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./foundation.core"),require("jquery"),require("./foundation.smoothScroll"),require("./foundation.util.motion")):"function"==typeof define&&define.amd?define(["./foundation.core","jquery","./foundation.smoothScroll","./foundation.util.motion"],e):"object"==typeof exports?exports.__FOUNDATION_EXTERNAL__=e(require("./foundation.core"),require("jquery"),require("./foundation.smoothScroll"),require("./foundation.util.motion")):(t.__FOUNDATION_EXTERNAL__=t.__FOUNDATION_EXTERNAL__||{},t.__FOUNDATION_EXTERNAL__["foundation.magellan"]=e(t.__FOUNDATION_EXTERNAL__["foundation.core"],t.jQuery,t.__FOUNDATION_EXTERNAL__["foundation.smoothScroll"],t.__FOUNDATION_EXTERNAL__["foundation.util.motion"]))})(self,function(e,i,n,o){return s={"./js/foundation.magellan.js":function(t,e,i){i.r(e),i.d(e,{Magellan:function(){return n}});var e=i("jquery"),a=i.n(e),o=i("./foundation.core"),r=i("./foundation.smoothScroll"),s=i("./js/foundation.util.triggers.js");function l(t){return(l="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 c(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(t=>(t=((t,e)=>{if("object"!=l(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0===i)return("string"===e?String:Number)(t);if("object"!=l(i=i.call(t,e||"default")))return i;throw new TypeError("@@toPrimitive must return a primitive value.")})(t,"string"),"symbol"==l(t)?t:t+""))(n.key),n)}}function u(t,e,i){e=d(e);var n=t,e=f()?Reflect.construct(e,i||[],d(t).constructor):e.apply(t,i);if(!e||"object"!=l(e)&&"function"!=typeof e){if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");if(void 0===(e=n))throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function d(t){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function g(t,e){return(g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var n=(t=>{function i(){var t=this,e=i;if(t instanceof e)return u(this,i,arguments);throw new TypeError("Cannot call a class as a function")}var e,n=i;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),t&&g(n,t),n=i,(t=[{key:"_setup",value:function(t,e){this.$element=t,this.options=a().extend({},i.defaults,this.$element.data(),e),this.className="Magellan",s.Triggers.init(a()),this._init(),this.calcPoints()}},{key:"_init",value:function(){var t=this.$element[0].id||(0,o.GetYoDigits)(6,"magellan");this.$targets=a()("[data-magellan-target]"),this.$links=this.$element.find("a"),this.$element.attr({"data-resize":t,"data-scroll":t,id:t}),this.$active=a()(),this.scrollPos=parseInt(window.pageYOffset,10),this._events()}},{key:"calcPoints",value:function(){var i=this,t=document.body,e=document.documentElement;this.points=[],this.winHeight=Math.round(Math.max(window.innerHeight,e.clientHeight)),this.docHeight=Math.round(Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)),this.$targets.each(function(){var t=a()(this),e=Math.round(t.offset().top-i.options.threshold);t.targetPoint=e,i.points.push(e)})}},{key:"_events",value:function(){var e=this;a()(window).one("load",function(){e.options.deepLinking&&location.hash&&e.scrollToLoc(location.hash),e.calcPoints(),e._updateActive()}),e.onLoadListener=(0,o.onLoad)(a()(window),function(){e.$element.on({"resizeme.zf.trigger":e.reflow.bind(e),"scrollme.zf.trigger":e._updateActive.bind(e)}).on("click.zf.magellan",'a[href^="#"]',function(t){t.preventDefault();t=this.getAttribute("href");e.scrollToLoc(t)})}),this._deepLinkScroll=function(){e.options.deepLinking&&e.scrollToLoc(window.location.hash)},a()(window).on("hashchange",this._deepLinkScroll)}},{key:"scrollToLoc",value:function(t){this._inTransition=!0;var e=this,i={animationEasing:this.options.animationEasing,animationDuration:this.options.animationDuration,threshold:this.options.threshold,offset:this.options.offset};r.SmoothScroll.scrollToLoc(t,i,function(){e._inTransition=!1})}},{key:"reflow",value:function(){this.calcPoints(),this._updateActive()}},{key:"_updateActive",value:function(){var e,i,t,n,o,r,s=this;this._inTransition||(e=parseInt(window.pageYOffset,10),i=this.scrollPos>e,(this.scrollPos=e)<this.points[0]-this.options.offset-(i?this.options.threshold:0)||(n=e+this.winHeight===this.docHeight?this.points.length-1:(n=this.points.filter(function(t){return t-s.options.offset-(i?s.options.threshold:0)<=e})).length?n.length-1:0),r=this.$active,t="",void 0!==n?(this.$active=this.$links.filter('[href="#'+this.$targets.eq(n).data("magellan-target")+'"]'),this.$active.length&&(t=this.$active[0].getAttribute("href"))):this.$active=a()(),n=!(!this.$active.length&&!r.length||this.$active.is(r)),o=t!==window.location.hash,n&&(r.removeClass(this.options.activeClass),this.$active.addClass(this.options.activeClass)),this.options.deepLinking&&o&&(window.history.pushState?(r=t||window.location.pathname+window.location.search,this.options.updateHistory?window.history.pushState({},"",r):window.history.replaceState({},"",r)):window.location.hash=t),n&&this.$element.trigger("update.zf.magellan",[this.$active]))}},{key:"_destroy",value:function(){var t;this.$element.off(".zf.trigger .zf.magellan").find(".".concat(this.options.activeClass)).removeClass(this.options.activeClass),this.options.deepLinking&&(t=this.$active[0].getAttribute("href"),window.location.hash.replace(t,"")),a()(window).off("hashchange",this._deepLinkScroll),this.onLoadListener&&a()(window).off(this.onLoadListener)}}])&&c(n.prototype,t),e&&c(n,e),Object.defineProperty(n,"prototype",{writable:!1}),n})(o.Plugin);n.defaults={animationDuration:500,animationEasing:"linear",threshold:50,activeClass:"is-active",deepLinking:!1,updateHistory:!1,offset:0}},"./js/foundation.util.triggers.js":function(t,e,i){i.r(e),i.d(e,{Triggers:function(){return c}});var e=i("jquery"),r=i.n(e),n=i("./foundation.core"),o=i("./foundation.util.motion");function s(t){return(s="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 a(e,i){e.data(i).split(" ").forEach(function(t){r()("#".concat(t))["close"===i?"trigger":"triggerHandler"]("".concat(i,".zf.trigger"),[e])})}var l=(()=>{for(var t=["WebKit","Moz","O","Ms",""],e=0;e<t.length;e++)if("".concat(t[e],"MutationObserver")in window)return window["".concat(t[e],"MutationObserver")];return!1})(),c={Listeners:{Basic:{},Global:{}},Initializers:{}};function u(t,e,i){var n,o=Array.prototype.slice.call(arguments,3);r()(window).on(e,function(){n&&clearTimeout(n),n=setTimeout(function(){i.apply(null,o)},t||10)})}c.Listeners.Basic={openListener:function(){a(r()(this),"open")},closeListener:function(){r()(this).data("close")?a(r()(this),"close"):r()(this).trigger("close.zf.trigger")},toggleListener:function(){r()(this).data("toggle")?a(r()(this),"toggle"):r()(this).trigger("toggle.zf.trigger")},closeableListener:function(t){var e=r()(this).data("closable");t.stopPropagation(),""!==e?o.Motion.animateOut(r()(this),e,function(){r()(this).trigger("closed.zf")}):r()(this).fadeOut().trigger("closed.zf")},toggleFocusListener:function(){var t=r()(this).data("toggle-focus");r()("#".concat(t)).triggerHandler("toggle.zf.trigger",[r()(this)])}},c.Initializers.addOpenListener=function(t){t.off("click.zf.trigger",c.Listeners.Basic.openListener),t.on("click.zf.trigger","[data-open]",c.Listeners.Basic.openListener)},c.Initializers.addCloseListener=function(t){t.off("click.zf.trigger",c.Listeners.Basic.closeListener),t.on("click.zf.trigger","[data-close]",c.Listeners.Basic.closeListener)},c.Initializers.addToggleListener=function(t){t.off("click.zf.trigger",c.Listeners.Basic.toggleListener),t.on("click.zf.trigger","[data-toggle]",c.Listeners.Basic.toggleListener)},c.Initializers.addCloseableListener=function(t){t.off("close.zf.trigger",c.Listeners.Basic.closeableListener),t.on("close.zf.trigger","[data-closeable], [data-closable]",c.Listeners.Basic.closeableListener)},c.Initializers.addToggleFocusListener=function(t){t.off("focus.zf.trigger blur.zf.trigger",c.Listeners.Basic.toggleFocusListener),t.on("focus.zf.trigger blur.zf.trigger","[data-toggle-focus]",c.Listeners.Basic.toggleFocusListener)},c.Listeners.Global={resizeListener:function(t){l||t.each(function(){r()(this).triggerHandler("resizeme.zf.trigger")}),t.attr("data-events","resize")},scrollListener:function(t){l||t.each(function(){r()(this).triggerHandler("scrollme.zf.trigger")}),t.attr("data-events","scroll")},closeMeListener:function(t,e){t=t.namespace.split(".")[0];r()("[data-".concat(t,"]")).not('[data-yeti-box="'.concat(e,'"]')).each(function(){var t=r()(this);t.triggerHandler("close.zf.trigger",[t])})}},c.Initializers.addClosemeListener=function(t){var e=r()("[data-yeti-box]"),i=["dropdown","tooltip","reveal"];t&&("string"==typeof t?i.push(t):"object"===s(t)&&"string"==typeof t[0]?i=i.concat(t):console.error("Plugin names must be strings")),e.length&&(t=i.map(function(t){return"closeme.zf.".concat(t)}).join(" "),r()(window).off(t).on(t,c.Listeners.Global.closeMeListener))},c.Initializers.addResizeListener=function(t){var e=r()("[data-resize]");e.length&&u(t,"resize.zf.trigger",c.Listeners.Global.resizeListener,e)},c.Initializers.addScrollListener=function(t){var e=r()("[data-scroll]");e.length&&u(t,"scroll.zf.trigger",c.Listeners.Global.scrollListener,e)},c.Initializers.addMutationEventsListener=function(t){if(!l)return!1;function e(t){var e=r()(t[0].target);switch(t[0].type){case"attributes":"scroll"===e.attr("data-events")&&"data-events"===t[0].attributeName&&e.triggerHandler("scrollme.zf.trigger",[e,window.pageYOffset]),"resize"===e.attr("data-events")&&"data-events"===t[0].attributeName&&e.triggerHandler("resizeme.zf.trigger",[e]),"style"===t[0].attributeName&&(e.closest("[data-mutate]").attr("data-events","mutate"),e.closest("[data-mutate]").triggerHandler("mutateme.zf.trigger",[e.closest("[data-mutate]")]));break;case"childList":e.closest("[data-mutate]").attr("data-events","mutate"),e.closest("[data-mutate]").triggerHandler("mutateme.zf.trigger",[e.closest("[data-mutate]")]);break;default:return!1}}var i=t.find("[data-resize], [data-scroll], [data-mutate]");if(i.length)for(var n=0;n<=i.length-1;n++)new l(e).observe(i[n],{attributes:!0,childList:!0,characterData:!1,subtree:!0,attributeFilter:["data-events","style"]})},c.Initializers.addSimpleListeners=function(){var t=r()(document);c.Initializers.addOpenListener(t),c.Initializers.addCloseListener(t),c.Initializers.addToggleListener(t),c.Initializers.addCloseableListener(t),c.Initializers.addToggleFocusListener(t)},c.Initializers.addGlobalListeners=function(){var t=r()(document);c.Initializers.addMutationEventsListener(t),c.Initializers.addResizeListener(250),c.Initializers.addScrollListener(),c.Initializers.addClosemeListener()},c.init=function(t,e){(0,n.onLoad)(r()(window),function(){!0!==r().triggersInitialized&&(c.Initializers.addSimpleListeners(),c.Initializers.addGlobalListeners(),r().triggersInitialized=!0)}),e&&(e.Triggers=c,e.IHearYou=c.Initializers.addGlobalListeners)}},"./foundation.core":function(t){t.exports=e},"./foundation.smoothScroll":function(t){t.exports=n},"./foundation.util.motion":function(t){t.exports=o},jquery:function(t){t.exports=i}},a={},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},c={},(r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})})(c),r.d(c,{Foundation:function(){return t.Foundation},Magellan:function(){return l.Magellan}}),t=r("./foundation.core"),l=r("./js/foundation.magellan.js"),t.Foundation.plugin(l.Magellan,"Magellan"),c;function r(t){var e=a[t];return void 0!==e||(e=a[t]={exports:{}},s[t](e,e.exports,r)),e.exports}var s,a,t,l,c});
//# sourceMappingURL=foundation.magellan.min.js.map