]> git.donarmstrong.com Git - roundcube.git/blobdiff - program/js/tiny_mce/plugins/table/js/table.js
Imported Upstream version 0.3
[roundcube.git] / program / js / tiny_mce / plugins / table / js / table.js
index a8e112c2ff99f4a2a3b87dffd5dcc54ca27118fb..2b6fd1f7020a896ce8717921e5d88111c367a0cb 100644 (file)
@@ -12,7 +12,7 @@ function insertTable() {
        tinyMCEPopup.restoreSelection();\r
 \r
        if (!AutoValidator.validate(formObj)) {\r
-               alert(inst.getLang('invalid_data'));\r
+               tinyMCEPopup.alert(inst.getLang('invalid_data'));\r
                return false;\r
        }\r
 \r
@@ -46,13 +46,13 @@ function insertTable() {
 \r
        // Validate table size\r
        if (colLimit && cols > colLimit) {\r
-               inst.windowManager.alert(inst.getLang('table_dlg.col_limit').replace(/\{\$cols\}/g, colLimit));\r
+               tinyMCEPopup.alert(inst.getLang('table_dlg.col_limit').replace(/\{\$cols\}/g, colLimit));\r
                return false;\r
        } else if (rowLimit && rows > rowLimit) {\r
-               inst.windowManager.alert(inst.getLang('table_dlg.row_limit').replace(/\{\$rows\}/g, rowLimit));\r
+               tinyMCEPopup.alert(inst.getLang('table_dlg.row_limit').replace(/\{\$rows\}/g, rowLimit));\r
                return false;\r
        } else if (cellLimit && cols * rows > cellLimit) {\r
-               inst.windowManager.alert(inst.getLang('table_dlg.cell_limit').replace(/\{\$cells\}/g, cellLimit));\r
+               tinyMCEPopup.alert(inst.getLang('table_dlg.cell_limit').replace(/\{\$cells\}/g, cellLimit));\r
                return false;\r
        }\r
 \r
@@ -87,7 +87,7 @@ function insertTable() {
                        elm.insertBefore(capEl, elm.firstChild);\r
                }\r
 \r
-               if (width && /(pt|em|cm)$/.test(width)) {\r
+               if (width && inst.settings.inline_styles) {\r
                        dom.setStyle(elm, 'width', width);\r
                        dom.setAttrib(elm, 'width', '');\r
                } else {\r
@@ -100,10 +100,13 @@ function insertTable() {
                dom.setAttrib(elm, 'bgColor', '');\r
                dom.setAttrib(elm, 'background', '');\r
 \r
-               if (height) {\r
+               if (height && inst.settings.inline_styles) {\r
                        dom.setStyle(elm, 'height', height);\r
                        dom.setAttrib(elm, 'height', '');\r
-               }\r
+               } else {\r
+                       dom.setAttrib(elm, 'height', height, true);\r
+                       dom.setStyle(elm, 'height', '');\r
+               }\r
 \r
                if (background != '')\r
                        elm.style.backgroundImage = "url('" + background + "')";\r
@@ -149,10 +152,14 @@ function insertTable() {
        html += makeAttrib('cellpadding', cellpadding);\r
        html += makeAttrib('cellspacing', cellspacing);\r
 \r
-       if (width && /(pt|em|cm)$/.test(width)) {\r
+       if (width && inst.settings.inline_styles) {\r
                if (style)\r
                        style += '; ';\r
 \r
+               // Force px\r
+               if (/[0-9\.]+/.test(width))\r
+                       width += 'px';\r
+\r
                style += 'width: ' + width;\r
        } else\r
                html += makeAttrib('width', width);\r
@@ -200,7 +207,30 @@ function insertTable() {
        html += "</table>";\r
 \r
        inst.execCommand('mceBeginUndoLevel');\r
-       inst.execCommand('mceInsertContent', false, html);\r
+\r
+       // Move table\r
+       if (inst.settings.fix_table_elements) {\r
+               var bm = inst.selection.getBookmark(), patt = '';\r
+\r
+               inst.execCommand('mceInsertContent', false, '<br class="_mce_marker" />');\r
+\r
+               tinymce.each('h1,h2,h3,h4,h5,h6,p'.split(','), function(n) {\r
+                       if (patt)\r
+                               patt += ',';\r
+\r
+                       patt += n + ' ._mce_marker';\r
+               });\r
+\r
+               tinymce.each(inst.dom.select(patt), function(n) {\r
+                       inst.dom.split(inst.dom.getParent(n, 'h1,h2,h3,h4,h5,h6,p'), n);\r
+               });\r
+\r
+               dom.setOuterHTML(dom.select('._mce_marker')[0], html);\r
+\r
+               inst.selection.moveToBookmark(bm);\r
+       } else\r
+               inst.execCommand('mceInsertContent', false, html);\r
+\r
        inst.addVisual();\r
        inst.execCommand('mceEndUndoLevel');\r
 \r