r104922 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104921‎ | r104922 | r104923 >
Date:23:53, 1 December 2011
Author:inez
Status:deferred
Tags:
Comment:
Implemented es.FormatDropdownTool.prototype.updateState
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js
@@ -33,8 +33,31 @@
3434 }
3535 };
3636
37 -es.FormatDropdownTool.prototype.updateState = function( annotations ) {
38 - // ...
 37+es.FormatDropdownTool.prototype.updateState = function( annotations, nodes ) {
 38+ var format = {
 39+ 'type': nodes[0].getElementType(),
 40+ 'attributes': nodes[0].element.attributes
 41+ };
 42+
 43+ for( var i = 1; i < nodes.length; i++ ) {
 44+ if ( nodes[i].getElementType() != format.type
 45+ || !es.compareObjects( nodes[0].element.attributes, format.attributes ) ) {
 46+ format = null;
 47+ break;
 48+ }
 49+ }
 50+
 51+ if ( format === null ) {
 52+ this.$select.val( null );
 53+ } else {
 54+ for ( var i = 0; i < this.formats.length; i++ ) {
 55+ if ( this.formats[i].type === format.type
 56+ && es.compareObjects( this.formats[i].attributes, format.attributes ) ) {
 57+ this.$select.val( i );
 58+ break;
 59+ }
 60+ }
 61+ }
3962 };
4063
4164 es.Tool.tools.format = {

Status & tagging log