summaryrefslogtreecommitdiff
path: root/program/js/tiny_mce/plugins/table/editor_plugin_src.js
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-07-18 14:59:01 +0000
committeralecpl <alec@alec.pl>2008-07-18 14:59:01 +0000
commit18240a9201d193a5a2420f8644fa05b7bfbceeec (patch)
tree79f1f65e1eede1f8f5e8bf87960594c286b600e8 /program/js/tiny_mce/plugins/table/editor_plugin_src.js
parentbc0fe54235ae4f5cd4a74be91beb1f9953eb7b03 (diff)
- Updated TinyMCE to version 3.1.0.1
Diffstat (limited to 'program/js/tiny_mce/plugins/table/editor_plugin_src.js')
-rw-r--r--program/js/tiny_mce/plugins/table/editor_plugin_src.js57
1 files changed, 51 insertions, 6 deletions
diff --git a/program/js/tiny_mce/plugins/table/editor_plugin_src.js b/program/js/tiny_mce/plugins/table/editor_plugin_src.js
index 0baafb1f6..24635826f 100644
--- a/program/js/tiny_mce/plugins/table/editor_plugin_src.js
+++ b/program/js/tiny_mce/plugins/table/editor_plugin_src.js
@@ -1,5 +1,5 @@
/**
- * $Id: editor_plugin_src.js 768 2008-04-04 13:52:49Z spocke $
+ * $Id: editor_plugin_src.js 853 2008-05-27 08:05:35Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
@@ -88,14 +88,32 @@
// Add undo level when new rows are created using the tab key
ed.onKeyDown.add(function(ed, e) {
- if (e.keyCode == 9 && ed.dom.getParent(ed.selection.getNode(), 'TABLE'))
+ if (e.keyCode == 9 && ed.dom.getParent(ed.selection.getNode(), 'TABLE')) {
+ if (!tinymce.isGecko && !tinymce.isOpera) {
+ tinyMCE.execInstanceCommand(ed.editorId, "mceTableMoveToNextRow", true);
+ return tinymce.dom.Event.cancel(e);
+ }
+
ed.undoManager.add();
+ }
});
+ // Select whole table is a table border is clicked
+ if (!tinymce.isIE) {
+ if (ed.getParam('table_selection', true)) {
+ ed.onClick.add(function(ed, e) {
+ e = e.target;
+
+ if (e.nodeName === 'TABLE')
+ ed.selection.select(e);
+ });
+ }
+ }
+
ed.onNodeChange.add(function(ed, cm, n) {
var p = ed.dom.getParent(n, 'td,th,caption');
- cm.setActive('table', !!p);
+ cm.setActive('table', n.nodeName === 'TABLE' || !!p);
if (p && p.nodeName === 'CAPTION')
p = null;
@@ -127,6 +145,7 @@
// Is table command
switch (cmd) {
+ case "mceTableMoveToNextRow":
case "mceInsertTable":
case "mceTableRowProps":
case "mceTableCellProps":
@@ -252,6 +271,19 @@
return null;
}
+ function getNextCell(table, cell) {
+ var cells = [], x = 0, i, j, cell, nextCell;
+
+ for (i = 0; i < table.rows.length; i++)
+ for (j = 0; j < table.rows[i].cells.length; j++, x++)
+ cells[x] = table.rows[i].cells[j];
+
+ for (i = 0; i < cells.length; i++)
+ if (cells[i] == cell)
+ if (nextCell = cells[i+1])
+ return nextCell;
+ }
+
function getTableGrid(table) {
var grid = [], rows = table.rows, x, y, td, sd, xstart, x2, y2;
@@ -419,6 +451,19 @@
// Handle commands
switch (command) {
+ case "mceTableMoveToNextRow":
+ var nextCell = getNextCell(tableElm, tdElm);
+
+ if (!nextCell) {
+ inst.execCommand("mceTableInsertRowAfter", tdElm);
+ nextCell = getNextCell(tableElm, tdElm);
+ }
+
+ inst.selection.select(nextCell);
+ inst.selection.collapse(true);
+
+ return true;
+
case "mceTableRowProps":
if (trElm == null)
return true;
@@ -631,7 +676,7 @@
var cpos = getCellPos(grid, tdElm);
// Only one row, remove whole table
- if (grid.length == 1) {
+ if (grid.length == 1 && tableElm.nodeName == 'TBODY') {
inst.dom.remove(inst.dom.getParent(tableElm, "table"));
return true;
}
@@ -754,7 +799,7 @@
var lastTDElm = null;
// Only one col, remove whole table
- if (grid.length > 1 && grid[0].length <= 1) {
+ if ((grid.length > 1 && grid[0].length <= 1) && tableElm.nodeName == 'TBODY') {
inst.dom.remove(inst.dom.getParent(tableElm, "table"));
return true;
}
@@ -892,7 +937,7 @@
if (!tdElm)
break;
- if (tdElm.nodeName == "TD")
+ if (tdElm.nodeName == "TD" || tdElm.nodeName == "TH")
cells[cells.length] = tdElm;
}