From 32ca1f9fc8a78e092565b51cc97faa724bb4e6cf Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 30 May 2009 05:09:57 -0400
Subject: [PATCH] - css fixes (#1485869)
---
program/js/tiny_mce/plugins/table/editor_plugin_src.js | 82 +++++++++++++++++++++++++++++++++++++----
1 files changed, 74 insertions(+), 8 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 0baafb1..80cf748 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 953 2008-11-04 10:16:50Z spocke $
*
* @author Moxiecode
* @copyright Copyright � 2004-2008, Moxiecode Systems AB, All rights reserved.
@@ -32,6 +32,27 @@
], function(c) {
ed.addButton(c[0], {title : c[1], cmd : c[2], ui : c[3]});
});
+
+ if (ed.getParam('inline_styles')) {
+ // Force move of attribs to styles in strict mode
+ ed.onPreProcess.add(function(ed, o) {
+ var dom = ed.dom;
+
+ each(dom.select('table', o.node), function(n) {
+ var v;
+
+ if (v = dom.getAttrib(n, 'width')) {
+ dom.setStyle(n, 'width', v);
+ dom.setAttrib(n, 'width');
+ }
+
+ if (v = dom.getAttrib(n, 'height')) {
+ dom.setStyle(n, 'height', v);
+ dom.setAttrib(n, 'height');
+ }
+ });
+ });
+ }
ed.onInit.add(function() {
if (ed && ed.plugins.contextmenu) {
@@ -88,14 +109,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 +166,7 @@
// Is table command
switch (cmd) {
+ case "mceTableMoveToNextRow":
case "mceInsertTable":
case "mceTableRowProps":
case "mceTableCellProps":
@@ -250,6 +290,19 @@
return grid[row][col];
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) {
@@ -419,6 +472,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 +697,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;
}
@@ -683,7 +749,7 @@
if (!trElm || !tdElm)
return true;
- var grid = getTableGrid(tableElm);
+ var grid = getTableGrid(inst.dom.getParent(tableElm, "table"));
var cpos = getCellPos(grid, tdElm);
var lastTDElm = null;
@@ -714,7 +780,7 @@
if (!trElm || !tdElm)
return true;
- var grid = getTableGrid(tableElm);
+ var grid = getTableGrid(inst.dom.getParent(tableElm, "table"));
var cpos = getCellPos(grid, tdElm);
var lastTDElm = null;
@@ -754,7 +820,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 +958,7 @@
if (!tdElm)
break;
- if (tdElm.nodeName == "TD")
+ if (tdElm.nodeName == "TD" || tdElm.nodeName == "TH")
cells[cells.length] = tdElm;
}
--
Gitblit v1.9.1