mint-ui
Version:
Mobile UI elements for vue.js
1,592 lines (1,364 loc) • 39.1 kB
JavaScript
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 225);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ function(module, exports) {
/* globals __VUE_SSR_CONTEXT__ */
// this module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle
module.exports = function normalizeComponent (
rawScriptExports,
compiledTemplate,
injectStyles,
scopeId,
moduleIdentifier /* server only */
) {
var esModule
var scriptExports = rawScriptExports = rawScriptExports || {}
// ES6 modules interop
var type = typeof rawScriptExports.default
if (type === 'object' || type === 'function') {
esModule = rawScriptExports
scriptExports = rawScriptExports.default
}
// Vue.extend constructor export interop
var options = typeof scriptExports === 'function'
? scriptExports.options
: scriptExports
// render functions
if (compiledTemplate) {
options.render = compiledTemplate.render
options.staticRenderFns = compiledTemplate.staticRenderFns
}
// scopedId
if (scopeId) {
options._scopeId = scopeId
}
var hook
if (moduleIdentifier) { // server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__
}
// inject component styles
if (injectStyles) {
injectStyles.call(this, context)
}
// register component module identifier for async chunk inferrence
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier)
}
}
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook
} else if (injectStyles) {
hook = injectStyles
}
if (hook) {
var functional = options.functional
var existing = functional
? options.render
: options.beforeCreate
if (!functional) {
// inject component registration as beforeCreate hook
options.beforeCreate = existing
? [].concat(existing, hook)
: [hook]
} else {
// register for functioal component in vue file
options.render = function renderWithStyleInjection (h, context) {
hook.call(context)
return existing(h, context)
}
}
}
return {
esModule: esModule,
exports: scriptExports,
options: options
}
}
/***/ },
/***/ 1:
/***/ function(module, exports) {
module.exports = require("vue");
/***/ },
/***/ 117:
/***/ function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ },
/***/ 118:
/***/ function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ },
/***/ 143:
/***/ function(module, exports, __webpack_require__) {
function injectStyle (ssrContext) {
__webpack_require__(117)
__webpack_require__(118)
}
var Component = __webpack_require__(0)(
/* script */
__webpack_require__(65),
/* template */
__webpack_require__(187),
/* styles */
injectStyle,
/* scopeId */
null,
/* moduleIdentifier (server only) */
null
)
module.exports = Component.exports
/***/ },
/***/ 187:
/***/ function(module, exports) {
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
return _c('div', {
staticClass: "mint-msgbox-wrapper"
}, [_c('transition', {
attrs: {
"name": "msgbox-bounce"
}
}, [_c('div', {
directives: [{
name: "show",
rawName: "v-show",
value: (_vm.value),
expression: "value"
}],
staticClass: "mint-msgbox"
}, [(_vm.title !== '') ? _c('div', {
staticClass: "mint-msgbox-header"
}, [_c('div', {
staticClass: "mint-msgbox-title"
}, [_vm._v(_vm._s(_vm.title))])]) : _vm._e(), _vm._v(" "), (_vm.message !== '') ? _c('div', {
staticClass: "mint-msgbox-content"
}, [_c('div', {
staticClass: "mint-msgbox-message",
domProps: {
"innerHTML": _vm._s(_vm.message)
}
}), _vm._v(" "), _c('div', {
directives: [{
name: "show",
rawName: "v-show",
value: (_vm.showInput),
expression: "showInput"
}],
staticClass: "mint-msgbox-input"
}, [_c('input', {
directives: [{
name: "model",
rawName: "v-model",
value: (_vm.inputValue),
expression: "inputValue"
}],
ref: "input",
attrs: {
"placeholder": _vm.inputPlaceholder
},
domProps: {
"value": (_vm.inputValue)
},
on: {
"input": function($event) {
if ($event.target.composing) { return; }
_vm.inputValue = $event.target.value
}
}
}), _vm._v(" "), _c('div', {
staticClass: "mint-msgbox-errormsg",
style: ({
visibility: !!_vm.editorErrorMessage ? 'visible' : 'hidden'
})
}, [_vm._v(_vm._s(_vm.editorErrorMessage))])])]) : _vm._e(), _vm._v(" "), _c('div', {
staticClass: "mint-msgbox-btns"
}, [_c('button', {
directives: [{
name: "show",
rawName: "v-show",
value: (_vm.showCancelButton),
expression: "showCancelButton"
}],
class: [_vm.cancelButtonClasses],
on: {
"click": function($event) {
_vm.handleAction('cancel')
}
}
}, [_vm._v(_vm._s(_vm.cancelButtonText))]), _vm._v(" "), _c('button', {
directives: [{
name: "show",
rawName: "v-show",
value: (_vm.showConfirmButton),
expression: "showConfirmButton"
}],
class: [_vm.confirmButtonClasses],
on: {
"click": function($event) {
_vm.handleAction('confirm')
}
}
}, [_vm._v(_vm._s(_vm.confirmButtonText))])])])])], 1)
},staticRenderFns: []}
/***/ },
/***/ 2:
/***/ function(module, exports, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
/* unused harmony export on */
/* unused harmony export off */
/* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return once; });
/* unused harmony export hasClass */
/* harmony export (immutable) */ exports["a"] = addClass;
/* harmony export (immutable) */ exports["b"] = removeClass;
/* unused harmony export getStyle */
/* unused harmony export setStyle */
/* istanbul ignore next */
var isServer = __WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer;
var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
var MOZ_HACK_REGEXP = /^moz([A-Z])/;
var ieVersion = isServer ? 0 : Number(document.documentMode);
/* istanbul ignore next */
var trim = function(string) {
return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
};
/* istanbul ignore next */
var camelCase = function(name) {
return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
return offset ? letter.toUpperCase() : letter;
}).replace(MOZ_HACK_REGEXP, 'Moz$1');
};
/* istanbul ignore next */
var on = (function() {
if (!isServer && document.addEventListener) {
return function(element, event, handler) {
if (element && event && handler) {
element.addEventListener(event, handler, false);
}
};
} else {
return function(element, event, handler) {
if (element && event && handler) {
element.attachEvent('on' + event, handler);
}
};
}
})();
/* istanbul ignore next */
var off = (function() {
if (!isServer && document.removeEventListener) {
return function(element, event, handler) {
if (element && event) {
element.removeEventListener(event, handler, false);
}
};
} else {
return function(element, event, handler) {
if (element && event) {
element.detachEvent('on' + event, handler);
}
};
}
})();
/* istanbul ignore next */
var once = function(el, event, fn) {
var listener = function() {
if (fn) {
fn.apply(this, arguments);
}
off(el, event, listener);
};
on(el, event, listener);
};
/* istanbul ignore next */
function hasClass(el, cls) {
if (!el || !cls) return false;
if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.');
if (el.classList) {
return el.classList.contains(cls);
} else {
return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
}
};
/* istanbul ignore next */
function addClass(el, cls) {
if (!el) return;
var curClass = el.className;
var classes = (cls || '').split(' ');
for (var i = 0, j = classes.length; i < j; i++) {
var clsName = classes[i];
if (!clsName) continue;
if (el.classList) {
el.classList.add(clsName);
} else {
if (!hasClass(el, clsName)) {
curClass += ' ' + clsName;
}
}
}
if (!el.classList) {
el.className = curClass;
}
};
/* istanbul ignore next */
function removeClass(el, cls) {
if (!el || !cls) return;
var classes = cls.split(' ');
var curClass = ' ' + el.className + ' ';
for (var i = 0, j = classes.length; i < j; i++) {
var clsName = classes[i];
if (!clsName) continue;
if (el.classList) {
el.classList.remove(clsName);
} else {
if (hasClass(el, clsName)) {
curClass = curClass.replace(' ' + clsName + ' ', ' ');
}
}
}
if (!el.classList) {
el.className = trim(curClass);
}
};
/* istanbul ignore next */
var getStyle = ieVersion < 9 ? function(element, styleName) {
if (isServer) return;
if (!element || !styleName) return null;
styleName = camelCase(styleName);
if (styleName === 'float') {
styleName = 'styleFloat';
}
try {
switch (styleName) {
case 'opacity':
try {
return element.filters.item('alpha').opacity / 100;
} catch (e) {
return 1.0;
}
default:
return (element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null);
}
} catch (e) {
return element.style[styleName];
}
} : function(element, styleName) {
if (isServer) return;
if (!element || !styleName) return null;
styleName = camelCase(styleName);
if (styleName === 'float') {
styleName = 'cssFloat';
}
try {
var computed = document.defaultView.getComputedStyle(element, '');
return element.style[styleName] || computed ? computed[styleName] : null;
} catch (e) {
return element.style[styleName];
}
};
/* istanbul ignore next */
function setStyle(element, styleName, value) {
if (!element || !styleName) return;
if (typeof styleName === 'object') {
for (var prop in styleName) {
if (styleName.hasOwnProperty(prop)) {
setStyle(element, prop, styleName[prop]);
}
}
} else {
styleName = camelCase(styleName);
if (styleName === 'opacity' && ieVersion < 9) {
element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')';
} else {
element.style[styleName] = value;
}
}
};
/***/ },
/***/ 225:
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(33);
/***/ },
/***/ 33:
/***/ function(module, exports, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_message_box_js__ = __webpack_require__(90);
Object.defineProperty(exports, "__esModule", { value: true });
/* harmony reexport (binding) */ __webpack_require__.d(exports, "default", function() { return __WEBPACK_IMPORTED_MODULE_0__src_message_box_js__["a"]; });
/***/ },
/***/ 65:
/***/ function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_popup__ = __webpack_require__(8);
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
var CONFIRM_TEXT = '确定';
var CANCEL_TEXT = '取消';
/* harmony default export */ exports["default"] = {
mixins: [ __WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_popup__["a" /* default */] ],
props: {
modal: {
default: true
},
showClose: {
type: Boolean,
default: true
},
lockScroll: {
type: Boolean,
default: false
},
closeOnClickModal: {
default: true
},
closeOnPressEscape: {
default: true
},
inputType: {
type: String,
default: 'text'
}
},
computed: {
confirmButtonClasses: function confirmButtonClasses() {
var classes = 'mint-msgbox-btn mint-msgbox-confirm ' + this.confirmButtonClass;
if (this.confirmButtonHighlight) {
classes += ' mint-msgbox-confirm-highlight';
}
return classes;
},
cancelButtonClasses: function cancelButtonClasses() {
var classes = 'mint-msgbox-btn mint-msgbox-cancel ' + this.cancelButtonClass;
if (this.cancelButtonHighlight) {
classes += ' mint-msgbox-cancel-highlight';
}
return classes;
}
},
methods: {
doClose: function doClose() {
var this$1 = this;
this.value = false;
this._closing = true;
this.onClose && this.onClose();
setTimeout(function () {
if (this$1.modal && this$1.bodyOverflow !== 'hidden') {
document.body.style.overflow = this$1.bodyOverflow;
document.body.style.paddingRight = this$1.bodyPaddingRight;
}
this$1.bodyOverflow = null;
this$1.bodyPaddingRight = null;
}, 200);
this.opened = false;
if (!this.transition) {
this.doAfterClose();
}
},
handleAction: function handleAction(action) {
if (this.$type === 'prompt' && action === 'confirm' && !this.validate()) {
return;
}
var callback = this.callback;
this.value = false;
callback(action);
},
validate: function validate() {
if (this.$type === 'prompt') {
var inputPattern = this.inputPattern;
if (inputPattern && !inputPattern.test(this.inputValue || '')) {
this.editorErrorMessage = this.inputErrorMessage || '输入的数据不合法!';
this.$refs.input.classList.add('invalid');
return false;
}
var inputValidator = this.inputValidator;
if (typeof inputValidator === 'function') {
var validateResult = inputValidator(this.inputValue);
if (validateResult === false) {
this.editorErrorMessage = this.inputErrorMessage || '输入的数据不合法!';
this.$refs.input.classList.add('invalid');
return false;
}
if (typeof validateResult === 'string') {
this.editorErrorMessage = validateResult;
return false;
}
}
}
this.editorErrorMessage = '';
this.$refs.input.classList.remove('invalid');
return true;
},
handleInputType: function handleInputType(val) {
if (val === 'range' || !this.$refs.input) return;
this.$refs.input.type = val;
}
},
watch: {
inputValue: function inputValue() {
if (this.$type === 'prompt') {
this.validate();
}
},
value: function value(val) {
var this$1 = this;
this.handleInputType(this.inputType);
if (val && this.$type === 'prompt') {
setTimeout(function () {
if (this$1.$refs.input) {
this$1.$refs.input.focus();
}
}, 500);
}
},
inputType: function inputType(val) {
this.handleInputType(val);
}
},
data: function data() {
return {
title: '',
message: '',
type: '',
showInput: false,
inputValue: null,
inputPlaceholder: '',
inputPattern: null,
inputValidator: null,
inputErrorMessage: '',
showConfirmButton: true,
showCancelButton: false,
confirmButtonText: CONFIRM_TEXT,
cancelButtonText: CANCEL_TEXT,
confirmButtonClass: '',
confirmButtonDisabled: false,
cancelButtonClass: '',
editorErrorMessage: null,
callback: null
};
}
};
/***/ },
/***/ 7:
/***/ function(module, exports, __webpack_require__) {
"use strict";
/* harmony default export */ exports["a"] = function(target) {
var arguments$1 = arguments;
for (var i = 1, j = arguments.length; i < j; i++) {
var source = arguments$1[i] || {};
for (var prop in source) {
if (source.hasOwnProperty(prop)) {
var value = source[prop];
if (value !== undefined) {
target[prop] = value;
}
}
}
}
return target;
};;
/***/ },
/***/ 8:
/***/ function(module, exports, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_merge__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__ = __webpack_require__(9);
/* unused harmony reexport PopupManager */
var idSeed = 1;
var transitions = [];
var hookTransition = function (transition) {
if (transitions.indexOf(transition) !== -1) return;
var getVueInstance = function (element) {
var instance = element.__vue__;
if (!instance) {
var textNode = element.previousSibling;
if (textNode.__vue__) {
instance = textNode.__vue__;
}
}
return instance;
};
__WEBPACK_IMPORTED_MODULE_0_vue___default.a.transition(transition, {
afterEnter: function afterEnter(el) {
var instance = getVueInstance(el);
if (instance) {
instance.doAfterOpen && instance.doAfterOpen();
}
},
afterLeave: function afterLeave(el) {
var instance = getVueInstance(el);
if (instance) {
instance.doAfterClose && instance.doAfterClose();
}
}
});
};
var scrollBarWidth;
var getScrollBarWidth = function () {
if (__WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer) return;
if (scrollBarWidth !== undefined) return scrollBarWidth;
var outer = document.createElement('div');
outer.style.visibility = 'hidden';
outer.style.width = '100px';
outer.style.position = 'absolute';
outer.style.top = '-9999px';
document.body.appendChild(outer);
var widthNoScroll = outer.offsetWidth;
outer.style.overflow = 'scroll';
var inner = document.createElement('div');
inner.style.width = '100%';
outer.appendChild(inner);
var widthWithScroll = inner.offsetWidth;
outer.parentNode.removeChild(outer);
return widthNoScroll - widthWithScroll;
};
var getDOM = function(dom) {
if (dom.nodeType === 3) {
dom = dom.nextElementSibling || dom.nextSibling;
getDOM(dom);
}
return dom;
};
/* harmony default export */ exports["a"] = {
props: {
value: {
type: Boolean,
default: false
},
transition: {
type: String,
default: ''
},
openDelay: {},
closeDelay: {},
zIndex: {},
modal: {
type: Boolean,
default: false
},
modalFade: {
type: Boolean,
default: true
},
modalClass: {
},
lockScroll: {
type: Boolean,
default: true
},
closeOnPressEscape: {
type: Boolean,
default: false
},
closeOnClickModal: {
type: Boolean,
default: false
}
},
created: function created() {
if (this.transition) {
hookTransition(this.transition);
}
},
beforeMount: function beforeMount() {
this._popupId = 'popup-' + idSeed++;
__WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].register(this._popupId, this);
},
beforeDestroy: function beforeDestroy() {
__WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].deregister(this._popupId);
__WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].closeModal(this._popupId);
if (this.modal && this.bodyOverflow !== null && this.bodyOverflow !== 'hidden') {
document.body.style.overflow = this.bodyOverflow;
document.body.style.paddingRight = this.bodyPaddingRight;
}
this.bodyOverflow = null;
this.bodyPaddingRight = null;
},
data: function data() {
return {
opened: false,
bodyOverflow: null,
bodyPaddingRight: null,
rendered: false
};
},
watch: {
value: function value(val) {
var this$1 = this;
if (val) {
if (this._opening) return;
if (!this.rendered) {
this.rendered = true;
__WEBPACK_IMPORTED_MODULE_0_vue___default.a.nextTick(function () {
this$1.open();
});
} else {
this.open();
}
} else {
this.close();
}
}
},
methods: {
open: function open(options) {
var this$1 = this;
if (!this.rendered) {
this.rendered = true;
this.$emit('input', true);
}
var props = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_merge__["a" /* default */])({}, this, options, this.$props);
if (this._closeTimer) {
clearTimeout(this._closeTimer);
this._closeTimer = null;
}
clearTimeout(this._openTimer);
var openDelay = Number(props.openDelay);
if (openDelay > 0) {
this._openTimer = setTimeout(function () {
this$1._openTimer = null;
this$1.doOpen(props);
}, openDelay);
} else {
this.doOpen(props);
}
},
doOpen: function doOpen(props) {
if (this.$isServer) return;
if (this.willOpen && !this.willOpen()) return;
if (this.opened) return;
this._opening = true;
// 使用 vue-popup 的组件,如果需要和父组件通信显示的状态,应该使用 value,它是一个 prop,
// 这样在父组件中用 v-model 即可;否则可以使用 visible,它是一个 data
this.visible = true;
this.$emit('input', true);
var dom = getDOM(this.$el);
var modal = props.modal;
var zIndex = props.zIndex;
if (zIndex) {
__WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].zIndex = zIndex;
}
if (modal) {
if (this._closing) {
__WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].closeModal(this._popupId);
this._closing = false;
}
__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);
if (props.lockScroll) {
if (!this.bodyOverflow) {
this.bodyPaddingRight = document.body.style.paddingRight;
this.bodyOverflow = document.body.style.overflow;
}
scrollBarWidth = getScrollBarWidth();
var bodyHasOverflow = document.documentElement.clientHeight < document.body.scrollHeight;
if (scrollBarWidth > 0 && bodyHasOverflow) {
document.body.style.paddingRight = scrollBarWidth + 'px';
}
document.body.style.overflow = 'hidden';
}
}
if (getComputedStyle(dom).position === 'static') {
dom.style.position = 'absolute';
}
dom.style.zIndex = __WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].nextZIndex();
this.opened = true;
this.onOpen && this.onOpen();
if (!this.transition) {
this.doAfterOpen();
}
},
doAfterOpen: function doAfterOpen() {
this._opening = false;
},
close: function close() {
var this$1 = this;
if (this.willClose && !this.willClose()) return;
if (this._openTimer !== null) {
clearTimeout(this._openTimer);
this._openTimer = null;
}
clearTimeout(this._closeTimer);
var closeDelay = Number(this.closeDelay);
if (closeDelay > 0) {
this._closeTimer = setTimeout(function () {
this$1._closeTimer = null;
this$1.doClose();
}, closeDelay);
} else {
this.doClose();
}
},
doClose: function doClose() {
var this$1 = this;
this.visible = false;
this.$emit('input', false);
this._closing = true;
this.onClose && this.onClose();
if (this.lockScroll) {
setTimeout(function () {
if (this$1.modal && this$1.bodyOverflow !== 'hidden') {
document.body.style.overflow = this$1.bodyOverflow;
document.body.style.paddingRight = this$1.bodyPaddingRight;
}
this$1.bodyOverflow = null;
this$1.bodyPaddingRight = null;
}, 200);
}
this.opened = false;
if (!this.transition) {
this.doAfterClose();
}
},
doAfterClose: function doAfterClose() {
__WEBPACK_IMPORTED_MODULE_2_mint_ui_src_utils_popup_popup_manager__["a" /* default */].closeModal(this._popupId);
this._closing = false;
}
}
};
/***/ },
/***/ 9:
/***/ function(module, exports, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__ = __webpack_require__(2);
var hasModal = false;
var getModal = function() {
if (__WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer) return;
var modalDom = PopupManager.modalDom;
if (modalDom) {
hasModal = true;
} else {
hasModal = false;
modalDom = document.createElement('div');
PopupManager.modalDom = modalDom;
modalDom.addEventListener('touchmove', function(event) {
event.preventDefault();
event.stopPropagation();
});
modalDom.addEventListener('click', function() {
PopupManager.doOnModalClick && PopupManager.doOnModalClick();
});
}
return modalDom;
};
var instances = {};
var PopupManager = {
zIndex: 2000,
modalFade: true,
getInstance: function(id) {
return instances[id];
},
register: function(id, instance) {
if (id && instance) {
instances[id] = instance;
}
},
deregister: function(id) {
if (id) {
instances[id] = null;
delete instances[id];
}
},
nextZIndex: function() {
return PopupManager.zIndex++;
},
modalStack: [],
doOnModalClick: function() {
var topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1];
if (!topItem) return;
var instance = PopupManager.getInstance(topItem.id);
if (instance && instance.closeOnClickModal) {
instance.close();
}
},
openModal: function(id, zIndex, dom, modalClass, modalFade) {
if (__WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer) return;
if (!id || zIndex === undefined) return;
this.modalFade = modalFade;
var modalStack = this.modalStack;
for (var i = 0, j = modalStack.length; i < j; i++) {
var item = modalStack[i];
if (item.id === id) {
return;
}
}
var modalDom = getModal();
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["a" /* addClass */])(modalDom, 'v-modal');
if (this.modalFade && !hasModal) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["a" /* addClass */])(modalDom, 'v-modal-enter');
}
if (modalClass) {
var classArr = modalClass.trim().split(/\s+/);
classArr.forEach(function (item) { return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["a" /* addClass */])(modalDom, item); });
}
setTimeout(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["b" /* removeClass */])(modalDom, 'v-modal-enter');
}, 200);
if (dom && dom.parentNode && dom.parentNode.nodeType !== 11) {
dom.parentNode.appendChild(modalDom);
} else {
document.body.appendChild(modalDom);
}
if (zIndex) {
modalDom.style.zIndex = zIndex;
}
modalDom.style.display = '';
this.modalStack.push({ id: id, zIndex: zIndex, modalClass: modalClass });
},
closeModal: function(id) {
var modalStack = this.modalStack;
var modalDom = getModal();
if (modalStack.length > 0) {
var topItem = modalStack[modalStack.length - 1];
if (topItem.id === id) {
if (topItem.modalClass) {
var classArr = topItem.modalClass.trim().split(/\s+/);
classArr.forEach(function (item) { return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["b" /* removeClass */])(modalDom, item); });
}
modalStack.pop();
if (modalStack.length > 0) {
modalDom.style.zIndex = modalStack[modalStack.length - 1].zIndex;
}
} else {
for (var i = modalStack.length - 1; i >= 0; i--) {
if (modalStack[i].id === id) {
modalStack.splice(i, 1);
break;
}
}
}
}
if (modalStack.length === 0) {
if (this.modalFade) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["a" /* addClass */])(modalDom, 'v-modal-leave');
}
setTimeout(function () {
if (modalStack.length === 0) {
if (modalDom.parentNode) modalDom.parentNode.removeChild(modalDom);
modalDom.style.display = 'none';
PopupManager.modalDom = undefined;
}
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_utils_dom__["b" /* removeClass */])(modalDom, 'v-modal-leave');
}, 200);
}
}
};
!__WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer && window.addEventListener('keydown', function(event) {
if (event.keyCode === 27) { // ESC
if (PopupManager.modalStack.length > 0) {
var topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1];
if (!topItem) return;
var instance = PopupManager.getInstance(topItem.id);
if (instance.closeOnPressEscape) {
instance.close();
}
}
}
});
/* harmony default export */ exports["a"] = PopupManager;
/***/ },
/***/ 90:
/***/ function(module, exports, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__message_box_vue__ = __webpack_require__(143);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__message_box_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__message_box_vue__);
/* unused harmony export MessageBox */
var CONFIRM_TEXT = '确定';
var CANCEL_TEXT = '取消';
var defaults = {
title: '提示',
message: '',
type: '',
showInput: false,
showClose: true,
modalFade: false,
lockScroll: false,
closeOnClickModal: true,
inputValue: null,
inputPlaceholder: '',
inputPattern: null,
inputValidator: null,
inputErrorMessage: '',
showConfirmButton: true,
showCancelButton: false,
confirmButtonPosition: 'right',
confirmButtonHighlight: false,
cancelButtonHighlight: false,
confirmButtonText: CONFIRM_TEXT,
cancelButtonText: CANCEL_TEXT,
confirmButtonClass: '',
cancelButtonClass: ''
};
var merge = function(target) {
var arguments$1 = arguments;
for (var i = 1, j = arguments.length; i < j; i++) {
var source = arguments$1[i];
for (var prop in source) {
if (source.hasOwnProperty(prop)) {
var value = source[prop];
if (value !== undefined) {
target[prop] = value;
}
}
}
}
return target;
};
var MessageBoxConstructor = __WEBPACK_IMPORTED_MODULE_0_vue___default.a.extend(__WEBPACK_IMPORTED_MODULE_1__message_box_vue___default.a);
var currentMsg, instance;
var msgQueue = [];
var defaultCallback = function (action) {
if (currentMsg) {
var callback = currentMsg.callback;
if (typeof callback === 'function') {
if (instance.showInput) {
callback(instance.inputValue, action);
} else {
callback(action);
}
}
if (currentMsg.resolve) {
var $type = currentMsg.options.$type;
if ($type === 'confirm' || $type === 'prompt') {
if (action === 'confirm') {
if (instance.showInput) {
currentMsg.resolve({ value: instance.inputValue, action: action });
} else {
currentMsg.resolve(action);
}
} else if (action === 'cancel' && currentMsg.reject) {
currentMsg.reject(action);
}
} else {
currentMsg.resolve(action);
}
}
}
};
var initInstance = function() {
instance = new MessageBoxConstructor({
el: document.createElement('div')
});
instance.callback = defaultCallback;
};
var showNextMsg = function() {
if (!instance) {
initInstance();
}
if (!instance.value || instance.closeTimer) {
if (msgQueue.length > 0) {
currentMsg = msgQueue.shift();
var options = currentMsg.options;
for (var prop in options) {
if (options.hasOwnProperty(prop)) {
instance[prop] = options[prop];
}
}
if (options.callback === undefined) {
instance.callback = defaultCallback;
}
['modal', 'showClose', 'closeOnClickModal', 'closeOnPressEscape'].forEach(function (prop) {
if (instance[prop] === undefined) {
instance[prop] = true;
}
});
document.body.appendChild(instance.$el);
__WEBPACK_IMPORTED_MODULE_0_vue___default.a.nextTick(function () {
instance.value = true;
});
}
}
};
var MessageBox = function(options, callback) {
if (typeof options === 'string') {
options = {
title: options
};
if (arguments[1]) {
options.message = arguments[1];
}
if (arguments[2]) {
options.type = arguments[2];
}
} else if (options.callback && !callback) {
callback = options.callback;
}
if (typeof Promise !== 'undefined') {
return new Promise(function(resolve, reject) { // eslint-disable-line
msgQueue.push({
options: merge({}, defaults, MessageBox.defaults || {}, options),
callback: callback,
resolve: resolve,
reject: reject
});
showNextMsg();
});
} else {
msgQueue.push({
options: merge({}, defaults, MessageBox.defaults || {}, options),
callback: callback
});
showNextMsg();
}
};
MessageBox.setDefaults = function(defaults) {
MessageBox.defaults = defaults;
};
MessageBox.alert = function(message, title, options) {
if (typeof title === 'object') {
options = title;
title = '';
}
return MessageBox(merge({
title: title,
message: message,
$type: 'alert',
closeOnPressEscape: false,
closeOnClickModal: false
}, options));
};
MessageBox.confirm = function(message, title, options) {
if (typeof title === 'object') {
options = title;
title = '';
}
return MessageBox(merge({
title: title,
message: message,
$type: 'confirm',
showCancelButton: true
}, options));
};
MessageBox.prompt = function(message, title, options) {
if (typeof title === 'object') {
options = title;
title = '';
}
return MessageBox(merge({
title: title,
message: message,
showCancelButton: true,
showInput: true,
$type: 'prompt'
}, options));
};
MessageBox.close = function() {
if (!instance) return;
instance.value = false;
msgQueue = [];
currentMsg = null;
};
/* harmony default export */ exports["a"] = MessageBox;
/***/ }
/******/ });