MCE Table Buttons - Version 1.0

Version Description

Download this release

Release Info

Developer jakemgold
Plugin Icon 128x128 MCE Table Buttons
Version 1.0
Comparing to
See all releases

Version 1.0

mce-table/cell.htm ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <title>{#table_dlg.cell_title}</title>
5
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/tiny_mce_popup.js"></script>
6
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/mctabs.js"></script>
7
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/form_utils.js"></script>
8
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/editable_selects.js"></script>
9
+ <script type="text/javascript" src="js/cell.js"></script>
10
+ <link href="css/cell.css" rel="stylesheet" type="text/css" />
11
+ </head>
12
+ <body id="tablecell" style="display: none">
13
+ <form onsubmit="updateAction();return false;" action="#">
14
+ <div class="tabs">
15
+ <ul>
16
+ <li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#table_dlg.general_tab}</a></span></li>
17
+ <li id="advanced_tab"><span><a href="javascript:mcTabs.displayTab('advanced_tab','advanced_panel');" onmousedown="return false;">{#table_dlg.advanced_tab}</a></span></li>
18
+ </ul>
19
+ </div>
20
+
21
+ <div class="panel_wrapper">
22
+ <div id="general_panel" class="panel current">
23
+ <fieldset>
24
+ <legend>{#table_dlg.general_props}</legend>
25
+
26
+ <table border="0" cellpadding="4" cellspacing="0">
27
+ <tr>
28
+ <td><label for="align">{#table_dlg.align}</label></td>
29
+ <td>
30
+ <select id="align" name="align" class="mceFocus">
31
+ <option value="">{#not_set}</option>
32
+ <option value="center">{#table_dlg.align_middle}</option>
33
+ <option value="left">{#table_dlg.align_left}</option>
34
+ <option value="right">{#table_dlg.align_right}</option>
35
+ </select>
36
+ </td>
37
+
38
+ <td><label for="celltype">{#table_dlg.cell_type}</label></td>
39
+ <td>
40
+ <select id="celltype" name="celltype">
41
+ <option value="td">{#table_dlg.td}</option>
42
+ <option value="th">{#table_dlg.th}</option>
43
+ </select>
44
+ </td>
45
+ </tr>
46
+
47
+ <tr>
48
+ <td><label for="valign">{#table_dlg.valign}</label></td>
49
+ <td>
50
+ <select id="valign" name="valign">
51
+ <option value="">{#not_set}</option>
52
+ <option value="top">{#table_dlg.align_top}</option>
53
+ <option value="middle">{#table_dlg.align_middle}</option>
54
+ <option value="bottom">{#table_dlg.align_bottom}</option>
55
+ </select>
56
+ </td>
57
+
58
+ <td><label for="scope">{#table_dlg.scope}</label></td>
59
+ <td>
60
+ <select id="scope" name="scope">
61
+ <option value="">{#not_set}</option>
62
+ <option value="col">{#table.col}</option>
63
+ <option value="row">{#table.row}</option>
64
+ <option value="rowgroup">{#table_dlg.rowgroup}</option>
65
+ <option value="colgroup">{#table_dlg.colgroup}</option>
66
+ </select>
67
+ </td>
68
+
69
+ </tr>
70
+
71
+ <tr>
72
+ <td><label for="width">{#table_dlg.width}</label></td>
73
+ <td><input id="width" name="width" type="text" value="" size="4" maxlength="4" onchange="changedSize();" /></td>
74
+
75
+ <td><label for="height">{#table_dlg.height}</label></td>
76
+ <td><input id="height" name="height" type="text" value="" size="4" maxlength="4" onchange="changedSize();" /></td>
77
+ </tr>
78
+
79
+ <tr id="styleSelectRow">
80
+ <td><label for="class">{#class_name}</label></td>
81
+ <td colspan="3">
82
+ <select id="class" name="class" class="mceEditableSelect">
83
+ <option value="" selected="selected">{#not_set}</option>
84
+ </select>
85
+ </td>
86
+ </tr>
87
+ </table>
88
+ </fieldset>
89
+ </div>
90
+
91
+ <div id="advanced_panel" class="panel">
92
+ <fieldset>
93
+ <legend>{#table_dlg.advanced_props}</legend>
94
+
95
+ <table border="0" cellpadding="0" cellspacing="4">
96
+ <tr>
97
+ <td class="column1"><label for="id">{#table_dlg.id}</label></td>
98
+ <td><input id="id" name="id" type="text" value="" style="width: 200px" /></td>
99
+ </tr>
100
+
101
+ <tr>
102
+ <td><label for="style">{#table_dlg.style}</label></td>
103
+ <td><input type="text" id="style" name="style" value="" style="width: 200px;" onchange="changedStyle();" /></td>
104
+ </tr>
105
+
106
+ <tr>
107
+ <td class="column1"><label for="dir">{#table_dlg.langdir}</label></td>
108
+ <td>
109
+ <select id="dir" name="dir" style="width: 200px">
110
+ <option value="">{#not_set}</option>
111
+ <option value="ltr">{#table_dlg.ltr}</option>
112
+ <option value="rtl">{#table_dlg.rtl}</option>
113
+ </select>
114
+ </td>
115
+ </tr>
116
+
117
+ <tr>
118
+ <td class="column1"><label for="lang">{#table_dlg.langcode}</label></td>
119
+ <td>
120
+ <input id="lang" name="lang" type="text" value="" style="width: 200px" />
121
+ </td>
122
+ </tr>
123
+
124
+ <tr>
125
+ <td class="column1"><label for="backgroundimage">{#table_dlg.bgimage}</label></td>
126
+ <td>
127
+ <table border="0" cellpadding="0" cellspacing="0">
128
+ <tr>
129
+ <td><input id="backgroundimage" name="backgroundimage" type="text" value="" style="width: 200px" onchange="changedBackgroundImage();" /></td>
130
+ <td id="backgroundimagebrowsercontainer">&nbsp;</td>
131
+ </tr>
132
+ </table>
133
+ </td>
134
+ </tr>
135
+
136
+ <tr>
137
+ <td class="column1"><label for="bordercolor">{#table_dlg.bordercolor}</label></td>
138
+ <td>
139
+ <table border="0" cellpadding="0" cellspacing="0">
140
+ <tr>
141
+ <td><input id="bordercolor" name="bordercolor" type="text" value="" size="9" onchange="updateColor('bordercolor_pick','bordercolor');changedColor();" /></td>
142
+ <td id="bordercolor_pickcontainer">&nbsp;</td>
143
+ </tr>
144
+ </table>
145
+ </td>
146
+ </tr>
147
+
148
+ <tr>
149
+ <td class="column1"><label for="bgcolor">{#table_dlg.bgcolor}</label></td>
150
+ <td>
151
+ <table border="0" cellpadding="0" cellspacing="0">
152
+ <tr>
153
+ <td><input id="bgcolor" name="bgcolor" type="text" value="" size="9" onchange="updateColor('bgcolor_pick','bgcolor');changedColor();" /></td>
154
+ <td id="bgcolor_pickcontainer">&nbsp;</td>
155
+ </tr>
156
+ </table>
157
+ </td>
158
+ </tr>
159
+ </table>
160
+ </fieldset>
161
+ </div>
162
+ </div>
163
+
164
+ <div class="mceActionPanel">
165
+ <div>
166
+ <select id="action" name="action">
167
+ <option value="cell">{#table_dlg.cell_cell}</option>
168
+ <option value="row">{#table_dlg.cell_row}</option>
169
+ <option value="all">{#table_dlg.cell_all}</option>
170
+ </select>
171
+ </div>
172
+
173
+ <div style="float: left">
174
+ <div><input type="submit" id="insert" name="insert" value="{#update}" /></div>
175
+ </div>
176
+
177
+ <div style="float: right">
178
+ <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
179
+ </div>
180
+ </div>
181
+ </form>
182
+ </body>
183
+ </html>
mce-table/css/cell.css ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* CSS file for cell dialog in the table plugin */
2
+
3
+ .panel_wrapper div.current {
4
+ height: 200px;
5
+ }
6
+
7
+ .advfield {
8
+ width: 200px;
9
+ }
10
+
11
+ #action {
12
+ margin-bottom: 3px;
13
+ }
14
+
15
+ #class {
16
+ width: 150px;
17
+ }
mce-table/css/row.css ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* CSS file for row dialog in the table plugin */
2
+
3
+ .panel_wrapper div.current {
4
+ height: 200px;
5
+ }
6
+
7
+ .advfield {
8
+ width: 200px;
9
+ }
10
+
11
+ #action {
12
+ margin-bottom: 3px;
13
+ }
14
+
15
+ #rowtype,#align,#valign,#class,#height {
16
+ width: 150px;
17
+ }
18
+
19
+ #height {
20
+ width: 50px;
21
+ }
22
+
23
+ .col2 {
24
+ padding-left: 20px;
25
+ }
mce-table/css/table.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* CSS file for table dialog in the table plugin */
2
+
3
+ .panel_wrapper div.current {
4
+ height: 245px;
5
+ }
6
+
7
+ .advfield {
8
+ width: 200px;
9
+ }
10
+
11
+ #class {
12
+ width: 150px;
13
+ }
mce-table/js/cell.js ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tinyMCEPopup.requireLangPack();
2
+
3
+ var ed;
4
+
5
+ function init() {
6
+ ed = tinyMCEPopup.editor;
7
+ tinyMCEPopup.resizeToInnerSize();
8
+
9
+ document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
10
+ document.getElementById('bordercolor_pickcontainer').innerHTML = getColorPickerHTML('bordercolor_pick','bordercolor');
11
+ document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor')
12
+
13
+ var inst = ed;
14
+ var tdElm = ed.dom.getParent(ed.selection.getNode(), "td,th");
15
+ var formObj = document.forms[0];
16
+ var st = ed.dom.parseStyle(ed.dom.getAttrib(tdElm, "style"));
17
+
18
+ // Get table cell data
19
+ var celltype = tdElm.nodeName.toLowerCase();
20
+ var align = ed.dom.getAttrib(tdElm, 'align');
21
+ var valign = ed.dom.getAttrib(tdElm, 'valign');
22
+ var width = trimSize(getStyle(tdElm, 'width', 'width'));
23
+ var height = trimSize(getStyle(tdElm, 'height', 'height'));
24
+ var bordercolor = convertRGBToHex(getStyle(tdElm, 'bordercolor', 'borderLeftColor'));
25
+ var bgcolor = convertRGBToHex(getStyle(tdElm, 'bgcolor', 'backgroundColor'));
26
+ var className = ed.dom.getAttrib(tdElm, 'class');
27
+ var backgroundimage = getStyle(tdElm, 'background', 'backgroundImage').replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");;
28
+ var id = ed.dom.getAttrib(tdElm, 'id');
29
+ var lang = ed.dom.getAttrib(tdElm, 'lang');
30
+ var dir = ed.dom.getAttrib(tdElm, 'dir');
31
+ var scope = ed.dom.getAttrib(tdElm, 'scope');
32
+
33
+ // Setup form
34
+ addClassesToList('class', 'table_cell_styles');
35
+ TinyMCE_EditableSelects.init();
36
+
37
+ formObj.bordercolor.value = bordercolor;
38
+ formObj.bgcolor.value = bgcolor;
39
+ formObj.backgroundimage.value = backgroundimage;
40
+ formObj.width.value = width;
41
+ formObj.height.value = height;
42
+ formObj.id.value = id;
43
+ formObj.lang.value = lang;
44
+ formObj.style.value = ed.dom.serializeStyle(st);
45
+ selectByValue(formObj, 'align', align);
46
+ selectByValue(formObj, 'valign', valign);
47
+ selectByValue(formObj, 'class', className, true, true);
48
+ selectByValue(formObj, 'celltype', celltype);
49
+ selectByValue(formObj, 'dir', dir);
50
+ selectByValue(formObj, 'scope', scope);
51
+
52
+ // Resize some elements
53
+ if (isVisible('backgroundimagebrowser'))
54
+ document.getElementById('backgroundimage').style.width = '180px';
55
+
56
+ updateColor('bordercolor_pick', 'bordercolor');
57
+ updateColor('bgcolor_pick', 'bgcolor');
58
+ }
59
+
60
+ function updateAction() {
61
+ var el, inst = ed, tdElm, trElm, tableElm, formObj = document.forms[0];
62
+
63
+ tinyMCEPopup.restoreSelection();
64
+ el = ed.selection.getNode();
65
+ tdElm = ed.dom.getParent(el, "td,th");
66
+ trElm = ed.dom.getParent(el, "tr");
67
+ tableElm = ed.dom.getParent(el, "table");
68
+
69
+ ed.execCommand('mceBeginUndoLevel');
70
+
71
+ switch (getSelectValue(formObj, 'action')) {
72
+ case "cell":
73
+ var celltype = getSelectValue(formObj, 'celltype');
74
+ var scope = getSelectValue(formObj, 'scope');
75
+
76
+ function doUpdate(s) {
77
+ if (s) {
78
+ updateCell(tdElm);
79
+
80
+ ed.addVisual();
81
+ ed.nodeChanged();
82
+ inst.execCommand('mceEndUndoLevel');
83
+ tinyMCEPopup.close();
84
+ }
85
+ };
86
+
87
+ if (ed.getParam("accessibility_warnings", 1)) {
88
+ if (celltype == "th" && scope == "")
89
+ tinyMCEPopup.confirm(ed.getLang('table_dlg.missing_scope', '', true), doUpdate);
90
+ else
91
+ doUpdate(1);
92
+
93
+ return;
94
+ }
95
+
96
+ updateCell(tdElm);
97
+ break;
98
+
99
+ case "row":
100
+ var cell = trElm.firstChild;
101
+
102
+ if (cell.nodeName != "TD" && cell.nodeName != "TH")
103
+ cell = nextCell(cell);
104
+
105
+ do {
106
+ cell = updateCell(cell, true);
107
+ } while ((cell = nextCell(cell)) != null);
108
+
109
+ break;
110
+
111
+ case "all":
112
+ var rows = tableElm.getElementsByTagName("tr");
113
+
114
+ for (var i=0; i<rows.length; i++) {
115
+ var cell = rows[i].firstChild;
116
+
117
+ if (cell.nodeName != "TD" && cell.nodeName != "TH")
118
+ cell = nextCell(cell);
119
+
120
+ do {
121
+ cell = updateCell(cell, true);
122
+ } while ((cell = nextCell(cell)) != null);
123
+ }
124
+
125
+ break;
126
+ }
127
+
128
+ ed.addVisual();
129
+ ed.nodeChanged();
130
+ inst.execCommand('mceEndUndoLevel');
131
+ tinyMCEPopup.close();
132
+ }
133
+
134
+ function nextCell(elm) {
135
+ while ((elm = elm.nextSibling) != null) {
136
+ if (elm.nodeName == "TD" || elm.nodeName == "TH")
137
+ return elm;
138
+ }
139
+
140
+ return null;
141
+ }
142
+
143
+ function updateCell(td, skip_id) {
144
+ var inst = ed;
145
+ var formObj = document.forms[0];
146
+ var curCellType = td.nodeName.toLowerCase();
147
+ var celltype = getSelectValue(formObj, 'celltype');
148
+ var doc = inst.getDoc();
149
+ var dom = ed.dom;
150
+
151
+ if (!skip_id)
152
+ td.setAttribute('id', formObj.id.value);
153
+
154
+ td.setAttribute('align', formObj.align.value);
155
+ td.setAttribute('vAlign', formObj.valign.value);
156
+ td.setAttribute('lang', formObj.lang.value);
157
+ td.setAttribute('dir', getSelectValue(formObj, 'dir'));
158
+ td.setAttribute('style', ed.dom.serializeStyle(ed.dom.parseStyle(formObj.style.value)));
159
+ td.setAttribute('scope', formObj.scope.value);
160
+ ed.dom.setAttrib(td, 'class', getSelectValue(formObj, 'class'));
161
+
162
+ // Clear deprecated attributes
163
+ ed.dom.setAttrib(td, 'width', '');
164
+ ed.dom.setAttrib(td, 'height', '');
165
+ ed.dom.setAttrib(td, 'bgColor', '');
166
+ ed.dom.setAttrib(td, 'borderColor', '');
167
+ ed.dom.setAttrib(td, 'background', '');
168
+
169
+ // Set styles
170
+ td.style.width = getCSSSize(formObj.width.value);
171
+ td.style.height = getCSSSize(formObj.height.value);
172
+ if (formObj.bordercolor.value != "") {
173
+ td.style.borderColor = formObj.bordercolor.value;
174
+ td.style.borderStyle = td.style.borderStyle == "" ? "solid" : td.style.borderStyle;
175
+ td.style.borderWidth = td.style.borderWidth == "" ? "1px" : td.style.borderWidth;
176
+ } else
177
+ td.style.borderColor = '';
178
+
179
+ td.style.backgroundColor = formObj.bgcolor.value;
180
+
181
+ if (formObj.backgroundimage.value != "")
182
+ td.style.backgroundImage = "url('" + formObj.backgroundimage.value + "')";
183
+ else
184
+ td.style.backgroundImage = '';
185
+
186
+ if (curCellType != celltype) {
187
+ // changing to a different node type
188
+ var newCell = doc.createElement(celltype);
189
+
190
+ for (var c=0; c<td.childNodes.length; c++)
191
+ newCell.appendChild(td.childNodes[c].cloneNode(1));
192
+
193
+ for (var a=0; a<td.attributes.length; a++)
194
+ ed.dom.setAttrib(newCell, td.attributes[a].name, ed.dom.getAttrib(td, td.attributes[a].name));
195
+
196
+ td.parentNode.replaceChild(newCell, td);
197
+ td = newCell;
198
+ }
199
+
200
+ dom.setAttrib(td, 'style', dom.serializeStyle(dom.parseStyle(td.style.cssText)));
201
+
202
+ return td;
203
+ }
204
+
205
+ function changedBackgroundImage() {
206
+ var formObj = document.forms[0];
207
+ var st = ed.dom.parseStyle(formObj.style.value);
208
+
209
+ st['background-image'] = "url('" + formObj.backgroundimage.value + "')";
210
+
211
+ formObj.style.value = ed.dom.serializeStyle(st);
212
+ }
213
+
214
+ function changedSize() {
215
+ var formObj = document.forms[0];
216
+ var st = ed.dom.parseStyle(formObj.style.value);
217
+
218
+ var width = formObj.width.value;
219
+ if (width != "")
220
+ st['width'] = getCSSSize(width);
221
+ else
222
+ st['width'] = "";
223
+
224
+ var height = formObj.height.value;
225
+ if (height != "")
226
+ st['height'] = getCSSSize(height);
227
+ else
228
+ st['height'] = "";
229
+
230
+ formObj.style.value = ed.dom.serializeStyle(st);
231
+ }
232
+
233
+ function changedColor() {
234
+ var formObj = document.forms[0];
235
+ var st = ed.dom.parseStyle(formObj.style.value);
236
+
237
+ st['background-color'] = formObj.bgcolor.value;
238
+ st['border-color'] = formObj.bordercolor.value;
239
+
240
+ formObj.style.value = ed.dom.serializeStyle(st);
241
+ }
242
+
243
+ function changedStyle() {
244
+ var formObj = document.forms[0];
245
+ var st = ed.dom.parseStyle(formObj.style.value);
246
+
247
+ if (st['background-image'])
248
+ formObj.backgroundimage.value = st['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
249
+ else
250
+ formObj.backgroundimage.value = '';
251
+
252
+ if (st['width'])
253
+ formObj.width.value = trimSize(st['width']);
254
+
255
+ if (st['height'])
256
+ formObj.height.value = trimSize(st['height']);
257
+
258
+ if (st['background-color']) {
259
+ formObj.bgcolor.value = st['background-color'];
260
+ updateColor('bgcolor_pick','bgcolor');
261
+ }
262
+
263
+ if (st['border-color']) {
264
+ formObj.bordercolor.value = st['border-color'];
265
+ updateColor('bordercolor_pick','bordercolor');
266
+ }
267
+ }
268
+
269
+ tinyMCEPopup.onInit.add(init);
mce-table/js/merge_cells.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tinyMCEPopup.requireLangPack();
2
+
3
+ function init() {
4
+ var f = document.forms[0], v;
5
+
6
+ tinyMCEPopup.resizeToInnerSize();
7
+
8
+ f.numcols.value = tinyMCEPopup.getWindowArg('numcols', 1);
9
+ f.numrows.value = tinyMCEPopup.getWindowArg('numrows', 1);
10
+ }
11
+
12
+ function mergeCells() {
13
+ var args = [], f = document.forms[0];
14
+
15
+ tinyMCEPopup.restoreSelection();
16
+
17
+ if (!AutoValidator.validate(f)) {
18
+ tinyMCEPopup.alert(tinyMCEPopup.getLang('invalid_data'));
19
+ return false;
20
+ }
21
+
22
+ args["numcols"] = f.numcols.value;
23
+ args["numrows"] = f.numrows.value;
24
+
25
+ tinyMCEPopup.execCommand("mceTableMergeCells", false, args);
26
+ tinyMCEPopup.close();
27
+ }
28
+
29
+ tinyMCEPopup.onInit.add(init);
mce-table/js/row.js ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tinyMCEPopup.requireLangPack();
2
+
3
+ function init() {
4
+ tinyMCEPopup.resizeToInnerSize();
5
+
6
+ document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
7
+ document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
8
+
9
+ var inst = tinyMCEPopup.editor;
10
+ var dom = inst.dom;
11
+ var trElm = dom.getParent(inst.selection.getNode(), "tr");
12
+ var formObj = document.forms[0];
13
+ var st = dom.parseStyle(dom.getAttrib(trElm, "style"));
14
+
15
+ // Get table row data
16
+ var rowtype = trElm.parentNode.nodeName.toLowerCase();
17
+ var align = dom.getAttrib(trElm, 'align');
18
+ var valign = dom.getAttrib(trElm, 'valign');
19
+ var height = trimSize(getStyle(trElm, 'height', 'height'));
20
+ var className = dom.getAttrib(trElm, 'class');
21
+ var bgcolor = convertRGBToHex(getStyle(trElm, 'bgcolor', 'backgroundColor'));
22
+ var backgroundimage = getStyle(trElm, 'background', 'backgroundImage').replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");;
23
+ var id = dom.getAttrib(trElm, 'id');
24
+ var lang = dom.getAttrib(trElm, 'lang');
25
+ var dir = dom.getAttrib(trElm, 'dir');
26
+
27
+ // Setup form
28
+ addClassesToList('class', 'table_row_styles');
29
+ TinyMCE_EditableSelects.init();
30
+
31
+ formObj.bgcolor.value = bgcolor;
32
+ formObj.backgroundimage.value = backgroundimage;
33
+ formObj.height.value = height;
34
+ formObj.id.value = id;
35
+ formObj.lang.value = lang;
36
+ formObj.style.value = dom.serializeStyle(st);
37
+ selectByValue(formObj, 'align', align);
38
+ selectByValue(formObj, 'valign', valign);
39
+ selectByValue(formObj, 'class', className, true, true);
40
+ selectByValue(formObj, 'rowtype', rowtype);
41
+ selectByValue(formObj, 'dir', dir);
42
+
43
+ // Resize some elements
44
+ if (isVisible('backgroundimagebrowser'))
45
+ document.getElementById('backgroundimage').style.width = '180px';
46
+
47
+ updateColor('bgcolor_pick', 'bgcolor');
48
+ }
49
+
50
+ function updateAction() {
51
+ var inst = tinyMCEPopup.editor, dom = inst.dom, trElm, tableElm, formObj = document.forms[0];
52
+ var action = getSelectValue(formObj, 'action');
53
+
54
+ tinyMCEPopup.restoreSelection();
55
+ trElm = dom.getParent(inst.selection.getNode(), "tr");
56
+ tableElm = dom.getParent(inst.selection.getNode(), "table");
57
+
58
+ inst.execCommand('mceBeginUndoLevel');
59
+
60
+ switch (action) {
61
+ case "row":
62
+ updateRow(trElm);
63
+ break;
64
+
65
+ case "all":
66
+ var rows = tableElm.getElementsByTagName("tr");
67
+
68
+ for (var i=0; i<rows.length; i++)
69
+ updateRow(rows[i], true);
70
+
71
+ break;
72
+
73
+ case "odd":
74
+ case "even":
75
+ var rows = tableElm.getElementsByTagName("tr");
76
+
77
+ for (var i=0; i<rows.length; i++) {
78
+ if ((i % 2 == 0 && action == "odd") || (i % 2 != 0 && action == "even"))
79
+ updateRow(rows[i], true, true);
80
+ }
81
+
82
+ break;
83
+ }
84
+
85
+ inst.addVisual();
86
+ inst.nodeChanged();
87
+ inst.execCommand('mceEndUndoLevel');
88
+ tinyMCEPopup.close();
89
+ }
90
+
91
+ function updateRow(tr_elm, skip_id, skip_parent) {
92
+ var inst = tinyMCEPopup.editor;
93
+ var formObj = document.forms[0];
94
+ var dom = inst.dom;
95
+ var curRowType = tr_elm.parentNode.nodeName.toLowerCase();
96
+ var rowtype = getSelectValue(formObj, 'rowtype');
97
+ var doc = inst.getDoc();
98
+
99
+ // Update row element
100
+ if (!skip_id)
101
+ tr_elm.setAttribute('id', formObj.id.value);
102
+
103
+ tr_elm.setAttribute('align', getSelectValue(formObj, 'align'));
104
+ tr_elm.setAttribute('vAlign', getSelectValue(formObj, 'valign'));
105
+ tr_elm.setAttribute('lang', formObj.lang.value);
106
+ tr_elm.setAttribute('dir', getSelectValue(formObj, 'dir'));
107
+ tr_elm.setAttribute('style', dom.serializeStyle(dom.parseStyle(formObj.style.value)));
108
+ dom.setAttrib(tr_elm, 'class', getSelectValue(formObj, 'class'));
109
+
110
+ // Clear deprecated attributes
111
+ tr_elm.setAttribute('background', '');
112
+ tr_elm.setAttribute('bgColor', '');
113
+ tr_elm.setAttribute('height', '');
114
+
115
+ // Set styles
116
+ tr_elm.style.height = getCSSSize(formObj.height.value);
117
+ tr_elm.style.backgroundColor = formObj.bgcolor.value;
118
+
119
+ if (formObj.backgroundimage.value != "")
120
+ tr_elm.style.backgroundImage = "url('" + formObj.backgroundimage.value + "')";
121
+ else
122
+ tr_elm.style.backgroundImage = '';
123
+
124
+ // Setup new rowtype
125
+ if (curRowType != rowtype && !skip_parent) {
126
+ // first, clone the node we are working on
127
+ var newRow = tr_elm.cloneNode(1);
128
+
129
+ // next, find the parent of its new destination (creating it if necessary)
130
+ var theTable = dom.getParent(tr_elm, "table");
131
+ var dest = rowtype;
132
+ var newParent = null;
133
+ for (var i = 0; i < theTable.childNodes.length; i++) {
134
+ if (theTable.childNodes[i].nodeName.toLowerCase() == dest)
135
+ newParent = theTable.childNodes[i];
136
+ }
137
+
138
+ if (newParent == null) {
139
+ newParent = doc.createElement(dest);
140
+
141
+ if (dest == "thead") {
142
+ if (theTable.firstChild.nodeName == 'CAPTION')
143
+ inst.dom.insertAfter(newParent, theTable.firstChild);
144
+ else
145
+ theTable.insertBefore(newParent, theTable.firstChild);
146
+ } else
147
+ theTable.appendChild(newParent);
148
+ }
149
+
150
+ // append the row to the new parent
151
+ newParent.appendChild(newRow);
152
+
153
+ // remove the original
154
+ tr_elm.parentNode.removeChild(tr_elm);
155
+
156
+ // set tr_elm to the new node
157
+ tr_elm = newRow;
158
+ }
159
+
160
+ dom.setAttrib(tr_elm, 'style', dom.serializeStyle(dom.parseStyle(tr_elm.style.cssText)));
161
+ }
162
+
163
+ function changedBackgroundImage() {
164
+ var formObj = document.forms[0], dom = tinyMCEPopup.editor.dom;
165
+ var st = dom.parseStyle(formObj.style.value);
166
+
167
+ st['background-image'] = "url('" + formObj.backgroundimage.value + "')";
168
+
169
+ formObj.style.value = dom.serializeStyle(st);
170
+ }
171
+
172
+ function changedStyle() {
173
+ var formObj = document.forms[0], dom = tinyMCEPopup.editor.dom;
174
+ var st = dom.parseStyle(formObj.style.value);
175
+
176
+ if (st['background-image'])
177
+ formObj.backgroundimage.value = st['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
178
+ else
179
+ formObj.backgroundimage.value = '';
180
+
181
+ if (st['height'])
182
+ formObj.height.value = trimSize(st['height']);
183
+
184
+ if (st['background-color']) {
185
+ formObj.bgcolor.value = st['background-color'];
186
+ updateColor('bgcolor_pick','bgcolor');
187
+ }
188
+ }
189
+
190
+ function changedSize() {
191
+ var formObj = document.forms[0], dom = tinyMCEPopup.editor.dom;
192
+ var st = dom.parseStyle(formObj.style.value);
193
+
194
+ var height = formObj.height.value;
195
+ if (height != "")
196
+ st['height'] = getCSSSize(height);
197
+ else
198
+ st['height'] = "";
199
+
200
+ formObj.style.value = dom.serializeStyle(st);
201
+ }
202
+
203
+ function changedColor() {
204
+ var formObj = document.forms[0], dom = tinyMCEPopup.editor.dom;
205
+ var st = dom.parseStyle(formObj.style.value);
206
+
207
+ st['background-color'] = formObj.bgcolor.value;
208
+
209
+ formObj.style.value = dom.serializeStyle(st);
210
+ }
211
+
212
+ tinyMCEPopup.onInit.add(init);
mce-table/js/table.js ADDED
@@ -0,0 +1,440 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tinyMCEPopup.requireLangPack();
2
+
3
+ var action, orgTableWidth, orgTableHeight, dom = tinyMCEPopup.editor.dom;
4
+
5
+ function insertTable() {
6
+ var formObj = document.forms[0];
7
+ var inst = tinyMCEPopup.editor, dom = inst.dom;
8
+ var cols = 2, rows = 2, border = 0, cellpadding = -1, cellspacing = -1, align, width, height, className, caption, frame, rules;
9
+ var html = '', capEl, elm;
10
+ var cellLimit, rowLimit, colLimit;
11
+
12
+ tinyMCEPopup.restoreSelection();
13
+
14
+ if (!AutoValidator.validate(formObj)) {
15
+ tinyMCEPopup.alert(inst.getLang('invalid_data'));
16
+ return false;
17
+ }
18
+
19
+ elm = dom.getParent(inst.selection.getNode(), 'table');
20
+
21
+ // Get form data
22
+ cols = formObj.elements['cols'].value;
23
+ rows = formObj.elements['rows'].value;
24
+ border = formObj.elements['border'].value != "" ? formObj.elements['border'].value : 0;
25
+ cellpadding = formObj.elements['cellpadding'].value != "" ? formObj.elements['cellpadding'].value : "";
26
+ cellspacing = formObj.elements['cellspacing'].value != "" ? formObj.elements['cellspacing'].value : "";
27
+ align = getSelectValue(formObj, "align");
28
+ frame = getSelectValue(formObj, "tframe");
29
+ rules = getSelectValue(formObj, "rules");
30
+ width = formObj.elements['width'].value;
31
+ height = formObj.elements['height'].value;
32
+ bordercolor = formObj.elements['bordercolor'].value;
33
+ bgcolor = formObj.elements['bgcolor'].value;
34
+ className = getSelectValue(formObj, "class");
35
+ id = formObj.elements['id'].value;
36
+ summary = formObj.elements['summary'].value;
37
+ style = formObj.elements['style'].value;
38
+ dir = formObj.elements['dir'].value;
39
+ lang = formObj.elements['lang'].value;
40
+ background = formObj.elements['backgroundimage'].value;
41
+ caption = formObj.elements['caption'].checked;
42
+
43
+ cellLimit = tinyMCEPopup.getParam('table_cell_limit', false);
44
+ rowLimit = tinyMCEPopup.getParam('table_row_limit', false);
45
+ colLimit = tinyMCEPopup.getParam('table_col_limit', false);
46
+
47
+ // Validate table size
48
+ if (colLimit && cols > colLimit) {
49
+ tinyMCEPopup.alert(inst.getLang('table_dlg.col_limit').replace(/\{\$cols\}/g, colLimit));
50
+ return false;
51
+ } else if (rowLimit && rows > rowLimit) {
52
+ tinyMCEPopup.alert(inst.getLang('table_dlg.row_limit').replace(/\{\$rows\}/g, rowLimit));
53
+ return false;
54
+ } else if (cellLimit && cols * rows > cellLimit) {
55
+ tinyMCEPopup.alert(inst.getLang('table_dlg.cell_limit').replace(/\{\$cells\}/g, cellLimit));
56
+ return false;
57
+ }
58
+
59
+ // Update table
60
+ if (action == "update") {
61
+ inst.execCommand('mceBeginUndoLevel');
62
+
63
+ dom.setAttrib(elm, 'cellPadding', cellpadding, true);
64
+ dom.setAttrib(elm, 'cellSpacing', cellspacing, true);
65
+ dom.setAttrib(elm, 'border', border);
66
+ dom.setAttrib(elm, 'align', align);
67
+ dom.setAttrib(elm, 'frame', frame);
68
+ dom.setAttrib(elm, 'rules', rules);
69
+ dom.setAttrib(elm, 'class', className);
70
+ dom.setAttrib(elm, 'style', style);
71
+ dom.setAttrib(elm, 'id', id);
72
+ dom.setAttrib(elm, 'summary', summary);
73
+ dom.setAttrib(elm, 'dir', dir);
74
+ dom.setAttrib(elm, 'lang', lang);
75
+
76
+ capEl = inst.dom.select('caption', elm)[0];
77
+
78
+ if (capEl && !caption)
79
+ capEl.parentNode.removeChild(capEl);
80
+
81
+ if (!capEl && caption) {
82
+ capEl = elm.ownerDocument.createElement('caption');
83
+
84
+ if (!tinymce.isIE)
85
+ capEl.innerHTML = '<br mce_bogus="1"/>';
86
+
87
+ elm.insertBefore(capEl, elm.firstChild);
88
+ }
89
+
90
+ if (width && inst.settings.inline_styles) {
91
+ dom.setStyle(elm, 'width', width);
92
+ dom.setAttrib(elm, 'width', '');
93
+ } else {
94
+ dom.setAttrib(elm, 'width', width, true);
95
+ dom.setStyle(elm, 'width', '');
96
+ }
97
+
98
+ // Remove these since they are not valid XHTML
99
+ dom.setAttrib(elm, 'borderColor', '');
100
+ dom.setAttrib(elm, 'bgColor', '');
101
+ dom.setAttrib(elm, 'background', '');
102
+
103
+ if (height && inst.settings.inline_styles) {
104
+ dom.setStyle(elm, 'height', height);
105
+ dom.setAttrib(elm, 'height', '');
106
+ } else {
107
+ dom.setAttrib(elm, 'height', height, true);
108
+ dom.setStyle(elm, 'height', '');
109
+ }
110
+
111
+ if (background != '')
112
+ elm.style.backgroundImage = "url('" + background + "')";
113
+ else
114
+ elm.style.backgroundImage = '';
115
+
116
+ /* if (tinyMCEPopup.getParam("inline_styles")) {
117
+ if (width != '')
118
+ elm.style.width = getCSSSize(width);
119
+ }*/
120
+
121
+ if (bordercolor != "") {
122
+ elm.style.borderColor = bordercolor;
123
+ elm.style.borderStyle = elm.style.borderStyle == "" ? "solid" : elm.style.borderStyle;
124
+ elm.style.borderWidth = border == "" ? "1px" : border;
125
+ } else
126
+ elm.style.borderColor = '';
127
+
128
+ elm.style.backgroundColor = bgcolor;
129
+ elm.style.height = getCSSSize(height);
130
+
131
+ inst.addVisual();
132
+
133
+ // Fix for stange MSIE align bug
134
+ //elm.outerHTML = elm.outerHTML;
135
+
136
+ inst.nodeChanged();
137
+ inst.execCommand('mceEndUndoLevel');
138
+
139
+ // Repaint if dimensions changed
140
+ if (formObj.width.value != orgTableWidth || formObj.height.value != orgTableHeight)
141
+ inst.execCommand('mceRepaint');
142
+
143
+ tinyMCEPopup.close();
144
+ return true;
145
+ }
146
+
147
+ // Create new table
148
+ html += '<table';
149
+
150
+ html += makeAttrib('id', id);
151
+ html += makeAttrib('border', border);
152
+ html += makeAttrib('cellpadding', cellpadding);
153
+ html += makeAttrib('cellspacing', cellspacing);
154
+
155
+ if (width && inst.settings.inline_styles) {
156
+ if (style)
157
+ style += '; ';
158
+
159
+ // Force px
160
+ if (/^[0-9\.]+$/.test(width))
161
+ width += 'px';
162
+
163
+ style += 'width: ' + width;
164
+ } else
165
+ html += makeAttrib('width', width);
166
+
167
+ /* if (height) {
168
+ if (style)
169
+ style += '; ';
170
+
171
+ style += 'height: ' + height;
172
+ }*/
173
+
174
+ //html += makeAttrib('height', height);
175
+ //html += makeAttrib('bordercolor', bordercolor);
176
+ //html += makeAttrib('bgcolor', bgcolor);
177
+ html += makeAttrib('align', align);
178
+ html += makeAttrib('frame', frame);
179
+ html += makeAttrib('rules', rules);
180
+ html += makeAttrib('class', className);
181
+ html += makeAttrib('style', style);
182
+ html += makeAttrib('summary', summary);
183
+ html += makeAttrib('dir', dir);
184
+ html += makeAttrib('lang', lang);
185
+ html += '>';
186
+
187
+ if (caption) {
188
+ if (!tinymce.isIE)
189
+ html += '<caption><br mce_bogus="1"/></caption>';
190
+ else
191
+ html += '<caption></caption>';
192
+ }
193
+
194
+ for (var y=0; y<rows; y++) {
195
+ html += "<tr>";
196
+
197
+ for (var x=0; x<cols; x++) {
198
+ if (!tinymce.isIE)
199
+ html += '<td><br mce_bogus="1"/></td>';
200
+ else
201
+ html += '<td></td>';
202
+ }
203
+
204
+ html += "</tr>";
205
+ }
206
+
207
+ html += "</table>";
208
+
209
+ inst.execCommand('mceBeginUndoLevel');
210
+
211
+ // Move table
212
+ if (inst.settings.fix_table_elements) {
213
+ var bm = inst.selection.getBookmark(), patt = '';
214
+
215
+ inst.execCommand('mceInsertContent', false, '<br class="_mce_marker" />');
216
+
217
+ tinymce.each('h1,h2,h3,h4,h5,h6,p'.split(','), function(n) {
218
+ if (patt)
219
+ patt += ',';
220
+
221
+ patt += n + ' ._mce_marker';
222
+ });
223
+
224
+ tinymce.each(inst.dom.select(patt), function(n) {
225
+ inst.dom.split(inst.dom.getParent(n, 'h1,h2,h3,h4,h5,h6,p'), n);
226
+ });
227
+
228
+ dom.setOuterHTML(dom.select('._mce_marker')[0], html);
229
+
230
+ inst.selection.moveToBookmark(bm);
231
+ } else
232
+ inst.execCommand('mceInsertContent', false, html);
233
+
234
+ inst.addVisual();
235
+ inst.execCommand('mceEndUndoLevel');
236
+
237
+ tinyMCEPopup.close();
238
+ }
239
+
240
+ function makeAttrib(attrib, value) {
241
+ var formObj = document.forms[0];
242
+ var valueElm = formObj.elements[attrib];
243
+
244
+ if (typeof(value) == "undefined" || value == null) {
245
+ value = "";
246
+
247
+ if (valueElm)
248
+ value = valueElm.value;
249
+ }
250
+
251
+ if (value == "")
252
+ return "";
253
+
254
+ // XML encode it
255
+ value = value.replace(/&/g, '&amp;');
256
+ value = value.replace(/\"/g, '&quot;');
257
+ value = value.replace(/</g, '&lt;');
258
+ value = value.replace(/>/g, '&gt;');
259
+
260
+ return ' ' + attrib + '="' + value + '"';
261
+ }
262
+
263
+ function init() {
264
+ tinyMCEPopup.resizeToInnerSize();
265
+
266
+ document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
267
+ document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
268
+ document.getElementById('bordercolor_pickcontainer').innerHTML = getColorPickerHTML('bordercolor_pick','bordercolor');
269
+ document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
270
+
271
+ var cols = 2, rows = 2, border = tinyMCEPopup.getParam('table_default_border', '0'), cellpadding = tinyMCEPopup.getParam('table_default_cellpadding', ''), cellspacing = tinyMCEPopup.getParam('table_default_cellspacing', '');
272
+ var align = "", width = "", height = "", bordercolor = "", bgcolor = "", className = "";
273
+ var id = "", summary = "", style = "", dir = "", lang = "", background = "", bgcolor = "", bordercolor = "", rules, frame;
274
+ var inst = tinyMCEPopup.editor, dom = inst.dom;
275
+ var formObj = document.forms[0];
276
+ var elm = dom.getParent(inst.selection.getNode(), "table");
277
+
278
+ action = tinyMCEPopup.getWindowArg('action');
279
+
280
+ if (!action)
281
+ action = elm ? "update" : "insert";
282
+
283
+ if (elm && action != "insert") {
284
+ var rowsAr = elm.rows;
285
+ var cols = 0;
286
+ for (var i=0; i<rowsAr.length; i++)
287
+ if (rowsAr[i].cells.length > cols)
288
+ cols = rowsAr[i].cells.length;
289
+
290
+ cols = cols;
291
+ rows = rowsAr.length;
292
+
293
+ st = dom.parseStyle(dom.getAttrib(elm, "style"));
294
+ border = trimSize(getStyle(elm, 'border', 'borderWidth'));
295
+ cellpadding = dom.getAttrib(elm, 'cellpadding', "");
296
+ cellspacing = dom.getAttrib(elm, 'cellspacing', "");
297
+ width = trimSize(getStyle(elm, 'width', 'width'));
298
+ height = trimSize(getStyle(elm, 'height', 'height'));
299
+ bordercolor = convertRGBToHex(getStyle(elm, 'bordercolor', 'borderLeftColor'));
300
+ bgcolor = convertRGBToHex(getStyle(elm, 'bgcolor', 'backgroundColor'));
301
+ align = dom.getAttrib(elm, 'align', align);
302
+ frame = dom.getAttrib(elm, 'frame');
303
+ rules = dom.getAttrib(elm, 'rules');
304
+ className = tinymce.trim(dom.getAttrib(elm, 'class').replace(/mceItem.+/g, ''));
305
+ id = dom.getAttrib(elm, 'id');
306
+ summary = dom.getAttrib(elm, 'summary');
307
+ style = dom.serializeStyle(st);
308
+ dir = dom.getAttrib(elm, 'dir');
309
+ lang = dom.getAttrib(elm, 'lang');
310
+ background = getStyle(elm, 'background', 'backgroundImage').replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
311
+ formObj.caption.checked = elm.getElementsByTagName('caption').length > 0;
312
+
313
+ orgTableWidth = width;
314
+ orgTableHeight = height;
315
+
316
+ action = "update";
317
+ formObj.insert.value = inst.getLang('update');
318
+ }
319
+
320
+ addClassesToList('class', "table_styles");
321
+ TinyMCE_EditableSelects.init();
322
+
323
+ // Update form
324
+ selectByValue(formObj, 'align', align);
325
+ selectByValue(formObj, 'tframe', frame);
326
+ selectByValue(formObj, 'rules', rules);
327
+ selectByValue(formObj, 'class', className, true, true);
328
+ formObj.cols.value = cols;
329
+ formObj.rows.value = rows;
330
+ formObj.border.value = border;
331
+ formObj.cellpadding.value = cellpadding;
332
+ formObj.cellspacing.value = cellspacing;
333
+ formObj.width.value = width;
334
+ formObj.height.value = height;
335
+ formObj.bordercolor.value = bordercolor;
336
+ formObj.bgcolor.value = bgcolor;
337
+ formObj.id.value = id;
338
+ formObj.summary.value = summary;
339
+ formObj.style.value = style;
340
+ formObj.dir.value = dir;
341
+ formObj.lang.value = lang;
342
+ formObj.backgroundimage.value = background;
343
+
344
+ updateColor('bordercolor_pick', 'bordercolor');
345
+ updateColor('bgcolor_pick', 'bgcolor');
346
+
347
+ // Resize some elements
348
+ if (isVisible('backgroundimagebrowser'))
349
+ document.getElementById('backgroundimage').style.width = '180px';
350
+
351
+ // Disable some fields in update mode
352
+ if (action == "update") {
353
+ formObj.cols.disabled = true;
354
+ formObj.rows.disabled = true;
355
+ }
356
+ }
357
+
358
+ function changedSize() {
359
+ var formObj = document.forms[0];
360
+ var st = dom.parseStyle(formObj.style.value);
361
+
362
+ /* var width = formObj.width.value;
363
+ if (width != "")
364
+ st['width'] = tinyMCEPopup.getParam("inline_styles") ? getCSSSize(width) : "";
365
+ else
366
+ st['width'] = "";*/
367
+
368
+ var height = formObj.height.value;
369
+ if (height != "")
370
+ st['height'] = getCSSSize(height);
371
+ else
372
+ st['height'] = "";
373
+
374
+ formObj.style.value = dom.serializeStyle(st);
375
+ }
376
+
377
+ function changedBackgroundImage() {
378
+ var formObj = document.forms[0];
379
+ var st = dom.parseStyle(formObj.style.value);
380
+
381
+ st['background-image'] = "url('" + formObj.backgroundimage.value + "')";
382
+
383
+ formObj.style.value = dom.serializeStyle(st);
384
+ }
385
+
386
+ function changedBorder() {
387
+ var formObj = document.forms[0];
388
+ var st = dom.parseStyle(formObj.style.value);
389
+
390
+ // Update border width if the element has a color
391
+ if (formObj.border.value != "" && formObj.bordercolor.value != "")
392
+ st['border-width'] = formObj.border.value + "px";
393
+
394
+ formObj.style.value = dom.serializeStyle(st);
395
+ }
396
+
397
+ function changedColor() {
398
+ var formObj = document.forms[0];
399
+ var st = dom.parseStyle(formObj.style.value);
400
+
401
+ st['background-color'] = formObj.bgcolor.value;
402
+
403
+ if (formObj.bordercolor.value != "") {
404
+ st['border-color'] = formObj.bordercolor.value;
405
+
406
+ // Add border-width if it's missing
407
+ if (!st['border-width'])
408
+ st['border-width'] = formObj.border.value == "" ? "1px" : formObj.border.value + "px";
409
+ }
410
+
411
+ formObj.style.value = dom.serializeStyle(st);
412
+ }
413
+
414
+ function changedStyle() {
415
+ var formObj = document.forms[0];
416
+ var st = dom.parseStyle(formObj.style.value);
417
+
418
+ if (st['background-image'])
419
+ formObj.backgroundimage.value = st['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
420
+ else
421
+ formObj.backgroundimage.value = '';
422
+
423
+ if (st['width'])
424
+ formObj.width.value = trimSize(st['width']);
425
+
426
+ if (st['height'])
427
+ formObj.height.value = trimSize(st['height']);
428
+
429
+ if (st['background-color']) {
430
+ formObj.bgcolor.value = st['background-color'];
431
+ updateColor('bgcolor_pick','bgcolor');
432
+ }
433
+
434
+ if (st['border-color']) {
435
+ formObj.bordercolor.value = st['border-color'];
436
+ updateColor('bordercolor_pick','bordercolor');
437
+ }
438
+ }
439
+
440
+ tinyMCEPopup.onInit.add(init);
mce-table/langs/en_dlg.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tinyMCE.addI18n('en.table_dlg',{
2
+ general_tab:"General",
3
+ advanced_tab:"Advanced",
4
+ general_props:"General properties",
5
+ advanced_props:"Advanced properties",
6
+ rowtype:"Row in table part",
7
+ title:"Insert/Modify table",
8
+ width:"Width",
9
+ height:"Height",
10
+ cols:"Cols",
11
+ rows:"Rows",
12
+ cellspacing:"Cellspacing",
13
+ cellpadding:"Cellpadding",
14
+ border:"Border",
15
+ align:"Alignment",
16
+ align_default:"Default",
17
+ align_left:"Left",
18
+ align_right:"Right",
19
+ align_middle:"Center",
20
+ row_title:"Table row properties",
21
+ cell_title:"Table cell properties",
22
+ cell_type:"Cell type",
23
+ valign:"Vertical alignment",
24
+ align_top:"Top",
25
+ align_bottom:"Bottom",
26
+ bordercolor:"Border color",
27
+ bgcolor:"Background color",
28
+ merge_cells_title:"Merge table cells",
29
+ id:"Id",
30
+ style:"Style",
31
+ langdir:"Language direction",
32
+ langcode:"Language code",
33
+ mime:"Target MIME type",
34
+ ltr:"Left to right",
35
+ rtl:"Right to left",
36
+ bgimage:"Background image",
37
+ summary:"Summary",
38
+ td:"Data",
39
+ th:"Header",
40
+ cell_cell:"Update current cell",
41
+ cell_row:"Update all cells in row",
42
+ cell_all:"Update all cells in table",
43
+ row_row:"Update current row",
44
+ row_odd:"Update odd rows in table",
45
+ row_even:"Update even rows in table",
46
+ row_all:"Update all rows in table",
47
+ thead:"Table Head",
48
+ tbody:"Table Body",
49
+ tfoot:"Table Foot",
50
+ scope:"Scope",
51
+ rowgroup:"Row Group",
52
+ colgroup:"Col Group",
53
+ col_limit:"You've exceeded the maximum number of columns of {$cols}.",
54
+ row_limit:"You've exceeded the maximum number of rows of {$rows}.",
55
+ cell_limit:"You've exceeded the maximum number of cells of {$cells}.",
56
+ missing_scope:"Are you sure you want to continue without specifying a scope for this table header cell. Without it, it may be difficult for some users with disabilities to understand the content or data displayed of the table.",
57
+ caption:"Table caption",
58
+ frame:"Frame",
59
+ frame_none:"none",
60
+ frame_groups:"groups",
61
+ frame_rows:"rows",
62
+ frame_cols:"cols",
63
+ frame_all:"all",
64
+ rules:"Rules",
65
+ rules_void:"void",
66
+ rules_above:"above",
67
+ rules_below:"below",
68
+ rules_hsides:"hsides",
69
+ rules_lhs:"lhs",
70
+ rules_rhs:"rhs",
71
+ rules_vsides:"vsides",
72
+ rules_box:"box",
73
+ rules_border:"border"
74
+ });
mce-table/merge_cells.htm ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <title>{#table_dlg.merge_cells_title}</title>
5
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/tiny_mce_popup.js"></script>
6
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/mctabs.js"></script>
7
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/validate.js"></script>
8
+ <script type="text/javascript" src="js/merge_cells.js"></script>
9
+ </head>
10
+ <body style="margin: 8px">
11
+ <form onsubmit="mergeCells();return false;" action="#">
12
+ <fieldset>
13
+ <legend>{#table_dlg.merge_cells_title}</legend>
14
+ <table border="0" cellpadding="0" cellspacing="3" width="100%">
15
+ <tr>
16
+ <td>{#table_dlg.cols}:</td>
17
+ <td align="right"><input type="text" name="numcols" value="" class="number min1 mceFocus" style="width: 30px" /></td>
18
+ </tr>
19
+ <tr>
20
+ <td>{#table_dlg.rows}:</td>
21
+ <td align="right"><input type="text" name="numrows" value="" class="number min1" style="width: 30px" /></td>
22
+ </tr>
23
+ </table>
24
+ </fieldset>
25
+
26
+ <div class="mceActionPanel">
27
+ <div style="float: left">
28
+ <input type="submit" id="insert" name="insert" value="{#update}" />
29
+ </div>
30
+
31
+ <div style="float: right">
32
+ <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
33
+ </div>
34
+ </div>
35
+ </form>
36
+ </body>
37
+ </html>
mce-table/row.htm ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <title>{#table_dlg.row_title}</title>
5
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/tiny_mce_popup.js"></script>
6
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/mctabs.js"></script>
7
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/form_utils.js"></script>
8
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/editable_selects.js"></script>
9
+ <script type="text/javascript" src="js/row.js"></script>
10
+ <link href="css/row.css" rel="stylesheet" type="text/css" />
11
+ </head>
12
+ <body id="tablerow" style="display: none">
13
+ <form onsubmit="updateAction();return false;" action="#">
14
+ <div class="tabs">
15
+ <ul>
16
+ <li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#table_dlg.general_tab}</a></span></li>
17
+ <li id="advanced_tab"><span><a href="javascript:mcTabs.displayTab('advanced_tab','advanced_panel');" onmousedown="return false;">{#table_dlg.advanced_tab}</a></span></li>
18
+ </ul>
19
+ </div>
20
+
21
+ <div class="panel_wrapper">
22
+ <div id="general_panel" class="panel current">
23
+ <fieldset>
24
+ <legend>{#table_dlg.general_props}</legend>
25
+
26
+ <table border="0" cellpadding="4" cellspacing="0">
27
+ <tr>
28
+ <td><label for="rowtype">{#table_dlg.rowtype}</label></td>
29
+ <td class="col2">
30
+ <select id="rowtype" name="rowtype" class="mceFocus">
31
+ <option value="thead">{#table_dlg.thead}</option>
32
+ <option value="tbody">{#table_dlg.tbody}</option>
33
+ <option value="tfoot">{#table_dlg.tfoot}</option>
34
+ </select>
35
+ </td>
36
+ </tr>
37
+
38
+ <tr>
39
+ <td><label for="align">{#table_dlg.align}</label></td>
40
+ <td class="col2">
41
+ <select id="align" name="align">
42
+ <option value="">{#not_set}</option>
43
+ <option value="center">{#table_dlg.align_middle}</option>
44
+ <option value="left">{#table_dlg.align_left}</option>
45
+ <option value="right">{#table_dlg.align_right}</option>
46
+ </select>
47
+ </td>
48
+ </tr>
49
+
50
+ <tr>
51
+ <td><label for="valign">{#table_dlg.valign}</label></td>
52
+ <td class="col2">
53
+ <select id="valign" name="valign">
54
+ <option value="">{#not_set}</option>
55
+ <option value="top">{#table_dlg.align_top}</option>
56
+ <option value="middle">{#table_dlg.align_middle}</option>
57
+ <option value="bottom">{#table_dlg.align_bottom}</option>
58
+ </select>
59
+ </td>
60
+ </tr>
61
+
62
+ <tr id="styleSelectRow">
63
+ <td><label for="class">{#class_name}</label></td>
64
+ <td class="col2">
65
+ <select id="class" name="class" class="mceEditableSelect">
66
+ <option value="" selected="selected">{#not_set}</option>
67
+ </select>
68
+ </td>
69
+ </tr>
70
+
71
+ <tr>
72
+ <td><label for="height">{#table_dlg.height}</label></td>
73
+ <td class="col2"><input name="height" type="text" id="height" value="" size="4" maxlength="4" onchange="changedSize();" /></td>
74
+ </tr>
75
+ </table>
76
+ </fieldset>
77
+ </div>
78
+
79
+ <div id="advanced_panel" class="panel">
80
+ <fieldset>
81
+ <legend>{#table_dlg.advanced_props}</legend>
82
+
83
+ <table border="0" cellpadding="0" cellspacing="4">
84
+ <tr>
85
+ <td class="column1"><label for="id">{#table_dlg.id}</label></td>
86
+ <td><input id="id" name="id" type="text" value="" style="width: 200px" /></td>
87
+ </tr>
88
+
89
+ <tr>
90
+ <td><label for="style">{#table_dlg.style}</label></td>
91
+ <td><input type="text" id="style" name="style" value="" style="width: 200px;" onchange="changedStyle();" /></td>
92
+ </tr>
93
+
94
+ <tr>
95
+ <td class="column1"><label for="dir">{#table_dlg.langdir}</label></td>
96
+ <td>
97
+ <select id="dir" name="dir" style="width: 200px">
98
+ <option value="">{#not_set}</option>
99
+ <option value="ltr">{#table_dlg.ltr}</option>
100
+ <option value="rtl">{#table_dlg.rtl}</option>
101
+ </select>
102
+ </td>
103
+ </tr>
104
+
105
+ <tr>
106
+ <td class="column1"><label for="lang">{#table_dlg.langcode}</label></td>
107
+ <td>
108
+ <input id="lang" name="lang" type="text" value="" style="width: 200px" />
109
+ </td>
110
+ </tr>
111
+
112
+ <tr>
113
+ <td class="column1"><label for="backgroundimage">{#table_dlg.bgimage}</label></td>
114
+ <td>
115
+ <table border="0" cellpadding="0" cellspacing="0">
116
+ <tr>
117
+ <td><input id="backgroundimage" name="backgroundimage" type="text" value="" style="width: 200px" onchange="changedBackgroundImage();" /></td>
118
+ <td id="backgroundimagebrowsercontainer">&nbsp;</td>
119
+ </tr>
120
+ </table>
121
+ </td>
122
+ </tr>
123
+
124
+ <tr>
125
+ <td class="column1"><label for="bgcolor">{#table_dlg.bgcolor}</label></td>
126
+ <td>
127
+ <table border="0" cellpadding="0" cellspacing="0">
128
+ <tr>
129
+ <td><input id="bgcolor" name="bgcolor" type="text" value="" size="9" onchange="updateColor('bgcolor_pick','bgcolor');changedColor();" /></td>
130
+ <td id="bgcolor_pickcontainer">&nbsp;</td>
131
+ </tr>
132
+ </table>
133
+ </td>
134
+ </tr>
135
+ </table>
136
+ </fieldset>
137
+ </div>
138
+ </div>
139
+
140
+ <div class="mceActionPanel">
141
+ <div>
142
+ <select id="action" name="action">
143
+ <option value="row">{#table_dlg.row_row}</option>
144
+ <option value="odd">{#table_dlg.row_odd}</option>
145
+ <option value="even">{#table_dlg.row_even}</option>
146
+ <option value="all">{#table_dlg.row_all}</option>
147
+ </select>
148
+ </div>
149
+
150
+ <div style="float: left">
151
+ <div><input type="submit" id="insert" name="insert" value="{#update}" /></div>
152
+ </div>
153
+
154
+ <div style="float: right">
155
+ <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
156
+ </div>
157
+ </div>
158
+ </form>
159
+ </body>
160
+ </html>
mce-table/table.htm ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <title>{#table_dlg.title}</title>
5
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/tiny_mce_popup.js"></script>
6
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/mctabs.js"></script>
7
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/form_utils.js"></script>
8
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/validate.js"></script>
9
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/utils/editable_selects.js"></script>
10
+ <script type="text/javascript" src="js/table.js"></script>
11
+ <link href="css/table.css" rel="stylesheet" type="text/css" />
12
+ </head>
13
+ <body id="table" style="display: none">
14
+ <form onsubmit="insertTable();return false;" action="#">
15
+ <div class="tabs">
16
+ <ul>
17
+ <li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#table_dlg.general_tab}</a></span></li>
18
+ <li id="advanced_tab"><span><a href="javascript:mcTabs.displayTab('advanced_tab','advanced_panel');" onmousedown="return false;">{#table_dlg.advanced_tab}</a></span></li>
19
+ </ul>
20
+ </div>
21
+
22
+ <div class="panel_wrapper">
23
+ <div id="general_panel" class="panel current">
24
+ <fieldset>
25
+ <legend>{#table_dlg.general_props}</legend>
26
+ <table border="0" cellpadding="4" cellspacing="0" width="100%">
27
+ <tr>
28
+ <td><label id="colslabel" for="cols">{#table_dlg.cols}</label></td>
29
+ <td><input id="cols" name="cols" type="text" value="" size="3" maxlength="3" class="required number min1 mceFocus" /></td>
30
+ <td><label id="rowslabel" for="rows">{#table_dlg.rows}</label></td>
31
+ <td><input id="rows" name="rows" type="text" value="" size="3" maxlength="3" class="required number min1" /></td>
32
+ </tr>
33
+ <tr>
34
+ <td><label id="cellpaddinglabel" for="cellpadding">{#table_dlg.cellpadding}</label></td>
35
+ <td><input id="cellpadding" name="cellpadding" type="text" value="" size="3" maxlength="3" class="number" /></td>
36
+ <td><label id="cellspacinglabel" for="cellspacing">{#table_dlg.cellspacing}</label></td>
37
+ <td><input id="cellspacing" name="cellspacing" type="text" value="" size="3" maxlength="3" class="number" /></td>
38
+ </tr>
39
+ <tr>
40
+ <td><label id="alignlabel" for="align">{#table_dlg.align}</label></td>
41
+ <td><select id="align" name="align">
42
+ <option value="">{#not_set}</option>
43
+ <option value="center">{#table_dlg.align_middle}</option>
44
+ <option value="left">{#table_dlg.align_left}</option>
45
+ <option value="right">{#table_dlg.align_right}</option>
46
+ </select></td>
47
+ <td><label id="borderlabel" for="border">{#table_dlg.border}</label></td>
48
+ <td><input id="border" name="border" type="text" value="" size="3" maxlength="3" onchange="changedBorder();" class="number" /></td>
49
+ </tr>
50
+ <tr id="width_row">
51
+ <td><label id="widthlabel" for="width">{#table_dlg.width}</label></td>
52
+ <td><input name="width" type="text" id="width" value="" size="4" maxlength="4" onchange="changedSize();" class="size" /></td>
53
+ <td><label id="heightlabel" for="height">{#table_dlg.height}</label></td>
54
+ <td><input name="height" type="text" id="height" value="" size="4" maxlength="4" onchange="changedSize();" class="size" /></td>
55
+ </tr>
56
+ <tr id="styleSelectRow">
57
+ <td><label id="classlabel" for="class">{#class_name}</label></td>
58
+ <td colspan="3">
59
+ <select id="class" name="class" class="mceEditableSelect">
60
+ <option value="" selected="selected">{#not_set}</option>
61
+ </select></td>
62
+ </tr>
63
+ <tr>
64
+ <td class="column1"><label for="caption">{#table_dlg.caption}</label></td>
65
+ <td><input id="caption" name="caption" type="checkbox" class="checkbox" value="true" /></td>
66
+ </tr>
67
+ </table>
68
+ </fieldset>
69
+ </div>
70
+
71
+ <div id="advanced_panel" class="panel">
72
+ <fieldset>
73
+ <legend>{#table_dlg.advanced_props}</legend>
74
+
75
+ <table border="0" cellpadding="0" cellspacing="4">
76
+ <tr>
77
+ <td class="column1"><label for="id">{#table_dlg.id}</label></td>
78
+ <td><input id="id" name="id" type="text" value="" class="advfield" /></td>
79
+ </tr>
80
+
81
+ <tr>
82
+ <td class="column1"><label for="summary">{#table_dlg.summary}</label></td>
83
+ <td><input id="summary" name="summary" type="text" value="" class="advfield" /></td>
84
+ </tr>
85
+
86
+ <tr>
87
+ <td><label for="style">{#table_dlg.style}</label></td>
88
+ <td><input type="text" id="style" name="style" value="" class="advfield" onchange="changedStyle();" /></td>
89
+ </tr>
90
+
91
+ <tr>
92
+ <td class="column1"><label id="langlabel" for="lang">{#table_dlg.langcode}</label></td>
93
+ <td>
94
+ <input id="lang" name="lang" type="text" value="" class="advfield" />
95
+ </td>
96
+ </tr>
97
+
98
+ <tr>
99
+ <td class="column1"><label for="backgroundimage">{#table_dlg.bgimage}</label></td>
100
+ <td>
101
+ <table border="0" cellpadding="0" cellspacing="0">
102
+ <tr>
103
+ <td><input id="backgroundimage" name="backgroundimage" type="text" value="" class="advfield" onchange="changedBackgroundImage();" /></td>
104
+ <td id="backgroundimagebrowsercontainer">&nbsp;</td>
105
+ </tr>
106
+ </table>
107
+ </td>
108
+ </tr>
109
+
110
+ <tr>
111
+ <td class="column1"><label for="tframe">{#table_dlg.frame}</label></td>
112
+ <td>
113
+ <select id="tframe" name="tframe" class="advfield">
114
+ <option value="">{#not_set}</option>
115
+ <option value="void">{#table_dlg.rules_void}</option>
116
+ <option value="above">{#table_dlg.rules_above}</option>
117
+ <option value="below">{#table_dlg.rules_below}</option>
118
+ <option value="hsides">{#table_dlg.rules_hsides}</option>
119
+ <option value="lhs">{#table_dlg.rules_lhs}</option>
120
+ <option value="rhs">{#table_dlg.rules_rhs}</option>
121
+ <option value="vsides">{#table_dlg.rules_vsides}</option>
122
+ <option value="box">{#table_dlg.rules_box}</option>
123
+ <option value="border">{#table_dlg.rules_border}</option>
124
+ </select>
125
+ </td>
126
+ </tr>
127
+
128
+ <tr>
129
+ <td class="column1"><label for="rules">{#table_dlg.rules}</label></td>
130
+ <td>
131
+ <select id="rules" name="rules" class="advfield">
132
+ <option value="">{#not_set}</option>
133
+ <option value="none">{#table_dlg.frame_none}</option>
134
+ <option value="groups">{#table_dlg.frame_groups}</option>
135
+ <option value="rows">{#table_dlg.frame_rows}</option>
136
+ <option value="cols">{#table_dlg.frame_cols}</option>
137
+ <option value="all">{#table_dlg.frame_all}</option>
138
+ </select>
139
+ </td>
140
+ </tr>
141
+
142
+ <tr>
143
+ <td class="column1"><label for="dir">{#table_dlg.langdir}</label></td>
144
+ <td>
145
+ <select id="dir" name="dir" class="advfield">
146
+ <option value="">{#not_set}</option>
147
+ <option value="ltr">{#table_dlg.ltr}</option>
148
+ <option value="rtl">{#table_dlg.rtl}</option>
149
+ </select>
150
+ </td>
151
+ </tr>
152
+
153
+ <tr>
154
+ <td class="column1"><label for="bordercolor">{#table_dlg.bordercolor}</label></td>
155
+ <td>
156
+ <table border="0" cellpadding="0" cellspacing="0">
157
+ <tr>
158
+ <td><input id="bordercolor" name="bordercolor" type="text" value="" size="9" onchange="updateColor('bordercolor_pick','bordercolor');changedColor();" /></td>
159
+ <td id="bordercolor_pickcontainer">&nbsp;</td>
160
+ </tr>
161
+ </table>
162
+ </td>
163
+ </tr>
164
+
165
+ <tr>
166
+ <td class="column1"><label for="bgcolor">{#table_dlg.bgcolor}</label></td>
167
+ <td>
168
+ <table border="0" cellpadding="0" cellspacing="0">
169
+ <tr>
170
+ <td><input id="bgcolor" name="bgcolor" type="text" value="" size="9" onchange="updateColor('bgcolor_pick','bgcolor');changedColor();" /></td>
171
+ <td id="bgcolor_pickcontainer">&nbsp;</td>
172
+ </tr>
173
+ </table>
174
+ </td>
175
+ </tr>
176
+ </table>
177
+ </fieldset>
178
+ </div>
179
+ </div>
180
+
181
+ <div class="mceActionPanel">
182
+ <div style="float: left">
183
+ <input type="submit" id="insert" name="insert" value="{#insert}" />
184
+ </div>
185
+
186
+ <div style="float: right">
187
+ <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
188
+ </div>
189
+ </div>
190
+ </form>
191
+ </body>
192
+ </html>
mce-table/table_plugin.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(){var b=tinymce.each;function a(d,e){var f=e.ownerDocument,c=f.createRange(),g;c.setStartBefore(e);c.setEnd(d.endContainer,d.endOffset);g=f.createElement("body");g.appendChild(c.cloneContents());return g.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length==0}tinymce.create("tinymce.plugins.TablePlugin",{init:function(c,d){var e=this;e.editor=c;e.url=d;b([["table","table.desc","mceInsertTable",true],["delete_table","table.del","mceTableDelete"],["delete_col","table.delete_col_desc","mceTableDeleteCol"],["delete_row","table.delete_row_desc","mceTableDeleteRow"],["col_after","table.col_after_desc","mceTableInsertColAfter"],["col_before","table.col_before_desc","mceTableInsertColBefore"],["row_after","table.row_after_desc","mceTableInsertRowAfter"],["row_before","table.row_before_desc","mceTableInsertRowBefore"],["row_props","table.row_desc","mceTableRowProps",true],["cell_props","table.cell_desc","mceTableCellProps",true],["split_cells","table.split_cells_desc","mceTableSplitCells",true],["merge_cells","table.merge_cells_desc","mceTableMergeCells",true]],function(f){c.addButton(f[0],{title:f[1],cmd:f[2],ui:f[3]})});if(c.getParam("inline_styles")){c.onPreProcess.add(function(f,h){var g=f.dom;b(g.select("table",h.node),function(j){var i;if(i=g.getAttrib(j,"width")){g.setStyle(j,"width",i);g.setAttrib(j,"width")}if(i=g.getAttrib(j,"height")){g.setStyle(j,"height",i);g.setAttrib(j,"height")}})})}c.onInit.add(function(){if(!tinymce.isIE&&c.getParam("forced_root_block")){function f(){var g=c.getBody().lastChild;if(g&&g.nodeName=="TABLE"){c.dom.add(c.getBody(),"p",null,'<br mce_bogus="1" />')}}if(tinymce.isGecko){c.onKeyDown.add(function(h,j){var g,i,k=h.dom;if(j.keyCode==37||j.keyCode==38){g=h.selection.getRng();i=k.getParent(g.startContainer,"table");if(i&&h.getBody().firstChild==i){if(a(g,i)){g=k.createRng();g.setStartBefore(i);g.setEndBefore(i);h.selection.setRng(g);j.preventDefault()}}}})}c.onKeyUp.add(f);c.onSetContent.add(f);c.onVisualAid.add(f);c.onPreProcess.add(function(g,i){var h=i.node.lastChild;if(h&&h.childNodes.length==1&&h.firstChild.nodeName=="BR"){g.dom.remove(h)}});f()}if(c&&c.plugins.contextmenu){c.plugins.contextmenu.onContextMenu.add(function(i,g,k){var l,j=c.selection,h=j.getNode()||c.getBody();if(c.dom.getParent(k,"td")||c.dom.getParent(k,"th")){g.removeAll();if(h.nodeName=="A"&&!c.dom.getAttrib(h,"name")){g.add({title:"advanced.link_desc",icon:"link",cmd:c.plugins.advlink?"mceAdvLink":"mceLink",ui:true});g.add({title:"advanced.unlink_desc",icon:"unlink",cmd:"UnLink"});g.addSeparator()}if(h.nodeName=="IMG"&&h.className.indexOf("mceItem")==-1){g.add({title:"advanced.image_desc",icon:"image",cmd:c.plugins.advimage?"mceAdvImage":"mceImage",ui:true});g.addSeparator()}g.add({title:"table.desc",icon:"table",cmd:"mceInsertTable",ui:true,value:{action:"insert"}});g.add({title:"table.props_desc",icon:"table_props",cmd:"mceInsertTable",ui:true});g.add({title:"table.del",icon:"delete_table",cmd:"mceTableDelete",ui:true});g.addSeparator();l=g.addMenu({title:"table.cell"});l.add({title:"table.cell_desc",icon:"cell_props",cmd:"mceTableCellProps",ui:true});l.add({title:"table.split_cells_desc",icon:"split_cells",cmd:"mceTableSplitCells",ui:true});l.add({title:"table.merge_cells_desc",icon:"merge_cells",cmd:"mceTableMergeCells",ui:true});l=g.addMenu({title:"table.row"});l.add({title:"table.row_desc",icon:"row_props",cmd:"mceTableRowProps",ui:true});l.add({title:"table.row_before_desc",icon:"row_before",cmd:"mceTableInsertRowBefore"});l.add({title:"table.row_after_desc",icon:"row_after",cmd:"mceTableInsertRowAfter"});l.add({title:"table.delete_row_desc",icon:"delete_row",cmd:"mceTableDeleteRow"});l.addSeparator();l.add({title:"table.cut_row_desc",icon:"cut",cmd:"mceTableCutRow"});l.add({title:"table.copy_row_desc",icon:"copy",cmd:"mceTableCopyRow"});l.add({title:"table.paste_row_before_desc",icon:"paste",cmd:"mceTablePasteRowBefore"});l.add({title:"table.paste_row_after_desc",icon:"paste",cmd:"mceTablePasteRowAfter"});l=g.addMenu({title:"table.col"});l.add({title:"table.col_before_desc",icon:"col_before",cmd:"mceTableInsertColBefore"});l.add({title:"table.col_after_desc",icon:"col_after",cmd:"mceTableInsertColAfter"});l.add({title:"table.delete_col_desc",icon:"delete_col",cmd:"mceTableDeleteCol"})}else{g.add({title:"table.desc",icon:"table",cmd:"mceInsertTable",ui:true})}})}});c.onKeyDown.add(function(f,g){if(g.keyCode==9&&f.dom.getParent(f.selection.getNode(),"TABLE")){if(!tinymce.isGecko&&!tinymce.isOpera){tinyMCE.execInstanceCommand(f.editorId,"mceTableMoveToNextRow",true);return tinymce.dom.Event.cancel(g)}f.undoManager.add()}});if(!tinymce.isIE){if(c.getParam("table_selection",true)){c.onClick.add(function(f,g){g=g.target;if(g.nodeName==="TABLE"){f.selection.select(g)}})}}c.onNodeChange.add(function(g,f,i){var h=g.dom.getParent(i,"td,th,caption");f.setActive("table",i.nodeName==="TABLE"||!!h);if(h&&h.nodeName==="CAPTION"){h=null}f.setDisabled("delete_table",!h);f.setDisabled("delete_col",!h);f.setDisabled("delete_table",!h);f.setDisabled("delete_row",!h);f.setDisabled("col_after",!h);f.setDisabled("col_before",!h);f.setDisabled("row_after",!h);f.setDisabled("row_before",!h);f.setDisabled("row_props",!h);f.setDisabled("cell_props",!h);f.setDisabled("split_cells",!h||(parseInt(g.dom.getAttrib(h,"colspan","1"))<2&&parseInt(g.dom.getAttrib(h,"rowspan","1"))<2));f.setDisabled("merge_cells",!h)});if(!tinymce.isIE){c.onBeforeSetContent.add(function(f,g){if(g.initial){g.content=g.content.replace(/<(td|th)([^>]+|)>\s*<\/(td|th)>/g,tinymce.isOpera?"<$1$2>&nbsp;</$1>":'<$1$2><br mce_bogus="1" /></$1>')}})}},execCommand:function(f,e,g){var d=this.editor,c;switch(f){case"mceTableMoveToNextRow":case"mceInsertTable":case"mceTableRowProps":case"mceTableCellProps":case"mceTableSplitCells":case"mceTableMergeCells":case"mceTableInsertRowBefore":case"mceTableInsertRowAfter":case"mceTableDeleteRow":case"mceTableInsertColBefore":case"mceTableInsertColAfter":case"mceTableDeleteCol":case"mceTableCutRow":case"mceTableCopyRow":case"mceTablePasteRowBefore":case"mceTablePasteRowAfter":case"mceTableDelete":d.execCommand("mceBeginUndoLevel");this._doExecCommand(f,e,g);d.execCommand("mceEndUndoLevel");return true}return false},getInfo:function(){return{longname:"Tables",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/table",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_doExecCommand:function(s,aa,af){var W=this.editor,av=W,h=this.url;var o=W.selection.getNode();var X=W.dom.getParent(o,"tr");var ar=W.dom.getParent(o,"td,th");var G=W.dom.getParent(o,"table");var l=W.contentWindow.document;var aw=G?G.getAttribute("border"):"";if(X&&ar==null){ar=X.cells[0]}function aq(y,x){for(var ay=0;ay<y.length;ay++){if(y[ay].length>0&&aq(y[ay],x)){return true}if(y[ay]==x){return true}}return false}function ak(x,i){var y;ae=f(G);x=x||0;i=i||0;x=Math.max(p.cellindex+x,0);i=Math.max(p.rowindex+i,0);W.execCommand("mceRepaint");y=e(ae,i,x);if(y){W.selection.select(y.firstChild||y);W.selection.collapse(1)}}function ai(){var i=l.createElement("td");if(!tinymce.isIE){i.innerHTML='<br mce_bogus="1"/>'}}function k(y){var x=W.dom.getAttrib(y,"colspan");var i=W.dom.getAttrib(y,"rowspan");x=x==""?1:parseInt(x);i=i==""?1:parseInt(i);return{colspan:x,rowspan:i}}function am(ay,aA){var i,az;for(az=0;az<ay.length;az++){for(i=0;i<ay[az].length;i++){if(ay[az][i]==aA){return{cellindex:i,rowindex:az}}}}return null}function e(x,y,i){if(x[y]&&x[y][i]){return x[y][i]}return null}function B(aD,ay){var aA=[],y=0,aB,az,ay,aC;for(aB=0;aB<aD.rows.length;aB++){for(az=0;az<aD.rows[aB].cells.length;az++,y++){aA[y]=aD.rows[aB].cells[az]}}for(aB=0;aB<aA.length;aB++){if(aA[aB]==ay){if(aC=aA[aB+1]){return aC}}}}function f(aF){var i=[],aG=aF.rows,aD,aC,az,aA,aE,ay,aB;for(aC=0;aC<aG.length;aC++){for(aD=0;aD<aG[aC].cells.length;aD++){az=aG[aC].cells[aD];aA=k(az);for(aE=aD;i[aC]&&i[aC][aE];aE++){}for(aB=aC;aB<aC+aA.rowspan;aB++){if(!i[aB]){i[aB]=[]}for(ay=aE;ay<aE+aA.colspan;ay++){i[aB][ay]=az}}}}return i}function n(aH,aE,az,ay){var y=f(aH),aG=am(y,az);var aI,aD;if(ay.cells.length!=aE.childNodes.length){aI=aE.childNodes;aD=null;for(var aF=0;az=e(y,aG.rowindex,aF);aF++){var aB=true;var aC=k(az);if(aq(aI,az)){ay.childNodes[aF]._delete=true}else{if((aD==null||az!=aD)&&aC.colspan>1){for(var aA=aF;aA<aF+az.colSpan;aA++){ay.childNodes[aA]._delete=true}}}if((aD==null||az!=aD)&&aC.rowspan>1){az.rowSpan=aC.rowspan+1}aD=az}C(G)}}function P(x,i){while((x=x.previousSibling)!=null){if(x.nodeName==i){return x}}return null}function ag(ay,az){var x=az.split(",");while((ay=ay.nextSibling)!=null){for(var y=0;y<x.length;y++){if(ay.nodeName.toLowerCase()==x[y].toLowerCase()){return ay}}}return null}function C(ay){if(ay.rows==0){return}var y=ay.rows[0];do{var x=ag(y,"TR");if(y._delete){y.parentNode.removeChild(y);continue}var az=y.cells[0];if(az.cells>1){do{var i=ag(az,"TD,TH");if(az._delete){az.parentNode.removeChild(az)}}while((az=i)!=null)}}while((y=x)!=null)}function q(ay,aB,aA){ay.rowSpan=1;var x=ag(aB,"TR");for(var az=1;az<aA&&x;az++){var y=l.createElement("td");if(!tinymce.isIE){y.innerHTML='<br mce_bogus="1"/>'}if(tinymce.isIE){x.insertBefore(y,x.cells(ay.cellIndex))}else{x.insertBefore(y,x.cells[ay.cellIndex])}x=ag(x,"TR")}}function T(aG,aI,aC){var y=f(aI);var ay=aC.cloneNode(false);var aH=am(y,aC.cells[0]);var aD=null;var aB=W.dom.getAttrib(aI,"border");var aA=null;for(var aF=0;aA=e(y,aH.rowindex,aF);aF++){var aE=null;if(aD!=aA){for(var az=0;az<aC.cells.length;az++){if(aA==aC.cells[az]){aE=aA.cloneNode(true);break}}}if(aE==null){aE=aG.createElement("td");if(!tinymce.isIE){aE.innerHTML='<br mce_bogus="1"/>'}}aE.colSpan=1;aE.rowSpan=1;ay.appendChild(aE);aD=aA}return ay}switch(s){case"mceTableMoveToNextRow":var M=B(G,ar);if(!M){W.execCommand("mceTableInsertRowAfter",ar);M=B(G,ar)}W.selection.select(M);W.selection.collapse(true);return true;case"mceTableRowProps":if(X==null){return true}if(aa){W.windowManager.open({url:h+"/row.htm",width:400+parseInt(W.getLang("table.rowprops_delta_width",0)),height:295+parseInt(W.getLang("table.rowprops_delta_height",0)),inline:1},{plugin_url:h})}return true;case"mceTableCellProps":if(ar==null){return true}if(aa){W.windowManager.open({url:h+"/cell.htm",width:400+parseInt(W.getLang("table.cellprops_delta_width",0)),height:295+parseInt(W.getLang("table.cellprops_delta_height",0)),inline:1},{plugin_url:h})}return true;case"mceInsertTable":if(aa){W.windowManager.open({url:h+"/table.htm",width:400+parseInt(W.getLang("table.table_delta_width",0)),height:320+parseInt(W.getLang("table.table_delta_height",0)),inline:1},{plugin_url:h,action:af?af.action:0})}return true;case"mceTableDelete":var H=W.dom.getParent(W.selection.getNode(),"table");if(H){H.parentNode.removeChild(H);W.execCommand("mceRepaint")}return true;case"mceTableSplitCells":case"mceTableMergeCells":case"mceTableInsertRowBefore":case"mceTableInsertRowAfter":case"mceTableDeleteRow":case"mceTableInsertColBefore":case"mceTableInsertColAfter":case"mceTableDeleteCol":case"mceTableCutRow":case"mceTableCopyRow":case"mceTablePasteRowBefore":case"mceTablePasteRowAfter":if(!G){return true}if(X&&G!=X.parentNode){G=X.parentNode}if(G&&X){switch(s){case"mceTableCutRow":if(!X||!ar){return true}W.tableRowClipboard=T(l,G,X);W.execCommand("mceTableDeleteRow");break;case"mceTableCopyRow":if(!X||!ar){return true}W.tableRowClipboard=T(l,G,X);break;case"mceTablePasteRowBefore":if(!X||!ar){return true}var w=W.tableRowClipboard.cloneNode(true);var j=P(X,"TR");if(j!=null){n(G,j,j.cells[0],w)}X.parentNode.insertBefore(w,X);break;case"mceTablePasteRowAfter":if(!X||!ar){return true}var Y=ag(X,"TR");var w=W.tableRowClipboard.cloneNode(true);n(G,X,ar,w);if(Y==null){X.parentNode.appendChild(w)}else{Y.parentNode.insertBefore(w,Y)}break;case"mceTableInsertRowBefore":if(!X||!ar){return true}var ae=f(G);var p=am(ae,ar);var w=l.createElement("tr");var v=null;p.rowindex--;if(p.rowindex<0){p.rowindex=0}for(var ad=0;ar=e(ae,p.rowindex,ad);ad++){if(ar!=v){var F=k(ar);if(F.rowspan==1){var K=l.createElement("td");if(!tinymce.isIE){K.innerHTML='<br mce_bogus="1"/>'}K.colSpan=ar.colSpan;w.appendChild(K)}else{ar.rowSpan=F.rowspan+1}v=ar}}X.parentNode.insertBefore(w,X);ak(0,1);break;case"mceTableInsertRowAfter":if(!X||!ar){return true}var ae=f(G);var p=am(ae,ar);var w=l.createElement("tr");var v=null;for(var ad=0;ar=e(ae,p.rowindex,ad);ad++){if(ar!=v){var F=k(ar);if(F.rowspan==1){var K=l.createElement("td");if(!tinymce.isIE){K.innerHTML='<br mce_bogus="1"/>'}K.colSpan=ar.colSpan;w.appendChild(K)}else{ar.rowSpan=F.rowspan+1}v=ar}}if(w.hasChildNodes()){var Y=ag(X,"TR");if(Y){Y.parentNode.insertBefore(w,Y)}else{G.appendChild(w)}}ak(0,1);break;case"mceTableDeleteRow":if(!X||!ar){return true}var ae=f(G);var p=am(ae,ar);if(ae.length==1&&G.nodeName=="TBODY"){W.dom.remove(W.dom.getParent(G,"table"));return true}var E=X.cells;var Y=ag(X,"TR");for(var ad=0;ad<E.length;ad++){if(E[ad].rowSpan>1){var K=E[ad].cloneNode(true);var F=k(E[ad]);K.rowSpan=F.rowspan-1;var al=Y.cells[ad];if(al==null){Y.appendChild(K)}else{Y.insertBefore(K,al)}}}var v=null;for(var ad=0;ar=e(ae,p.rowindex,ad);ad++){if(ar!=v){var F=k(ar);if(F.rowspan>1){ar.rowSpan=F.rowspan-1}else{X=ar.parentNode;if(X.parentNode){X._delete=true}}v=ar}}C(G);ak(0,-1);break;case"mceTableInsertColBefore":if(!X||!ar){return true}var ae=f(W.dom.getParent(G,"table"));var p=am(ae,ar);var v=null;for(var ab=0;ar=e(ae,ab,p.cellindex);ab++){if(ar!=v){var F=k(ar);if(F.colspan==1){var K=l.createElement(ar.nodeName);if(!tinymce.isIE){K.innerHTML='<br mce_bogus="1"/>'}K.rowSpan=ar.rowSpan;ar.parentNode.insertBefore(K,ar)}else{ar.colSpan++}v=ar}}ak();break;case"mceTableInsertColAfter":if(!X||!ar){return true}var ae=f(W.dom.getParent(G,"table"));var p=am(ae,ar);var v=null;for(var ab=0;ar=e(ae,ab,p.cellindex);ab++){if(ar!=v){var F=k(ar);if(F.colspan==1){var K=l.createElement(ar.nodeName);if(!tinymce.isIE){K.innerHTML='<br mce_bogus="1"/>'}K.rowSpan=ar.rowSpan;var al=ag(ar,"TD,TH");if(al==null){ar.parentNode.appendChild(K)}else{al.parentNode.insertBefore(K,al)}}else{ar.colSpan++}v=ar}}ak(1);break;case"mceTableDeleteCol":if(!X||!ar){return true}var ae=f(G);var p=am(ae,ar);var v=null;if((ae.length>1&&ae[0].length<=1)&&G.nodeName=="TBODY"){W.dom.remove(W.dom.getParent(G,"table"));return true}for(var ab=0;ar=e(ae,ab,p.cellindex);ab++){if(ar!=v){var F=k(ar);if(F.colspan>1){ar.colSpan=F.colspan-1}else{if(ar.parentNode){ar.parentNode.removeChild(ar)}}v=ar}}ak(-1);break;case"mceTableSplitCells":if(!X||!ar){return true}var m=k(ar);var D=m.colspan;var I=m.rowspan;if(D>1||I>1){ar.colSpan=1;for(var an=1;an<D;an++){var K=l.createElement("td");if(!tinymce.isIE){K.innerHTML='<br mce_bogus="1"/>'}X.insertBefore(K,ag(ar,"TD,TH"));if(I>1){q(K,X,I)}}q(ar,X,I)}G=W.dom.getParent(W.selection.getNode(),"table");break;case"mceTableMergeCells":var ap=[];var S=W.selection.getSel();var ae=f(G);if(tinymce.isIE||S.rangeCount==1){if(aa){var u=k(ar);W.windowManager.open({url:h+"/merge_cells.htm",width:240+parseInt(W.getLang("table.merge_cells_delta_width",0)),height:110+parseInt(W.getLang("table.merge_cells_delta_height",0)),inline:1},{action:"update",numcols:u.colspan,numrows:u.rowspan,plugin_url:h});return true}else{var V=parseInt(af.numrows);var d=parseInt(af.numcols);var p=am(ae,ar);if((""+V)=="NaN"){V=1}if((""+d)=="NaN"){d=1}var c=G.rows;for(var ab=p.rowindex;ab<ae.length;ab++){var ah=[];for(var ad=p.cellindex;ad<ae[ab].length;ad++){var g=e(ae,ab,ad);if(g&&!aq(ap,g)&&!aq(ah,g)){var O=am(ae,g);if(O.cellindex<p.cellindex+d&&O.rowindex<p.rowindex+V){ah[ah.length]=g}}}if(ah.length>0){ap[ap.length]=ah}var g=e(ae,p.rowindex,p.cellindex);b(av.dom.select("br",g),function(y,x){if(x>0&&av.dom.getAttrib("mce_bogus")){av.dom.remove(y)}})}}}else{var E=[];var S=W.selection.getSel();var Z=null;var ao=null;var A=-1,ax=-1,z,au;if(S.rangeCount<2){return true}for(var an=0;an<S.rangeCount;an++){var aj=S.getRangeAt(an);var ar=aj.startContainer.childNodes[aj.startOffset];if(!ar){break}if(ar.nodeName=="TD"||ar.nodeName=="TH"){E[E.length]=ar}}var c=G.rows;for(var ab=0;ab<c.length;ab++){var ah=[];for(var ad=0;ad<c[ab].cells.length;ad++){var g=c[ab].cells[ad];for(var an=0;an<E.length;an++){if(g==E[an]){ah[ah.length]=g}}}if(ah.length>0){ap[ap.length]=ah}}var ao=[];var Z=null;for(var ab=0;ab<ae.length;ab++){for(var ad=0;ad<ae[ab].length;ad++){ae[ab][ad]._selected=false;for(var an=0;an<E.length;an++){if(ae[ab][ad]==E[an]){if(A==-1){A=ad;ax=ab}z=ad;au=ab;ae[ab][ad]._selected=true}}}}for(var ab=ax;ab<=au;ab++){for(var ad=A;ad<=z;ad++){if(!ae[ab][ad]._selected){alert("Invalid selection for merge.");return true}}}}var t=1,r=1;var U=-1;for(var ab=0;ab<ap.length;ab++){var J=0;for(var ad=0;ad<ap[ab].length;ad++){var F=k(ap[ab][ad]);J+=F.colspan;if(U!=-1&&F.rowspan!=U){alert("Invalid selection for merge.");return true}U=F.rowspan}if(J>r){r=J}U=-1}var R=-1;for(var ad=0;ad<ap[0].length;ad++){var N=0;for(var ab=0;ab<ap.length;ab++){var F=k(ap[ab][ad]);N+=F.rowspan;if(R!=-1&&F.colspan!=R){alert("Invalid selection for merge.");return true}R=F.colspan}if(N>t){t=N}R=-1}ar=ap[0][0];ar.rowSpan=t;ar.colSpan=r;for(var ab=0;ab<ap.length;ab++){for(var ad=0;ad<ap[ab].length;ad++){var Q=ap[ab][ad].innerHTML;var L=Q.replace(/[ \t\r\n]/g,"");if(L!="<br/>"&&L!="<br>"&&L!='<br mce_bogus="1"/>'&&(ad+ab>0)){ar.innerHTML+=Q}if(ap[ab][ad]!=ar&&!ap[ab][ad]._deleted){var p=am(ae,ap[ab][ad]);var at=ap[ab][ad].parentNode;at.removeChild(ap[ab][ad]);ap[ab][ad]._deleted=true;if(!at.hasChildNodes()){at.parentNode.removeChild(at);var ac=null;for(var ad=0;cellElm=e(ae,p.rowindex,ad);ad++){if(cellElm!=ac&&cellElm.rowSpan>1){cellElm.rowSpan--}ac=cellElm}if(ar.rowSpan>1){ar.rowSpan--}}}}}b(av.dom.select("br",ar),function(y,x){if(x>0&&av.dom.getAttrib(y,"mce_bogus")){av.dom.remove(y)}});break}G=W.dom.getParent(W.selection.getNode(),"table");W.addVisual(G);W.nodeChanged()}return true}return false}});tinymce.PluginManager.add("table",tinymce.plugins.TablePlugin)})();
mce_table_buttons.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ Plugin Name: MCE Table Buttons
4
+ Plugin URI: http://www.cmurrayconsulting.com/software/wordpress-mce-table-buttons/
5
+ Description: Add <strong>buttons for table editing</strong> to the WordPress WYSIWYG editor with this very <strong>light weight</strong> plug-in.
6
+ Version: 1.0
7
+ Author: Jacob M Goldman (C. Murray Consulting)
8
+ Author URI: http://www.cmurrayconsulting.com
9
+
10
+ Plugin: Copyright 2009 C. Murray Consulting (email : jake@cmurrayconsulting.com)
11
+
12
+ This program is free software; you can redistribute it and/or modify
13
+ it under the terms of the GNU General Public License as published by
14
+ the Free Software Foundation; either version 2 of the License, or
15
+ (at your option) any later version.
16
+
17
+ This program is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ GNU General Public License for more details.
21
+
22
+ You should have received a copy of the GNU General Public License
23
+ along with this program; if not, write to the Free Software
24
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
+ */
26
+
27
+ add_action("admin_init","mce_table_buttons_setup");
28
+
29
+ function mce_table_buttons_setup() {
30
+ //only if editing permissions do we bother
31
+ if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) return;
32
+
33
+ if ( get_user_option('rich_editing') == 'true') {
34
+ add_filter("mce_external_plugins", "add_mcetable_tinymce_plugin");
35
+ add_filter('mce_buttons_3', 'rigbc_mcetable_buttons');
36
+ }
37
+ }
38
+
39
+ function add_mcetable_tinymce_plugin($plugin_array) {
40
+ $plugin_array['table'] = WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/mce-table/table_plugin.js';
41
+ return $plugin_array;
42
+ }
43
+
44
+ function rigbc_mcetable_buttons($buttons) {
45
+ array_push($buttons, "tablecontrols");
46
+ return $buttons;
47
+ }
48
+ ?>
readme.txt ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === MCE Table Buttons ===
2
+ Contributors: Jacob M Goldman (C. Murray Consulting)
3
+ Donate link: http://www.cmurrayconsulting.com/software/wordpress-mce-table-buttons/
4
+ Tags: tables, editor, WYSIWYG, buttons
5
+ Requires at least: 2.8
6
+ Tested up to: 2.8.5
7
+ Stable tag: 1.0
8
+
9
+ Adds table editing buttons to a new, third row in the WordPress WYSIWYG editor.
10
+
11
+ == Description ==
12
+
13
+ Adds table editing buttons to a new, third row in the WordPress WYSIWYG editor.
14
+
15
+ A very light weight plug-in based on a slightly modified version of the table editor plug-in included with
16
+ the full version of TinyMCE 3.2.7. Only includes English localization; please let us know if you would
17
+ like additional localizations added.
18
+
19
+ Note that this should not be used with other plug-ins that significantly alter the editor's default behavior.
20
+ It is intended to be a simple, light weight solution for editors who only want to add table management to
21
+ WordPress' included editor.
22
+
23
+ Hoping to add the ability to hide the new table editing toolbar with the "kitchen sink" option in a future
24
+ update.
25
+
26
+
27
+ == Installation ==
28
+
29
+ 1. Install easily with the WordPress plugin control panel or manually download the plugin and upload the folder
30
+ `mce-table-buttons` to the `/wp-content/plugins/` directory
31
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
32
+
33
+
34
+ == Screenshots ==
35
+
36
+ 1. The editor with the new table editing controls.
screenshot-1.png ADDED
Binary file