| 1 |
/* |
| 2 |
|
| 3 |
* FCKeditor - The text editor for Internet - http://www.fckeditor.net |
| 4 |
|
| 5 |
* Copyright (C) 2003-2009 Frederico Caldeira Knabben |
| 6 |
|
| 7 |
* |
| 8 |
|
| 9 |
* == BEGIN LICENSE == |
| 10 |
|
| 11 |
* |
| 12 |
|
| 13 |
* Licensed under the terms of any of the following licenses at your |
| 14 |
|
| 15 |
* choice: |
| 16 |
|
| 17 |
* |
| 18 |
|
| 19 |
* - GNU General Public License Version 2 or later (the "GPL") |
| 20 |
|
| 21 |
* http://www.gnu.org/licenses/gpl.html |
| 22 |
|
| 23 |
* |
| 24 |
|
| 25 |
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
| 26 |
|
| 27 |
* http://www.gnu.org/licenses/lgpl.html |
| 28 |
|
| 29 |
* |
| 30 |
|
| 31 |
* - Mozilla Public License Version 1.1 or later (the "MPL") |
| 32 |
|
| 33 |
* http://www.mozilla.org/MPL/MPL-1.1.html |
| 34 |
|
| 35 |
* |
| 36 |
|
| 37 |
* == END LICENSE == |
| 38 |
|
| 39 |
* |
| 40 |
|
| 41 |
* FCKPastePlainTextCommand Class: represents the |
| 42 |
|
| 43 |
* "Paste as Plain Text" command. |
| 44 |
|
| 45 |
*/ |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
var FCKTableCommand = function( command ) |
| 50 |
|
| 51 |
{ |
| 52 |
|
| 53 |
this.Name = command ; |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
FCKTableCommand.prototype.Execute = function() |
| 60 |
|
| 61 |
{ |
| 62 |
|
| 63 |
FCKUndo.SaveUndoStep() ; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
if ( ! FCKBrowserInfo.IsGecko ) |
| 68 |
|
| 69 |
{ |
| 70 |
|
| 71 |
switch ( this.Name ) |
| 72 |
|
| 73 |
{ |
| 74 |
|
| 75 |
case 'TableMergeRight' : |
| 76 |
|
| 77 |
return FCKTableHandler.MergeRight() ; |
| 78 |
|
| 79 |
case 'TableMergeDown' : |
| 80 |
|
| 81 |
return FCKTableHandler.MergeDown() ; |
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
switch ( this.Name ) |
| 90 |
|
| 91 |
{ |
| 92 |
|
| 93 |
case 'TableInsertRowAfter' : |
| 94 |
|
| 95 |
return FCKTableHandler.InsertRow( false ) ; |
| 96 |
|
| 97 |
case 'TableInsertRowBefore' : |
| 98 |
|
| 99 |
return FCKTableHandler.InsertRow( true ) ; |
| 100 |
|
| 101 |
case 'TableDeleteRows' : |
| 102 |
|
| 103 |
return FCKTableHandler.DeleteRows() ; |
| 104 |
|
| 105 |
case 'TableInsertColumnAfter' : |
| 106 |
|
| 107 |
return FCKTableHandler.InsertColumn( false ) ; |
| 108 |
|
| 109 |
case 'TableInsertColumnBefore' : |
| 110 |
|
| 111 |
return FCKTableHandler.InsertColumn( true ) ; |
| 112 |
|
| 113 |
case 'TableDeleteColumns' : |
| 114 |
|
| 115 |
return FCKTableHandler.DeleteColumns() ; |
| 116 |
|
| 117 |
case 'TableInsertCellAfter' : |
| 118 |
|
| 119 |
return FCKTableHandler.InsertCell( null, false ) ; |
| 120 |
|
| 121 |
case 'TableInsertCellBefore' : |
| 122 |
|
| 123 |
return FCKTableHandler.InsertCell( null, true ) ; |
| 124 |
|
| 125 |
case 'TableDeleteCells' : |
| 126 |
|
| 127 |
return FCKTableHandler.DeleteCells() ; |
| 128 |
|
| 129 |
case 'TableMergeCells' : |
| 130 |
|
| 131 |
return FCKTableHandler.MergeCells() ; |
| 132 |
|
| 133 |
case 'TableHorizontalSplitCell' : |
| 134 |
|
| 135 |
return FCKTableHandler.HorizontalSplitCell() ; |
| 136 |
|
| 137 |
case 'TableVerticalSplitCell' : |
| 138 |
|
| 139 |
return FCKTableHandler.VerticalSplitCell() ; |
| 140 |
|
| 141 |
case 'TableDelete' : |
| 142 |
|
| 143 |
return FCKTableHandler.DeleteTable() ; |
| 144 |
|
| 145 |
default : |
| 146 |
|
| 147 |
return alert( FCKLang.UnknownCommand.replace( /%1/g, this.Name ) ) ; |
| 148 |
|
| 149 |
} |
| 150 |
|
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
FCKTableCommand.prototype.GetState = function() |
| 156 |
|
| 157 |
{ |
| 158 |
|
| 159 |
if ( FCK.EditorDocument != null && FCKSelection.HasAncestorNode( 'TABLE' ) ) |
| 160 |
|
| 161 |
{ |
| 162 |
|
| 163 |
switch ( this.Name ) |
| 164 |
|
| 165 |
{ |
| 166 |
|
| 167 |
case 'TableHorizontalSplitCell' : |
| 168 |
|
| 169 |
case 'TableVerticalSplitCell' : |
| 170 |
|
| 171 |
if ( FCKTableHandler.GetSelectedCells().length == 1 ) |
| 172 |
|
| 173 |
return FCK_TRISTATE_OFF ; |
| 174 |
|
| 175 |
else |
| 176 |
|
| 177 |
return FCK_TRISTATE_DISABLED ; |
| 178 |
|
| 179 |
case 'TableMergeCells' : |
| 180 |
|
| 181 |
if ( FCKTableHandler.CheckIsSelectionRectangular() |
| 182 |
|
| 183 |
&& FCKTableHandler.GetSelectedCells().length > 1 ) |
| 184 |
|
| 185 |
return FCK_TRISTATE_OFF ; |
| 186 |
|
| 187 |
else |
| 188 |
|
| 189 |
return FCK_TRISTATE_DISABLED ; |
| 190 |
|
| 191 |
case 'TableMergeRight' : |
| 192 |
|
| 193 |
return FCKTableHandler.GetMergeRightTarget() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; |
| 194 |
|
| 195 |
case 'TableMergeDown' : |
| 196 |
|
| 197 |
return FCKTableHandler.GetMergeDownTarget() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; |
| 198 |
|
| 199 |
default : |
| 200 |
|
| 201 |
return FCK_TRISTATE_OFF ; |
| 202 |
|
| 203 |
} |
| 204 |
|
| 205 |
} |
| 206 |
|
| 207 |
else |
| 208 |
|
| 209 |
return FCK_TRISTATE_DISABLED; |
| 210 |
|
| 211 |
} |
| 212 |
|
| 213 |
|