Browse Source

Pull request #1822: 统一item.mulitselect和item.singleselect.radio 图标和文字的布局行为 && 临时回滚layout中patchItem改动

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

* commit 'f8a30ba6eca66f17ce7aa4eb299d28e79a52405d':
  无JIRA任务 统一item.mulitselect和item.singleselect.radio 图标和文字的布局行为
  无JIRA任务 revert: 5fb75ef130 [5fb75ef]
  无JIRA任务 统一item.mulitselect和item.singleselect.radio 图标和文字的布局行为
es6
parent
commit
9e60b230d7
  1. 8
      src/case/button/item.multiselect.js
  2. 10
      src/case/button/item.singleselect.radio.js
  3. 26
      src/core/wrapper/layout.js

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

@ -11,7 +11,9 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
logic: { logic: {
dynamic: false dynamic: false
}, },
iconWrapperWidth: 26 iconWrapperWidth: 16,
textHgap: 0,
textRgap: 0
}); });
}, },
_init: function () { _init: function () {
@ -27,8 +29,8 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
whiteSpace: "nowrap", whiteSpace: "nowrap",
textHeight: o.height, textHeight: o.height,
height: o.height, height: o.height,
hgap: o.hgap, hgap: o.textHgap,
rgap: o.rgap, rgap: o.textHgap,
text: o.text, text: o.text,
keyword: o.keyword, keyword: o.keyword,
value: o.value, value: o.value,

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

@ -10,7 +10,10 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
logic: { logic: {
dynamic: false dynamic: false
}, },
height: 24 height: 24,
iconWrapperWidth: 16,
textHgap: 0,
textRgap: 0
}); });
}, },
_init: function () { _init: function () {
@ -26,7 +29,8 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
whiteSpace: "nowrap", whiteSpace: "nowrap",
textHeight: o.height, textHeight: o.height,
height: o.height, height: o.height,
hgap: o.hgap, hgap: o.textHgap,
rgap: o.textHgap,
text: o.text, text: o.text,
keyword: o.keyword, keyword: o.keyword,
value: o.value, value: o.value,
@ -39,7 +43,7 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
items: BI.LogicFactory.createLogicItemsByDirection("left", { items: BI.LogicFactory.createLogicItemsByDirection("left", {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.radio], items: [this.radio],
width: 16 width: o.conWrapperWidth
}, this.text) }, this.text)
})))); }))));
}, },

26
src/core/wrapper/layout.js

@ -71,13 +71,12 @@ BI.Layout = BI.inherit(BI.Widget, {
var self = this; var self = this;
var frag = BI.Widget._renderEngine.createFragment(); var frag = BI.Widget._renderEngine.createFragment();
var hasChild = false; var hasChild = false;
for (var key in this._children) { BI.each(this._children, function (i, widget) {
var child = this._children[key]; if (widget.element !== self.element) {
if (child.element !== self.element) { frag.appendChild(widget.element[0]);
frag.appendChild(child.element[0]);
hasChild = true; hasChild = true;
} }
} });
if (hasChild === true) { if (hasChild === true) {
this.appendFragment(frag); this.appendFragment(frag);
} }
@ -269,13 +268,19 @@ BI.Layout = BI.inherit(BI.Widget, {
if (!child.shouldUpdate) { if (!child.shouldUpdate) {
return null; return null;
} }
return child.shouldUpdate(this._getOptions(item)); return child.shouldUpdate(this._getOptions(item)) === true;
}, },
updateItemAt: function (index, item) { updateItemAt: function (index, item) {
if (index < 0 || index > this.options.items.length - 1) { if (index < 0 || index > this.options.items.length - 1) {
return; return;
} }
var child = this._children[this._getChildName(index)];
var updated;
if (updated = child.update(this._getOptions(item))) {
return updated;
}
var del = this._children[this._getChildName(index)]; var del = this._children[this._getChildName(index)];
delete this._children[this._getChildName(index)]; delete this._children[this._getChildName(index)];
this.options.items.splice(index, 1); this.options.items.splice(index, 1);
@ -362,14 +367,7 @@ BI.Layout = BI.inherit(BI.Widget, {
patchItem: function (oldVnode, vnode, index) { patchItem: function (oldVnode, vnode, index) {
var shouldUpdate = this.shouldUpdateItem(index, vnode); var shouldUpdate = this.shouldUpdateItem(index, vnode);
var child = this._children[this._getChildName(index)]; if (shouldUpdate === true || (shouldUpdate === null && !this._compare(oldVnode, vnode))) {
if (shouldUpdate) {
return child._update(this._getOptions(vnode), shouldUpdate);
}
if (shouldUpdate === null && !this._compare(oldVnode, vnode)) {
// if (child.update) {
// return child.update(this._getOptions(vnode));
// }
return this.updateItemAt(index, vnode); return this.updateItemAt(index, vnode);
} }
}, },

Loading…
Cancel
Save