summaryrefslogtreecommitdiff
path: root/program/js/tiny_mce/plugins/table
diff options
context:
space:
mode:
authortill <till@php.net>2011-11-02 15:14:32 +0000
committertill <till@php.net>2011-11-02 15:14:32 +0000
commit4dd50a41ee477806745a05772d5abbf16d23db89 (patch)
tree3d65607d946f0eaecb468b8a21d40f147bc87fda /program/js/tiny_mce/plugins/table
parentd6284b4d22d1e6912b01228b7d2a63e9fecbc5fb (diff)
fix path/structure (my bad)
Diffstat (limited to 'program/js/tiny_mce/plugins/table')
-rw-r--r--program/js/tiny_mce/plugins/table/cell.htm180
-rw-r--r--program/js/tiny_mce/plugins/table/css/cell.css17
-rw-r--r--program/js/tiny_mce/plugins/table/css/row.css25
-rw-r--r--program/js/tiny_mce/plugins/table/css/table.css13
-rw-r--r--program/js/tiny_mce/plugins/table/editor_plugin.js1
-rw-r--r--program/js/tiny_mce/plugins/table/editor_plugin_src.js1364
-rw-r--r--program/js/tiny_mce/plugins/table/js/cell.js319
-rw-r--r--program/js/tiny_mce/plugins/table/js/merge_cells.js27
-rw-r--r--program/js/tiny_mce/plugins/table/js/row.js237
-rw-r--r--program/js/tiny_mce/plugins/table/js/table.js450
-rw-r--r--program/js/tiny_mce/plugins/table/langs/en_dlg.js1
-rw-r--r--program/js/tiny_mce/plugins/table/merge_cells.htm32
-rw-r--r--program/js/tiny_mce/plugins/table/row.htm158
-rw-r--r--program/js/tiny_mce/plugins/table/table.htm188
14 files changed, 3012 insertions, 0 deletions
diff --git a/program/js/tiny_mce/plugins/table/cell.htm b/program/js/tiny_mce/plugins/table/cell.htm
new file mode 100644
index 000000000..a72a8d697
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/cell.htm
@@ -0,0 +1,180 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>{#table_dlg.cell_title}</title>
+ <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
+ <script type="text/javascript" src="../../utils/mctabs.js"></script>
+ <script type="text/javascript" src="../../utils/form_utils.js"></script>
+ <script type="text/javascript" src="../../utils/validate.js"></script>
+ <script type="text/javascript" src="../../utils/editable_selects.js"></script>
+ <script type="text/javascript" src="js/cell.js"></script>
+ <link href="css/cell.css" rel="stylesheet" type="text/css" />
+</head>
+<body id="tablecell" style="display: none" role="application">
+ <form onsubmit="updateAction();return false;" action="#">
+ <div class="tabs">
+ <ul>
+ <li id="general_tab" class="current" aria-controls="general_panel"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#table_dlg.general_tab}</a></span></li>
+ <li id="advanced_tab" aria-controls="advanced_panel"><span><a href="javascript:mcTabs.displayTab('advanced_tab','advanced_panel');" onmousedown="return false;">{#table_dlg.advanced_tab}</a></span></li>
+ </ul>
+ </div>
+
+ <div class="panel_wrapper">
+ <div id="general_panel" class="panel current">
+ <fieldset>
+ <legend>{#table_dlg.general_props}</legend>
+
+ <table role="presentation" border="0" cellpadding="4" cellspacing="0">
+ <tr>
+ <td><label for="align">{#table_dlg.align}</label></td>
+ <td>
+ <select id="align" name="align" class="mceFocus">
+ <option value="">{#not_set}</option>
+ <option value="center">{#table_dlg.align_middle}</option>
+ <option value="left">{#table_dlg.align_left}</option>
+ <option value="right">{#table_dlg.align_right}</option>
+ </select>
+ </td>
+
+ <td><label for="celltype">{#table_dlg.cell_type}</label></td>
+ <td>
+ <select id="celltype" name="celltype">
+ <option value="td">{#table_dlg.td}</option>
+ <option value="th">{#table_dlg.th}</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td><label for="valign">{#table_dlg.valign}</label></td>
+ <td>
+ <select id="valign" name="valign">
+ <option value="">{#not_set}</option>
+ <option value="top">{#table_dlg.align_top}</option>
+ <option value="middle">{#table_dlg.align_middle}</option>
+ <option value="bottom">{#table_dlg.align_bottom}</option>
+ </select>
+ </td>
+
+ <td><label for="scope">{#table_dlg.scope}</label></td>
+ <td>
+ <select id="scope" name="scope">
+ <option value="">{#not_set}</option>
+ <option value="col">{#table.col}</option>
+ <option value="row">{#table.row}</option>
+ <option value="rowgroup">{#table_dlg.rowgroup}</option>
+ <option value="colgroup">{#table_dlg.colgroup}</option>
+ </select>
+ </td>
+
+ </tr>
+
+ <tr>
+ <td><label for="width">{#table_dlg.width}</label></td>
+ <td><input id="width" name="width" type="text" value="" size="7" maxlength="7" onchange="changedSize();" class="size" /></td>
+
+ <td><label for="height">{#table_dlg.height}</label></td>
+ <td><input id="height" name="height" type="text" value="" size="7" maxlength="7" onchange="changedSize();" class="size" /></td>
+ </tr>
+
+ <tr id="styleSelectRow">
+ <td><label for="class">{#class_name}</label></td>
+ <td colspan="3">
+ <select id="class" name="class" class="mceEditableSelect">
+ <option value="" selected="selected">{#not_set}</option>
+ </select>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+ </div>
+
+ <div id="advanced_panel" class="panel">
+ <fieldset>
+ <legend>{#table_dlg.advanced_props}</legend>
+
+ <table role="presentation" border="0" cellpadding="0" cellspacing="4">
+ <tr>
+ <td class="column1"><label for="id">{#table_dlg.id}</label></td>
+ <td><input id="id" name="id" type="text" value="" style="width: 200px" /></td>
+ </tr>
+
+ <tr>
+ <td><label for="style">{#table_dlg.style}</label></td>
+ <td><input type="text" id="style" name="style" value="" style="width: 200px;" onchange="changedStyle();" /></td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="dir">{#table_dlg.langdir}</label></td>
+ <td>
+ <select id="dir" name="dir" style="width: 200px">
+ <option value="">{#not_set}</option>
+ <option value="ltr">{#table_dlg.ltr}</option>
+ <option value="rtl">{#table_dlg.rtl}</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="lang">{#table_dlg.langcode}</label></td>
+ <td>
+ <input id="lang" name="lang" type="text" value="" style="width: 200px" />
+ </td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="backgroundimage">{#table_dlg.bgimage}</label></td>
+ <td>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input id="backgroundimage" name="backgroundimage" type="text" value="" style="width: 200px" onchange="changedBackgroundImage();" /></td>
+ <td id="backgroundimagebrowsercontainer">&nbsp;</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr role="group" aria-labelledby="bordercolor_label">
+ <td class="column1"><label id="bordercolor_label" for="bordercolor">{#table_dlg.bordercolor}</label></td>
+ <td>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input id="bordercolor" name="bordercolor" type="text" value="" size="9" onchange="updateColor('bordercolor_pick','bordercolor');changedColor();" /></td>
+ <td id="bordercolor_pickcontainer">&nbsp;</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr role="group" aria-labelledby="bgcolor_label">
+ <td class="column1"><label id="bgcolor_label" for="bgcolor">{#table_dlg.bgcolor}</label></td>
+ <td>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input id="bgcolor" name="bgcolor" type="text" value="" size="9" onchange="updateColor('bgcolor_pick','bgcolor');changedColor();" /></td>
+ <td id="bgcolor_pickcontainer">&nbsp;</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+ </div>
+ </div>
+
+ <div class="mceActionPanel">
+ <div>
+ <select id="action" name="action">
+ <option value="cell">{#table_dlg.cell_cell}</option>
+ <option value="row">{#table_dlg.cell_row}</option>
+ <option value="col">{#table_dlg.cell_col}</option>
+ <option value="all">{#table_dlg.cell_all}</option>
+ </select>
+ </div>
+
+ <input type="submit" id="insert" name="insert" value="{#update}" />
+ <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+ </div>
+ </form>
+</body>
+</html>
diff --git a/program/js/tiny_mce/plugins/table/css/cell.css b/program/js/tiny_mce/plugins/table/css/cell.css
new file mode 100644
index 000000000..a067ecdfe
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/css/cell.css
@@ -0,0 +1,17 @@
+/* CSS file for cell dialog in the table plugin */
+
+.panel_wrapper div.current {
+ height: 200px;
+}
+
+.advfield {
+ width: 200px;
+}
+
+#action {
+ margin-bottom: 3px;
+}
+
+#class {
+ width: 150px;
+} \ No newline at end of file
diff --git a/program/js/tiny_mce/plugins/table/css/row.css b/program/js/tiny_mce/plugins/table/css/row.css
new file mode 100644
index 000000000..1f7755daf
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/css/row.css
@@ -0,0 +1,25 @@
+/* CSS file for row dialog in the table plugin */
+
+.panel_wrapper div.current {
+ height: 200px;
+}
+
+.advfield {
+ width: 200px;
+}
+
+#action {
+ margin-bottom: 3px;
+}
+
+#rowtype,#align,#valign,#class,#height {
+ width: 150px;
+}
+
+#height {
+ width: 50px;
+}
+
+.col2 {
+ padding-left: 20px;
+}
diff --git a/program/js/tiny_mce/plugins/table/css/table.css b/program/js/tiny_mce/plugins/table/css/table.css
new file mode 100644
index 000000000..d11c3f69c
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/css/table.css
@@ -0,0 +1,13 @@
+/* CSS file for table dialog in the table plugin */
+
+.panel_wrapper div.current {
+ height: 245px;
+}
+
+.advfield {
+ width: 200px;
+}
+
+#class {
+ width: 150px;
+}
diff --git a/program/js/tiny_mce/plugins/table/editor_plugin.js b/program/js/tiny_mce/plugins/table/editor_plugin.js
new file mode 100644
index 000000000..94e3c210f
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/editor_plugin.js
@@ -0,0 +1 @@
+(function(d){var e=d.each;function c(g,h){var j=h.ownerDocument,f=j.createRange(),k;f.setStartBefore(h);f.setEnd(g.endContainer,g.endOffset);k=j.createElement("body");k.appendChild(f.cloneContents());return k.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length==0}function a(g,f){return parseInt(g.getAttribute(f)||1)}function b(H,G,K){var g,L,D,o;t();o=G.getParent(K.getStart(),"th,td");if(o){L=F(o);D=I();o=z(L.x,L.y)}function A(N,M){N=N.cloneNode(M);N.removeAttribute("id");return N}function t(){var M=0;g=[];e(["thead","tbody","tfoot"],function(N){var O=G.select("> "+N+" tr",H);e(O,function(P,Q){Q+=M;e(G.select("> td, > th",P),function(W,R){var S,T,U,V;if(g[Q]){while(g[Q][R]){R++}}U=a(W,"rowspan");V=a(W,"colspan");for(T=Q;T<Q+U;T++){if(!g[T]){g[T]=[]}for(S=R;S<R+V;S++){g[T][S]={part:N,real:T==Q&&S==R,elm:W,rowspan:U,colspan:V}}}})});M+=O.length})}function z(M,O){var N;N=g[O];if(N){return N[M]}}function s(O,M,N){if(O){N=parseInt(N);if(N===1){O.removeAttribute(M,1)}else{O.setAttribute(M,N,1)}}}function j(M){return M&&(G.hasClass(M.elm,"mceSelected")||M==o)}function k(){var M=[];e(H.rows,function(N){e(N.cells,function(O){if(G.hasClass(O,"mceSelected")||O==o.elm){M.push(N);return false}})});return M}function r(){var M=G.createRng();M.setStartAfter(H);M.setEndAfter(H);K.setRng(M);G.remove(H)}function f(M){var N;d.walk(M,function(P){var O;if(P.nodeType==3){e(G.getParents(P.parentNode,null,M).reverse(),function(Q){Q=A(Q,false);if(!N){N=O=Q}else{if(O){O.appendChild(Q)}}O=Q});if(O){O.innerHTML=d.isIE?"&nbsp;":'<br data-mce-bogus="1" />'}return false}},"childNodes");M=A(M,false);s(M,"rowSpan",1);s(M,"colSpan",1);if(N){M.appendChild(N)}else{if(!d.isIE){M.innerHTML='<br data-mce-bogus="1" />'}}return M}function q(){var M=G.createRng();e(G.select("tr",H),function(N){if(N.cells.length==0){G.remove(N)}});if(G.select("tr",H).length==0){M.setStartAfter(H);M.setEndAfter(H);K.setRng(M);G.remove(H);return}e(G.select("thead,tbody,tfoot",H),function(N){if(N.rows.length==0){G.remove(N)}});t();row=g[Math.min(g.length-1,L.y)];if(row){K.select(row[Math.min(row.length-1,L.x)].elm,true);K.collapse(true)}}function u(S,Q,U,R){var P,N,M,O,T;P=g[Q][S].elm.parentNode;for(M=1;M<=U;M++){P=G.getNext(P,"tr");if(P){for(N=S;N>=0;N--){T=g[Q+M][N].elm;if(T.parentNode==P){for(O=1;O<=R;O++){G.insertAfter(f(T),T)}break}}if(N==-1){for(O=1;O<=R;O++){P.insertBefore(f(P.cells[0]),P.cells[0])}}}}}function C(){e(g,function(M,N){e(M,function(P,O){var S,R,T,Q;if(j(P)){P=P.elm;S=a(P,"colspan");R=a(P,"rowspan");if(S>1||R>1){s(P,"rowSpan",1);s(P,"colSpan",1);for(Q=0;Q<S-1;Q++){G.insertAfter(f(P),P)}u(O,N,R-1,S)}}})})}function p(V,S,Y){var P,O,X,W,U,R,T,M,V,N,Q;if(V){pos=F(V);P=pos.x;O=pos.y;X=P+(S-1);W=O+(Y-1)}else{P=L.x;O=L.y;X=D.x;W=D.y}T=z(P,O);M=z(X,W);if(T&&M&&T.part==M.part){C();t();T=z(P,O).elm;s(T,"colSpan",(X-P)+1);s(T,"rowSpan",(W-O)+1);for(R=O;R<=W;R++){for(U=P;U<=X;U++){if(!g[R]||!g[R][U]){continue}V=g[R][U].elm;if(V!=T){N=d.grep(V.childNodes);e(N,function(Z){T.appendChild(Z)});if(N.length){N=d.grep(T.childNodes);Q=0;e(N,function(Z){if(Z.nodeName=="BR"&&G.getAttrib(Z,"data-mce-bogus")&&Q++<N.length-1){T.removeChild(Z)}})}G.remove(V)}}}q()}}function l(Q){var M,S,P,R,T,U,N,V,O;e(g,function(W,X){e(W,function(Z,Y){if(j(Z)){Z=Z.elm;T=Z.parentNode;U=A(T,false);M=X;if(Q){return false}}});if(Q){return !M}});for(R=0;R<g[0].length;R++){if(!g[M][R]){continue}S=g[M][R].elm;if(S!=P){if(!Q){O=a(S,"rowspan");if(O>1){s(S,"rowSpan",O+1);continue}}else{if(M>0&&g[M-1][R]){V=g[M-1][R].elm;O=a(V,"rowSpan");if(O>1){s(V,"rowSpan",O+1);continue}}}N=f(S);s(N,"colSpan",S.colSpan);U.appendChild(N);P=S}}if(U.hasChildNodes()){if(!Q){G.insertAfter(U,T)}else{T.parentNode.insertBefore(U,T)}}}function h(N){var O,M;e(g,function(P,Q){e(P,function(S,R){if(j(S)){O=R;if(N){return false}}});if(N){return !O}});e(g,function(S,T){var P,Q,R;if(!S[O]){return}P=S[O].elm;if(P!=M){R=a(P,"colspan");Q=a(P,"rowspan");if(R==1){if(!N){G.insertAfter(f(P),P);u(O,T,Q-1,R)}else{P.parentNode.insertBefore(f(P),P);u(O,T,Q-1,R)}}else{s(P,"colSpan",P.colSpan+1)}M=P}})}function n(){var M=[];e(g,function(N,O){e(N,function(Q,P){if(j(Q)&&d.inArray(M,P)===-1){e(g,function(T){var R=T[P].elm,S;S=a(R,"colSpan");if(S>1){s(R,"colSpan",S-1)}else{G.remove(R)}});M.push(P)}})});q()}function m(){var N;function M(Q){var P,R,O;P=G.getNext(Q,"tr");e(Q.cells,function(S){var T=a(S,"rowSpan");if(T>1){s(S,"rowSpan",T-1);R=F(S);u(R.x,R.y,1,1)}});R=F(Q.cells[0]);e(g[R.y],function(S){var T;S=S.elm;if(S!=O){T=a(S,"rowSpan");if(T<=1){G.remove(S)}else{s(S,"rowSpan",T-1)}O=S}})}N=k();e(N.reverse(),function(O){M(O)});q()}function E(){var M=k();G.remove(M);q();return M}function J(){var M=k();e(M,function(O,N){M[N]=A(O,true)});return M}function B(O,N){var P=k(),M=P[N?0:P.length-1],Q=M.cells.length;e(g,function(S){var R;Q=0;e(S,function(U,T){if(U.real){Q+=U.colspan}if(U.elm.parentNode==M){R=1}});if(R){return false}});if(!N){O.reverse()}e(O,function(T){var S=T.cells.length,R;for(i=0;i<S;i++){R=T.cells[i];s(R,"colSpan",1);s(R,"rowSpan",1)}for(i=S;i<Q;i++){T.appendChild(f(T.cells[S-1]))}for(i=Q;i<S;i++){G.remove(T.cells[i])}if(N){M.parentNode.insertBefore(T,M)}else{G.insertAfter(T,M)}})}function F(M){var N;e(g,function(O,P){e(O,function(R,Q){if(R.elm==M){N={x:Q,y:P};return false}});return !N});return N}function w(M){L=F(M)}function I(){var O,N,M;N=M=0;e(g,function(P,Q){e(P,function(S,R){var U,T;if(j(S)){S=g[Q][R];if(R>N){N=R}if(Q>M){M=Q}if(S.real){U=S.colspan-1;T=S.rowspan-1;if(U){if(R+U>N){N=R+U}}if(T){if(Q+T>M){M=Q+T}}}}})});return{x:N,y:M}}function v(S){var P,O,U,T,N,M,Q,R;D=F(S);if(L&&D){P=Math.min(L.x,D.x);O=Math.min(L.y,D.y);U=Math.max(L.x,D.x);T=Math.max(L.y,D.y);N=U;M=T;for(y=O;y<=M;y++){S=g[y][P];if(!S.real){if(P-(S.colspan-1)<P){P-=S.colspan-1}}}for(x=P;x<=N;x++){S=g[O][x];if(!S.real){if(O-(S.rowspan-1)<O){O-=S.rowspan-1}}}for(y=O;y<=T;y++){for(x=P;x<=U;x++){S=g[y][x];if(S.real){Q=S.colspan-1;R=S.rowspan-1;if(Q){if(x+Q>N){N=x+Q}}if(R){if(y+R>M){M=y+R}}}}}G.removeClass(G.select("td.mceSelected,th.mceSelected"),"mceSelected");for(y=O;y<=M;y++){for(x=P;x<=N;x++){if(g[y][x]){G.addClass(g[y][x].elm,"mceSelected")}}}}}d.extend(this,{deleteTable:r,split:C,merge:p,insertRow:l,insertCol:h,deleteCols:n,deleteRows:m,cutRows:E,copyRows:J,pasteRows:B,getPos:F,setStartCell:w,setEndCell:v})}d.create("tinymce.plugins.TablePlugin",{init:function(g,h){var f,m,j=true;function l(p){var o=g.selection,n=g.dom.getParent(p||o.getNode(),"table");if(n){return new b(n,g.dom,o)}}function k(){g.getBody().style.webkitUserSelect="";if(j){g.dom.removeClass(g.dom.select("td.mceSelected,th.mceSelected"),"mceSelected");j=false}}e([["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(n){g.addButton(n[0],{title:n[1],cmd:n[2],ui:n[3]})});if(!d.isIE){g.onClick.add(function(n,o){o=o.target;if(o.nodeName==="TABLE"){n.selection.select(o);n.nodeChanged()}})}g.onPreProcess.add(function(o,p){var n,q,r,t=o.dom,s;n=t.select("table",p.node);q=n.length;while(q--){r=n[q];t.setAttrib(r,"data-mce-style","");if((s=t.getAttrib(r,"width"))){t.setStyle(r,"width",s);t.setAttrib(r,"width","")}if((s=t.getAttrib(r,"height"))){t.setStyle(r,"height",s);t.setAttrib(r,"height","")}}});g.onNodeChange.add(function(q,o,s){var r;s=q.selection.getStart();r=q.dom.getParent(s,"td,th,caption");o.setActive("table",s.nodeName==="TABLE"||!!r);if(r&&r.nodeName==="CAPTION"){r=0}o.setDisabled("delete_table",!r);o.setDisabled("delete_col",!r);o.setDisabled("delete_table",!r);o.setDisabled("delete_row",!r);o.setDisabled("col_after",!r);o.setDisabled("col_before",!r);o.setDisabled("row_after",!r);o.setDisabled("row_before",!r);o.setDisabled("row_props",!r);o.setDisabled("cell_props",!r);o.setDisabled("split_cells",!r);o.setDisabled("merge_cells",!r)});g.onInit.add(function(r){var p,t,q=r.dom,u;f=r.windowManager;r.onMouseDown.add(function(w,z){if(z.button!=2){k();t=q.getParent(z.target,"td,th");p=q.getParent(t,"table")}});q.bind(r.getDoc(),"mouseover",function(C){var A,z,B=C.target;if(t&&(u||B!=t)&&(B.nodeName=="TD"||B.nodeName=="TH")){z=q.getParent(B,"table");if(z==p){if(!u){u=l(z);u.setStartCell(t);r.getBody().style.webkitUserSelect="none"}u.setEndCell(B);j=true}A=r.selection.getSel();try{if(A.removeAllRanges){A.removeAllRanges()}else{A.empty()}}catch(w){}C.preventDefault()}});r.onMouseUp.add(function(F,G){var z,B=F.selection,H,I=B.getSel(),w,C,A,E;if(t){if(u){F.getBody().style.webkitUserSelect=""}function D(J,L){var K=new d.dom.TreeWalker(J,J);do{if(J.nodeType==3&&d.trim(J.nodeValue).length!=0){if(L){z.setStart(J,0)}else{z.setEnd(J,J.nodeValue.length)}return}if(J.nodeName=="BR"){if(L){z.setStartBefore(J)}else{z.setEndBefore(J)}return}}while(J=(L?K.next():K.prev()))}H=q.select("td.mceSelected,th.mceSelected");if(H.length>0){z=q.createRng();C=H[0];E=H[H.length-1];z.setStartBefore(C);z.setEndAfter(C);D(C,1);w=new d.dom.TreeWalker(C,q.getParent(H[0],"table"));do{if(C.nodeName=="TD"||C.nodeName=="TH"){if(!q.hasClass(C,"mceSelected")){break}A=C}}while(C=w.next());D(A);B.setRng(z)}F.nodeChanged();t=u=p=null}});r.onKeyUp.add(function(w,z){k()});r.onKeyDown.add(function(w,z){n(w)});r.onMouseDown.add(function(w,z){if(z.button!=2){n(w)}});function o(D,z,A,F){var B=3,G=D.dom.getParent(z.startContainer,"TABLE"),C,w,E;if(G){C=G.parentNode}w=z.startContainer.nodeType==B&&z.startOffset==0&&z.endOffset==0&&F&&(A.nodeName=="TR"||A==C);E=(A.nodeName=="TD"||A.nodeName=="TH")&&!F;return w||E}function n(A){if(!d.isWebKit){return}var z=A.selection.getRng();var C=A.selection.getNode();var B=A.dom.getParent(z.startContainer,"TD");if(!o(A,z,C,B)){return}if(!B){B=C}var w=B.lastChild;while(w.lastChild){w=w.lastChild}z.setEnd(w,w.nodeValue.length);A.selection.setRng(z)}r.plugins.table.fixTableCellSelection=n;if(r&&r.plugins.contextmenu){r.plugins.contextmenu.onContextMenu.add(function(A,w,C){var D,B=r.selection,z=B.getNode()||r.getBody();if(r.dom.getParent(C,"td")||r.dom.getParent(C,"th")||r.dom.select("td.mceSelected,th.mceSelected").length){w.removeAll();if(z.nodeName=="A"&&!r.dom.getAttrib(z,"name")){w.add({title:"advanced.link_desc",icon:"link",cmd:r.plugins.advlink?"mceAdvLink":"mceLink",ui:true});w.add({title:"advanced.unlink_desc",icon:"unlink",cmd:"UnLink"});w.addSeparator()}if(z.nodeName=="IMG"&&z.className.indexOf("mceItem")==-1){w.add({title:"advanced.image_desc",icon:"image",cmd:r.plugins.advimage?"mceAdvImage":"mceImage",ui:true});w.addSeparator()}w.add({title:"table.desc",icon:"table",cmd:"mceInsertTable",value:{action:"insert"}});w.add({title:"table.props_desc",icon:"table_props",cmd:"mceInsertTable"});w.add({title:"table.del",icon:"delete_table",cmd:"mceTableDelete"});w.addSeparator();D=w.addMenu({title:"table.cell"});D.add({title:"table.cell_desc",icon:"cell_props",cmd:"mceTableCellProps"});D.add({title:"table.split_cells_desc",icon:"split_cells",cmd:"mceTableSplitCells"});D.add({title:"table.merge_cells_desc",icon:"merge_cells",cmd:"mceTableMergeCells"});D=w.addMenu({title:"table.row"});D.add({title:"table.row_desc",icon:"row_props",cmd:"mceTableRowProps"});D.add({title:"table.row_before_desc",icon:"row_before",cmd:"mceTableInsertRowBefore"});D.add({title:"table.row_after_desc",icon:"row_after",cmd:"mceTableInsertRowAfter"});D.add({title:"table.delete_row_desc",icon:"delete_row",cmd:"mceTableDeleteRow"});D.addSeparator();D.add({title:"table.cut_row_desc",icon:"cut",cmd:"mceTableCutRow"});D.add({title:"table.copy_row_desc",icon:"copy",cmd:"mceTableCopyRow"});D.add({title:"table.paste_row_before_desc",icon:"paste",cmd:"mceTablePasteRowBefore"}).setDisabled(!m);D.add({title:"table.paste_row_after_desc",icon:"paste",cmd:"mceTablePasteRowAfter"}).setDisabled(!m);D=w.addMenu({title:"table.col"});D.add({title:"table.col_before_desc",icon:"col_before",cmd:"mceTableInsertColBefore"});D.add({title:"table.col_after_desc",icon:"col_after",cmd:"mceTableInsertColAfter"});D.add({title:"table.delete_col_desc",icon:"delete_col",cmd:"mceTableDeleteCol"})}else{w.add({title:"table.desc",icon:"table",cmd:"mceInsertTable"})}})}if(d.isWebKit){function v(B,M){function F(Q){B.selection.setCursorLocation(Q,0)}function H(R,Q){return R.keyCode==z?Q.previousSibling:Q.nextSibling}function G(R,S){var Q=H(R,S);return Q!==null&&Q.tagName==="TR"?Q:null}function C(Q,R){return Q.dom.getParent(R,"table")}function O(Q){var R=C(B,Q);return H(M,R)}function A(Q){return Q.keyCode==z||Q.keyCode==I}function D(Q){var S=Q.selection.getNode();var R=Q.dom.getParent(S,"tr");return R!==null}function N(R){var Q=0;var S=R;while(S.previousSibling){S=S.previousSibling;Q=Q+a(S,"colspan")}return Q}function E(S,Q){var T=0;var R=0;e(S.children,function(U,V){T=T+a(U,"colspan");R=V;if(T>Q){return false}});return R}function w(S,T,V){var U=N(S.dom.getParent(T,"td,th"));var R=E(V,U);var Q=V.childNodes[R];F(Q)}function L(R,T){var Q=O(R);if(Q!==null){F(Q);return d.dom.Event.cancel(T)}else{var S=T.keyCode==z?R.firstChild:R.lastChild;F(S);return true}}var z=38;var I=40;if(A(M)&&D(B)){var J=B.selection.getNode();var P=B.dom.getParent(J,"tr");var K=G(M,P);if(K==null){return L(P,M)}else{w(B,J,K);d.dom.Event.cancel(M);return true}}}r.onKeyDown.add(v)}if(!d.isIE){function s(){var w;for(w=r.getBody().lastChild;w&&w.nodeType==3&&!w.nodeValue.length;w=w.previousSibling){}if(w&&w.nodeName=="TABLE"){r.dom.add(r.getBody(),"p",null,'<br mce_bogus="1" />')}}if(d.isGecko){r.onKeyDown.add(function(z,B){var w,A,C=z.dom;if(B.keyCode==37||B.keyCode==38){w=z.selection.getRng();A=C.getParent(w.startContainer,"table");if(A&&z.getBody().firstChild==A){if(c(w,A)){w=C.createRng();w.setStartBefore(A);w.setEndBefore(A);z.selection.setRng(w);B.preventDefault()}}}})}r.onKeyUp.add(s);r.onSetContent.add(s);r.onVisualAid.add(s);r.onPreProcess.add(function(w,A){var z=A.node.lastChild;if(z&&z.childNodes.length==1&&z.firstChild.nodeName=="BR"){w.dom.remove(z)}});s();r.startContent=r.getContent({format:"raw"})}});e({mceTableSplitCells:function(n){n.split()},mceTableMergeCells:function(o){var p,q,n;n=g.dom.getParent(g.selection.getNode(),"th,td");if(n){p=n.rowSpan;q=n.colSpan}if(!g.dom.select("td.mceSelected,th.mceSelected").length){f.open({url:h+"/merge_cells.htm",width:240+parseInt(g.getLang("table.merge_cells_delta_width",0)),height:110+parseInt(g.getLang("table.merge_cells_delta_height",0)),inline:1},{rows:p,cols:q,onaction:function(r){o.merge(n,r.cols,r.rows)},plugin_url:h})}else{o.merge()}},mceTableInsertRowBefore:function(n){n.insertRow(true)},mceTableInsertRowAfter:function(n){n.insertRow()},mceTableInsertColBefore:function(n){n.insertCol(true)},mceTableInsertColAfter:function(n){n.insertCol()},mceTableDeleteCol:function(n){n.deleteCols()},mceTableDeleteRow:function(n){n.deleteRows()},mceTableCutRow:function(n){m=n.cutRows()},mceTableCopyRow:function(n){m=n.copyRows()},mceTablePasteRowBefore:function(n){n.pasteRows(m,true)},mceTablePasteRowAfter:function(n){n.pasteRows(m)},mceTableDelete:function(n){n.deleteTable()}},function(o,n){g.addCommand(n,function(){var p=l();if(p){o(p);g.execCommand("mceRepaint");k()}})});e({mceInsertTable:function(n){f.open({url:h+"/table.htm",width:400+parseInt(g.getLang("table.table_delta_width",0)),height:320+parseInt(g.getLang("table.table_delta_height",0)),inline:1},{plugin_url:h,action:n?n.action:0})},mceTableRowProps:function(){f.open({url:h+"/row.htm",width:400+parseInt(g.getLang("table.rowprops_delta_width",0)),height:295+parseInt(g.getLang("table.rowprops_delta_height",0)),inline:1},{plugin_url:h})},mceTableCellProps:function(){f.open({url:h+"/cell.htm",width:400+parseInt(g.getLang("table.cellprops_delta_width",0)),height:295+parseInt(g.getLang("table.cellprops_delta_height",0)),inline:1},{plugin_url:h})}},function(o,n){g.addCommand(n,function(p,q){o(q)})})}});d.PluginManager.add("table",d.plugins.TablePlugin)})(tinymce); \ No newline at end of file
diff --git a/program/js/tiny_mce/plugins/table/editor_plugin_src.js b/program/js/tiny_mce/plugins/table/editor_plugin_src.js
new file mode 100644
index 000000000..ccfe808f6
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/editor_plugin_src.js
@@ -0,0 +1,1364 @@
+/**
+ * editor_plugin_src.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+(function(tinymce) {
+ var each = tinymce.each;
+
+ // Checks if the selection/caret is at the start of the specified block element
+ function isAtStart(rng, par) {
+ var doc = par.ownerDocument, rng2 = doc.createRange(), elm;
+
+ rng2.setStartBefore(par);
+ rng2.setEnd(rng.endContainer, rng.endOffset);
+
+ elm = doc.createElement('body');
+ elm.appendChild(rng2.cloneContents());
+
+ // Check for text characters of other elements that should be treated as content
+ return elm.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi, '-').replace(/<[^>]+>/g, '').length == 0;
+ };
+
+ function getSpanVal(td, name) {
+ return parseInt(td.getAttribute(name) || 1);
+ }
+
+ /**
+ * Table Grid class.
+ */
+ function TableGrid(table, dom, selection) {
+ var grid, startPos, endPos, selectedCell;
+
+ buildGrid();
+ selectedCell = dom.getParent(selection.getStart(), 'th,td');
+ if (selectedCell) {
+ startPos = getPos(selectedCell);
+ endPos = findEndPos();
+ selectedCell = getCell(startPos.x, startPos.y);
+ }
+
+ function cloneNode(node, children) {
+ node = node.cloneNode(children);
+ node.removeAttribute('id');
+
+ return node;
+ }
+
+ function buildGrid() {
+ var startY = 0;
+
+ grid = [];
+
+ each(['thead', 'tbody', 'tfoot'], function(part) {
+ var rows = dom.select('> ' + part + ' tr', table);
+
+ each(rows, function(tr, y) {
+ y += startY;
+
+ each(dom.select('> td, > th', tr), function(td, x) {
+ var x2, y2, rowspan, colspan;
+
+ // Skip over existing cells produced by rowspan
+ if (grid[y]) {
+ while (grid[y][x])
+ x++;
+ }
+
+ // Get col/rowspan from cell
+ rowspan = getSpanVal(td, 'rowspan');
+ colspan = getSpanVal(td, 'colspan');
+
+ // Fill out rowspan/colspan right and down
+ for (y2 = y; y2 < y + rowspan; y2++) {
+ if (!grid[y2])
+ grid[y2] = [];
+
+ for (x2 = x; x2 < x + colspan; x2++) {
+ grid[y2][x2] = {
+ part : part,
+ real : y2 == y && x2 == x,
+ elm : td,
+ rowspan : rowspan,
+ colspan : colspan
+ };
+ }
+ }
+ });
+ });
+
+ startY += rows.length;
+ });
+ };
+
+ function getCell(x, y) {
+ var row;
+
+ row = grid[y];
+ if (row)
+ return row[x];
+ };
+
+ function setSpanVal(td, name, val) {
+ if (td) {
+ val = parseInt(val);
+
+ if (val === 1)
+ td.removeAttribute(name, 1);
+ else
+ td.setAttribute(name, val, 1);
+ }
+ }
+
+ function isCellSelected(cell) {
+ return cell && (dom.hasClass(cell.elm, 'mceSelected') || cell == selectedCell);
+ };
+
+ function getSelectedRows() {
+ var rows = [];
+
+ each(table.rows, function(row) {
+ each(row.cells, function(cell) {
+ if (dom.hasClass(cell, 'mceSelected') || cell == selectedCell.elm) {
+ rows.push(row);
+ return false;
+ }
+ });
+ });
+
+ return rows;
+ };
+
+ function deleteTable() {
+ var rng = dom.createRng();
+
+ rng.setStartAfter(table);
+ rng.setEndAfter(table);
+
+ selection.setRng(rng);
+
+ dom.remove(table);
+ };
+
+ function cloneCell(cell) {
+ var formatNode;
+
+ // Clone formats
+ tinymce.walk(cell, function(node) {
+ var curNode;
+
+ if (node.nodeType == 3) {
+ each(dom.getParents(node.parentNode, null, cell).reverse(), function(node) {
+ node = cloneNode(node, false);
+
+ if (!formatNode)
+ formatNode = curNode = node;
+ else if (curNode)
+ curNode.appendChild(node);
+
+ curNode = node;
+ });
+
+ // Add something to the inner node
+ if (curNode)
+ curNode.innerHTML = tinymce.isIE ? '&nbsp;' : '<br data-mce-bogus="1" />';
+
+ return false;
+ }
+ }, 'childNodes');
+
+ cell = cloneNode(cell, false);
+ setSpanVal(cell, 'rowSpan', 1);
+ setSpanVal(cell, 'colSpan', 1);
+
+ if (formatNode) {
+ cell.appendChild(formatNode);
+ } else {
+ if (!tinymce.isIE)
+ cell.innerHTML = '<br data-mce-bogus="1" />';
+ }
+
+ return cell;
+ };
+
+ function cleanup() {
+ var rng = dom.createRng();
+
+ // Empty rows
+ each(dom.select('tr', table), function(tr) {
+ if (tr.cells.length == 0)
+ dom.remove(tr);
+ });
+
+ // Empty table
+ if (dom.select('tr', table).length == 0) {
+ rng.setStartAfter(table);
+ rng.setEndAfter(table);
+ selection.setRng(rng);
+ dom.remove(table);
+ return;
+ }
+
+ // Empty header/body/footer
+ each(dom.select('thead,tbody,tfoot', table), function(part) {
+ if (part.rows.length == 0)
+ dom.remove(part);
+ });
+
+ // Restore selection to start position if it still exists
+ buildGrid();
+
+ // Restore the selection to the closest table position
+ row = grid[Math.min(grid.length - 1, startPos.y)];
+ if (row) {
+ selection.select(row[Math.min(row.length - 1, startPos.x)].elm, true);
+ selection.collapse(true);
+ }
+ };
+
+ function fillLeftDown(x, y, rows, cols) {
+ var tr, x2, r, c, cell;
+
+ tr = grid[y][x].elm.parentNode;
+ for (r = 1; r <= rows; r++) {
+ tr = dom.getNext(tr, 'tr');
+
+ if (tr) {
+ // Loop left to find real cell
+ for (x2 = x; x2 >= 0; x2--) {
+ cell = grid[y + r][x2].elm;
+
+ if (cell.parentNode == tr) {
+ // Append clones after
+ for (c = 1; c <= cols; c++)
+ dom.insertAfter(cloneCell(cell), cell);
+
+ break;
+ }
+ }
+
+ if (x2 == -1) {
+ // Insert nodes before first cell
+ for (c = 1; c <= cols; c++)
+ tr.insertBefore(cloneCell(tr.cells[0]), tr.cells[0]);
+ }
+ }
+ }
+ };
+
+ function split() {
+ each(grid, function(row, y) {
+ each(row, function(cell, x) {
+ var colSpan, rowSpan, newCell, i;
+
+ if (isCellSelected(cell)) {
+ cell = cell.elm;
+ colSpan = getSpanVal(cell, 'colspan');
+ rowSpan = getSpanVal(cell, 'rowspan');
+
+ if (colSpan > 1 || rowSpan > 1) {
+ setSpanVal(cell, 'rowSpan', 1);
+ setSpanVal(cell, 'colSpan', 1);
+
+ // Insert cells right
+ for (i = 0; i < colSpan - 1; i++)
+ dom.insertAfter(cloneCell(cell), cell);
+
+ fillLeftDown(x, y, rowSpan - 1, colSpan);
+ }
+ }
+ });
+ });
+ };
+
+ function merge(cell, cols, rows) {
+ var startX, startY, endX, endY, x, y, startCell, endCell, cell, children, count;
+
+ // Use specified cell and cols/rows
+ if (cell) {
+ pos = getPos(cell);
+ startX = pos.x;
+ startY = pos.y;
+ endX = startX + (cols - 1);
+ endY = startY + (rows - 1);
+ } else {
+ // Use selection
+ startX = startPos.x;
+ startY = startPos.y;
+ endX = endPos.x;
+ endY = endPos.y;
+ }
+
+ // Find start/end cells
+ startCell = getCell(startX, startY);
+ endCell = getCell(endX, endY);
+
+ // Check if the cells exists and if they are of the same part for example tbody = tbody
+ if (startCell && endCell && startCell.part == endCell.part) {
+ // Split and rebuild grid
+ split();
+ buildGrid();
+
+ // Set row/col span to start cell
+ startCell = getCell(startX, startY).elm;
+ setSpanVal(startCell, 'colSpan', (endX - startX) + 1);
+ setSpanVal(startCell, 'rowSpan', (endY - startY) + 1);
+
+ // Remove other cells and add it's contents to the start cell
+ for (y = startY; y <= endY; y++) {
+ for (x = startX; x <= endX; x++) {
+ if (!grid[y] || !grid[y][x])
+ continue;
+
+ cell = grid[y][x].elm;
+
+ if (cell != startCell) {
+ // Move children to startCell
+ children = tinymce.grep(cell.childNodes);
+ each(children, function(node) {
+ startCell.appendChild(node);
+ });
+
+ // Remove bogus nodes if there is children in the target cell
+ if (children.length) {
+ children = tinymce.grep(startCell.childNodes);
+ count = 0;
+ each(children, function(node) {
+ if (node.nodeName == 'BR' && dom.getAttrib(node, 'data-mce-bogus') && count++ < children.length - 1)
+ startCell.removeChild(node);
+ });
+ }
+
+ // Remove cell
+ dom.remove(cell);
+ }
+ }
+ }
+
+ // Remove empty rows etc and restore caret location
+ cleanup();
+ }
+ };
+
+ function insertRow(before) {
+ var posY, cell, lastCell, x, rowElm, newRow, newCell, otherCell, rowSpan;
+
+ // Find first/last row
+ each(grid, function(row, y) {
+ each(row, function(cell, x) {
+ if (isCellSelected(cell)) {
+ cell = cell.elm;
+ rowElm = cell.parentNode;
+ newRow = cloneNode(rowElm, false);
+ posY = y;
+
+ if (before)
+ return false;
+ }
+ });
+
+ if (before)
+ return !posY;
+ });
+
+ for (x = 0; x < grid[0].length; x++) {
+ // Cell not found could be because of an invalid table structure
+ if (!grid[posY][x])
+ continue;
+
+ cell = grid[posY][x].elm;
+
+ if (cell != lastCell) {
+ if (!before) {
+ rowSpan = getSpanVal(cell, 'rowspan');
+ if (rowSpan > 1) {
+ setSpanVal(cell, 'rowSpan', rowSpan + 1);
+ continue;
+ }
+ } else {
+ // Check if cell above can be expanded
+ if (posY > 0 && grid[posY - 1][x]) {
+ otherCell = grid[posY - 1][x].elm;
+ rowSpan = getSpanVal(otherCell, 'rowSpan');
+ if (rowSpan > 1) {
+ setSpanVal(otherCell, 'rowSpan', rowSpan + 1);
+ continue;
+ }
+ }
+ }
+
+ // Insert new cell into new row
+ newCell = cloneCell(cell);
+ setSpanVal(newCell, 'colSpan', cell.colSpan);
+
+ newRow.appendChild(newCell);
+
+ lastCell = cell;
+ }
+ }
+
+ if (newRow.hasChildNodes()) {
+ if (!before)
+ dom.insertAfter(newRow, rowElm);
+ else
+ rowElm.parentNode.insertBefore(newRow, rowElm);
+ }
+ };
+
+ function insertCol(before) {
+ var posX, lastCell;
+
+ // Find first/last column
+ each(grid, function(row, y) {
+ each(row, function(cell, x) {
+ if (isCellSelected(cell)) {
+ posX = x;
+
+ if (before)
+ return false;
+ }
+ });
+
+ if (before)
+ return !posX;
+ });
+
+ each(grid, function(row, y) {
+ var cell, rowSpan, colSpan;
+
+ if (!row[posX])
+ return;
+
+ cell = row[posX].elm;
+ if (cell != lastCell) {
+ colSpan = getSpanVal(cell, 'colspan');
+ rowSpan = getSpanVal(cell, 'rowspan');
+
+ if (colSpan == 1) {
+ if (!before) {
+ dom.insertAfter(cloneCell(cell), cell);
+ fillLeftDown(posX, y, rowSpan - 1, colSpan);
+ } else {
+ cell.parentNode.insertBefore(cloneCell(cell), cell);
+ fillLeftDown(posX, y, rowSpan - 1, colSpan);
+ }
+ } else
+ setSpanVal(cell, 'colSpan', cell.colSpan + 1);
+
+ lastCell = cell;
+ }
+ });
+ };
+
+ function deleteCols() {
+ var cols = [];
+
+ // Get selected column indexes
+ each(grid, function(row, y) {
+ each(row, function(cell, x) {
+ if (isCellSelected(cell) && tinymce.inArray(cols, x) === -1) {
+ each(grid, function(row) {
+ var cell = row[x].elm, colSpan;
+
+ colSpan = getSpanVal(cell, 'colSpan');
+
+ if (colSpan > 1)
+ setSpanVal(cell, 'colSpan', colSpan - 1);
+ else
+ dom.remove(cell);
+ });
+
+ cols.push(x);
+ }
+ });
+ });
+
+ cleanup();
+ };
+
+ function deleteRows() {
+ var rows;
+
+ function deleteRow(tr) {
+ var nextTr, pos, lastCell;
+
+ nextTr = dom.getNext(tr, 'tr');
+
+ // Move down row spanned cells
+ each(tr.cells, function(cell) {
+ var rowSpan = getSpanVal(cell, 'rowSpan');
+
+ if (rowSpan > 1) {
+ setSpanVal(cell, 'rowSpan', rowSpan - 1);
+ pos = getPos(cell);
+ fillLeftDown(pos.x, pos.y, 1, 1);
+ }
+ });
+
+ // Delete cells
+ pos = getPos(tr.cells[0]);
+ each(grid[pos.y], function(cell) {
+ var rowSpan;
+
+ cell = cell.elm;
+
+ if (cell != lastCell) {
+ rowSpan = getSpanVal(cell, 'rowSpan');
+
+ if (rowSpan <= 1)
+ dom.remove(cell);
+ else
+ setSpanVal(cell, 'rowSpan', rowSpan - 1);
+
+ lastCell = cell;
+ }
+ });
+ };
+
+ // Get selected rows and move selection out of scope
+ rows = getSelectedRows();
+
+ // Delete all selected rows
+ each(rows.reverse(), function(tr) {
+ deleteRow(tr);
+ });
+
+ cleanup();
+ };
+
+ function cutRows() {
+ var rows = getSelectedRows();
+
+ dom.remove(rows);
+ cleanup();
+
+ return rows;
+ };
+
+ function copyRows() {
+ var rows = getSelectedRows();
+
+ each(rows, function(row, i) {
+ rows[i] = cloneNode(row, true);
+ });
+
+ return rows;
+ };
+
+ function pasteRows(rows, before) {
+ var selectedRows = getSelectedRows(),
+ targetRow = selectedRows[before ? 0 : selectedRows.length - 1],
+ targetCellCount = targetRow.cells.length;
+
+ // Calc target cell count
+ each(grid, function(row) {
+ var match;
+
+ targetCellCount = 0;
+ each(row, function(cell, x) {
+ if (cell.real)
+ targetCellCount += cell.colspan;
+
+ if (cell.elm.parentNode == targetRow)
+ match = 1;
+ });
+
+ if (match)
+ return false;
+ });
+
+ if (!before)
+ rows.reverse();
+
+ each(rows, function(row) {
+ var cellCount = row.cells.length, cell;
+
+ // Remove col/rowspans
+ for (i = 0; i < cellCount; i++) {
+ cell = row.cells[i];
+ setSpanVal(cell, 'colSpan', 1);
+ setSpanVal(cell, 'rowSpan', 1);
+ }
+
+ // Needs more cells
+ for (i = cellCount; i < targetCellCount; i++)
+ row.appendChild(cloneCell(row.cells[cellCount - 1]));
+
+ // Needs less cells
+ for (i = targetCellCount; i < cellCount; i++)
+ dom.remove(row.cells[i]);
+
+ // Add before/after
+ if (before)
+ targetRow.parentNode.insertBefore(row, targetRow);
+ else
+ dom.insertAfter(row, targetRow);
+ });
+ };
+
+ function getPos(target) {
+ var pos;
+
+ each(grid, function(row, y) {
+ each(row, function(cell, x) {
+ if (cell.elm == target) {
+ pos = {x : x, y : y};
+ return false;
+ }
+ });
+
+ return !pos;
+ });
+
+ return pos;
+ };
+
+ function setStartCell(cell) {
+ startPos = getPos(cell);
+ };
+
+ function findEndPos() {
+ var pos, maxX, maxY;
+
+ maxX = maxY = 0;
+
+ each(grid, function(row, y) {
+ each(row, function(cell, x) {
+ var colSpan, rowSpan;
+
+ if (isCellSelected(cell)) {
+ cell = grid[y][x];
+
+ if (x > maxX)
+ maxX = x;
+
+ if (y > maxY)
+ maxY = y;
+
+ if (cell.real) {
+ colSpan = cell.colspan - 1;
+ rowSpan = cell.rowspan - 1;
+
+ if (colSpan) {
+ if (x + colSpan > maxX)
+ maxX = x + colSpan;
+ }
+
+ if (rowSpan) {
+ if (y + rowSpan > maxY)
+ maxY = y + rowSpan;
+ }
+ }
+ }
+ });
+ });
+
+ return {x : maxX, y : maxY};
+ };
+
+ function setEndCell(cell) {
+ var startX, startY, endX, endY, maxX, maxY, colSpan, rowSpan;
+
+ endPos = getPos(cell);
+
+ if (startPos && endPos) {
+ // Get start/end positions
+ startX = Math.min(startPos.x, endPos.x);
+ startY = Math.min(startPos.y, endPos.y);
+ endX = Math.max(startPos.x, endPos.x);
+ endY = Math.max(startPos.y, endPos.y);
+
+ // Expand end positon to include spans
+ maxX = endX;
+ maxY = endY;
+
+ // Expand startX
+ for (y = startY; y <= maxY; y++) {
+ cell = grid[y][startX];
+
+ if (!cell.real) {
+ if (startX - (cell.colspan - 1) < startX)
+ startX -= cell.colspan - 1;
+ }
+ }
+
+ // Expand startY
+ for (x = startX; x <= maxX; x++) {
+ cell = grid[startY][x];
+
+ if (!cell.real) {
+ if (startY - (cell.rowspan - 1) < startY)
+ startY -= cell.rowspan - 1;
+ }
+ }
+
+ // Find max X, Y
+ for (y = startY; y <= endY; y++) {
+ for (x = startX; x <= endX; x++) {
+ cell = grid[y][x];
+
+ if (cell.real) {
+ colSpan = cell.colspan - 1;
+ rowSpan = cell.rowspan - 1;
+
+ if (colSpan) {
+ if (x + colSpan > maxX)
+ maxX = x + colSpan;
+ }
+
+ if (rowSpan) {
+ if (y + rowSpan > maxY)
+ maxY = y + rowSpan;
+ }
+ }
+ }
+ }
+
+ // Remove current selection
+ dom.removeClass(dom.select('td.mceSelected,th.mceSelected'), 'mceSelected');
+
+ // Add new selection
+ for (y = startY; y <= maxY; y++) {
+ for (x = startX; x <= maxX; x++) {
+ if (grid[y][x])
+ dom.addClass(grid[y][x].elm, 'mceSelected');
+ }
+ }
+ }
+ };
+
+ // Expose to public
+ tinymce.extend(this, {
+ deleteTable : deleteTable,
+ split : split,
+ merge : merge,
+ insertRow : insertRow,
+ insertCol : insertCol,
+ deleteCols : deleteCols,
+ deleteRows : deleteRows,
+ cutRows : cutRows,
+ copyRows : copyRows,
+ pasteRows : pasteRows,
+ getPos : getPos,
+ setStartCell : setStartCell,
+ setEndCell : setEndCell
+ });
+ };
+
+ tinymce.create('tinymce.plugins.TablePlugin', {
+ init : function(ed, url) {
+ var winMan, clipboardRows, hasCellSelection = true; // Might be selected cells on reload
+
+ function createTableGrid(node) {
+ var selection = ed.selection, tblElm = ed.dom.getParent(node || selection.getNode(), 'table');
+
+ if (tblElm)
+ return new TableGrid(tblElm, ed.dom, selection);
+ };
+
+ function cleanup() {
+ // Restore selection possibilities
+ ed.getBody().style.webkitUserSelect = '';
+
+ if (hasCellSelection) {
+ ed.dom.removeClass(ed.dom.select('td.mceSelected,th.mceSelected'), 'mceSelected');
+ hasCellSelection = false;
+ }
+ };
+
+ // Register buttons
+ 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]});
+ });
+
+ // Select whole table is a table border is clicked
+ if (!tinymce.isIE) {
+ ed.onClick.add(function(ed, e) {
+ e = e.target;
+
+ if (e.nodeName === 'TABLE') {
+ ed.selection.select(e);
+ ed.nodeChanged();
+ }
+ });
+ }
+
+ ed.onPreProcess.add(function(ed, args) {
+ var nodes, i, node, dom = ed.dom, value;
+
+ nodes = dom.select('table', args.node);
+ i = nodes.length;
+ while (i--) {
+ node = nodes[i];
+ dom.setAttrib(node, 'data-mce-style', '');
+
+ if ((value = dom.getAttrib(node, 'width'))) {
+ dom.setStyle(node, 'width', value);
+ dom.setAttrib(node, 'width', '');
+ }
+
+ if ((value = dom.getAttrib(node, 'height'))) {
+ dom.setStyle(node, 'height', value);
+ dom.setAttrib(node, 'height', '');
+ }
+ }
+ });
+
+ // Handle node change updates
+ ed.onNodeChange.add(function(ed, cm, n) {
+ var p;
+
+ n = ed.selection.getStart();
+ p = ed.dom.getParent(n, 'td,th,caption');
+ cm.setActive('table', n.nodeName === 'TABLE' || !!p);
+
+ // Disable table tools if we are in caption
+ if (p && p.nodeName === 'CAPTION')
+ p = 0;
+
+ 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);
+ cm.setDisabled('merge_cells', !p);
+ });
+
+ ed.onInit.add(function(ed) {
+ var startTable, startCell, dom = ed.dom, tableGrid;
+
+ winMan = ed.windowManager;
+
+ // Add cell selection logic
+ ed.onMouseDown.add(function(ed, e) {
+ if (e.button != 2) {
+ cleanup();
+
+ startCell = dom.getParent(e.target, 'td,th');
+ startTable = dom.getParent(startCell, 'table');
+ }
+ });
+
+ dom.bind(ed.getDoc(), 'mouseover', function(e) {
+ var sel, table, target = e.target;
+
+ if (startCell && (tableGrid || target != startCell) && (target.nodeName == 'TD' || target.nodeName == 'TH')) {
+ table = dom.getParent(target, 'table');
+ if (table == startTable) {
+ if (!tableGrid) {
+ tableGrid = createTableGrid(table);
+ tableGrid.setStartCell(startCell);
+
+ ed.getBody().style.webkitUserSelect = 'none';
+ }
+
+ tableGrid.setEndCell(target);
+ hasCellSelection = true;
+ }
+
+ // Remove current selection
+ sel = ed.selection.getSel();
+
+ try {
+ if (sel.removeAllRanges)
+ sel.removeAllRanges();
+ else
+ sel.empty();
+ } catch (ex) {
+ // IE9 might throw errors here
+ }
+
+ e.preventDefault();
+ }
+ });
+
+ ed.onMouseUp.add(function(ed, e) {
+ var rng, sel = ed.selection, selectedCells, nativeSel = sel.getSel(), walker, node, lastNode, endNode;
+
+ // Move selection to startCell
+ if (startCell) {
+ if (tableGrid)
+ ed.getBody().style.webkitUserSelect = '';
+
+ function setPoint(node, start) {
+ var walker = new tinymce.dom.TreeWalker(node, node);
+
+ do {
+ // Text node
+ if (node.nodeType == 3 && tinymce.trim(node.nodeValue).length != 0) {
+ if (start)
+ rng.setStart(node, 0);
+ else
+ rng.setEnd(node, node.nodeValue.length);
+
+ return;
+ }
+
+ // BR element
+ if (node.nodeName == 'BR') {
+ if (start)
+ rng.setStartBefore(node);
+ else
+ rng.setEndBefore(node);
+
+ return;
+ }
+ } while (node = (start ? walker.next() : walker.prev()));
+ }
+
+ // Try to expand text selection as much as we can only Gecko supports cell selection
+ selectedCells = dom.select('td.mceSelected,th.mceSelected');
+ if (selectedCells.length > 0) {
+ rng = dom.createRng();
+ node = selectedCells[0];
+ endNode = selectedCells[selectedCells.length - 1];
+ rng.setStartBefore(node);
+ rng.setEndAfter(node);
+
+ setPoint(node, 1);
+ walker = new tinymce.dom.TreeWalker(node, dom.getParent(selectedCells[0], 'table'));
+
+ do {
+ if (node.nodeName == 'TD' || node.nodeName == 'TH') {
+ if (!dom.hasClass(node, 'mceSelected'))
+ break;
+
+ lastNode = node;
+ }
+ } while (node = walker.next());
+
+ setPoint(lastNode);
+
+ sel.setRng(rng);
+ }
+
+ ed.nodeChanged();
+ startCell = tableGrid = startTable = null;
+ }
+ });
+
+ ed.onKeyUp.add(function(ed, e) {
+ cleanup();
+ });
+
+ ed.onKeyDown.add(function (ed, e) {
+ fixTableCellSelection(ed);
+ });
+
+ ed.onMouseDown.add(function (ed, e) {
+ if (e.button != 2) {
+ fixTableCellSelection(ed);
+ }
+ });
+ function tableCellSelected(ed, rng, n, currentCell) {
+ // The decision of when a table cell is selected is somewhat involved. The fact that this code is
+ // required is actually a pointer to the root cause of this bug. A cell is selected when the start
+ // and end offsets are 0, the start container is a text, and the selection node is either a TR (most cases)
+ // or the parent of the table (in the case of the selection containing the last cell of a table).
+ var TEXT_NODE = 3, table = ed.dom.getParent(rng.startContainer, 'TABLE'),
+ tableParent, allOfCellSelected, tableCellSelection;
+ if (table)
+ tableParent = table.parentNode;
+ allOfCellSelected =rng.startContainer.nodeType == TEXT_NODE &&
+ rng.startOffset == 0 &&
+ rng.endOffset == 0 &&
+ currentCell &&
+ (n.nodeName=="TR" || n==tableParent);
+ tableCellSelection = (n.nodeName=="TD"||n.nodeName=="TH")&& !currentCell;
+ return allOfCellSelected || tableCellSelection;
+ // return false;
+ }
+
+ // this nasty hack is here to work around some WebKit selection bugs.
+ function fixTableCellSelection(ed) {
+ if (!tinymce.isWebKit)
+ return;
+
+ var rng = ed.selection.getRng();
+ var n = ed.selection.getNode();
+ var currentCell = ed.dom.getParent(rng.startContainer, 'TD');
+
+ if (!tableCellSelected(ed, rng, n, currentCell))
+ return;
+ if (!currentCell) {
+ currentCell=n;
+ }
+
+ // Get the very last node inside the table cell
+ var end = currentCell.lastChild;
+ while (end.lastChild)
+ end = end.lastChild;
+
+ // Select the entire table cell. Nothing outside of the table cell should be selected.
+ rng.setEnd(end, end.nodeValue.length);
+ ed.selection.setRng(rng);
+ }
+ ed.plugins.table.fixTableCellSelection=fixTableCellSelection;
+
+ // Add context menu
+ 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') || ed.dom.select('td.mceSelected,th.mceSelected').length) {
+ 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', value : {action : 'insert'}});
+ m.add({title : 'table.props_desc', icon : 'table_props', cmd : 'mceInsertTable'});
+ m.add({title : 'table.del', icon : 'delete_table', cmd : 'mceTableDelete'});
+ m.addSeparator();
+
+ // Cell menu
+ sm = m.addMenu({title : 'table.cell'});
+ sm.add({title : 'table.cell_desc', icon : 'cell_props', cmd : 'mceTableCellProps'});
+ sm.add({title : 'table.split_cells_desc', icon : 'split_cells', cmd : 'mceTableSplitCells'});
+ sm.add({title : 'table.merge_cells_desc', icon : 'merge_cells', cmd : 'mceTableMergeCells'});
+
+ // Row menu
+ sm = m.addMenu({title : 'table.row'});
+ sm.add({title : 'table.row_desc', icon : 'row_props', cmd : 'mceTableRowProps'});
+ 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'}).setDisabled(!clipboardRows);
+ sm.add({title : 'table.paste_row_after_desc', icon : 'paste', cmd : 'mceTablePasteRowAfter'}).setDisabled(!clipboardRows);
+
+ // Column menu
+ 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'});
+ });
+ }
+
+ // Fix to allow navigating up and down in a table in WebKit browsers.
+ if (tinymce.isWebKit) {
+ function moveSelection(ed, e) {
+
+ function moveCursorToStartOfElement(n) {
+ ed.selection.setCursorLocation(n, 0);
+ }
+
+ function getSibling(event, element) {
+ return event.keyCode == UP_ARROW ? element.previousSibling : element.nextSibling;
+ }
+
+ function getNextRow(e, row) {
+ var sibling = getSibling(e, row);
+ return sibling !== null && sibling.tagName === 'TR' ? sibling : null;
+ }
+
+ function getTable(ed, currentRow) {
+ return ed.dom.getParent(currentRow, 'table');
+ }
+
+ function getTableSibling(currentRow) {
+ var table = getTable(ed, currentRow);
+ return getSibling(e, table);
+ }
+
+ function isVerticalMovement(event) {
+ return event.keyCode == UP_ARROW || event.keyCode == DOWN_ARROW;
+ }
+
+ function isInTable(ed) {
+ var node = ed.selection.getNode();
+ var currentRow = ed.dom.getParent(node, 'tr');
+ return currentRow !== null;
+ }
+
+ function columnIndex(column) {
+ var colIndex = 0;
+ var c = column;
+ while (c.previousSibling) {
+ c = c.previousSibling;
+ colIndex = colIndex + getSpanVal(c, "colspan");
+ }
+ return colIndex;
+ }
+
+ function findColumn(rowElement, columnIndex) {
+ var c = 0;
+ var r = 0;
+ each(rowElement.children, function(cell, i) {
+ c = c + getSpanVal(cell, "colspan");
+ r = i;
+ if (c > columnIndex)
+ return false;
+ });
+ return r;
+ }
+
+ function moveCursorToRow(ed, node, row) {
+ var srcColumnIndex = columnIndex(ed.dom.getParent(node, 'td,th'));
+ var tgtColumnIndex = findColumn(row, srcColumnIndex)
+ var tgtNode = row.childNodes[tgtColumnIndex];
+ moveCursorToStartOfElement(tgtNode);
+ }
+
+ function escapeTable(currentRow, e) {
+ var tableSiblingElement = getTableSibling(currentRow);
+ if (tableSiblingElement !== null) {
+ moveCursorToStartOfElement(tableSiblingElement);
+ return tinymce.dom.Event.cancel(e);
+ } else {
+ var element = e.keyCode == UP_ARROW ? currentRow.firstChild : currentRow.lastChild;
+ // rely on default behaviour to escape table after we are in the last cell of the last row
+ moveCursorToStartOfElement(element);
+ return true;
+ }
+ }
+
+ var UP_ARROW = 38;
+ var DOWN_ARROW = 40;
+
+ if (isVerticalMovement(e) && isInTable(ed)) {
+ var node = ed.selection.getNode();
+ var currentRow = ed.dom.getParent(node, 'tr');
+ var nextRow = getNextRow(e, currentRow);
+
+ // If we're at the first or last row in the table, we should move the caret outside of the table
+ if (nextRow == null) {
+ return escapeTable(currentRow, e);
+ } else {
+ moveCursorToRow(ed, node, nextRow);
+ tinymce.dom.Event.cancel(e);
+ return true;
+ }
+ }
+ }
+
+ ed.onKeyDown.add(moveSelection);
+ }
+
+ // Fixes an issue on Gecko where it's impossible to place the caret behind a table
+ // This fix will force a paragraph element after the table but only when the forced_root_block setting is enabled
+ if (!tinymce.isIE) {
+ function fixTableCaretPos() {
+ var last;
+
+ // Skip empty text nodes form the end
+ for (last = ed.getBody().lastChild; last && last.nodeType == 3 && !last.nodeValue.length; last = last.previousSibling) ;
+
+ if (last && last.nodeName == 'TABLE')
+ ed.dom.add(ed.getBody(), 'p', null, '<br mce_bogus="1" />');
+ };
+
+ // Fixes an bug where it's impossible to place the caret before a table in Gecko
+ // this fix solves it by detecting when the caret is at the beginning of such a table
+ // and then manually moves the caret infront of the table
+ if (tinymce.isGecko) {
+ ed.onKeyDown.add(function(ed, e) {
+ var rng, table, dom = ed.dom;
+
+ // On gecko it's not possible to place the caret before a table
+ if (e.keyCode == 37 || e.keyCode == 38) {
+ rng = ed.selection.getRng();
+ table = dom.getParent(rng.startContainer, 'table');
+
+ if (table && ed.getBody().firstChild == table) {
+ if (isAtStart(rng, table)) {
+ rng = dom.createRng();
+
+ rng.setStartBefore(table);
+ rng.setEndBefore(table);
+
+ ed.selection.setRng(rng);
+
+ e.preventDefault();
+ }
+ }
+ }
+ });
+ }
+
+ ed.onKeyUp.add(fixTableCaretPos);
+ ed.onSetContent.add(fixTableCaretPos);
+ ed.onVisualAid.add(fixTableCaretPos);
+
+ ed.onPreProcess.add(function(ed, o) {
+ var last = o.node.lastChild;
+
+ if (last && last.childNodes.length == 1 && last.firstChild.nodeName == 'BR')
+ ed.dom.remove(last);
+ });
+
+ fixTableCaretPos();
+ ed.startContent = ed.getContent({format : 'raw'});
+ }
+ });
+
+ // Register action commands
+ each({
+ mceTableSplitCells : function(grid) {
+ grid.split();
+ },
+
+ mceTableMergeCells : function(grid) {
+ var rowSpan, colSpan, cell;
+
+ cell = ed.dom.getParent(ed.selection.getNode(), 'th,td');
+ if (cell) {
+ rowSpan = cell.rowSpan;
+ colSpan = cell.colSpan;
+ }
+
+ if (!ed.dom.select('td.mceSelected,th.mceSelected').length) {
+ winMan.open({
+ url : url + '/merge_cells.htm',
+ width : 240 + parseInt(ed.getLang('table.merge_cells_delta_width', 0)),
+ height : 110 + parseInt(ed.getLang('table.merge_cells_delta_height', 0)),
+ inline : 1
+ }, {
+ rows : rowSpan,
+ cols : colSpan,
+ onaction : function(data) {
+ grid.merge(cell, data.cols, data.rows);
+ },
+ plugin_url : url
+ });
+ } else
+ grid.merge();
+ },
+
+ mceTableInsertRowBefore : function(grid) {
+ grid.insertRow(true);
+ },
+
+ mceTableInsertRowAfter : function(grid) {
+ grid.insertRow();
+ },
+
+ mceTableInsertColBefore : function(grid) {
+ grid.insertCol(true);
+ },
+
+ mceTableInsertColAfter : function(grid) {
+ grid.insertCol();
+ },
+
+ mceTableDeleteCol : function(grid) {
+ grid.deleteCols();
+ },
+
+ mceTableDeleteRow : function(grid) {
+ grid.deleteRows();
+ },
+
+ mceTableCutRow : function(grid) {
+ clipboardRows = grid.cutRows();
+ },
+
+ mceTableCopyRow : function(grid) {
+ clipboardRows = grid.copyRows();
+ },
+
+ mceTablePasteRowBefore : function(grid) {
+ grid.pasteRows(clipboardRows, true);
+ },
+
+ mceTablePasteRowAfter : function(grid) {
+ grid.pasteRows(clipboardRows);
+ },
+
+ mceTableDelete : function(grid) {
+ grid.deleteTable();
+ }
+ }, function(func, name) {
+ ed.addCommand(name, function() {
+ var grid = createTableGrid();
+
+ if (grid) {
+ func(grid);
+ ed.execCommand('mceRepaint');
+ cleanup();
+ }
+ });
+ });
+
+ // Register dialog commands
+ each({
+ mceInsertTable : function(val) {
+ winMan.open({
+ url : url + '/table.htm',
+ width : 400 + parseInt(ed.getLang('table.table_delta_width', 0)),
+ height : 320 + parseInt(ed.getLang('table.table_delta_height', 0)),
+ inline : 1
+ }, {
+ plugin_url : url,
+ action : val ? val.action : 0
+ });
+ },
+
+ mceTableRowProps : function() {
+ winMan.open({
+ url : url + '/row.htm',
+ width : 400 + parseInt(ed.getLang('table.rowprops_delta_width', 0)),
+ height : 295 + parseInt(ed.getLang('table.rowprops_delta_height', 0)),
+ inline : 1
+ }, {
+ plugin_url : url
+ });
+ },
+
+ mceTableCellProps : function() {
+ winMan.open({
+ url : url + '/cell.htm',
+ width : 400 + parseInt(ed.getLang('table.cellprops_delta_width', 0)),
+ height : 295 + parseInt(ed.getLang('table.cellprops_delta_height', 0)),
+ inline : 1
+ }, {
+ plugin_url : url
+ });
+ }
+ }, function(func, name) {
+ ed.addCommand(name, function(ui, val) {
+ func(val);
+ });
+ });
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('table', tinymce.plugins.TablePlugin);
+})(tinymce);
diff --git a/program/js/tiny_mce/plugins/table/js/cell.js b/program/js/tiny_mce/plugins/table/js/cell.js
new file mode 100644
index 000000000..d6f329059
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/js/cell.js
@@ -0,0 +1,319 @@
+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();
+
+ if (!ed.dom.hasClass(tdElm, 'mceSelected')) {
+ 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');
+ } else
+ tinyMCEPopup.dom.hide('action');
+}
+
+function updateAction() {
+ var el, inst = ed, tdElm, trElm, tableElm, formObj = document.forms[0];
+
+ if (!AutoValidator.validate(formObj)) {
+ tinyMCEPopup.alert(AutoValidator.getErrorMessages(formObj).join('. ') + '.');
+ return false;
+ }
+
+ 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");
+
+ // Cell is selected
+ if (ed.dom.hasClass(tdElm, 'mceSelected')) {
+ // Update all selected sells
+ tinymce.each(ed.dom.select('td.mceSelected,th.mceSelected'), function(td) {
+ updateCell(td);
+ });
+
+ ed.addVisual();
+ ed.nodeChanged();
+ inst.execCommand('mceEndUndoLevel');
+ tinyMCEPopup.close();
+ return;
+ }
+
+ 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 "col":
+ var curr, col = 0, cell = trElm.firstChild, rows = tableElm.getElementsByTagName("tr");
+
+ if (cell.nodeName != "TD" && cell.nodeName != "TH")
+ cell = nextCell(cell);
+
+ do {
+ if (cell == tdElm)
+ break;
+ col += cell.getAttribute("colspan");
+ } while ((cell = nextCell(cell)) != null);
+
+ for (var i=0; i<rows.length; i++) {
+ cell = rows[i].firstChild;
+
+ if (cell.nodeName != "TD" && cell.nodeName != "TH")
+ cell = nextCell(cell);
+
+ curr = 0;
+ do {
+ if (curr == col) {
+ cell = updateCell(cell, true);
+ break;
+ }
+ curr += cell.getAttribute("colspan");
+ } while ((cell = nextCell(cell)) != null);
+ }
+
+ break;
+
+ case "all":
+ var rows = tableElm.getElementsByTagName("tr");
+
+ for (var i=0; i<rows.length; i++) {
+ var cell = rows[i].firstChild;
+
+ if (cell.nodeName != "TD" && cell.nodeName != "TH")
+ cell = nextCell(cell);
+
+ do {
+ cell = updateCell(cell, true);
+ } while ((cell = nextCell(cell)) != null);
+ }
+
+ break;
+ }
+
+ ed.addVisual();
+ ed.nodeChanged();
+ inst.execCommand('mceEndUndoLevel');
+ tinyMCEPopup.close();
+}
+
+function nextCell(elm) {
+ while ((elm = elm.nextSibling) != null) {
+ if (elm.nodeName == "TD" || elm.nodeName == "TH")
+ return elm;
+ }
+
+ return null;
+}
+
+function updateCell(td, skip_id) {
+ var inst = ed;
+ var formObj = document.forms[0];
+ var curCellType = td.nodeName.toLowerCase();
+ var celltype = getSelectValue(formObj, 'celltype');
+ var doc = inst.getDoc();
+ var dom = ed.dom;
+
+ if (!skip_id)
+ dom.setAttrib(td, 'id', formObj.id.value);
+
+ dom.setAttrib(td, 'align', formObj.align.value);
+ dom.setAttrib(td, 'vAlign', formObj.valign.value);
+ dom.setAttrib(td, 'lang', formObj.lang.value);
+ dom.setAttrib(td, 'dir', getSelectValue(formObj, 'dir'));
+ dom.setAttrib(td, 'style', ed.dom.serializeStyle(ed.dom.parseStyle(formObj.style.value)));
+ dom.setAttrib(td, 'scope', formObj.scope.value);
+ dom.setAttrib(td, 'class', getSelectValue(formObj, 'class'));
+
+ // Clear deprecated attributes
+ ed.dom.setAttrib(td, 'width', '');
+ ed.dom.setAttrib(td, 'height', '');
+ ed.dom.setAttrib(td, 'bgColor', '');
+ ed.dom.setAttrib(td, 'borderColor', '');
+ ed.dom.setAttrib(td, 'background', '');
+
+ // Set styles
+ td.style.width = getCSSSize(formObj.width.value);
+ td.style.height = getCSSSize(formObj.height.value);
+ if (formObj.bordercolor.value != "") {
+ td.style.borderColor = formObj.bordercolor.value;
+ td.style.borderStyle = td.style.borderStyle == "" ? "solid" : td.style.borderStyle;
+ td.style.borderWidth = td.style.borderWidth == "" ? "1px" : td.style.borderWidth;
+ } else
+ td.style.borderColor = '';
+
+ td.style.backgroundColor = formObj.bgcolor.value;
+
+ if (formObj.backgroundimage.value != "")
+ td.style.backgroundImage = "url('" + formObj.backgroundimage.value + "')";
+ else
+ td.style.backgroundImage = '';
+
+ if (curCellType != celltype) {
+ // changing to a different node type
+ var newCell = doc.createElement(celltype);
+
+ for (var c=0; c<td.childNodes.length; c++)
+ newCell.appendChild(td.childNodes[c].cloneNode(1));
+
+ for (var a=0; a<td.attributes.length; a++)
+ ed.dom.setAttrib(newCell, td.attributes[a].name, ed.dom.getAttrib(td, td.attributes[a].name));
+
+ td.parentNode.replaceChild(newCell, td);
+ td = newCell;
+ }
+
+ dom.setAttrib(td, 'style', dom.serializeStyle(dom.parseStyle(td.style.cssText)));
+
+ return td;
+}
+
+function changedBackgroundImage() {
+ var formObj = document.forms[0];
+ var st = ed.dom.parseStyle(formObj.style.value);
+
+ st['background-image'] = "url('" + formObj.backgroundimage.value + "')";
+
+ formObj.style.value = ed.dom.serializeStyle(st);
+}
+
+function changedSize() {
+ var formObj = document.forms[0];
+ var st = ed.dom.parseStyle(formObj.style.value);
+
+ var width = formObj.width.value;
+ if (width != "")
+ st['width'] = getCSSSize(width);
+ else
+ st['width'] = "";
+
+ var height = formObj.height.value;
+ if (height != "")
+ st['height'] = getCSSSize(height);
+ else
+ st['height'] = "";
+
+ formObj.style.value = ed.dom.serializeStyle(st);
+}
+
+function changedColor() {
+ var formObj = document.forms[0];
+ var st = ed.dom.parseStyle(formObj.style.value);
+
+ st['background-color'] = formObj.bgcolor.value;
+ st['border-color'] = formObj.bordercolor.value;
+
+ formObj.style.value = ed.dom.serializeStyle(st);
+}
+
+function changedStyle() {
+ var formObj = document.forms[0];
+ var st = ed.dom.parseStyle(formObj.style.value);
+
+ if (st['background-image'])
+ formObj.backgroundimage.value = st['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
+ else
+ formObj.backgroundimage.value = '';
+
+ if (st['width'])
+ formObj.width.value = trimSize(st['width']);
+
+ if (st['height'])
+ formObj.height.value = trimSize(st['height']);
+
+ if (st['background-color']) {
+ formObj.bgcolor.value = st['background-color'];
+ updateColor('bgcolor_pick','bgcolor');
+ }
+
+ if (st['border-color']) {
+ formObj.bordercolor.value = st['border-color'];
+ updateColor('bordercolor_pick','bordercolor');
+ }
+}
+
+tinyMCEPopup.onInit.add(init);
diff --git a/program/js/tiny_mce/plugins/table/js/merge_cells.js b/program/js/tiny_mce/plugins/table/js/merge_cells.js
new file mode 100644
index 000000000..7ee4bf040
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/js/merge_cells.js
@@ -0,0 +1,27 @@
+tinyMCEPopup.requireLangPack();
+
+var MergeCellsDialog = {
+ init : function() {
+ var f = document.forms[0];
+
+ f.numcols.value = tinyMCEPopup.getWindowArg('cols', 1);
+ f.numrows.value = tinyMCEPopup.getWindowArg('rows', 1);
+ },
+
+ merge : function() {
+ var func, f = document.forms[0];
+
+ tinyMCEPopup.restoreSelection();
+
+ func = tinyMCEPopup.getWindowArg('onaction');
+
+ func({
+ cols : f.numcols.value,
+ rows : f.numrows.value
+ });
+
+ tinyMCEPopup.close();
+ }
+};
+
+tinyMCEPopup.onInit.add(MergeCellsDialog.init, MergeCellsDialog);
diff --git a/program/js/tiny_mce/plugins/table/js/row.js b/program/js/tiny_mce/plugins/table/js/row.js
new file mode 100644
index 000000000..a13d69592
--- /dev/null
+++ b/program/js/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');
+
+ if (!AutoValidator.validate(formObj)) {
+ tinyMCEPopup.alert(AutoValidator.getErrorMessages(formObj).join('. ') + '.');
+ return false;
+ }
+
+ 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;
+ }
+
+ switch (action) {
+ case "row":
+ updateRow(trElm);
+ break;
+
+ case "all":
+ var rows = tableElm.getElementsByTagName("tr");
+
+ for (var i=0; i<rows.length; i++)
+ updateRow(rows[i], true);
+
+ break;
+
+ case "odd":
+ case "even":
+ var rows = tableElm.getElementsByTagName("tr");
+
+ for (var i=0; i<rows.length; i++) {
+ if ((i % 2 == 0 && action == "odd") || (i % 2 != 0 && action == "even"))
+ updateRow(rows[i], true, true);
+ }
+
+ break;
+ }
+
+ inst.addVisual();
+ inst.nodeChanged();
+ inst.execCommand('mceEndUndoLevel');
+ tinyMCEPopup.close();
+}
+
+function updateRow(tr_elm, skip_id, skip_parent) {
+ var inst = tinyMCEPopup.editor;
+ var formObj = document.forms[0];
+ var dom = inst.dom;
+ var curRowType = tr_elm.parentNode.nodeName.toLowerCase();
+ var rowtype = getSelectValue(formObj, 'rowtype');
+ var doc = inst.getDoc();
+
+ // Update row element
+ if (!skip_id)
+ dom.setAttrib(tr_elm, 'id', formObj.id.value);
+
+ dom.setAttrib(tr_elm, 'align', getSelectValue(formObj, 'align'));
+ dom.setAttrib(tr_elm, 'vAlign', getSelectValue(formObj, 'valign'));
+ dom.setAttrib(tr_elm, 'lang', formObj.lang.value);
+ dom.setAttrib(tr_elm, 'dir', getSelectValue(formObj, 'dir'));
+ dom.setAttrib(tr_elm, 'style', dom.serializeStyle(dom.parseStyle(formObj.style.value)));
+ dom.setAttrib(tr_elm, 'class', getSelectValue(formObj, 'class'));
+
+ // Clear deprecated attributes
+ dom.setAttrib(tr_elm, 'background', '');
+ dom.setAttrib(tr_elm, 'bgColor', '');
+ dom.setAttrib(tr_elm, 'height', '');
+
+ // Set styles
+ tr_elm.style.height = getCSSSize(formObj.height.value);
+ tr_elm.style.backgroundColor = formObj.bgcolor.value;
+
+ if (formObj.backgroundimage.value != "")
+ tr_elm.style.backgroundImage = "url('" + formObj.backgroundimage.value + "')";
+ else
+ tr_elm.style.backgroundImage = '';
+
+ // Setup new rowtype
+ if (curRowType != rowtype && !skip_parent) {
+ // first, clone the node we are working on
+ var newRow = tr_elm.cloneNode(1);
+
+ // next, find the parent of its new destination (creating it if necessary)
+ var theTable = dom.getParent(tr_elm, "table");
+ var dest = rowtype;
+ var newParent = null;
+ for (var i = 0; i < theTable.childNodes.length; i++) {
+ if (theTable.childNodes[i].nodeName.toLowerCase() == dest)
+ newParent = theTable.childNodes[i];
+ }
+
+ if (newParent == null) {
+ newParent = doc.createElement(dest);
+
+ if (theTable.firstChild.nodeName == 'CAPTION')
+ inst.dom.insertAfter(newParent, theTable.firstChild);
+ else
+ theTable.insertBefore(newParent, theTable.firstChild);
+ }
+
+ // append the row to the new parent
+ newParent.appendChild(newRow);
+
+ // remove the original
+ tr_elm.parentNode.removeChild(tr_elm);
+
+ // set tr_elm to the new node
+ tr_elm = newRow;
+ }
+
+ dom.setAttrib(tr_elm, 'style', dom.serializeStyle(dom.parseStyle(tr_elm.style.cssText)));
+}
+
+function changedBackgroundImage() {
+ var formObj = document.forms[0], dom = tinyMCEPopup.editor.dom;
+ var st = dom.parseStyle(formObj.style.value);
+
+ st['background-image'] = "url('" + formObj.backgroundimage.value + "')";
+
+ formObj.style.value = dom.serializeStyle(st);
+}
+
+function changedStyle() {
+ var formObj = document.forms[0], dom = tinyMCEPopup.editor.dom;
+ var st = dom.parseStyle(formObj.style.value);
+
+ if (st['background-image'])
+ formObj.backgroundimage.value = st['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
+ else
+ formObj.backgroundimage.value = '';
+
+ if (st['height'])
+ formObj.height.value = trimSize(st['height']);
+
+ if (st['background-color']) {
+ formObj.bgcolor.value = st['background-color'];
+ updateColor('bgcolor_pick','bgcolor');
+ }
+}
+
+function changedSize() {
+ var formObj = document.forms[0], dom = tinyMCEPopup.editor.dom;
+ var st = dom.parseStyle(formObj.style.value);
+
+ var height = formObj.height.value;
+ if (height != "")
+ st['height'] = getCSSSize(height);
+ else
+ st['height'] = "";
+
+ formObj.style.value = dom.serializeStyle(st);
+}
+
+function changedColor() {
+ var formObj = document.forms[0], dom = tinyMCEPopup.editor.dom;
+ var st = dom.parseStyle(formObj.style.value);
+
+ st['background-color'] = formObj.bgcolor.value;
+
+ formObj.style.value = dom.serializeStyle(st);
+}
+
+tinyMCEPopup.onInit.add(init);
diff --git a/program/js/tiny_mce/plugins/table/js/table.js b/program/js/tiny_mce/plugins/table/js/table.js
new file mode 100644
index 000000000..520d857fc
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/js/table.js
@@ -0,0 +1,450 @@
+tinyMCEPopup.requireLangPack();
+
+var action, orgTableWidth, orgTableHeight, dom = tinyMCEPopup.editor.dom;
+
+function insertTable() {
+ var formObj = document.forms[0];
+ var inst = tinyMCEPopup.editor, dom = inst.dom;
+ var cols = 2, rows = 2, border = 0, cellpadding = -1, cellspacing = -1, align, width, height, className, caption, frame, rules;
+ var html = '', capEl, elm;
+ var cellLimit, rowLimit, colLimit;
+
+ tinyMCEPopup.restoreSelection();
+
+ if (!AutoValidator.validate(formObj)) {
+ tinyMCEPopup.alert(AutoValidator.getErrorMessages(formObj).join('. ') + '.');
+ return false;
+ }
+
+ elm = dom.getParent(inst.selection.getNode(), 'table');
+
+ // Get form data
+ cols = formObj.elements['cols'].value;
+ rows = formObj.elements['rows'].value;
+ border = formObj.elements['border'].value != "" ? formObj.elements['border'].value : 0;
+ cellpadding = formObj.elements['cellpadding'].value != "" ? formObj.elements['cellpadding'].value : "";
+ cellspacing = formObj.elements['cellspacing'].value != "" ? formObj.elements['cellspacing'].value : "";
+ align = getSelectValue(formObj, "align");
+ frame = getSelectValue(formObj, "tframe");
+ rules = getSelectValue(formObj, "rules");
+ width = formObj.elements['width'].value;
+ height = formObj.elements['height'].value;
+ bordercolor = formObj.elements['bordercolor'].value;
+ bgcolor = formObj.elements['bgcolor'].value;
+ className = getSelectValue(formObj, "class");
+ id = formObj.elements['id'].value;
+ summary = formObj.elements['summary'].value;
+ style = formObj.elements['style'].value;
+ dir = formObj.elements['dir'].value;
+ lang = formObj.elements['lang'].value;
+ background = formObj.elements['backgroundimage'].value;
+ caption = formObj.elements['caption'].checked;
+
+ cellLimit = tinyMCEPopup.getParam('table_cell_limit', false);
+ rowLimit = tinyMCEPopup.getParam('table_row_limit', false);
+ colLimit = tinyMCEPopup.getParam('table_col_limit', false);
+
+ // Validate table size
+ if (colLimit && cols > colLimit) {
+ tinyMCEPopup.alert(inst.getLang('table_dlg.col_limit').replace(/\{\$cols\}/g, colLimit));
+ return false;
+ } else if (rowLimit && rows > rowLimit) {
+ tinyMCEPopup.alert(inst.getLang('table_dlg.row_limit').replace(/\{\$rows\}/g, rowLimit));
+ return false;
+ } else if (cellLimit && cols * rows > cellLimit) {
+ tinyMCEPopup.alert(inst.getLang('table_dlg.cell_limit').replace(/\{\$cells\}/g, cellLimit));
+ return false;
+ }
+
+ // Update table
+ if (action == "update") {
+ dom.setAttrib(elm, 'cellPadding', cellpadding, true);
+ dom.setAttrib(elm, 'cellSpacing', cellspacing, true);
+ dom.setAttrib(elm, 'border', border);
+ dom.setAttrib(elm, 'align', align);
+ dom.setAttrib(elm, 'frame', frame);
+ dom.setAttrib(elm, 'rules', rules);
+ dom.setAttrib(elm, 'class', className);
+ dom.setAttrib(elm, 'style', style);
+ dom.setAttrib(elm, 'id', id);
+ dom.setAttrib(elm, 'summary', summary);
+ dom.setAttrib(elm, 'dir', dir);
+ dom.setAttrib(elm, 'lang', lang);
+
+ capEl = inst.dom.select('caption', elm)[0];
+
+ if (capEl && !caption)
+ capEl.parentNode.removeChild(capEl);
+
+ if (!capEl && caption) {
+ capEl = elm.ownerDocument.createElement('caption');
+
+ if (!tinymce.isIE)
+ capEl.innerHTML = '<br data-mce-bogus="1"/>';
+
+ elm.insertBefore(capEl, elm.firstChild);
+ }
+
+ if (width && inst.settings.inline_styles) {
+ dom.setStyle(elm, 'width', width);
+ dom.setAttrib(elm, 'width', '');
+ } else {
+ dom.setAttrib(elm, 'width', width, true);
+ dom.setStyle(elm, 'width', '');
+ }
+
+ // Remove these since they are not valid XHTML
+ dom.setAttrib(elm, 'borderColor', '');
+ dom.setAttrib(elm, 'bgColor', '');
+ dom.setAttrib(elm, 'background', '');
+
+ if (height && inst.settings.inline_styles) {
+ dom.setStyle(elm, 'height', height);
+ dom.setAttrib(elm, 'height', '');
+ } else {
+ dom.setAttrib(elm, 'height', height, true);
+ dom.setStyle(elm, 'height', '');
+ }
+
+ if (background != '')
+ elm.style.backgroundImage = "url('" + background + "')";
+ else
+ elm.style.backgroundImage = '';
+
+/* if (tinyMCEPopup.getParam("inline_styles")) {
+ if (width != '')
+ elm.style.width = getCSSSize(width);
+ }*/
+
+ if (bordercolor != "") {
+ elm.style.borderColor = bordercolor;
+ elm.style.borderStyle = elm.style.borderStyle == "" ? "solid" : elm.style.borderStyle;
+ elm.style.borderWidth = border == "" ? "1px" : border;
+ } else
+ elm.style.borderColor = '';
+
+ elm.style.backgroundColor = bgcolor;
+ elm.style.height = getCSSSize(height);
+
+ inst.addVisual();
+
+ // Fix for stange MSIE align bug
+ //elm.outerHTML = elm.outerHTML;
+
+ inst.nodeChanged();
+ inst.execCommand('mceEndUndoLevel');
+
+ // Repaint if dimensions changed
+ if (formObj.width.value != orgTableWidth || formObj.height.value != orgTableHeight)
+ inst.execCommand('mceRepaint');
+
+ tinyMCEPopup.close();
+ return true;
+ }
+
+ // Create new table
+ html += '<table';
+
+ html += makeAttrib('id', id);
+ html += makeAttrib('border', border);
+ html += makeAttrib('cellpadding', cellpadding);
+ html += makeAttrib('cellspacing', cellspacing);
+ html += makeAttrib('data-mce-new', '1');
+
+ if (width && inst.settings.inline_styles) {
+ if (style)
+ style += '; ';
+
+ // Force px
+ if (/^[0-9\.]+$/.test(width))
+ width += 'px';
+
+ style += 'width: ' + width;
+ } else
+ html += makeAttrib('width', width);
+
+/* if (height) {
+ if (style)
+ style += '; ';
+
+ style += 'height: ' + height;
+ }*/
+
+ //html += makeAttrib('height', height);
+ //html += makeAttrib('bordercolor', bordercolor);
+ //html += makeAttrib('bgcolor', bgcolor);
+ html += makeAttrib('align', align);
+ html += makeAttrib('frame', frame);
+ html += makeAttrib('rules', rules);
+ html += makeAttrib('class', className);
+ html += makeAttrib('style', style);
+ html += makeAttrib('summary', summary);
+ html += makeAttrib('dir', dir);
+ html += makeAttrib('lang', lang);
+ html += '>';
+
+ if (caption) {
+ if (!tinymce.isIE)
+ html += '<caption><br data-mce-bogus="1"/></caption>';
+ else
+ html += '<caption></caption>';
+ }
+
+ for (var y=0; y<rows; y++) {
+ html += "<tr>";
+
+ for (var x=0; x<cols; x++) {
+ if (!tinymce.isIE)
+ html += '<td><br data-mce-bogus="1"/></td>';
+ else
+ html += '<td></td>';
+ }
+
+ html += "</tr>";
+ }
+
+ html += "</table>";
+
+ // Move table
+ if (inst.settings.fix_table_elements) {
+ var patt = '';
+
+ inst.focus();
+ inst.selection.setContent('<br class="_mce_marker" />');
+
+ tinymce.each('h1,h2,h3,h4,h5,h6,p'.split(','), function(n) {
+ if (patt)
+ patt += ',';
+
+ patt += n + ' ._mce_marker';
+ });
+
+ tinymce.each(inst.dom.select(patt), function(n) {
+ inst.dom.split(inst.dom.getParent(n, 'h1,h2,h3,h4,h5,h6,p'), n);
+ });
+
+ dom.setOuterHTML(dom.select('br._mce_marker')[0], html);
+ } else
+ inst.execCommand('mceInsertContent', false, html);
+
+ tinymce.each(dom.select('table[data-mce-new]'), function(node) {
+ var td = dom.select('td', node);
+
+ try {
+ // IE9 might fail to do this selection
+ inst.selection.select(td[0], true);
+ inst.selection.collapse();
+ } catch (ex) {
+ // Ignore
+ }
+
+ dom.setAttrib(node, 'data-mce-new', '');
+ });
+
+ inst.addVisual();
+ inst.execCommand('mceEndUndoLevel');
+
+ tinyMCEPopup.close();
+}
+
+function makeAttrib(attrib, value) {
+ var formObj = document.forms[0];
+ var valueElm = formObj.elements[attrib];
+
+ if (typeof(value) == "undefined" || value == null) {
+ value = "";
+
+ if (valueElm)
+ value = valueElm.value;
+ }
+
+ if (value == "")
+ return "";
+
+ // XML encode it
+ value = value.replace(/&/g, '&amp;');
+ value = value.replace(/\"/g, '&quot;');
+ value = value.replace(/</g, '&lt;');
+ value = value.replace(/>/g, '&gt;');
+
+ return ' ' + attrib + '="' + value + '"';
+}
+
+function init() {
+ tinyMCEPopup.resizeToInnerSize();
+
+ document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
+ 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 cols = 2, rows = 2, border = tinyMCEPopup.getParam('table_default_border', '0'), cellpadding = tinyMCEPopup.getParam('table_default_cellpadding', ''), cellspacing = tinyMCEPopup.getParam('table_default_cellspacing', '');
+ var align = "", width = "", height = "", bordercolor = "", bgcolor = "", className = "";
+ var id = "", summary = "", style = "", dir = "", lang = "", background = "", bgcolor = "", bordercolor = "", rules = "", frame = "";
+ var inst = tinyMCEPopup.editor, dom = inst.dom;
+ var formObj = document.forms[0];
+ var elm = dom.getParent(inst.selection.getNode(), "table");
+
+ action = tinyMCEPopup.getWindowArg('action');
+
+ if (!action)
+ action = elm ? "update" : "insert";
+
+ if (elm && action != "insert") {
+ var rowsAr = elm.rows;
+ var cols = 0;
+ for (var i=0; i<rowsAr.length; i++)
+ if (rowsAr[i].cells.length > cols)
+ cols = rowsAr[i].cells.length;
+
+ cols = cols;
+ rows = rowsAr.length;
+
+ st = dom.parseStyle(dom.getAttrib(elm, "style"));
+ border = trimSize(getStyle(elm, 'border', 'borderWidth'));
+ cellpadding = dom.getAttrib(elm, 'cellpadding', "");
+ cellspacing = dom.getAttrib(elm, 'cellspacing', "");
+ width = trimSize(getStyle(elm, 'width', 'width'));
+ height = trimSize(getStyle(elm, 'height', 'height'));
+ bordercolor = convertRGBToHex(getStyle(elm, 'bordercolor', 'borderLeftColor'));
+ bgcolor = convertRGBToHex(getStyle(elm, 'bgcolor', 'backgroundColor'));
+ align = dom.getAttrib(elm, 'align', align);
+ frame = dom.getAttrib(elm, 'frame');
+ rules = dom.getAttrib(elm, 'rules');
+ className = tinymce.trim(dom.getAttrib(elm, 'class').replace(/mceItem.+/g, ''));
+ id = dom.getAttrib(elm, 'id');
+ summary = dom.getAttrib(elm, 'summary');
+ style = dom.serializeStyle(st);
+ dir = dom.getAttrib(elm, 'dir');
+ lang = dom.getAttrib(elm, 'lang');
+ background = getStyle(elm, 'background', 'backgroundImage').replace(new RegExp("url\\(['\"]?([^'\"]*)['\"]?\\)", 'gi'), "$1");
+ formObj.caption.checked = elm.getElementsByTagName('caption').length > 0;
+
+ orgTableWidth = width;
+ orgTableHeight = height;
+
+ action = "update";
+ formObj.insert.value = inst.getLang('update');
+ }
+
+ addClassesToList('class', "table_styles");
+ TinyMCE_EditableSelects.init();
+
+ // Update form
+ selectByValue(formObj, 'align', align);
+ selectByValue(formObj, 'tframe', frame);
+ selectByValue(formObj, 'rules', rules);
+ selectByValue(formObj, 'class', className, true, true);
+ formObj.cols.value = cols;
+ formObj.rows.value = rows;
+ formObj.border.value = border;
+ formObj.cellpadding.value = cellpadding;
+ formObj.cellspacing.value = cellspacing;
+ formObj.width.value = width;
+ formObj.height.value = height;
+ formObj.bordercolor.value = bordercolor;
+ formObj.bgcolor.value = bgcolor;
+ formObj.id.value = id;
+ formObj.summary.value = summary;
+ formObj.style.value = style;
+ formObj.dir.value = dir;
+ formObj.lang.value = lang;
+ formObj.backgroundimage.value = background;
+
+ updateColor('bordercolor_pick', 'bordercolor');
+ updateColor('bgcolor_pick', 'bgcolor');
+
+ // Resize some elements
+ if (isVisible('backgroundimagebrowser'))
+ document.getElementById('backgroundimage').style.width = '180px';
+
+ // Disable some fields in update mode
+ if (action == "update") {
+ formObj.cols.disabled = true;
+ formObj.rows.disabled = true;
+ }
+}
+
+function changedSize() {
+ var formObj = document.forms[0];
+ var st = dom.parseStyle(formObj.style.value);
+
+/* var width = formObj.width.value;
+ if (width != "")
+ st['width'] = tinyMCEPopup.getParam("inline_styles") ? getCSSSize(width) : "";
+ else
+ st['width'] = "";*/
+
+ var height = formObj.height.value;
+ if (height != "")
+ st['height'] = getCSSSize(height);
+ else
+ st['height'] = "";
+
+ formObj.style.value = dom.serializeStyle(st);
+}
+
+function changedBackgroundImage() {
+ var formObj = document.forms[0];
+ var st = dom.parseStyle(formObj.style.value);
+
+ st['background-image'] = "url('" + formObj.backgroundimage.value + "')";
+
+ formObj.style.value = dom.serializeStyle(st);
+}
+
+function changedBorder() {
+ var formObj = document.forms[0];
+ var st = dom.parseStyle(formObj.style.value);
+
+ // Update border width if the element has a color
+ if (formObj.border.value != "" && formObj.bordercolor.value != "")
+ st['border-width'] = formObj.border.value + "px";
+
+ formObj.style.value = dom.serializeStyle(st);
+}
+
+function changedColor() {
+ var formObj = document.forms[0];
+ var st = dom.parseStyle(formObj.style.value);
+
+ st['background-color'] = formObj.bgcolor.value;
+
+ if (formObj.bordercolor.value != "") {
+ st['border-color'] = formObj.bordercolor.value;
+
+ // Add border-width if it's missing
+ if (!st['border-width'])
+ st['border-width'] = formObj.border.value == "" ? "1px" : formObj.border.value + "px";
+ }
+
+ formObj.style.value = dom.serializeStyle(st);
+}
+
+function changedStyle() {
+ var formObj = document.forms[0];
+ var st = dom.parseStyle(formObj.style.value);
+
+ if (st['background-image'])
+ formObj.backgroundimage.value = st['background-image'].replace(new RegExp("url\\(['\"]?([^'\"]*)['\"]?\\)", 'gi'), "$1");
+ else
+ formObj.backgroundimage.value = '';
+
+ if (st['width'])
+ formObj.width.value = trimSize(st['width']);
+
+ if (st['height'])
+ formObj.height.value = trimSize(st['height']);
+
+ if (st['background-color']) {
+ formObj.bgcolor.value = st['background-color'];
+ updateColor('bgcolor_pick','bgcolor');
+ }
+
+ if (st['border-color']) {
+ formObj.bordercolor.value = st['border-color'];
+ updateColor('bordercolor_pick','bordercolor');
+ }
+}
+
+tinyMCEPopup.onInit.add(init);
diff --git a/program/js/tiny_mce/plugins/table/langs/en_dlg.js b/program/js/tiny_mce/plugins/table/langs/en_dlg.js
new file mode 100644
index 000000000..463e09ee1
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/langs/en_dlg.js
@@ -0,0 +1 @@
+tinyMCE.addI18n('en.table_dlg',{"rules_border":"border","rules_box":"box","rules_vsides":"vsides","rules_rhs":"rhs","rules_lhs":"lhs","rules_hsides":"hsides","rules_below":"below","rules_above":"above","rules_void":"void",rules:"Rules","frame_all":"all","frame_cols":"cols","frame_rows":"rows","frame_groups":"groups","frame_none":"none",frame:"Frame",caption:"Table Caption","missing_scope":"Are you sure you want to continue without specifying a scope for this table header cell. Without it, it may be difficult for some users with disabilities to understand the content or data displayed of the table.","cell_limit":"You\'ve exceeded the maximum number of cells of {$cells}.","row_limit":"You\'ve exceeded the maximum number of rows of {$rows}.","col_limit":"You\'ve exceeded the maximum number of columns of {$cols}.",colgroup:"Col Group",rowgroup:"Row Group",scope:"Scope",tfoot:"Footer",tbody:"Body",thead:"Header","row_all":"Update All Rows in Table","row_even":"Update Even Rows in Table","row_odd":"Update Odd Rows in Table","row_row":"Update Current Row","cell_all":"Update All Cells in Table","cell_row":"Update All Cells in Row","cell_cell":"Update Current Cell",th:"Header",td:"Data",summary:"Summary",bgimage:"Background Image",rtl:"Right to Left",ltr:"Left to Right",mime:"Target MIME Type",langcode:"Language Code",langdir:"Language Direction",style:"Style",id:"ID","merge_cells_title":"Merge Table Cells",bgcolor:"Background Color",bordercolor:"Border Color","align_bottom":"Bottom","align_top":"Top",valign:"Vertical Alignment","cell_type":"Cell Type","cell_title":"Table Cell Properties","row_title":"Table Row Properties","align_middle":"Center","align_right":"Right","align_left":"Left","align_default":"Default",align:"Alignment",border:"Border",cellpadding:"Cell Padding",cellspacing:"Cell Spacing",rows:"Rows",cols:"Columns",height:"Height",width:"Width",title:"Insert/Edit Table",rowtype:"Row Type","advanced_props":"Advanced Properties","general_props":"General Properties","advanced_tab":"Advanced","general_tab":"General","cell_col":"Update all cells in column"}); \ No newline at end of file
diff --git a/program/js/tiny_mce/plugins/table/merge_cells.htm b/program/js/tiny_mce/plugins/table/merge_cells.htm
new file mode 100644
index 000000000..d231090e7
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/merge_cells.htm
@@ -0,0 +1,32 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>{#table_dlg.merge_cells_title}</title>
+ <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
+ <script type="text/javascript" src="../../utils/mctabs.js"></script>
+ <script type="text/javascript" src="../../utils/validate.js"></script>
+ <script type="text/javascript" src="js/merge_cells.js"></script>
+</head>
+<body style="margin: 8px" role="application">
+<form onsubmit="MergeCellsDialog.merge();return false;" action="#">
+ <fieldset>
+ <legend>{#table_dlg.merge_cells_title}</legend>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="3" width="100%">
+ <tr>
+ <td><label for="numcols">{#table_dlg.cols}</label>:</td>
+ <td align="right"><input type="text" id="numcols" name="numcols" value="" class="number min1 mceFocus" style="width: 30px" aria-required="true" /></td>
+ </tr>
+ <tr>
+ <td><label for="numrows">{#table_dlg.rows}</label>:</td>
+ <td align="right"><input type="text" id="numrows" name="numrows" value="" class="number min1" style="width: 30px" aria-required="true" /></td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <div class="mceActionPanel">
+ <input type="submit" id="insert" name="insert" value="{#update}" />
+ <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+ </div>
+</form>
+</body>
+</html>
diff --git a/program/js/tiny_mce/plugins/table/row.htm b/program/js/tiny_mce/plugins/table/row.htm
new file mode 100644
index 000000000..1885401f6
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/row.htm
@@ -0,0 +1,158 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>{#table_dlg.row_title}</title>
+ <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
+ <script type="text/javascript" src="../../utils/mctabs.js"></script>
+ <script type="text/javascript" src="../../utils/form_utils.js"></script>
+ <script type="text/javascript" src="../../utils/validate.js"></script>
+ <script type="text/javascript" src="../../utils/editable_selects.js"></script>
+ <script type="text/javascript" src="js/row.js"></script>
+ <link href="css/row.css" rel="stylesheet" type="text/css" />
+</head>
+<body id="tablerow" style="display: none" role="application">
+ <form onsubmit="updateAction();return false;" action="#">
+ <div class="tabs">
+ <ul>
+ <li id="general_tab" class="current" aria-controls="general_panel"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#table_dlg.general_tab}</a></span></li>
+ <li id="advanced_tab" aria-controls="advanced_panel"><span><a href="javascript:mcTabs.displayTab('advanced_tab','advanced_panel');" onmousedown="return false;">{#table_dlg.advanced_tab}</a></span></li>
+ </ul>
+ </div>
+
+ <div class="panel_wrapper">
+ <div id="general_panel" class="panel current">
+ <fieldset>
+ <legend>{#table_dlg.general_props}</legend>
+
+ <table role="presentation" border="0" cellpadding="4" cellspacing="0">
+ <tr>
+ <td><label for="rowtype">{#table_dlg.rowtype}</label></td>
+ <td class="col2">
+ <select id="rowtype" name="rowtype" class="mceFocus">
+ <option value="thead">{#table_dlg.thead}</option>
+ <option value="tbody">{#table_dlg.tbody}</option>
+ <option value="tfoot">{#table_dlg.tfoot}</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td><label for="align">{#table_dlg.align}</label></td>
+ <td class="col2">
+ <select id="align" name="align">
+ <option value="">{#not_set}</option>
+ <option value="center">{#table_dlg.align_middle}</option>
+ <option value="left">{#table_dlg.align_left}</option>
+ <option value="right">{#table_dlg.align_right}</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td><label for="valign">{#table_dlg.valign}</label></td>
+ <td class="col2">
+ <select id="valign" name="valign">
+ <option value="">{#not_set}</option>
+ <option value="top">{#table_dlg.align_top}</option>
+ <option value="middle">{#table_dlg.align_middle}</option>
+ <option value="bottom">{#table_dlg.align_bottom}</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr id="styleSelectRow">
+ <td><label for="class">{#class_name}</label></td>
+ <td class="col2">
+ <select id="class" name="class" class="mceEditableSelect">
+ <option value="" selected="selected">{#not_set}</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td><label for="height">{#table_dlg.height}</label></td>
+ <td class="col2"><input name="height" type="text" id="height" value="" size="7" maxlength="7" onchange="changedSize();" class="size" /></td>
+ </tr>
+ </table>
+ </fieldset>
+ </div>
+
+ <div id="advanced_panel" class="panel">
+ <fieldset>
+ <legend>{#table_dlg.advanced_props}</legend>
+
+ <table role="presentation" border="0" cellpadding="0" cellspacing="4">
+ <tr>
+ <td class="column1"><label for="id">{#table_dlg.id}</label></td>
+ <td><input id="id" name="id" type="text" value="" style="width: 200px" /></td>
+ </tr>
+
+ <tr>
+ <td><label for="style">{#table_dlg.style}</label></td>
+ <td><input type="text" id="style" name="style" value="" style="width: 200px;" onchange="changedStyle();" /></td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="dir">{#table_dlg.langdir}</label></td>
+ <td>
+ <select id="dir" name="dir" style="width: 200px">
+ <option value="">{#not_set}</option>
+ <option value="ltr">{#table_dlg.ltr}</option>
+ <option value="rtl">{#table_dlg.rtl}</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="lang">{#table_dlg.langcode}</label></td>
+ <td>
+ <input id="lang" name="lang" type="text" value="" style="width: 200px" />
+ </td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="backgroundimage">{#table_dlg.bgimage}</label></td>
+ <td>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input id="backgroundimage" name="backgroundimage" type="text" value="" style="width: 200px" onchange="changedBackgroundImage();" /></td>
+ <td id="backgroundimagebrowsercontainer">&nbsp;</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="bgcolor" id="bgcolor_label">{#table_dlg.bgcolor}</label></td>
+ <td>
+ <span role="group" aria-labelledby="bgcolor_label">
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input id="bgcolor" name="bgcolor" type="text" value="" size="9" onchange="updateColor('bgcolor_pick','bgcolor');changedColor();" /></td>
+ <td id="bgcolor_pickcontainer">&nbsp;</td>
+ </tr>
+ </table>
+ </span>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+ </div>
+ </div>
+
+ <div class="mceActionPanel">
+ <div>
+ <select id="action" name="action">
+ <option value="row">{#table_dlg.row_row}</option>
+ <option value="odd">{#table_dlg.row_odd}</option>
+ <option value="even">{#table_dlg.row_even}</option>
+ <option value="all">{#table_dlg.row_all}</option>
+ </select>
+ </div>
+
+ <input type="submit" id="insert" name="insert" value="{#update}" />
+ <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+ </div>
+ </form>
+</body>
+</html>
diff --git a/program/js/tiny_mce/plugins/table/table.htm b/program/js/tiny_mce/plugins/table/table.htm
new file mode 100644
index 000000000..09d3700f7
--- /dev/null
+++ b/program/js/tiny_mce/plugins/table/table.htm
@@ -0,0 +1,188 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>{#table_dlg.title}</title>
+ <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
+ <script type="text/javascript" src="../../utils/mctabs.js"></script>
+ <script type="text/javascript" src="../../utils/form_utils.js"></script>
+ <script type="text/javascript" src="../../utils/validate.js"></script>
+ <script type="text/javascript" src="../../utils/editable_selects.js"></script>
+ <script type="text/javascript" src="js/table.js"></script>
+ <link href="css/table.css" rel="stylesheet" type="text/css" />
+</head>
+<body id="table" style="display: none" role="application" aria-labelledby="app_title">
+ <span style="display:none;" id="app_title">{#table_dlg.title}</span>
+ <form onsubmit="insertTable();return false;" action="#">
+ <div class="tabs">
+ <ul>
+ <li id="general_tab" aria-controls="general_panel" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#table_dlg.general_tab}</a></span></li>
+ <li id="advanced_tab" aria-controls="advanced_panel"><span><a href="javascript:mcTabs.displayTab('advanced_tab','advanced_panel');" onmousedown="return false;">{#table_dlg.advanced_tab}</a></span></li>
+ </ul>
+ </div>
+
+ <div class="panel_wrapper">
+ <div id="general_panel" class="panel current">
+ <fieldset>
+ <legend>{#table_dlg.general_props}</legend>
+ <table role="presentation" border="0" cellpadding="4" cellspacing="0" width="100%">
+ <tr>
+ <td><label id="colslabel" for="cols">{#table_dlg.cols}</label></td>
+ <td><input id="cols" name="cols" type="text" value="" size="3" maxlength="3" class="required number min1 mceFocus" aria-required="true" /></td>
+ <td><label id="rowslabel" for="rows">{#table_dlg.rows}</label></td>
+ <td><input id="rows" name="rows" type="text" value="" size="3" maxlength="3" class="required number min1" aria-required="true" /></td>
+ </tr>
+ <tr>
+ <td><label id="cellpaddinglabel" for="cellpadding">{#table_dlg.cellpadding}</label></td>
+ <td><input id="cellpadding" name="cellpadding" type="text" value="" size="3" maxlength="3" class="number" /></td>
+ <td><label id="cellspacinglabel" for="cellspacing">{#table_dlg.cellspacing}</label></td>
+ <td><input id="cellspacing" name="cellspacing" type="text" value="" size="3" maxlength="3" class="number" /></td>
+ </tr>
+ <tr>
+ <td><label id="alignlabel" for="align">{#table_dlg.align}</label></td>
+ <td><select id="align" name="align">
+ <option value="">{#not_set}</option>
+ <option value="center">{#table_dlg.align_middle}</option>
+ <option value="left">{#table_dlg.align_left}</option>
+ <option value="right">{#table_dlg.align_right}</option>
+ </select></td>
+ <td><label id="borderlabel" for="border">{#table_dlg.border}</label></td>
+ <td><input id="border" name="border" type="text" value="" size="3" maxlength="3" onchange="changedBorder();" class="number" /></td>
+ </tr>
+ <tr id="width_row">
+ <td><label id="widthlabel" for="width">{#table_dlg.width}</label></td>
+ <td><input name="width" type="text" id="width" value="" size="7" maxlength="7" onchange="changedSize();" class="size" /></td>
+ <td><label id="heightlabel" for="height">{#table_dlg.height}</label></td>
+ <td><input name="height" type="text" id="height" value="" size="7" maxlength="7" onchange="changedSize();" class="size" /></td>
+ </tr>
+ <tr id="styleSelectRow" >
+ <td><label id="classlabel" for="class">{#class_name}</label></td>
+ <td colspan="3" >
+ <select id="class" name="class" class="mceEditableSelect">
+ <option value="" selected="selected">{#not_set}</option>
+ </select></td>
+ </tr>
+ <tr>
+ <td class="column1" ><label for="caption">{#table_dlg.caption}</label></td>
+ <td><input id="caption" name="caption" type="checkbox" class="checkbox" value="true" /></td>
+ </tr>
+ </table>
+ </fieldset>
+ </div>
+
+ <div id="advanced_panel" class="panel">
+ <fieldset>
+ <legend>{#table_dlg.advanced_props}</legend>
+
+ <table role="presentation" border="0" cellpadding="0" cellspacing="4">
+ <tr>
+ <td class="column1"><label for="id">{#table_dlg.id}</label></td>
+ <td><input id="id" name="id" type="text" value="" class="advfield" /></td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="summary">{#table_dlg.summary}</label></td>
+ <td><input id="summary" name="summary" type="text" value="" class="advfield" /></td>
+ </tr>
+
+ <tr>
+ <td><label for="style">{#table_dlg.style}</label></td>
+ <td><input type="text" id="style" name="style" value="" class="advfield" onchange="changedStyle();" /></td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label id="langlabel" for="lang">{#table_dlg.langcode}</label></td>
+ <td>
+ <input id="lang" name="lang" type="text" value="" class="advfield" />
+ </td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="backgroundimage">{#table_dlg.bgimage}</label></td>
+ <td>
+ <table role="presentation" aria-labelledby="backgroundimage_label" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input id="backgroundimage" name="backgroundimage" type="text" value="" class="advfield" onchange="changedBackgroundImage();" /></td>
+ <td id="backgroundimagebrowsercontainer">&nbsp;</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="tframe">{#table_dlg.frame}</label></td>
+ <td>
+ <select id="tframe" name="tframe" class="advfield">
+ <option value="">{#not_set}</option>
+ <option value="void">{#table_dlg.rules_void}</option>
+ <option value="above">{#table_dlg.rules_above}</option>
+ <option value="below">{#table_dlg.rules_below}</option>
+ <option value="hsides">{#table_dlg.rules_hsides}</option>
+ <option value="lhs">{#table_dlg.rules_lhs}</option>
+ <option value="rhs">{#table_dlg.rules_rhs}</option>
+ <option value="vsides">{#table_dlg.rules_vsides}</option>
+ <option value="box">{#table_dlg.rules_box}</option>
+ <option value="border">{#table_dlg.rules_border}</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="rules">{#table_dlg.rules}</label></td>
+ <td>
+ <select id="rules" name="rules" class="advfield">
+ <option value="">{#not_set}</option>
+ <option value="none">{#table_dlg.frame_none}</option>
+ <option value="groups">{#table_dlg.frame_groups}</option>
+ <option value="rows">{#table_dlg.frame_rows}</option>
+ <option value="cols">{#table_dlg.frame_cols}</option>
+ <option value="all">{#table_dlg.frame_all}</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="column1"><label for="dir">{#table_dlg.langdir}</label></td>
+ <td>
+ <select id="dir" name="dir" class="advfield">
+ <option value="">{#not_set}</option>
+ <option value="ltr">{#table_dlg.ltr}</option>
+ <option value="rtl">{#table_dlg.rtl}</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr role="group" aria-labelledby="bordercolor_label">
+ <td class="column1"><label id="bordercolor_label" for="bordercolor">{#table_dlg.bordercolor}</label></td>
+ <td>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input id="bordercolor" name="bordercolor" type="text" value="" size="9" onchange="updateColor('bordercolor_pick','bordercolor');changedColor();" /></td>
+ <td id="bordercolor_pickcontainer">&nbsp;</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr role="group" aria-labelledby="bgcolor_label">
+ <td class="column1"><label id="bgcolor_label" for="bgcolor">{#table_dlg.bgcolor}</label></td>
+ <td>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input id="bgcolor" name="bgcolor" type="text" value="" size="9" onchange="updateColor('bgcolor_pick','bgcolor');changedColor();" /></td>
+ <td id="bgcolor_pickcontainer">&nbsp;</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+ </div>
+ </div>
+
+ <div class="mceActionPanel">
+ <input type="submit" id="insert" name="insert" value="{#insert}" />
+ <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+ </div>
+ </form>
+</body>
+</html>