summaryrefslogtreecommitdiff
path: root/program/js/tinymce/plugins/table/plugin.min.js
blob: 4ee5ccaf749224d480d3e03a3d6df3927b532486 (plain)
1
!function(e,t){"use strict";function n(e,t){for(var n,o=[],a=0;a<e.length;++a){if(n=i[e[a]]||l(e[a]),!n)throw"module definition dependecy not found: "+e[a];o.push(n)}t.apply(null,o)}function o(e,o,a){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(o===t)throw"invalid module definition, dependencies must be specified";if(a===t)throw"invalid module definition, definition function must be specified";n(o,function(){i[e]=a.apply(null,arguments)})}function a(e){return!!i[e]}function l(t){for(var n=e,o=t.split(/[.\/]/),a=0;a<o.length;++a){if(!n[o[a]])return;n=n[o[a]]}return n}function r(n){for(var o=0;o<n.length;o++){for(var a=e,l=n[o],r=l.split(/[.\/]/),s=0;s<r.length-1;++s)a[r[s]]===t&&(a[r[s]]={}),a=a[r[s]];a[r[r.length-1]]=i[l]}}var i={},s="tinymce/tableplugin/TableGrid",c="tinymce/util/Tools",d="tinymce/Env",u="tinymce/tableplugin/Quirks",m="tinymce/util/VK",f="tinymce/tableplugin/CellSelection",g="tinymce/dom/TreeWalker",p="tinymce/tableplugin/Plugin",h="tinymce/PluginManager";o(s,[c,d],function(e,n){function o(e,t){return parseInt(e.getAttribute(t)||1,10)}var a=e.each;return function(l,r){function i(){var e=0;M=[],_=0,a(["thead","tbody","tfoot"],function(t){var n=H.select("> "+t+" tr",r);a(n,function(n,l){l+=e,a(H.select("> td, > th",n),function(e,n){var a,r,i,s;if(M[l])for(;M[l][n];)n++;for(i=o(e,"rowspan"),s=o(e,"colspan"),r=l;l+i>r;r++)for(M[r]||(M[r]=[]),a=n;n+s>a;a++)M[r][a]={part:t,real:r==l&&a==n,elm:e,rowspan:i,colspan:s};_=Math.max(_,n+1)})}),e+=n.length})}function s(e,t){return e=e.cloneNode(t),e.removeAttribute("id"),e}function c(e,t){var n;return n=M[t],n?n[e]:void 0}function d(e,t,n){e&&(n=parseInt(n,10),1===n?e.removeAttribute(t,1):e.setAttribute(t,n,1))}function u(e){return e&&(H.hasClass(e.elm,"mce-item-selected")||e==E)}function m(){var e=[];return a(r.rows,function(t){a(t.cells,function(n){return H.hasClass(n,"mce-item-selected")||E&&n==E.elm?(e.push(t),!1):void 0})}),e}function f(){var e=H.createRng();e.setStartAfter(r),e.setEndAfter(r),L.setRng(e),H.remove(r)}function g(t){var o,r={};return l.settings.table_clone_elements!==!1&&(r=e.makeMap((l.settings.table_clone_elements||"strong em b i span font h1 h2 h3 h4 h5 h6 p div").toUpperCase(),/[ ,]/)),e.walk(t,function(e){var l;return 3==e.nodeType?(a(H.getParents(e.parentNode,null,t).reverse(),function(e){r[e.nodeName]&&(e=s(e,!1),o?l&&l.appendChild(e):o=l=e,l=e)}),l&&(l.innerHTML=n.ie?"&nbsp;":'<br data-mce-bogus="1" />'),!1):void 0},"childNodes"),t=s(t,!1),d(t,"rowSpan",1),d(t,"colSpan",1),o?t.appendChild(o):(!n.ie||n.ie>10)&&(t.innerHTML='<br data-mce-bogus="1" />'),t}function p(){var e=H.createRng(),t;return a(H.select("tr",r),function(e){0===e.cells.length&&H.remove(e)}),0===H.select("tr",r).length?(e.setStartBefore(r),e.setEndBefore(r),L.setRng(e),void H.remove(r)):(a(H.select("thead,tbody,tfoot",r),function(e){0===e.rows.length&&H.remove(e)}),i(),void(D&&(t=M[Math.min(M.length-1,D.y)],t&&(L.select(t[Math.min(t.length-1,D.x)].elm,!0),L.collapse(!0)))))}function h(e,t,n,o){var a,l,r,i,s;for(a=M[t][e].elm.parentNode,r=1;n>=r;r++)if(a=H.getNext(a,"tr")){for(l=e;l>=0;l--)if(s=M[t+r][l].elm,s.parentNode==a){for(i=1;o>=i;i++)H.insertAfter(g(s),s);break}if(-1==l)for(i=1;o>=i;i++)a.insertBefore(g(a.cells[0]),a.cells[0])}}function b(){a(M,function(e,t){a(e,function(e,n){var a,l,r;if(u(e)&&(e=e.elm,a=o(e,"colspan"),l=o(e,"rowspan"),a>1||l>1)){for(d(e,"rowSpan",1),d(e,"colSpan",1),r=0;a-1>r;r++)H.insertAfter(g(e),e);h(n,t,l-1,a)}})})}function v(t,n,o){var l,r,s,m,f,g,h,v,x,y,w;if(t?(l=T(t),r=l.x,s=l.y,m=r+(n-1),f=s+(o-1)):(D=I=null,a(M,function(e,t){a(e,function(e,n){u(e)&&(D||(D={x:n,y:t}),I={x:n,y:t})})}),D&&(r=D.x,s=D.y,m=I.x,f=I.y)),v=c(r,s),x=c(m,f),v&&x&&v.part==x.part){for(b(),i(),v=c(r,s).elm,d(v,"colSpan",m-r+1),d(v,"rowSpan",f-s+1),h=s;f>=h;h++)for(g=r;m>=g;g++)M[h]&&M[h][g]&&(t=M[h][g].elm,t!=v&&(y=e.grep(t.childNodes),a(y,function(e){v.appendChild(e)}),y.length&&(y=e.grep(v.childNodes),w=0,a(y,function(e){"BR"==e.nodeName&&H.getAttrib(e,"data-mce-bogus")&&w++<y.length-1&&v.removeChild(e)})),H.remove(t)));p()}}function x(e){var n,l,r,i,c,m,f,p,h;if(a(M,function(t,o){return a(t,function(t){return u(t)&&(t=t.elm,c=t.parentNode,m=s(c,!1),n=o,e)?!1:void 0}),e?!n:void 0}),n!==t){for(i=0;i<M[0].length;i++)if(M[n][i]&&(l=M[n][i].elm,l!=r)){if(e){if(n>0&&M[n-1][i]&&(p=M[n-1][i].elm,h=o(p,"rowSpan"),h>1)){d(p,"rowSpan",h+1);continue}}else if(h=o(l,"rowspan"),h>1){d(l,"rowSpan",h+1);continue}f=g(l),d(f,"colSpan",l.colSpan),m.appendChild(f),r=l}m.hasChildNodes()&&(e?c.parentNode.insertBefore(m,c):H.insertAfter(m,c))}}function y(e){var t,n;a(M,function(n){return a(n,function(n,o){return u(n)&&(t=o,e)?!1:void 0}),e?!t:void 0}),a(M,function(a,l){var r,i,s;a[t]&&(r=a[t].elm,r!=n&&(s=o(r,"colspan"),i=o(r,"rowspan"),1==s?e?(r.parentNode.insertBefore(g(r),r),h(t,l,i-1,s)):(H.insertAfter(g(r),r),h(t,l,i-1,s)):d(r,"colSpan",r.colSpan+1),n=r))})}function w(){var t=[];a(M,function(n){a(n,function(n,l){u(n)&&-1===e.inArray(t,l)&&(a(M,function(e){var t=e[l].elm,n;n=o(t,"colSpan"),n>1?d(t,"colSpan",n-1):H.remove(t)}),t.push(l))})}),p()}function C(){function e(e){var t,n;a(e.cells,function(e){var n=o(e,"rowSpan");n>1&&(d(e,"rowSpan",n-1),t=T(e),h(t.x,t.y,1,1))}),t=T(e.cells[0]),a(M[t.y],function(e){var t;e=e.elm,e!=n&&(t=o(e,"rowSpan"),1>=t?H.remove(e):d(e,"rowSpan",t-1),n=e)})}var t;t=m(),a(t.reverse(),function(t){e(t)}),p()}function R(){var e=m();return H.remove(e),p(),e}function N(){var e=m();return a(e,function(t,n){e[n]=s(t,!0)}),e}function S(e,t){var n=m(),o=n[t?0:n.length-1],l=o.cells.length;e&&(a(M,function(e){var t;return l=0,a(e,function(e){e.real&&(l+=e.colspan),e.elm.parentNode==o&&(t=1)}),t?!1:void 0}),t||e.reverse(),a(e,function(e){var n,a=e.cells.length,r;for(n=0;a>n;n++)r=e.cells[n],d(r,"colSpan",1),d(r,"rowSpan",1);for(n=a;l>n;n++)e.appendChild(g(e.cells[a-1]));for(n=l;a>n;n++)H.remove(e.cells[n]);t?o.parentNode.insertBefore(e,o):H.insertAfter(e,o)}),H.removeClass(H.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"))}function T(e){var t;return a(M,function(n,o){return a(n,function(n,a){return n.elm==e?(t={x:a,y:o},!1):void 0}),!t}),t}function P(e){D=T(e)}function A(){var e,t;return e=t=0,a(M,function(n,o){a(n,function(n,a){var l,r;u(n)&&(n=M[o][a],a>e&&(e=a),o>t&&(t=o),n.real&&(l=n.colspan-1,r=n.rowspan-1,l&&a+l>e&&(e=a+l),r&&o+r>t&&(t=o+r)))})}),{x:e,y:t}}function k(e){var t,n,o,a,l,r,i,s,c,d;if(I=T(e),D&&I){for(t=Math.min(D.x,I.x),n=Math.min(D.y,I.y),o=Math.max(D.x,I.x),a=Math.max(D.y,I.y),l=o,r=a,d=n;r>=d;d++)e=M[d][t],e.real||t-(e.colspan-1)<t&&(t-=e.colspan-1);for(c=t;l>=c;c++)e=M[n][c],e.real||n-(e.rowspan-1)<n&&(n-=e.rowspan-1);for(d=n;a>=d;d++)for(c=t;o>=c;c++)e=M[d][c],e.real&&(i=e.colspan-1,s=e.rowspan-1,i&&c+i>l&&(l=c+i),s&&d+s>r&&(r=d+s));for(H.removeClass(H.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),d=n;r>=d;d++)for(c=t;l>=c;c++)M[d][c]&&H.addClass(M[d][c].elm,"mce-item-selected")}}function B(e,t){var n,o,a;n=T(e),o=n.y*_+n.x;do{if(o+=t,a=c(o%_,Math.floor(o/_)),!a)break;if(a.elm!=e)return L.select(a.elm,!0),H.isEmpty(a.elm)&&L.collapse(!0),!0}while(a.elm==e);return!1}var M,_,D,I,E,L=l.selection,H=L.dom;r=r||H.getParent(L.getStart(),"table"),i(),E=H.getParent(L.getStart(),"th,td"),E&&(D=T(E),I=A(),E=c(D.x,D.y)),e.extend(this,{deleteTable:f,split:b,merge:v,insertRow:x,insertCol:y,deleteCols:w,deleteRows:C,cutRows:R,copyRows:N,pasteRows:S,getPos:T,setStartCell:P,setEndCell:k,moveRelIdx:B,refresh:i})}}),o(u,[m,d,c],function(e,t,n){function o(e,t){return parseInt(e.getAttribute(t)||1,10)}var a=n.each;return function(n){function l(){function t(t){function l(e,o){var a=e?"previousSibling":"nextSibling",l=n.dom.getParent(o,"tr"),i=l[a];if(i)return h(n,o,i,e),t.preventDefault(),!0;var d=n.dom.getParent(l,"table"),u=l.parentNode,m=u.nodeName.toLowerCase();if("tbody"===m||m===(e?"tfoot":"thead")){var f=r(e,d,u,"tbody");if(null!==f)return s(e,f,o)}return c(e,l,a,d)}function r(e,t,o,a){var l=n.dom.select(">"+a,t),r=l.indexOf(o);if(e&&0===r||!e&&r===l.length-1)return i(e,t);if(-1===r){var s="thead"===o.tagName.toLowerCase()?0:l.length-1;return l[s]}return l[r+(e?-1:1)]}function i(e,t){var o=e?"thead":"tfoot",a=n.dom.select(">"+o,t);return 0!==a.length?a[0]:null}function s(e,o,a){var l=d(o,e);return l&&h(n,a,l,e),t.preventDefault(),!0}function c(e,o,a,r){var i=r[a];if(i)return u(i),!0;var s=n.dom.getParent(r,"td,th");if(s)return l(e,s,t);var c=d(o,!e);return u(c),t.preventDefault(),!1}function d(e,t){var o=e&&e[t?"lastChild":"firstChild"];return o&&"BR"===o.nodeName?n.dom.getParent(o,"td,th"):o}function u(e){n.selection.setCursorLocation(e,0)}function m(){return x==e.UP||x==e.DOWN}function f(e){var t=e.selection.getNode(),n=e.dom.getParent(t,"tr");return null!==n}function g(e){for(var t=0,n=e;n.previousSibling;)n=n.previousSibling,t+=o(n,"colspan");return t}function p(e,t){var n=0,l=0;return a(e.children,function(e,a){return n+=o(e,"colspan"),l=a,n>t?!1:void 0}),l}function h(e,t,o,a){var l=g(n.dom.getParent(t,"td,th")),r=p(o,l),i=o.childNodes[r],s=d(i,a);u(s||i)}function b(e){var t=n.selection.getNode(),o=n.dom.getParent(t,"td,th"),a=n.dom.getParent(e,"td,th");return o&&o!==a&&v(o,a)}function v(e,t){return n.dom.getParent(e,"TABLE")===n.dom.getParent(t,"TABLE")}var x=t.keyCode;if(m()&&f(n)){var y=n.selection.getNode();setTimeout(function(){b(y)&&l(!t.shiftKey&&x===e.UP,y,t)},0)}}n.on("KeyDown",function(e){t(e)})}function r(){function e(e,t){var n=t.ownerDocument,o=n.createRange(),a;return o.setStartBefore(t),o.setEnd(e.endContainer,e.endOffset),a=n.createElement("body"),a.appendChild(o.cloneContents()),0===a.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length}n.on("KeyDown",function(t){var o,a,l=n.dom;(37==t.keyCode||38==t.keyCode)&&(o=n.selection.getRng(),a=l.getParent(o.startContainer,"table"),a&&n.getBody().firstChild==a&&e(o,a)&&(o=l.createRng(),o.setStartBefore(a),o.setEndBefore(a),n.selection.setRng(o),t.preventDefault()))})}function i(){n.on("KeyDown SetContent VisualAid",function(){var e;for(e=n.getBody().lastChild;e;e=e.previousSibling)if(3==e.nodeType){if(e.nodeValue.length>0)break}else if(1==e.nodeType&&("BR"==e.tagName||!e.getAttribute("data-mce-bogus")))break;e&&"TABLE"==e.nodeName&&(n.settings.forced_root_block?n.dom.add(n.getBody(),n.settings.forced_root_block,n.settings.forced_root_block_attrs,t.ie&&t.ie<11?"&nbsp;":'<br data-mce-bogus="1" />'):n.dom.add(n.getBody(),"br",{"data-mce-bogus":"1"}))}),n.on("PreProcess",function(e){var t=e.node.lastChild;t&&("BR"==t.nodeName||1==t.childNodes.length&&("BR"==t.firstChild.nodeName||"\xa0"==t.firstChild.nodeValue))&&t.previousSibling&&"TABLE"==t.previousSibling.nodeName&&n.dom.remove(t)})}function s(){function e(e,t,n,o){var a=3,l=e.dom.getParent(t.startContainer,"TABLE"),r,i,s;return l&&(r=l.parentNode),i=t.startContainer.nodeType==a&&0===t.startOffset&&0===t.endOffset&&o&&("TR"==n.nodeName||n==r),s=("TD"==n.nodeName||"TH"==n.nodeName)&&!o,i||s}function t(){var t=n.selection.getRng(),o=n.selection.getNode(),a=n.dom.getParent(t.startContainer,"TD,TH");if(e(n,t,o,a)){a||(a=o);for(var l=a.lastChild;l.lastChild;)l=l.lastChild;3==l.nodeType&&(t.setEnd(l,l.data.length),n.selection.setRng(t))}}n.on("KeyDown",function(){t()}),n.on("MouseDown",function(e){2!=e.button&&t()})}function c(){n.on("keydown",function(t){if((t.keyCode==e.DELETE||t.keyCode==e.BACKSPACE)&&!t.isDefaultPrevented()){var o=n.dom.getParent(n.selection.getStart(),"table");if(o){for(var a=n.dom.select("td,th",o),l=a.length;l--;)if(!n.dom.hasClass(a[l],"mce-item-selected"))return;t.preventDefault(),n.execCommand("mceTableDelete")}}})}c(),t.webkit&&(l(),s()),t.gecko&&(r(),i()),t.ie>10&&(r(),i())}}),o(f,[s,g,c],function(e,t,n){return function(o){function a(){o.getBody().style.webkitUserSelect="",d&&(o.dom.removeClass(o.dom.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),d=!1)}function l(t){var n,a,l=t.target;if(s&&(i||l!=s)&&("TD"==l.nodeName||"TH"==l.nodeName)){a=r.getParent(l,"table"),a==c&&(i||(i=new e(o,a),i.setStartCell(s),o.getBody().style.webkitUserSelect="none"),i.setEndCell(l),d=!0),n=o.selection.getSel();try{n.removeAllRanges?n.removeAllRanges():n.empty()}catch(u){}t.preventDefault()}}var r=o.dom,i,s,c,d=!0;return o.on("MouseDown",function(e){2!=e.button&&(a(),s=r.getParent(e.target,"td,th"),c=r.getParent(s,"table"))}),o.on("mouseover",l),o.on("remove",function(){r.unbind(o.getDoc(),"mouseover",l)}),o.on("MouseUp",function(){function e(e,o){var l=new t(e,e);do{if(3==e.nodeType&&0!==n.trim(e.nodeValue).length)return void(o?a.setStart(e,0):a.setEnd(e,e.nodeValue.length));if("BR"==e.nodeName)return void(o?a.setStartBefore(e):a.setEndBefore(e))}while(e=o?l.next():l.prev())}var a,l=o.selection,d,u,m,f;if(s){if(i&&(o.getBody().style.webkitUserSelect=""),d=r.select("td.mce-item-selected,th.mce-item-selected"),d.length>0){a=r.createRng(),m=d[0],a.setStartBefore(m),a.setEndAfter(m),e(m,1),u=new t(m,r.getParent(d[0],"table"));do if("TD"==m.nodeName||"TH"==m.nodeName){if(!r.hasClass(m,"mce-item-selected"))break;f=m}while(m=u.next());e(f),l.setRng(a)}o.nodeChanged(),s=i=c=null}}),o.on("KeyUp Drop",function(){a(),s=i=c=null}),{clear:a}}}),o(p,[s,u,f,c,g,d,h],function(e,t,n,o,a,l,r){function i(a){function r(e){return e?e.replace(/px$/,""):""}function i(e){return/^[0-9]+$/.test(e)&&(e+="px"),e}function c(e){s("left center right".split(" "),function(t){a.formatter.remove("align"+t,{},e)})}function d(e){s("top middle bottom".split(" "),function(t){a.formatter.remove("valign"+t,{},e)})}function u(e,t){return o.each(t,function(t){t.textStyle=function(){return a.formatter.getCssText({block:e,classes:[t.value]})}}),t}function m(e,t,n,l){var r,i=[];return o.each(a.settings[t]||l,function(t){var o={text:t.text||t.title,value:t.value};i.push(o),(e[n]===t.value||!r&&t.selected)&&(r=o)}),r&&(e[n]=r.value,r.selected=!0),i}function f(){var e=a.dom,t,n,d,f,g;t=e.getParent(a.selection.getStart(),"table"),g={width:r(e.getStyle(t,"width")||e.getAttrib(t,"width")),height:r(e.getStyle(t,"height")||e.getAttrib(t,"height")),cellspacing:t?e.getAttrib(t,"cellspacing"):"",cellpadding:t?e.getAttrib(t,"cellpadding"):"",border:t?e.getAttrib(t,"border"):"",caption:!!e.select("caption",t)[0],"class":e.getAttrib(t,"class")},s("left center right".split(" "),function(e){a.formatter.matchNode(t,"align"+e)&&(g.align=e)}),t||(n={label:"Cols",name:"cols"},d={label:"Rows",name:"rows"}),a.settings.table_class_list&&(g["class"]&&(g["class"]=g["class"].replace(/\s*mce\-item\-table\s*/g,"")),f={name:"class",type:"listbox",label:"Class",values:u("table",m(g,"table_class_list","class"))}),a.windowManager.open({title:"Table properties",items:{type:"form",layout:"flex",direction:"column",labelGapCalc:"children",items:[{type:"form",labelGapCalc:!1,padding:0,layout:"grid",columns:2,data:g,defaults:{type:"textbox",maxWidth:50},items:[n,d,{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",name:"align",type:"listbox",text:"None",values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},f]},onsubmit:function(){var n;g=o.extend(g,this.toJSON()),a.undoManager.transact(function(){t||(t=v(g.cols||1,g.rows||1)),a.dom.setAttribs(t,{cellspacing:g.cellspacing,cellpadding:g.cellpadding,border:g.border,"class":g["class"]}),a.dom.setStyles(t,{width:i(g.width),height:i(g.height)}),n=e.select("caption",t)[0],n&&!g.caption&&e.remove(n),!n&&g.caption&&(n=e.create("caption"),n.innerHTML=l.ie?"\xa0":'<br data-mce-bogus="1"/>',t.insertBefore(n,t.firstChild)),c(t),g.align&&a.formatter.apply("align"+g.align,{},t),a.focus(),a.addVisual()})}})}function g(e,t){a.windowManager.open({title:"Merge cells",body:[{label:"Cols",name:"cols",type:"textbox",value:"1",size:10},{label:"Rows",name:"rows",type:"textbox",value:"1",size:10}],onsubmit:function(){var n=this.toJSON();a.undoManager.transact(function(){e.merge(t,n.cols,n.rows)})}})}function p(){var e=a.dom,t,n,l,f=[];f=a.dom.select("td.mce-item-selected,th.mce-item-selected"),t=a.dom.getParent(a.selection.getStart(),"td,th"),!f.length&&t&&f.push(t),t=t||f[0],t&&(n={width:r(e.getStyle(t,"width")||e.getAttrib(t,"width")),height:r(e.getStyle(t,"height")||e.getAttrib(t,"height")),scope:e.getAttrib(t,"scope"),"class":e.getAttrib(t,"class")},n.type=t.nodeName.toLowerCase(),s("left center right".split(" "),function(e){a.formatter.matchNode(t,"align"+e)&&(n.align=e)}),s("top middle bottom".split(" "),function(e){a.formatter.matchNode(t,"valign"+e)&&(n.valign=e)}),a.settings.table_cell_class_list&&(l={name:"class",type:"listbox",label:"Class",values:u("td",m(n,"table_cell_class_list","class"))}),a.windowManager.open({title:"Cell properties",items:{type:"form",layout:"flex",direction:"column",labelGapCalc:"children",items:[{type:"form",data:n,layout:"grid",columns:2,labelGapCalc:!1,padding:0,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,values:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{label:"Scope",name:"scope",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{label:"H Align",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"}]},{label:"V Align",name:"valign",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}]}]},l]},onsubmit:function(){n=o.extend(n,this.toJSON()),a.undoManager.transact(function(){s(f,function(t){a.dom.setAttribs(t,{scope:n.scope,"class":n["class"]}),a.dom.setStyles(t,{width:i(n.width),height:i(n.height)}),n.type&&t.nodeName.toLowerCase()!=n.type&&(t=e.rename(t,n.type)),c(t),n.align&&a.formatter.apply("align"+n.align,{},t),d(t),n.valign&&a.formatter.apply("valign"+n.valign,{},t)}),a.focus()})}}))}function h(){var e=a.dom,t,n,l,d,f,g=[];t=a.dom.getParent(a.selection.getStart(),"table"),n=a.dom.getParent(a.selection.getStart(),"td,th"),s(t.rows,function(t){s(t.cells,function(o){return e.hasClass(o,"mce-item-selected")||o==n?(g.push(t),!1):void 0})}),l=g[0],l&&(f={height:r(e.getStyle(l,"height")||e.getAttrib(l,"height")),scope:e.getAttrib(l,"scope"),"class":e.getAttrib(l,"class")},f.type=l.parentNode.nodeName.toLowerCase(),s("left center right".split(" "),function(e){a.formatter.matchNode(l,"align"+e)&&(f.align=e)}),a.settings.table_row_class_list&&(d={name:"class",type:"listbox",label:"Class",values:u("tr",m(f,"table_row_class_list","class"))}),a.windowManager.open({title:"Row properties",items:{type:"form",data:f,columns:2,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"None",maxWidth:null,values:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"listbox",name:"align",label:"Alignment",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height"},d]},onsubmit:function(){var t,n,l;f=o.extend(f,this.toJSON()),a.undoManager.transact(function(){var o=f.type;s(g,function(r){a.dom.setAttribs(r,{scope:f.scope,"class":f["class"]}),a.dom.setStyles(r,{height:i(f.height)}),o!=r.parentNode.nodeName.toLowerCase()&&(t=e.getParent(r,"table"),n=r.parentNode,l=e.select(o,t)[0],l||(l=e.create(o),t.firstChild?t.insertBefore(l,t.firstChild):t.appendChild(l)),l.appendChild(r),n.hasChildNodes()||e.remove(n)),c(r),f.align&&a.formatter.apply("align"+f.align,{},r)}),a.focus()})}}))}function b(e){return function(){a.execCommand(e)}}function v(e,t){var n,o,r;for(r='<table id="__mce"><tbody>',n=0;t>n;n++){for(r+="<tr>",o=0;e>o;o++)r+="<td>"+(l.ie?" ":"<br>")+"</td>";r+="</tr>"}r+="</tbody></table>",a.insertContent(r);var i=a.dom.get("__mce");return a.dom.setAttrib(i,"id",null),a.dom.setAttribs(i,a.settings.table_default_attributes||{}),a.dom.setStyles(i,a.settings.table_default_styles||{}),i}function x(e,t){function n(){e.disabled(!a.dom.getParent(a.selection.getStart(),t)),a.selection.selectorChanged(t,function(t){e.disabled(!t)})}a.initialized?n():a.on("init",n)}function y(){x(this,"table")}function w(){x(this,"td,th")}function C(){var e="";e='<table role="grid" class="mce-grid mce-grid-border" aria-readonly="true">';for(var t=0;10>t;t++){e+="<tr>";for(var n=0;10>n;n++)e+='<td role="gridcell" tabindex="-1"><a id="mcegrid'+(10*t+n)+'" href="#" data-mce-x="'+n+'" data-mce-y="'+t+'"></a></td>';e+="</tr>"}return e+="</table>",e+='<div class="mce-text-center" role="presentation">1 x 1</div>'}function R(e,t,n){var o=n.getEl().getElementsByTagName("table")[0],l,r,i,s,c,d=n.isRtl()||"tl-tr"==n.parent().rel;for(o.nextSibling.innerHTML=e+1+" x "+(t+1),d&&(e=9-e),r=0;10>r;r++)for(l=0;10>l;l++)s=o.rows[r].childNodes[l].firstChild,c=(d?l>=e:e>=l)&&t>=r,a.dom.toggleClass(s,"mce-active",c),c&&(i=s);return i.parentNode}var N,S=this;a.settings.table_grid===!1?a.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",onclick:f}):a.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",ariaHideMenu:!0,onclick:function(e){e.aria&&(this.parent().hideAll(),e.stopImmediatePropagation(),f())},onshow:function(){R(0,0,this.menu.items()[0])},onhide:function(){var e=this.menu.items()[0].getEl().getElementsByTagName("a");a.dom.removeClass(e,"mce-active"),a.dom.addClass(e[0],"mce-active")},menu:[{type:"container",html:C(),onPostRender:function(){this.lastX=this.lastY=0},onmousemove:function(e){var t=e.target,n,o;"A"==t.tagName.toUpperCase()&&(n=parseInt(t.getAttribute("data-mce-x"),10),o=parseInt(t.getAttribute("data-mce-y"),10),(this.isRtl()||"tl-tr"==this.parent().rel)&&(n=9-n),(n!==this.lastX||o!==this.lastY)&&(R(n,o,e.control),this.lastX=n,this.lastY=o))},onkeydown:function(e){var t=this.lastX,n=this.lastY,o;switch(e.keyCode){case 37:t>0&&(t--,o=!0);break;case 39:o=!0,9>t&&t++;break;case 38:o=!0,n>0&&n--;break;case 40:o=!0,9>n&&n++}o&&(e.preventDefault(),e.stopPropagation(),R(t,n,e.control).focus(),this.lastX=t,this.lastY=n)},onclick:function(e){var t=this;"A"==e.target.tagName.toUpperCase()&&(e.preventDefault(),e.stopPropagation(),t.parent().cancel(),a.undoManager.transact(function(){v(t.lastX+1,t.lastY+1)}),a.addVisual())}}]}),a.addMenuItem("tableprops",{text:"Table properties",context:"table",onPostRender:y,onclick:f}),a.addMenuItem("deletetable",{text:"Delete table",context:"table",onPostRender:y,cmd:"mceTableDelete"}),a.addMenuItem("cell",{separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:b("mceTableCellProps"),onPostRender:w},{text:"Merge cells",onclick:b("mceTableMergeCells"),onPostRender:w},{text:"Split cell",onclick:b("mceTableSplitCells"),onPostRender:w}]}),a.addMenuItem("row",{text:"Row",context:"table",menu:[{text:"Insert row before",onclick:b("mceTableInsertRowBefore"),onPostRender:w},{text:"Insert row after",onclick:b("mceTableInsertRowAfter"),onPostRender:w},{text:"Delete row",onclick:b("mceTableDeleteRow"),onPostRender:w},{text:"Row properties",onclick:b("mceTableRowProps"),onPostRender:w},{text:"-"},{text:"Cut row",onclick:b("mceTableCutRow"),onPostRender:w},{text:"Copy row",onclick:b("mceTableCopyRow"),onPostRender:w},{text:"Paste row before",onclick:b("mceTablePasteRowBefore"),onPostRender:w},{text:"Paste row after",onclick:b("mceTablePasteRowAfter"),onPostRender:w}]}),a.addMenuItem("column",{text:"Column",context:"table",menu:[{text:"Insert column before",onclick:b("mceTableInsertColBefore"),onPostRender:w},{text:"Insert column after",onclick:b("mceTableInsertColAfter"),onPostRender:w},{text:"Delete column",onclick:b("mceTableDeleteCol"),onPostRender:w}]});var T=[];s("inserttable tableprops deletetable | cell row column".split(" "),function(e){T.push("|"==e?{text:"-"}:a.menuItems[e])}),a.addButton("table",{type:"menubutton",title:"Table",menu:T}),l.isIE||a.on("click",function(e){e=e.target,"TABLE"===e.nodeName&&(a.selection.select(e),a.nodeChanged())}),S.quirks=new t(a),a.on("Init",function(){S.cellSelection=new n(a)}),s({mceTableSplitCells:function(e){e.split()},mceTableMergeCells:function(e){var t;t=a.dom.getParent(a.selection.getStart(),"th,td"),a.dom.select("td.mce-item-selected,th.mce-item-selected").length?e.merge():g(e,t)},mceTableInsertRowBefore:function(e){e.insertRow(!0)},mceTableInsertRowAfter:function(e){e.insertRow()},mceTableInsertColBefore:function(e){e.insertCol(!0)},mceTableInsertColAfter:function(e){e.insertCol()},mceTableDeleteCol:function(e){e.deleteCols()},mceTableDeleteRow:function(e){e.deleteRows()},mceTableCutRow:function(e){N=e.cutRows()},mceTableCopyRow:function(e){N=e.copyRows()},mceTablePasteRowBefore:function(e){e.pasteRows(N,!0)},mceTablePasteRowAfter:function(e){e.pasteRows(N)},mceTableDelete:function(e){e.deleteTable()}},function(t,n){a.addCommand(n,function(){var n=new e(a);n&&(t(n),a.execCommand("mceRepaint"),S.cellSelection.clear())})}),s({mceInsertTable:function(){f()},mceTableRowProps:h,mceTableCellProps:p},function(e,t){a.addCommand(t,function(t,n){e(n)})}),a.settings.table_tab_navigation!==!1&&a.on("keydown",function(t){var n,o,l;9==t.keyCode&&(n=a.dom.getParent(a.selection.getStart(),"th,td"),n&&(t.preventDefault(),o=new e(a),l=t.shiftKey?-1:1,a.undoManager.transact(function(){!o.moveRelIdx(n,l)&&l>0&&(o.insertRow(),o.refresh(),o.moveRelIdx(n,l))})))})}var s=o.each;r.add("table",i)}),r([])}(this);