forked from zewish/rmodal.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js.map
1 lines (1 loc) · 10.1 KB
/
index.js.map
1
{"version":3,"file":"index.js","sources":["rmodal.js"],"sourcesContent":["'use strict';\n\nlet is = (obj, type) => Object.prototype.toString.call(obj).toLowerCase() === `[object ${type}]`;\n\nlet addClass = (el, cls) => {\n let arr = el.className\n .split(/\\s+/)\n .filter((c) => !!c && c == cls);\n\n if (!arr.length) {\n el.className += ` ${cls}`;\n }\n}\n\nlet removeClass = (el, cls) => {\n el.className = el.className\n .split(/\\s+/)\n .filter((c) => !!c && c != cls)\n .join(' ');\n}\n\nclass RModal {\n constructor(el, opts) {\n this.opened = false;\n\n this.opts = {\n bodyClass: 'modal-open'\n , dialogClass: 'modal-dialog'\n , dialogOpenClass: 'bounceInDown'\n , dialogCloseClass: 'bounceOutUp'\n\n , focus: true\n , focusElements: [\n 'a[href]', 'area[href]', 'input:not([disabled]):not([type=hidden])'\n , 'button:not([disabled])', 'select:not([disabled])'\n , 'textarea:not([disabled])', 'iframe', 'object', 'embed'\n , '*[tabindex]', '*[contenteditable]'\n ]\n\n , escapeClose: true\n , content: null\n };\n\n Object.keys(opts || {})\n .forEach((key) => {\n /* istanbul ignore else */\n if (opts[key] !== undefined) {\n this.opts[key] = opts[key];\n }\n });\n\n this.overlay = el;\n this.dialog = el.querySelector(`.${this.opts.dialogClass}`);\n\n if (this.opts.content) {\n this.content(this.opts.content);\n }\n }\n\n open(content) {\n this.content(content);\n\n if (!is(this.opts.beforeOpen, 'function')) {\n return this._doOpen();\n }\n\n this.opts.beforeOpen(() => {\n this._doOpen();\n });\n }\n\n _doOpen() {\n addClass(document.body, this.opts.bodyClass);\n\n removeClass(this.dialog, this.opts.dialogCloseClass);\n addClass(this.dialog, this.opts.dialogOpenClass);\n\n this.overlay.style.display = 'block';\n\n if (this.opts.focus) {\n this.focusOutElement = document.activeElement;\n this.focus();\n }\n\n if (is(this.opts.afterOpen, 'function')) {\n this.opts.afterOpen();\n }\n this.opened = true;\n }\n\n close() {\n if (!is(this.opts.beforeClose, 'function')) {\n return this._doClose();\n }\n\n this.opts.beforeClose(() => {\n this._doClose();\n });\n }\n\n _doClose() {\n removeClass(this.dialog, this.opts.dialogOpenClass);\n addClass(this.dialog, this.opts.dialogCloseClass);\n\n removeClass(document.body, this.opts.bodyClass);\n\n if (this.opts.focus) {\n this.focus(this.focusOutElement);\n }\n\n if (is(this.opts.afterClose, 'function')) {\n this.opts.afterClose();\n }\n\n this.opened = false;\n setTimeout(() => {\n this.overlay.style.display = 'none';\n }, 500);\n }\n\n content(content) {\n if (content === undefined) {\n return this.dialog.innerHTML;\n }\n\n this.dialog.innerHTML = content;\n }\n\n elements(selector, fallback) {\n fallback = fallback || window.navigator.appVersion.indexOf('MSIE 9.0') > -1;\n selector = is(selector, 'array') ? selector.join(',') : selector;\n\n return [].filter.call(\n this.dialog.querySelectorAll(selector)\n , (element) => {\n if (fallback) {\n var style = window.getComputedStyle(element);\n return style.display !== 'none' && style.visibility !== 'hidden';\n }\n\n return element.offsetParent !== null;\n }\n );\n }\n\n focus(el) {\n el = el || this.elements(this.opts.focusElements)[0] || this.dialog.firstChild;\n\n if (el && is(el.focus, 'function')) {\n el.focus();\n }\n }\n\n keydown(ev) {\n if (this.opts.escapeClose && ev.which == 27) {\n this.close();\n }\n\n function stopEvent() {\n ev.preventDefault();\n ev.stopPropagation();\n }\n\n if (this.opened && ev.which == 9 && this.dialog.contains(ev.target)) {\n var elements = this.elements(this.opts.focusElements)\n , first = elements[0]\n , last = elements[elements.length - 1];\n\n if (first == last) {\n stopEvent();\n }\n else if (ev.target == first && ev.shiftKey) {\n stopEvent();\n last.focus();\n }\n else if (ev.target == last && !ev.shiftKey) {\n stopEvent();\n first.focus();\n }\n }\n }\n}\n\nRModal.prototype.version = '@@VERSION@@';\nRModal.version = '@@VERSION@@';\n\nexport default RModal;"],"names":["let"],"mappings":"AAEAA,IAAI,EAAE,GAAG,UAAC,GAAG,EAAE,I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