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 | + */ |
2 | 11 | es.ClearButtonTool = function( toolbar, name ) { |
| 12 | + // Inheritance |
3 | 13 | es.ButtonTool.call( this, toolbar, name ); |
| 14 | + |
| 15 | + // Properties |
4 | 16 | this.$.addClass( 'es-toolbarButtonTool-disabled' ); |
5 | 17 | this.pattern = /(textStyle\/|link\/).*/; |
6 | 18 | }; |
7 | 19 | |
| 20 | +/* Methods */ |
| 21 | + |
8 | 22 | es.ClearButtonTool.prototype.onClick = function() { |
9 | 23 | var tx = this.toolbar.surfaceView.model.getDocument().prepareContentAnnotation( |
10 | 24 | this.toolbar.surfaceView.currentSelection, |
— | — | @@ -25,9 +39,13 @@ |
26 | 40 | } |
27 | 41 | }; |
28 | 42 | |
| 43 | +/* Registration */ |
| 44 | + |
29 | 45 | es.Tool.tools.clear = { |
30 | 46 | constructor: es.ClearButtonTool, |
31 | 47 | name: 'clear' |
32 | 48 | }; |
33 | 49 | |
| 50 | +/* Inheritance */ |
| 51 | + |
34 | 52 | 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 | + */ |
2 | 12 | es.FormatDropdownTool = function( toolbar, name ) { |
3 | 13 | // Inheritance |
4 | 14 | es.DropdownTool.call( this, toolbar, name, [ |
— | — | @@ -49,6 +59,7 @@ |
50 | 60 | } |
51 | 61 | ] ); |
52 | 62 | |
| 63 | + // Events |
53 | 64 | var _this = this; |
54 | 65 | this.$.bind( { |
55 | 66 | '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 |
3 | 14 | es.ButtonTool.call( this, toolbar, name ); |
4 | | - this.data = data; |
| 15 | + |
| 16 | + // Properties |
| 17 | + this.annotation = annotation; |
5 | 18 | }; |
6 | 19 | |
| 20 | +/* Methods */ |
| 21 | + |
7 | 22 | es.AnnotationButtonTool.prototype.onClick = function() { |
8 | 23 | var method; |
9 | 24 | if ( this.$.hasClass( 'es-toolbarButtonTool-down' ) ) { |
10 | 25 | method = 'clear'; |
11 | | - this.toolbar.surfaceView.removeInsertionAnnotation( this.data ); |
| 26 | + this.toolbar.surfaceView.removeInsertionAnnotation( this.annotation ); |
12 | 27 | } else { |
13 | 28 | method = 'set'; |
14 | | - this.toolbar.surfaceView.addInsertionAnnotation( this.data ); |
| 29 | + this.toolbar.surfaceView.addInsertionAnnotation( this.annotation ); |
15 | 30 | } |
16 | 31 | |
17 | 32 | var tx = this.toolbar.surfaceView.model.getDocument().prepareContentAnnotation( |
18 | 33 | this.toolbar.surfaceView.currentSelection, |
19 | 34 | method, |
20 | | - this.data |
| 35 | + this.annotation |
21 | 36 | ); |
22 | 37 | this.toolbar.surfaceView.model.transact( tx ); |
23 | 38 | }; |
24 | 39 | |
25 | 40 | es.AnnotationButtonTool.prototype.updateState = function( annotations ) { |
26 | 41 | 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 ) { |
28 | 43 | this.$.addClass( 'es-toolbarButtonTool-down' ); |
29 | 44 | return; |
30 | 45 | } |
— | — | @@ -31,23 +46,26 @@ |
32 | 47 | this.$.removeClass( 'es-toolbarButtonTool-down' ); |
33 | 48 | }; |
34 | 49 | |
| 50 | +/* Registration */ |
| 51 | + |
35 | 52 | es.Tool.tools.bold = { |
36 | 53 | constructor: es.AnnotationButtonTool, |
37 | 54 | name: 'bold', |
38 | | - data: { 'type': 'textStyle/bold' } |
| 55 | + annotation: { 'type': 'textStyle/bold' } |
39 | 56 | }; |
40 | 57 | |
41 | 58 | es.Tool.tools.italic = { |
42 | 59 | constructor: es.AnnotationButtonTool, |
43 | 60 | name: 'italic', |
44 | | - data: { 'type': 'textStyle/italic' } |
| 61 | + annotation: { 'type': 'textStyle/italic' } |
45 | 62 | }; |
46 | 63 | |
47 | 64 | es.Tool.tools.link = { |
48 | 65 | constructor: es.AnnotationButtonTool, |
49 | 66 | name: 'link', |
50 | | - data: { 'type': 'link/internal', 'data': { 'title': '' } } |
| 67 | + annotation: { 'type': 'link/internal', 'data': { 'title': '' } } |
51 | 68 | }; |
52 | 69 | |
| 70 | +/* Inheritance */ |
53 | 71 | |
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 |
3 | 13 | es.ButtonTool.call( this, toolbar, name ); |
| 14 | + |
| 15 | + // Properties |
4 | 16 | this.data = data; |
5 | 17 | this.nodes = []; |
6 | 18 | }; |
7 | 19 | |
| 20 | +/* Methods */ |
| 21 | + |
8 | 22 | es.ListButtonTool.prototype.onClick = function() { |
9 | 23 | /* |
10 | 24 | var parent; |
— | — | @@ -41,6 +55,8 @@ |
42 | 56 | } |
43 | 57 | }; |
44 | 58 | |
| 59 | +/* Registration */ |
| 60 | + |
45 | 61 | es.Tool.tools.number = { |
46 | 62 | constructor: es.ListButtonTool, |
47 | 63 | name: 'number' |
— | — | @@ -51,4 +67,6 @@ |
52 | 68 | name: 'bullet' |
53 | 69 | }; |
54 | 70 | |
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 ) { |
3 | 12 | es.ButtonTool.call( this, toolbar, name ); |
4 | 13 | this.data = data; |
5 | 14 | }; |
6 | 15 | |
| 16 | +/* Methods */ |
| 17 | + |
7 | 18 | es.IndentationButtonTool.prototype.onClick = function() { |
| 19 | + // |
8 | 20 | }; |
9 | 21 | |
10 | 22 | es.IndentationButtonTool.prototype.updateState = function( annotations, nodes ) { |
— | — | @@ -25,6 +37,8 @@ |
26 | 38 | } |
27 | 39 | }; |
28 | 40 | |
| 41 | +/* Registration */ |
| 42 | + |
29 | 43 | es.Tool.tools.indent = { |
30 | 44 | constructor: es.IndentationButtonTool, |
31 | 45 | name: 'indent' |
— | — | @@ -35,4 +49,6 @@ |
36 | 50 | name: 'outdent' |
37 | 51 | }; |
38 | 52 | |
| 53 | +/* Inheritance */ |
| 54 | + |
39 | 55 | 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 | + */ |
2 | 10 | es.ButtonTool = function( toolbar, name ) { |
| 11 | + // Inheritance |
3 | 12 | es.Tool.call( this, toolbar, name ); |
4 | | - |
5 | | - // for es.extendClass |
6 | 13 | if ( !name ) { |
7 | 14 | return; |
8 | 15 | } |
9 | 16 | |
| 17 | + // Properties |
10 | 18 | this.$.addClass( 'es-toolbarButtonTool' ).addClass( 'es-toolbarButtonTool-' + name ); |
11 | 19 | |
| 20 | + // Events |
12 | 21 | var _this = this; |
13 | | - |
14 | 22 | this.$.bind( { |
15 | 23 | 'mousedown': function( e ) { |
16 | 24 | if ( e.button === 0 ) { |
— | — | @@ -23,11 +31,14 @@ |
24 | 32 | } |
25 | 33 | } |
26 | 34 | } ); |
27 | | - |
28 | 35 | }; |
29 | 36 | |
| 37 | +/* Methods */ |
| 38 | + |
30 | 39 | es.ButtonTool.prototype.onClick = function() { |
31 | 40 | throw 'ButtonTool.onClick not implemented in this subclass:' + this.constructor; |
32 | 41 | }; |
33 | 42 | |
| 43 | +/* Inheritance */ |
| 44 | + |
34 | 45 | 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 | + */ |
2 | 11 | es.DropdownTool = function( toolbar, name, items ) { |
3 | 12 | // Inheritance |
4 | 13 | es.Tool.call( this, toolbar, name ); |
5 | | - |
6 | | - // Early exit when extending via es.extendClass |
7 | 14 | if ( !name ) { |
8 | 15 | return; |
9 | 16 | } |
10 | | - |
| 17 | + |
11 | 18 | // Properties |
12 | 19 | var _this = this; |
13 | 20 | this.menuView = new es.MenuView( items, function( item ) { |
— | — | @@ -14,11 +21,14 @@ |
15 | 22 | _this.$.text( item.label ); |
16 | 23 | } ); |
17 | 24 | |
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 | + } ); |
23 | 33 | |
24 | 34 | // DOM Changes |
25 | 35 | 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 | + */ |
2 | 11 | es.HistoryButtonTool = function( toolbar, name, data ) { |
| 12 | + // Inheritance |
3 | 13 | es.ButtonTool.call( this, toolbar, name ); |
| 14 | + |
| 15 | + // Properties |
4 | 16 | this.data = data; |
5 | 17 | }; |
6 | 18 | |
| 19 | +/* Methods */ |
| 20 | + |
7 | 21 | es.HistoryButtonTool.prototype.onClick = function() { |
8 | 22 | switch ( this.name ) { |
9 | 23 | case 'undo': |
— | — | @@ -15,8 +29,11 @@ |
16 | 30 | }; |
17 | 31 | |
18 | 32 | es.HistoryButtonTool.prototype.updateState = function( annotations ) { |
| 33 | + // |
19 | 34 | }; |
20 | 35 | |
| 36 | +/* Registration */ |
| 37 | + |
21 | 38 | es.Tool.tools.undo = { |
22 | 39 | constructor: es.HistoryButtonTool, |
23 | 40 | name: 'undo' |
— | — | @@ -27,5 +44,6 @@ |
28 | 45 | name: 'redo' |
29 | 46 | }; |
30 | 47 | |
| 48 | +/* Inhertiance */ |
31 | 49 | |
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 | + */ |
2 | 10 | es.Tool = function( toolbar, name ) { |
3 | 11 | this.toolbar = toolbar; |
4 | 12 | this.name = name; |
5 | | - this.$ = $( '<div>' ).attr( 'title', this.name ); |
| 13 | + this.$ = $( '<div class="es-tool"></div>' ).attr( 'title', this.name ); |
6 | 14 | }; |
7 | 15 | |
| 16 | +/* Static Members */ |
| 17 | + |
| 18 | +es.Tool.tools = {}; |
| 19 | + |
| 20 | +/* Methods */ |
| 21 | + |
8 | 22 | es.Tool.prototype.updateState = function() { |
9 | 23 | throw 'Tool.updateState not implemented in this subclass:' + this.constructor; |
10 | 24 | }; |
11 | | - |
12 | | -es.Tool.tools = {}; |