index.js 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/ // Check if module is in cache
  8. /******/ if(installedModules[moduleId])
  9. /******/ return installedModules[moduleId].exports;
  10. /******/ // Create a new module (and put it into the cache)
  11. /******/ var module = installedModules[moduleId] = {
  12. /******/ i: moduleId,
  13. /******/ l: false,
  14. /******/ exports: {}
  15. /******/ };
  16. /******/ // Execute the module function
  17. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  18. /******/ // Flag the module as loaded
  19. /******/ module.l = true;
  20. /******/ // Return the exports of the module
  21. /******/ return module.exports;
  22. /******/ }
  23. /******/ // expose the modules object (__webpack_modules__)
  24. /******/ __webpack_require__.m = modules;
  25. /******/ // expose the module cache
  26. /******/ __webpack_require__.c = installedModules;
  27. /******/ // identity function for calling harmony imports with the correct context
  28. /******/ __webpack_require__.i = function(value) { return value; };
  29. /******/ // define getter function for harmony exports
  30. /******/ __webpack_require__.d = function(exports, name, getter) {
  31. /******/ if(!__webpack_require__.o(exports, name)) {
  32. /******/ Object.defineProperty(exports, name, {
  33. /******/ configurable: false,
  34. /******/ enumerable: true,
  35. /******/ get: getter
  36. /******/ });
  37. /******/ }
  38. /******/ };
  39. /******/ // getDefaultExport function for compatibility with non-harmony modules
  40. /******/ __webpack_require__.n = function(module) {
  41. /******/ var getter = module && module.__esModule ?
  42. /******/ function getDefault() { return module['default']; } :
  43. /******/ function getModuleExports() { return module; };
  44. /******/ __webpack_require__.d(getter, 'a', getter);
  45. /******/ return getter;
  46. /******/ };
  47. /******/ // Object.prototype.hasOwnProperty.call
  48. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  49. /******/ // __webpack_public_path__
  50. /******/ __webpack_require__.p = "";
  51. /******/ // Load entry module and return exports
  52. /******/ return __webpack_require__(__webpack_require__.s = 209);
  53. /******/ })
  54. /************************************************************************/
  55. /******/ ({
  56. /***/ 0:
  57. /***/ function(module, exports) {
  58. /* globals __VUE_SSR_CONTEXT__ */
  59. // this module is a runtime utility for cleaner component module output and will
  60. // be included in the final webpack user bundle
  61. module.exports = function normalizeComponent (
  62. rawScriptExports,
  63. compiledTemplate,
  64. injectStyles,
  65. scopeId,
  66. moduleIdentifier /* server only */
  67. ) {
  68. var esModule
  69. var scriptExports = rawScriptExports = rawScriptExports || {}
  70. // ES6 modules interop
  71. var type = typeof rawScriptExports.default
  72. if (type === 'object' || type === 'function') {
  73. esModule = rawScriptExports
  74. scriptExports = rawScriptExports.default
  75. }
  76. // Vue.extend constructor export interop
  77. var options = typeof scriptExports === 'function'
  78. ? scriptExports.options
  79. : scriptExports
  80. // render functions
  81. if (compiledTemplate) {
  82. options.render = compiledTemplate.render
  83. options.staticRenderFns = compiledTemplate.staticRenderFns
  84. }
  85. // scopedId
  86. if (scopeId) {
  87. options._scopeId = scopeId
  88. }
  89. var hook
  90. if (moduleIdentifier) { // server build
  91. hook = function (context) {
  92. // 2.3 injection
  93. context =
  94. context || // cached call
  95. (this.$vnode && this.$vnode.ssrContext) || // stateful
  96. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  97. // 2.2 with runInNewContext: true
  98. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  99. context = __VUE_SSR_CONTEXT__
  100. }
  101. // inject component styles
  102. if (injectStyles) {
  103. injectStyles.call(this, context)
  104. }
  105. // register component module identifier for async chunk inferrence
  106. if (context && context._registeredComponents) {
  107. context._registeredComponents.add(moduleIdentifier)
  108. }
  109. }
  110. // used by ssr in case component is cached and beforeCreate
  111. // never gets called
  112. options._ssrRegister = hook
  113. } else if (injectStyles) {
  114. hook = injectStyles
  115. }
  116. if (hook) {
  117. var functional = options.functional
  118. var existing = functional
  119. ? options.render
  120. : options.beforeCreate
  121. if (!functional) {
  122. // inject component registration as beforeCreate hook
  123. options.beforeCreate = existing
  124. ? [].concat(existing, hook)
  125. : [hook]
  126. } else {
  127. // register for functioal component in vue file
  128. options.render = function renderWithStyleInjection (h, context) {
  129. hook.call(context)
  130. return existing(h, context)
  131. }
  132. }
  133. }
  134. return {
  135. esModule: esModule,
  136. exports: scriptExports,
  137. options: options
  138. }
  139. }
  140. /***/ },
  141. /***/ 1:
  142. /***/ function(module, exports) {
  143. module.exports = require("vue");
  144. /***/ },
  145. /***/ 104:
  146. /***/ function(module, exports) {
  147. // removed by extract-text-webpack-plugin
  148. /***/ },
  149. /***/ 13:
  150. /***/ function(module, exports) {
  151. // removed by extract-text-webpack-plugin
  152. /***/ },
  153. /***/ 130:
  154. /***/ function(module, exports, __webpack_require__) {
  155. function injectStyle (ssrContext) {
  156. __webpack_require__(104)
  157. }
  158. var Component = __webpack_require__(0)(
  159. /* script */
  160. __webpack_require__(52),
  161. /* template */
  162. __webpack_require__(173),
  163. /* styles */
  164. injectStyle,
  165. /* scopeId */
  166. null,
  167. /* moduleIdentifier (server only) */
  168. null
  169. )
  170. module.exports = Component.exports
  171. /***/ },
  172. /***/ 173:
  173. /***/ function(module, exports) {
  174. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  175. return _c('transition', {
  176. attrs: {
  177. "name": "actionsheet-float"
  178. }
  179. }, [_c('div', {
  180. directives: [{
  181. name: "show",
  182. rawName: "v-show",
  183. value: (_vm.currentValue),
  184. expression: "currentValue"
  185. }],
  186. staticClass: "mint-actionsheet"
  187. }, [_c('ul', {
  188. staticClass: "mint-actionsheet-list",
  189. style: ({
  190. 'margin-bottom': _vm.cancelText ? '5px' : '0'
  191. })
  192. }, _vm._l((_vm.actions), function(item, index) {
  193. return _c('li', {
  194. staticClass: "mint-actionsheet-listitem",
  195. on: {
  196. "click": function($event) {
  197. $event.stopPropagation();
  198. _vm.itemClick(item, index)
  199. }
  200. }
  201. }, [_vm._v(_vm._s(item.name))])
  202. })), _vm._v(" "), (_vm.cancelText) ? _c('a', {
  203. staticClass: "mint-actionsheet-button",
  204. on: {
  205. "click": function($event) {
  206. $event.stopPropagation();
  207. _vm.currentValue = false
  208. }
  209. }
  210. }, [_vm._v(_vm._s(_vm.cancelText))]) : _vm._e()])])
  211. },staticRenderFns: []}
  212. /***/ },
  213. /***/ 18:
  214. /***/ function(module, exports, __webpack_require__) {
  215. "use strict";
  216. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_actionsheet_vue__ = __webpack_require__(130);
  217. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_actionsheet_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__src_actionsheet_vue__);
  218. Object.defineProperty(exports, "__esModule", { value: true });
  219. /* harmony reexport (default from non-hamory) */ __webpack_require__.d(exports, "default", function() { return __WEBPACK_IMPORTED_MODULE_0__src_actionsheet_vue___default.a; });
  220. /***/ },
  221. /***/ 2:
  222. /***/ function(module, exports, __webpack_require__) {
  223. "use strict";
  224. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
  225. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
  226. /* unused harmony export on */
  227. /* unused harmony export off */
  228. /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return once; });
  229. /* unused harmony export hasClass */
  230. /* harmony export (immutable) */ exports["a"] = addClass;
  231. /* harmony export (immutable) */ exports["b"] = removeClass;
  232. /* unused harmony export getStyle */
  233. /* unused harmony export setStyle */
  234. /* istanbul ignore next */
  235. var isServer = __WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer;
  236. var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
  237. var MOZ_HACK_REGEXP = /^moz([A-Z])/;
  238. var ieVersion = isServer ? 0 : Number(document.documentMode);
  239. /* istanbul ignore next */
  240. var trim = function(string) {
  241. return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
  242. };
  243. /* istanbul ignore next */
  244. var camelCase = function(name) {
  245. return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
  246. return offset ? letter.toUpperCase() : letter;
  247. }).replace(MOZ_HACK_REGEXP, 'Moz$1');
  248. };
  249. /* istanbul ignore next */
  250. var on = (function() {
  251. if (!isServer && document.addEventListener) {
  252. return function(element, event, handler) {
  253. if (element && event && handler) {
  254. element.addEventListener(event, handler, false);
  255. }
  256. };
  257. } else {
  258. return function(element, event, handler) {
  259. if (element && event && handler) {
  260. element.attachEvent('on' + event, handler);
  261. }
  262. };
  263. }
  264. })();
  265. /* istanbul ignore next */
  266. var off = (function() {
  267. if (!isServer && document.removeEventListener) {
  268. return function(element, event, handler) {
  269. if (element && event) {
  270. element.removeEventListener(event, handler, false);
  271. }
  272. };
  273. } else {
  274. return function(element, event, handler) {
  275. if (element && event) {
  276. element.detachEvent('on' + event, handler);
  277. }
  278. };
  279. }
  280. })();
  281. /* istanbul ignore next */
  282. var once = function(el, event, fn) {
  283. var listener = function() {
  284. if (fn) {
  285. fn.apply(this, arguments);
  286. }
  287. off(el, event, listener);
  288. };
  289. on(el, event, listener);
  290. };
  291. /* istanbul ignore next */
  292. function hasClass(el, cls) {
  293. if (!el || !cls) return false;
  294. if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.');
  295. if (el.classList) {
  296. return el.classList.contains(cls);
  297. } else {
  298. return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
  299. }
  300. };
  301. /* istanbul ignore next */
  302. function addClass(el, cls) {
  303. if (!el) return;
  304. var curClass = el.className;
  305. var classes = (cls || '').split(' ');
  306. for (var i = 0, j = classes.length; i < j; i++) {
  307. var clsName = classes[i];
  308. if (!clsName) continue;
  309. if (el.classList) {
  310. el.classList.add(clsName);
  311. } else {
  312. if (!hasClass(el, clsName)) {
  313. curClass += ' ' + clsName;
  314. }
  315. }
  316. }
  317. if (!el.classList) {
  318. el.className = curClass;
  319. }
  320. };
  321. /* istanbul ignore next */
  322. function removeClass(el, cls) {
  323. if (!el || !cls) return;
  324. var classes = cls.split(' ');
  325. var curClass = ' ' + el.className + ' ';
  326. for (var i = 0, j = classes.length; i < j; i++) {
  327. var clsName = classes[i];
  328. if (!clsName) continue;
  329. if (el.classList) {
  330. el.classList.remove(clsName);
  331. } else {
  332. if (hasClass(el, clsName)) {
  333. curClass = curClass.replace(' ' + clsName + ' ', ' ');
  334. }
  335. }
  336. }
  337. if (!el.classList) {
  338. el.className = trim(curClass);
  339. }
  340. };
  341. /* istanbul ignore next */
  342. var getStyle = ieVersion < 9 ? function(element, styleName) {
  343. if (isServer) return;
  344. if (!element || !styleName) return null;
  345. styleName = camelCase(styleName);
  346. if (styleName === 'float') {
  347. styleName = 'styleFloat';
  348. }
  349. try {
  350. switch (styleName) {
  351. case 'opacity':
  352. try {
  353. return element.filters.item('alpha').opacity / 100;
  354. } catch (e) {
  355. return 1.0;
  356. }
  357. default:
  358. return (element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null);
  359. }
  360. } catch (e) {
  361. return element.style[styleName];
  362. }
  363. } : function(element, styleName) {
  364. if (isServer) return;
  365. if (!element || !styleName) return null;
  366. styleName = camelCase(styleName);
  367. if (styleName === 'float') {
  368. styleName = 'cssFloat';
  369. }
  370. try {
  371. var computed = document.defaultView.getComputedStyle(element, '');
  372. return element.style[styleName] || computed ? computed[styleName] : null;
  373. } catch (e) {
  374. return element.style[styleName];
  375. }
  376. };
  377. /* istanbul ignore next */
  378. function setStyle(element, styleName, value) {
  379. if (!element || !styleName) return;
  380. if (typeof styleName === 'object') {
  381. for (var prop in styleName) {
  382. if (styleName.hasOwnProperty(prop)) {
  383. setStyle(element, prop, styleName[prop]);
  384. }
  385. }
  386. } else {
  387. styleName = camelCase(styleName);
  388. if (styleName === 'opacity' && ieVersion < 9) {
  389. element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')';
  390. } else {
  391. element.style[styleName] = value;
  392. }
  393. }
  394. };
  395. /***/ },
  396. /***/ 209:
  397. /***/ function(module, exports, __webpack_require__) {
  398. module.exports = __webpack_require__(18);
  399. /***/ },
  400. /***/ 52:
  401. /***/ function(module, exports, __webpack_require__) {
  402. "use strict";
  403. Object.defineProperty(exports, "__esModule", { value: true });
  404. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_popup__ = __webpack_require__(8);
  405. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_mint_ui_src_style_popup_css__ = __webpack_require__(13);
  406. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_mint_ui_src_style_popup_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_style_popup_css__);
  407. //
  408. //
  409. //
  410. //
  411. //
  412. //
  413. //
  414. //
  415. //
  416. //
  417. //
  418. //
  419. //
  420. //
  421. //
  422. //
  423. //
  424. //
  425. //
  426. //
  427. //
  428. //
  429. //
  430. //
  431. //
  432. //
  433. //
  434. //
  435. //
  436. //
  437. //
  438. //
  439. //
  440. //
  441. //
  442. //
  443. //
  444. //
  445. //
  446. //
  447. //
  448. //
  449. //
  450. //
  451. //
  452. //
  453. //
  454. //
  455. //
  456. //
  457. //
  458. //
  459. //
  460. //
  461. //
  462. /* harmony default export */ exports["default"] = {
  463. name: 'mt-actionsheet',
  464. mixins: [__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_popup__["a" /* default */]],
  465. props: {
  466. modal: {
  467. default: true
  468. },
  469. modalFade: {
  470. default: false
  471. },
  472. lockScroll: {
  473. default: false
  474. },
  475. closeOnClickModal: {
  476. default: true
  477. },
  478. cancelText: {
  479. type: String,
  480. default: '取消'
  481. },
  482. actions: {
  483. type: Array,
  484. default: function () { return []; }
  485. }
  486. },
  487. data: function data() {
  488. return {
  489. currentValue: false
  490. };
  491. },
  492. watch: {
  493. currentValue: function currentValue(val) {
  494. this.$emit('input', val);
  495. },
  496. value: function value(val) {
  497. this.currentValue = val;
  498. }
  499. },
  500. methods: {
  501. itemClick: function itemClick(item, index) {
  502. if (item.method && typeof item.method === 'function') {
  503. item.method(item, index);
  504. }
  505. this.currentValue = false;
  506. }
  507. },
  508. mounted: function mounted() {
  509. if (this.value) {
  510. this.rendered = true;
  511. this.currentValue = true;
  512. this.open();
  513. }
  514. }
  515. };
  516. /***/ },
  517. /***/ 7:
  518. /***/ function(module, exports, __webpack_require__) {
  519. "use strict";
  520. /* harmony default export */ exports["a"] = function(target) {
  521. var arguments$1 = arguments;
  522. for (var i = 1, j = arguments.length; i < j; i++) {
  523. var source = arguments$1[i] || {};
  524. for (var prop in source) {
  525. if (source.hasOwnProperty(prop)) {
  526. var value = source[prop];
  527. if (value !== undefined) {
  528. target[prop] = value;
  529. }
  530. }
  531. }
  532. }
  533. return target;
  534. };;
  535. /***/ },
  536. /***/ 8:
  537. /***/ function(module, exports, __webpack_require__) {
  538. "use strict";
  539. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
  540. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
  541. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_merge__ = __webpack_require__(7);
  542. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__ = __webpack_require__(9);
  543. /* unused harmony reexport PopupManager */
  544. var idSeed = 1;
  545. var transitions = [];
  546. var hookTransition = function (transition) {
  547. if (transitions.indexOf(transition) !== -1) return;
  548. var getVueInstance = function (element) {
  549. var instance = element.__vue__;
  550. if (!instance) {
  551. var textNode = element.previousSibling;
  552. if (textNode.__vue__) {
  553. instance = textNode.__vue__;
  554. }
  555. }
  556. return instance;
  557. };
  558. __WEBPACK_IMPORTED_MODULE_0_vue___default.a.transition(transition, {
  559. afterEnter: function afterEnter(el) {
  560. var instance = getVueInstance(el);
  561. if (instance) {
  562. instance.doAfterOpen && instance.doAfterOpen();
  563. }
  564. },
  565. afterLeave: function afterLeave(el) {
  566. var instance = getVueInstance(el);
  567. if (instance) {
  568. instance.doAfterClose && instance.doAfterClose();
  569. }
  570. }
  571. });
  572. };
  573. var scrollBarWidth;
  574. var getScrollBarWidth = function () {
  575. if (__WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer) return;
  576. if (scrollBarWidth !== undefined) return scrollBarWidth;
  577. var outer = document.createElement('div');
  578. outer.style.visibility = 'hidden';
  579. outer.style.width = '100px';
  580. outer.style.position = 'absolute';
  581. outer.style.top = '-9999px';
  582. document.body.appendChild(outer);
  583. var widthNoScroll = outer.offsetWidth;
  584. outer.style.overflow = 'scroll';
  585. var inner = document.createElement('div');
  586. inner.style.width = '100%';
  587. outer.appendChild(inner);
  588. var widthWithScroll = inner.offsetWidth;
  589. outer.parentNode.removeChild(outer);
  590. return widthNoScroll - widthWithScroll;
  591. };
  592. var getDOM = function(dom) {
  593. if (dom.nodeType === 3) {
  594. dom = dom.nextElementSibling || dom.nextSibling;
  595. getDOM(dom);
  596. }
  597. return dom;
  598. };
  599. /* harmony default export */ exports["a"] = {
  600. props: {
  601. value: {
  602. type: Boolean,
  603. default: false
  604. },
  605. transition: {
  606. type: String,
  607. default: ''
  608. },
  609. openDelay: {},
  610. closeDelay: {},
  611. zIndex: {},
  612. modal: {
  613. type: Boolean,
  614. default: false
  615. },
  616. modalFade: {
  617. type: Boolean,
  618. default: true
  619. },
  620. modalClass: {
  621. },
  622. lockScroll: {
  623. type: Boolean,
  624. default: true
  625. },
  626. closeOnPressEscape: {
  627. type: Boolean,
  628. default: false
  629. },
  630. closeOnClickModal: {
  631. type: Boolean,
  632. default: false
  633. }
  634. },
  635. created: function created() {
  636. if (this.transition) {
  637. hookTransition(this.transition);
  638. }
  639. },
  640. beforeMount: function beforeMount() {
  641. this._popupId = 'popup-' + idSeed++;
  642. __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].register(this._popupId, this);
  643. },
  644. beforeDestroy: function beforeDestroy() {
  645. __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].deregister(this._popupId);
  646. __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].closeModal(this._popupId);
  647. if (this.modal && this.bodyOverflow !== null && this.bodyOverflow !== 'hidden') {
  648. document.body.style.overflow = this.bodyOverflow;
  649. document.body.style.paddingRight = this.bodyPaddingRight;
  650. }
  651. this.bodyOverflow = null;
  652. this.bodyPaddingRight = null;
  653. },
  654. data: function data() {
  655. return {
  656. opened: false,
  657. bodyOverflow: null,
  658. bodyPaddingRight: null,
  659. rendered: false
  660. };
  661. },
  662. watch: {
  663. value: function value(val) {
  664. var this$1 = this;
  665. if (val) {
  666. if (this._opening) return;
  667. if (!this.rendered) {
  668. this.rendered = true;
  669. __WEBPACK_IMPORTED_MODULE_0_vue___default.a.nextTick(function () {
  670. this$1.open();
  671. });
  672. } else {
  673. this.open();
  674. }
  675. } else {
  676. this.close();
  677. }
  678. }
  679. },
  680. methods: {
  681. open: function open(options) {
  682. var this$1 = this;
  683. if (!this.rendered) {
  684. this.rendered = true;
  685. this.$emit('input', true);
  686. }
  687. var props = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_merge__["a" /* default */])({}, this, options, this.$props);
  688. if (this._closeTimer) {
  689. clearTimeout(this._closeTimer);
  690. this._closeTimer = null;
  691. }
  692. clearTimeout(this._openTimer);
  693. var openDelay = Number(props.openDelay);
  694. if (openDelay > 0) {
  695. this._openTimer = setTimeout(function () {
  696. this$1._openTimer = null;
  697. this$1.doOpen(props);
  698. }, openDelay);
  699. } else {
  700. this.doOpen(props);
  701. }
  702. },
  703. doOpen: function doOpen(props) {
  704. if (this.$isServer) return;
  705. if (this.willOpen && !this.willOpen()) return;
  706. if (this.opened) return;
  707. this._opening = true;
  708. // 使用 vue-popup 的组件,如果需要和父组件通信显示的状态,应该使用 value,它是一个 prop,
  709. // 这样在父组件中用 v-model 即可;否则可以使用 visible,它是一个 data
  710. this.visible = true;
  711. this.$emit('input', true);
  712. var dom = getDOM(this.$el);
  713. var modal = props.modal;
  714. var zIndex = props.zIndex;
  715. if (zIndex) {
  716. __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].zIndex = zIndex;
  717. }
  718. if (modal) {
  719. if (this._closing) {
  720. __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].closeModal(this._popupId);
  721. this._closing = false;
  722. }
  723. __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].openModal(this._popupId, __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].nextZIndex(), dom, props.modalClass, props.modalFade);
  724. if (props.lockScroll) {
  725. if (!this.bodyOverflow) {
  726. this.bodyPaddingRight = document.body.style.paddingRight;
  727. this.bodyOverflow = document.body.style.overflow;
  728. }
  729. scrollBarWidth = getScrollBarWidth();
  730. var bodyHasOverflow = document.documentElement.clientHeight < document.body.scrollHeight;
  731. if (scrollBarWidth > 0 && bodyHasOverflow) {
  732. document.body.style.paddingRight = scrollBarWidth + 'px';
  733. }
  734. document.body.style.overflow = 'hidden';
  735. }
  736. }
  737. if (getComputedStyle(dom).position === 'static') {
  738. dom.style.position = 'absolute';
  739. }
  740. dom.style.zIndex = __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].nextZIndex();
  741. this.opened = true;
  742. this.onOpen && this.onOpen();
  743. if (!this.transition) {
  744. this.doAfterOpen();
  745. }
  746. },
  747. doAfterOpen: function doAfterOpen() {
  748. this._opening = false;
  749. },
  750. close: function close() {
  751. var this$1 = this;
  752. if (this.willClose && !this.willClose()) return;
  753. if (this._openTimer !== null) {
  754. clearTimeout(this._openTimer);
  755. this._openTimer = null;
  756. }
  757. clearTimeout(this._closeTimer);
  758. var closeDelay = Number(this.closeDelay);
  759. if (closeDelay > 0) {
  760. this._closeTimer = setTimeout(function () {
  761. this$1._closeTimer = null;
  762. this$1.doClose();
  763. }, closeDelay);
  764. } else {
  765. this.doClose();
  766. }
  767. },
  768. doClose: function doClose() {
  769. var this$1 = this;
  770. this.visible = false;
  771. this.$emit('input', false);
  772. this._closing = true;
  773. this.onClose && this.onClose();
  774. if (this.lockScroll) {
  775. setTimeout(function () {
  776. if (this$1.modal && this$1.bodyOverflow !== 'hidden') {
  777. document.body.style.overflow = this$1.bodyOverflow;
  778. document.body.style.paddingRight = this$1.bodyPaddingRight;
  779. }
  780. this$1.bodyOverflow = null;
  781. this$1.bodyPaddingRight = null;
  782. }, 200);
  783. }
  784. this.opened = false;
  785. if (!this.transition) {
  786. this.doAfterClose();
  787. }
  788. },
  789. doAfterClose: function doAfterClose() {
  790. __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].closeModal(this._popupId);
  791. this._closing = false;
  792. }
  793. }
  794. };
  795. /***/ },
  796. /***/ 9:
  797. /***/ function(module, exports, __webpack_require__) {
  798. "use strict";
  799. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
  800. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
  801. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__ = __webpack_require__(2);
  802. var hasModal = false;
  803. var getModal = function() {
  804. if (__WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer) return;
  805. var modalDom = PopupManager.modalDom;
  806. if (modalDom) {
  807. hasModal = true;
  808. } else {
  809. hasModal = false;
  810. modalDom = document.createElement('div');
  811. PopupManager.modalDom = modalDom;
  812. modalDom.addEventListener('touchmove', function(event) {
  813. event.preventDefault();
  814. event.stopPropagation();
  815. });
  816. modalDom.addEventListener('click', function() {
  817. PopupManager.doOnModalClick && PopupManager.doOnModalClick();
  818. });
  819. }
  820. return modalDom;
  821. };
  822. var instances = {};
  823. var PopupManager = {
  824. zIndex: 2000,
  825. modalFade: true,
  826. getInstance: function(id) {
  827. return instances[id];
  828. },
  829. register: function(id, instance) {
  830. if (id && instance) {
  831. instances[id] = instance;
  832. }
  833. },
  834. deregister: function(id) {
  835. if (id) {
  836. instances[id] = null;
  837. delete instances[id];
  838. }
  839. },
  840. nextZIndex: function() {
  841. return PopupManager.zIndex++;
  842. },
  843. modalStack: [],
  844. doOnModalClick: function() {
  845. var topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1];
  846. if (!topItem) return;
  847. var instance = PopupManager.getInstance(topItem.id);
  848. if (instance && instance.closeOnClickModal) {
  849. instance.close();
  850. }
  851. },
  852. openModal: function(id, zIndex, dom, modalClass, modalFade) {
  853. if (__WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer) return;
  854. if (!id || zIndex === undefined) return;
  855. this.modalFade = modalFade;
  856. var modalStack = this.modalStack;
  857. for (var i = 0, j = modalStack.length; i < j; i++) {
  858. var item = modalStack[i];
  859. if (item.id === id) {
  860. return;
  861. }
  862. }
  863. var modalDom = getModal();
  864. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["a" /* addClass */])(modalDom, 'v-modal');
  865. if (this.modalFade && !hasModal) {
  866. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["a" /* addClass */])(modalDom, 'v-modal-enter');
  867. }
  868. if (modalClass) {
  869. var classArr = modalClass.trim().split(/\s+/);
  870. classArr.forEach(function (item) { return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["a" /* addClass */])(modalDom, item); });
  871. }
  872. setTimeout(function () {
  873. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["b" /* removeClass */])(modalDom, 'v-modal-enter');
  874. }, 200);
  875. if (dom && dom.parentNode && dom.parentNode.nodeType !== 11) {
  876. dom.parentNode.appendChild(modalDom);
  877. } else {
  878. document.body.appendChild(modalDom);
  879. }
  880. if (zIndex) {
  881. modalDom.style.zIndex = zIndex;
  882. }
  883. modalDom.style.display = '';
  884. this.modalStack.push({ id: id, zIndex: zIndex, modalClass: modalClass });
  885. },
  886. closeModal: function(id) {
  887. var modalStack = this.modalStack;
  888. var modalDom = getModal();
  889. if (modalStack.length > 0) {
  890. var topItem = modalStack[modalStack.length - 1];
  891. if (topItem.id === id) {
  892. if (topItem.modalClass) {
  893. var classArr = topItem.modalClass.trim().split(/\s+/);
  894. classArr.forEach(function (item) { return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["b" /* removeClass */])(modalDom, item); });
  895. }
  896. modalStack.pop();
  897. if (modalStack.length > 0) {
  898. modalDom.style.zIndex = modalStack[modalStack.length - 1].zIndex;
  899. }
  900. } else {
  901. for (var i = modalStack.length - 1; i >= 0; i--) {
  902. if (modalStack[i].id === id) {
  903. modalStack.splice(i, 1);
  904. break;
  905. }
  906. }
  907. }
  908. }
  909. if (modalStack.length === 0) {
  910. if (this.modalFade) {
  911. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["a" /* addClass */])(modalDom, 'v-modal-leave');
  912. }
  913. setTimeout(function () {
  914. if (modalStack.length === 0) {
  915. if (modalDom.parentNode) modalDom.parentNode.removeChild(modalDom);
  916. modalDom.style.display = 'none';
  917. PopupManager.modalDom = undefined;
  918. }
  919. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["b" /* removeClass */])(modalDom, 'v-modal-leave');
  920. }, 200);
  921. }
  922. }
  923. };
  924. !__WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer && window.addEventListener('keydown', function(event) {
  925. if (event.keyCode === 27) { // ESC
  926. if (PopupManager.modalStack.length > 0) {
  927. var topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1];
  928. if (!topItem) return;
  929. var instance = PopupManager.getInstance(topItem.id);
  930. if (instance.closeOnPressEscape) {
  931. instance.close();
  932. }
  933. }
  934. }
  935. });
  936. /* harmony default export */ exports["a"] = PopupManager;
  937. /***/ }
  938. /******/ });