message-box.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, {
  41. /******/ configurable: false,
  42. /******/ enumerable: true,
  43. /******/ get: getter
  44. /******/ });
  45. /******/ }
  46. /******/ };
  47. /******/
  48. /******/ // getDefaultExport function for compatibility with non-harmony modules
  49. /******/ __webpack_require__.n = function(module) {
  50. /******/ var getter = module && module.__esModule ?
  51. /******/ function getDefault() { return module['default']; } :
  52. /******/ function getModuleExports() { return module; };
  53. /******/ __webpack_require__.d(getter, 'a', getter);
  54. /******/ return getter;
  55. /******/ };
  56. /******/
  57. /******/ // Object.prototype.hasOwnProperty.call
  58. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  59. /******/
  60. /******/ // __webpack_public_path__
  61. /******/ __webpack_require__.p = "/dist/";
  62. /******/
  63. /******/ // Load entry module and return exports
  64. /******/ return __webpack_require__(__webpack_require__.s = 209);
  65. /******/ })
  66. /************************************************************************/
  67. /******/ ({
  68. /***/ 0:
  69. /***/ (function(module, exports) {
  70. /* globals __VUE_SSR_CONTEXT__ */
  71. // IMPORTANT: Do NOT use ES2015 features in this file.
  72. // This module is a runtime utility for cleaner component module output and will
  73. // be included in the final webpack user bundle.
  74. module.exports = function normalizeComponent (
  75. rawScriptExports,
  76. compiledTemplate,
  77. functionalTemplate,
  78. injectStyles,
  79. scopeId,
  80. moduleIdentifier /* server only */
  81. ) {
  82. var esModule
  83. var scriptExports = rawScriptExports = rawScriptExports || {}
  84. // ES6 modules interop
  85. var type = typeof rawScriptExports.default
  86. if (type === 'object' || type === 'function') {
  87. esModule = rawScriptExports
  88. scriptExports = rawScriptExports.default
  89. }
  90. // Vue.extend constructor export interop
  91. var options = typeof scriptExports === 'function'
  92. ? scriptExports.options
  93. : scriptExports
  94. // render functions
  95. if (compiledTemplate) {
  96. options.render = compiledTemplate.render
  97. options.staticRenderFns = compiledTemplate.staticRenderFns
  98. options._compiled = true
  99. }
  100. // functional template
  101. if (functionalTemplate) {
  102. options.functional = true
  103. }
  104. // scopedId
  105. if (scopeId) {
  106. options._scopeId = scopeId
  107. }
  108. var hook
  109. if (moduleIdentifier) { // server build
  110. hook = function (context) {
  111. // 2.3 injection
  112. context =
  113. context || // cached call
  114. (this.$vnode && this.$vnode.ssrContext) || // stateful
  115. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  116. // 2.2 with runInNewContext: true
  117. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  118. context = __VUE_SSR_CONTEXT__
  119. }
  120. // inject component styles
  121. if (injectStyles) {
  122. injectStyles.call(this, context)
  123. }
  124. // register component module identifier for async chunk inferrence
  125. if (context && context._registeredComponents) {
  126. context._registeredComponents.add(moduleIdentifier)
  127. }
  128. }
  129. // used by ssr in case component is cached and beforeCreate
  130. // never gets called
  131. options._ssrRegister = hook
  132. } else if (injectStyles) {
  133. hook = injectStyles
  134. }
  135. if (hook) {
  136. var functional = options.functional
  137. var existing = functional
  138. ? options.render
  139. : options.beforeCreate
  140. if (!functional) {
  141. // inject component registration as beforeCreate hook
  142. options.beforeCreate = existing
  143. ? [].concat(existing, hook)
  144. : [hook]
  145. } else {
  146. // for template-only hot-reload because in that case the render fn doesn't
  147. // go through the normalizer
  148. options._injectStyles = hook
  149. // register for functioal component in vue file
  150. options.render = function renderWithStyleInjection (h, context) {
  151. hook.call(context)
  152. return existing(h, context)
  153. }
  154. }
  155. }
  156. return {
  157. esModule: esModule,
  158. exports: scriptExports,
  159. options: options
  160. }
  161. }
  162. /***/ }),
  163. /***/ 12:
  164. /***/ (function(module, exports) {
  165. module.exports = require("element-ui/lib/locale");
  166. /***/ }),
  167. /***/ 13:
  168. /***/ (function(module, exports) {
  169. module.exports = require("element-ui/lib/utils/popup");
  170. /***/ }),
  171. /***/ 15:
  172. /***/ (function(module, exports) {
  173. module.exports = require("element-ui/lib/button");
  174. /***/ }),
  175. /***/ 20:
  176. /***/ (function(module, exports) {
  177. module.exports = require("element-ui/lib/utils/vdom");
  178. /***/ }),
  179. /***/ 209:
  180. /***/ (function(module, exports, __webpack_require__) {
  181. "use strict";
  182. exports.__esModule = true;
  183. var _main = __webpack_require__(210);
  184. var _main2 = _interopRequireDefault(_main);
  185. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  186. exports.default = _main2.default;
  187. /***/ }),
  188. /***/ 210:
  189. /***/ (function(module, exports, __webpack_require__) {
  190. "use strict";
  191. exports.__esModule = true;
  192. exports.MessageBox = undefined;
  193. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  194. var _vue = __webpack_require__(4);
  195. var _vue2 = _interopRequireDefault(_vue);
  196. var _main = __webpack_require__(211);
  197. var _main2 = _interopRequireDefault(_main);
  198. var _merge = __webpack_require__(9);
  199. var _merge2 = _interopRequireDefault(_merge);
  200. var _vdom = __webpack_require__(20);
  201. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  202. var defaults = {
  203. title: null,
  204. message: '',
  205. type: '',
  206. iconClass: '',
  207. showInput: false,
  208. showClose: true,
  209. modalFade: true,
  210. lockScroll: true,
  211. closeOnClickModal: true,
  212. closeOnPressEscape: true,
  213. closeOnHashChange: true,
  214. inputValue: null,
  215. inputPlaceholder: '',
  216. inputType: 'text',
  217. inputPattern: null,
  218. inputValidator: null,
  219. inputErrorMessage: '',
  220. showConfirmButton: true,
  221. showCancelButton: false,
  222. confirmButtonPosition: 'right',
  223. confirmButtonHighlight: false,
  224. cancelButtonHighlight: false,
  225. confirmButtonText: '',
  226. cancelButtonText: '',
  227. confirmButtonClass: '',
  228. cancelButtonClass: '',
  229. customClass: '',
  230. beforeClose: null,
  231. dangerouslyUseHTMLString: false,
  232. center: false,
  233. roundButton: false,
  234. distinguishCancelAndClose: false
  235. };
  236. var MessageBoxConstructor = _vue2.default.extend(_main2.default);
  237. var currentMsg = void 0,
  238. instance = void 0;
  239. var msgQueue = [];
  240. var defaultCallback = function defaultCallback(action) {
  241. if (currentMsg) {
  242. var callback = currentMsg.callback;
  243. if (typeof callback === 'function') {
  244. if (instance.showInput) {
  245. callback(instance.inputValue, action);
  246. } else {
  247. callback(action);
  248. }
  249. }
  250. if (currentMsg.resolve) {
  251. if (action === 'confirm') {
  252. if (instance.showInput) {
  253. currentMsg.resolve({ value: instance.inputValue, action: action });
  254. } else {
  255. currentMsg.resolve(action);
  256. }
  257. } else if (currentMsg.reject && (action === 'cancel' || action === 'close')) {
  258. currentMsg.reject(action);
  259. }
  260. }
  261. }
  262. };
  263. var initInstance = function initInstance() {
  264. instance = new MessageBoxConstructor({
  265. el: document.createElement('div')
  266. });
  267. instance.callback = defaultCallback;
  268. };
  269. var showNextMsg = function showNextMsg() {
  270. if (!instance) {
  271. initInstance();
  272. }
  273. instance.action = '';
  274. if (!instance.visible || instance.closeTimer) {
  275. if (msgQueue.length > 0) {
  276. (function () {
  277. currentMsg = msgQueue.shift();
  278. var options = currentMsg.options;
  279. for (var prop in options) {
  280. if (options.hasOwnProperty(prop)) {
  281. instance[prop] = options[prop];
  282. }
  283. }
  284. if (options.callback === undefined) {
  285. instance.callback = defaultCallback;
  286. }
  287. var oldCb = instance.callback;
  288. instance.callback = function (action, instance) {
  289. oldCb(action, instance);
  290. showNextMsg();
  291. };
  292. if ((0, _vdom.isVNode)(instance.message)) {
  293. instance.$slots.default = [instance.message];
  294. instance.message = null;
  295. } else {
  296. delete instance.$slots.default;
  297. }
  298. ['modal', 'showClose', 'closeOnClickModal', 'closeOnPressEscape', 'closeOnHashChange'].forEach(function (prop) {
  299. if (instance[prop] === undefined) {
  300. instance[prop] = true;
  301. }
  302. });
  303. document.body.appendChild(instance.$el);
  304. _vue2.default.nextTick(function () {
  305. instance.visible = true;
  306. });
  307. })();
  308. }
  309. }
  310. };
  311. var MessageBox = function MessageBox(options, callback) {
  312. if (_vue2.default.prototype.$isServer) return;
  313. if (typeof options === 'string' || (0, _vdom.isVNode)(options)) {
  314. options = {
  315. message: options
  316. };
  317. if (typeof arguments[1] === 'string') {
  318. options.title = arguments[1];
  319. }
  320. } else if (options.callback && !callback) {
  321. callback = options.callback;
  322. }
  323. if (typeof Promise !== 'undefined') {
  324. return new Promise(function (resolve, reject) {
  325. // eslint-disable-line
  326. msgQueue.push({
  327. options: (0, _merge2.default)({}, defaults, MessageBox.defaults, options),
  328. callback: callback,
  329. resolve: resolve,
  330. reject: reject
  331. });
  332. showNextMsg();
  333. });
  334. } else {
  335. msgQueue.push({
  336. options: (0, _merge2.default)({}, defaults, MessageBox.defaults, options),
  337. callback: callback
  338. });
  339. showNextMsg();
  340. }
  341. };
  342. MessageBox.setDefaults = function (defaults) {
  343. MessageBox.defaults = defaults;
  344. };
  345. MessageBox.alert = function (message, title, options) {
  346. if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') {
  347. options = title;
  348. title = '';
  349. } else if (title === undefined) {
  350. title = '';
  351. }
  352. return MessageBox((0, _merge2.default)({
  353. title: title,
  354. message: message,
  355. $type: 'alert',
  356. closeOnPressEscape: false,
  357. closeOnClickModal: false
  358. }, options));
  359. };
  360. MessageBox.confirm = function (message, title, options) {
  361. if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') {
  362. options = title;
  363. title = '';
  364. } else if (title === undefined) {
  365. title = '';
  366. }
  367. return MessageBox((0, _merge2.default)({
  368. title: title,
  369. message: message,
  370. $type: 'confirm',
  371. showCancelButton: true
  372. }, options));
  373. };
  374. MessageBox.prompt = function (message, title, options) {
  375. if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') {
  376. options = title;
  377. title = '';
  378. } else if (title === undefined) {
  379. title = '';
  380. }
  381. return MessageBox((0, _merge2.default)({
  382. title: title,
  383. message: message,
  384. showCancelButton: true,
  385. showInput: true,
  386. $type: 'prompt'
  387. }, options));
  388. };
  389. MessageBox.close = function () {
  390. instance.doClose();
  391. instance.visible = false;
  392. msgQueue = [];
  393. currentMsg = null;
  394. };
  395. exports.default = MessageBox;
  396. exports.MessageBox = MessageBox;
  397. /***/ }),
  398. /***/ 211:
  399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  400. "use strict";
  401. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  402. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue__ = __webpack_require__(212);
  403. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue__);
  404. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_05b9df22_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_main_vue__ = __webpack_require__(214);
  405. var normalizeComponent = __webpack_require__(0)
  406. /* script */
  407. /* template */
  408. /* template functional */
  409. var __vue_template_functional__ = false
  410. /* styles */
  411. var __vue_styles__ = null
  412. /* scopeId */
  413. var __vue_scopeId__ = null
  414. /* moduleIdentifier (server only) */
  415. var __vue_module_identifier__ = null
  416. var Component = normalizeComponent(
  417. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue___default.a,
  418. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_05b9df22_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_main_vue__["a" /* default */],
  419. __vue_template_functional__,
  420. __vue_styles__,
  421. __vue_scopeId__,
  422. __vue_module_identifier__
  423. )
  424. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  425. /***/ }),
  426. /***/ 212:
  427. /***/ (function(module, exports, __webpack_require__) {
  428. "use strict";
  429. exports.__esModule = true;
  430. var _popup = __webpack_require__(13);
  431. var _popup2 = _interopRequireDefault(_popup);
  432. var _locale = __webpack_require__(5);
  433. var _locale2 = _interopRequireDefault(_locale);
  434. var _input = __webpack_require__(6);
  435. var _input2 = _interopRequireDefault(_input);
  436. var _button = __webpack_require__(15);
  437. var _button2 = _interopRequireDefault(_button);
  438. var _dom = __webpack_require__(3);
  439. var _locale3 = __webpack_require__(12);
  440. var _ariaDialog = __webpack_require__(213);
  441. var _ariaDialog2 = _interopRequireDefault(_ariaDialog);
  442. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  443. var messageBox = void 0; //
  444. //
  445. //
  446. //
  447. //
  448. //
  449. //
  450. //
  451. //
  452. //
  453. //
  454. //
  455. //
  456. //
  457. //
  458. //
  459. //
  460. //
  461. //
  462. //
  463. //
  464. //
  465. //
  466. //
  467. //
  468. //
  469. //
  470. //
  471. //
  472. //
  473. //
  474. //
  475. //
  476. //
  477. //
  478. //
  479. //
  480. //
  481. //
  482. //
  483. //
  484. //
  485. //
  486. //
  487. //
  488. //
  489. //
  490. //
  491. //
  492. //
  493. //
  494. //
  495. //
  496. //
  497. //
  498. //
  499. //
  500. //
  501. //
  502. //
  503. //
  504. //
  505. //
  506. //
  507. //
  508. //
  509. //
  510. //
  511. //
  512. //
  513. //
  514. //
  515. //
  516. //
  517. //
  518. //
  519. //
  520. //
  521. var typeMap = {
  522. success: 'success',
  523. info: 'info',
  524. warning: 'warning',
  525. error: 'error'
  526. };
  527. exports.default = {
  528. mixins: [_popup2.default, _locale2.default],
  529. props: {
  530. modal: {
  531. default: true
  532. },
  533. lockScroll: {
  534. default: true
  535. },
  536. showClose: {
  537. type: Boolean,
  538. default: true
  539. },
  540. closeOnClickModal: {
  541. default: true
  542. },
  543. closeOnPressEscape: {
  544. default: true
  545. },
  546. closeOnHashChange: {
  547. default: true
  548. },
  549. center: {
  550. default: false,
  551. type: Boolean
  552. },
  553. roundButton: {
  554. default: false,
  555. type: Boolean
  556. }
  557. },
  558. components: {
  559. ElInput: _input2.default,
  560. ElButton: _button2.default
  561. },
  562. computed: {
  563. icon: function icon() {
  564. var type = this.type,
  565. iconClass = this.iconClass;
  566. return iconClass || (type && typeMap[type] ? 'el-icon-' + typeMap[type] : '');
  567. },
  568. confirmButtonClasses: function confirmButtonClasses() {
  569. return 'el-button--primary ' + this.confirmButtonClass;
  570. },
  571. cancelButtonClasses: function cancelButtonClasses() {
  572. return '' + this.cancelButtonClass;
  573. }
  574. },
  575. methods: {
  576. getSafeClose: function getSafeClose() {
  577. var _this = this;
  578. var currentId = this.uid;
  579. return function () {
  580. _this.$nextTick(function () {
  581. if (currentId === _this.uid) _this.doClose();
  582. });
  583. };
  584. },
  585. doClose: function doClose() {
  586. var _this2 = this;
  587. if (!this.visible) return;
  588. this.visible = false;
  589. this._closing = true;
  590. this.onClose && this.onClose();
  591. messageBox.closeDialog(); // 解绑
  592. if (this.lockScroll) {
  593. setTimeout(this.restoreBodyStyle, 200);
  594. }
  595. this.opened = false;
  596. this.doAfterClose();
  597. setTimeout(function () {
  598. if (_this2.action) _this2.callback(_this2.action, _this2);
  599. });
  600. },
  601. handleWrapperClick: function handleWrapperClick() {
  602. if (this.closeOnClickModal) {
  603. this.handleAction(this.distinguishCancelAndClose ? 'close' : 'cancel');
  604. }
  605. },
  606. handleInputEnter: function handleInputEnter() {
  607. if (this.inputType !== 'textarea') {
  608. return this.handleAction('confirm');
  609. }
  610. },
  611. handleAction: function handleAction(action) {
  612. if (this.$type === 'prompt' && action === 'confirm' && !this.validate()) {
  613. return;
  614. }
  615. this.action = action;
  616. if (typeof this.beforeClose === 'function') {
  617. this.close = this.getSafeClose();
  618. this.beforeClose(action, this, this.close);
  619. } else {
  620. this.doClose();
  621. }
  622. },
  623. validate: function validate() {
  624. if (this.$type === 'prompt') {
  625. var inputPattern = this.inputPattern;
  626. if (inputPattern && !inputPattern.test(this.inputValue || '')) {
  627. this.editorErrorMessage = this.inputErrorMessage || (0, _locale3.t)('el.messagebox.error');
  628. (0, _dom.addClass)(this.getInputElement(), 'invalid');
  629. return false;
  630. }
  631. var inputValidator = this.inputValidator;
  632. if (typeof inputValidator === 'function') {
  633. var validateResult = inputValidator(this.inputValue);
  634. if (validateResult === false) {
  635. this.editorErrorMessage = this.inputErrorMessage || (0, _locale3.t)('el.messagebox.error');
  636. (0, _dom.addClass)(this.getInputElement(), 'invalid');
  637. return false;
  638. }
  639. if (typeof validateResult === 'string') {
  640. this.editorErrorMessage = validateResult;
  641. (0, _dom.addClass)(this.getInputElement(), 'invalid');
  642. return false;
  643. }
  644. }
  645. }
  646. this.editorErrorMessage = '';
  647. (0, _dom.removeClass)(this.getInputElement(), 'invalid');
  648. return true;
  649. },
  650. getFirstFocus: function getFirstFocus() {
  651. var btn = this.$el.querySelector('.el-message-box__btns .el-button');
  652. var title = this.$el.querySelector('.el-message-box__btns .el-message-box__title');
  653. return btn || title;
  654. },
  655. getInputElement: function getInputElement() {
  656. var inputRefs = this.$refs.input.$refs;
  657. return inputRefs.input || inputRefs.textarea;
  658. }
  659. },
  660. watch: {
  661. inputValue: {
  662. immediate: true,
  663. handler: function handler(val) {
  664. var _this3 = this;
  665. this.$nextTick(function (_) {
  666. if (_this3.$type === 'prompt' && val !== null) {
  667. _this3.validate();
  668. }
  669. });
  670. }
  671. },
  672. visible: function visible(val) {
  673. var _this4 = this;
  674. if (val) {
  675. this.uid++;
  676. if (this.$type === 'alert' || this.$type === 'confirm') {
  677. this.$nextTick(function () {
  678. _this4.$refs.confirm.$el.focus();
  679. });
  680. }
  681. this.focusAfterClosed = document.activeElement;
  682. messageBox = new _ariaDialog2.default(this.$el, this.focusAfterClosed, this.getFirstFocus());
  683. }
  684. // prompt
  685. if (this.$type !== 'prompt') return;
  686. if (val) {
  687. setTimeout(function () {
  688. if (_this4.$refs.input && _this4.$refs.input.$el) {
  689. _this4.getInputElement().focus();
  690. }
  691. }, 500);
  692. } else {
  693. this.editorErrorMessage = '';
  694. (0, _dom.removeClass)(this.getInputElement(), 'invalid');
  695. }
  696. }
  697. },
  698. mounted: function mounted() {
  699. var _this5 = this;
  700. this.$nextTick(function () {
  701. if (_this5.closeOnHashChange) {
  702. window.addEventListener('hashchange', _this5.close);
  703. }
  704. });
  705. },
  706. beforeDestroy: function beforeDestroy() {
  707. if (this.closeOnHashChange) {
  708. window.removeEventListener('hashchange', this.close);
  709. }
  710. setTimeout(function () {
  711. messageBox.closeDialog();
  712. });
  713. },
  714. data: function data() {
  715. return {
  716. uid: 1,
  717. title: undefined,
  718. message: '',
  719. type: '',
  720. iconClass: '',
  721. customClass: '',
  722. showInput: false,
  723. inputValue: null,
  724. inputPlaceholder: '',
  725. inputType: 'text',
  726. inputPattern: null,
  727. inputValidator: null,
  728. inputErrorMessage: '',
  729. showConfirmButton: true,
  730. showCancelButton: false,
  731. action: '',
  732. confirmButtonText: '',
  733. cancelButtonText: '',
  734. confirmButtonLoading: false,
  735. cancelButtonLoading: false,
  736. confirmButtonClass: '',
  737. confirmButtonDisabled: false,
  738. cancelButtonClass: '',
  739. editorErrorMessage: null,
  740. callback: null,
  741. dangerouslyUseHTMLString: false,
  742. focusAfterClosed: null,
  743. isOnComposition: false,
  744. distinguishCancelAndClose: false
  745. };
  746. }
  747. };
  748. /***/ }),
  749. /***/ 213:
  750. /***/ (function(module, exports) {
  751. module.exports = require("element-ui/lib/utils/aria-dialog");
  752. /***/ }),
  753. /***/ 214:
  754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  755. "use strict";
  756. var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"msgbox-fade"}},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.visible),expression:"visible"}],staticClass:"el-message-box__wrapper",attrs:{"tabindex":"-1","role":"dialog","aria-modal":"true","aria-label":_vm.title || 'dialog'},on:{"click":function($event){if($event.target !== $event.currentTarget){ return null; }_vm.handleWrapperClick($event)}}},[_c('div',{staticClass:"el-message-box",class:[_vm.customClass, _vm.center && 'el-message-box--center']},[(_vm.title !== null)?_c('div',{staticClass:"el-message-box__header"},[_c('div',{staticClass:"el-message-box__title"},[(_vm.icon && _vm.center)?_c('div',{class:['el-message-box__status', _vm.icon]}):_vm._e(),_c('span',[_vm._v(_vm._s(_vm.title))])]),(_vm.showClose)?_c('button',{staticClass:"el-message-box__headerbtn",attrs:{"type":"button","aria-label":"Close"},on:{"click":function($event){_vm.handleAction(_vm.distinguishCancelAndClose ? 'close' : 'cancel')},"keydown":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,"enter",13,$event.key)){ return null; }_vm.handleAction(_vm.distinguishCancelAndClose ? 'close' : 'cancel')}}},[_c('i',{staticClass:"el-message-box__close el-icon-close"})]):_vm._e()]):_vm._e(),_c('div',{staticClass:"el-message-box__content"},[(_vm.icon && !_vm.center && _vm.message !== '')?_c('div',{class:['el-message-box__status', _vm.icon]}):_vm._e(),(_vm.message !== '')?_c('div',{staticClass:"el-message-box__message"},[_vm._t("default",[(!_vm.dangerouslyUseHTMLString)?_c('p',[_vm._v(_vm._s(_vm.message))]):_c('p',{domProps:{"innerHTML":_vm._s(_vm.message)}})])],2):_vm._e(),_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.showInput),expression:"showInput"}],staticClass:"el-message-box__input"},[_c('el-input',{ref:"input",attrs:{"type":_vm.inputType,"placeholder":_vm.inputPlaceholder},nativeOn:{"keydown":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,"enter",13,$event.key)){ return null; }_vm.handleInputEnter($event)}},model:{value:(_vm.inputValue),callback:function ($$v) {_vm.inputValue=$$v},expression:"inputValue"}}),_c('div',{staticClass:"el-message-box__errormsg",style:({ visibility: !!_vm.editorErrorMessage ? 'visible' : 'hidden' })},[_vm._v(_vm._s(_vm.editorErrorMessage))])],1)]),_c('div',{staticClass:"el-message-box__btns"},[(_vm.showCancelButton)?_c('el-button',{class:[ _vm.cancelButtonClasses ],attrs:{"loading":_vm.cancelButtonLoading,"round":_vm.roundButton,"size":"small"},on:{"keydown":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,"enter",13,$event.key)){ return null; }_vm.handleAction('cancel')}},nativeOn:{"click":function($event){_vm.handleAction('cancel')}}},[_vm._v("\n "+_vm._s(_vm.cancelButtonText || _vm.t('el.messagebox.cancel'))+"\n ")]):_vm._e(),_c('el-button',{directives:[{name:"show",rawName:"v-show",value:(_vm.showConfirmButton),expression:"showConfirmButton"}],ref:"confirm",class:[ _vm.confirmButtonClasses ],attrs:{"loading":_vm.confirmButtonLoading,"round":_vm.roundButton,"size":"small"},on:{"keydown":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,"enter",13,$event.key)){ return null; }_vm.handleAction('confirm')}},nativeOn:{"click":function($event){_vm.handleAction('confirm')}}},[_vm._v("\n "+_vm._s(_vm.confirmButtonText || _vm.t('el.messagebox.confirm'))+"\n ")])],1)])])])}
  757. var staticRenderFns = []
  758. var esExports = { render: render, staticRenderFns: staticRenderFns }
  759. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  760. /***/ }),
  761. /***/ 3:
  762. /***/ (function(module, exports) {
  763. module.exports = require("element-ui/lib/utils/dom");
  764. /***/ }),
  765. /***/ 4:
  766. /***/ (function(module, exports) {
  767. module.exports = require("vue");
  768. /***/ }),
  769. /***/ 5:
  770. /***/ (function(module, exports) {
  771. module.exports = require("element-ui/lib/mixins/locale");
  772. /***/ }),
  773. /***/ 6:
  774. /***/ (function(module, exports) {
  775. module.exports = require("element-ui/lib/input");
  776. /***/ }),
  777. /***/ 9:
  778. /***/ (function(module, exports) {
  779. module.exports = require("element-ui/lib/utils/merge");
  780. /***/ })
  781. /******/ });