annotate WebContent/jscripts/tiny_mce/plugins/table/js/cell.js @ 14:0f64de5fff5a

try to use javax.xml.bind.DatatypeConverter
author casties
date Wed, 21 Mar 2012 16:38:50 +0100
parents 0be9d53a6967
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1 tinyMCEPopup.requireLangPack();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3 var ed;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5 function init() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6 ed = tinyMCEPopup.editor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
7 tinyMCEPopup.resizeToInnerSize();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
8
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
9 document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
10 document.getElementById('bordercolor_pickcontainer').innerHTML = getColorPickerHTML('bordercolor_pick','bordercolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
11 document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor')
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
12
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
13 var inst = ed;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
14 var tdElm = ed.dom.getParent(ed.selection.getStart(), "td,th");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
15 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
16 var st = ed.dom.parseStyle(ed.dom.getAttrib(tdElm, "style"));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
17
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
18 // Get table cell data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
19 var celltype = tdElm.nodeName.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
20 var align = ed.dom.getAttrib(tdElm, 'align');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
21 var valign = ed.dom.getAttrib(tdElm, 'valign');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
22 var width = trimSize(getStyle(tdElm, 'width', 'width'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
23 var height = trimSize(getStyle(tdElm, 'height', 'height'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
24 var bordercolor = convertRGBToHex(getStyle(tdElm, 'bordercolor', 'borderLeftColor'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
25 var bgcolor = convertRGBToHex(getStyle(tdElm, 'bgcolor', 'backgroundColor'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
26 var className = ed.dom.getAttrib(tdElm, 'class');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
27 var backgroundimage = getStyle(tdElm, 'background', 'backgroundImage').replace(new RegExp("url\\(['\"]?([^'\"]*)['\"]?\\)", 'gi'), "$1");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
28 var id = ed.dom.getAttrib(tdElm, 'id');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
29 var lang = ed.dom.getAttrib(tdElm, 'lang');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
30 var dir = ed.dom.getAttrib(tdElm, 'dir');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
31 var scope = ed.dom.getAttrib(tdElm, 'scope');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
32
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
33 // Setup form
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
34 addClassesToList('class', 'table_cell_styles');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
35 TinyMCE_EditableSelects.init();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37 if (!ed.dom.hasClass(tdElm, 'mceSelected')) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 formObj.bordercolor.value = bordercolor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
39 formObj.bgcolor.value = bgcolor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
40 formObj.backgroundimage.value = backgroundimage;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
41 formObj.width.value = width;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
42 formObj.height.value = height;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
43 formObj.id.value = id;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
44 formObj.lang.value = lang;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 formObj.style.value = ed.dom.serializeStyle(st);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46 selectByValue(formObj, 'align', align);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47 selectByValue(formObj, 'valign', valign);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48 selectByValue(formObj, 'class', className, true, true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49 selectByValue(formObj, 'celltype', celltype);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50 selectByValue(formObj, 'dir', dir);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
51 selectByValue(formObj, 'scope', scope);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
52
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
53 // Resize some elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
54 if (isVisible('backgroundimagebrowser'))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
55 document.getElementById('backgroundimage').style.width = '180px';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
56
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
57 updateColor('bordercolor_pick', 'bordercolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
58 updateColor('bgcolor_pick', 'bgcolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
59 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
60 tinyMCEPopup.dom.hide('action');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
61 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
62
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
63 function updateAction() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
64 var el, inst = ed, tdElm, trElm, tableElm, formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
65
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
66 if (!AutoValidator.validate(formObj)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
67 tinyMCEPopup.alert(AutoValidator.getErrorMessages(formObj).join('. ') + '.');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
68 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
69 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
70
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
71 tinyMCEPopup.restoreSelection();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
72 el = ed.selection.getStart();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
73 tdElm = ed.dom.getParent(el, "td,th");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
74 trElm = ed.dom.getParent(el, "tr");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
75 tableElm = ed.dom.getParent(el, "table");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
76
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
77 // Cell is selected
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
78 if (ed.dom.hasClass(tdElm, 'mceSelected')) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
79 // Update all selected sells
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
80 tinymce.each(ed.dom.select('td.mceSelected,th.mceSelected'), function(td) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
81 updateCell(td);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
82 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
83
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
84 ed.addVisual();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
85 ed.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
86 inst.execCommand('mceEndUndoLevel');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
87 tinyMCEPopup.close();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
88 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
89 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
90
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
91 switch (getSelectValue(formObj, 'action')) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
92 case "cell":
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
93 var celltype = getSelectValue(formObj, 'celltype');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
94 var scope = getSelectValue(formObj, 'scope');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
95
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
96 function doUpdate(s) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
97 if (s) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
98 updateCell(tdElm);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
99
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
100 ed.addVisual();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
101 ed.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
102 inst.execCommand('mceEndUndoLevel');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
103 tinyMCEPopup.close();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
104 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
105 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
106
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
107 if (ed.getParam("accessibility_warnings", 1)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
108 if (celltype == "th" && scope == "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
109 tinyMCEPopup.confirm(ed.getLang('table_dlg.missing_scope', '', true), doUpdate);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
110 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
111 doUpdate(1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
112
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
113 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
114 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
115
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
116 updateCell(tdElm);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
117 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
118
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
119 case "row":
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
120 var cell = trElm.firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
121
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
122 if (cell.nodeName != "TD" && cell.nodeName != "TH")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
123 cell = nextCell(cell);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
124
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
125 do {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
126 cell = updateCell(cell, true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
127 } while ((cell = nextCell(cell)) != null);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
128
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
129 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
130
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
131 case "col":
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
132 var curr, col = 0, cell = trElm.firstChild, rows = tableElm.getElementsByTagName("tr");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
133
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
134 if (cell.nodeName != "TD" && cell.nodeName != "TH")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
135 cell = nextCell(cell);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
136
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
137 do {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
138 if (cell == tdElm)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
139 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
140 col += cell.getAttribute("colspan");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
141 } while ((cell = nextCell(cell)) != null);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
142
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
143 for (var i=0; i<rows.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
144 cell = rows[i].firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
145
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
146 if (cell.nodeName != "TD" && cell.nodeName != "TH")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
147 cell = nextCell(cell);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
148
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
149 curr = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
150 do {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
151 if (curr == col) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
152 cell = updateCell(cell, true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
153 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
154 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
155 curr += cell.getAttribute("colspan");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
156 } while ((cell = nextCell(cell)) != null);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
157 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
158
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
159 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
160
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
161 case "all":
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
162 var rows = tableElm.getElementsByTagName("tr");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
163
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
164 for (var i=0; i<rows.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
165 var cell = rows[i].firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
166
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
167 if (cell.nodeName != "TD" && cell.nodeName != "TH")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
168 cell = nextCell(cell);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
169
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
170 do {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
171 cell = updateCell(cell, true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
172 } while ((cell = nextCell(cell)) != null);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
173 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
174
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
175 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
176 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
177
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
178 ed.addVisual();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
179 ed.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
180 inst.execCommand('mceEndUndoLevel');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
181 tinyMCEPopup.close();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
182 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
183
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
184 function nextCell(elm) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
185 while ((elm = elm.nextSibling) != null) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
186 if (elm.nodeName == "TD" || elm.nodeName == "TH")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
187 return elm;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
188 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
189
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
190 return null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
191 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
192
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
193 function updateCell(td, skip_id) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
194 var inst = ed;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
195 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
196 var curCellType = td.nodeName.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
197 var celltype = getSelectValue(formObj, 'celltype');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
198 var doc = inst.getDoc();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
199 var dom = ed.dom;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
200
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
201 if (!skip_id)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
202 dom.setAttrib(td, 'id', formObj.id.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
203
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
204 dom.setAttrib(td, 'align', formObj.align.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
205 dom.setAttrib(td, 'vAlign', formObj.valign.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
206 dom.setAttrib(td, 'lang', formObj.lang.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
207 dom.setAttrib(td, 'dir', getSelectValue(formObj, 'dir'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
208 dom.setAttrib(td, 'style', ed.dom.serializeStyle(ed.dom.parseStyle(formObj.style.value)));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
209 dom.setAttrib(td, 'scope', formObj.scope.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
210 dom.setAttrib(td, 'class', getSelectValue(formObj, 'class'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
211
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
212 // Clear deprecated attributes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
213 ed.dom.setAttrib(td, 'width', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
214 ed.dom.setAttrib(td, 'height', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
215 ed.dom.setAttrib(td, 'bgColor', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
216 ed.dom.setAttrib(td, 'borderColor', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
217 ed.dom.setAttrib(td, 'background', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
218
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
219 // Set styles
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
220 td.style.width = getCSSSize(formObj.width.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
221 td.style.height = getCSSSize(formObj.height.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
222 if (formObj.bordercolor.value != "") {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
223 td.style.borderColor = formObj.bordercolor.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
224 td.style.borderStyle = td.style.borderStyle == "" ? "solid" : td.style.borderStyle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
225 td.style.borderWidth = td.style.borderWidth == "" ? "1px" : td.style.borderWidth;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
226 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
227 td.style.borderColor = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
228
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
229 td.style.backgroundColor = formObj.bgcolor.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
230
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
231 if (formObj.backgroundimage.value != "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
232 td.style.backgroundImage = "url('" + formObj.backgroundimage.value + "')";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
233 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
234 td.style.backgroundImage = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
235
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
236 if (curCellType != celltype) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
237 // changing to a different node type
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
238 var newCell = doc.createElement(celltype);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
239
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
240 for (var c=0; c<td.childNodes.length; c++)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
241 newCell.appendChild(td.childNodes[c].cloneNode(1));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
242
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
243 for (var a=0; a<td.attributes.length; a++)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
244 ed.dom.setAttrib(newCell, td.attributes[a].name, ed.dom.getAttrib(td, td.attributes[a].name));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
245
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
246 td.parentNode.replaceChild(newCell, td);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
247 td = newCell;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
248 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
249
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
250 dom.setAttrib(td, 'style', dom.serializeStyle(dom.parseStyle(td.style.cssText)));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
251
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
252 return td;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
253 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
254
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
255 function changedBackgroundImage() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
256 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
257 var st = ed.dom.parseStyle(formObj.style.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
258
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
259 st['background-image'] = "url('" + formObj.backgroundimage.value + "')";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
260
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
261 formObj.style.value = ed.dom.serializeStyle(st);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
262 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
263
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
264 function changedSize() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
265 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
266 var st = ed.dom.parseStyle(formObj.style.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
267
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
268 var width = formObj.width.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
269 if (width != "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
270 st['width'] = getCSSSize(width);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
271 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
272 st['width'] = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
273
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
274 var height = formObj.height.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
275 if (height != "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
276 st['height'] = getCSSSize(height);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
277 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
278 st['height'] = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
279
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
280 formObj.style.value = ed.dom.serializeStyle(st);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
281 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
282
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
283 function changedColor() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
284 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
285 var st = ed.dom.parseStyle(formObj.style.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
286
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
287 st['background-color'] = formObj.bgcolor.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
288 st['border-color'] = formObj.bordercolor.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
289
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
290 formObj.style.value = ed.dom.serializeStyle(st);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
291 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
292
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
293 function changedStyle() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
294 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
295 var st = ed.dom.parseStyle(formObj.style.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
296
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
297 if (st['background-image'])
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
298 formObj.backgroundimage.value = st['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
299 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
300 formObj.backgroundimage.value = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
301
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
302 if (st['width'])
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
303 formObj.width.value = trimSize(st['width']);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
304
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
305 if (st['height'])
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
306 formObj.height.value = trimSize(st['height']);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
307
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
308 if (st['background-color']) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
309 formObj.bgcolor.value = st['background-color'];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
310 updateColor('bgcolor_pick','bgcolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
311 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
312
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
313 if (st['border-color']) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
314 formObj.bordercolor.value = st['border-color'];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
315 updateColor('bordercolor_pick','bordercolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
316 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
317 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
318
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
319 tinyMCEPopup.onInit.add(init);