| 1 |
/* |
| 2 |
* FCKeditor - The text editor for Internet - http://www.fckeditor.net |
| 3 |
* Copyright (C) 2003-2009 Frederico Caldeira Knabben |
| 4 |
* |
| 5 |
* == BEGIN LICENSE == |
| 6 |
* |
| 7 |
* Licensed under the terms of any of the following licenses at your |
| 8 |
* choice: |
| 9 |
* |
| 10 |
* - GNU General Public License Version 2 or later (the "GPL") |
| 11 |
* http://www.gnu.org/licenses/gpl.html |
| 12 |
* |
| 13 |
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
| 14 |
* http://www.gnu.org/licenses/lgpl.html |
| 15 |
* |
| 16 |
* - Mozilla Public License Version 1.1 or later (the "MPL") |
| 17 |
* http://www.mozilla.org/MPL/MPL-1.1.html |
| 18 |
* |
| 19 |
* == END LICENSE == |
| 20 |
* |
| 21 |
* FCKPastePlainTextCommand Class: represents the |
| 22 |
* "Paste as Plain Text" command. |
| 23 |
*/ |
| 24 |
|
| 25 |
var FCKTableCommand = function( command ) |
| 26 |
{ |
| 27 |
this.Name = command ; |
| 28 |
} |
| 29 |
|
| 30 |
FCKTableCommand.prototype.Execute = function() |
| 31 |
{ |
| 32 |
FCKUndo.SaveUndoStep() ; |
| 33 |
|
| 34 |
if ( ! FCKBrowserInfo.IsGecko ) |
| 35 |
{ |
| 36 |
switch ( this.Name ) |
| 37 |
{ |
| 38 |
case 'TableMergeRight' : |
| 39 |
return FCKTableHandler.MergeRight() ; |
| 40 |
case 'TableMergeDown' : |
| 41 |
return FCKTableHandler.MergeDown() ; |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
switch ( this.Name ) |
| 46 |
{ |
| 47 |
case 'TableInsertRowAfter' : |
| 48 |
return FCKTableHandler.InsertRow( false ) ; |
| 49 |
case 'TableInsertRowBefore' : |
| 50 |
return FCKTableHandler.InsertRow( true ) ; |
| 51 |
case 'TableDeleteRows' : |
| 52 |
return FCKTableHandler.DeleteRows() ; |
| 53 |
case 'TableInsertColumnAfter' : |
| 54 |
return FCKTableHandler.InsertColumn( false ) ; |
| 55 |
case 'TableInsertColumnBefore' : |
| 56 |
return FCKTableHandler.InsertColumn( true ) ; |
| 57 |
case 'TableDeleteColumns' : |
| 58 |
return FCKTableHandler.DeleteColumns() ; |
| 59 |
case 'TableInsertCellAfter' : |
| 60 |
return FCKTableHandler.InsertCell( null, false ) ; |
| 61 |
case 'TableInsertCellBefore' : |
| 62 |
return FCKTableHandler.InsertCell( null, true ) ; |
| 63 |
case 'TableDeleteCells' : |
| 64 |
return FCKTableHandler.DeleteCells() ; |
| 65 |
case 'TableMergeCells' : |
| 66 |
return FCKTableHandler.MergeCells() ; |
| 67 |
case 'TableHorizontalSplitCell' : |
| 68 |
return FCKTableHandler.HorizontalSplitCell() ; |
| 69 |
case 'TableVerticalSplitCell' : |
| 70 |
return FCKTableHandler.VerticalSplitCell() ; |
| 71 |
case 'TableDelete' : |
| 72 |
return FCKTableHandler.DeleteTable() ; |
| 73 |
default : |
| 74 |
return alert( FCKLang.UnknownCommand.replace( /%1/g, this.Name ) ) ; |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
FCKTableCommand.prototype.GetState = function() |
| 79 |
{ |
| 80 |
if ( FCK.EditorDocument != null && FCKSelection.HasAncestorNode( 'TABLE' ) ) |
| 81 |
{ |
| 82 |
switch ( this.Name ) |
| 83 |
{ |
| 84 |
case 'TableHorizontalSplitCell' : |
| 85 |
case 'TableVerticalSplitCell' : |
| 86 |
if ( FCKTableHandler.GetSelectedCells().length == 1 ) |
| 87 |
return FCK_TRISTATE_OFF ; |
| 88 |
else |
| 89 |
return FCK_TRISTATE_DISABLED ; |
| 90 |
case 'TableMergeCells' : |
| 91 |
if ( FCKTableHandler.CheckIsSelectionRectangular() |
| 92 |
&& FCKTableHandler.GetSelectedCells().length > 1 ) |
| 93 |
return FCK_TRISTATE_OFF ; |
| 94 |
else |
| 95 |
return FCK_TRISTATE_DISABLED ; |
| 96 |
case 'TableMergeRight' : |
| 97 |
return FCKTableHandler.GetMergeRightTarget() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; |
| 98 |
case 'TableMergeDown' : |
| 99 |
return FCKTableHandler.GetMergeDownTarget() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; |
| 100 |
default : |
| 101 |
return FCK_TRISTATE_OFF ; |
| 102 |
} |
| 103 |
} |
| 104 |
else |
| 105 |
return FCK_TRISTATE_DISABLED; |
| 106 |
} |
| 107 |
|