2011-12-02 06:43:26 +00:00
|
|
|
es.ListButtonTool = function( toolbar, name, data ) {
|
|
|
|
es.ButtonTool.call( this, toolbar, name );
|
|
|
|
this.data = data;
|
2011-12-03 00:53:37 +00:00
|
|
|
this.nodes = [];
|
2011-12-02 06:43:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
es.ListButtonTool.prototype.onClick = function() {
|
2011-12-03 00:53:37 +00:00
|
|
|
/*
|
|
|
|
var parent;
|
|
|
|
for( var i = 0; i < this.nodes.length; i++ ) {
|
|
|
|
parent = this.nodes[i].getParent();
|
|
|
|
if ( parent.getElementType() !== 'listItem' ) {
|
|
|
|
console.log( this.nodes[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2011-12-02 06:43:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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-03 00:53:37 +00:00
|
|
|
var parent, styles;
|
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-03 00:53:37 +00:00
|
|
|
this.nodes = nodes;
|
|
|
|
if ( check( this.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 );
|