From 276b4468f85fb7cfd6c6696f8a33551a0d6620d9 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 25 Feb 2022 13:58:57 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A=20=E4=BC=98=E5=8C=96=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=EF=BC=8Clogic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/button/item.multiselect.js | 68 +++++++++---------- src/case/button/item.singleselect.icontext.js | 4 +- src/case/button/item.singleselect.js | 4 +- src/case/button/item.singleselect.radio.js | 57 ++++++++-------- src/case/button/node/node.arrow.js | 48 ++++++------- src/case/button/node/node.plus.js | 50 +++++++------- 6 files changed, 111 insertions(+), 120 deletions(-) diff --git a/src/case/button/item.multiselect.js b/src/case/button/item.multiselect.js index 8a082a16b..afe27abcc 100644 --- a/src/case/button/item.multiselect.js +++ b/src/case/button/item.multiselect.js @@ -20,52 +20,52 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { textRgap: 0 }); }, - _init: function () { - BI.MultiSelectItem.superclass._init.apply(this, arguments); + + render: function () { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.checkbox" }); - this.text = BI.createWidget({ - type: "bi.label", - cls: "list-item-text", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - rgap: o.rgap, - lgap: o.textLgap, - text: o.text, - keyword: o.keyword, - value: o.value, - 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", { + return { + type: "bi.vertical_adapt", + columnSize: [o.iconWrapperWidth || o.height, "fill"], + items: [{ type: "bi.center_adapt", - items: [this.checkbox], - width: o.iconWrapperWidth - }, this.text) - })))); + items: [this.checkbox] + }, { + type: "bi.label", + ref: function (_ref) { + self.text = _ref; + }, + cls: "list-item-text", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + rgap: o.rgap, + lgap: o.textLgap, + text: o.text, + keyword: o.keyword, + value: o.value, + py: o.py + }] + }; }, - _setEnable: function (enable) { - BI.MultiSelectItem.superclass._setEnable.apply(this, arguments); - if (enable === true) { - this.element.attr("tabIndex", 1); - } else if (enable === false) { - this.element.removeAttr("tabIndex"); - } - }, + // _setEnable: function (enable) { + // BI.MultiSelectItem.superclass._setEnable.apply(this, arguments); + // if (enable === true) { + // this.element.attr("tabIndex", 1); + // } else if (enable === false) { + // this.element.removeAttr("tabIndex"); + // } + // }, doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); diff --git a/src/case/button/item.singleselect.icontext.js b/src/case/button/item.singleselect.icontext.js index e1a3e4f05..a84170cb4 100644 --- a/src/case/button/item.singleselect.icontext.js +++ b/src/case/button/item.singleselect.icontext.js @@ -15,8 +15,8 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, { height: 24 }); }, - _init: function () { - BI.SingleSelectIconTextItem.superclass._init.apply(this, arguments); + + render: function () { var self = this, o = this.options; this.text = BI.createWidget({ type: "bi.icon_text_item", diff --git a/src/case/button/item.singleselect.js b/src/case/button/item.singleselect.js index 030dcff8f..56d7ac6a4 100644 --- a/src/case/button/item.singleselect.js +++ b/src/case/button/item.singleselect.js @@ -10,8 +10,8 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, { textAlign: "left" }); }, - _init: function () { - BI.SingleSelectItem.superclass._init.apply(this, arguments); + + render: function () { var self = this, o = this.options; this.text = BI.createWidget({ type: "bi.label", diff --git a/src/case/button/item.singleselect.radio.js b/src/case/button/item.singleselect.radio.js index 42c628247..93cef5ee7 100644 --- a/src/case/button/item.singleselect.radio.js +++ b/src/case/button/item.singleselect.radio.js @@ -21,37 +21,36 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { textRgap: 0 }); }, - _init: function () { - BI.SingleSelectRadioItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.radio = BI.createWidget({ - type: "bi.radio" - }); - this.text = BI.createWidget({ - type: "bi.label", - cls: "list-item-text", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - rgap: o.textRgap, - lgap: o.textLgap, - text: o.text, - keyword: o.keyword, - value: o.value, - py: o.py - }); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection("left", { + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + columnSize: [o.iconWrapperWidth || o.height, "fill"], + items: [{ type: "bi.center_adapt", - items: [this.radio], - width: o.iconWrapperWidth - }, this.text) - })))); + items: [{ + type: "bi.radio" + }] + }, { + type: "bi.label", + ref: function (_ref) { + self.text = _ref; + }, + cls: "list-item-text", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + rgap: o.textRgap, + lgap: o.textLgap, + text: o.text, + keyword: o.keyword, + value: o.value, + py: o.py + }] + }; }, _setEnable: function (enable) { diff --git a/src/case/button/node/node.arrow.js b/src/case/button/node/node.arrow.js index 38fe40ffb..68c58fac9 100644 --- a/src/case/button/node/node.arrow.js +++ b/src/case/button/node/node.arrow.js @@ -16,43 +16,37 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, { iconWrapperWidth: 16 }); }, - _init: function () { + + render: function () { var self = this, o = this.options; - BI.ArrowNode.superclass._init.apply(this, arguments); this.checkbox = BI.createWidget({ type: "bi.arrow_group_node_checkbox" }); - - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py, - 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 - })))); + return { + type: "bi.vertical_adapt", + columnSize: [o.iconWrapperWidth || o.height, "fill"], + items: [this.checkbox, { + type: "bi.label", + ref: function (_ref) { + self.text = _ref; + }, + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py, + keyword: o.keyword + }] + }; }, doRedMark: function () { diff --git a/src/case/button/node/node.plus.js b/src/case/button/node/node.plus.js index 3d71fc892..f60e1c933 100644 --- a/src/case/button/node/node.plus.js +++ b/src/case/button/node/node.plus.js @@ -15,28 +15,17 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, { id: "", pId: "", open: false, + iconWrapperWidth: null, height: 24 }); }, - _init: function () { - BI.PlusGroupNode.superclass._init.apply(this, arguments); + + render: function () { var self = this, o = this.options; this.checkbox = BI.createWidget({ type: "bi.tree_node_checkbox", iconHeight: o.height, - iconWidth: o.height - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - keyword: o.keyword, - py: o.py + iconWidth: o.iconWrapperWidth || o.height }); this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { if (type === BI.Events.CLICK) { @@ -44,16 +33,25 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, { } 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 - })))); + return { + type: "bi.vertical_adapt", + columnSize: [o.iconWrapperWidth || o.height, "fill"], + items: [this.checkbox, { + type: "bi.label", + ref: function (_ref) { + self.text = _ref; + }, + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + keyword: o.keyword, + py: o.py + }] + }; }, doRedMark: function () { @@ -77,4 +75,4 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, { } }); -BI.shortcut("bi.plus_group_node", BI.PlusGroupNode); \ No newline at end of file +BI.shortcut("bi.plus_group_node", BI.PlusGroupNode);