mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
Avoid using global variables
This commit is contained in:
parent
1f3604a959
commit
e683199853
|
@ -1,14 +1,25 @@
|
|||
es.ListButtonTool = function( toolbar, name, data ) {
|
||||
es.ButtonTool.call( this, toolbar, name );
|
||||
this.data = data;
|
||||
this.nodes = [];
|
||||
};
|
||||
|
||||
es.ListButtonTool.prototype.onClick = function() {
|
||||
/*
|
||||
var parent;
|
||||
for( var i = 0; i < this.nodes.length; i++ ) {
|
||||
parent = this.nodes[i].getParent();
|
||||
if ( parent.getElementType() !== 'listItem' ) {
|
||||
console.log( this.nodes[i] );
|
||||
}
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
es.ListButtonTool.prototype.updateState = function( annotations, nodes ) {
|
||||
// checks if all passed nodes are listItems of passed style
|
||||
function check( nodes, style ) {
|
||||
var parent, styles;
|
||||
for( var i = 0; i < nodes.length; i++ ) {
|
||||
parent = nodes[i].getParent();
|
||||
if ( parent.getElementType() !== 'listItem' ) {
|
||||
|
@ -22,7 +33,8 @@ es.ListButtonTool.prototype.updateState = function( annotations, nodes ) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if ( check( nodes, this.name ) ) {
|
||||
this.nodes = nodes;
|
||||
if ( check( this.nodes, this.name ) ) {
|
||||
this.$.addClass( 'es-toolbarButtonTool-down' );
|
||||
} else {
|
||||
this.$.removeClass( 'es-toolbarButtonTool-down' );
|
||||
|
|
Loading…
Reference in a new issue