Browse Source

chore: 优化一下,logic

es6
guy 3 years ago
parent
commit
276b4468f8
  1. 68
      src/case/button/item.multiselect.js
  2. 4
      src/case/button/item.singleselect.icontext.js
  3. 4
      src/case/button/item.singleselect.js
  4. 57
      src/case/button/item.singleselect.radio.js
  5. 48
      src/case/button/node/node.arrow.js
  6. 50
      src/case/button/node/node.plus.js

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

@ -20,52 +20,52 @@ 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({
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) { this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
self.setSelected(self.isSelected()); self.setSelected(self.isSelected());
} }
}); });
return {
BI.createWidget(BI.extend({ type: "bi.vertical_adapt",
element: this columnSize: [o.iconWrapperWidth || o.height, "fill"],
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { items: [{
items: BI.LogicFactory.createLogicItemsByDirection("left", {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.checkbox], items: [this.checkbox]
width: o.iconWrapperWidth }, {
}, this.text) 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) { // _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",

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

@ -21,37 +21,36 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
textRgap: 0 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({ render: function () {
element: this var self = this, o = this.options;
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { return {
items: BI.LogicFactory.createLogicItemsByDirection("left", { type: "bi.vertical_adapt",
columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [{
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.radio], items: [{
width: o.iconWrapperWidth type: "bi.radio"
}, this.text) }]
})))); }, {
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) { _setEnable: function (enable) {

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

@ -16,43 +16,37 @@ 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.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) { this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
self.setSelected(self.isSelected()); self.setSelected(self.isSelected());
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
return {
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); type: "bi.vertical_adapt",
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { columnSize: [o.iconWrapperWidth || o.height, "fill"],
width: o.iconWrapperWidth, items: [this.checkbox, {
el: this.checkbox type: "bi.label",
}, this.text); ref: function (_ref) {
BI.createWidget(BI.extend({ self.text = _ref;
element: this },
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { textAlign: "left",
items: items 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 () { doRedMark: function () {

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

@ -15,28 +15,17 @@ 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.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
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
@ -44,16 +33,25 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, {
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); return {
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { type: "bi.vertical_adapt",
width: 24, columnSize: [o.iconWrapperWidth || o.height, "fill"],
el: this.checkbox items: [this.checkbox, {
}, this.text); type: "bi.label",
BI.createWidget(BI.extend({ ref: function (_ref) {
element: this self.text = _ref;
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { },
items: items 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 () { doRedMark: function () {
@ -77,4 +75,4 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, {
} }
}); });
BI.shortcut("bi.plus_group_node", BI.PlusGroupNode); BI.shortcut("bi.plus_group_node", BI.PlusGroupNode);

Loading…
Cancel
Save