From 0f9eb6313a5a1a949662eb17c5e09cfb6c7e5189 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 28 Mar 2017 17:44:19 +0800 Subject: [PATCH] add --- bi/base.js | 28 +++++++++++++++++++++++---- bi/core.js | 23 ++++++++++++++++------ dist/base.js | 28 +++++++++++++++++++++++---- dist/core.js | 23 ++++++++++++++++------ src/base/combination/group.button.js | 18 ++++++++++++++--- src/base/combination/group.virtual.js | 10 +++++++++- src/core/wrapper/layout.js | 23 ++++++++++++++++------ src/css/base/single/text.css | 2 +- src/less/base/single/text.less | 2 +- 9 files changed, 125 insertions(+), 32 deletions(-) diff --git a/bi/base.js b/bi/base.js index 2d39187d1..77e869009 100644 --- a/bi/base.js +++ b/bi/base.js @@ -1118,9 +1118,21 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.layouts.addItems(this._packageLayout(items).items); }, - removeItemAt: function (index) { - this.buttons[index].destroy(); - this.layouts.removeItemAt(index); + removeItemAt: function (indexes) { + BI.remove(this.buttons, indexes); + this.layouts.removeItemAt(indexes); + }, + + removeItems: function (values) { + values = BI.isArray(values) ? values : [values]; + var deleted = []; + BI.each(this.buttons, function (i, button) { + if (BI.deepContains(values, button.getValue())) { + deleted.push(i); + } + }); + BI.remove(this.buttons, deleted); + this.layouts.removeItemAt(deleted); }, populate: function (items) { @@ -3609,7 +3621,15 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid }, prependItems: function (items) { - this.layouts.prependItems(items); + this.layouts.prependItems(items); + }, + + setValue: function (v) { + this.layouts.setValue(v); + }, + + getValue: function () { + return this.layouts.getValue(); }, populate: function (items) { diff --git a/bi/core.js b/bi/core.js index bc36f84a6..e065a7a4b 100644 --- a/bi/core.js +++ b/bi/core.js @@ -11419,13 +11419,24 @@ BI.Layout = BI.inherit(BI.Widget, { return w; }, - removeItemAt: function (index) { - if (index < 0 || index > this.options.items.length - 1) { - return; + removeItemAt: function (indexes) { + indexes = BI.isArray(indexes) ? indexes : [indexes]; + var deleted = []; + var newItems = [], newChildren = {}; + for (var i = 0, len = this.options.items.length; i < len; i++) { + var child = this._children[this._getChildName(i)]; + if (indexes.contains(i)) { + deleted.push(child); + } else { + newChildren[this._getChildName(newItems.length)] = child; + newItems.push(this.options.items[i]); + } } - var child = this._children[this._getChildName(index)]; - this._removeItemAt(index); - child.destroy(); + this.options.items = newItems; + this._children = newChildren; + BI.each(deleted, function (i, c) { + c.destroy(); + }); }, updateItemAt: function (index, item) { diff --git a/dist/base.js b/dist/base.js index 2d39187d1..77e869009 100644 --- a/dist/base.js +++ b/dist/base.js @@ -1118,9 +1118,21 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.layouts.addItems(this._packageLayout(items).items); }, - removeItemAt: function (index) { - this.buttons[index].destroy(); - this.layouts.removeItemAt(index); + removeItemAt: function (indexes) { + BI.remove(this.buttons, indexes); + this.layouts.removeItemAt(indexes); + }, + + removeItems: function (values) { + values = BI.isArray(values) ? values : [values]; + var deleted = []; + BI.each(this.buttons, function (i, button) { + if (BI.deepContains(values, button.getValue())) { + deleted.push(i); + } + }); + BI.remove(this.buttons, deleted); + this.layouts.removeItemAt(deleted); }, populate: function (items) { @@ -3609,7 +3621,15 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid }, prependItems: function (items) { - this.layouts.prependItems(items); + this.layouts.prependItems(items); + }, + + setValue: function (v) { + this.layouts.setValue(v); + }, + + getValue: function () { + return this.layouts.getValue(); }, populate: function (items) { diff --git a/dist/core.js b/dist/core.js index 18bd9eefa..efa58d6bb 100644 --- a/dist/core.js +++ b/dist/core.js @@ -19552,13 +19552,24 @@ BI.Layout = BI.inherit(BI.Widget, { return w; }, - removeItemAt: function (index) { - if (index < 0 || index > this.options.items.length - 1) { - return; + removeItemAt: function (indexes) { + indexes = BI.isArray(indexes) ? indexes : [indexes]; + var deleted = []; + var newItems = [], newChildren = {}; + for (var i = 0, len = this.options.items.length; i < len; i++) { + var child = this._children[this._getChildName(i)]; + if (indexes.contains(i)) { + deleted.push(child); + } else { + newChildren[this._getChildName(newItems.length)] = child; + newItems.push(this.options.items[i]); + } } - var child = this._children[this._getChildName(index)]; - this._removeItemAt(index); - child.destroy(); + this.options.items = newItems; + this._children = newChildren; + BI.each(deleted, function (i, c) { + c.destroy(); + }); }, updateItemAt: function (index, item) { diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index f680af2cc..d4d7ad278 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -155,9 +155,21 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.layouts.addItems(this._packageLayout(items).items); }, - removeItemAt: function (index) { - this.buttons[index].destroy(); - this.layouts.removeItemAt(index); + removeItemAt: function (indexes) { + BI.remove(this.buttons, indexes); + this.layouts.removeItemAt(indexes); + }, + + removeItems: function (values) { + values = BI.isArray(values) ? values : [values]; + var deleted = []; + BI.each(this.buttons, function (i, button) { + if (BI.deepContains(values, button.getValue())) { + deleted.push(i); + } + }); + BI.remove(this.buttons, deleted); + this.layouts.removeItemAt(deleted); }, populate: function (items) { diff --git a/src/base/combination/group.virtual.js b/src/base/combination/group.virtual.js index 2a959d710..48ebdcb10 100644 --- a/src/base/combination/group.virtual.js +++ b/src/base/combination/group.virtual.js @@ -52,7 +52,15 @@ BI.VirtualGroup = BI.inherit(BI.Widget, { }, prependItems: function (items) { - this.layouts.prependItems(items); + this.layouts.prependItems(items); + }, + + setValue: function (v) { + this.layouts.setValue(v); + }, + + getValue: function () { + return this.layouts.getValue(); }, populate: function (items) { diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 4074b3fd7..f4b0dbd48 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -220,13 +220,24 @@ BI.Layout = BI.inherit(BI.Widget, { return w; }, - removeItemAt: function (index) { - if (index < 0 || index > this.options.items.length - 1) { - return; + removeItemAt: function (indexes) { + indexes = BI.isArray(indexes) ? indexes : [indexes]; + var deleted = []; + var newItems = [], newChildren = {}; + for (var i = 0, len = this.options.items.length; i < len; i++) { + var child = this._children[this._getChildName(i)]; + if (indexes.contains(i)) { + deleted.push(child); + } else { + newChildren[this._getChildName(newItems.length)] = child; + newItems.push(this.options.items[i]); + } } - var child = this._children[this._getChildName(index)]; - this._removeItemAt(index); - child.destroy(); + this.options.items = newItems; + this._children = newChildren; + BI.each(deleted, function (i, c) { + c.destroy(); + }); }, updateItemAt: function (index, item) { diff --git a/src/css/base/single/text.css b/src/css/base/single/text.css index 34613e8aa..ce71f6ee5 100644 --- a/src/css/base/single/text.css +++ b/src/css/base/single/text.css @@ -6,5 +6,5 @@ overflow-x: hidden; overflow-y: hidden; white-space: nowrap; - word-break: break-all; + word-break: break-word; } diff --git a/src/less/base/single/text.less b/src/less/base/single/text.less index 568122a9c..a6f1d83cd 100644 --- a/src/less/base/single/text.less +++ b/src/less/base/single/text.less @@ -2,5 +2,5 @@ .bi-text{ .overflow-dot(); - word-break: break-all; + word-break: break-word; } \ No newline at end of file