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. 48
      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
});
},
_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);

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

57
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) {

48
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 () {

48
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 () {

Loading…
Cancel
Save