mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Add reset method to toolbar"
This commit is contained in:
commit
7c6f534a74
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue