Initiali implementation of number and bullet buttons for lists.

This commit is contained in:
Inez Korczynski 2011-12-02 06:43:26 +00:00
parent 31585463ed
commit a9a53a00a8
5 changed files with 52 additions and 1 deletions

View file

@ -106,6 +106,7 @@ $wgResourceModules += array(
'es/tools/es.AnnotationButtonTool.js',
'es/tools/es.ClearButtonTool.js',
'es/tools/es.HistoryButtonTool.js',
'es/tools/es.ListButtonTool.js',
'es/tools/es.DropdownTool.js',
'es/tools/es.FormatDropdownTool.js'

View file

@ -139,6 +139,7 @@
<script src="../modules/es/tools/es.AnnotationButtonTool.js"></script>
<script src="../modules/es/tools/es.ClearButtonTool.js"></script>
<script src="../modules/es/tools/es.HistoryButtonTool.js"></script>
<script src="../modules/es/tools/es.ListButtonTool.js"></script>
<script src="../modules/es/tools/es.DropdownTool.js"></script>
<script src="../modules/es/tools/es.FormatDropdownTool.js"></script>

View file

@ -73,10 +73,17 @@
.es-toolbarButtonTool-clear:before {
background-image: url(../images/clear.png);
}
.es-toolbarButtonTool-number:before {
background-image: url(../images/number.png);
}
.es-toolbarButtonTool-bullet:before {
background-image: url(../images/bullet.png);
}
.es-toolbarButtonTool-disabled.es-toolbarButtonTool-clear:before {
-moz-opacity: 0.25;
filter:alpha(opacity=25);
opacity: 0.25;
}
.es-toolbarButtonTool-clear:before {
background-image: url(../images/clear.png);
}

View file

@ -0,0 +1,41 @@
es.ListButtonTool = function( toolbar, name, data ) {
es.ButtonTool.call( this, toolbar, name );
this.data = data;
};
es.ListButtonTool.prototype.onClick = function() {
};
es.ListButtonTool.prototype.updateState = function( annotations, nodes ) {
function areSameTypeAndStyle( nodes, style ) {
for( var i = 0; i < nodes.length; i++ ) {
parent = nodes[i].getParent();
if ( parent.getElementType() !== 'listItem' ) {
return false;
}
styles = parent.getElementAttribute( 'styles' );
if ( styles[ styles.length - 1] !== style ) {
return false;
}
}
return true;
}
if ( areSameTypeAndStyle( nodes, this.name ) ) {
this.$.addClass( 'es-toolbarButtonTool-down' );
} else {
this.$.removeClass( 'es-toolbarButtonTool-down' );
}
};
es.Tool.tools.number = {
constructor: es.ListButtonTool,
name: 'number'
};
es.Tool.tools.bullet = {
constructor: es.ListButtonTool,
name: 'bullet'
};
es.extendClass( es.ListButtonTool, es.ButtonTool );

View file

@ -49,7 +49,8 @@ es.ToolbarView = function( $container, surfaceView, config ) {
this.config = config || [
{ 'name': 'textStyle', 'items' : [ 'bold', 'italic', 'link', 'clear', 'format' ] },
{ 'name': 'history', 'items' : [ 'undo', 'redo' ] }
{ 'name': 'history', 'items' : [ 'undo', 'redo' ] },
{ 'name': 'list', 'items' : [ 'number', 'bullet' ] }
];
this.setup();
};