mindoc/static/element-ui/lib/switch.js
2017-04-19 18:19:27 +08:00

389 lines
8.3 KiB
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] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = 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;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/dist/";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(293);
/***/ },
/***/ 3:
/***/ function(module, exports) {
module.exports = function normalizeComponent (
rawScriptExports,
compiledTemplate,
scopeId,
cssModules
) {
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
}
// inject cssModules
if (cssModules) {
var computed = options.computed || (options.computed = {})
Object.keys(cssModules).forEach(function (key) {
var module = cssModules[key]
computed[key] = function () { return module }
})
}
return {
esModule: esModule,
exports: scriptExports,
options: options
}
}
/***/ },
/***/ 293:
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _component = __webpack_require__(294);
var _component2 = _interopRequireDefault(_component);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* istanbul ignore next */
_component2.default.install = function (Vue) {
Vue.component(_component2.default.name, _component2.default);
};
exports.default = _component2.default;
/***/ },
/***/ 294:
/***/ function(module, exports, __webpack_require__) {
var Component = __webpack_require__(3)(
/* script */
__webpack_require__(295),
/* template */
__webpack_require__(296),
/* scopeId */
null,
/* cssModules */
null
)
module.exports = Component.exports
/***/ },
/***/ 295:
/***/ function(module, exports) {
'use strict';
exports.__esModule = true;
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
exports.default = {
name: 'ElSwitch',
props: {
value: {
type: Boolean,
default: true
},
disabled: {
type: Boolean,
default: false
},
width: {
type: Number,
default: 0
},
onIconClass: {
type: String,
default: ''
},
offIconClass: {
type: String,
default: ''
},
onText: {
type: String,
default: 'ON'
},
offText: {
type: String,
default: 'OFF'
},
onColor: {
type: String,
default: ''
},
offColor: {
type: String,
default: ''
},
name: {
type: String,
default: ''
}
},
data: function data() {
return {
coreWidth: this.width
};
},
computed: {
hasText: function hasText() {
/* istanbul ignore next */
return this.onText || this.offText;
},
_value: {
get: function get() {
return this.value;
},
set: function set(val) {
this.$emit('input', val);
}
},
transform: function transform() {
return this.value ? 'translate(' + (this.coreWidth - 20) + 'px, 2px)' : 'translate(2px, 2px)';
}
},
watch: {
value: function value() {
if (this.onColor || this.offColor) {
this.setBackgroundColor();
}
}
},
methods: {
handleChange: function handleChange(event) {
this.$emit('change', event.currentTarget.checked);
},
setBackgroundColor: function setBackgroundColor() {
var newColor = this.value ? this.onColor : this.offColor;
this.$refs.core.style.borderColor = newColor;
this.$refs.core.style.backgroundColor = newColor;
}
},
mounted: function mounted() {
/* istanbul ignore if */
if (this.width === 0) {
this.coreWidth = this.hasText ? 58 : 46;
}
if (this.onColor || this.offColor) {
this.setBackgroundColor();
}
}
};
/***/ },
/***/ 296:
/***/ function(module, exports) {
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
return _c('label', {
staticClass: "el-switch",
class: {
'is-disabled': _vm.disabled, 'el-switch--wide': _vm.hasText
}
}, [_c('div', {
directives: [{
name: "show",
rawName: "v-show",
value: (_vm.disabled),
expression: "disabled"
}],
staticClass: "el-switch__mask"
}), _c('input', {
directives: [{
name: "model",
rawName: "v-model",
value: (_vm._value),
expression: "_value"
}],
staticClass: "el-switch__input",
attrs: {
"type": "checkbox",
"name": _vm.name,
"disabled": _vm.disabled
},
domProps: {
"checked": Array.isArray(_vm._value) ? _vm._i(_vm._value, null) > -1 : (_vm._value)
},
on: {
"change": [function($event) {
var $$a = _vm._value,
$$el = $event.target,
$$c = $$el.checked ? (true) : (false);
if (Array.isArray($$a)) {
var $$v = null,
$$i = _vm._i($$a, $$v);
if ($$c) {
$$i < 0 && (_vm._value = $$a.concat($$v))
} else {
$$i > -1 && (_vm._value = $$a.slice(0, $$i).concat($$a.slice($$i + 1)))
}
} else {
_vm._value = $$c
}
}, _vm.handleChange]
}
}), _c('span', {
ref: "core",
staticClass: "el-switch__core",
style: ({
'width': _vm.coreWidth + 'px'
})
}, [_c('span', {
staticClass: "el-switch__button",
style: ({
transform: _vm.transform
})
})]), _c('transition', {
attrs: {
"name": "label-fade"
}
}, [_c('div', {
directives: [{
name: "show",
rawName: "v-show",
value: (_vm.value),
expression: "value"
}],
staticClass: "el-switch__label el-switch__label--left",
style: ({
'width': _vm.coreWidth + 'px'
})
}, [(_vm.onIconClass) ? _c('i', {
class: [_vm.onIconClass]
}) : _vm._e(), (!_vm.onIconClass && _vm.onText) ? _c('span', [_vm._v(_vm._s(_vm.onText))]) : _vm._e()])]), _c('transition', {
attrs: {
"name": "label-fade"
}
}, [_c('div', {
directives: [{
name: "show",
rawName: "v-show",
value: (!_vm.value),
expression: "!value"
}],
staticClass: "el-switch__label el-switch__label--right",
style: ({
'width': _vm.coreWidth + 'px'
})
}, [(_vm.offIconClass) ? _c('i', {
class: [_vm.offIconClass]
}) : _vm._e(), (!_vm.offIconClass && _vm.offText) ? _c('span', [_vm._v(_vm._s(_vm.offText))]) : _vm._e()])])], 1)
},staticRenderFns: []}
/***/ }
/******/ });