annotate WebContent/jscripts/tiny_mce/plugins/table/js/table.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 action, orgTableWidth, orgTableHeight, dom = tinyMCEPopup.editor.dom;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5 function insertTable() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
7 var inst = tinyMCEPopup.editor, dom = inst.dom;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
8 var cols = 2, rows = 2, border = 0, cellpadding = -1, cellspacing = -1, align, width, height, className, caption, frame, rules;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
9 var html = '', capEl, elm;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
10 var cellLimit, rowLimit, colLimit;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
11
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
12 tinyMCEPopup.restoreSelection();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
13
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
14 if (!AutoValidator.validate(formObj)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
15 tinyMCEPopup.alert(AutoValidator.getErrorMessages(formObj).join('. ') + '.');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
16 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
17 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
18
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
19 elm = dom.getParent(inst.selection.getNode(), 'table');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
20
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
21 // Get form data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
22 cols = formObj.elements['cols'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
23 rows = formObj.elements['rows'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
24 border = formObj.elements['border'].value != "" ? formObj.elements['border'].value : 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
25 cellpadding = formObj.elements['cellpadding'].value != "" ? formObj.elements['cellpadding'].value : "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
26 cellspacing = formObj.elements['cellspacing'].value != "" ? formObj.elements['cellspacing'].value : "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
27 align = getSelectValue(formObj, "align");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
28 frame = getSelectValue(formObj, "tframe");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
29 rules = getSelectValue(formObj, "rules");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
30 width = formObj.elements['width'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
31 height = formObj.elements['height'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
32 bordercolor = formObj.elements['bordercolor'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
33 bgcolor = formObj.elements['bgcolor'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
34 className = getSelectValue(formObj, "class");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
35 id = formObj.elements['id'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36 summary = formObj.elements['summary'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37 style = formObj.elements['style'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 dir = formObj.elements['dir'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
39 lang = formObj.elements['lang'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
40 background = formObj.elements['backgroundimage'].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
41 caption = formObj.elements['caption'].checked;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
42
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
43 cellLimit = tinyMCEPopup.getParam('table_cell_limit', false);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
44 rowLimit = tinyMCEPopup.getParam('table_row_limit', false);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 colLimit = tinyMCEPopup.getParam('table_col_limit', false);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47 // Validate table size
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48 if (colLimit && cols > colLimit) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49 tinyMCEPopup.alert(inst.getLang('table_dlg.col_limit').replace(/\{\$cols\}/g, colLimit));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
51 } else if (rowLimit && rows > rowLimit) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
52 tinyMCEPopup.alert(inst.getLang('table_dlg.row_limit').replace(/\{\$rows\}/g, rowLimit));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
53 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
54 } else if (cellLimit && cols * rows > cellLimit) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
55 tinyMCEPopup.alert(inst.getLang('table_dlg.cell_limit').replace(/\{\$cells\}/g, cellLimit));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
56 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
57 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
58
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
59 // Update table
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
60 if (action == "update") {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
61 dom.setAttrib(elm, 'cellPadding', cellpadding, true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
62 dom.setAttrib(elm, 'cellSpacing', cellspacing, true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
63
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
64 if (!isCssSize(border)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
65 dom.setAttrib(elm, 'border', border);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
66 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
67 dom.setAttrib(elm, 'border', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
68 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
69
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
70 if (border == '') {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
71 dom.setStyle(elm, 'border-width', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
72 dom.setStyle(elm, 'border', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
73 dom.setAttrib(elm, 'border', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
74 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
75
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
76 dom.setAttrib(elm, 'align', align);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
77 dom.setAttrib(elm, 'frame', frame);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
78 dom.setAttrib(elm, 'rules', rules);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
79 dom.setAttrib(elm, 'class', className);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
80 dom.setAttrib(elm, 'style', style);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
81 dom.setAttrib(elm, 'id', id);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
82 dom.setAttrib(elm, 'summary', summary);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
83 dom.setAttrib(elm, 'dir', dir);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
84 dom.setAttrib(elm, 'lang', lang);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
85
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
86 capEl = inst.dom.select('caption', elm)[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
87
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
88 if (capEl && !caption)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
89 capEl.parentNode.removeChild(capEl);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
90
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
91 if (!capEl && caption) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
92 capEl = elm.ownerDocument.createElement('caption');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
93
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
94 if (!tinymce.isIE)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
95 capEl.innerHTML = '<br data-mce-bogus="1"/>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
96
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
97 elm.insertBefore(capEl, elm.firstChild);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
98 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
99
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
100 if (width && inst.settings.inline_styles) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
101 dom.setStyle(elm, 'width', width);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
102 dom.setAttrib(elm, 'width', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
103 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
104 dom.setAttrib(elm, 'width', width, true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
105 dom.setStyle(elm, 'width', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
106 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
107
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
108 // Remove these since they are not valid XHTML
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
109 dom.setAttrib(elm, 'borderColor', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
110 dom.setAttrib(elm, 'bgColor', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
111 dom.setAttrib(elm, 'background', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
112
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
113 if (height && inst.settings.inline_styles) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
114 dom.setStyle(elm, 'height', height);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
115 dom.setAttrib(elm, 'height', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
116 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
117 dom.setAttrib(elm, 'height', height, true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
118 dom.setStyle(elm, 'height', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
119 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
120
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
121 if (background != '')
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
122 elm.style.backgroundImage = "url('" + background + "')";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
123 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
124 elm.style.backgroundImage = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
125
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
126 /* if (tinyMCEPopup.getParam("inline_styles")) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
127 if (width != '')
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
128 elm.style.width = getCSSSize(width);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
129 }*/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
130
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
131 if (bordercolor != "") {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
132 elm.style.borderColor = bordercolor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
133 elm.style.borderStyle = elm.style.borderStyle == "" ? "solid" : elm.style.borderStyle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
134 elm.style.borderWidth = cssSize(border);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
135 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
136 elm.style.borderColor = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
137
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
138 elm.style.backgroundColor = bgcolor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
139 elm.style.height = getCSSSize(height);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
140
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
141 inst.addVisual();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
142
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
143 // Fix for stange MSIE align bug
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
144 //elm.outerHTML = elm.outerHTML;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
145
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
146 inst.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
147 inst.execCommand('mceEndUndoLevel');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
148
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
149 // Repaint if dimensions changed
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
150 if (formObj.width.value != orgTableWidth || formObj.height.value != orgTableHeight)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
151 inst.execCommand('mceRepaint');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
152
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
153 tinyMCEPopup.close();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
154 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
155 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
156
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
157 // Create new table
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
158 html += '<table';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
159
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
160 html += makeAttrib('id', id);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
161 if (!isCssSize(border)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
162 html += makeAttrib('border', border);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
163 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
164
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
165 html += makeAttrib('cellpadding', cellpadding);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
166 html += makeAttrib('cellspacing', cellspacing);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
167 html += makeAttrib('data-mce-new', '1');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
168
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
169 if (width && inst.settings.inline_styles) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
170 if (style)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
171 style += '; ';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
172
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
173 // Force px
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
174 if (/^[0-9\.]+$/.test(width))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
175 width += 'px';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
176
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
177 style += 'width: ' + width;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
178 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
179 html += makeAttrib('width', width);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
180
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
181 /* if (height) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
182 if (style)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
183 style += '; ';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
184
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
185 style += 'height: ' + height;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
186 }*/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
187
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
188 //html += makeAttrib('height', height);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
189 //html += makeAttrib('bordercolor', bordercolor);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
190 //html += makeAttrib('bgcolor', bgcolor);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
191 html += makeAttrib('align', align);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
192 html += makeAttrib('frame', frame);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
193 html += makeAttrib('rules', rules);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
194 html += makeAttrib('class', className);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
195 html += makeAttrib('style', style);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
196 html += makeAttrib('summary', summary);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
197 html += makeAttrib('dir', dir);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
198 html += makeAttrib('lang', lang);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
199 html += '>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
200
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
201 if (caption) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
202 if (!tinymce.isIE)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
203 html += '<caption><br data-mce-bogus="1"/></caption>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
204 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
205 html += '<caption></caption>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
206 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
207
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
208 for (var y=0; y<rows; y++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
209 html += "<tr>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
210
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
211 for (var x=0; x<cols; x++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
212 if (!tinymce.isIE)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
213 html += '<td><br data-mce-bogus="1"/></td>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
214 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
215 html += '<td></td>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
216 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
217
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
218 html += "</tr>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
219 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
220
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
221 html += "</table>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
222
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
223 // Move table
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
224 if (inst.settings.fix_table_elements) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
225 var patt = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
226
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
227 inst.focus();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
228 inst.selection.setContent('<br class="_mce_marker" />');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
229
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
230 tinymce.each('h1,h2,h3,h4,h5,h6,p'.split(','), function(n) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
231 if (patt)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
232 patt += ',';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
233
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
234 patt += n + ' ._mce_marker';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
235 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
236
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
237 tinymce.each(inst.dom.select(patt), function(n) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
238 inst.dom.split(inst.dom.getParent(n, 'h1,h2,h3,h4,h5,h6,p'), n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
239 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
240
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
241 dom.setOuterHTML(dom.select('br._mce_marker')[0], html);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
242 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
243 inst.execCommand('mceInsertContent', false, html);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
244
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
245 tinymce.each(dom.select('table[data-mce-new]'), function(node) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
246 var tdorth = dom.select('td,th', node);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
247
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
248 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
249 // IE9 might fail to do this selection
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
250 inst.selection.setCursorLocation(tdorth[0], 0);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
251 } catch (ex) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
252 // Ignore
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 dom.setAttrib(node, 'data-mce-new', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
256 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
257
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
258 inst.addVisual();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
259 inst.execCommand('mceEndUndoLevel');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
260
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
261 tinyMCEPopup.close();
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 makeAttrib(attrib, value) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
265 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
266 var valueElm = formObj.elements[attrib];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
267
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
268 if (typeof(value) == "undefined" || value == null) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
269 value = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
270
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
271 if (valueElm)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
272 value = valueElm.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
273 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
274
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
275 if (value == "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
276 return "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
277
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
278 // XML encode it
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
279 value = value.replace(/&/g, '&amp;');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
280 value = value.replace(/\"/g, '&quot;');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
281 value = value.replace(/</g, '&lt;');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
282 value = value.replace(/>/g, '&gt;');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
283
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
284 return ' ' + attrib + '="' + value + '"';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
285 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
286
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
287 function init() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
288 tinyMCEPopup.resizeToInnerSize();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
289
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
290 document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
291 document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
292 document.getElementById('bordercolor_pickcontainer').innerHTML = getColorPickerHTML('bordercolor_pick','bordercolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
293 document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
294
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
295 var cols = 2, rows = 2, border = tinyMCEPopup.getParam('table_default_border', '0'), cellpadding = tinyMCEPopup.getParam('table_default_cellpadding', ''), cellspacing = tinyMCEPopup.getParam('table_default_cellspacing', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
296 var align = "", width = "", height = "", bordercolor = "", bgcolor = "", className = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
297 var id = "", summary = "", style = "", dir = "", lang = "", background = "", bgcolor = "", bordercolor = "", rules = "", frame = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
298 var inst = tinyMCEPopup.editor, dom = inst.dom;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
299 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
300 var elm = dom.getParent(inst.selection.getNode(), "table");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
301
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
302 action = tinyMCEPopup.getWindowArg('action');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
303
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
304 if (!action)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
305 action = elm ? "update" : "insert";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
306
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
307 if (elm && action != "insert") {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
308 var rowsAr = elm.rows;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
309 var cols = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
310 for (var i=0; i<rowsAr.length; i++)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
311 if (rowsAr[i].cells.length > cols)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
312 cols = rowsAr[i].cells.length;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
313
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
314 cols = cols;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
315 rows = rowsAr.length;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
316
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
317 st = dom.parseStyle(dom.getAttrib(elm, "style"));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
318 border = trimSize(getStyle(elm, 'border', 'borderWidth'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
319 cellpadding = dom.getAttrib(elm, 'cellpadding', "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
320 cellspacing = dom.getAttrib(elm, 'cellspacing', "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
321 width = trimSize(getStyle(elm, 'width', 'width'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
322 height = trimSize(getStyle(elm, 'height', 'height'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
323 bordercolor = convertRGBToHex(getStyle(elm, 'bordercolor', 'borderLeftColor'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
324 bgcolor = convertRGBToHex(getStyle(elm, 'bgcolor', 'backgroundColor'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
325 align = dom.getAttrib(elm, 'align', align);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
326 frame = dom.getAttrib(elm, 'frame');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
327 rules = dom.getAttrib(elm, 'rules');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
328 className = tinymce.trim(dom.getAttrib(elm, 'class').replace(/mceItem.+/g, ''));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
329 id = dom.getAttrib(elm, 'id');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
330 summary = dom.getAttrib(elm, 'summary');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
331 style = dom.serializeStyle(st);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
332 dir = dom.getAttrib(elm, 'dir');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
333 lang = dom.getAttrib(elm, 'lang');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
334 background = getStyle(elm, 'background', 'backgroundImage').replace(new RegExp("url\\(['\"]?([^'\"]*)['\"]?\\)", 'gi'), "$1");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
335 formObj.caption.checked = elm.getElementsByTagName('caption').length > 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
336
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
337 orgTableWidth = width;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
338 orgTableHeight = height;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
339
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
340 action = "update";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
341 formObj.insert.value = inst.getLang('update');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
342 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
343
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
344 addClassesToList('class', "table_styles");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
345 TinyMCE_EditableSelects.init();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
346
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
347 // Update form
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
348 selectByValue(formObj, 'align', align);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
349 selectByValue(formObj, 'tframe', frame);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
350 selectByValue(formObj, 'rules', rules);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
351 selectByValue(formObj, 'class', className, true, true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
352 formObj.cols.value = cols;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
353 formObj.rows.value = rows;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
354 formObj.border.value = border;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
355 formObj.cellpadding.value = cellpadding;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
356 formObj.cellspacing.value = cellspacing;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
357 formObj.width.value = width;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
358 formObj.height.value = height;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
359 formObj.bordercolor.value = bordercolor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
360 formObj.bgcolor.value = bgcolor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
361 formObj.id.value = id;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
362 formObj.summary.value = summary;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
363 formObj.style.value = style;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
364 formObj.dir.value = dir;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
365 formObj.lang.value = lang;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
366 formObj.backgroundimage.value = background;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
367
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
368 updateColor('bordercolor_pick', 'bordercolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
369 updateColor('bgcolor_pick', 'bgcolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
370
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
371 // Resize some elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
372 if (isVisible('backgroundimagebrowser'))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
373 document.getElementById('backgroundimage').style.width = '180px';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
374
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
375 // Disable some fields in update mode
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
376 if (action == "update") {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
377 formObj.cols.disabled = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
378 formObj.rows.disabled = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
379 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
380 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
381
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
382 function changedSize() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
383 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
384 var st = dom.parseStyle(formObj.style.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
385
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
386 /* var width = formObj.width.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
387 if (width != "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
388 st['width'] = tinyMCEPopup.getParam("inline_styles") ? getCSSSize(width) : "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
389 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
390 st['width'] = "";*/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
391
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
392 var height = formObj.height.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
393 if (height != "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
394 st['height'] = getCSSSize(height);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
395 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
396 st['height'] = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
397
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
398 formObj.style.value = dom.serializeStyle(st);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
399 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
400
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
401 function isCssSize(value) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
402 return /^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)$/.test(value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
403 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
404
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
405 function cssSize(value, def) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
406 value = tinymce.trim(value || def);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
407
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
408 if (!isCssSize(value)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
409 return parseInt(value, 10) + 'px';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
410 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
411
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
412 return value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
413 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
414
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
415 function changedBackgroundImage() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
416 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
417 var st = dom.parseStyle(formObj.style.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
418
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
419 st['background-image'] = "url('" + formObj.backgroundimage.value + "')";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
420
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
421 formObj.style.value = dom.serializeStyle(st);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
422 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
423
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
424 function changedBorder() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
425 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
426 var st = dom.parseStyle(formObj.style.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
427
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
428 // Update border width if the element has a color
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
429 if (formObj.border.value != "" && (isCssSize(formObj.border.value) || formObj.bordercolor.value != ""))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
430 st['border-width'] = cssSize(formObj.border.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
431 else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
432 if (!formObj.border.value) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
433 st['border'] = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
434 st['border-width'] = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
435 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
436 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
437
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
438 formObj.style.value = dom.serializeStyle(st);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
439 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
440
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
441 function changedColor() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
442 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
443 var st = dom.parseStyle(formObj.style.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
444
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
445 st['background-color'] = formObj.bgcolor.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
446
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
447 if (formObj.bordercolor.value != "") {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
448 st['border-color'] = formObj.bordercolor.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
449
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
450 // Add border-width if it's missing
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
451 if (!st['border-width'])
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
452 st['border-width'] = cssSize(formObj.border.value, 1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
453 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
454
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
455 formObj.style.value = dom.serializeStyle(st);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
456 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
457
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
458 function changedStyle() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
459 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
460 var st = dom.parseStyle(formObj.style.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
461
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
462 if (st['background-image'])
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
463 formObj.backgroundimage.value = st['background-image'].replace(new RegExp("url\\(['\"]?([^'\"]*)['\"]?\\)", 'gi'), "$1");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
464 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
465 formObj.backgroundimage.value = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
466
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
467 if (st['width'])
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
468 formObj.width.value = trimSize(st['width']);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
469
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
470 if (st['height'])
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
471 formObj.height.value = trimSize(st['height']);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
472
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
473 if (st['background-color']) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
474 formObj.bgcolor.value = st['background-color'];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
475 updateColor('bgcolor_pick','bgcolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
476 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
477
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
478 if (st['border-color']) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
479 formObj.bordercolor.value = st['border-color'];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
480 updateColor('bordercolor_pick','bordercolor');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
481 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
482 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
483
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
484 tinyMCEPopup.onInit.add(init);