From 0b221e8945ae785dc706d8ea9a9e8e25532c0096 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 28 Jun 2011 21:11:52 -0700 Subject: bug #96 move libraries to library - better alignment of like rotator --- .../jscripts/tiny_mce/plugins/table/js/row.js | 237 +++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 library/tinymce/jscripts/tiny_mce/plugins/table/js/row.js (limited to 'library/tinymce/jscripts/tiny_mce/plugins/table/js/row.js') diff --git a/library/tinymce/jscripts/tiny_mce/plugins/table/js/row.js b/library/tinymce/jscripts/tiny_mce/plugins/table/js/row.js new file mode 100644 index 000000000..70d95b672 --- /dev/null +++ b/library/tinymce/jscripts/tiny_mce/plugins/table/js/row.js @@ -0,0 +1,237 @@ +tinyMCEPopup.requireLangPack(); + +function init() { + tinyMCEPopup.resizeToInnerSize(); + + document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table'); + document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor'); + + var inst = tinyMCEPopup.editor; + var dom = inst.dom; + var trElm = dom.getParent(inst.selection.getStart(), "tr"); + var formObj = document.forms[0]; + var st = dom.parseStyle(dom.getAttrib(trElm, "style")); + + // Get table row data + var rowtype = trElm.parentNode.nodeName.toLowerCase(); + var align = dom.getAttrib(trElm, 'align'); + var valign = dom.getAttrib(trElm, 'valign'); + var height = trimSize(getStyle(trElm, 'height', 'height')); + var className = dom.getAttrib(trElm, 'class'); + var bgcolor = convertRGBToHex(getStyle(trElm, 'bgcolor', 'backgroundColor')); + var backgroundimage = getStyle(trElm, 'background', 'backgroundImage').replace(new RegExp("url\\(['\"]?([^'\"]*)['\"]?\\)", 'gi'), "$1"); + var id = dom.getAttrib(trElm, 'id'); + var lang = dom.getAttrib(trElm, 'lang'); + var dir = dom.getAttrib(trElm, 'dir'); + + selectByValue(formObj, 'rowtype', rowtype); + + // Any cells selected + if (dom.select('td.mceSelected,th.mceSelected', trElm).length == 0) { + // Setup form + addClassesToList('class', 'table_row_styles'); + TinyMCE_EditableSelects.init(); + + formObj.bgcolor.value = bgcolor; + formObj.backgroundimage.value = backgroundimage; + formObj.height.value = height; + formObj.id.value = id; + formObj.lang.value = lang; + formObj.style.value = dom.serializeStyle(st); + selectByValue(formObj, 'align', align); + selectByValue(formObj, 'valign', valign); + selectByValue(formObj, 'class', className, true, true); + selectByValue(formObj, 'dir', dir); + + // Resize some elements + if (isVisible('backgroundimagebrowser')) + document.getElementById('backgroundimage').style.width = '180px'; + + updateColor('bgcolor_pick', 'bgcolor'); + } else + tinyMCEPopup.dom.hide('action'); +} + +function updateAction() { + var inst = tinyMCEPopup.editor, dom = inst.dom, trElm, tableElm, formObj = document.forms[0]; + var action = getSelectValue(formObj, 'action'); + + tinyMCEPopup.restoreSelection(); + trElm = dom.getParent(inst.selection.getStart(), "tr"); + tableElm = dom.getParent(inst.selection.getStart(), "table"); + + // Update all selected rows + if (dom.select('td.mceSelected,th.mceSelected', trElm).length > 0) { + tinymce.each(tableElm.rows, function(tr) { + var i; + + for (i = 0; i < tr.cells.length; i++) { + if (dom.hasClass(tr.cells[i], 'mceSelected')) { + updateRow(tr, true); + return; + } + } + }); + + inst.addVisual(); + inst.nodeChanged(); + inst.execCommand('mceEndUndoLevel'); + tinyMCEPopup.close(); + return; + } + + inst.execCommand('mceBeginUndoLevel'); + + switch (action) { + case "row": + updateRow(trElm); + break; + + case "all": + var rows = tableElm.getElementsByTagName("tr"); + + for (var i=0; i