includes/clientside/tinymce/plugins/table/editor_plugin.js
changeset 1193 e3b94bd055dc
parent 778 57ce13805b6f
--- a/includes/clientside/tinymce/plugins/table/editor_plugin.js	Mon Dec 21 15:41:05 2009 -0500
+++ b/includes/clientside/tinymce/plugins/table/editor_plugin.js	Tue Dec 22 13:09:59 2009 -0500
@@ -1,1 +1,1 @@
-(function(){var each=tinymce.each;tinymce.create('tinymce.plugins.TablePlugin',{init:function(ed,url){var t=this;t.editor=ed;t.url=url;each([['table','table.desc','mceInsertTable',true],['delete_table','table.del','mceTableDelete'],['delete_col','table.delete_col_desc','mceTableDeleteCol'],['delete_row','table.delete_row_desc','mceTableDeleteRow'],['col_after','table.col_after_desc','mceTableInsertColAfter'],['col_before','table.col_before_desc','mceTableInsertColBefore'],['row_after','table.row_after_desc','mceTableInsertRowAfter'],['row_before','table.row_before_desc','mceTableInsertRowBefore'],['row_props','table.row_desc','mceTableRowProps',true],['cell_props','table.cell_desc','mceTableCellProps',true],['split_cells','table.split_cells_desc','mceTableSplitCells',true],['merge_cells','table.merge_cells_desc','mceTableMergeCells',true]],function(c){ed.addButton(c[0],{title:c[1],cmd:c[2],ui:c[3]});});if(ed.getParam('inline_styles')){ed.onPreProcess.add(function(ed,o){var dom=ed.dom;each(dom.select('table',o.node),function(n){var v;if(v=dom.getAttrib(n,'width')){dom.setStyle(n,'width',v);dom.setAttrib(n,'width');}if(v=dom.getAttrib(n,'height')){dom.setStyle(n,'height',v);dom.setAttrib(n,'height');}});});}ed.onInit.add(function(){if(ed&&ed.plugins.contextmenu){ed.plugins.contextmenu.onContextMenu.add(function(th,m,e){var sm,se=ed.selection,el=se.getNode()||ed.getBody();if(ed.dom.getParent(e,'td')||ed.dom.getParent(e,'th')){m.removeAll();if(el.nodeName=='A'&&!ed.dom.getAttrib(el,'name')){m.add({title:'advanced.link_desc',icon:'link',cmd:ed.plugins.advlink?'mceAdvLink':'mceLink',ui:true});m.add({title:'advanced.unlink_desc',icon:'unlink',cmd:'UnLink'});m.addSeparator();}if(el.nodeName=='IMG'&&el.className.indexOf('mceItem')==-1){m.add({title:'advanced.image_desc',icon:'image',cmd:ed.plugins.advimage?'mceAdvImage':'mceImage',ui:true});m.addSeparator();}m.add({title:'table.desc',icon:'table',cmd:'mceInsertTable',ui:true,value:{action:'insert'}});m.add({title:'table.props_desc',icon:'table_props',cmd:'mceInsertTable',ui:true});m.add({title:'table.del',icon:'delete_table',cmd:'mceTableDelete',ui:true});m.addSeparator();sm=m.addMenu({title:'table.cell'});sm.add({title:'table.cell_desc',icon:'cell_props',cmd:'mceTableCellProps',ui:true});sm.add({title:'table.split_cells_desc',icon:'split_cells',cmd:'mceTableSplitCells',ui:true});sm.add({title:'table.merge_cells_desc',icon:'merge_cells',cmd:'mceTableMergeCells',ui:true});sm=m.addMenu({title:'table.row'});sm.add({title:'table.row_desc',icon:'row_props',cmd:'mceTableRowProps',ui:true});sm.add({title:'table.row_before_desc',icon:'row_before',cmd:'mceTableInsertRowBefore'});sm.add({title:'table.row_after_desc',icon:'row_after',cmd:'mceTableInsertRowAfter'});sm.add({title:'table.delete_row_desc',icon:'delete_row',cmd:'mceTableDeleteRow'});sm.addSeparator();sm.add({title:'table.cut_row_desc',icon:'cut',cmd:'mceTableCutRow'});sm.add({title:'table.copy_row_desc',icon:'copy',cmd:'mceTableCopyRow'});sm.add({title:'table.paste_row_before_desc',icon:'paste',cmd:'mceTablePasteRowBefore'});sm.add({title:'table.paste_row_after_desc',icon:'paste',cmd:'mceTablePasteRowAfter'});sm=m.addMenu({title:'table.col'});sm.add({title:'table.col_before_desc',icon:'col_before',cmd:'mceTableInsertColBefore'});sm.add({title:'table.col_after_desc',icon:'col_after',cmd:'mceTableInsertColAfter'});sm.add({title:'table.delete_col_desc',icon:'delete_col',cmd:'mceTableDeleteCol'});}else m.add({title:'table.desc',icon:'table',cmd:'mceInsertTable',ui:true});});}});ed.onKeyDown.add(function(ed,e){if(e.keyCode==9&&ed.dom.getParent(ed.selection.getNode(),'TABLE')){if(!tinymce.isGecko&&!tinymce.isOpera){tinyMCE.execInstanceCommand(ed.editorId,"mceTableMoveToNextRow",true);return tinymce.dom.Event.cancel(e);}ed.undoManager.add();}});if(!tinymce.isIE){if(ed.getParam('table_selection',true)){ed.onClick.add(function(ed,e){e=e.target;if(e.nodeName==='TABLE')ed.selection.select(e);});}}ed.onNodeChange.add(function(ed,cm,n){var p=ed.dom.getParent(n,'td,th,caption');cm.setActive('table',n.nodeName==='TABLE'||!!p);if(p&&p.nodeName==='CAPTION')p=null;cm.setDisabled('delete_table',!p);cm.setDisabled('delete_col',!p);cm.setDisabled('delete_table',!p);cm.setDisabled('delete_row',!p);cm.setDisabled('col_after',!p);cm.setDisabled('col_before',!p);cm.setDisabled('row_after',!p);cm.setDisabled('row_before',!p);cm.setDisabled('row_props',!p);cm.setDisabled('cell_props',!p);cm.setDisabled('split_cells',!p||(parseInt(ed.dom.getAttrib(p,'colspan','1'))<2&&parseInt(ed.dom.getAttrib(p,'rowspan','1'))<2));cm.setDisabled('merge_cells',!p);});if(!tinymce.isIE){ed.onBeforeSetContent.add(function(ed,o){if(o.initial)o.content=o.content.replace(/<(td|th)([^>]+|)>\s*<\/(td|th)>/g,tinymce.isOpera?'<$1$2>&nbsp;</$1>':'<$1$2><br mce_bogus="1" /></$1>');});}},execCommand:function(cmd,ui,val){var ed=this.editor,b;switch(cmd){case"mceTableMoveToNextRow":case"mceInsertTable":case"mceTableRowProps":case"mceTableCellProps":case"mceTableSplitCells":case"mceTableMergeCells":case"mceTableInsertRowBefore":case"mceTableInsertRowAfter":case"mceTableDeleteRow":case"mceTableInsertColBefore":case"mceTableInsertColAfter":case"mceTableDeleteCol":case"mceTableCutRow":case"mceTableCopyRow":case"mceTablePasteRowBefore":case"mceTablePasteRowAfter":case"mceTableDelete":ed.execCommand('mceBeginUndoLevel');this._doExecCommand(cmd,ui,val);ed.execCommand('mceEndUndoLevel');return true;}return false;},getInfo:function(){return{longname:'Tables',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/table',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_doExecCommand:function(command,user_interface,value){var inst=this.editor,ed=inst,url=this.url;var focusElm=inst.selection.getNode();var trElm=inst.dom.getParent(focusElm,"tr");var tdElm=inst.dom.getParent(focusElm,"td,th");var tableElm=inst.dom.getParent(focusElm,"table");var doc=inst.contentWindow.document;var tableBorder=tableElm?tableElm.getAttribute("border"):"";if(trElm&&tdElm==null)tdElm=trElm.cells[0];function inArray(ar,v){for(var i=0;i<ar.length;i++){if(ar[i].length>0&&inArray(ar[i],v))return true;if(ar[i]==v)return true;}return false;}function select(dx,dy){var td;grid=getTableGrid(tableElm);dx=dx||0;dy=dy||0;dx=Math.max(cpos.cellindex+dx,0);dy=Math.max(cpos.rowindex+dy,0);inst.execCommand('mceRepaint');td=getCell(grid,dy,dx);if(td){inst.selection.select(td.firstChild||td);inst.selection.collapse(1);}};function makeTD(){var newTD=doc.createElement("td");if(!tinymce.isIE)newTD.innerHTML='<br mce_bogus="1"/>';}function getColRowSpan(td){var colspan=inst.dom.getAttrib(td,"colspan");var rowspan=inst.dom.getAttrib(td,"rowspan");colspan=colspan==""?1:parseInt(colspan);rowspan=rowspan==""?1:parseInt(rowspan);return{colspan:colspan,rowspan:rowspan};}function getCellPos(grid,td){var x,y;for(y=0;y<grid.length;y++){for(x=0;x<grid[y].length;x++){if(grid[y][x]==td)return{cellindex:x,rowindex:y};}}return null;}function getCell(grid,row,col){if(grid[row]&&grid[row][col])return grid[row][col];return null;}function getNextCell(table,cell){var cells=[],x=0,i,j,cell,nextCell;for(i=0;i<table.rows.length;i++)for(j=0;j<table.rows[i].cells.length;j++,x++)cells[x]=table.rows[i].cells[j];for(i=0;i<cells.length;i++)if(cells[i]==cell)if(nextCell=cells[i+1])return nextCell;}function getTableGrid(table){var grid=[],rows=table.rows,x,y,td,sd,xstart,x2,y2;for(y=0;y<rows.length;y++){for(x=0;x<rows[y].cells.length;x++){td=rows[y].cells[x];sd=getColRowSpan(td);for(xstart=x;grid[y]&&grid[y][xstart];xstart++);for(y2=y;y2<y+sd['rowspan'];y2++){if(!grid[y2])grid[y2]=[];for(x2=xstart;x2<xstart+sd['colspan'];x2++)grid[y2][x2]=td;}}}return grid;}function trimRow(table,tr,td,new_tr){var grid=getTableGrid(table),cpos=getCellPos(grid,td);var cells,lastElm;if(new_tr.cells.length!=tr.childNodes.length){cells=tr.childNodes;lastElm=null;for(var x=0;td=getCell(grid,cpos.rowindex,x);x++){var remove=true;var sd=getColRowSpan(td);if(inArray(cells,td)){new_tr.childNodes[x]._delete=true;}else if((lastElm==null||td!=lastElm)&&sd.colspan>1){for(var i=x;i<x+td.colSpan;i++)new_tr.childNodes[i]._delete=true;}if((lastElm==null||td!=lastElm)&&sd.rowspan>1)td.rowSpan=sd.rowspan+1;lastElm=td;}deleteMarked(tableElm);}}function prevElm(node,name){while((node=node.previousSibling)!=null){if(node.nodeName==name)return node;}return null;}function nextElm(node,names){var namesAr=names.split(',');while((node=node.nextSibling)!=null){for(var i=0;i<namesAr.length;i++){if(node.nodeName.toLowerCase()==namesAr[i].toLowerCase())return node;}}return null;}function deleteMarked(tbl){if(tbl.rows==0)return;var tr=tbl.rows[0];do{var next=nextElm(tr,"TR");if(tr._delete){tr.parentNode.removeChild(tr);continue;}var td=tr.cells[0];if(td.cells>1){do{var nexttd=nextElm(td,"TD,TH");if(td._delete)td.parentNode.removeChild(td);}while((td=nexttd)!=null);}}while((tr=next)!=null);}function addRows(td_elm,tr_elm,rowspan){td_elm.rowSpan=1;var trNext=nextElm(tr_elm,"TR");for(var i=1;i<rowspan&&trNext;i++){var newTD=doc.createElement("td");if(!tinymce.isIE)newTD.innerHTML='<br mce_bogus="1"/>';if(tinymce.isIE)trNext.insertBefore(newTD,trNext.cells(td_elm.cellIndex));else trNext.insertBefore(newTD,trNext.cells[td_elm.cellIndex]);trNext=nextElm(trNext,"TR");}}function copyRow(doc,table,tr){var grid=getTableGrid(table);var newTR=tr.cloneNode(false);var cpos=getCellPos(grid,tr.cells[0]);var lastCell=null;var tableBorder=inst.dom.getAttrib(table,"border");var tdElm=null;for(var x=0;tdElm=getCell(grid,cpos.rowindex,x);x++){var newTD=null;if(lastCell!=tdElm){for(var i=0;i<tr.cells.length;i++){if(tdElm==tr.cells[i]){newTD=tdElm.cloneNode(true);break;}}}if(newTD==null){newTD=doc.createElement("td");if(!tinymce.isIE)newTD.innerHTML='<br mce_bogus="1"/>';}newTD.colSpan=1;newTD.rowSpan=1;newTR.appendChild(newTD);lastCell=tdElm;}return newTR;}switch(command){case"mceTableMoveToNextRow":var nextCell=getNextCell(tableElm,tdElm);if(!nextCell){inst.execCommand("mceTableInsertRowAfter",tdElm);nextCell=getNextCell(tableElm,tdElm);}inst.selection.select(nextCell);inst.selection.collapse(true);return true;case"mceTableRowProps":if(trElm==null)return true;if(user_interface){inst.windowManager.open({url:url+'/row.htm',width:400+parseInt(inst.getLang('table.rowprops_delta_width',0)),height:295+parseInt(inst.getLang('table.rowprops_delta_height',0)),inline:1},{plugin_url:url});}return true;case"mceTableCellProps":if(tdElm==null)return true;if(user_interface){inst.windowManager.open({url:url+'/cell.htm',width:400+parseInt(inst.getLang('table.cellprops_delta_width',0)),height:295+parseInt(inst.getLang('table.cellprops_delta_height',0)),inline:1},{plugin_url:url});}return true;case"mceInsertTable":if(user_interface){inst.windowManager.open({url:url+'/table.htm',width:400+parseInt(inst.getLang('table.table_delta_width',0)),height:320+parseInt(inst.getLang('table.table_delta_height',0)),inline:1},{plugin_url:url,action:value?value.action:0});}return true;case"mceTableDelete":var table=inst.dom.getParent(inst.selection.getNode(),"table");if(table){table.parentNode.removeChild(table);inst.execCommand('mceRepaint');}return true;case"mceTableSplitCells":case"mceTableMergeCells":case"mceTableInsertRowBefore":case"mceTableInsertRowAfter":case"mceTableDeleteRow":case"mceTableInsertColBefore":case"mceTableInsertColAfter":case"mceTableDeleteCol":case"mceTableCutRow":case"mceTableCopyRow":case"mceTablePasteRowBefore":case"mceTablePasteRowAfter":if(!tableElm)return true;if(trElm&&tableElm!=trElm.parentNode)tableElm=trElm.parentNode;if(tableElm&&trElm){switch(command){case"mceTableCutRow":if(!trElm||!tdElm)return true;inst.tableRowClipboard=copyRow(doc,tableElm,trElm);inst.execCommand("mceTableDeleteRow");break;case"mceTableCopyRow":if(!trElm||!tdElm)return true;inst.tableRowClipboard=copyRow(doc,tableElm,trElm);break;case"mceTablePasteRowBefore":if(!trElm||!tdElm)return true;var newTR=inst.tableRowClipboard.cloneNode(true);var prevTR=prevElm(trElm,"TR");if(prevTR!=null)trimRow(tableElm,prevTR,prevTR.cells[0],newTR);trElm.parentNode.insertBefore(newTR,trElm);break;case"mceTablePasteRowAfter":if(!trElm||!tdElm)return true;var nextTR=nextElm(trElm,"TR");var newTR=inst.tableRowClipboard.cloneNode(true);trimRow(tableElm,trElm,tdElm,newTR);if(nextTR==null)trElm.parentNode.appendChild(newTR);else nextTR.parentNode.insertBefore(newTR,nextTR);break;case"mceTableInsertRowBefore":if(!trElm||!tdElm)return true;var grid=getTableGrid(tableElm);var cpos=getCellPos(grid,tdElm);var newTR=doc.createElement("tr");var lastTDElm=null;cpos.rowindex--;if(cpos.rowindex<0)cpos.rowindex=0;for(var x=0;tdElm=getCell(grid,cpos.rowindex,x);x++){if(tdElm!=lastTDElm){var sd=getColRowSpan(tdElm);if(sd['rowspan']==1){var newTD=doc.createElement("td");if(!tinymce.isIE)newTD.innerHTML='<br mce_bogus="1"/>';newTD.colSpan=tdElm.colSpan;newTR.appendChild(newTD);}else tdElm.rowSpan=sd['rowspan']+1;lastTDElm=tdElm;}}trElm.parentNode.insertBefore(newTR,trElm);select(0,1);break;case"mceTableInsertRowAfter":if(!trElm||!tdElm)return true;var grid=getTableGrid(tableElm);var cpos=getCellPos(grid,tdElm);var newTR=doc.createElement("tr");var lastTDElm=null;for(var x=0;tdElm=getCell(grid,cpos.rowindex,x);x++){if(tdElm!=lastTDElm){var sd=getColRowSpan(tdElm);if(sd['rowspan']==1){var newTD=doc.createElement("td");if(!tinymce.isIE)newTD.innerHTML='<br mce_bogus="1"/>';newTD.colSpan=tdElm.colSpan;newTR.appendChild(newTD);}else tdElm.rowSpan=sd['rowspan']+1;lastTDElm=tdElm;}}if(newTR.hasChildNodes()){var nextTR=nextElm(trElm,"TR");if(nextTR)nextTR.parentNode.insertBefore(newTR,nextTR);else tableElm.appendChild(newTR);}select(0,1);break;case"mceTableDeleteRow":if(!trElm||!tdElm)return true;var grid=getTableGrid(tableElm);var cpos=getCellPos(grid,tdElm);if(grid.length==1&&tableElm.nodeName=='TBODY'){inst.dom.remove(inst.dom.getParent(tableElm,"table"));return true;}var cells=trElm.cells;var nextTR=nextElm(trElm,"TR");for(var x=0;x<cells.length;x++){if(cells[x].rowSpan>1){var newTD=cells[x].cloneNode(true);var sd=getColRowSpan(cells[x]);newTD.rowSpan=sd.rowspan-1;var nextTD=nextTR.cells[x];if(nextTD==null)nextTR.appendChild(newTD);else nextTR.insertBefore(newTD,nextTD);}}var lastTDElm=null;for(var x=0;tdElm=getCell(grid,cpos.rowindex,x);x++){if(tdElm!=lastTDElm){var sd=getColRowSpan(tdElm);if(sd.rowspan>1){tdElm.rowSpan=sd.rowspan-1;}else{trElm=tdElm.parentNode;if(trElm.parentNode)trElm._delete=true;}lastTDElm=tdElm;}}deleteMarked(tableElm);select(0,-1);break;case"mceTableInsertColBefore":if(!trElm||!tdElm)return true;var grid=getTableGrid(inst.dom.getParent(tableElm,"table"));var cpos=getCellPos(grid,tdElm);var lastTDElm=null;for(var y=0;tdElm=getCell(grid,y,cpos.cellindex);y++){if(tdElm!=lastTDElm){var sd=getColRowSpan(tdElm);if(sd['colspan']==1){var newTD=doc.createElement(tdElm.nodeName);if(!tinymce.isIE)newTD.innerHTML='<br mce_bogus="1"/>';newTD.rowSpan=tdElm.rowSpan;tdElm.parentNode.insertBefore(newTD,tdElm);}else tdElm.colSpan++;lastTDElm=tdElm;}}select();break;case"mceTableInsertColAfter":if(!trElm||!tdElm)return true;var grid=getTableGrid(inst.dom.getParent(tableElm,"table"));var cpos=getCellPos(grid,tdElm);var lastTDElm=null;for(var y=0;tdElm=getCell(grid,y,cpos.cellindex);y++){if(tdElm!=lastTDElm){var sd=getColRowSpan(tdElm);if(sd['colspan']==1){var newTD=doc.createElement(tdElm.nodeName);if(!tinymce.isIE)newTD.innerHTML='<br mce_bogus="1"/>';newTD.rowSpan=tdElm.rowSpan;var nextTD=nextElm(tdElm,"TD,TH");if(nextTD==null)tdElm.parentNode.appendChild(newTD);else nextTD.parentNode.insertBefore(newTD,nextTD);}else tdElm.colSpan++;lastTDElm=tdElm;}}select(1);break;case"mceTableDeleteCol":if(!trElm||!tdElm)return true;var grid=getTableGrid(tableElm);var cpos=getCellPos(grid,tdElm);var lastTDElm=null;if((grid.length>1&&grid[0].length<=1)&&tableElm.nodeName=='TBODY'){inst.dom.remove(inst.dom.getParent(tableElm,"table"));return true;}for(var y=0;tdElm=getCell(grid,y,cpos.cellindex);y++){if(tdElm!=lastTDElm){var sd=getColRowSpan(tdElm);if(sd['colspan']>1)tdElm.colSpan=sd['colspan']-1;else{if(tdElm.parentNode)tdElm.parentNode.removeChild(tdElm);}lastTDElm=tdElm;}}select(-1);break;case"mceTableSplitCells":if(!trElm||!tdElm)return true;var spandata=getColRowSpan(tdElm);var colspan=spandata["colspan"];var rowspan=spandata["rowspan"];if(colspan>1||rowspan>1){tdElm.colSpan=1;for(var i=1;i<colspan;i++){var newTD=doc.createElement("td");if(!tinymce.isIE)newTD.innerHTML='<br mce_bogus="1"/>';trElm.insertBefore(newTD,nextElm(tdElm,"TD,TH"));if(rowspan>1)addRows(newTD,trElm,rowspan);}addRows(tdElm,trElm,rowspan);}tableElm=inst.dom.getParent(inst.selection.getNode(),"table");break;case"mceTableMergeCells":var rows=[];var sel=inst.selection.getSel();var grid=getTableGrid(tableElm);if(tinymce.isIE||sel.rangeCount==1){if(user_interface){var sp=getColRowSpan(tdElm);inst.windowManager.open({url:url+'/merge_cells.htm',width:240+parseInt(inst.getLang('table.merge_cells_delta_width',0)),height:110+parseInt(inst.getLang('table.merge_cells_delta_height',0)),inline:1},{action:"update",numcols:sp.colspan,numrows:sp.rowspan,plugin_url:url});return true;}else{var numRows=parseInt(value['numrows']);var numCols=parseInt(value['numcols']);var cpos=getCellPos(grid,tdElm);if((""+numRows)=="NaN")numRows=1;if((""+numCols)=="NaN")numCols=1;var tRows=tableElm.rows;for(var y=cpos.rowindex;y<grid.length;y++){var rowCells=[];for(var x=cpos.cellindex;x<grid[y].length;x++){var td=getCell(grid,y,x);if(td&&!inArray(rows,td)&&!inArray(rowCells,td)){var cp=getCellPos(grid,td);if(cp.cellindex<cpos.cellindex+numCols&&cp.rowindex<cpos.rowindex+numRows)rowCells[rowCells.length]=td;}}if(rowCells.length>0)rows[rows.length]=rowCells;var td=getCell(grid,cpos.rowindex,cpos.cellindex);each(ed.dom.select('br',td),function(e,i){if(i>0&&ed.dom.getAttrib('mce_bogus'))ed.dom.remove(e);});}}}else{var cells=[];var sel=inst.selection.getSel();var lastTR=null;var curRow=null;var x1=-1,y1=-1,x2,y2;if(sel.rangeCount<2)return true;for(var i=0;i<sel.rangeCount;i++){var rng=sel.getRangeAt(i);var tdElm=rng.startContainer.childNodes[rng.startOffset];if(!tdElm)break;if(tdElm.nodeName=="TD"||tdElm.nodeName=="TH")cells[cells.length]=tdElm;}var tRows=tableElm.rows;for(var y=0;y<tRows.length;y++){var rowCells=[];for(var x=0;x<tRows[y].cells.length;x++){var td=tRows[y].cells[x];for(var i=0;i<cells.length;i++){if(td==cells[i]){rowCells[rowCells.length]=td;}}}if(rowCells.length>0)rows[rows.length]=rowCells;}var curRow=[];var lastTR=null;for(var y=0;y<grid.length;y++){for(var x=0;x<grid[y].length;x++){grid[y][x]._selected=false;for(var i=0;i<cells.length;i++){if(grid[y][x]==cells[i]){if(x1==-1){x1=x;y1=y;}x2=x;y2=y;grid[y][x]._selected=true;}}}}for(var y=y1;y<=y2;y++){for(var x=x1;x<=x2;x++){if(!grid[y][x]._selected){alert("Invalid selection for merge.");return true;}}}}var rowSpan=1,colSpan=1;var lastRowSpan=-1;for(var y=0;y<rows.length;y++){var rowColSpan=0;for(var x=0;x<rows[y].length;x++){var sd=getColRowSpan(rows[y][x]);rowColSpan+=sd['colspan'];if(lastRowSpan!=-1&&sd['rowspan']!=lastRowSpan){alert("Invalid selection for merge.");return true;}lastRowSpan=sd['rowspan'];}if(rowColSpan>colSpan)colSpan=rowColSpan;lastRowSpan=-1;}var lastColSpan=-1;for(var x=0;x<rows[0].length;x++){var colRowSpan=0;for(var y=0;y<rows.length;y++){var sd=getColRowSpan(rows[y][x]);colRowSpan+=sd['rowspan'];if(lastColSpan!=-1&&sd['colspan']!=lastColSpan){alert("Invalid selection for merge.");return true;}lastColSpan=sd['colspan'];}if(colRowSpan>rowSpan)rowSpan=colRowSpan;lastColSpan=-1;}tdElm=rows[0][0];tdElm.rowSpan=rowSpan;tdElm.colSpan=colSpan;for(var y=0;y<rows.length;y++){for(var x=0;x<rows[y].length;x++){var html=rows[y][x].innerHTML;var chk=html.replace(/[ \t\r\n]/g,"");if(chk!="<br/>"&&chk!="<br>"&&chk!='<br mce_bogus="1"/>'&&(x+y>0))tdElm.innerHTML+=html;if(rows[y][x]!=tdElm&&!rows[y][x]._deleted){var cpos=getCellPos(grid,rows[y][x]);var tr=rows[y][x].parentNode;tr.removeChild(rows[y][x]);rows[y][x]._deleted=true;if(!tr.hasChildNodes()){tr.parentNode.removeChild(tr);var lastCell=null;for(var x=0;cellElm=getCell(grid,cpos.rowindex,x);x++){if(cellElm!=lastCell&&cellElm.rowSpan>1)cellElm.rowSpan--;lastCell=cellElm;}if(tdElm.rowSpan>1)tdElm.rowSpan--;}}}}each(ed.dom.select('br',tdElm),function(e,i){if(i>0&&ed.dom.getAttrib(e,'mce_bogus'))ed.dom.remove(e);});break;}tableElm=inst.dom.getParent(inst.selection.getNode(),"table");inst.addVisual(tableElm);inst.nodeChanged();}return true;}return false;}});tinymce.PluginManager.add('table',tinymce.plugins.TablePlugin);})();
\ No newline at end of file
+(function(){var b=tinymce.each;function a(d,e){var f=e.ownerDocument,c=f.createRange(),g;c.setStartBefore(e);c.setEnd(d.endContainer,d.endOffset);g=f.createElement("body");g.appendChild(c.cloneContents());return g.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length==0}tinymce.create("tinymce.plugins.TablePlugin",{init:function(c,d){var e=this;e.editor=c;e.url=d;b([["table","table.desc","mceInsertTable",true],["delete_table","table.del","mceTableDelete"],["delete_col","table.delete_col_desc","mceTableDeleteCol"],["delete_row","table.delete_row_desc","mceTableDeleteRow"],["col_after","table.col_after_desc","mceTableInsertColAfter"],["col_before","table.col_before_desc","mceTableInsertColBefore"],["row_after","table.row_after_desc","mceTableInsertRowAfter"],["row_before","table.row_before_desc","mceTableInsertRowBefore"],["row_props","table.row_desc","mceTableRowProps",true],["cell_props","table.cell_desc","mceTableCellProps",true],["split_cells","table.split_cells_desc","mceTableSplitCells",true],["merge_cells","table.merge_cells_desc","mceTableMergeCells",true]],function(f){c.addButton(f[0],{title:f[1],cmd:f[2],ui:f[3]})});if(c.getParam("inline_styles")){c.onPreProcess.add(function(f,h){var g=f.dom;b(g.select("table",h.node),function(j){var i;if(i=g.getAttrib(j,"width")){g.setStyle(j,"width",i);g.setAttrib(j,"width")}if(i=g.getAttrib(j,"height")){g.setStyle(j,"height",i);g.setAttrib(j,"height")}})})}c.onInit.add(function(){if(!tinymce.isIE&&c.getParam("forced_root_block")){function f(){var g=c.getBody().lastChild;if(g&&g.nodeName=="TABLE"){c.dom.add(c.getBody(),"p",null,'<br mce_bogus="1" />')}}if(tinymce.isGecko){c.onKeyDown.add(function(h,j){var g,i,k=h.dom;if(j.keyCode==37||j.keyCode==38){g=h.selection.getRng();i=k.getParent(g.startContainer,"table");if(i&&h.getBody().firstChild==i){if(a(g,i)){g=k.createRng();g.setStartBefore(i);g.setEndBefore(i);h.selection.setRng(g);j.preventDefault()}}}})}c.onKeyUp.add(f);c.onSetContent.add(f);c.onVisualAid.add(f);c.onPreProcess.add(function(g,i){var h=i.node.lastChild;if(h&&h.childNodes.length==1&&h.firstChild.nodeName=="BR"){g.dom.remove(h)}});f()}if(c&&c.plugins.contextmenu){c.plugins.contextmenu.onContextMenu.add(function(i,g,k){var l,j=c.selection,h=j.getNode()||c.getBody();if(c.dom.getParent(k,"td")||c.dom.getParent(k,"th")){g.removeAll();if(h.nodeName=="A"&&!c.dom.getAttrib(h,"name")){g.add({title:"advanced.link_desc",icon:"link",cmd:c.plugins.advlink?"mceAdvLink":"mceLink",ui:true});g.add({title:"advanced.unlink_desc",icon:"unlink",cmd:"UnLink"});g.addSeparator()}if(h.nodeName=="IMG"&&h.className.indexOf("mceItem")==-1){g.add({title:"advanced.image_desc",icon:"image",cmd:c.plugins.advimage?"mceAdvImage":"mceImage",ui:true});g.addSeparator()}g.add({title:"table.desc",icon:"table",cmd:"mceInsertTable",ui:true,value:{action:"insert"}});g.add({title:"table.props_desc",icon:"table_props",cmd:"mceInsertTable",ui:true});g.add({title:"table.del",icon:"delete_table",cmd:"mceTableDelete",ui:true});g.addSeparator();l=g.addMenu({title:"table.cell"});l.add({title:"table.cell_desc",icon:"cell_props",cmd:"mceTableCellProps",ui:true});l.add({title:"table.split_cells_desc",icon:"split_cells",cmd:"mceTableSplitCells",ui:true});l.add({title:"table.merge_cells_desc",icon:"merge_cells",cmd:"mceTableMergeCells",ui:true});l=g.addMenu({title:"table.row"});l.add({title:"table.row_desc",icon:"row_props",cmd:"mceTableRowProps",ui:true});l.add({title:"table.row_before_desc",icon:"row_before",cmd:"mceTableInsertRowBefore"});l.add({title:"table.row_after_desc",icon:"row_after",cmd:"mceTableInsertRowAfter"});l.add({title:"table.delete_row_desc",icon:"delete_row",cmd:"mceTableDeleteRow"});l.addSeparator();l.add({title:"table.cut_row_desc",icon:"cut",cmd:"mceTableCutRow"});l.add({title:"table.copy_row_desc",icon:"copy",cmd:"mceTableCopyRow"});l.add({title:"table.paste_row_before_desc",icon:"paste",cmd:"mceTablePasteRowBefore"});l.add({title:"table.paste_row_after_desc",icon:"paste",cmd:"mceTablePasteRowAfter"});l=g.addMenu({title:"table.col"});l.add({title:"table.col_before_desc",icon:"col_before",cmd:"mceTableInsertColBefore"});l.add({title:"table.col_after_desc",icon:"col_after",cmd:"mceTableInsertColAfter"});l.add({title:"table.delete_col_desc",icon:"delete_col",cmd:"mceTableDeleteCol"})}else{g.add({title:"table.desc",icon:"table",cmd:"mceInsertTable",ui:true})}})}});c.onKeyDown.add(function(f,g){if(g.keyCode==9&&f.dom.getParent(f.selection.getNode(),"TABLE")){if(!tinymce.isGecko&&!tinymce.isOpera){tinyMCE.execInstanceCommand(f.editorId,"mceTableMoveToNextRow",true);return tinymce.dom.Event.cancel(g)}f.undoManager.add()}});if(!tinymce.isIE){if(c.getParam("table_selection",true)){c.onClick.add(function(f,g){g=g.target;if(g.nodeName==="TABLE"){f.selection.select(g)}})}}c.onNodeChange.add(function(g,f,i){var h=g.dom.getParent(i,"td,th,caption");f.setActive("table",i.nodeName==="TABLE"||!!h);if(h&&h.nodeName==="CAPTION"){h=null}f.setDisabled("delete_table",!h);f.setDisabled("delete_col",!h);f.setDisabled("delete_table",!h);f.setDisabled("delete_row",!h);f.setDisabled("col_after",!h);f.setDisabled("col_before",!h);f.setDisabled("row_after",!h);f.setDisabled("row_before",!h);f.setDisabled("row_props",!h);f.setDisabled("cell_props",!h);f.setDisabled("split_cells",!h||(parseInt(g.dom.getAttrib(h,"colspan","1"))<2&&parseInt(g.dom.getAttrib(h,"rowspan","1"))<2));f.setDisabled("merge_cells",!h)});if(!tinymce.isIE){c.onBeforeSetContent.add(function(f,g){if(g.initial){g.content=g.content.replace(/<(td|th)([^>]+|)>\s*<\/(td|th)>/g,tinymce.isOpera?"<$1$2>&nbsp;</$1>":'<$1$2><br mce_bogus="1" /></$1>')}})}},execCommand:function(f,e,g){var d=this.editor,c;switch(f){case"mceTableMoveToNextRow":case"mceInsertTable":case"mceTableRowProps":case"mceTableCellProps":case"mceTableSplitCells":case"mceTableMergeCells":case"mceTableInsertRowBefore":case"mceTableInsertRowAfter":case"mceTableDeleteRow":case"mceTableInsertColBefore":case"mceTableInsertColAfter":case"mceTableDeleteCol":case"mceTableCutRow":case"mceTableCopyRow":case"mceTablePasteRowBefore":case"mceTablePasteRowAfter":case"mceTableDelete":d.execCommand("mceBeginUndoLevel");this._doExecCommand(f,e,g);d.execCommand("mceEndUndoLevel");return true}return false},getInfo:function(){return{longname:"Tables",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/table",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_doExecCommand:function(s,aa,af){var W=this.editor,av=W,h=this.url;var o=W.selection.getNode();var X=W.dom.getParent(o,"tr");var ar=W.dom.getParent(o,"td,th");var G=W.dom.getParent(o,"table");var l=W.contentWindow.document;var aw=G?G.getAttribute("border"):"";if(X&&ar==null){ar=X.cells[0]}function aq(y,x){for(var ay=0;ay<y.length;ay++){if(y[ay].length>0&&aq(y[ay],x)){return true}if(y[ay]==x){return true}}return false}function ak(x,i){var y;ae=f(G);x=x||0;i=i||0;x=Math.max(p.cellindex+x,0);i=Math.max(p.rowindex+i,0);W.execCommand("mceRepaint");y=e(ae,i,x);if(y){W.selection.select(y.firstChild||y);W.selection.collapse(1)}}function ai(){var i=l.createElement("td");if(!tinymce.isIE){i.innerHTML='<br mce_bogus="1"/>'}}function k(y){var x=W.dom.getAttrib(y,"colspan");var i=W.dom.getAttrib(y,"rowspan");x=x==""?1:parseInt(x);i=i==""?1:parseInt(i);return{colspan:x,rowspan:i}}function am(ay,aA){var i,az;for(az=0;az<ay.length;az++){for(i=0;i<ay[az].length;i++){if(ay[az][i]==aA){return{cellindex:i,rowindex:az}}}}return null}function e(x,y,i){if(x[y]&&x[y][i]){return x[y][i]}return null}function B(aD,ay){var aA=[],y=0,aB,az,ay,aC;for(aB=0;aB<aD.rows.length;aB++){for(az=0;az<aD.rows[aB].cells.length;az++,y++){aA[y]=aD.rows[aB].cells[az]}}for(aB=0;aB<aA.length;aB++){if(aA[aB]==ay){if(aC=aA[aB+1]){return aC}}}}function f(aF){var i=[],aG=aF.rows,aD,aC,az,aA,aE,ay,aB;for(aC=0;aC<aG.length;aC++){for(aD=0;aD<aG[aC].cells.length;aD++){az=aG[aC].cells[aD];aA=k(az);for(aE=aD;i[aC]&&i[aC][aE];aE++){}for(aB=aC;aB<aC+aA.rowspan;aB++){if(!i[aB]){i[aB]=[]}for(ay=aE;ay<aE+aA.colspan;ay++){i[aB][ay]=az}}}}return i}function n(aH,aE,az,ay){var y=f(aH),aG=am(y,az);var aI,aD;if(ay.cells.length!=aE.childNodes.length){aI=aE.childNodes;aD=null;for(var aF=0;az=e(y,aG.rowindex,aF);aF++){var aB=true;var aC=k(az);if(aq(aI,az)){ay.childNodes[aF]._delete=true}else{if((aD==null||az!=aD)&&aC.colspan>1){for(var aA=aF;aA<aF+az.colSpan;aA++){ay.childNodes[aA]._delete=true}}}if((aD==null||az!=aD)&&aC.rowspan>1){az.rowSpan=aC.rowspan+1}aD=az}C(G)}}function P(x,i){while((x=x.previousSibling)!=null){if(x.nodeName==i){return x}}return null}function ag(ay,az){var x=az.split(",");while((ay=ay.nextSibling)!=null){for(var y=0;y<x.length;y++){if(ay.nodeName.toLowerCase()==x[y].toLowerCase()){return ay}}}return null}function C(ay){if(ay.rows==0){return}var y=ay.rows[0];do{var x=ag(y,"TR");if(y._delete){y.parentNode.removeChild(y);continue}var az=y.cells[0];if(az.cells>1){do{var i=ag(az,"TD,TH");if(az._delete){az.parentNode.removeChild(az)}}while((az=i)!=null)}}while((y=x)!=null)}function q(ay,aB,aA){ay.rowSpan=1;var x=ag(aB,"TR");for(var az=1;az<aA&&x;az++){var y=l.createElement("td");if(!tinymce.isIE){y.innerHTML='<br mce_bogus="1"/>'}if(tinymce.isIE){x.insertBefore(y,x.cells(ay.cellIndex))}else{x.insertBefore(y,x.cells[ay.cellIndex])}x=ag(x,"TR")}}function T(aG,aI,aC){var y=f(aI);var ay=aC.cloneNode(false);var aH=am(y,aC.cells[0]);var aD=null;var aB=W.dom.getAttrib(aI,"border");var aA=null;for(var aF=0;aA=e(y,aH.rowindex,aF);aF++){var aE=null;if(aD!=aA){for(var az=0;az<aC.cells.length;az++){if(aA==aC.cells[az]){aE=aA.cloneNode(true);break}}}if(aE==null){aE=aG.createElement("td");if(!tinymce.isIE){aE.innerHTML='<br mce_bogus="1"/>'}}aE.colSpan=1;aE.rowSpan=1;ay.appendChild(aE);aD=aA}return ay}switch(s){case"mceTableMoveToNextRow":var M=B(G,ar);if(!M){W.execCommand("mceTableInsertRowAfter",ar);M=B(G,ar)}W.selection.select(M);W.selection.collapse(true);return true;case"mceTableRowProps":if(X==null){return true}if(aa){W.windowManager.open({url:h+"/row.htm",width:400+parseInt(W.getLang("table.rowprops_delta_width",0)),height:295+parseInt(W.getLang("table.rowprops_delta_height",0)),inline:1},{plugin_url:h})}return true;case"mceTableCellProps":if(ar==null){return true}if(aa){W.windowManager.open({url:h+"/cell.htm",width:400+parseInt(W.getLang("table.cellprops_delta_width",0)),height:295+parseInt(W.getLang("table.cellprops_delta_height",0)),inline:1},{plugin_url:h})}return true;case"mceInsertTable":if(aa){W.windowManager.open({url:h+"/table.htm",width:400+parseInt(W.getLang("table.table_delta_width",0)),height:320+parseInt(W.getLang("table.table_delta_height",0)),inline:1},{plugin_url:h,action:af?af.action:0})}return true;case"mceTableDelete":var H=W.dom.getParent(W.selection.getNode(),"table");if(H){H.parentNode.removeChild(H);W.execCommand("mceRepaint")}return true;case"mceTableSplitCells":case"mceTableMergeCells":case"mceTableInsertRowBefore":case"mceTableInsertRowAfter":case"mceTableDeleteRow":case"mceTableInsertColBefore":case"mceTableInsertColAfter":case"mceTableDeleteCol":case"mceTableCutRow":case"mceTableCopyRow":case"mceTablePasteRowBefore":case"mceTablePasteRowAfter":if(!G){return true}if(X&&G!=X.parentNode){G=X.parentNode}if(G&&X){switch(s){case"mceTableCutRow":if(!X||!ar){return true}W.tableRowClipboard=T(l,G,X);W.execCommand("mceTableDeleteRow");break;case"mceTableCopyRow":if(!X||!ar){return true}W.tableRowClipboard=T(l,G,X);break;case"mceTablePasteRowBefore":if(!X||!ar){return true}var w=W.tableRowClipboard.cloneNode(true);var j=P(X,"TR");if(j!=null){n(G,j,j.cells[0],w)}X.parentNode.insertBefore(w,X);break;case"mceTablePasteRowAfter":if(!X||!ar){return true}var Y=ag(X,"TR");var w=W.tableRowClipboard.cloneNode(true);n(G,X,ar,w);if(Y==null){X.parentNode.appendChild(w)}else{Y.parentNode.insertBefore(w,Y)}break;case"mceTableInsertRowBefore":if(!X||!ar){return true}var ae=f(G);var p=am(ae,ar);var w=l.createElement("tr");var v=null;p.rowindex--;if(p.rowindex<0){p.rowindex=0}for(var ad=0;ar=e(ae,p.rowindex,ad);ad++){if(ar!=v){var F=k(ar);if(F.rowspan==1){var K=l.createElement("td");if(!tinymce.isIE){K.innerHTML='<br mce_bogus="1"/>'}K.colSpan=ar.colSpan;w.appendChild(K)}else{ar.rowSpan=F.rowspan+1}v=ar}}X.parentNode.insertBefore(w,X);ak(0,1);break;case"mceTableInsertRowAfter":if(!X||!ar){return true}var ae=f(G);var p=am(ae,ar);var w=l.createElement("tr");var v=null;for(var ad=0;ar=e(ae,p.rowindex,ad);ad++){if(ar!=v){var F=k(ar);if(F.rowspan==1){var K=l.createElement("td");if(!tinymce.isIE){K.innerHTML='<br mce_bogus="1"/>'}K.colSpan=ar.colSpan;w.appendChild(K)}else{ar.rowSpan=F.rowspan+1}v=ar}}if(w.hasChildNodes()){var Y=ag(X,"TR");if(Y){Y.parentNode.insertBefore(w,Y)}else{G.appendChild(w)}}ak(0,1);break;case"mceTableDeleteRow":if(!X||!ar){return true}var ae=f(G);var p=am(ae,ar);if(ae.length==1&&G.nodeName=="TBODY"){W.dom.remove(W.dom.getParent(G,"table"));return true}var E=X.cells;var Y=ag(X,"TR");for(var ad=0;ad<E.length;ad++){if(E[ad].rowSpan>1){var K=E[ad].cloneNode(true);var F=k(E[ad]);K.rowSpan=F.rowspan-1;var al=Y.cells[ad];if(al==null){Y.appendChild(K)}else{Y.insertBefore(K,al)}}}var v=null;for(var ad=0;ar=e(ae,p.rowindex,ad);ad++){if(ar!=v){var F=k(ar);if(F.rowspan>1){ar.rowSpan=F.rowspan-1}else{X=ar.parentNode;if(X.parentNode){X._delete=true}}v=ar}}C(G);ak(0,-1);break;case"mceTableInsertColBefore":if(!X||!ar){return true}var ae=f(W.dom.getParent(G,"table"));var p=am(ae,ar);var v=null;for(var ab=0;ar=e(ae,ab,p.cellindex);ab++){if(ar!=v){var F=k(ar);if(F.colspan==1){var K=l.createElement(ar.nodeName);if(!tinymce.isIE){K.innerHTML='<br mce_bogus="1"/>'}K.rowSpan=ar.rowSpan;ar.parentNode.insertBefore(K,ar)}else{ar.colSpan++}v=ar}}ak();break;case"mceTableInsertColAfter":if(!X||!ar){return true}var ae=f(W.dom.getParent(G,"table"));var p=am(ae,ar);var v=null;for(var ab=0;ar=e(ae,ab,p.cellindex);ab++){if(ar!=v){var F=k(ar);if(F.colspan==1){var K=l.createElement(ar.nodeName);if(!tinymce.isIE){K.innerHTML='<br mce_bogus="1"/>'}K.rowSpan=ar.rowSpan;var al=ag(ar,"TD,TH");if(al==null){ar.parentNode.appendChild(K)}else{al.parentNode.insertBefore(K,al)}}else{ar.colSpan++}v=ar}}ak(1);break;case"mceTableDeleteCol":if(!X||!ar){return true}var ae=f(G);var p=am(ae,ar);var v=null;if((ae.length>1&&ae[0].length<=1)&&G.nodeName=="TBODY"){W.dom.remove(W.dom.getParent(G,"table"));return true}for(var ab=0;ar=e(ae,ab,p.cellindex);ab++){if(ar!=v){var F=k(ar);if(F.colspan>1){ar.colSpan=F.colspan-1}else{if(ar.parentNode){ar.parentNode.removeChild(ar)}}v=ar}}ak(-1);break;case"mceTableSplitCells":if(!X||!ar){return true}var m=k(ar);var D=m.colspan;var I=m.rowspan;if(D>1||I>1){ar.colSpan=1;for(var an=1;an<D;an++){var K=l.createElement("td");if(!tinymce.isIE){K.innerHTML='<br mce_bogus="1"/>'}X.insertBefore(K,ag(ar,"TD,TH"));if(I>1){q(K,X,I)}}q(ar,X,I)}G=W.dom.getParent(W.selection.getNode(),"table");break;case"mceTableMergeCells":var ap=[];var S=W.selection.getSel();var ae=f(G);if(tinymce.isIE||S.rangeCount==1){if(aa){var u=k(ar);W.windowManager.open({url:h+"/merge_cells.htm",width:240+parseInt(W.getLang("table.merge_cells_delta_width",0)),height:110+parseInt(W.getLang("table.merge_cells_delta_height",0)),inline:1},{action:"update",numcols:u.colspan,numrows:u.rowspan,plugin_url:h});return true}else{var V=parseInt(af.numrows);var d=parseInt(af.numcols);var p=am(ae,ar);if((""+V)=="NaN"){V=1}if((""+d)=="NaN"){d=1}var c=G.rows;for(var ab=p.rowindex;ab<ae.length;ab++){var ah=[];for(var ad=p.cellindex;ad<ae[ab].length;ad++){var g=e(ae,ab,ad);if(g&&!aq(ap,g)&&!aq(ah,g)){var O=am(ae,g);if(O.cellindex<p.cellindex+d&&O.rowindex<p.rowindex+V){ah[ah.length]=g}}}if(ah.length>0){ap[ap.length]=ah}var g=e(ae,p.rowindex,p.cellindex);b(av.dom.select("br",g),function(y,x){if(x>0&&av.dom.getAttrib("mce_bogus")){av.dom.remove(y)}})}}}else{var E=[];var S=W.selection.getSel();var Z=null;var ao=null;var A=-1,ax=-1,z,au;if(S.rangeCount<2){return true}for(var an=0;an<S.rangeCount;an++){var aj=S.getRangeAt(an);var ar=aj.startContainer.childNodes[aj.startOffset];if(!ar){break}if(ar.nodeName=="TD"||ar.nodeName=="TH"){E[E.length]=ar}}var c=G.rows;for(var ab=0;ab<c.length;ab++){var ah=[];for(var ad=0;ad<c[ab].cells.length;ad++){var g=c[ab].cells[ad];for(var an=0;an<E.length;an++){if(g==E[an]){ah[ah.length]=g}}}if(ah.length>0){ap[ap.length]=ah}}var ao=[];var Z=null;for(var ab=0;ab<ae.length;ab++){for(var ad=0;ad<ae[ab].length;ad++){ae[ab][ad]._selected=false;for(var an=0;an<E.length;an++){if(ae[ab][ad]==E[an]){if(A==-1){A=ad;ax=ab}z=ad;au=ab;ae[ab][ad]._selected=true}}}}for(var ab=ax;ab<=au;ab++){for(var ad=A;ad<=z;ad++){if(!ae[ab][ad]._selected){alert("Invalid selection for merge.");return true}}}}var t=1,r=1;var U=-1;for(var ab=0;ab<ap.length;ab++){var J=0;for(var ad=0;ad<ap[ab].length;ad++){var F=k(ap[ab][ad]);J+=F.colspan;if(U!=-1&&F.rowspan!=U){alert("Invalid selection for merge.");return true}U=F.rowspan}if(J>r){r=J}U=-1}var R=-1;for(var ad=0;ad<ap[0].length;ad++){var N=0;for(var ab=0;ab<ap.length;ab++){var F=k(ap[ab][ad]);N+=F.rowspan;if(R!=-1&&F.colspan!=R){alert("Invalid selection for merge.");return true}R=F.colspan}if(N>t){t=N}R=-1}ar=ap[0][0];ar.rowSpan=t;ar.colSpan=r;for(var ab=0;ab<ap.length;ab++){for(var ad=0;ad<ap[ab].length;ad++){var Q=ap[ab][ad].innerHTML;var L=Q.replace(/[ \t\r\n]/g,"");if(L!="<br/>"&&L!="<br>"&&L!='<br mce_bogus="1"/>'&&(ad+ab>0)){ar.innerHTML+=Q}if(ap[ab][ad]!=ar&&!ap[ab][ad]._deleted){var p=am(ae,ap[ab][ad]);var at=ap[ab][ad].parentNode;at.removeChild(ap[ab][ad]);ap[ab][ad]._deleted=true;if(!at.hasChildNodes()){at.parentNode.removeChild(at);var ac=null;for(var ad=0;cellElm=e(ae,p.rowindex,ad);ad++){if(cellElm!=ac&&cellElm.rowSpan>1){cellElm.rowSpan--}ac=cellElm}if(ar.rowSpan>1){ar.rowSpan--}}}}}b(av.dom.select("br",ar),function(y,x){if(x>0&&av.dom.getAttrib(y,"mce_bogus")){av.dom.remove(y)}});break}G=W.dom.getParent(W.selection.getNode(),"table");W.addVisual(G);W.nodeChanged()}return true}return false}});tinymce.PluginManager.add("table",tinymce.plugins.TablePlugin)})();
\ No newline at end of file