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

54 lines
1.1 KiB
JavaScript
Raw Normal View History

2011-12-05 21:10:19 +00:00
/**
* Creates an es.IndentationButtonTool object.
*
* @class
* @constructor
* @extends {es.ButtonTool}
* @param {es.ToolbarView} toolbar
* @param {String} name
*/
es.IndentationButtonTool = function( toolbar, name, data ) {
2011-12-04 02:59:53 +00:00
es.ButtonTool.call( this, toolbar, name );
this.data = data;
};
2011-12-05 21:10:19 +00:00
/* Methods */
2011-12-04 02:59:53 +00:00
es.IndentationButtonTool.prototype.onClick = function() {
2011-12-05 21:10:19 +00:00
//
2011-12-04 02:59:53 +00:00
};
es.IndentationButtonTool.prototype.updateState = function( annotations, nodes ) {
// checks if all passed nodes are listItems
function check( nodes, style ) {
var parent, styles;
for( var i = 0; i < nodes.length; i++ ) {
if ( nodes[i].getParent().getElementType() !== 'listItem' ) {
return false;
}
}
return true;
}
if ( check( nodes, this.name ) ) {
this.$.removeClass( 'es-toolbarButtonTool-disabled' );
} else {
this.$.addClass( 'es-toolbarButtonTool-disabled' );
}
};
2011-12-05 21:10:19 +00:00
/* Registration */
2011-12-04 02:59:53 +00:00
es.Tool.tools.indent = {
constructor: es.IndentationButtonTool,
name: 'indent'
};
es.Tool.tools.outdent = {
constructor: es.IndentationButtonTool,
name: 'outdent'
};
2011-12-05 21:10:19 +00:00
/* Inheritance */
es.extendClass( es.IndentationButtonTool, es.ButtonTool );