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