/** * VisualEditor user interface IndentationButtonTool class. * * @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ /** * Creates an ve.ui.IndentationButtonTool object. * * @class * @constructor * @extends {ve.ui.ButtonTool} * @param {ve.ui.Toolbar} toolbar * @param {String} name */ ve.ui.IndentationButtonTool = function ( toolbar, name, title, data ) { ve.ui.ButtonTool.call( this, toolbar, name, title ); this.data = data; }; /* Methods */ ve.ui.IndentationButtonTool.prototype.onClick = function () { if ( !this.$.hasClass( 'es-toolbarButtonTool-disabled' ) ) { var listItems = [], listItem, i; // FIXME old code, doesn't work for ( i = 0; i < this.nodes.length; i++ ) { listItem = this.nodes[i].getParent(); if ( listItems.length > 0 ) { if (listItem !== listItems[listItems.length - 1]) { listItems.push( listItem ); } } else { listItems.push( listItem ); } } if ( this.name === 'indent' ) { this.indent( listItems ); } else if ( this.name === 'outdent' ) { this.outdent( listItems ); } } }; ve.ui.IndentationButtonTool.prototype.indent = function ( listItems ) { ve.ui.IndentationButtonTool.indentListItem( this.toolbar.getSurfaceView().getModel() ); }; ve.ui.IndentationButtonTool.prototype.outdent = function ( listItems ) { ve.ui.IndentationButtonTool.outdentListItem( this.toolbar.getSurfaceView().getModel() ); }; ve.ui.IndentationButtonTool.indentListItem = function ( surfaceModel ) { var i, group, documentModel = surfaceModel.getDocument(), selection = surfaceModel.getSelection(), groups = documentModel.getCoveredSiblingGroups( selection ); function indentListItem( listItem ) { /* * Indenting a list item is done as follows: * 1. Wrap the listItem in a list and a listItem (
  • -->