mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-26 07:15:32 +00:00
42 lines
1 KiB
JavaScript
42 lines
1 KiB
JavaScript
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 ) {
|
|
// 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;
|
|
}
|
|
|
|
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 ); |