diff --git a/src/main/java/im/zhaojun/common/constant/ZfileConstant.java b/src/main/java/im/zhaojun/common/constant/ZfileConstant.java new file mode 100644 index 0000000..f24b614 --- /dev/null +++ b/src/main/java/im/zhaojun/common/constant/ZfileConstant.java @@ -0,0 +1,11 @@ +package im.zhaojun.common.constant; + +public class ZfileConstant { + + public static final String HEADER_FILE_NAME = "header.md"; + + public static final String README_FILE_NAME = "readme.md"; + + public static final String PASSWORD_FILE_NAME = "password.txt"; + +} diff --git a/src/main/java/im/zhaojun/common/controller/FileController.java b/src/main/java/im/zhaojun/common/controller/FileController.java index 8ad9bc5..4e120ae 100644 --- a/src/main/java/im/zhaojun/common/controller/FileController.java +++ b/src/main/java/im/zhaojun/common/controller/FileController.java @@ -1,8 +1,8 @@ package im.zhaojun.common.controller; -import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.URLUtil; import im.zhaojun.common.config.StorageTypeFactory; +import im.zhaojun.common.constant.ZfileConstant; import im.zhaojun.common.enums.FileTypeEnum; import im.zhaojun.common.enums.StorageTypeEnum; import im.zhaojun.common.model.FileItem; @@ -14,11 +14,13 @@ import im.zhaojun.common.service.SystemConfigService; import im.zhaojun.common.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.PostConstruct; import javax.annotation.Resource; -import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -34,9 +36,22 @@ public class FileController { private SystemConfigService systemConfigService; @GetMapping("/list") - public ResultBean list(String path, String sortBy, boolean descending) throws Exception { + public ResultBean list(String path, String sortBy, boolean descending, @RequestParam(required = false) String password) throws Exception { List fileItems = fileService.fileList(StringUtils.removeDuplicateSeparator("/" + URLUtil.decode(path))); + for (FileItem fileItem : fileItems) { + if (ZfileConstant.PASSWORD_FILE_NAME.equals(fileItem.getName())) { + + String url = StringUtils.removeDuplicateSeparator("/" + fileItem.getPath() + "/" + fileItem.getName()); + + if (!fileService.getTextContent(url).equals(password)) { + if (password != null && !"".equals(password)) return ResultBean.error("密码错误."); + return ResultBean.error("此文件夹需要密码.", ResultBean.REQUIRED_PASSWORD); + } + } + } + + // 排序, 先按照文件类型比较, 文件夹在前, 文件在后, 然后根据 sortBy 字段排序, 默认为升序; fileItems.sort((o1, o2) -> { FileTypeEnum o1Type = o1.getType(); @@ -61,7 +76,6 @@ public class FileController { if (descending) { Collections.reverse(fileItems); } - return ResultBean.successData(fileItems); } diff --git a/src/main/java/im/zhaojun/common/model/ResultBean.java b/src/main/java/im/zhaojun/common/model/ResultBean.java index c7787e7..a6623b0 100644 --- a/src/main/java/im/zhaojun/common/model/ResultBean.java +++ b/src/main/java/im/zhaojun/common/model/ResultBean.java @@ -6,9 +6,11 @@ public class ResultBean implements Serializable { private static final long serialVersionUID = -8276264968757808344L; - private static final int SUCCESS = 0; + public static final int SUCCESS = 0; - private static final int FAIL = -1; + public static final int FAIL = -1; + + public static final int REQUIRED_PASSWORD = -2; private String msg = "操作成功"; @@ -53,6 +55,13 @@ public class ResultBean implements Serializable { return resultBean; } + public static ResultBean error(String msg, Integer code) { + ResultBean resultBean = new ResultBean(); + resultBean.setCode(code); + resultBean.setMsg(msg); + return resultBean; + } + public String getMsg() { return msg; } diff --git a/src/main/java/im/zhaojun/common/service/FileService.java b/src/main/java/im/zhaojun/common/service/FileService.java index 4108228..bb96a7a 100644 --- a/src/main/java/im/zhaojun/common/service/FileService.java +++ b/src/main/java/im/zhaojun/common/service/FileService.java @@ -1,20 +1,18 @@ package im.zhaojun.common.service; -import cn.hutool.core.codec.Base64; import cn.hutool.core.io.FileUtil; import cn.hutool.core.lang.UUID; import cn.hutool.core.util.URLUtil; import cn.hutool.http.HttpUtil; -import com.mpatric.mp3agic.ID3v1; -import com.mpatric.mp3agic.ID3v2; -import com.mpatric.mp3agic.Mp3File; import im.zhaojun.common.config.ZfileCacheConfiguration; +import im.zhaojun.common.constant.ZfileConstant; import im.zhaojun.common.enums.FileTypeEnum; import im.zhaojun.common.enums.StorageTypeEnum; import im.zhaojun.common.model.AudioInfo; import im.zhaojun.common.model.FileItem; import im.zhaojun.common.model.ImageInfo; import im.zhaojun.common.model.SiteConfig; +import im.zhaojun.common.util.AudioHelper; import im.zhaojun.common.util.StringUtils; import org.springframework.aop.framework.AopContext; import org.springframework.cache.annotation.CacheConfig; @@ -52,9 +50,9 @@ public interface FileService { List fileItemList = fileService.fileList(path); path = StringUtils.removeLastSeparator(path); for (FileItem fileItem : fileItemList) { - if ("readme.md".equalsIgnoreCase(fileItem.getName())) { + if (ZfileConstant.README_FILE_NAME.equalsIgnoreCase(fileItem.getName())) { siteConfig.setFooter(getTextContent(path + "/" + fileItem.getName())); - } else if ("header.md".equalsIgnoreCase(fileItem.getName())) { + } else if (ZfileConstant.HEADER_FILE_NAME.equalsIgnoreCase(fileItem.getName())) { siteConfig.setHeader(getTextContent(path + "/" + fileItem.getName())); } } diff --git a/src/main/resources/static/config.js b/src/main/resources/static/config.js index 655f755..befc635 100644 --- a/src/main/resources/static/config.js +++ b/src/main/resources/static/config.js @@ -10,7 +10,8 @@ requirejs.config({ layer: '/layer/layer', highlight: '/highlight/highlight.min', DPlayer: '/DPlayer/DPlayer.min', - Shikwasa: '/shikwasa/shikwasa.min' + Shikwasa: '/shikwasa/shikwasa.min', + swal: '/sweetalert/sweetalert.min' }, shim: { zfile: { @@ -33,5 +34,4 @@ requirejs.config({ }); requirejs(['index'], function(index) { - }); \ No newline at end of file diff --git a/src/main/resources/static/script/index.js b/src/main/resources/static/script/index.js index 17b5939..763e38d 100644 --- a/src/main/resources/static/script/index.js +++ b/src/main/resources/static/script/index.js @@ -1,7 +1,7 @@ define(['jquery', 'zfile', 'QRCode', 'contextMenu', 'marked'], function($, zfile, QRCode, contextMenu, marked) { var index = { - LOCAL_STORAGE_KEY: "zadmin-config", + LOCAL_STORAGE_CONFIG_KEY: "zadmin-config", buildInfo: function (info) { $("#info .block .name").html(info.name); $("#info .block .time").html(info.time); @@ -15,10 +15,10 @@ define(['jquery', 'zfile', 'QRCode', 'contextMenu', 'marked'], function($, zfile } }, updateConfig: function (key, value) { - var systemConfigStr = localStorage.getItem(index.LOCAL_STORAGE_KEY); + var systemConfigStr = localStorage.getItem(index.LOCAL_STORAGE_CONFIG_KEY); var systemConfig = JSON.parse(systemConfigStr); systemConfig[key] = value; - localStorage.setItem(index.LOCAL_STORAGE_KEY, JSON.stringify(systemConfig)); + localStorage.setItem(index.LOCAL_STORAGE_CONFIG_KEY, JSON.stringify(systemConfig)); }, updateListSize: function (value) { var size; @@ -50,7 +50,7 @@ define(['jquery', 'zfile', 'QRCode', 'contextMenu', 'marked'], function($, zfile result = data.data; var systemConfig = result.systemConfig; - var systemConfigCache = localStorage.getItem(index.LOCAL_STORAGE_KEY); + var systemConfigCache = localStorage.getItem(index.LOCAL_STORAGE_CONFIG_KEY); if (systemConfigCache) { systemConfig = JSON.parse(systemConfigCache); } @@ -120,7 +120,7 @@ define(['jquery', 'zfile', 'QRCode', 'contextMenu', 'marked'], function($, zfile } } - localStorage.setItem(index.LOCAL_STORAGE_KEY, JSON.stringify(systemConfig)); + localStorage.setItem(index.LOCAL_STORAGE_CONFIG_KEY, JSON.stringify(systemConfig)); }, error: function (textStatus, errorThrown) { alert("加载站点配置失败.!"); diff --git a/src/main/resources/static/script/main.js b/src/main/resources/static/script/main.js index 933f9f3..e4ef536 100644 --- a/src/main/resources/static/script/main.js +++ b/src/main/resources/static/script/main.js @@ -1,4 +1,4 @@ -define(['jquery', 'Mustache', 'layer', 'marked', 'highlight', 'DPlayer', 'Shikwasa'], function ($, Mustache, layer, marked, hljs, DPlayer, Shikwasa){ +define(['jquery', 'Mustache', 'layer', 'marked', 'highlight', 'DPlayer', 'Shikwasa', 'swal'], function ($, Mustache, layer, marked, hljs, DPlayer, Shikwasa, swal){ var zfile = { prefixPath: '/file', @@ -7,6 +7,7 @@ define(['jquery', 'Mustache', 'layer', 'marked', 'highlight', 'DPlayer', 'Shikwa sizeObj: $(".size"), infoObj: $("#info"), listObj: $("#list"), + LOCAL_STORAGE_PWD_KEY_PREFIX: "zadmin-pwd-", util: { bytesToSize: function (bytes) { if (bytes === 0) return '0 B'; @@ -29,8 +30,6 @@ define(['jquery', 'Mustache', 'layer', 'marked', 'highlight', 'DPlayer', 'Shikwa } }, buildList: function (data) { - var path = zfile.getPath(); - var list = []; $.each(data, function (i, val) { var fileType, url; @@ -73,11 +72,16 @@ define(['jquery', 'Mustache', 'layer', 'marked', 'highlight', 'DPlayer', 'Shikwa path: zfile.getPath(), sortBy: zfile.getSortBy(), descending: zfile.getDescending() === 'desc', - search: false + search: false, + password: zfile.getPassword(zfile.getPath()) }; + console.log("尝试获取 key: " + zfile.getPath()); + $.extend(defaultSetting, settings); + + if (!defaultSetting.search && defaultSetting.path !== '' && defaultSetting.path.charAt(defaultSetting.path.length - 1) !== '/') { defaultSetting.path += '/'; } @@ -88,20 +92,32 @@ define(['jquery', 'Mustache', 'layer', 'marked', 'highlight', 'DPlayer', 'Shikwa } $("#items").attr("style", "opacity: 0.5;-moz-opacit: 0.5;"); + $.ajax({ type: 'GET', url: url, data: { path: encodeURIComponent(decodeURIComponent(defaultSetting.path)), // 先解码, 再编码, 防止重复编码 sortBy: defaultSetting.sortBy, - descending: defaultSetting.descending + descending: defaultSetting.descending, + password: defaultSetting.password }, dataType: 'json', success: function (result) { + zfile.clearList(); var data = result.data; - if (data.length === 0) { + if (result.code === -1) { + swal({ + title: result.msg, + text: "请重新输入密码.", + icon: "error" + }).then(zfile.pwdModal); + } else if (result.code === -2) { + zfile.pwdModal(); + } else if (data.length === 0) { zfile.listObj.html('
空文件夹
'); } else { + zfile.savePassword(zfile.getPath(), defaultSetting.password); zfile.buildList(data); } }, @@ -122,6 +138,26 @@ define(['jquery', 'Mustache', 'layer', 'marked', 'highlight', 'DPlayer', 'Shikwa } }); }, + pwdModal: function () { + swal({ + content: { + element: "input", + attributes: { + placeholder: "输入密码进行查看." + } + } + }).then(function (value) { + if (value !== null) { + zfile.listObjects({password: value}); + } + }); + }, + savePassword: function(path, pwd) { + localStorage.setItem(zfile.LOCAL_STORAGE_PWD_KEY_PREFIX + path, pwd); + }, + getPassword: function(path) { + return localStorage.getItem(zfile.LOCAL_STORAGE_PWD_KEY_PREFIX + path); + }, clearList: function () { this.listObj.html(''); }, @@ -368,7 +404,6 @@ define(['jquery', 'Mustache', 'layer', 'marked', 'highlight', 'DPlayer', 'Shikwa layer.open({ type: 1, title: false, - // area: ['66%', '120px'], area: screen.availWidth > 768 ? ['66%', '120px'] : ['100%', '60px'], offset: screen.availWidth > 768 ? 'auto' : 'b', shade: 0.3, diff --git a/src/main/resources/static/sweetalert/sweetalert.min.js b/src/main/resources/static/sweetalert/sweetalert.min.js new file mode 100644 index 0000000..dc8f5e7 --- /dev/null +++ b/src/main/resources/static/sweetalert/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