message-box.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  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 = 238);
  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. /***/ 14:
  164. /***/ (function(module, exports) {
  165. module.exports = require("element-ui/lib/locale");
  166. /***/ }),
  167. /***/ 15:
  168. /***/ (function(module, exports) {
  169. module.exports = require("element-ui/lib/button");
  170. /***/ }),
  171. /***/ 17:
  172. /***/ (function(module, exports) {
  173. module.exports = require("element-ui/lib/utils/popup");
  174. /***/ }),
  175. /***/ 2:
  176. /***/ (function(module, exports) {
  177. module.exports = require("element-ui/lib/utils/dom");
  178. /***/ }),
  179. /***/ 20:
  180. /***/ (function(module, exports) {
  181. module.exports = require("element-ui/lib/utils/vdom");
  182. /***/ }),
  183. /***/ 238:
  184. /***/ (function(module, exports, __webpack_require__) {
  185. module.exports = __webpack_require__(239);
  186. /***/ }),
  187. /***/ 239:
  188. /***/ (function(module, exports, __webpack_require__) {
  189. "use strict";
  190. exports.__esModule = true;
  191. var _main = __webpack_require__(240);
  192. var _main2 = _interopRequireDefault(_main);
  193. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  194. exports.default = _main2.default;
  195. /***/ }),
  196. /***/ 240:
  197. /***/ (function(module, exports, __webpack_require__) {
  198. "use strict";
  199. exports.__esModule = true;
  200. exports.MessageBox = undefined;
  201. 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; };
  202. var _vue = __webpack_require__(5);
  203. var _vue2 = _interopRequireDefault(_vue);
  204. var _main = __webpack_require__(241);
  205. var _main2 = _interopRequireDefault(_main);
  206. var _merge = __webpack_require__(9);
  207. var _merge2 = _interopRequireDefault(_merge);
  208. var _vdom = __webpack_require__(20);
  209. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  210. var defaults = {
  211. title: undefined,
  212. message: '',
  213. type: '',
  214. showInput: false,
  215. showClose: true,
  216. modalFade: true,
  217. lockScroll: true,
  218. closeOnClickModal: true,
  219. closeOnPressEscape: true,
  220. closeOnHashChange: true,
  221. inputValue: null,
  222. inputPlaceholder: '',
  223. inputType: 'text',
  224. inputPattern: null,
  225. inputValidator: null,
  226. inputErrorMessage: '',
  227. showConfirmButton: true,
  228. showCancelButton: false,
  229. confirmButtonPosition: 'right',
  230. confirmButtonHighlight: false,
  231. cancelButtonHighlight: false,
  232. confirmButtonText: '',
  233. cancelButtonText: '',
  234. confirmButtonClass: '',
  235. cancelButtonClass: '',
  236. customClass: '',
  237. beforeClose: null,
  238. dangerouslyUseHTMLString: false,
  239. center: false,
  240. roundButton: false
  241. };
  242. var MessageBoxConstructor = _vue2.default.extend(_main2.default);
  243. var currentMsg = void 0,
  244. instance = void 0;
  245. var msgQueue = [];
  246. var defaultCallback = function defaultCallback(action) {
  247. if (currentMsg) {
  248. var callback = currentMsg.callback;
  249. if (typeof callback === 'function') {
  250. if (instance.showInput) {
  251. callback(instance.inputValue, action);
  252. } else {
  253. callback(action);
  254. }
  255. }
  256. if (currentMsg.resolve) {
  257. if (action === 'confirm') {
  258. if (instance.showInput) {
  259. currentMsg.resolve({ value: instance.inputValue, action: action });
  260. } else {
  261. currentMsg.resolve(action);
  262. }
  263. } else if (action === 'cancel' && currentMsg.reject) {
  264. currentMsg.reject(action);
  265. }
  266. }
  267. }
  268. };
  269. var initInstance = function initInstance() {
  270. instance = new MessageBoxConstructor({
  271. el: document.createElement('div')
  272. });
  273. instance.callback = defaultCallback;
  274. };
  275. var showNextMsg = function showNextMsg() {
  276. if (!instance) {
  277. initInstance();
  278. }
  279. instance.action = '';
  280. if (!instance.visible || instance.closeTimer) {
  281. if (msgQueue.length > 0) {
  282. (function () {
  283. currentMsg = msgQueue.shift();
  284. var options = currentMsg.options;
  285. for (var prop in options) {
  286. if (options.hasOwnProperty(prop)) {
  287. instance[prop] = options[prop];
  288. }
  289. }
  290. if (options.callback === undefined) {
  291. instance.callback = defaultCallback;
  292. }
  293. var oldCb = instance.callback;
  294. instance.callback = function (action, instance) {
  295. oldCb(action, instance);
  296. showNextMsg();
  297. };
  298. if ((0, _vdom.isVNode)(instance.message)) {
  299. instance.$slots.default = [instance.message];
  300. instance.message = null;
  301. } else {
  302. delete instance.$slots.default;
  303. }
  304. ['modal', 'showClose', 'closeOnClickModal', 'closeOnPressEscape', 'closeOnHashChange'].forEach(function (prop) {
  305. if (instance[prop] === undefined) {
  306. instance[prop] = true;
  307. }
  308. });
  309. document.body.appendChild(instance.$el);
  310. _vue2.default.nextTick(function () {
  311. instance.visible = true;
  312. });
  313. })();
  314. }
  315. }
  316. };
  317. var MessageBox = function MessageBox(options, callback) {
  318. if (_vue2.default.prototype.$isServer) return;
  319. if (typeof options === 'string' || (0, _vdom.isVNode)(options)) {
  320. options = {
  321. message: options
  322. };
  323. if (typeof arguments[1] === 'string') {
  324. options.title = arguments[1];
  325. }
  326. } else if (options.callback && !callback) {
  327. callback = options.callback;
  328. }
  329. if (typeof Promise !== 'undefined') {
  330. return new Promise(function (resolve, reject) {
  331. // eslint-disable-line
  332. msgQueue.push({
  333. options: (0, _merge2.default)({}, defaults, MessageBox.defaults, options),
  334. callback: callback,
  335. resolve: resolve,
  336. reject: reject
  337. });
  338. showNextMsg();
  339. });
  340. } else {
  341. msgQueue.push({
  342. options: (0, _merge2.default)({}, defaults, MessageBox.defaults, options),
  343. callback: callback
  344. });
  345. showNextMsg();
  346. }
  347. };
  348. MessageBox.setDefaults = function (defaults) {
  349. MessageBox.defaults = defaults;
  350. };
  351. MessageBox.alert = function (message, title, options) {
  352. if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') {
  353. options = title;
  354. title = '';
  355. } else if (title === undefined) {
  356. title = '';
  357. }
  358. return MessageBox((0, _merge2.default)({
  359. title: title,
  360. message: message,
  361. $type: 'alert',
  362. closeOnPressEscape: false,
  363. closeOnClickModal: false
  364. }, options));
  365. };
  366. MessageBox.confirm = function (message, title, options) {
  367. if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') {
  368. options = title;
  369. title = '';
  370. } else if (title === undefined) {
  371. title = '';
  372. }
  373. return MessageBox((0, _merge2.default)({
  374. title: title,
  375. message: message,
  376. $type: 'confirm',
  377. showCancelButton: true
  378. }, options));
  379. };
  380. MessageBox.prompt = function (message, title, options) {
  381. if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') {
  382. options = title;
  383. title = '';
  384. } else if (title === undefined) {
  385. title = '';
  386. }
  387. return MessageBox((0, _merge2.default)({
  388. title: title,
  389. message: message,
  390. showCancelButton: true,
  391. showInput: true,
  392. $type: 'prompt'
  393. }, options));
  394. };
  395. MessageBox.close = function () {
  396. instance.doClose();
  397. instance.visible = false;
  398. msgQueue = [];
  399. currentMsg = null;
  400. };
  401. exports.default = MessageBox;
  402. exports.MessageBox = MessageBox;
  403. /***/ }),
  404. /***/ 241:
  405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  406. "use strict";
  407. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  408. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue__ = __webpack_require__(242);
  409. /* 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__);
  410. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_f44daa3a_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_main_vue__ = __webpack_require__(244);
  411. var normalizeComponent = __webpack_require__(0)
  412. /* script */
  413. /* template */
  414. /* template functional */
  415. var __vue_template_functional__ = false
  416. /* styles */
  417. var __vue_styles__ = null
  418. /* scopeId */
  419. var __vue_scopeId__ = null
  420. /* moduleIdentifier (server only) */
  421. var __vue_module_identifier__ = null
  422. var Component = normalizeComponent(
  423. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue___default.a,
  424. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_f44daa3a_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_main_vue__["a" /* default */],
  425. __vue_template_functional__,
  426. __vue_styles__,
  427. __vue_scopeId__,
  428. __vue_module_identifier__
  429. )
  430. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  431. /***/ }),
  432. /***/ 242:
  433. /***/ (function(module, exports, __webpack_require__) {
  434. "use strict";
  435. exports.__esModule = true;
  436. var _popup = __webpack_require__(17);
  437. var _popup2 = _interopRequireDefault(_popup);
  438. var _locale = __webpack_require__(4);
  439. var _locale2 = _interopRequireDefault(_locale);
  440. var _input = __webpack_require__(6);
  441. var _input2 = _interopRequireDefault(_input);
  442. var _button = __webpack_require__(15);
  443. var _button2 = _interopRequireDefault(_button);
  444. var _dom = __webpack_require__(2);
  445. var _locale3 = __webpack_require__(14);
  446. var _ariaDialog = __webpack_require__(243);
  447. var _ariaDialog2 = _interopRequireDefault(_ariaDialog);
  448. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  449. var messageBox = void 0; //
  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. //
  522. //
  523. //
  524. //
  525. //
  526. //
  527. var typeMap = {
  528. success: 'success',
  529. info: 'info',
  530. warning: 'warning',
  531. error: 'error'
  532. };
  533. exports.default = {
  534. mixins: [_popup2.default, _locale2.default],
  535. props: {
  536. modal: {
  537. default: true
  538. },
  539. lockScroll: {
  540. default: true
  541. },
  542. showClose: {
  543. type: Boolean,
  544. default: true
  545. },
  546. closeOnClickModal: {
  547. default: true
  548. },
  549. closeOnPressEscape: {
  550. default: true
  551. },
  552. closeOnHashChange: {
  553. default: true
  554. },
  555. center: {
  556. default: false,
  557. type: Boolean
  558. },
  559. roundButton: {
  560. default: false,
  561. type: Boolean
  562. }
  563. },
  564. components: {
  565. ElInput: _input2.default,
  566. ElButton: _button2.default
  567. },
  568. computed: {
  569. typeClass: function typeClass() {
  570. return this.type && typeMap[this.type] ? 'el-icon-' + typeMap[this.type] : '';
  571. },
  572. confirmButtonClasses: function confirmButtonClasses() {
  573. return 'el-button--primary ' + this.confirmButtonClass;
  574. },
  575. cancelButtonClasses: function cancelButtonClasses() {
  576. return '' + this.cancelButtonClass;
  577. }
  578. },
  579. methods: {
  580. handleComposition: function handleComposition(event) {
  581. var _this = this;
  582. if (event.type === 'compositionend') {
  583. setTimeout(function () {
  584. _this.isOnComposition = false;
  585. }, 100);
  586. } else {
  587. this.isOnComposition = true;
  588. }
  589. },
  590. handleKeyup: function handleKeyup() {
  591. !this.isOnComposition && this.handleAction('confirm');
  592. },
  593. getSafeClose: function getSafeClose() {
  594. var _this2 = this;
  595. var currentId = this.uid;
  596. return function () {
  597. _this2.$nextTick(function () {
  598. if (currentId === _this2.uid) _this2.doClose();
  599. });
  600. };
  601. },
  602. doClose: function doClose() {
  603. var _this3 = this;
  604. if (!this.visible) return;
  605. this.visible = false;
  606. this._closing = true;
  607. this.onClose && this.onClose();
  608. messageBox.closeDialog(); // 解绑
  609. if (this.lockScroll) {
  610. setTimeout(function () {
  611. if (_this3.modal && _this3.bodyOverflow !== 'hidden') {
  612. document.body.style.overflow = _this3.bodyOverflow;
  613. document.body.style.paddingRight = _this3.bodyPaddingRight;
  614. }
  615. _this3.bodyOverflow = null;
  616. _this3.bodyPaddingRight = null;
  617. }, 200);
  618. }
  619. this.opened = false;
  620. if (!this.transition) {
  621. this.doAfterClose();
  622. }
  623. setTimeout(function () {
  624. if (_this3.action) _this3.callback(_this3.action, _this3);
  625. });
  626. },
  627. handleWrapperClick: function handleWrapperClick() {
  628. if (this.closeOnClickModal) {
  629. this.handleAction('cancel');
  630. }
  631. },
  632. handleAction: function handleAction(action) {
  633. if (this.$type === 'prompt' && action === 'confirm' && !this.validate()) {
  634. return;
  635. }
  636. this.action = action;
  637. if (typeof this.beforeClose === 'function') {
  638. this.close = this.getSafeClose();
  639. this.beforeClose(action, this, this.close);
  640. } else {
  641. this.doClose();
  642. }
  643. },
  644. validate: function validate() {
  645. if (this.$type === 'prompt') {
  646. var inputPattern = this.inputPattern;
  647. if (inputPattern && !inputPattern.test(this.inputValue || '')) {
  648. this.editorErrorMessage = this.inputErrorMessage || (0, _locale3.t)('el.messagebox.error');
  649. (0, _dom.addClass)(this.getInputElement(), 'invalid');
  650. return false;
  651. }
  652. var inputValidator = this.inputValidator;
  653. if (typeof inputValidator === 'function') {
  654. var validateResult = inputValidator(this.inputValue);
  655. if (validateResult === false) {
  656. this.editorErrorMessage = this.inputErrorMessage || (0, _locale3.t)('el.messagebox.error');
  657. (0, _dom.addClass)(this.getInputElement(), 'invalid');
  658. return false;
  659. }
  660. if (typeof validateResult === 'string') {
  661. this.editorErrorMessage = validateResult;
  662. return false;
  663. }
  664. }
  665. }
  666. this.editorErrorMessage = '';
  667. (0, _dom.removeClass)(this.getInputElement(), 'invalid');
  668. return true;
  669. },
  670. getFistFocus: function getFistFocus() {
  671. var $btns = this.$el.querySelector('.el-message-box__btns .el-button');
  672. var $title = this.$el.querySelector('.el-message-box__btns .el-message-box__title');
  673. return $btns && $btns[0] || $title;
  674. },
  675. getInputElement: function getInputElement() {
  676. var inputRefs = this.$refs.input.$refs;
  677. return inputRefs.input || inputRefs.textarea;
  678. }
  679. },
  680. watch: {
  681. inputValue: {
  682. immediate: true,
  683. handler: function handler(val) {
  684. var _this4 = this;
  685. this.$nextTick(function (_) {
  686. if (_this4.$type === 'prompt' && val !== null) {
  687. _this4.validate();
  688. }
  689. });
  690. }
  691. },
  692. visible: function visible(val) {
  693. var _this5 = this;
  694. if (val) {
  695. this.uid++;
  696. if (this.$type === 'alert' || this.$type === 'confirm') {
  697. this.$nextTick(function () {
  698. _this5.$refs.confirm.$el.focus();
  699. });
  700. }
  701. this.focusAfterClosed = document.activeElement;
  702. messageBox = new _ariaDialog2.default(this.$el, this.focusAfterClosed, this.getFistFocus());
  703. }
  704. // prompt
  705. if (this.$type !== 'prompt') return;
  706. if (val) {
  707. setTimeout(function () {
  708. if (_this5.$refs.input && _this5.$refs.input.$el) {
  709. _this5.getInputElement().focus();
  710. }
  711. }, 500);
  712. } else {
  713. this.editorErrorMessage = '';
  714. (0, _dom.removeClass)(this.getInputElement(), 'invalid');
  715. }
  716. }
  717. },
  718. mounted: function mounted() {
  719. if (this.closeOnHashChange) {
  720. window.addEventListener('hashchange', this.close);
  721. }
  722. },
  723. beforeDestroy: function beforeDestroy() {
  724. if (this.closeOnHashChange) {
  725. window.removeEventListener('hashchange', this.close);
  726. }
  727. setTimeout(function () {
  728. messageBox.closeDialog();
  729. });
  730. },
  731. data: function data() {
  732. return {
  733. uid: 1,
  734. title: undefined,
  735. message: '',
  736. type: '',
  737. customClass: '',
  738. showInput: false,
  739. inputValue: null,
  740. inputPlaceholder: '',
  741. inputType: 'text',
  742. inputPattern: null,
  743. inputValidator: null,
  744. inputErrorMessage: '',
  745. showConfirmButton: true,
  746. showCancelButton: false,
  747. action: '',
  748. confirmButtonText: '',
  749. cancelButtonText: '',
  750. confirmButtonLoading: false,
  751. cancelButtonLoading: false,
  752. confirmButtonClass: '',
  753. confirmButtonDisabled: false,
  754. cancelButtonClass: '',
  755. editorErrorMessage: null,
  756. callback: null,
  757. dangerouslyUseHTMLString: false,
  758. focusAfterClosed: null,
  759. isOnComposition: false
  760. };
  761. }
  762. };
  763. /***/ }),
  764. /***/ 243:
  765. /***/ (function(module, exports) {
  766. module.exports = require("element-ui/lib/utils/aria-dialog");
  767. /***/ }),
  768. /***/ 244:
  769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  770. "use strict";
  771. 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 !== undefined)?_c('div',{staticClass:"el-message-box__header"},[_c('div',{staticClass:"el-message-box__title"},[(_vm.typeClass && _vm.center)?_c('div',{staticClass:"el-message-box__status",class:[ _vm.typeClass ]}):_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('cancel')},"keydown":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,"enter",13,$event.key)){ return null; }_vm.handleAction('cancel')}}},[_c('i',{staticClass:"el-message-box__close el-icon-close"})]):_vm._e()]):_vm._e(),(_vm.message !== '')?_c('div',{staticClass:"el-message-box__content"},[(_vm.typeClass && !_vm.center)?_c('div',{staticClass:"el-message-box__status",class:[ _vm.typeClass ]}):_vm._e(),_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),_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:{"compositionstart":function($event){_vm.handleComposition($event)},"compositionupdate":function($event){_vm.handleComposition($event)},"compositionend":function($event){_vm.handleComposition($event)},"keyup":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,"enter",13,$event.key)){ return null; }_vm.handleKeyup($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)]):_vm._e(),_c('div',{staticClass:"el-message-box__btns"},[_c('el-button',{directives:[{name:"show",rawName:"v-show",value:(_vm.showCancelButton),expression:"showCancelButton"}],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 ")]),_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)])])])}
  772. var staticRenderFns = []
  773. var esExports = { render: render, staticRenderFns: staticRenderFns }
  774. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  775. /***/ }),
  776. /***/ 4:
  777. /***/ (function(module, exports) {
  778. module.exports = require("element-ui/lib/mixins/locale");
  779. /***/ }),
  780. /***/ 5:
  781. /***/ (function(module, exports) {
  782. module.exports = require("vue");
  783. /***/ }),
  784. /***/ 6:
  785. /***/ (function(module, exports) {
  786. module.exports = require("element-ui/lib/input");
  787. /***/ }),
  788. /***/ 9:
  789. /***/ (function(module, exports) {
  790. module.exports = require("element-ui/lib/utils/merge");
  791. /***/ })
  792. /******/ });