r105226 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105225‎ | r105226 | r105227 >
Date:21:10, 5 December 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added comments to code
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/bases/es.Tool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.AnnotationButtonTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.ButtonTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.ClearButtonTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.DropdownTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.HistoryButtonTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.IndentationButtonTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.ListButtonTool.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/tools/es.ClearButtonTool.js
@@ -1,9 +1,23 @@
 2+/**
 3+ * Creates an es.ClearButtonTool object.
 4+ *
 5+ * @class
 6+ * @constructor
 7+ * @extends {es.ButtonTool}
 8+ * @param {es.ToolbarView} toolbar
 9+ * @param {String} name
 10+ */
211 es.ClearButtonTool = function( toolbar, name ) {
 12+ // Inheritance
313 es.ButtonTool.call( this, toolbar, name );
 14+
 15+ // Properties
416 this.$.addClass( 'es-toolbarButtonTool-disabled' );
517 this.pattern = /(textStyle\/|link\/).*/;
618 };
719
 20+/* Methods */
 21+
822 es.ClearButtonTool.prototype.onClick = function() {
923 var tx = this.toolbar.surfaceView.model.getDocument().prepareContentAnnotation(
1024 this.toolbar.surfaceView.currentSelection,
@@ -25,9 +39,13 @@
2640 }
2741 };
2842
 43+/* Registration */
 44+
2945 es.Tool.tools.clear = {
3046 constructor: es.ClearButtonTool,
3147 name: 'clear'
3248 };
3349
 50+/* Inheritance */
 51+
3452 es.extendClass( es.ClearButtonTool, es.ButtonTool );
\ No newline at end of file
Index: trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js
@@ -1,3 +1,13 @@
 2+/**
 3+ * Creates an es.FormatDropdownTool object.
 4+ *
 5+ * @class
 6+ * @constructor
 7+ * @extends {es.DropdownTool}
 8+ * @param {es.ToolbarView} toolbar
 9+ * @param {String} name
 10+ * @param {Object[]} items
 11+ */
212 es.FormatDropdownTool = function( toolbar, name ) {
313 // Inheritance
414 es.DropdownTool.call( this, toolbar, name, [
@@ -49,6 +59,7 @@
5060 }
5161 ] );
5262
 63+ // Events
