1"use strict"; 2var _extends = Object.assign || function(t) { 3 for (var n = 1; n < arguments.length; n++) { 4 var i = arguments[n]; 5 for (var e in i) Object.prototype.hasOwnProperty.call(i, e) && (t[e] = i[e]) 6 } 7 return t 8 }, 9 _createClass = function() { 10 function e(t, n) { 11 for (var i = 0; i < n.length; i++) { 12 var e = n[i]; 13 e.enumerable = e.enumerable || !1, e.configurable = !0, "value" in e && (e.writable = !0), Object.defineProperty(t, e.key, e) 14 } 15 } 16 return function(t, n, i) { 17 return n && e(t.prototype, n), i && e(t, i), t 18 } 19 }(); 20 21function _classCallCheck(t, n) { 22 if (!(t instanceof n)) throw new TypeError("Cannot call a class as a function") 23} 24var Canvi = function() { 25 function i() { 26 var n = this, 27 t = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}; 28 _classCallCheck(this, i), this.options = _extends({ 29 speed: "0.3s", 30 width: "300px", 31 isDebug: !1, 32 position: "left", 33 pushContent: !0, 34 navbar: ".canvi-navbar", 35 content: ".canvi-content", 36 openButton: ".canvi-open-button" 37 }, t), this.isOpen = !1, this.body = document.querySelector("body"), this.transitionEvent = this._whichTransitionEvent(), this.navbar = document.querySelector(this.options.navbar), this.content = document.querySelector(this.options.content), this.openButton = document.querySelector(this.options.openButton), this.listeners = { 38 open: function() { 39 return n.open() 40 }, 41 close: function() { 42 return n.close() 43 }, 44 responsiveWidth: function() { 45 return n._responsiveWidth() 46 }, 47 transitionOpenEnd: function(t) { 48 return n._transitionOpenEnd(t) 49 }, 50 transitionCloseEnd: function(t) { 51 return n._transitionCloseEnd(t) 52 } 53 }, this.init() 54 } 55 return _createClass(i, [{ 56 key: "init", 57 value: function() { 58 this.options.isDebug && (console.log("%c %s", "color: #e01a51; font-style: italic;", "CANVI: Init is running..."), this._objectLog()), this._buildMarkup(), this._initializeMainEvents(), this._triggerCanviEvent("canvi.init"), this.navbar.setAttribute("inert", ""), this.navbar.setAttribute("aria-hidden", "true") 59 } 60 }, { 61 key: "open", 62 value: function() { 63 this.isOpen || (this.options.isDebug && console.log("%c %s", "color: #e01a51; font-style: italic;", "CANVI: Open is running..."), this._triggerCanviEvent("canvi.before-open"), this._buildOverlay(), this._setZindex(), this.content.classList.add("is-canvi-open"), this.body.classList.add("is-canvi-open"), this.navbar.classList.add("is-canvi-open"), this._responsiveWidth(), (this.options.pushContent ? this.content : this.navbar).addEventListener(this.transitionEvent, this.listeners.transitionOpenEnd), this.navbar.removeAttribute("inert"), this.navbar.removeAttribute("aria-hidden"), this.isOpen = !0) 64 } 65 }, { 66 key: "close", 67 value: function() { 68 this.isOpen && (this.options.isDebug && console.log("%c %s", "color: #e01a51; font-style: italic;", "CANVI: Close is running..."), this._triggerCanviEvent("canvi.before-close"), this.overlay.classList.add("canvi-animate-out"), this.content.style.transform = "translateX(0)", this.body.classList.remove("is-canvi-open"), this.navbar.classList.remove("is-canvi-open"), (this.options.pushContent ? this.content : this.navbar).addEventListener(this.transitionEvent, this.listeners.transitionCloseEnd), this.navbar.setAttribute("inert", ""), this.navbar.setAttribute("aria-hidden", "true"), this.isOpen = !1) 69 } 70 }, { 71 key: "toggle", 72 value: function() { 73 this.options.isDebug && console.log("%c %s", "color: #e
7301a51; font-style: italic;", "CANVI: Toggle is running..."), this.isOpen ? this.close() : this.open() 74 } 75 }, { 76 key: "_buildMarkup", 77 value: function() { 78 this.options.isDebug && console.log("%c %s", "color: #ccc; font-style: italic;", "CANVI: Build markup..."), this.options.position && (this.navbar.setAttribute("data-position", this.options.position), this.navbar.setAttribute("data-push-content", this.options.pushContent)), this.navbar.style.width = this.options.width, this.body.classList.add("is-canvi-ready") 79 } 80 }, { 81 key: "_responsiveWidth", 82 value: function() { 83 var n = this; 84 this.navbar.classList.contains("is-canvi-open") && window.matchMedia("(min-width: 0px)").matches && (this.navbar.style.width = this.options.width, this._responsiveWidthHelper(this.options.width)), this.navbar.classList.contains("is-canvi-open") && Array.isArray(this.options.responsiveWidths) && -1 < this.options.responsiveWidths.length && this.options.responsiveWidths.forEach(function(t) { 85 window.matchMedia("(min-width: " + t.breakpoint + ")").matches && (n.navbar.style.width = t.width, n._responsiveWidthHelper(t.width)) 86 }) 87 } 88 }, { 89 key: "_responsiveWidthHelper", 90 value: function(t) { 91 this.options.pushContent && (this.content.style.transform = "left" === this.options.position ? "translateX(" + t + ")" : "translateX(-" + t + ")") 92 } 93 }, { 94 key: "_buildOverlay", 95 value: function() { 96 this.options.isDebug && console.log("%c %s", "color: #32da94; font-style: italic;", "CANVI: Build overlay..."), this.content.querySelector(".canvi-overlay") || (this.overlay = document.createElement("div"), this.overlay.className = "canvi-overlay", this.content.appendChild(this.overlay)), this.overlay.addEventListener("click", this.listeners.close), this._setTransitionSpeed() 97 } 98 }, { 99 key: "_removeOverlay", 100 value: function() { 101 this.options.isDebug && console.log("%c %s", "color: #32da94; font-style: italic;", "CANVI: Remove overlay..."), this.overlay && (this.content.removeChild(this.overlay), this.overlay.removeEventListener("click", this.listeners.close)) 102 } 103 }, { 104 key: "_initializeMainEvents", 105 value: function() { 106 var n = this; 107 this.options.isDebug && (console.log("%c %s", "color: #ccc; font-style: italic;", "CANVI: Init main events..."), console.log("%c %s", "color: #999; font-style: italic;", "---------")), this.body.addEventListener("keyup", function(t) { 108 n.isOpen && 27 == t.keyCode && n.close() 109 }), this.openButton && this.openButton.addEventListener("click", this.listeners.open), window.addEventListener("resize", this.listeners.responsiveWidth) 110 } 111 }, { 112 key: "_transitionOpenEnd", 113 value: function(t) { 114 this.isOpen && "transform" === t.propertyName && (this.options.isDebug && (console.log("%c %s", "color: #ff7600; font-style: italic;", "CANVI: Open transition end..."), console.log("%c %s", "color: #999; font-style: italic;", "---------")), this._triggerCanviEvent("canvi.after-open"), (this.options.pushContent ? this.content : this.navbar).removeEventListener(this.transitionEvent, this.listeners.transitionOpenEnd)) 115 } 116 }, { 117 key: "_transitionCloseEnd", 118 value: function(t) { 119 this.isOpen || "transform" !== t.propertyName || (this.options.isDebug && console.log("%c %s", "color: #ff7600; font-style: italic;", "CANVI: Close transition end..."), this._triggerCanviEvent("canvi.after-close"), this._removeOverlay(), this._resetZindex(), (this.options.pushContent ? this.content : this.navbar).removeEventListener(this.transitionEvent, this.listeners.transitionCloseEnd), this.content.classList.remove("is-canvi-open")) 120 } 121 }, { 122 key: "_setTransitionSpeed", 123 value: function() { 124 this.navbar.style.transitionDuration = this.options.speed, this.content.style.transitionDuration = this.options.speed, this.overlay.style.animationDuration = this.options.speed 125 } 126 }, { 127 key: "_setZindex", 128 value: function() { 129 this.navbar.style.zIndex = this.options.pushContent ? 20 : 10, this.content.style.zIndex = this.options.pushContent ? 40 : 5 130 } 131 }, { 132 key: "_resetZindex", 133 value: function() { 134 this.navbar.style.zIndex = 1, this.content.style.zIndex = 5 135 } 136 }, { 137 key: "_whichTransitionEvent", 138 value: function() { 139 var t = document.createElement("fakeelement"), 140 n = { 141 transition: "transitionend", 142 OTransition: "oTransitionEnd", 143 MozTransition: "transitionend", 144 WebkitTransition: "webkitTransitionEnd" 145 }; 146 for (var i in n) 147 if (void 0 !== t.style[i]) return n[i] 148 } 149 }, { 150 key: "_triggerCanviEvent", 151 value: function(t) { 152 this.body.dispatchEvent(new CustomEvent(t, { 153 details: { 154 navbar: this.navbar, 155 openButton: this.openButton, 156 content: this.content 157 } 158 })) 159 } 160 }, { 161 key: "_objectLog", 162 value: function() { 163 console.groupCollapsed("Canvi Object"), console.log("Open Button: ", this.openButton), console.log("Navbar: ", this.navbar), console.log("Content: ", this.content), console.groupEnd() 164 } 165 }]), i 166}();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.