/** * VisualEditor IndentationAction class. * * @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ /** * Indentation action. * * @class * @constructor * @extends {ve.Action} * @param {ve.Surface} surface Surface to act on */ ve.IndentationAction = function VeIndentationAction( surface ) { // Parent constructor ve.Action.call( this, surface ); }; /* Inheritance */ ve.inheritClass( ve.IndentationAction, ve.Action ); /* Static Members */ /** * List of allowed methods for this action. * * @static * @member */ ve.IndentationAction.static.methods = ['increase', 'decrease']; /* Methods */ /** * Increases indentation level. * * TODO: Refactor functionality into {ve.dm.SurfaceFragment}. * * @method */ ve.IndentationAction.prototype.increase = function () { var i, group, surfaceModel = this.surface.getModel(), documentModel = surfaceModel.getDocument(), selection = surfaceModel.getSelection(), groups = documentModel.getCoveredSiblingGroups( selection ); for ( i = 0; i < groups.length; i++ ) { group = groups[i]; if ( group.grandparent && group.grandparent.getType() === 'list' ) { // FIXME this doesn't work when trying to work with multiple list items this.indentListItem( group.parent ); } } }; /** * Decreses indentation level. * * TODO: Refactor functionality into {ve.dm.SurfaceFragment}. * * @method */ ve.IndentationAction.prototype.decrease = function () { var i, group, surfaceModel = this.surface.getModel(), documentModel = surfaceModel.getDocument(), selection = surfaceModel.getSelection(), groups = documentModel.getCoveredSiblingGroups( selection ); for ( i = 0; i < groups.length; i++ ) { group = groups[i]; if ( group.grandparent && group.grandparent.getType() === 'list' ) { // FIXME this doesn't work when trying to work with multiple list items this.outdentListItem( group.parent ); } } }; /** * TODO: Refactor functionality into {ve.dm.SurfaceFragment}. */ ve.IndentationAction.prototype.indentListItem = function ( listItem ) { /* * Indenting a list item is done as follows: * 1. Wrap the listItem in a list and a listItem (
  • -->