Browse Source

chore: 优化一下,logic

es6
guy 3 years ago
parent
commit
276b4468f8
  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
});
},
_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({
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",
ref: function (_ref) {
self.text = _ref;
},
cls: "list-item-text",
textAlign: "left",
whiteSpace: "nowrap",
@ -40,32 +54,18 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
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", {
type: "bi.center_adapt",
items: [this.checkbox],
width: o.iconWrapperWidth
}, this.text)
}))));
}]
};
},
_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);

4
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",

4
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",

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

@ -21,14 +21,22 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
textRgap: 0
});
},
_init: function () {
BI.SingleSelectRadioItem.superclass._init.apply(this, arguments);
render: function () {
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"
});
this.text = BI.createWidget({
}]
}, {
type: "bi.label",
ref: function (_ref) {
self.text = _ref;
},
cls: "list-item-text",
textAlign: "left",
whiteSpace: "nowrap",
@ -41,17 +49,8 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
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", {
type: "bi.center_adapt",
items: [this.radio],
width: o.iconWrapperWidth
}, this.text)
}))));
}]
};
},
_setEnable: function (enable) {

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

@ -16,15 +16,26 @@ 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({
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);
});
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,
@ -34,25 +45,8 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
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
}))));
}]
};
},
doRedMark: function () {

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

@ -15,19 +15,32 @@ 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
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",
ref: function (_ref) {
self.text = _ref;
},
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
@ -37,23 +50,8 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, {
value: o.value,
keyword: o.keyword,
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 () {

Loading…
Cancel
Save