tinyMCEPopup.requireLangPack(); var ed; function init() { ed = tinyMCEPopup.editor; tinyMCEPopup.resizeToInnerSize(); document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table'); document.getElementById('bordercolor_pickcontainer').innerHTML = getColorPickerHTML('bordercolor_pick','bordercolor'); document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor') var inst = ed; var tdElm = ed.dom.getParent(ed.selection.getStart(), "td,th"); var formObj = document.forms[0]; var st = ed.dom.parseStyle(ed.dom.getAttrib(tdElm, "style")); // Get table cell data var celltype = tdElm.nodeName.toLowerCase(); var align = ed.dom.getAttrib(tdElm, 'align'); var valign = ed.dom.getAttrib(tdElm, 'valign'); var width = trimSize(getStyle(tdElm, 'width', 'width')); var height = trimSize(getStyle(tdElm, 'height', 'height')); var bordercolor = convertRGBToHex(getStyle(tdElm, 'bordercolor', 'borderLeftColor')); var bgcolor = convertRGBToHex(getStyle(tdElm, 'bgcolor', 'backgroundColor')); var className = ed.dom.getAttrib(tdElm, 'class'); var backgroundimage = getStyle(tdElm, 'background', 'backgroundImage').replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");; var id = ed.dom.getAttrib(tdElm, 'id'); var lang = ed.dom.getAttrib(tdElm, 'lang'); var dir = ed.dom.getAttrib(tdElm, 'dir'); var scope = ed.dom.getAttrib(tdElm, 'scope'); // Setup form addClassesToList('class', 'table_cell_styles'); TinyMCE_EditableSelects.init(); formObj.bordercolor.value = bordercolor; formObj.bgcolor.value = bgcolor; formObj.backgroundimage.value = backgroundimage; formObj.width.value = width; formObj.height.value = height; formObj.id.value = id; formObj.lang.value = lang; formObj.style.value = ed.dom.serializeStyle(st); selectByValue(formObj, 'align', align); selectByValue(formObj, 'valign', valign); selectByValue(formObj, 'class', className, true, true); selectByValue(formObj, 'celltype', celltype); selectByValue(formObj, 'dir', dir); selectByValue(formObj, 'scope', scope); // Resize some elements if (isVisible('backgroundimagebrowser')) document.getElementById('backgroundimage').style.width = '180px'; updateColor('bordercolor_pick', 'bordercolor'); updateColor('bgcolor_pick', 'bgcolor'); } function updateAction() { var el, inst = ed, tdElm, trElm, tableElm, formObj = document.forms[0]; tinyMCEPopup.restoreSelection(); el = ed.selection.getStart(); tdElm = ed.dom.getParent(el, "td,th"); trElm = ed.dom.getParent(el, "tr"); tableElm = ed.dom.getParent(el, "table"); ed.execCommand('mceBeginUndoLevel'); switch (getSelectValue(formObj, 'action')) { case "cell": var celltype = getSelectValue(formObj, 'celltype'); var scope = getSelectValue(formObj, 'scope'); function doUpdate(s) { if (s) { updateCell(tdElm); ed.addVisual(); ed.nodeChanged(); inst.execCommand('mceEndUndoLevel'); tinyMCEPopup.close(); } }; if (ed.getParam("accessibility_warnings", 1)) { if (celltype == "th" && scope == "") tinyMCEPopup.confirm(ed.getLang('table_dlg.missing_scope', '', true), doUpdate); else doUpdate(1); return; } updateCell(tdElm); break; case "row": var cell = trElm.firstChild; if (cell.nodeName != "TD" && cell.nodeName != "TH") cell = nextCell(cell); do { cell = updateCell(cell, true); } while ((cell = nextCell(cell)) != null); break; case "all": var rows = tableElm.getElementsByTagName("tr"); for (var i=0; i