19 include_once($ROOT_PATH.
'wysiwyg_plugin.inc');
47 wysiwyg_plugin::wysiwyg_plugin($wysiwyg);
48 $this->_add_button(
'inserttable',
'InsertTable',
'Insert Table',
'false',
'35');
49 $this->_add_button(
'tableproperties',
'TableProperties',
'Table Properties',
'false',
'36',
'table');
63 this.config._showborders =
true;
78 <script type=
"text/javascript">
84 HTMLArea.prototype.clearRow =
function(tr) {
85 var mozbr = HTMLArea.is_gecko ?
"<br />" :
"";
86 var tds = tr.getElementsByTagName(
"td");
87 for (var i = tds.length; --i >= 0;) {
95 HTMLArea.prototype.selectNextNode =
function(el) {
96 var node = el.nextSibling;
97 while (node && node.nodeType != 1) {
98 node = node.nextSibling;
101 node = el.previousSibling;
102 while (node && node.nodeType != 1) {
103 node = node.previousSibling;
107 node = el.parentNode;
109 this.selectNodeContents(node);
114 HTMLArea.prototype._insertTable =
function() {
118 if (HTMLArea.is_ie) {
119 this._docContent.focus();
120 }
else if (HTMLArea.is_gecko) {
123 var sel = this._getSelection();
124 var range = this._createRange(sel);
126 (
"insertTable",
"<?php echo $this->get_popup_href('insert_table.html')?>", 400, 500,
true,
function(param) {
130 var doc = editor._doc;
132 var table = doc.createElement(
"table");
134 var row_header = param[
"f_headerRow"];
135 var col_header = param[
"f_headerCol"];
138 for (var field in param) {
139 var value = param[field];
147 table.className = value;
152 table.style.width = value + param[
"f_widthUnit"];
156 table.border = parseInt(value);
160 table.cellSpacing = parseInt(value);
164 table.cellPadding = parseInt(value);
169 table.setAttribute(
"summary", value);
175 var tbody = doc.createElement(
"tbody");
176 table.appendChild(tbody);
177 for (var i = 0; i < param[
"f_rows"]; ++i) {
178 var tr = doc.createElement(
"tr");
179 tbody.appendChild(tr);
180 for (var j = 0; j < param[
"f_cols"]; ++j) {
183 if ((col_header && j == 0)
184 || (row_header && i == 0)) {
185 td = doc.createElement(
"th");
187 td = doc.createElement(
"td");
190 if (HTMLArea.is_gecko) {
193 td.appendChild(doc.createElement(
"br"));
194 }
else if (HTMLArea.is_ie) {
196 td.appendChild(doc.createTextNode(
''));
201 if (HTMLArea.is_ie) {
202 range.pasteHTML(HTMLArea.getHTML(table,
true));
205 editor.insertNodeAtSelection(table);
213 HTMLArea.prototype._editTableProperties =
function() {
217 var table = this.getClosest(
"table");
218 if (HTMLArea.is_ie) {
220 var tablekeeper = table.outerHTML;
222 var div = document.createElement(
"DIV");
223 div.appendChild(table.cloneNode(
true));
224 var tablekeeper = div.innerHTML;
226 table_structure = tablekeeper;
227 strPage =
"<?php echo $this->get_popup_href('edit_table.php')?>";
230 table_structure = this.make_absolute_urls(table_structure);
231 this._popupDialog(
"editTableProperties", strPage, width, height,
true,
function(params) {
236 var div = document.createElement(
"DIV");
237 div.innerHTML = params;
238 var table = div.getElementsByTagName(
"TABLE")[0];
239 var old_table = editor.getClosest(
"TABLE");
240 if (HTMLArea.is_ie) {
241 old_table.outerHTML = table.outerHTML;
243 old_table.parentNode.replaceChild(table, old_table);
247 editor.forceRedraw();
248 editor.focusEditor();
249 editor.updateToolbar();
250 var save_collapse = table.style.borderCollapse;
251 table.style.borderCollapse =
"collapse";
252 table.style.borderCollapse =
"separate";
253 table.style.borderCollapse = save_collapse;
259 HTMLArea.prototype.storedBorders = Array();
261 this.clonedBorder =
function() {
263 this.cloneSaveBorder =
function(border) {
271 HTMLArea._restoreBorder =
function(elt, stored)
273 if (stored.borderLeft) {
274 elt.style.borderLeft = stored.borderLeft;
276 if (stored.borderRight) {
277 elt.style.borderRight = stored.borderRight;
279 if (stored.borderTop) {
280 elt.style.borderTop = stored.borderTop;
282 if (stored.borderBottom) {
283 elt.style.borderBottom = stored.borderBottom;
304 if (this.config._showborders){
305 if (HTMLArea.is_ie) {
306 var doco = this._docContent;
308 var doco = this._iframe.contentWindow;
310 this.config._showborders =
true;
314 case "tableproperties":
315 this._editTableProperties();
344 retVal = retVal.replace(/
class=
""/gi,
'');