Browse Source

Pull request #2510: 无JIRA任务 chore: 优化一下,logic

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit '4dedbf2200bc4cf371ab06df9d1dcd59d6d99200':
  chore: 优化一下,logic
es6
guy 3 years ago
parent
commit
dacbe858c9
  1. 54
      src/case/button/item.multiselect.js
  2. 4
      src/case/button/item.singleselect.icontext.js
  3. 4
      src/case/button/item.singleselect.js
  4. 31
      src/case/button/item.singleselect.radio.js
  5. 40
      src/case/button/node/node.arrow.js
  6. 40
      src/case/button/node/node.plus.js

54
src/case/button/item.multiselect.js

@ -20,14 +20,28 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
textRgap: 0 textRgap: 0
}); });
}, },
_init: function () {
BI.MultiSelectItem.superclass._init.apply(this, arguments); render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.checkbox" type: "bi.checkbox"
}); });
this.text = BI.createWidget({ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
self.setSelected(self.isSelected());
}
});
return {
type: "bi.vertical_adapt",
columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [{
type: "bi.center_adapt",
items: [this.checkbox]
}, {
type: "bi.label", type: "bi.label",
ref: function (_ref) {
self.text = _ref;
},
cls: "list-item-text", cls: "list-item-text",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -40,32 +54,18 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
keyword: o.keyword, keyword: o.keyword,
value: o.value, value: o.value,
py: o.py py: o.py
}); }]
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { };
if (type === BI.Events.CLICK) {
self.setSelected(self.isSelected());
}
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("left", {
type: "bi.center_adapt",
items: [this.checkbox],
width: o.iconWrapperWidth
}, this.text)
}))));
}, },
_setEnable: function (enable) { // _setEnable: function (enable) {
BI.MultiSelectItem.superclass._setEnable.apply(this, arguments); // BI.MultiSelectItem.superclass._setEnable.apply(this, arguments);
if (enable === true) { // if (enable === true) {
this.element.attr("tabIndex", 1); // this.element.attr("tabIndex", 1);
} else if (enable === false) { // } else if (enable === false) {
this.element.removeAttr("tabIndex"); // this.element.removeAttr("tabIndex");
} // }
}, // },
doRedMark: function () { doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);

4
src/case/button/item.singleselect.icontext.js

@ -15,8 +15,8 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, {
height: 24 height: 24
}); });
}, },
_init: function () {
BI.SingleSelectIconTextItem.superclass._init.apply(this, arguments); render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.icon_text_item", type: "bi.icon_text_item",

4
src/case/button/item.singleselect.js

@ -10,8 +10,8 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, {
textAlign: "left" textAlign: "left"
}); });
}, },
_init: function () {
BI.SingleSelectItem.superclass._init.apply(this, arguments); render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.label", type: "bi.label",

31
src/case/button/item.singleselect.radio.js

@ -21,14 +21,22 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
textRgap: 0 textRgap: 0
}); });
}, },
_init: function () {
BI.SingleSelectRadioItem.superclass._init.apply(this, arguments); render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.radio = BI.createWidget({ return {
type: "bi.vertical_adapt",
columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [{
type: "bi.center_adapt",
items: [{
type: "bi.radio" type: "bi.radio"
}); }]
this.text = BI.createWidget({ }, {
type: "bi.label", type: "bi.label",
ref: function (_ref) {
self.text = _ref;
},
cls: "list-item-text", cls: "list-item-text",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -41,17 +49,8 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
keyword: o.keyword, keyword: o.keyword,
value: o.value, value: o.value,
py: o.py py: o.py
}); }]
};
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("left", {
type: "bi.center_adapt",
items: [this.radio],
width: o.iconWrapperWidth
}, this.text)
}))));
}, },
_setEnable: function (enable) { _setEnable: function (enable) {

40
src/case/button/node/node.arrow.js

@ -16,15 +16,26 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
iconWrapperWidth: 16 iconWrapperWidth: 16
}); });
}, },
_init: function () {
render: function () {
var self = this, o = this.options; var self = this, o = this.options;
BI.ArrowNode.superclass._init.apply(this, arguments);
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.arrow_group_node_checkbox" type: "bi.arrow_group_node_checkbox"
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
this.text = BI.createWidget({ if (type === BI.Events.CLICK) {
self.setSelected(self.isSelected());
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
return {
type: "bi.vertical_adapt",
columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [this.checkbox, {
type: "bi.label", type: "bi.label",
ref: function (_ref) {
self.text = _ref;
},
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
textHeight: o.height, textHeight: o.height,
@ -34,25 +45,8 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword
}); }]
};
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
self.setSelected(self.isSelected());
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: o.iconWrapperWidth,
el: this.checkbox
}, this.text);
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items
}))));
}, },
doRedMark: function () { doRedMark: function () {

40
src/case/button/node/node.plus.js

@ -15,19 +15,32 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, {
id: "", id: "",
pId: "", pId: "",
open: false, open: false,
iconWrapperWidth: null,
height: 24 height: 24
}); });
}, },
_init: function () {
BI.PlusGroupNode.superclass._init.apply(this, arguments); render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.tree_node_checkbox", type: "bi.tree_node_checkbox",
iconHeight: o.height, iconHeight: o.height,
iconWidth: o.height iconWidth: o.iconWrapperWidth || o.height
});
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
self.setSelected(self.isSelected());
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
this.text = BI.createWidget({ return {
type: "bi.vertical_adapt",
columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [this.checkbox, {
type: "bi.label", type: "bi.label",
ref: function (_ref) {
self.text = _ref;
},
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
textHeight: o.height, textHeight: o.height,
@ -37,23 +50,8 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, {
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
py: o.py py: o.py
}); }]
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { };
if (type === BI.Events.CLICK) {
self.setSelected(self.isSelected());
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
el: this.checkbox
}, this.text);
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items
}))));
}, },
doRedMark: function () { doRedMark: function () {

Loading…
Cancel
Save