tfp
Version:
A Web UI framework for TaskBuilder
110 lines (86 loc) • 3.86 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _controller = require("../controller.js");
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
/**
* 开关组件
* @param {[type]} dataModel [description]
*/
var Switch = /*#__PURE__*/function (_FormInput) {
(0, _inherits2["default"])(Switch, _FormInput);
var _super = _createSuper(Switch);
function Switch(__tfp, dataModel, parent) {
(0, _classCallCheck2["default"])(this, Switch);
return _super.call(this, __tfp, "Switch", dataModel, parent);
} //属性
(0, _createClass2["default"])(Switch, [{
key: "value",
get: function get() {
if (this._jqObj) {
if (this._jqObj.find("div").css("float") == "right") {
this.dataModel.value = this.dataModel.options[1];
} else {
this.dataModel.value = this.dataModel.options[0];
}
}
/*if(this.dataModel.value==undefined || this.dataModel.value==null) {
if(this.dataModel.options && this.dataModel.options.length>0)
this.dataModel.value = this.dataModel.options[0];
}*/
return this.dataModel.value;
},
set: function set(value) {
this.dataModel.value = value;
if (this._jqObj) {
if (value + "" == this.dataModel.options[1] + "") {
this._jqObj.find("div").css("float", "right");
this._jqObj.find("div").css("background-color", "#0099ff");
} else {
this._jqObj.find("div").css("float", "left");
this._jqObj.find("div").css("background-color", "#999999");
}
}
if (!this._tfp.isDesigning) {
this.valueOnChange();
this.exeEventHandler("onChange", value);
}
}
}, {
key: "options",
get: function get() {
return this.dataModel.options;
},
set: function set(value) {
if (!value) return;
if (typeof value == "string") {
this.dataModel.options = value.split(",");
} else if (Array.isArray(value)) {
this.dataModel.options = value;
}
}
}, {
key: "initRuntime",
value: function initRuntime() {
var that = this;
this._jqObj.click(function () {
if (that.dataModel.value == that.dataModel.options[1]) {
that.value = that.dataModel.options[0];
} else {
that.value = that.dataModel.options[1];
}
});
}
}]);
return Switch;
}(_controller.FormInput);
exports["default"] = Switch;