Avoid using global variables

This commit is contained in:
Inez Korczynski 2011-12-03 00:53:37 +00:00
parent 1f3604a959
commit e683199853

View file

@ -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' );