Index: trunk/extensions/VisualEditor/VisualEditor.php |
— | — | @@ -106,6 +106,7 @@ |
107 | 107 | 'es/tools/es.AnnotationButtonTool.js', |
108 | 108 | 'es/tools/es.ClearButtonTool.js', |
109 | 109 | 'es/tools/es.HistoryButtonTool.js', |
| 110 | + 'es/tools/es.ListButtonTool.js', |
110 | 111 | 'es/tools/es.DropdownTool.js', |
111 | 112 | 'es/tools/es.FormatDropdownTool.js' |
112 | 113 | |
Index: trunk/extensions/VisualEditor/demo/index.html |
— | — | @@ -139,6 +139,7 @@ |
140 | 140 | <script src="../modules/es/tools/es.AnnotationButtonTool.js"></script> |
141 | 141 | <script src="../modules/es/tools/es.ClearButtonTool.js"></script> |
142 | 142 | <script src="../modules/es/tools/es.HistoryButtonTool.js"></script> |
| 143 | + <script src="../modules/es/tools/es.ListButtonTool.js"></script> |
143 | 144 | <script src="../modules/es/tools/es.DropdownTool.js"></script> |
144 | 145 | <script src="../modules/es/tools/es.FormatDropdownTool.js"></script> |
145 | 146 | |
Index: trunk/extensions/VisualEditor/modules/es/tools/es.ListButtonTool.js |
— | — | @@ -0,0 +1,41 @@ |
| 2 | +es.ListButtonTool = function( toolbar, name, data ) {
|
| 3 | + es.ButtonTool.call( this, toolbar, name );
|
| 4 | + this.data = data;
|
| 5 | +};
|
| 6 | +
|
| 7 | +es.ListButtonTool.prototype.onClick = function() {
|
| 8 | +};
|
| 9 | +
|
| 10 | +es.ListButtonTool.prototype.updateState = function( annotations, nodes ) {
|
| 11 | + function areSameTypeAndStyle( nodes, style ) {
|
| 12 | + for( var i = 0; i < nodes.length; i++ ) {
|
| 13 | + parent = nodes[i].getParent();
|
| 14 | + if ( parent.getElementType() !== 'listItem' ) {
|
| 15 | + return false;
|
| 16 | + }
|
| 17 | + styles = parent.getElementAttribute( 'styles' );
|
| 18 | + if ( styles[ styles.length - 1] !== style ) {
|
| 19 | + return false;
|
| 20 | + }
|
| 21 | + }
|
| 22 | + return true;
|
| 23 | + }
|
| 24 | +
|
| 25 | + if ( areSameTypeAndStyle( nodes, this.name ) ) {
|
| 26 | + this.$.addClass( 'es-toolbarButtonTool-down' );
|
| 27 | + } else {
|
| 28 | + this.$.removeClass( 'es-toolbarButtonTool-down' );
|
| 29 | + }
|
| 30 | +};
|
| 31 | +
|
| 32 | +es.Tool.tools.number = {
|
| 33 | + constructor: es.ListButtonTool,
|
| 34 | + name: 'number'
|
| 35 | +};
|
| 36 | +
|
| 37 | +es.Tool.tools.bullet = {
|
| 38 | + constructor: es.ListButtonTool,
|
| 39 | + name: 'bullet'
|
| 40 | +};
|
| 41 | +
|
| 42 | +es.extendClass( es.ListButtonTool, es.ButtonTool ); |
\ No newline at end of file |
Index: trunk/extensions/VisualEditor/modules/es/styles/es.ToolbarView.css |
— | — | @@ -73,10 +73,17 @@ |
74 | 74 | .es-toolbarButtonTool-clear:before { |
75 | 75 | background-image: url(../images/clear.png); |
76 | 76 | } |
| 77 | +.es-toolbarButtonTool-number:before { |
| 78 | + background-image: url(../images/number.png); |
| 79 | +} |
| 80 | +.es-toolbarButtonTool-bullet:before { |
| 81 | + background-image: url(../images/bullet.png); |
| 82 | +} |
77 | 83 | .es-toolbarButtonTool-disabled.es-toolbarButtonTool-clear:before { |
78 | 84 | -moz-opacity: 0.25; |
79 | 85 | filter:alpha(opacity=25); |
80 | 86 | opacity: 0.25; |
| 87 | +} |
81 | 88 | .es-toolbarButtonTool-clear:before { |
82 | 89 | background-image: url(../images/clear.png); |
83 | 90 | } |
Index: trunk/extensions/VisualEditor/modules/es/views/es.ToolbarView.js |
— | — | @@ -49,7 +49,8 @@ |
50 | 50 | |
51 | 51 | this.config = config || [ |
52 | 52 | { 'name': 'textStyle', 'items' : [ 'bold', 'italic', 'link', 'clear', 'format' ] }, |
53 | | - { 'name': 'history', 'items' : [ 'undo', 'redo' ] } |
| 53 | + { 'name': 'history', 'items' : [ 'undo', 'redo' ] }, |
| 54 | + { 'name': 'list', 'items' : [ 'number', 'bullet' ] } |
54 | 55 | ]; |
55 | 56 | this.setup(); |
56 | 57 | }; |