mediawiki-extensions-Visual.../modules/es/tools/es.ListButtonTool.js

42 lines
1 KiB
JavaScript
Raw Normal View History

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 ) {
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 ) ) {
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 );