@lan-ui/lan-ui
Version:
A fantastic mobile ui lib implement by Vue
517 lines (457 loc) • 14.8 kB
JavaScript
(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["rate"] = factory();
else
root["lan"] = root["lan"] || {}, root["lan"]["rate"] = 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 = 423);
/******/ })
/************************************************************************/
/******/ ({
/***/ 204:
/***/ (function(module, exports, __webpack_require__) {
function injectStyle (ssrContext) {
__webpack_require__(228)
}
var Component = __webpack_require__(4)(
/* script */
__webpack_require__(229),
/* template */
__webpack_require__(230),
/* styles */
injectStyle,
/* scopeId */
null,
/* moduleIdentifier (server only) */
null
)
module.exports = Component.exports
/***/ }),
/***/ 225:
/***/ (function(module, exports, __webpack_require__) {
function injectStyle (ssrContext) {
__webpack_require__(226)
}
var Component = __webpack_require__(4)(
/* script */
__webpack_require__(227),
/* template */
__webpack_require__(231),
/* styles */
injectStyle,
/* scopeId */
null,
/* moduleIdentifier (server only) */
null
)
module.exports = Component.exports
/***/ }),
/***/ 226:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 227:
/***/ (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__(204)], __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('./rate-item.vue'));
} else {
var mod = {
exports: {}
};
factory(mod, mod.exports, global.rateItem);
global.rate = mod.exports;
}
})(this, function (module, exports, _rateItem) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _rateItem2 = _interopRequireDefault(_rateItem);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
var COMPONENT_NAME = 'cube-rate';
var EVENT_INPUT = 'input';
var EVENT_TYPE_MOUSE = 'mouse';
exports.default = {
name: COMPONENT_NAME,
props: {
value: {
type: Number,
default: 0
},
max: {
type: Number,
default: 5
},
disabled: {
type: Boolean,
default: false
},
justify: {
type: Boolean,
default: false
}
},
data: function data() {
return {
tempValue: this.value
};
},
created: function created() {
this.mousePressed = false;
},
computed: {
rateClass: function rateClass() {
return this.justify && 'cube-rate-justify';
}
},
watch: {
value: function value(val) {
if (val !== this.tempValue) {
this.tempValue = val;
}
}
},
methods: {
handleStart: function handleStart(e) {
if (!this.disabled) {
if (e.type.indexOf(EVENT_TYPE_MOUSE) > -1) {
this.mousePressed = true;
document.addEventListener('mouseup', this.handleEnd);
document.addEventListener('mousemove', this.handleMove);
}
var rect = this.$refs.rateContainer.getBoundingClientRect();
this.left = rect.left;
this.containerWidth = rect.width;
}
},
handleMove: function handleMove(e) {
if (!this.disabled && (e.type.indexOf(EVENT_TYPE_MOUSE) === -1 || this.mousePressed)) {
this.computeTempValue(e.type.indexOf(EVENT_TYPE_MOUSE) === -1 ? e.touches[0] : e);
}
},
handleEnd: function handleEnd(e) {
if (!this.disabled && (e.type.indexOf(EVENT_TYPE_MOUSE) === -1 || this.mousePressed)) {
if (e.type.indexOf(EVENT_TYPE_MOUSE) > -1) {
this.mousePressed = false;
document.removeEventListener('mouseup', this.handleEnd);
document.removeEventListener('mousemove', this.handleMove);
}
this.computeTempValue(e.type.indexOf(EVENT_TYPE_MOUSE) > -1 ? e : e.changedTouches[0]);
this.$emit(EVENT_INPUT, this.tempValue);
}
},
computeTempValue: function computeTempValue(touch) {
var leftAmount = Math.ceil((touch.clientX - this.left) / this.containerWidth * this.max);
if (leftAmount > 0 && leftAmount <= this.max) {
this.tempValue = leftAmount;
} else if (leftAmount <= 0) {
this.tempValue = 0;
} else {
this.tempValue = this.max;
}
}
},
components: {
CubeRateItem: _rateItem2.default
}
};
module.exports = exports['default'];
});
/***/ }),
/***/ 228:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 229:
/***/ (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_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);
} else {
var mod = {
exports: {}
};
factory(mod, mod.exports);
global.rateItem = mod.exports;
}
})(this, function (module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var COMPONENT_NAME = 'cube-rate-item';
exports.default = {
name: COMPONENT_NAME,
props: {
index: {
type: Number,
default: 0
}
}
};
module.exports = exports['default'];
});
/***/ }),
/***/ 230:
/***/ (function(module, exports) {
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
return _c('li', {
staticClass: "cube-rate-item",
class: {
'cube-rate-item_active': _vm.index <= _vm.$parent.tempValue
}
}, [_vm._t("default", [_c('div', {
staticClass: "cube-rate-item-def"
})])], 2)
},staticRenderFns: []}
/***/ }),
/***/ 231:
/***/ (function(module, exports) {
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
return _c('ul', {
ref: "rateContainer",
staticClass: "cube-rate",
class: _vm.rateClass,
on: {
"touchstart": function($event) {
$event.stopPropagation();
return _vm.handleStart($event)
},
"touchmove": function($event) {
$event.stopPropagation();
$event.preventDefault();
return _vm.handleMove($event)
},
"touchend": function($event) {
$event.stopPropagation();
return _vm.handleEnd($event)
},
"mousedown": function($event) {
$event.stopPropagation();
return _vm.handleStart($event)
},
"mousemove": function($event) {
$event.stopPropagation();
return _vm.handleMove($event)
},
"mouseup": function($event) {
$event.stopPropagation();
return _vm.handleEnd($event)
}
}
}, [_vm._t("default", _vm._l((_vm.max), function(n) {
return _c('cube-rate-item', {
key: n,
attrs: {
"index": n
}
})
}))], 2)
},staticRenderFns: []}
/***/ }),
/***/ 4:
/***/ (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
}
}
/***/ }),
/***/ 423:
/***/ (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__(225), __webpack_require__(204)], __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/rate/rate.vue'), require('../../components/rate/rate-item.vue'));
} else {
var mod = {
exports: {}
};
factory(mod, mod.exports, global.rate, global.rateItem);
global.index = mod.exports;
}
})(this, function (module, exports, _rate, _rateItem) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _rate2 = _interopRequireDefault(_rate);
var _rateItem2 = _interopRequireDefault(_rateItem);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
_rate2.default.install = function (Vue) {
Vue.component(_rate2.default.name, _rate2.default);
Vue.component(_rateItem2.default.name, _rateItem2.default);
};
_rate2.default.Item = _rateItem2.default;
exports.default = _rate2.default;
module.exports = exports['default'];
});
/***/ })
/******/ });
});