Merge "Add reset method to toolbar"

This commit is contained in:
jenkins-bot 2013-10-31 19:58:36 +00:00 committed by Gerrit Code Review
commit 7c6f534a74

View file

@ -125,10 +125,7 @@ OO.ui.Toolbar.prototype.setup = function ( groups ) {
};
// Cleanup previous groups
for ( i = 0, len = this.items.length; i < len; i++ ) {
this.items[i].destroy();
}
this.clearItems();
this.reset();
// Build out new groups
for ( i = 0, len = groups.length; i < len; i++ ) {
@ -150,18 +147,27 @@ OO.ui.Toolbar.prototype.setup = function ( groups ) {
this.addItems( items );
};
/**
* Remove all tools and groups from the toolbar.
*/
OO.ui.Toolbar.prototype.reset = function () {
var i, len;
this.groups = [];
this.tools = {};
for ( i = 0, len = this.items.length; i < len; i++ ) {
this.items[i].destroy();
}
this.clearItems();
};
/**
* Destroys toolbar, removing event handlers and DOM elements.
*
* Call this whenever you are done using a toolbar.
*/
OO.ui.Toolbar.prototype.destroy = function () {
var i, len;
for ( i = 0, len = this.items.length; i < len; i++ ) {
this.items[i].destroy();
}
this.clearItems();
this.reset();
this.$.remove();
};