r105036 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105035‎ | r105036 | r105037 >
Date:00:53, 3 December 2011
Author:inez
Status:deferred
Tags:
Comment:
Avoid using global variables
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/tools/es.ListButtonTool.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/tools/es.ListButtonTool.js
@@ -1,14 +1,25 @@
22 es.ListButtonTool = function( toolbar, name, data ) {
33 es.ButtonTool.call( this, toolbar, name );
44 this.data = data;
 5+ this.nodes = [];
56 };
67
78 es.ListButtonTool.prototype.onClick = function() {
 9+ /*
 10+ var parent;
 11+ for( var i = 0; i < this.nodes.length; i++ ) {
 12+ parent = this.nodes[i].getParent();
 13+ if ( parent.getElementType() !== 'listItem' ) {
 14+ console.log( this.nodes[i] );
 15+ }
 16+ }
 17+ */
818 };
919
1020 es.ListButtonTool.prototype.updateState = function( annotations, nodes ) {
1121 // checks if all passed nodes are listItems of passed style
1222 function check( nodes, style ) {
 23+ var parent, styles;
1324 for( var i = 0; i < nodes.length; i++ ) {
1425 parent = nodes[i].getParent();
1526 if ( parent.getElementType() !== 'listItem' ) {
@@ -22,7 +33,8 @@
2334 return true;
2435 }
2536
26 - if ( check( nodes, this.name ) ) {
 37+ this.nodes = nodes;
 38+ if ( check( this.nodes, this.name ) ) {
2739 this.$.addClass( 'es-toolbarButtonTool-down' );
2840 } else {
2941 this.$.removeClass( 'es-toolbarButtonTool-down' );

Status & tagging log