From c84579000b37731fe197678a055d37d60c44853a Mon Sep 17 00:00:00 2001 From: Maxim Stewart Date: Fri, 1 Mar 2019 01:20:25 -0600 Subject: [PATCH] Improved look of action messages. (Save, Delete, Edit, etc...) --- README.md | 4 +- src/manifest.json | 2 +- src/pages/import.html | 2 + src/pages/sessionManager.html | 5 +- src/scripts/background.js | 84 ++++++------- src/scripts/events.js | 2 - src/scripts/sessionManager.js | 218 +++++++++++++++++++--------------- src/scripts/sweetalert.min.js | 1 + src/styles/styles.css | 22 ++-- 9 files changed, 179 insertions(+), 161 deletions(-) create mode 100644 src/scripts/sweetalert.min.js diff --git a/README.md b/README.md index 5d23dad..7561977 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Easy Session Manager allows you to manage your Firefox session by backing up or # Download https://addons.mozilla.org/en-US/firefox/addon/easy-session-manager/ -# Version: 0.0.7 -Added override message for session edits. +# Version: 0.1.0 +Improved look of action messages. (Save, Delete, Edit, etc...) # Images ![1 Default interface with no sessions. ](images/pic1.png) diff --git a/src/manifest.json b/src/manifest.json index e2d6079..4061103 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": " Easy Session Manager", - "version": "0.0.7", + "version": "0.1.0", "description": " Easy Session Manager allows you to manage your Firefox session by backing up or loading your saved sessions.", "applications": { diff --git a/src/pages/import.html b/src/pages/import.html index 33c45c1..c791eef 100644 --- a/src/pages/import.html +++ b/src/pages/import.html @@ -29,6 +29,8 @@ body, html { + + diff --git a/src/pages/sessionManager.html b/src/pages/sessionManager.html index 7fbbf80..2a79b4f 100755 --- a/src/pages/sessionManager.html +++ b/src/pages/sessionManager.html @@ -34,11 +34,14 @@ + - + + + diff --git a/src/scripts/background.js b/src/scripts/background.js index 07dfa1b..994afd4 100644 --- a/src/scripts/background.js +++ b/src/scripts/background.js @@ -1,53 +1,47 @@ const regexp = /^[a-zA-Z0-9-_]+$/; // Alphanumeric, dash, underscore +const processor = (obj, enteryName = '', + message = "What is this session's name? Allowed: a-z, A-Z, -, _") => { + let data = obj.target.result; + let inputTag = document.createElement("INPUT"); + inputTag.value = enteryName; -const alertMessage = (type, message) => { - let msgTag = document.getElementById("allertMessage"); - let text = document.createTextNode(message); - let fontColor = "rgba(255, 255, 255, 1)"; - let bgColor = ""; + swal(message, { + content: inputTag, + buttons: true, + }).then((value) => { + if (value) { + enteryName = inputTag.value.replace(/ /g, "_"); + if (enteryName) { + if (enteryName.search(regexp) == -1) { + processor(obj, enteryName, "Please try again...\nAllowed: a-z, A-Z, -, _") + return ; + } - if (type === "success") { - bgColor = "rgba(72, 125, 25, 1)"; - } else if (type === "warning") { - bgColor = "rgba(195, 123, 0, 1)"; - } else if (type === "error") { - bgColor = "rgba(125, 45, 25, 1)"; - } - - msgTag.style.backgroundColor = bgColor; - msgTag.style.color = fontColor; - msgTag.style.display = "block"; - msgTag.append(text); - - setTimeout(function () { - let msgTag = document.getElementById("allertMessage"); - msgTag.innerHTML = ""; - msgTag.style.display = "none"; - }, 4000); -} - -const processor = (obj, enteryName = '') => { - let data = obj.target.result; - - do { - enteryName = prompt("What is this session's name? Allowed: a-z, A-Z, -, _", '' + enteryName); - if (enteryName == null) break - } while (enteryName.search(regexp) == -1); - - if (enteryName) { - try { - console.log("Importing session..."); - JSON.parse(data); - browser.storage.local.set({[enteryName]: data}); - alertMessage("success", "Imported file successfully.") - } catch (e) { - alertMessage("error", "Failed to import data. Not a JSON parsable file."); - return ; + try { + console.log("Importing session..."); + JSON.parse(data); + browser.storage.local.set({[enteryName]: data}); + swal("Imported file successfully.", { + icon: "success", + }); + } catch (e) { + swal("Failed to import data. Not a JSON parsable file.", { + icon: "error", + }); + return ; + } + } else { + swal("Canceled import.", { + icon: "warning", + }); + } + } else { + swal("Canceled import.", { + icon: "warning", + }); } - } else { - alertMessage("warning", "Canceled import."); - } + }); }; document.getElementById("inputId").onchange = (e) => { diff --git a/src/scripts/events.js b/src/scripts/events.js index 2637998..81e3e91 100644 --- a/src/scripts/events.js +++ b/src/scripts/events.js @@ -26,8 +26,6 @@ document.addEventListener("click", (e) => { deleteFromStorage(); else if (e.target.name == "edit") editSession(); - } else { - alertMessage("warning", "Select a session first..."); } } }); diff --git a/src/scripts/sessionManager.js b/src/scripts/sessionManager.js index 4557ecc..3b3141b 100644 --- a/src/scripts/sessionManager.js +++ b/src/scripts/sessionManager.js @@ -1,84 +1,143 @@ -const regexp = /^[a-zA-Z0-9-_]+$/; // Alphanumeric, dash, underscore const storage = browser.storage.local; const windowSys = browser.windows; +const regexp = /^[a-zA-Z0-9-_]+$/; // Alphanumeric, dash, underscore -const alertMessage = (type, message) => { - let msgTag = document.getElementById("allertMessage"); - let text = document.createTextNode(message); - let fontColor = "rgba(255, 255, 255, 1)"; - let bgColor = ""; - if (type === "success") { - bgColor = "rgba(72, 125, 25, 1)"; - } else if (type === "warning") { - bgColor = "rgba(195, 123, 0, 1)"; - } else if (type === "error") { - bgColor = "rgba(125, 45, 25, 1)"; - } - - msgTag.style.backgroundColor = bgColor; - msgTag.style.color = fontColor; - msgTag.style.display = "block"; - msgTag.innerHTML = ""; - msgTag.append(text); - - setTimeout(function () { - let msgTag = document.getElementById("allertMessage"); - msgTag.innerHTML = ""; - msgTag.style.display = "none"; - }, 3000); -} - -const saveSession = () => { - let enteryName = ''; - - do { - enteryName = prompt("What is this session's name? Allowed: a-z, A-Z, -, _", - new Date().toLocaleString().split(',')[0].replace(/\//g, '-')); - if (enteryName == null) break - } while (enteryName.search(regexp) == -1); - - if (enteryName) { - console.log("Saving session..."); - windowSys.getAll({ populate: true, windowTypes: ["normal"] }).then((windows) => { - let sessionData = {}; - for (let i = 0; i < windows.length; i++) { - let links = []; - for (var ii = 0; ii < windows[i].tabs.length; ii++) { - if (!windows[i].tabs[ii].url.includes("about:")) { - links.push( - {"link" : windows[i].tabs[ii].url.trim()} - ); - } +const saveSession = (message = "What is this session's name? Allowed: a-z, A-Z, -, _") => { + let inputTag = document.createElement("INPUT"); + inputTag.value = new Date().toLocaleString().split(',')[0].replace(/\//g, '-'); + swal(message, { + content: inputTag, + buttons: true, + }).then((value) => { + if (value) { + let enteryName = inputTag.value.replace(/ /g, "_"); + if (enteryName) { + if (enteryName.search(regexp) == -1) { + saveSession("Please try again...\nAllowed: a-z, A-Z, -, _") + return ; } - sessionData["WindowID:" + windows[i].id] = links; + + console.log("Saving session..."); + windowSys.getAll({ populate: true, windowTypes: ["normal"] }).then((windows) => { + let sessionData = {}; + for (let i = 0; i < windows.length; i++) { + let links = []; + for (var ii = 0; ii < windows[i].tabs.length; ii++) { + if (!windows[i].tabs[ii].url.includes("about:")) { + links.push( + {"link" : windows[i].tabs[ii].url.trim()} + ); + } + + } + sessionData["WindowID:" + windows[i].id] = links; + } + saveToStorage(enteryName, JSON.stringify(sessionData)); + }).then(() => { + if (document.getElementsByName(enteryName).length == 0) { + appendToSavedSessionsList(enteryName); + } + }); + } else { + swal("Canceled save...", { + icon: "warning", + }); } - saveToStorage(enteryName, JSON.stringify(sessionData)); - }).then(() => { - if (document.getElementsByName(enteryName).length == 0) { - appendToSavedSessionsList(enteryName); - } - }); - } else { - alertMessage("warning", "Canceled save..."); - } + } else { + swal("Canceled save...", { + icon: "warning", + }); + } + }); } -const saveToStorage = (name, data) => { +const editSession = (message = "Editing selected session... Allowed: a-z, A-Z, -, _") => { + let id = selectedItem.innerHTML; + let inputTag = document.createElement("INPUT"); + inputTag.value = id; + + swal(message, { + content: inputTag, + buttons: true, + }).then((value) => { + if (value) { + let newName = inputTag.value.replace(/ /g, "_"); + + if (newName) { + if (newName.search(regexp) == -1) { + editSession("Please try again...\nAllowed: a-z, A-Z, -, _") + return ; + } + + storage.get(id).then((storageResults) => { + storage.remove(id); + json = JSON.parse(storageResults[id]); + saveToStorage(newName, JSON.stringify(json), true); + }); + + selectedItem.textContent = newName; + } else { + swal("Canceled edit...", { + icon: "warning", + }); + } + } else { + swal("Canceled edit...", { + icon: "warning", + }); + } + }); +} + +const saveToStorage = (name, data, fromEdit = false) => { storage.get(name).then((storageResults) => { let json = null; try { json = JSON.parse(storageResults[name]); - alertMessage("success", "Overwrote session..."); + swal("Overwrote session...", { + icon: "warning", + }); } catch (e) { - alertMessage("success", "Saved session..."); + if (fromEdit) { // minor logic fix + swal("Overwrote session...", { + icon: "warning", + }); + } else { + swal("Saved session...", { + icon: "success", + }); + } } finally { storage.set({[name]: data}); } }); } +const deleteFromStorage = () => { + swal({ + title: "Are you sure?", + text: "Do you wish to delete session:\n" + selectedItem.innerHTML + "?", + icon: "warning", + buttons: true, + dangerMode: true, + }).then((willDelete) => { + if (willDelete) { + storage.remove(selectedItem.innerHTML).then(() => { + selectedItem.parentElement.removeChild(selectedItem); + }); + swal("Deleted session successfully...", { + icon: "success", + }); + } else { + swal("Canceled deletion...", { + icon: "warning", + }); + } + }); +} + const importSession = () => { browser.tabs.create({ url: browser.extension.getURL("../pages/import.html"), @@ -90,8 +149,7 @@ const downloadSession = () => { var dlAnchorElem = document.getElementById('downloadAnchorElem'); let id = selectedItem.innerHTML; fileName = "session:" + id + ":" + - new Date().toLocaleString().split(',')[0] - .replace(/\//g, "-") + ".json"; + new Date().toLocaleString().split(',')[0].replace(/\//g, "-") + ".json"; storage.get(id).then((storageResults) => { let json = JSON.parse(storageResults[id]); @@ -103,40 +161,6 @@ const downloadSession = () => { } -const deleteFromStorage = () => { - let action = confirm("Do you wish to delete session: " + selectedItem.innerHTML + "?"); - - if (action) { - storage.remove(selectedItem.innerHTML).then(() => { - selectedItem.parentElement.removeChild(selectedItem); - }); - alertMessage("success", "Deleted session successfully..."); - } else { - alertMessage("warning", "Canceled deletion..."); - } -} - -const editSession = () => { - let id = selectedItem.innerHTML; - let newName = ''; - - do { - newName = prompt("Editing selected session... Allowed: a-z, A-Z, -, _", id); - if (newName == null) break - } while (newName.search(regexp) == -1); - - if (newName) { - storage.get(id).then((storageResults) => { - storage.remove(id); - json = JSON.parse(storageResults[id]); - saveToStorage(newName, JSON.stringify(json)); - }); - selectedItem.textContent = newName; - } else { - alertMessage("warning", "Canceled edit..."); - } -} - const loadSession = (id = null) => { console.log("Loading session..."); try { diff --git a/src/scripts/sweetalert.min.js b/src/scripts/sweetalert.min.js new file mode 100644 index 0000000..dc8f5e7 --- /dev/null +++ b/src/scripts/sweetalert.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.swal=e():t.swal=e()}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=8)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o="swal-button";e.CLASS_NAMES={MODAL:"swal-modal",OVERLAY:"swal-overlay",SHOW_MODAL:"swal-overlay--show-modal",MODAL_TITLE:"swal-title",MODAL_TEXT:"swal-text",ICON:"swal-icon",ICON_CUSTOM:"swal-icon--custom",CONTENT:"swal-content",FOOTER:"swal-footer",BUTTON_CONTAINER:"swal-button-container",BUTTON:o,CONFIRM_BUTTON:o+"--confirm",CANCEL_BUTTON:o+"--cancel",DANGER_BUTTON:o+"--danger",BUTTON_LOADING:o+"--loading",BUTTON_LOADER:o+"__loader"},e.default=e.CLASS_NAMES},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getNode=function(t){var e="."+t;return document.querySelector(e)},e.stringToNode=function(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild},e.insertAfter=function(t,e){var n=e.nextSibling;e.parentNode.insertBefore(t,n)},e.removeNode=function(t){t.parentElement.removeChild(t)},e.throwErr=function(t){throw t=t.replace(/ +(?= )/g,""),"SweetAlert: "+(t=t.trim())},e.isPlainObject=function(t){if("[object Object]"!==Object.prototype.toString.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype},e.ordinalSuffixOf=function(t){var e=t%10,n=t%100;return 1===e&&11!==n?t+"st":2===e&&12!==n?t+"nd":3===e&&13!==n?t+"rd":t+"th"}},function(t,e,n){"use strict";function o(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),o(n(25));var r=n(26);e.overlayMarkup=r.default,o(n(27)),o(n(28)),o(n(29));var i=n(0),a=i.default.MODAL_TITLE,s=i.default.MODAL_TEXT,c=i.default.ICON,l=i.default.FOOTER;e.iconMarkup='\n
',e.titleMarkup='\n
\n',e.textMarkup='\n
',e.footerMarkup='\n
\n'},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(1);e.CONFIRM_KEY="confirm",e.CANCEL_KEY="cancel";var r={visible:!0,text:null,value:null,className:"",closeModal:!0},i=Object.assign({},r,{visible:!1,text:"Cancel",value:null}),a=Object.assign({},r,{text:"OK",value:!0});e.defaultButtonList={cancel:i,confirm:a};var s=function(t){switch(t){case e.CONFIRM_KEY:return a;case e.CANCEL_KEY:return i;default:var n=t.charAt(0).toUpperCase()+t.slice(1);return Object.assign({},r,{text:n,value:t})}},c=function(t,e){var n=s(t);return!0===e?Object.assign({},n,{visible:!0}):"string"==typeof e?Object.assign({},n,{visible:!0,text:e}):o.isPlainObject(e)?Object.assign({visible:!0},n,e):Object.assign({},n,{visible:!1})},l=function(t){for(var e={},n=0,o=Object.keys(t);n=0&&w.splice(e,1)}function s(t){var e=document.createElement("style");return t.attrs.type="text/css",l(e,t.attrs),i(t,e),e}function c(t){var e=document.createElement("link");return t.attrs.type="text/css",t.attrs.rel="stylesheet",l(e,t.attrs),i(t,e),e}function l(t,e){Object.keys(e).forEach(function(n){t.setAttribute(n,e[n])})}function u(t,e){var n,o,r,i;if(e.transform&&t.css){if(!(i=e.transform(t.css)))return function(){};t.css=i}if(e.singleton){var l=h++;n=g||(g=s(e)),o=f.bind(null,n,l,!1),r=f.bind(null,n,l,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=c(e),o=p.bind(null,n,e),r=function(){a(n),n.href&&URL.revokeObjectURL(n.href)}):(n=s(e),o=d.bind(null,n),r=function(){a(n)});return o(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;o(t=e)}else r()}}function f(t,e,n,o){var r=n?"":o.css;if(t.styleSheet)t.styleSheet.cssText=x(e,r);else{var i=document.createTextNode(r),a=t.childNodes;a[e]&&t.removeChild(a[e]),a.length?t.insertBefore(i,a[e]):t.appendChild(i)}}function d(t,e){var n=e.css,o=e.media;if(o&&t.setAttribute("media",o),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}function p(t,e,n){var o=n.css,r=n.sourceMap,i=void 0===e.convertToAbsoluteUrls&&r;(e.convertToAbsoluteUrls||i)&&(o=y(o)),r&&(o+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var a=new Blob([o],{type:"text/css"}),s=t.href;t.href=URL.createObjectURL(a),s&&URL.revokeObjectURL(s)}var m={},b=function(t){var e;return function(){return void 0===e&&(e=t.apply(this,arguments)),e}}(function(){return window&&document&&document.all&&!window.atob}),v=function(t){var e={};return function(n){return void 0===e[n]&&(e[n]=t.call(this,n)),e[n]}}(function(t){return document.querySelector(t)}),g=null,h=0,w=[],y=n(15);t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");e=e||{},e.attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||(e.singleton=b()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=r(t,e);return o(n,e),function(t){for(var i=[],a=0;athis.length)&&-1!==this.indexOf(t,e)}),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,e){if(null==this)throw new TypeError('"this" is null or not defined');var n=Object(this),o=n.length>>>0;if(0===o)return!1;for(var r=0|e,i=Math.max(r>=0?r:o-Math.abs(r),0);i=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(19),e.setImmediate=setImmediate,e.clearImmediate=clearImmediate},function(t,e,n){(function(t,e){!function(t,n){"use strict";function o(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n1)for(var n=1;n',e.default=e.modalMarkup},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),r=o.default.OVERLAY,i='
\n
';e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),r=o.default.ICON;e.errorIconMarkup=function(){var t=r+"--error",e=t+"__line";return'\n
\n \n \n
\n '},e.warningIconMarkup=function(){var t=r+"--warning";return'\n \n \n \n '},e.successIconMarkup=function(){var t=r+"--success";return'\n \n \n\n
\n
\n '}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),r=o.default.CONTENT;e.contentMarkup='\n
\n\n
\n'},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),r=o.default.BUTTON_CONTAINER,i=o.default.BUTTON,a=o.default.BUTTON_LOADER;e.buttonMarkup='\n
\n\n \n\n
\n
\n
\n
\n
\n\n
\n'},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(4),r=n(2),i=n(0),a=i.default.ICON,s=i.default.ICON_CUSTOM,c=["error","warning","success","info"],l={error:r.errorIconMarkup(),warning:r.warningIconMarkup(),success:r.successIconMarkup()},u=function(t,e){var n=a+"--"+t;e.classList.add(n);var o=l[t];o&&(e.innerHTML=o)},f=function(t,e){e.classList.add(s);var n=document.createElement("img");n.src=t,e.appendChild(n)},d=function(t){if(t){var e=o.injectElIntoModal(r.iconMarkup);c.includes(t)?u(t,e):f(t,e)}};e.default=d},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(2),r=n(4),i=function(t){navigator.userAgent.includes("AppleWebKit")&&(t.style.display="none",t.offsetHeight,t.style.display="")};e.initTitle=function(t){if(t){var e=r.injectElIntoModal(o.titleMarkup);e.textContent=t,i(e)}},e.initText=function(t){if(t){var e=document.createDocumentFragment();t.split("\n").forEach(function(t,n,o){e.appendChild(document.createTextNode(t)),n0}).forEach(function(t){b.classList.add(t)})}n&&t===c.CONFIRM_KEY&&b.classList.add(s),b.textContent=r;var g={};return g[t]=i,f.setActionValue(g),f.setActionOptionsFor(t,{closeModal:p}),b.addEventListener("click",function(){return u.onAction(t)}),m},p=function(t,e){var n=r.injectElIntoModal(l.footerMarkup);for(var o in t){var i=t[o],a=d(o,i,e);i.visible&&n.appendChild(a)}0===n.children.length&&n.remove()};e.default=p},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),r=n(4),i=n(2),a=n(5),s=n(6),c=n(0),l=c.default.CONTENT,u=function(t){t.addEventListener("input",function(t){var e=t.target,n=e.value;a.setActionValue(n)}),t.addEventListener("keyup",function(t){if("Enter"===t.key)return s.onAction(o.CONFIRM_KEY)}),setTimeout(function(){t.focus(),a.setActionValue("")},0)},f=function(t,e,n){var o=document.createElement(e),r=l+"__"+e;o.classList.add(r);for(var i in n){var a=n[i];o[i]=a}"input"===e&&u(o),t.appendChild(o)},d=function(t){if(t){var e=r.injectElIntoModal(i.contentMarkup),n=t.element,o=t.attributes;"string"==typeof n?f(e,n,o):e.appendChild(n)}};e.default=d},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(1),r=n(2),i=function(){var t=o.stringToNode(r.overlayMarkup);document.body.appendChild(t)};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(5),r=n(6),i=n(1),a=n(3),s=n(0),c=s.default.MODAL,l=s.default.BUTTON,u=s.default.OVERLAY,f=function(t){t.preventDefault(),v()},d=function(t){t.preventDefault(),g()},p=function(t){if(o.default.isOpen)switch(t.key){case"Escape":return r.onAction(a.CANCEL_KEY)}},m=function(t){if(o.default.isOpen)switch(t.key){case"Tab":return f(t)}},b=function(t){if(o.default.isOpen)return"Tab"===t.key&&t.shiftKey?d(t):void 0},v=function(){var t=i.getNode(l);t&&(t.tabIndex=0,t.focus())},g=function(){var t=i.getNode(c),e=t.querySelectorAll("."+l),n=e.length-1,o=e[n];o&&o.focus()},h=function(t){t[t.length-1].addEventListener("keydown",m)},w=function(t){t[0].addEventListener("keydown",b)},y=function(){var t=i.getNode(c),e=t.querySelectorAll("."+l);e.length&&(h(e),w(e))},x=function(t){if(i.getNode(u)===t.target)return r.onAction(a.CANCEL_KEY)},_=function(t){var e=i.getNode(u);e.removeEventListener("click",x),t&&e.addEventListener("click",x)},k=function(t){o.default.timer&&clearTimeout(o.default.timer),t&&(o.default.timer=window.setTimeout(function(){return r.onAction(a.CANCEL_KEY)},t))},O=function(t){t.closeOnEsc?document.addEventListener("keyup",p):document.removeEventListener("keyup",p),t.dangerMode?v():g(),y(),_(t.closeOnClickOutside),k(t.timer)};e.default=O},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(1),r=n(3),i=n(37),a=n(38),s={title:null,text:null,icon:null,buttons:r.defaultButtonList,content:null,className:null,closeOnClickOutside:!0,closeOnEsc:!0,dangerMode:!1,timer:null},c=Object.assign({},s);e.setDefaults=function(t){c=Object.assign({},s,t)};var l=function(t){var e=t&&t.button,n=t&&t.buttons;return void 0!==e&&void 0!==n&&o.throwErr("Cannot set both 'button' and 'buttons' options!"),void 0!==e?{confirm:e}:n},u=function(t){return o.ordinalSuffixOf(t+1)},f=function(t,e){o.throwErr(u(e)+" argument ('"+t+"') is invalid")},d=function(t,e){var n=t+1,r=e[n];o.isPlainObject(r)||void 0===r||o.throwErr("Expected "+u(n)+" argument ('"+r+"') to be a plain object")},p=function(t,e){var n=t+1,r=e[n];void 0!==r&&o.throwErr("Unexpected "+u(n)+" argument ("+r+")")},m=function(t,e,n,r){var i=typeof e,a="string"===i,s=e instanceof Element;if(a){if(0===n)return{text:e};if(1===n)return{text:e,title:r[0]};if(2===n)return d(n,r),{icon:e};f(e,n)}else{if(s&&0===n)return d(n,r),{content:e};if(o.isPlainObject(e))return p(n,r),e;f(e,n)}};e.getOpts=function(){for(var t=[],e=0;e