2 tinyMCEPopup
.resizeToInnerSize();
4 document
.getElementById('backgroundimagebrowsercontainer').innerHTML
= getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
5 document
.getElementById('bordercolor_pickcontainer').innerHTML
= getColorPickerHTML('bordercolor_pick','bordercolor');
6 document
.getElementById('bgcolor_pickcontainer').innerHTML
= getColorPickerHTML('bgcolor_pick','bgcolor')
8 var inst
= tinyMCE
.selectedInstance
;
9 var tdElm
= tinyMCE
.getParentElement(inst
.getFocusElement(), "td,th");
10 var formObj
= document
.forms
[0];
11 var st
= tinyMCE
.parseStyle(tinyMCE
.getAttrib(tdElm
, "style"));
13 // Get table cell data
14 var celltype
= tdElm
.nodeName
.toLowerCase();
15 var align
= tinyMCE
.getAttrib(tdElm
, 'align');
16 var valign
= tinyMCE
.getAttrib(tdElm
, 'valign');
17 var width
= trimSize(getStyle(tdElm
, 'width', 'width'));
18 var height
= trimSize(getStyle(tdElm
, 'height', 'height'));
19 var bordercolor
= convertRGBToHex(getStyle(tdElm
, 'bordercolor', 'borderLeftColor'));
20 var bgcolor
= convertRGBToHex(getStyle(tdElm
, 'bgcolor', 'backgroundColor'));
21 var className
= tinyMCE
.getVisualAidClass(tinyMCE
.getAttrib(tdElm
, 'class'), false);
22 var backgroundimage
= getStyle(tdElm
, 'background', 'backgroundImage').replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");;
23 var id
= tinyMCE
.getAttrib(tdElm
, 'id');
24 var lang
= tinyMCE
.getAttrib(tdElm
, 'lang');
25 var dir
= tinyMCE
.getAttrib(tdElm
, 'dir');
26 var scope
= tinyMCE
.getAttrib(tdElm
, 'scope');
29 addClassesToList('class', 'table_cell_styles');
30 formObj
.bordercolor
.value
= bordercolor
;
31 formObj
.bgcolor
.value
= bgcolor
;
32 formObj
.backgroundimage
.value
= backgroundimage
;
33 formObj
.width
.value
= width
;
34 formObj
.height
.value
= height
;
35 formObj
.id
.value
= id
;
36 formObj
.lang
.value
= lang
;
37 formObj
.style
.value
= tinyMCE
.serializeStyle(st
);
38 selectByValue(formObj
, 'align', align
);
39 selectByValue(formObj
, 'valign', valign
);
40 selectByValue(formObj
, 'class', className
);
41 selectByValue(formObj
, 'celltype', celltype
);
42 selectByValue(formObj
, 'dir', dir
);
43 selectByValue(formObj
, 'scope', scope
);
45 // Resize some elements
46 if (isVisible('backgroundimagebrowser'))
47 document
.getElementById('backgroundimage').style
.width
= '180px';
49 updateColor('bordercolor_pick', 'bordercolor');
50 updateColor('bgcolor_pick', 'bgcolor');
53 function updateAction() {
54 tinyMCEPopup
.restoreSelection();
56 var inst
= tinyMCE
.selectedInstance
;
57 var tdElm
= tinyMCE
.getParentElement(inst
.getFocusElement(), "td,th");
58 var trElm
= tinyMCE
.getParentElement(inst
.getFocusElement(), "tr");
59 var tableElm
= tinyMCE
.getParentElement(inst
.getFocusElement(), "table");
60 var formObj
= document
.forms
[0];
62 inst
.execCommand('mceBeginUndoLevel');
64 switch (getSelectValue(formObj
, 'action')) {
66 var celltype
= getSelectValue(formObj
, 'celltype');
67 var scope
= getSelectValue(formObj
, 'scope');
69 if (tinyMCE
.getParam("accessibility_warnings")) {
70 if (celltype
== "th" && scope
== "")
71 var answer
= confirm(tinyMCE
.getLang('lang_table_missing_scope', '', true));
83 var cell
= trElm
.firstChild
;
85 if (cell
.nodeName
!= "TD" && cell
.nodeName
!= "TH")
86 cell
= nextCell(cell
);
89 cell
= updateCell(cell
, true);
90 } while ((cell
= nextCell(cell
)) != null);
95 var rows
= tableElm
.getElementsByTagName("tr");
97 for (var i
=0; i
<rows
.length
; i
++) {
98 var cell
= rows
[i
].firstChild
;
100 if (cell
.nodeName
!= "TD" && cell
.nodeName
!= "TH")
101 cell
= nextCell(cell
);
104 cell
= updateCell(cell
, true);
105 } while ((cell
= nextCell(cell
)) != null);
111 tinyMCE
.handleVisualAid(inst
.getBody(), true, inst
.visualAid
, inst
);
112 tinyMCE
.triggerNodeChange();
113 inst
.execCommand('mceEndUndoLevel');
114 tinyMCEPopup
.close();
117 function nextCell(elm
) {
118 while ((elm
= elm
.nextSibling
) != null) {
119 if (elm
.nodeName
== "TD" || elm
.nodeName
== "TH")
126 function updateCell(td
, skip_id
) {
127 var inst
= tinyMCE
.selectedInstance
;
128 var formObj
= document
.forms
[0];
129 var curCellType
= td
.nodeName
.toLowerCase();
130 var celltype
= getSelectValue(formObj
, 'celltype');
131 var doc
= inst
.getDoc();
134 td
.setAttribute('id', formObj
.id
.value
);
136 td
.setAttribute('align', formObj
.align
.value
);
137 td
.setAttribute('vAlign', formObj
.valign
.value
);
138 td
.setAttribute('lang', formObj
.lang
.value
);
139 td
.setAttribute('dir', getSelectValue(formObj
, 'dir'));
140 td
.setAttribute('style', tinyMCE
.serializeStyle(tinyMCE
.parseStyle(formObj
.style
.value
)));
141 td
.setAttribute('scope', formObj
.scope
.value
);
142 tinyMCE
.setAttrib(td
, 'class', getSelectValue(formObj
, 'class'));
144 // Clear deprecated attributes
145 tinyMCE
.setAttrib(td
, 'width', '');
146 tinyMCE
.setAttrib(td
, 'height', '');
147 tinyMCE
.setAttrib(td
, 'bgColor', '');
148 tinyMCE
.setAttrib(td
, 'borderColor', '');
149 tinyMCE
.setAttrib(td
, 'background', '');
152 td
.style
.width
= getCSSSize(formObj
.width
.value
);
153 td
.style
.height
= getCSSSize(formObj
.height
.value
);
154 if (formObj
.bordercolor
.value
!= "") {
155 td
.style
.borderColor
= formObj
.bordercolor
.value
;
156 td
.style
.borderStyle
= td
.style
.borderStyle
== "" ? "solid" : td
.style
.borderStyle
;
157 td
.style
.borderWidth
= td
.style
.borderWidth
== "" ? "1px" : td
.style
.borderWidth
;
159 td
.style
.borderColor
= '';
161 td
.style
.backgroundColor
= formObj
.bgcolor
.value
;
163 if (formObj
.backgroundimage
.value
!= "")
164 td
.style
.backgroundImage
= "url('" + formObj
.backgroundimage
.value
+ "')";
166 td
.style
.backgroundImage
= '';
168 if (curCellType
!= celltype
) {
169 // changing to a different node type
170 var newCell
= doc
.createElement(celltype
);
172 for (var c
=0; c
<td
.childNodes
.length
; c
++)
173 newCell
.appendChild(td
.childNodes
[c
].cloneNode(1));
175 for (var a
=0; a
<td
.attributes
.length
; a
++) {
176 var attr
= td
.attributes
[a
];
177 newCell
.setAttribute(attr
.name
, attr
.value
);
180 td
.parentNode
.replaceChild(newCell
, td
);
187 function changedBackgroundImage() {
188 var formObj
= document
.forms
[0];
189 var st
= tinyMCE
.parseStyle(formObj
.style
.value
);
191 st
['background-image'] = "url('" + formObj
.backgroundimage
.value
+ "')";
193 formObj
.style
.value
= tinyMCE
.serializeStyle(st
);
196 function changedSize() {
197 var formObj
= document
.forms
[0];
198 var st
= tinyMCE
.parseStyle(formObj
.style
.value
);
200 var width
= formObj
.width
.value
;
202 st
['width'] = getCSSSize(width
);
206 var height
= formObj
.height
.value
;
208 st
['height'] = getCSSSize(height
);
212 formObj
.style
.value
= tinyMCE
.serializeStyle(st
);
215 function changedColor() {
216 var formObj
= document
.forms
[0];
217 var st
= tinyMCE
.parseStyle(formObj
.style
.value
);
219 st
['background-color'] = formObj
.bgcolor
.value
;
220 st
['border-color'] = formObj
.bordercolor
.value
;
222 formObj
.style
.value
= tinyMCE
.serializeStyle(st
);
225 function changedStyle() {
226 var formObj
= document
.forms
[0];
227 var st
= tinyMCE
.parseStyle(formObj
.style
.value
);
229 if (st
['background-image'])
230 formObj
.backgroundimage
.value
= st
['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
232 formObj
.backgroundimage
.value
= '';
235 formObj
.width
.value
= trimSize(st
['width']);
238 formObj
.height
.value
= trimSize(st
['height']);
240 if (st
['background-color']) {
241 formObj
.bgcolor
.value
= st
['background-color'];
242 updateColor('bgcolor_pick','bgcolor');
245 if (st
['border-color']) {
246 formObj
.bordercolor
.value
= st
['border-color'];
247 updateColor('bordercolor_pick','bordercolor');