UNPKG

cube-ui

Version:

A fantastic mobile ui lib implement by Vue

1,141 lines (1,015 loc) 33.8 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["swipe"] = factory(); else root["cube"] = root["cube"] || {}, root["cube"]["swipe"] = factory(); })(typeof self !== 'undefined' ? self : this, function() { return /******/ (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; /******/ /******/ // 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 = 377); /******/ }) /************************************************************************/ /******/ ({ /***/ 273: /***/ (function(module, exports, __webpack_require__) { function injectStyle (ssrContext) { __webpack_require__(381) } var Component = __webpack_require__(9)( /* script */ __webpack_require__(382), /* template */ __webpack_require__(384), /* styles */ injectStyle, /* scopeId */ null, /* moduleIdentifier (server only) */ null ) module.exports = Component.exports /***/ }), /***/ 377: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports, __webpack_require__(378), __webpack_require__(273)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else if (typeof exports !== "undefined") { factory(module, exports, require('../../components/swipe/swipe.vue'), require('../../components/swipe/swipe-item.vue')); } else { var mod = { exports: {} }; factory(mod, mod.exports, global.swipe, global.swipeItem); global.index = mod.exports; } })(this, function (module, exports, _swipe, _swipeItem) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _swipe2 = _interopRequireDefault(_swipe); var _swipeItem2 = _interopRequireDefault(_swipeItem); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _swipe2.default.install = function (Vue) { Vue.component(_swipe2.default.name, _swipe2.default); Vue.component(_swipeItem2.default.name, _swipeItem2.default); }; _swipe2.default.Item = _swipeItem2.default; exports.default = _swipe2.default; module.exports = exports['default']; }); /***/ }), /***/ 378: /***/ (function(module, exports, __webpack_require__) { function injectStyle (ssrContext) { __webpack_require__(379) } var Component = __webpack_require__(9)( /* script */ __webpack_require__(380), /* template */ __webpack_require__(385), /* styles */ injectStyle, /* scopeId */ null, /* moduleIdentifier (server only) */ null ) module.exports = Component.exports /***/ }), /***/ 379: /***/ (function(module, exports) { // removed by extract-text-webpack-plugin /***/ }), /***/ 380: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports, __webpack_require__(273)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else if (typeof exports !== "undefined") { factory(module, exports, require('./swipe-item.vue')); } else { var mod = { exports: {} }; factory(mod, mod.exports, global.swipeItem); global.swipe = mod.exports; } })(this, function (module, exports, _swipeItem) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _swipeItem2 = _interopRequireDefault(_swipeItem); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var COMPONENT_NAME = 'cube-swipe'; var EVENT_ITEM_CLICK = 'item-click'; var EVENT_BTN_CLICK = 'btn-click'; exports.default = { name: COMPONENT_NAME, provide: function provide() { return { swipe: this }; }, props: { data: { type: Array, default: function _default() { return []; } }, autoShrink: { type: Boolean, default: false } }, created: function created() { this.activeIndex = -1; this.items = []; }, methods: { addItem: function addItem(item) { this.items.push(item); }, removeItem: function removeItem(item) { var index = this.items.indexOf(item); this.items.splice(index, 1); if (index <= this.activeIndex) { this.activeIndex -= 1; } }, onItemClick: function onItemClick(item, index) { this.$emit(EVENT_ITEM_CLICK, item, index); }, onBtnClick: function onBtnClick(btn, index) { var item = this.data[index]; this.$emit(EVENT_BTN_CLICK, btn, index, item); }, onItemActive: function onItemActive(index) { if (index === this.activeIndex) { return; } if (this.activeIndex !== -1) { var activeItem = this.items[this.activeIndex]; activeItem.shrink(); } this.activeIndex = index; } }, components: { CubeSwipeItem: _swipeItem2.default } }; module.exports = exports['default']; }); /***/ }), /***/ 381: /***/ (function(module, exports) { // removed by extract-text-webpack-plugin /***/ }), /***/ 382: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports, __webpack_require__(87), __webpack_require__(383), __webpack_require__(91)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else if (typeof exports !== "undefined") { factory(module, exports, require('../../common/helpers/dom'), require('../../common/helpers/ease'), require('../../common/lang/date')); } else { var mod = { exports: {} }; factory(mod, mod.exports, global.dom, global.ease, global.date); global.swipeItem = mod.exports; } })(this, function (module, exports, _dom, _ease, _date) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var COMPONENT_NAME = 'cube-swipe-item'; var EVENT_ITEM_CLICK = 'item-click'; var EVENT_BTN_CLICK = 'btn-click'; var EVENT_SCROLL = 'scroll'; var EVENT_ACTIVE = 'active'; var DIRECTION_LEFT = 1; var DIRECTION_RIGHT = -1; var STATE_SHRINK = 0; var STATE_GROW = 1; var easingTime = 600; var momentumLimitTime = 300; var momentumLimitDistance = 15; var directionLockThreshold = 5; var transform = (0, _dom.prefixStyle)('transform'); var transitionProperty = (0, _dom.prefixStyle)('transitionProperty'); var transitionDuration = (0, _dom.prefixStyle)('transitionDuration'); var transitionTimingFunction = (0, _dom.prefixStyle)('transitionTimingFunction'); exports.default = { name: COMPONENT_NAME, inject: ['swipe'], props: { item: { type: Object, default: function _default() { return {}; } }, btns: { type: Array, default: function _default() { return []; } }, index: { type: Number, index: -1 }, autoShrink: { type: Boolean, default: false } }, watch: { btns: function btns() { var _this = this; this.$nextTick(function () { _this.refresh(); }); } }, created: function created() { this.x = 0; this.state = STATE_SHRINK; this.swipe.addItem(this); }, mounted: function mounted() { var _this2 = this; this.scrollerStyle = this.$refs.swipeItem.style; this.$nextTick(function () { _this2.refresh(); }); this.$on(EVENT_SCROLL, this._handleBtns); }, methods: { _initCachedBtns: function _initCachedBtns() { this.cachedBtns = []; var len = this.$refs.btns.length; for (var i = 0; i < len; i++) { this.cachedBtns.push({ width: (0, _dom.getRect)(this.$refs.btns[i]).width }); } }, _handleBtns: function _handleBtns(x) { if (this.btns.length === 0) { return; } var len = this.$refs.btns.length; var delta = 0; var totalWidth = -this.maxScrollX; for (var i = 0; i < len; i++) { var btn = this.$refs.btns[i]; var rate = (totalWidth - delta) / totalWidth; var width = void 0; var translate = rate * x - x; if (x < this.maxScrollX) { width = this.cachedBtns[i].width + rate * (this.maxScrollX - x); } else { width = this.cachedBtns[i].width; } delta += this.cachedBtns[i].width; btn.style.width = width + 'px'; btn.style[transform] = 'translate(' + translate + 'px)'; btn.style[transitionDuration] = '0ms'; } }, _isInBtns: function _isInBtns(target) { var parent = target; var flag = false; while (parent && parent.className.indexOf('cube-swipe-item') < 0) { if (parent.className.indexOf('cube-swipe-btns') >= 0) { flag = true; break; } parent = parent.parentNode; } return flag; }, _calculateBtnsWidth: function _calculateBtnsWidth() { var width = 0; var len = this.cachedBtns.length; for (var i = 0; i < len; i++) { width += this.cachedBtns[i].width; } this.maxScrollX = -width; }, _translate: function _translate(x, useZ) { var translateZ = useZ ? ' translateZ(0)' : ''; this.scrollerStyle[transform] = 'translate(' + x + 'px,0)' + translateZ; this.x = x; }, _transitionProperty: function _transitionProperty() { var property = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'transform'; this.scrollerStyle[transitionProperty] = property; }, _transitionTimingFunction: function _transitionTimingFunction(easing) { this.scrollerStyle[transitionTimingFunction] = easing; }, _transitionTime: function _transitionTime() { var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; this.scrollerStyle[transitionDuration] = time + 'ms'; }, _getComputedPositionX: function _getComputedPositionX() { var matrix = window.getComputedStyle(this.$refs.swipeItem, null); matrix = matrix[transform].split(')')[0].split(', '); var x = +(matrix[12] || matrix[4]); return x; }, _translateBtns: function _translateBtns(time, easing, extend) { if (this.btns.length === 0) { return; } var len = this.$refs.btns.length; var delta = 0; var translate = 0; for (var i = 0; i < len; i++) { var btn = this.$refs.btns[i]; if (this.state === STATE_GROW) { translate = delta; } else { translate = 0; } delta += this.cachedBtns[i].width; btn.style[transform] = 'translate(' + translate + 'px,0) translateZ(0)'; btn.style[transitionProperty] = 'all'; btn.style[transitionTimingFunction] = easing; btn.style[transitionDuration] = time + 'ms'; if (extend) { btn.style.width = this.cachedBtns[i].width + 'px'; } } }, refresh: function refresh() { if (this.btns.length > 0) { this._initCachedBtns(); this._calculateBtnsWidth(); } this.endTime = 0; }, shrink: function shrink() { var _this3 = this; this.stop(); this.state = STATE_SHRINK; this.$nextTick(function () { _this3.scrollTo(0, easingTime, _ease.easeOutQuart); _this3._translateBtns(easingTime, _ease.easeOutQuart); }); }, grow: function grow() { this.state = STATE_GROW; var extend = this.x < this.maxScrollX; var easing = _ease.easeOutCubic; this.scrollTo(this.maxScrollX, easingTime, easing); this._translateBtns(easingTime, easing, extend); }, scrollTo: function scrollTo(x, time, easing) { this._transitionProperty(); this._transitionTimingFunction(easing); this._transitionTime(time); this._translate(x, true); if (time) { this.isInTransition = true; } }, genBtnStyl: function genBtnStyl(btn) { return 'background: ' + btn.color; }, clickItem: function clickItem() { this.swipe.onItemClick(this.item, this.index); this.$emit(EVENT_ITEM_CLICK, this.item, this.index); }, clickBtn: function clickBtn(btn) { this.swipe.onBtnClick(btn, this.index); this.$emit(EVENT_BTN_CLICK, btn, this.index); if (this.autoShrink) { this.shrink(); } }, stop: function stop() { if (this.isInTransition) { this.isInTransition = false; var x = this.state === STATE_SHRINK ? 0 : this._getComputedPositionX(); this._translate(x); this.$emit(EVENT_SCROLL, this.x); } }, onTouchStart: function onTouchStart(e) { var _this4 = this; this.swipe.onItemActive(this.index); this.$emit(EVENT_ACTIVE, this.index); this.stop(); this.moved = false; this.movingDirectionX = 0; var point = e.touches[0]; this.pointX = point.pageX; this.pointY = point.pageY; this.distX = 0; this.distY = 0; this.startX = this.x; this._transitionTime(); this.startTime = (0, _date.getNow)(); if (this.state === STATE_GROW && !this._isInBtns(e.target)) { this.shrinkTimer = setTimeout(function () { _this4.shrink(); }, 300); } }, onTouchMove: function onTouchMove(e) { if (this.moved) { clearTimeout(this.shrinkTimer); e.stopPropagation(); } if (this.isInTransition) { return; } e.preventDefault(); var point = e.touches[0]; var deltaX = point.pageX - this.pointX; var deltaY = point.pageY - this.pointY; this.pointX = point.pageX; this.pointY = point.pageY; this.distX += deltaX; this.distY += deltaY; var absDistX = Math.abs(this.distX); var absDistY = Math.abs(this.distY); if (absDistX + directionLockThreshold <= absDistY) { return; } var timestamp = (0, _date.getNow)(); if (timestamp - this.endTime > momentumLimitTime && absDistX < momentumLimitDistance) { return; } this.movingDirectionX = deltaX > 0 ? DIRECTION_RIGHT : deltaX < 0 ? DIRECTION_LEFT : 0; var newX = this.x + deltaX; if (newX > 0) { newX = 0; } if (newX < this.maxScrollX) { newX = this.x + deltaX / 3; } if (!this.moved) { this.moved = true; } this._translate(newX, true); if (timestamp - this.startTime > momentumLimitTime) { this.startTime = timestamp; this.startX = this.x; } this.$emit(EVENT_SCROLL, this.x); }, onTouchEnd: function onTouchEnd() { if (!this.moved) { return; } if (this.movingDirectionX === DIRECTION_RIGHT) { this.shrink(); return; } this.endTime = (0, _date.getNow)(); var duration = this.endTime - this.startTime; var absDistX = Math.abs(this.x - this.startX); if (duration < momentumLimitTime && absDistX > momentumLimitDistance || this.x < this.maxScrollX / 2) { this.grow(); } else { this.shrink(); } }, onTransitionEnd: function onTransitionEnd() { this.isInTransition = false; this._transitionTime(); this._translate(this.x); } }, beforeDestroy: function beforeDestroy() { this.swipe.removeItem(this); } }; module.exports = exports['default']; }); /***/ }), /***/ 383: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else if (typeof exports !== "undefined") { factory(exports); } else { var mod = { exports: {} }; factory(mod.exports); global.ease = mod.exports; } })(this, function (exports) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var easeOutBack = exports.easeOutBack = 'cubic-bezier(0.18, 0.89, 0.32, 1.28)'; var easeOutQuart = exports.easeOutQuart = 'cubic-bezier(0.165, 0.84, 0.44, 1)'; var easeOutCubic = exports.easeOutCubic = 'cubic-bezier(0.22, 0.61, 0.36, 1)'; }); /***/ }), /***/ 384: /***/ (function(module, exports) { module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h; return _c('div', { ref: "swipeItem", staticClass: "cube-swipe-item", on: { "transitionend": _vm.onTransitionEnd, "touchstart": _vm.onTouchStart, "touchmove": _vm.onTouchMove, "touchend": _vm.onTouchEnd } }, [_vm._t("default", [_c('div', { staticClass: "cube-swipe-item-inner border-bottom-1px", on: { "click": _vm.clickItem } }, [_c('span', [_vm._v(_vm._s(_vm.item.text))])])]), _vm._v(" "), _c('ul', { staticClass: "cube-swipe-btns" }, _vm._l((_vm.btns), function(btn) { return _c('li', { ref: "btns", refInFor: true, staticClass: "cube-swipe-btn", style: (_vm.genBtnStyl(btn)), on: { "click": function($event) { $event.preventDefault(); _vm.clickBtn(btn) } } }, [_c('span', { staticClass: "text" }, [_vm._v(_vm._s(btn.text))])]) }))], 2) },staticRenderFns: []} /***/ }), /***/ 385: /***/ (function(module, exports) { module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h; return _c('div', { staticClass: "cube-swipe" }, [_vm._t("default", [_c('transition-group', { attrs: { "name": "cube-swipe", "tag": "ul" } }, _vm._l((_vm.data), function(item, index) { return _c('li', { key: item.item.value }, [_c('cube-swipe-item', { attrs: { "btns": item.btns, "item": item.item, "index": index, "auto-shrink": _vm.autoShrink } })], 1) }))])], 2) },staticRenderFns: []} /***/ }), /***/ 49: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else if (typeof exports !== "undefined") { factory(exports); } else { var mod = { exports: {} }; factory(mod.exports); global.env = mod.exports; } })(this, function (exports) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var inBrowser = exports.inBrowser = typeof window !== 'undefined'; var ua = exports.ua = inBrowser && navigator.userAgent.toLowerCase(); var isAndroid = exports.isAndroid = ua && ua.indexOf('android') > 0; var isIOS = exports.isIOS = ua && /iphone|ipad|ipod|ios/.test(ua); }); /***/ }), /***/ 87: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, __webpack_require__(49)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else if (typeof exports !== "undefined") { factory(exports, require('./env')); } else { var mod = { exports: {} }; factory(mod.exports, global.env); global.dom = mod.exports; } })(this, function (exports, _env) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasClass = hasClass; exports.addClass = addClass; exports.removeClass = removeClass; exports.getData = getData; exports.getRect = getRect; exports.prefixStyle = prefixStyle; exports.getMatchedTarget = getMatchedTarget; exports.dispatchEvent = dispatchEvent; function hasClass(el, className) { var reg = new RegExp('(^|\\s)' + className + '(\\s|$)'); return reg.test(el.className); } function addClass(el, className) { if (hasClass(el, className)) { return; } var newClass = el.className.split(' '); newClass.push(className); el.className = newClass.join(' '); } function removeClass(el, className) { if (!hasClass(el, className)) { return; } var reg = new RegExp('(^|\\s)' + className + '(\\s|$)', 'g'); el.className = el.className.replace(reg, ' '); } function getData(el, name) { var prefix = 'data-'; return el.getAttribute(prefix + name); } function getRect(el) { return { top: el.offsetTop, left: el.offsetLeft, width: el.offsetWidth, height: el.offsetHeight }; } var vendor = function () { if (!_env.inBrowser) { return false; } var elementStyle = document.createElement('div').style; var transformNames = { standard: 'transform', webkit: 'webkitTransform', Moz: 'MozTransform', O: 'OTransform', ms: 'msTransform' }; for (var key in transformNames) { if (elementStyle[transformNames[key]] !== undefined) { return key; } } return false; }(); function prefixStyle(style) { if (vendor === false) { return false; } if (vendor === 'standard') { if (style === 'transitionEnd') { return 'transitionend'; } return style; } return vendor + style.charAt(0).toUpperCase() + style.substr(1); } function getMatchedTarget(e, targetClassName) { var el = e.target; while (el && !hasClass(el, targetClassName)) { if (el === e.currentTarget) return null; el = el.parentNode; } return el; } function dispatchEvent(ele, name) { var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, _ref$type = _ref.type, type = _ref$type === undefined ? 'Event' : _ref$type, _ref$bubbles = _ref.bubbles, bubbles = _ref$bubbles === undefined ? true : _ref$bubbles, _ref$cancelable = _ref.cancelable, cancelable = _ref$cancelable === undefined ? true : _ref$cancelable; var e = document.createEvent(type); e.initEvent(name, bubbles, cancelable); ele.dispatchEvent(e); } }); /***/ }), /***/ 9: /***/ (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 } } /***/ }), /***/ 91: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else if (typeof exports !== "undefined") { factory(exports); } else { var mod = { exports: {} }; factory(mod.exports); global.date = mod.exports; } })(this, function (exports) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var DAY_TIMESTAMP = 60 * 60 * 24 * 1000; var HOUR_TIMESTAMP = 60 * 60 * 1000; var MINUTE_TIMESTAMP = 60 * 1000; function formatType(type, format, value, regExpAttributes) { var regExpMap = { year: '(Y+)', month: '(M+)', date: '(D+)', hour: '(h+)', minute: '(m+)', second: '(s+)', quarter: '(q+)', millisecond: '(S)' }; if (new RegExp(regExpMap[type], regExpAttributes).test(format)) { var replaceStr = type === 'year' ? value.toString().substr(4 - RegExp.$1.length) : RegExp.$1.length === 1 ? value : pad(value); format = format.replace(RegExp.$1, replaceStr); } return format; } function pad(value) { return ('00' + value).substr(('' + value).length); } function formatDate(date, format) { var map = { year: { value: date.getFullYear(), regExpAttributes: 'i' }, month: { value: date.getMonth() + 1 }, date: { value: date.getDate(), regExpAttributes: 'i' }, hour: { value: date.getHours(), regExpAttributes: 'i' }, minute: { value: date.getMinutes() }, second: { value: date.getSeconds() }, quarter: { value: Math.floor((date.getMonth() + 3) / 3), regExpAttributes: 'i' }, millisecond: { value: date.getMilliseconds() } }; for (var key in map) { format = formatType(key, format, map[key].value, map[key].regExpAttributes); } return format; } function getZeroStamp(date) { var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); return +new Date(year + '/' + month + '/' + day + ' 00:00:00'); } function getDayDiff(date1, date2) { return Math.floor((getZeroStamp(date1) - getZeroStamp(date2)) / DAY_TIMESTAMP); } function getNow() { return window.performance && window.performance.now ? window.performance.now() + window.performance.timing.navigationStart : +new Date(); } function computeNatureMaxDay(month, year) { var natureMaxDay = 30; if ([1, 3, 5, 7, 8, 10, 12].indexOf(month) > -1) { natureMaxDay = 31; } else { if (month === 2) { natureMaxDay = !year || !(year % 400) || !(year % 4) && year % 100 ? 29 : 28; } } return natureMaxDay; } exports.DAY_TIMESTAMP = DAY_TIMESTAMP; exports.HOUR_TIMESTAMP = HOUR_TIMESTAMP; exports.MINUTE_TIMESTAMP = MINUTE_TIMESTAMP; exports.pad = pad; exports.formatType = formatType; exports.formatDate = formatDate; exports.getZeroStamp = getZeroStamp; exports.getDayDiff = getDayDiff; exports.getNow = getNow; exports.computeNatureMaxDay = computeNatureMaxDay; }); /***/ }) /******/ }); });