UNPKG

vimo-dt

Version:

A Vue2.x UI Project For Mobile & HyBrid

89 lines (64 loc) 3.84 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _toast2 = require('./toast.vue'); var _toast3 = _interopRequireDefault(_toast2); var _GeneratePopUpInstance = require('../../util/GeneratePopUpInstance.js'); var _GeneratePopUpInstance2 = _interopRequireDefault(_GeneratePopUpInstance); var _type = require('../../util/type'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var ToastInstance = function (_GeneratePopUpInstanc) { _inherits(ToastInstance, _GeneratePopUpInstanc); function ToastInstance() { _classCallCheck(this, ToastInstance); return _possibleConstructorReturn(this, (ToastInstance.__proto__ || Object.getPrototypeOf(ToastInstance)).apply(this, arguments)); } _createClass(ToastInstance, [{ key: 'normalizeOptions', value: function normalizeOptions() { var _args = Array.prototype.slice.call(arguments); var propsData = {}; if (_args.length === 2) { propsData = { message: _args[0], duration: _args[1] }; } if (_args.length === 1 && (0, _type.isString)(_args[0])) { propsData = { message: _args[0] }; } if (_args.length === 1 && (0, _type.isObject)(_args[0])) { propsData = _args[0]; } propsData.scrollControl = false; return propsData; } }, { key: 'isPresentHandled', value: function isPresentHandled(options) { return !options.isH5 && window.VM && window.VM.platform && window.VM.platform.showToast && window.VM.platform.showToast(options); } }, { key: 'isDismissHandled', value: function isDismissHandled() { return window.VM && window.VM.platform && window.VM.platform.hideToast && window.VM.platform.hideToast(); } }]); return ToastInstance; }(_GeneratePopUpInstance2.default); function _toast() { var _instance = new ToastInstance(_toast3.default, 'toastPortal'); var _args = Array.prototype.slice.call(arguments); _instance.present.apply(_instance, _toConsumableArray(_args)); return _instance; } _toast.present = _toast; exports.default = _toast;