5364 var _this = this;
5465 this.$.bind( {
5566 'mousedown': function( e ) {
Index: trunk/extensions/VisualEditor/modules/es/tools/es.AnnotationButtonTool.js
@@ -1,29 +1,44 @@
2 -es.AnnotationButtonTool = function( toolbar, name, data ) {
 2+/**
 3+ * Creates an es.AnnotationButtonTool object.
 4+ *
 5+ * @class
 6+ * @constructor
 7+ * @extends {es.ButtonTool}
 8+ * @param {es.ToolbarView} toolbar
 9+ * @param {String} name
 10+ * @param {Object} annotation
 11+ */
 12+es.AnnotationButtonTool = function( toolbar, name, annotation ) {
 13+ // Inheritance
314 es.ButtonTool.call( this, toolbar, name );
4 - this.data = data;
 15+
 16+ // Properties
 17+ this.annotation = annotation;
518 };
619
 20+/* Methods */
 21+
722 es.AnnotationButtonTool.prototype.onClick = function() {
823 var method;
924 if ( this.$.hasClass( 'es-toolbarButtonTool-down' ) ) {
1025 method = 'clear';
11 - this.toolbar.surfaceView.removeInsertionAnnotation( this.data );
 26+ this.toolbar.surfaceView.removeInsertionAnnotation( this.annotation );
1227 } else {
1328 method = 'set';
14 - this.toolbar.surfaceView.addInsertionAnnotation( this.data );
 29+ this.toolbar.surfaceView.addInsertionAnnotation( this.annotation );
1530 }
1631
1732 var tx = this.toolbar.surfaceView.model.getDocument().prepareContentAnnotation(
1833 this.toolbar.surfaceView.currentSelection,
1934 method,
20 - this.data
 35+ this.annotation
2136 );
2237 this.toolbar.surfaceView.model.transact( tx );
2338 };
2439
2540 es.AnnotationButtonTool.prototype.updateState = function( annotations ) {
2641 for ( var i = 0; i < annotations.full.length; i++ ) {
27 - if ( annotations.full[i].type === this.data.type ) {
 42+ if ( annotations.full[i].type === this.annotation.type ) {
2843 this.$.addClass( 'es-toolbarButtonTool-down' );
2944 return;
3045 }
@@ -31,23 +46,26 @@
3247 this.$.removeClass( 'es-toolbarButtonTool-down' );
3348 };
3449
 50+/* Registration */
 51+
3552 es.Tool.tools.bold = {
3653 constructor: es.AnnotationButtonTool,
3754 name: 'bold',
38 - data: { 'type': 'textStyle/bold' }
 55+ annotation: { 'type': 'textStyle/bold' }
3956 };
4057
4158 es.Tool.tools.italic = {
4259 constructor: es.AnnotationButtonTool,
4360 name: 'italic',
44 - data: { 'type': 'textStyle/italic' }
 61+ annotation: { 'type': 'textStyle/italic' }
4562 };
4663
4764 es.Tool.tools.link = {
4865 constructor: es.AnnotationButtonTool,
4966 name: 'link',
50 - data: { 'type': 'link/internal', 'data': { 'title': '' } }
 67+ annotation: { 'type': 'link/internal', 'data': { 'title': '' } }
5168 };
5269
 70+/* Inheritance */
5371
54 -es.extendClass( es.AnnotationButtonTool, es.ButtonTool );
\ No newline at end of file
 72+es.extendClass( es.AnnotationButtonTool, es.ButtonTool );
Index: trunk/extensions/VisualEditor/modules/es/tools/es.ListButtonTool.js
@@ -1,9 +1,23 @@
2 -es.ListButtonTool = function( toolbar, name, data ) {
 2+/**
 3+ * Creates an es.ListButtonTool object.
 4+ *
 5+ * @class
 6+ * @constructor
 7+ * @extends {es.ButtonTool}
 8+ * @param {es.ToolbarView} toolbar
 9+ * @param {String} name
 10+ */
 11+ es.ListButtonTool = function( toolbar, name, data ) {
 12+ // Inheritance
313 es.ButtonTool.call( this, toolbar, name );
 14+
 15+ // Properties
416 this.data = data;
517 this.nodes = [];
618 };
719
 20+/* Methods */
 21+
822 es.ListButtonTool.prototype.onClick = function() {
923 /*
1024 var parent;
@@ -41,6 +55,8 @@
4256 }
4357 };
4458
 59+/* Registration */
 60+
4561 es.Tool.tools.number = {
4662 constructor: es.ListButtonTool,
4763 name: 'number'
@@ -51,4 +67,6 @@
5268 name: 'bullet'
5369 };
5470
55 -es.extendClass( es.ListButtonTool, es.ButtonTool );
\ No newline at end of file
 71+/* Inheritance */
 72+
 73+es.extendClass( es.ListButtonTool, es.ButtonTool );
Index: trunk/extensions/VisualEditor/modules/es/tools/es.IndentationButtonTool.js
@@ -1,9 +1,21 @@
2 -es.IndentationButtonTool = function( toolbar, name, data ) {
 2+/**
 3+ * Creates an es.IndentationButtonTool object.
 4+ *
 5+ * @class
 6+ * @constructor
 7+ * @extends {es.ButtonTool}
 8+ * @param {es.ToolbarView} toolbar
 9+ * @param {String} name
 10+ */
 11+ es.IndentationButtonTool = function( toolbar, name, data ) {
312 es.ButtonTool.call( this, toolbar, name );
413 this.data = data;
514 };
615
 16+/* Methods */
 17+
718 es.IndentationButtonTool.prototype.onClick = function() {
 19+ //
820 };
921
1022 es.IndentationButtonTool.prototype.updateState = function( annotations, nodes ) {
@@ -25,6 +37,8 @@
2638 }
2739 };
2840
 41+/* Registration */
 42+
2943 es.Tool.tools.indent = {
3044 constructor: es.IndentationButtonTool,
3145 name: 'indent'
@@ -35,4 +49,6 @@
3650 name: 'outdent'
3751 };
3852
 53+/* Inheritance */
 54+
3955 es.extendClass( es.IndentationButtonTool, es.ButtonTool );
\ No newline at end of file
Index: trunk/extensions/VisualEditor/modules/es/tools/es.ButtonTool.js
@@ -1,15 +1,23 @@
 2+/**
 3+ * Creates an es.ButtonTool object.
 4+ *
 5+ * @class
 6+ * @constructor
 7+ * @param {es.ToolbarView} toolbar
 8+ * @param {String} name
 9+ */
210 es.ButtonTool = function( toolbar, name ) {
 11+ // Inheritance
312 es.Tool.call( this, toolbar, name );
4 -
5 - // for es.extendClass
613 if ( !name ) {
714 return;
815 }
916
 17+ // Properties
1018 this.$.addClass( 'es-toolbarButtonTool' ).addClass( 'es-toolbarButtonTool-' + name );
1119
 20+ // Events
1221 var _this = this;
13 -
1422 this.$.bind( {
1523 'mousedown': function( e ) {
1624 if ( e.button === 0 ) {
@@ -23,11 +31,14 @@
2432 }
2533 }
2634 } );
27 -
2835 };
2936
 37+/* Methods */
 38+
3039 es.ButtonTool.prototype.onClick = function() {
3140 throw 'ButtonTool.onClick not implemented in this subclass:' + this.constructor;
3241 };
3342
 43+/* Inheritance */
 44+
3445 es.extendClass( es.ButtonTool, es.Tool );
\ No newline at end of file
Index: trunk/extensions/VisualEditor/modules/es/tools/es.DropdownTool.js
@@ -1,12 +1,19 @@
 2+/**
 3+ * Creates an es.DropdownTool object.
 4+ *
 5+ * @class
 6+ * @constructor
 7+ * @param {es.ToolbarView} toolbar
 8+ * @param {String} name
 9+ * @param {Object[]} items
 10+ */
211 es.DropdownTool = function( toolbar, name, items ) {
312 // Inheritance
413 es.Tool.call( this, toolbar, name );
5 -
6 - // Early exit when extending via es.extendClass
714 if ( !name ) {
815 return;
916 }
10 -
 17+
1118 // Properties
1219 var _this = this;
1320 this.menuView = new es.MenuView( items, function( item ) {
@@ -14,11 +21,14 @@
1522 _this.$.text( item.label );
1623 } );
1724
18 - $( document ).add( this.toolbar.surfaceView.$ ).mousedown( function( e ) {
19 - if ( e.button === 0 ) {
20 - _this.menuView.hide();
21 - }
22 - } );
 25+ // Events
 26+ $( document )
 27+ .add( this.toolbar.surfaceView.$ )
 28+ .mousedown( function( e ) {
 29+ if ( e.button === 0 ) {
 30+ _this.menuView.hide();
 31+ }
 32+ } );
2333
2434 // DOM Changes
2535 this.$.addClass( 'es-toolbarDropdownTool' ).addClass( 'es-toolbarDropdownTool-' + name );
Index: trunk/extensions/VisualEditor/modules/es/tools/es.HistoryButtonTool.js
@@ -1,8 +1,22 @@
 2+/**
 3+ * Creates an es.HistoryButtonTool object.
 4+ *
 5+ * @class
 6+ * @constructor
 7+ * @extends {es.ButtonTool}
 8+ * @param {es.ToolbarView} toolbar
 9+ * @param {String} name
 10+ */
211 es.HistoryButtonTool = function( toolbar, name, data ) {
 12+ // Inheritance
313 es.ButtonTool.call( this, toolbar, name );
 14+
 15+ // Properties
416 this.data = data;
517 };
618
 19+/* Methods */
 20+
721 es.HistoryButtonTool.prototype.onClick = function() {
822 switch ( this.name ) {
923 case 'undo':
@@ -15,8 +29,11 @@
1630 };
1731
1832 es.HistoryButtonTool.prototype.updateState = function( annotations ) {
 33+ //
1934 };
2035
 36+/* Registration */
 37+
2138 es.Tool.tools.undo = {
2239 constructor: es.HistoryButtonTool,
2340 name: 'undo'
@@ -27,5 +44,6 @@
2845 name: 'redo'
2946 };
3047
 48+/* Inhertiance */
3149
32 -es.extendClass( es.HistoryButtonTool, es.ButtonTool );
\ No newline at end of file
 50+es.extendClass( es.HistoryButtonTool, es.ButtonTool );
Index: trunk/extensions/VisualEditor/modules/es/bases/es.Tool.js
@@ -1,11 +1,23 @@
 2+/**
 3+ * Creates an es.Tool object.
 4+ *
 5+ * @class
 6+ * @constructor
 7+ * @param {es.ToolbarView} toolbar
 8+ * @param {String} name
 9+ */
210 es.Tool = function( toolbar, name ) {
311 this.toolbar = toolbar;
412 this.name = name;
5 - this.$ = $( '<div>' ).attr( 'title', this.name );
 13+ this.$ = $( '<div class="es-tool"></div>' ).attr( 'title', this.name );
614 };
715
 16+/* Static Members */
 17+
 18+es.Tool.tools = {};
 19+
 20+/* Methods */
 21+
822 es.Tool.prototype.updateState = function() {
923 throw 'Tool.updateState not implemented in this subclass:' + this.constructor;
1024 };
11 -
12 -es.Tool.tools = {};

Status & tagging log