2011-12-02 06:43:26 +00:00
|
|
|
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 ) {
|
2011-12-02 20:41:43 +00:00
|
|
|
// checks if all passed nodes are listItems of passed style
|
|
|
|
function check( nodes, style ) {
|
2011-12-02 06:43:26 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-12-02 20:41:43 +00:00
|
|
|
if ( check( nodes, this.name ) ) {
|
2011-12-02 06:43:26 +00:00
|
|
|
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 );
|