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

54 lines
1.2 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() {
if ( !this.$.hasClass( 'es-toolbarButtonTool-disabled' ) ) {
alert( 'This functionality is not yet supported.' );
}
2011-12-04 02:59:53 +00:00
};
es.IndentationButtonTool.prototype.updateState = function( annotations, nodes ) {
function areListItems( nodes ) {
2011-12-04 02:59:53 +00:00
for( var i = 0; i < nodes.length; i++ ) {
if ( nodes[i].getParent().getElementType() !== 'listItem' ) {
return false;
}
}
return true;
}
if ( areListItems( nodes ) ) {
2011-12-04 02:59:53 +00:00
this.$.removeClass( 'es-toolbarButtonTool-disabled' );
} else {
this.$.addClass( 'es-toolbarButtonTool-disabled' );
2011-12-04 02:59:53 +00:00
}
};
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 );