1 line
22 KiB
JavaScript
1 line
22 KiB
JavaScript
!function(B,G){function q(f,c){for(var g,d=[],a=0;a<f.length;++a){if(g=H[f[a]]||k(f[a]),!g){throw"module definition dependecy not found: "+f[a]}d.push(g)}c.apply(null,d)}function b(d,c,a){if("string"!=typeof d){throw"invalid module definition, module id must be defined and be a string"}if(c===G){throw"invalid module definition, dependencies must be specified"}if(a===G){throw"invalid module definition, definition function must be specified"}q(c,function(){H[d]=a.apply(null,arguments)})}function x(a){return !!H[a]}function k(c){for(var e=B,d=c.split(/[.\/]/),a=0;a<d.length;++a){if(!e[d[a]]){return}e=e[d[a]]}return e}function E(h){for(var f=0;f<h.length;f++){for(var e=B,g=h[f],d=g.split(/[.\/]/),c=0;c<d.length-1;++c){e[d[c]]===G&&(e[d[c]]={}),e=e[d[c]]}e[d[d.length-1]]=H[g]}}var H={},w="tinymce/tableplugin/TableGrid",D="tinymce/util/Tools",C="tinymce/Env",F="tinymce/tableplugin/Quirks",A="tinymce/util/VK",j="tinymce/tableplugin/CellSelection",v="tinymce/dom/TreeWalker",y="tinymce/tableplugin/Plugin",z="tinymce/PluginManager";b(w,[D,C],function(d,a){function f(h,g){return parseInt(h.getAttribute(g)||1,10)}var c=d.each;return function(ag,ac){function an(){var g=0;r=[],c(["thead","tbody","tfoot"],function(l){var h=O.select("> "+l+" tr",ac);c(h,function(m,p){p+=g,c(O.select("> td, > th",m),function(R,P){var M,u,N,o;if(r[p]){for(;r[p][P];){P++}}for(N=f(R,"rowspan"),o=f(R,"colspan"),u=p;p+N>u;u++){for(r[u]||(r[u]=[]),M=P;P+o>M;M++){r[u][M]={part:l,real:u==p&&M==P,elm:R,rowspan:N,colspan:o}}}})}),g+=h.length})}function X(h,g){return h=h.cloneNode(g),h.removeAttribute("id"),h}function ae(h,g){var i;return i=r[g],i?i[h]:void 0}function al(h,g,i){h&&(i=parseInt(i,10),1===i?h.removeAttribute(g,1):h.setAttribute(g,i,1))}function ak(g){return g&&(O.hasClass(g.elm,"mce-item-selected")||g==t)}function V(){var g=[];return c(ac.rows,function(h){c(h.cells,function(i){return O.hasClass(i,"mce-item-selected")||i==t.elm?(g.push(h),!1):void 0})}),g}function aj(){var g=O.createRng();g.setStartAfter(ac),g.setEndAfter(ac),J.setRng(g),O.remove(ac)}function ab(i){var h,g={};return ag.settings.table_clone_elements!==!1&&(g=d.makeMap((ag.settings.table_clone_elements||"strong em b i span font h1 h2 h3 h4 h5 h6 p div").toUpperCase(),/[ ,]/)),d.walk(i,function(m){var l;return 3==m.nodeType?(c(O.getParents(m.parentNode,null,i).reverse(),function(o){g[o.nodeName]&&(o=X(o,!1),h?l&&l.appendChild(o):h=l=o,l=o)}),l&&(l.innerHTML=a.ie?" ":'<br data-mce-bogus="1" />'),!1):void 0},"childNodes"),i=X(i,!1),al(i,"rowSpan",1),al(i,"colSpan",1),h?i.appendChild(h):a.ie||(i.innerHTML='<br data-mce-bogus="1" />'),i}function ad(){var h=O.createRng(),g;return c(O.select("tr",ac),function(i){0===i.cells.length&&O.remove(i)}),0===O.select("tr",ac).length?(h.setStartBefore(ac),h.setEndBefore(ac),J.setRng(h),O.remove(ac),void 0):(c(O.select("thead,tbody,tfoot",ac),function(i){0===i.rows.length&&O.remove(i)}),an(),g=r[Math.min(r.length-1,aa.y)],g&&(J.select(g[Math.min(g.length-1,aa.x)].elm,!0),J.collapse(!0)),void 0)}function ah(M,P,m,g){var u,h,N,R,p;for(u=r[P][M].elm.parentNode,N=1;m>=N;N++){if(u=O.getNext(u,"tr")){for(h=M;h>=0;h--){if(p=r[P+N][h].elm,p.parentNode==u){for(R=1;g>=R;R++){O.insertAfter(ab(p),p)}break}}if(-1==h){for(R=1;g>=R;R++){u.insertBefore(ab(u.cells[0]),u.cells[0])}}}}}function ai(){c(r,function(h,g){c(h,function(s,p){var m,u,l;if(ak(s)&&(s=s.elm,m=f(s,"colspan"),u=f(s,"rowspan"),m>1||u>1)){for(al(s,"rowSpan",1),al(s,"colSpan",1),l=0;m-1>l;l++){O.insertAfter(ab(s),s)}ah(p,g,u-1,m)}})})}function U(at,M,N){var m,au,ar,R,l,P,aq,T,S,g,ap;if(at?(m=n(at),au=m.x,ar=m.y,R=au+(M-1),l=ar+(N-1)):(aa=Z=null,c(r,function(i,h){c(i,function(o,p){ak(o)&&(aa||(aa={x:p,y:h}),Z={x:p,y:h})})}),au=aa.x,ar=aa.y,R=Z.x,l=Z.y),T=ae(au,ar),S=ae(R,l),T&&S&&T.part==S.part){for(ai(),an(),T=ae(au,ar).elm,al(T,"colSpan",R-au+1),al(T,"rowSpan",l-ar+1),aq=ar;l>=aq;aq++){for(P=au;R>=P;P++){r[aq]&&r[aq][P]&&(at=r[aq][P].elm,at!=T&&(g=d.grep(at.childNodes),c(g,function(h){T.appendChild(h)}),g.length&&(g=d.grep(T.childNodes),ap=0,c(g,function(h){"BR"==h.nodeName&&O.getAttrib(h,"data-mce-bogus")&&ap++<g.length-1&&T.removeChild(h)})),O.remove(at)))}}ad()}}function K(R){var ap,M,g,S,s,T,P,p,N;for(c(r,function(l,h){return c(l,function(i){return ak(i)&&(i=i.elm,s=i.parentNode,T=X(s,!1),ap=h,R)?!1:void 0}),R?!ap:void 0}),S=0;S<r[0].length;S++){if(r[ap][S]&&(M=r[ap][S].elm,M!=g)){if(R){if(ap>0&&r[ap-1][S]&&(p=r[ap-1][S].elm,N=f(p,"rowSpan"),N>1)){al(p,"rowSpan",N+1);continue}}else{if(N=f(M,"rowspan"),N>1){al(M,"rowSpan",N+1);continue}}P=ab(M),al(P,"colSpan",M.colSpan),T.appendChild(P),g=M}}T.hasChildNodes()&&(R?s.parentNode.insertBefore(T,s):O.insertAfter(T,s))}function am(l){var h,g;c(r,function(i){return c(i,function(o,m){return ak(o)&&(h=m,l)?!1:void 0}),l?!h:void 0}),c(r,function(u,M){var m,p,i;u[h]&&(m=u[h].elm,m!=g&&(i=f(m,"colspan"),p=f(m,"rowspan"),1==i?l?(m.parentNode.insertBefore(ab(m),m),ah(h,M,p-1,i)):(O.insertAfter(ab(m),m),ah(h,M,p-1,i)):al(m,"colSpan",m.colSpan+1),g=m))})}function Y(){var g=[];c(r,function(h){c(h,function(l,m){ak(l)&&-1===d.inArray(g,m)&&(c(r,function(p){var i=p[m].elm,o;o=f(i,"colSpan"),o>1?al(i,"colSpan",o-1):O.remove(i)}),g.push(m))})}),ad()}function L(){function h(p){var m,l,s;m=O.getNext(p,"tr"),c(p.cells,function(o){var i=f(o,"rowSpan");i>1&&(al(o,"rowSpan",i-1),l=n(o),ah(l.x,l.y,1,1))}),l=n(p.cells[0]),c(r[l.y],function(o){var i;o=o.elm,o!=s&&(i=f(o,"rowSpan"),1>=i?O.remove(o):al(o,"rowSpan",i-1),s=o)})}var g;g=V(),c(g.reverse(),function(i){h(i)}),ad()}function Q(){var g=V();return O.remove(g),ad(),g}function ao(){var g=V();return c(g,function(h,i){g[i]=X(h,!0)}),g}function I(l,h){var p=V(),g=p[h?0:p.length-1],m=g.cells.length;l&&(c(r,function(o){var i;return m=0,c(o,function(s){s.real&&(m+=s.colspan),s.elm.parentNode==g&&(i=1)}),i?!1:void 0}),h||l.reverse(),c(l,function(s){var u,o=s.cells.length,i;for(u=0;o>u;u++){i=s.cells[u],al(i,"colSpan",1),al(i,"rowSpan",1)}for(u=o;m>u;u++){s.appendChild(ab(s.cells[o-1]))}for(u=m;o>u;u++){O.remove(s.cells[u])}h?g.parentNode.insertBefore(s,g):O.insertAfter(s,g)}),O.removeClass(O.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"))}function n(h){var g;return c(r,function(m,l){return c(m,function(o,i){return o.elm==h?(g={x:i,y:l},!1):void 0}),!g}),g}function W(g){aa=n(g)}function af(){var h,g;return h=g=0,c(r,function(m,l){c(m,function(u,p){var s,i;ak(u)&&(u=r[l][p],p>h&&(h=p),l>g&&(g=l),u.real&&(s=u.colspan-1,i=u.rowspan-1,s&&p+s>h&&(h=p+s),i&&l+i>g&&(g=l+i)))})}),{x:h,y:g}}function e(M){var S,m,g,u,h,R,T,p,P,N;if(Z=n(M),aa&&Z){for(S=Math.min(aa.x,Z.x),m=Math.min(aa.y,Z.y),g=Math.max(aa.x,Z.x),u=Math.max(aa.y,Z.y),h=g,R=u,N=m;R>=N;N++){M=r[N][S],M.real||S-(M.colspan-1)<S&&(S-=M.colspan-1)}for(P=S;h>=P;P++){M=r[m][P],M.real||m-(M.rowspan-1)<m&&(m-=M.rowspan-1)}for(N=m;u>=N;N++){for(P=S;g>=P;P++){M=r[N][P],M.real&&(T=M.colspan-1,p=M.rowspan-1,T&&P+T>h&&(h=P+T),p&&N+p>R&&(R=N+p))}}for(O.removeClass(O.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),N=m;R>=N;N++){for(P=S;h>=P;P++){r[N][P]&&O.addClass(r[N][P].elm,"mce-item-selected")}}}}var r,aa,Z,t,J=ag.selection,O=J.dom;ac=ac||O.getParent(J.getStart(),"table"),an(),t=O.getParent(J.getStart(),"th,td"),t&&(aa=n(t),Z=af(),t=ae(aa.x,aa.y)),d.extend(this,{deleteTable:aj,split:ai,merge:U,insertRow:K,insertCol:am,deleteCols:Y,deleteRows:L,cutRows:Q,copyRows:ao,pasteRows:I,getPos:n,setStartCell:W,setEndCell:e})}}),b(F,[A,C,D],function(f,c,g){function d(i,h){return parseInt(i.getAttribute(h)||1,10)}var a=g.each;return function(p){function m(){function l(V){function I(ab,t){var Z=ab?"previousSibling":"nextSibling",Y=p.dom.getParent(t,"tr"),ae=Y[Z];if(ae){return M(p,t,ae,ab),V.preventDefault(),!0}var ac=p.dom.getParent(Y,"table"),ad=Y.parentNode,aa=ad.nodeName.toLowerCase();if("tbody"===aa||aa===(ab?"tfoot":"thead")){var X=S(ab,ac,ad,"tbody");if(null!==X){return K(ab,X,t)}}return P(ab,Y,Z,ac)}function S(aa,Y,Z,X){var ab=p.dom.select(">"+X,Y),u=ab.indexOf(Z);if(aa&&0===u||!aa&&u===ab.length-1){return W(aa,Y)}if(-1===u){var s="thead"===Z.tagName.toLowerCase()?0:ab.length-1;return ab[s]}return ab[u+(aa?-1:1)]}function W(X,s){var u=X?"thead":"tfoot",o=p.dom.select(">"+u,s);return 0!==o.length?o[0]:null}function K(u,t,s){var X=O(t,u);return X&&M(p,s,X,u),V.preventDefault(),!0}function P(Z,Y,u,t){var X=t[u];if(X){return U(X),!0}var o=p.dom.getParent(t,"td,th");if(o){return I(Z,o,V)}var aa=O(Y,!Z);return U(aa),V.preventDefault(),!1}function O(u,o){var s=u&&u[o?"lastChild":"firstChild"];return s&&"BR"===s.nodeName?p.dom.getParent(s,"td,th"):s}function U(o){p.selection.setCursorLocation(o,0)}function N(){return Q==f.UP||Q==f.DOWN}function r(s){var o=s.selection.getNode(),u=s.dom.getParent(o,"tr");return null!==u}function J(s){for(var o=0,u=s;u.previousSibling;){u=u.previousSibling,o+=d(u,"colspan")}return o}function L(u,s){var Y=0,X=0;return a(u.children,function(t,o){return Y+=d(t,"colspan"),X=o,Y>s?!1:void 0}),X}function M(ac,Z,ab,Y){var ad=J(p.dom.getParent(Z,"td,th")),X=L(ab,ad),aa=ab.childNodes[X],u=O(aa,Y);U(u||aa)}function T(X){var s=p.selection.getNode(),u=p.dom.getParent(s,"td,th"),o=p.dom.getParent(X,"td,th");return u&&u!==o&&R(u,o)}function R(s,o){return p.dom.getParent(s,"TABLE")===p.dom.getParent(o,"TABLE")}var Q=V.keyCode;if(N()&&r(p)){var n=p.selection.getNode();setTimeout(function(){T(n)&&I(!V.shiftKey&&Q===f.UP,n,V)},0)}}p.on("KeyDown",function(n){l(n)})}function h(){function l(I,s){var J=s.ownerDocument,u=J.createRange(),o;return u.setStartBefore(s),u.setEnd(I.endContainer,I.endOffset),o=J.createElement("body"),o.appendChild(u.cloneContents()),0===o.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length}p.on("KeyDown",function(s){var u,n,I=p.dom;(37==s.keyCode||38==s.keyCode)&&(u=p.selection.getRng(),n=I.getParent(u.startContainer,"table"),n&&p.getBody().firstChild==n&&l(u,n)&&(u=I.createRng(),u.setStartBefore(n),u.setEndBefore(n),p.selection.setRng(u),s.preventDefault()))})}function i(){p.on("KeyDown SetContent VisualAid",function(){var l;for(l=p.getBody().lastChild;l;l=l.previousSibling){if(3==l.nodeType){if(l.nodeValue.length>0){break}}else{if(1==l.nodeType&&!l.getAttribute("data-mce-bogus")){break}}}l&&"TABLE"==l.nodeName&&(p.settings.forced_root_block?p.dom.add(p.getBody(),p.settings.forced_root_block,null,c.ie?" ":'<br data-mce-bogus="1" />'):p.dom.add(p.getBody(),"br",{"data-mce-bogus":"1"}))}),p.on("PreProcess",function(n){var l=n.node.lastChild;l&&("BR"==l.nodeName||1==l.childNodes.length&&("BR"==l.firstChild.nodeName||"\xa0"==l.firstChild.nodeValue))&&l.previousSibling&&"TABLE"==l.previousSibling.nodeName&&p.dom.remove(l)})}function e(){function n(M,O,J,u){var L=3,I=M.dom.getParent(O.startContainer,"TABLE"),N,P,K;return I&&(N=I.parentNode),P=O.startContainer.nodeType==L&&0===O.startOffset&&0===O.endOffset&&u&&("TR"==J.nodeName||J==N),K=("TD"==J.nodeName||"TH"==J.nodeName)&&!u,P||K}function l(){var u=p.selection.getRng(),I=p.selection.getNode(),s=p.dom.getParent(u.startContainer,"TD,TH");if(n(p,u,I,s)){s||(s=I);for(var J=s.lastChild;J.lastChild;){J=J.lastChild}u.setEnd(J,J.nodeValue.length),p.selection.setRng(u)}}p.on("KeyDown",function(){l()}),p.on("MouseDown",function(o){2!=o.button&&l()})}c.webkit&&(m(),e()),c.gecko&&(h(),i())}}),b(j,[w,v,D],function(c,a,d){return function(m){function g(){m.getBody().style.webkitUserSelect="",p&&(m.dom.removeClass(m.dom.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),p=!1)}var n=m.dom,f,h,e,p=!0;return m.on("MouseDown",function(i){2!=i.button&&(g(),h=n.getParent(i.target,"td,th"),e=n.getParent(h,"table"))}),n.bind(m.getDoc(),"mouseover",function(r){var I,o,s=r.target;if(h&&(f||s!=h)&&("TD"==s.nodeName||"TH"==s.nodeName)){o=n.getParent(s,"table"),o==e&&(f||(f=new c(m,o),f.setStartCell(h),m.getBody().style.webkitUserSelect="none"),f.setEndCell(s),p=!0),I=m.selection.getSel();try{I.removeAllRanges?I.removeAllRanges():I.empty()}catch(l){}r.preventDefault()}}),m.on("MouseUp",function(){function I(u,i){var L=new a(u,u);do{if(3==u.nodeType&&0!==d.trim(u.nodeValue).length){return i?r.setStart(u,0):r.setEnd(u,u.nodeValue.length),void 0}if("BR"==u.nodeName){return i?r.setStartBefore(u):r.setEndBefore(u),void 0}}while(u=i?L.next():L.prev())}var r,K=m.selection,J,o,s,t,l;if(h){if(f&&(m.getBody().style.webkitUserSelect=""),J=n.select("td.mce-item-selected,th.mce-item-selected"),J.length>0){r=n.createRng(),s=J[0],l=J[J.length-1],r.setStartBefore(s),r.setEndAfter(s),I(s,1),o=new a(s,n.getParent(J[0],"table"));do{if("TD"==s.nodeName||"TH"==s.nodeName){if(!n.hasClass(s,"mce-item-selected")){break}t=s}}while(s=o.next());I(t),K.setRng(r)}m.nodeChanged(),h=f=e=null}}),m.on("KeyUp",function(){g()}),{clear:g}}}),b(y,[w,F,j,D,v,C,z],function(m,u,f,c,h,d,p){function I(L){function O(a){return a?a.replace(/px$/,""):""}function V(a){return/^[0-9]+$/.test(a)&&(a+="px"),a}function J(a){g("left center right".split(" "),function(i){L.formatter.remove("align"+i,{},a)})}function T(){var i=L.dom,a,s,r;a=L.dom.getParent(L.selection.getStart(),"table"),r=!1,s={width:O(i.getStyle(a,"width")||i.getAttrib(a,"width")),height:O(i.getStyle(a,"height")||i.getAttrib(a,"height")),cellspacing:i.getAttrib(a,"cellspacing"),cellpadding:i.getAttrib(a,"cellpadding"),border:i.getAttrib(a,"border"),caption:!!i.select("caption",a)[0]},g("left center right".split(" "),function(W){L.formatter.matchNode(a,"align"+W)&&(s.align=W)}),L.windowManager.open({title:"Table properties",items:{type:"form",layout:"grid",columns:2,data:s,defaults:{type:"textbox",maxWidth:50},items:[r?{label:"Cols",name:"cols",disabled:!0}:null,r?{label:"Rows",name:"rows",disabled:!0}:null,{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell spacing",name:"cellspacing"},{label:"Cell padding",name:"cellpadding"},{label:"Border",name:"border"},{label:"Caption",name:"caption",type:"checkbox"},{label:"Alignment",minWidth:90,name:"align",type:"listbox",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]},onsubmit:function(){var X=this.toJSON(),W;L.undoManager.transact(function(){L.dom.setAttribs(a,{cellspacing:X.cellspacing,cellpadding:X.cellpadding,border:X.border}),L.dom.setStyles(a,{width:V(X.width),height:V(X.height)}),W=i.select("caption",a)[0],W&&!X.caption&&i.remove(W),!W&&X.caption&&(W=i.create("caption"),d.ie||(W.innerHTML='<br data-mce-bogus="1"/>'),a.insertBefore(W,a.firstChild)),J(a),X.align&&L.formatter.apply("align"+X.align,{},a),L.focus(),L.addVisual()})}})}function S(i,a){L.windowManager.open({title:"Merge cells",body:[{label:"Cols",name:"cols",type:"textbox",size:10},{label:"Rows",name:"rows",type:"textbox",size:10}],onsubmit:function(){var r=this.toJSON();L.undoManager.transact(function(){i.merge(a,r.cols,r.rows)})}})}function t(){var i=L.dom,a,s,r=[];r=L.dom.select("td.mce-item-selected,th.mce-item-selected"),a=L.dom.getParent(L.selection.getStart(),"td,th"),!r.length&&a&&r.push(a),a=a||r[0],s={width:O(i.getStyle(a,"width")||i.getAttrib(a,"width")),height:O(i.getStyle(a,"height")||i.getAttrib(a,"height")),scope:i.getAttrib(a,"scope")},s.type=a.nodeName.toLowerCase(),g("left center right".split(" "),function(W){L.formatter.matchNode(a,"align"+W)&&(s.align=W)}),L.windowManager.open({title:"Cell properties",items:{type:"form",data:s,layout:"grid",columns:2,defaults:{type:"textbox",maxWidth:50},items:[{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell type",name:"type",type:"listbox",text:"None",minWidth:90,maxWidth:null,menu:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{label:"Scope",name:"scope",type:"listbox",text:"None",minWidth:90,maxWidth:null,menu:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{label:"Alignment",name:"align",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]},onsubmit:function(){var W=this.toJSON();L.undoManager.transact(function(){g(r,function(X){L.dom.setAttrib(X,"scope",W.scope),L.dom.setStyles(X,{width:V(W.width),height:V(W.height)}),W.type&&X.nodeName.toLowerCase()!=W.type&&(X=i.rename(X,W.type)),J(X),W.align&&L.formatter.apply("align"+W.align,{},X)}),L.focus()})}})}function R(){var i=L.dom,a,X,s,W,r=[];a=L.dom.getParent(L.selection.getStart(),"table"),X=L.dom.getParent(L.selection.getStart(),"td,th"),g(a.rows,function(Y){g(Y.cells,function(Z){return i.hasClass(Z,"mce-item-selected")||Z==X?(r.push(Y),!1):void 0})}),s=r[0],W={height:O(i.getStyle(s,"height")||i.getAttrib(s,"height")),scope:i.getAttrib(s,"scope")},W.type=s.parentNode.nodeName.toLowerCase(),g("left center right".split(" "),function(Y){L.formatter.matchNode(s,"align"+Y)&&(W.align=Y)}),L.windowManager.open({title:"Row properties",items:{type:"form",data:W,columns:2,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"None",maxWidth:null,menu:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"listbox",name:"align",label:"Alignment",text:"None",maxWidth:null,menu:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height"}]},onsubmit:function(){var Z=this.toJSON(),ab,Y,aa;L.undoManager.transact(function(){var ac=Z.type;g(r,function(ad){L.dom.setAttrib(ad,"scope",Z.scope),L.dom.setStyles(ad,{height:V(Z.height)}),ac!=ad.parentNode.nodeName.toLowerCase()&&(ab=i.getParent(ad,"table"),Y=ad.parentNode,aa=i.select(ac,ab)[0],aa||(aa=i.create(ac),ab.firstChild?ab.insertBefore(aa,ab.firstChild):ab.appendChild(aa)),aa.appendChild(ad),Y.hasChildNodes()||i.remove(Y)),J(ad),Z.align&&L.formatter.apply("align"+Z.align,{},ad)}),L.focus()})}})}function M(a){return function(){L.execCommand(a)}}function N(X,W){var Y,s,r;for(r="<table><tbody>",Y=0;W>Y;Y++){for(r+="<tr>",s=0;X>s;s++){r+="<td>"+(d.ie?" ":"<br>")+"</td>"}r+="</tr>"}r+="</tbody></table>",L.insertContent(r)}function P(i,a){function r(){i.disabled(!L.dom.getParent(L.selection.getStart(),a)),L.selection.selectorChanged(a,function(s){i.disabled(!s)})}L.initialized?r():L.on("init",r)}function Q(){P(this,"table")}function o(){P(this,"td,th")}function e(){var i="";i='<table role="presentation" class="mce-grid mce-grid-border">';for(var a=0;10>a;a++){i+="<tr>";for(var r=0;10>r;r++){i+='<td><a href="#" data-mce-index="'+r+","+a+'"></a></td>'}i+="</tr>"}return i+="</table>",i+='<div class="mce-text-center">0 x 0</div>'}var U,K,l=this;L.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",onhide:function(){L.dom.removeClass(this.menu.items()[0].getEl().getElementsByTagName("a"),"mce-active")},menu:[{type:"container",html:e(),onmousemove:function(X){var W=X.target;if("A"==W.nodeName){var Z=L.dom.getParent(W,"table"),s=W.getAttribute("data-mce-index");if(s!=this.lastPos){s=s.split(","),s[0]=parseInt(s[0],10),s[1]=parseInt(s[1],10);for(var Y=0;10>Y;Y++){for(var r=0;10>r;r++){L.dom.toggleClass(Z.rows[Y].childNodes[r].firstChild,"mce-active",r<=s[0]&&Y<=s[1])}}Z.nextSibling.innerHTML=s[0]+1+" x "+(s[1]+1),this.lastPos=s}}},onclick:function(a){"A"==a.target.nodeName&&this.lastPos&&(a.preventDefault(),N(this.lastPos[0]+1,this.lastPos[1]+1),this.parent().cancel())}}]}),L.addMenuItem("tableprops",{text:"Table properties",context:"table",onPostRender:Q,onclick:T}),L.addMenuItem("deletetable",{text:"Delete table",context:"table",onPostRender:Q,cmd:"mceTableDelete"}),L.addMenuItem("cell",{separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:M("mceTableCellProps"),onPostRender:o},{text:"Merge cells",onclick:M("mceTableMergeCells"),onPostRender:o},{text:"Split cell",onclick:M("mceTableSplitCells"),onPostRender:o}]}),L.addMenuItem("row",{text:"Row",context:"table",menu:[{text:"Insert row before",onclick:M("mceTableInsertRowBefore"),onPostRender:o},{text:"Insert row after",onclick:M("mceTableInsertRowAfter"),onPostRender:o},{text:"Delete row",onclick:M("mceTableDeleteRow"),onPostRender:o},{text:"Row properties",onclick:M("mceTableRowProps"),onPostRender:o},{text:"-"},{text:"Cut row",onclick:M("mceTableCutRow"),onPostRender:o},{text:"Copy row",onclick:M("mceTableCopyRow"),onPostRender:o},{text:"Paste row before",onclick:M("mceTablePasteRowBefore"),onPostRender:o},{text:"Paste row after",onclick:M("mceTablePasteRowAfter"),onPostRender:o}]}),L.addMenuItem("column",{text:"Column",context:"table",menu:[{text:"Insert column before",onclick:M("mceTableInsertColBefore"),onPostRender:o},{text:"Insert column after",onclick:M("mceTableInsertColAfter"),onPostRender:o},{text:"Delete column",onclick:M("mceTableDeleteCol"),onPostRender:o}]});var n=[];g("inserttable tableprops deletetable | cell row column".split(" "),function(a){"|"==a?n.push({text:"-"}):n.push(L.menuItems[a])}),L.addButton("table",{type:"menubutton",title:"Table",menu:n}),d.isIE||L.on("click",function(a){a=a.target,"TABLE"===a.nodeName&&(L.selection.select(a),L.nodeChanged())}),l.quirks=new u(L),L.on("Init",function(){U=L.windowManager,l.cellSelection=new f(L)}),g({mceTableSplitCells:function(a){a.split()},mceTableMergeCells:function(s){var r,W,a;a=L.dom.getParent(L.selection.getStart(),"th,td"),a&&(r=a.rowSpan,W=a.colSpan),L.dom.select("td.mce-item-selected,th.mce-item-selected").length?s.merge():S(s,a)},mceTableInsertRowBefore:function(a){a.insertRow(!0)},mceTableInsertRowAfter:function(a){a.insertRow()},mceTableInsertColBefore:function(a){a.insertCol(!0)},mceTableInsertColAfter:function(a){a.insertCol()},mceTableDeleteCol:function(a){a.deleteCols()},mceTableDeleteRow:function(a){a.deleteRows()},mceTableCutRow:function(a){K=a.cutRows()},mceTableCopyRow:function(a){K=a.copyRows()},mceTablePasteRowBefore:function(a){a.pasteRows(K,!0)},mceTablePasteRowAfter:function(a){a.pasteRows(K)},mceTableDelete:function(a){a.deleteTable()}},function(a,i){L.addCommand(i,function(){var r=new m(L);r&&(a(r),L.execCommand("mceRepaint"),l.cellSelection.clear())})}),g({mceInsertTable:function(){T()},mceTableRowProps:R,mceTableCellProps:t},function(i,a){L.addCommand(a,function(r,s){i(s)})})}var g=c.each;p.add("table",I)}),E([w,F,j,y])}(this); |