1?g(j,"colSpan",m-1):ca.remove(j);c?i.parentNode.insertBefore(a,i):i=ca.insertAfter(a,i)}),k())}function T(a){var b;return e(Z,function(c,d){return e(c,function(c,e){if(c.elm==a)return b={x:e,y:d},!1}),!b}),b}function U(a){_=T(a)}function V(){var a,b;return a=b=0,e(Z,function(c,d){e(c,function(c,e){var f,g;u(c)&&(c=Z[d][e],e>a&&(a=e),d>b&&(b=d),c.real&&(f=c.colspan-1,g=c.rowspan-1,f&&e+f>a&&(a=e+f),g&&d+g>b&&(b=d+g)))})}),{x:a,y:b}}function W(a){var b,c,d,e,f,g,h,i,j,l;if(aa=T(a),_&&aa){for(b=Math.min(_.x,aa.x),c=Math.min(_.y,aa.y),d=Math.max(_.x,aa.x),e=Math.max(_.y,aa.y),f=d,g=e,l=c;l<=e;l++)for(j=b;j<=d;j++)a=Z[l][j],a.real&&(h=a.colspan-1,i=a.rowspan-1,h&&j+h>f&&(f=j+h),i&&l+i>g&&(g=l+i));for(k(),l=c;l<=g;l++)for(j=b;j<=f;j++)Z[l][j]&&ca.setAttrib(Z[l][j].elm,"data-mce-selected","1")}}function X(a,b){var c,d,e;c=T(a),d=c.y*$+c.x;do{if(d+=b,e=r(d%$,Math.floor(d/$)),!e)break;if(e.elm!=a)return ba.select(e.elm,!0),ca.isEmpty(e.elm)&&ba.collapse(!0),!0}while(e.elm==a);return!1}function Y(b){if(_){var c=d.splitAt(Z,_.x,_.y,b);a.each(c.cells,p)}}var Z,$,_,aa,ba=h.selection,ca=ba.dom;i=i||ca.getParent(ba.getStart(!0),"table"),n(),j=j||ca.getParent(ba.getStart(!0),"th,td"),j&&(_=T(j),aa=V(),j=r(_.x,_.y)),a.extend(this,{deleteTable:x,split:B,merge:H,insertRow:I,insertRows:J,insertCol:K,insertCols:L,splitCols:Y,deleteCols:O,deleteRows:P,cutRows:Q,copyRows:R,pasteRows:S,getPos:T,setStartCell:U,setEndCell:W,moveRelIdx:X,refresh:n})}}),g("7",["6","1","4"],function(a,b,c){return function(d,e){function f(a){d.getBody().style.webkitUserSelect="",(a||p)&&(d.$("td[data-mce-selected],th[data-mce-selected]").removeAttr("data-mce-selected"),p=!1)}function g(a,b){return!(!a||!b)&&a===o.getParent(b,"table")}function h(b){var c,f,h=b.target;if(!m&&!n&&h!==l&&(l=h,k&&j)){if(f=o.getParent(h,"td,th"),g(k,f)||(f=o.getParent(k,"td,th")),j===f&&!p)return;if(e(!0),g(k,f)){b.preventDefault(),i||(i=new a(d,k,j),d.getBody().style.webkitUserSelect="none"),i.setEndCell(f),p=!0,c=d.selection.getSel();try{c.removeAllRanges?c.removeAllRanges():c.empty()}catch(a){}}}}var i,j,k,l,m,n,o=d.dom,p=!0,q=function(){j=i=k=l=null,e(!1)};return d.on("SelectionChange",function(a){p&&a.stopImmediatePropagation()},!0),d.on("MouseDown",function(a){2==a.button||m||n||(f(),j=o.getParent(a.target,"td,th"),k=o.getParent(j,"table"))}),d.on("mouseover",h),d.on("remove",function(){o.unbind(d.getDoc(),"mouseover",h),f()}),d.on("MouseUp",function(){function a(a,d){var f=new b(a,a);do{if(3==a.nodeType&&0!==c.trim(a.nodeValue).length)return void(d?e.setStart(a,0):e.setEnd(a,a.nodeValue.length));if("BR"==a.nodeName)return void(d?e.setStartBefore(a):e.setEndBefore(a))}while(a=d?f.next():f.prev())}var e,f,g,h,k,l=d.selection;if(j){if(i&&(d.getBody().style.webkitUserSelect=""),f=o.select("td[data-mce-selected],th[data-mce-selected]"),f.length>0){e=o.createRng(),h=f[0],e.setStartBefore(h),e.setEndAfter(h),a(h,1),g=new b(h,o.getParent(f[0],"table"));do if("TD"==h.nodeName||"TH"==h.nodeName){if(!o.getAttrib(h,"data-mce-selected"))break;k=h}while(h=g.next());a(k),l.setRng(e)}d.nodeChanged(),q()}}),d.on("KeyUp Drop SetContent",function(a){f("setcontent"==a.type),q(),m=!1}),d.on("ObjectResizeStart ObjectResized",function(a){m="objectresized"!=a.type}),d.on("dragstart",function(){n=!0}),d.on("drop dragend",function(){n=!1}),{clear:f}}}),g("8",["4","2"],function(a,b){var c=a.each;return function(d){function e(){var a=d.settings.color_picker_callback;if(a)return function(){var b=this;a.call(d,function(a){b.value(a).fire("change")},b.value())}}function f(a){return{title:"Advanced",type:"form",defaults:{onchange:function(){l(a,this.parents().reverse()[0],"style"==this.name())}},items:[{label:"Style",name:"style",type:"textbox"},{type:"form",padding:0,formItemDefaults:{layout:"grid",alignH:["start","right"]},defaults:{size:7},items:[{label:"Border color",type:"colorbox",name:"borderColor",onaction:e()},{label:"Background color",type:"colorbox",name:"backgroundColor",onaction:e()}]}]}}function g(a){return a?a.replace(/px$/,""):""}function h(a){return/^[0-9]+$/.test(a)&&(a+="px"),a}function i(a){c("left center right".split(" "),function(b){d.formatter.remove("align"+b,{},a)})}function j(a){c("top middle bottom".split(" "),function(b){d.formatter.remove("valign"+b,{},a)})}function k(b,c,d){function e(b,d){return d=d||[],a.each(b,function(a){var b={text:a.text||a.title};a.menu?b.menu=e(a.menu):(b.value=a.value,c&&c(b)),d.push(b)}),d}return e(b,d||[])}function l(a,b,c){var d=b.toJSON(),e=a.parseStyle(d.style);c?(b.find("#borderColor").value(e["border-color"]||"")[0].fire("change"),b.find("#backgroundColor").value(e["background-color"]||"")[0].fire("change")):(e["border-color"]=d.borderColor,e["background-color"]=d.backgroundColor),b.find("#style").value(a.serializeStyle(a.parseStyle(a.serializeStyle(e))))}function m(a,b,c){var d=a.parseStyle(a.getAttrib(c,"style"));d["border-color"]&&(b.borderColor=d["border-color"]),d["background-color"]&&(b.backgroundColor=d["background-color"]),b.style=a.serializeStyle(d)}function n(a,b,d){var e=a.parseStyle(a.getAttrib(b,"style"));c(d,function(a){e[a.name]=a.value}),a.setAttrib(b,"style",a.serializeStyle(a.parseStyle(a.serializeStyle(e))))}var o=this;o.tableProps=function(){o.table(!0)},o.table=function(e){function j(){function c(a,b,d){if("TD"===a.tagName||"TH"===a.tagName)v.setStyle(a,b,d);else if(a.children)for(var e=0;e',p.insertBefore(e,p.firstChild)),i(p),w.align&&d.formatter.apply("align"+w.align,{},p),d.focus(),d.addVisual()})}function o(a,b){function c(a,c){for(var d=0;d1?p={width:"",height:"",scope:"","class":"",align:"",style:"",type:o.nodeName.toLowerCase()}:(p={width:g(r.getStyle(o,"width")||r.getAttrib(o,"width")),height:g(r.getStyle(o,"height")||r.getAttrib(o,"height")),scope:r.getAttrib(o,"scope"),"class":r.getAttrib(o,"class")},p.type=o.nodeName.toLowerCase(),c("left center right".split(" "),function(a){d.formatter.matchNode(o,"align"+a)&&(p.align=a)}),c("top middle bottom".split(" "),function(a){d.formatter.matchNode(o,"valign"+a)&&(p.valign=a)}),m(r,p,o)),d.settings.table_cell_class_list&&(q={name:"class",type:"listbox",label:"Class",values:k(d.settings.table_cell_class_list,function(a){a.value&&(a.textStyle=function(){return d.formatter.getCssText({block:"td",classes:[a.value]})})})});var t={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",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"}]}]},q]};d.settings.table_cell_advtab!==!1?d.windowManager.open({title:"Cell properties",bodyType:"tabpanel",data:p,body:[{title:"General",type:"form",items:t},f(r)],onsubmit:n}):d.windowManager.open({title:"Cell properties",data:p,body:t,onsubmit:n})}},o.row=function(){function b(a,b,c){(1===u.length||c)&&t.setAttrib(a,b,c)}function e(a,b,c){(1===u.length||c)&&t.setStyle(a,b,c)}function j(){var f,g,j;l(t,this),r=a.extend(r,this.toJSON()),d.undoManager.transact(function(){var a=r.type;c(u,function(c){b(c,"scope",r.scope),b(c,"style",r.style),b(c,"class",r["class"]),e(c,"height",h(r.height)),a!==c.parentNode.nodeName.toLowerCase()&&(f=t.getParent(c,"table"),g=c.parentNode,j=t.select(a,f)[0],j||(j=t.create(a),f.firstChild?f.insertBefore(j,f.firstChild):f.appendChild(j)),j.appendChild(c),g.hasChildNodes()||t.remove(g)),1===u.length&&i(c),r.align&&d.formatter.apply("align"+r.align,{},c)}),d.focus()})}var n,o,p,q,r,s,t=d.dom,u=[];n=d.dom.getParent(d.selection.getStart(),"table"),o=d.dom.getParent(d.selection.getStart(),"td,th"),c(n.rows,function(a){c(a.cells,function(b){if(t.getAttrib(b,"data-mce-selected")||b==o)return u.push(a),!1})}),p=u[0],p&&(u.length>1?r={height:"",scope:"","class":"",align:"",type:p.parentNode.nodeName.toLowerCase()}:(r={height:g(t.getStyle(p,"height")||t.getAttrib(p,"height")),scope:t.getAttrib(p,"scope"),"class":t.getAttrib(p,"class")},r.type=p.parentNode.nodeName.toLowerCase(),c("left center right".split(" "),function(a){d.formatter.matchNode(p,"align"+a)&&(r.align=a)}),m(t,r,p)),d.settings.table_row_class_list&&(q={name:"class",type:"listbox",label:"Class",values:k(d.settings.table_row_class_list,function(a){a.value&&(a.textStyle=function(){return d.formatter.getCssText({block:"tr",classes:[a.value]})})})}),s={type:"form",columns:2,padding:0,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"Header",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"},q]},d.settings.table_row_advtab!==!1?d.windowManager.open({title:"Row properties",data:r,bodyType:"tabpanel",body:[{title:"General",type:"form",items:s},f(t)],onsubmit:j}):d.windowManager.open({title:"Row properties",data:r,body:s,onsubmit:j}))}}}),g("9",["4","5"],function(a,b){var c;return function(d){function e(a,b){return{index:a,y:d.dom.getPos(b).y}}function f(a,b){return{index:a,y:d.dom.getPos(b).y+b.offsetHeight}}function g(a,b){return{index:a,x:d.dom.getPos(b).x}}function h(a,b){return{index:a,x:d.dom.getPos(b).x+b.offsetWidth}}function i(){var a=d.getBody().dir;return"rtl"===a}function j(){return d.inline}function k(){return j?d.getBody().ownerDocument.body:d.getBody()}function l(a,b){return i()?h(a,b):g(a,b)}function m(a,b){return i()?g(a,b):h(a,b)}function n(a,b){return o(a,"width")/o(b,"width")*100}function o(a,b){var c=d.dom.getStyle(a,b,!0),e=parseInt(c,10);return e}function p(a){var b=o(a,"width"),c=o(a.parentElement,"width");return b/c*100}function q(a,b){var c=o(a,"width");return b/c*100}function r(a,b){var c=o(a.parentElement,"width");return b/c*100}function s(a,b,c){for(var d=[],e=1;e0?s(e,f,g):[],k=h.length>0?s(l,m,h):[];w(j,a.offsetWidth,i),x(k,a.offsetHeight,i)}function F(a,b,c,d){if(b<0||b>=a.length-1)return"";var e=a[b];if(e)e={value:e,delta:0};else for(var f=a.slice(0,b).reverse(),g=0;g0?e:f}function I(b,c,d){for(var e=C(b),f=a.map(e,function(a){return l(a.colIndex,a.element).x}),g=[],h=0;h1?F(f,h):H(e[h].element,c,d);j=j?j:va,g.push(j)}return g}function J(a){var b=G(a,"height"),c=parseInt(b,10);return Q(b)&&(c=0),!isNaN(c)&&c>0?c:o(a,"height")}function K(b){for(var c=D(b),d=a.map(c,function(a){return e(a.rowIndex,a.element).y}),f=[],g=0;g1?F(d,g):J(c[g].element);i=i?i:wa,f.push(i)}return f}function L(b,c,d,e,f){function g(b){return a.map(b,function(){return 0})}function h(){var a;if(f)a=[100-l[0]];else{var b=Math.max(e,l[0]+d);a=[b-l[0]]}return a}function i(a,b){var c,f=g(l.slice(0,a)),h=g(l.slice(b+1));if(d>=0){var i=Math.max(e,l[b]-d);c=f.concat([d,i-l[b]]).concat(h)}else{var j=Math.max(e,l[a]+d),k=l[a]-j;c=f.concat([j-l[a],k]).concat(h)}return c}function j(a,b){var c,f=g(l.slice(0,b));if(d>=0)c=f.concat([d]);else{var h=Math.max(e,l[b]+d);c=f.concat([h-l[b]])}return c}var k,l=b.slice(0);return k=0===b.length?[]:1===b.length?h():0===c?i(0,1):c>0&&c=1&&S(c,b,a)}else if(_(ia)){var g=parseInt(d.dom.getAttrib(ia,pa),10),h=d.dom.getPos(ia).y;a=parseInt(d.dom.getAttrib(ia,oa),10),b=h-g,Math.abs(b)>=1&&T(c,b,a)}u(c),d.nodeChanged()}}function Z(a,b){ha=ha?ha:W(),ga=!0,d.dom.addClass(a,xa),ia=a,X(ha,b),d.dom.add(k(),ha)}function $(a){return d.dom.hasClass(a,qa)}function _(a){return d.dom.hasClass(a,ma)}function aa(a){ja=void 0!==ja?ja:a.clientX;var b=a.clientX-ja;ja=a.clientX;var c=d.dom.getPos(ia).x;d.dom.setStyle(ia,"left",c+b+"px")}function ba(a){ka=void 0!==ka?ka:a.clientY;var b=a.clientY-ka;ka=a.clientY;var c=d.dom.getPos(ia).y;d.dom.setStyle(ia,"top",c+b+"px")}function ca(a){ja=void 0,Z(a,aa)}function da(a){ka=void 0,Z(a,ba)}function ea(a){var b=a.target,e=d.getBody();if(d.$.contains(e,c)||c===e)if($(b)){a.preventDefault();var f=d.dom.getPos(b).x;d.dom.setAttrib(b,ta,f),ca(b)}else if(_(b)){a.preventDefault();var g=d.dom.getPos(b).y;d.dom.setAttrib(b,pa,g),da(b)}else t()}var fa,ga,ha,ia,ja,ka,la="mce-resize-bar",ma="mce-resize-bar-row",na="row-resize",oa="data-row",pa="data-initial-top",qa="mce-resize-bar-col",ra="col-resize",sa="data-col",ta="data-initial-left",ua=4,va=10,wa=10,xa="mce-resize-bar-dragging",ya=new RegExp(/(\d+(\.\d+)?%)/),za=new RegExp(/px|em/); return d.on("init",function(){d.dom.bind(k(),"mousedown",ea)}),d.on("ObjectResized",function(b){var c=b.target;if("TABLE"===c.nodeName){var e=[];a.each(c.rows,function(b){a.each(b.cells,function(a){var b=d.dom.getStyle(a,"width",!0);e.push({cell:a,width:b})})}),a.each(e,function(a){d.dom.setStyle(a.cell,"width",a.width),d.dom.setAttrib(a.cell,"width",null)})}}),d.on("mouseover",function(a){if(!ga){var b=d.dom.getParent(a.target,"table");("TABLE"===a.target.nodeName||b)&&(c=b,u(b))}}),d.on("keydown",function(a){switch(a.keyCode){case b.LEFT:case b.RIGHT:case b.UP:case b.DOWN:t()}}),d.on("remove",function(){t(),d.dom.unbind(k(),"mousedown",ea)}),{adjustWidth:S,adjustHeight:T,clearBars:t,drawBars:E,determineDeltas:L,getTableGrid:z,getTableDetails:y,getWidths:I,getPixelHeights:K,isPercentageBasedSize:Q,isPixelBasedSize:R,recalculateWidths:N,recalculateCellHeights:O,recalculateRowHeights:P}}}),g("e",["b"],function(a){return a("tinymce.util.Delay")}),g("a",["5","e","2","4","c"],function(a,b,c,d,e){var f=d.each,g=e.getSpanVal;return function(h){function i(){function c(c){function d(a,b){var d=a?"previousSibling":"nextSibling",f=h.dom.getParent(b,"tr"),g=f[d];if(g)return r(h,b,g,a),c.preventDefault(),!0;var i=h.dom.getParent(f,"table"),l=f.parentNode,m=l.nodeName.toLowerCase();if("tbody"===m||m===(a?"tfoot":"thead")){var n=e(a,i,l,"tbody");if(null!==n)return j(a,n,b)}return k(a,f,d,i)}function e(a,b,c,d){var e=h.dom.select(">"+d,b),f=e.indexOf(c);if(a&&0===f||!a&&f===e.length-1)return i(a,b);if(f===-1){var g="thead"===c.tagName.toLowerCase()?0:e.length-1;return e[g]}return e[f+(a?-1:1)]}function i(a,b){var c=a?"thead":"tfoot",d=h.dom.select(">"+c,b);return 0!==d.length?d[0]:null}function j(a,b,d){var e=l(b,a);return e&&r(h,d,e,a),c.preventDefault(),!0}function k(a,b,e,f){var g=f[e];if(g)return m(g),!0;var i=h.dom.getParent(f,"td,th");if(i)return d(a,i,c);var j=l(b,!a);return m(j),c.preventDefault(),!1}function l(a,b){var c=a&&a[b?"lastChild":"firstChild"];return c&&"BR"===c.nodeName?h.dom.getParent(c,"td,th"):c}function m(a){h.selection.setCursorLocation(a,0)}function n(){return u==a.UP||u==a.DOWN}function o(a){var b=a.selection.getNode(),c=a.dom.getParent(b,"tr");return null!==c}function p(a){for(var b=0,c=a;c.previousSibling;)c=c.previousSibling,b+=g(c,"colspan");return b}function q(a,b){var c=0,d=0;return f(a.children,function(a,e){if(c+=g(a,"colspan"),d=e,c>b)return!1}),d}function r(a,b,c,d){var e=p(h.dom.getParent(b,"td,th")),f=q(c,e),g=c.childNodes[f],i=l(g,d);m(i||g)}function s(a){var b=h.selection.getNode(),c=h.dom.getParent(b,"td,th"),d=h.dom.getParent(a,"td,th");return c&&c!==d&&t(c,d)}function t(a,b){return h.dom.getParent(a,"TABLE")===h.dom.getParent(b,"TABLE")}var u=c.keyCode;if(n()&&o(h)){var v=h.selection.getNode();b.setEditorTimeout(h,function(){s(v)&&d(!c.shiftKey&&u===a.UP,v,c)},0)}}h.on("KeyDown",function(a){c(a)})}function j(){function a(a,b){var c,d=b.ownerDocument,e=d.createRange();return e.setStartBefore(b),e.setEnd(a.endContainer,a.endOffset),c=d.createElement("body"),c.appendChild(e.cloneContents()),0===c.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length}h.on("KeyDown",function(b){var c,d,e=h.dom;37!=b.keyCode&&38!=b.keyCode||(c=h.selection.getRng(),d=e.getParent(c.startContainer,"table"),d&&h.getBody().firstChild==d&&a(c,d)&&(c=e.createRng(),c.setStartBefore(d),c.setEndBefore(d),h.selection.setRng(c),b.preventDefault()))})}function k(){h.on("KeyDown SetContent VisualAid",function(){var a;for(a=h.getBody().lastChild;a;a=a.previousSibling)if(3==a.nodeType){if(a.nodeValue.length>0)break}else if(1==a.nodeType&&("BR"==a.tagName||!a.getAttribute("data-mce-bogus")))break;a&&"TABLE"==a.nodeName&&(h.settings.forced_root_block?h.dom.add(h.getBody(),h.settings.forced_root_block,h.settings.forced_root_block_attrs,c.ie&&c.ie<10?" ":''):h.dom.add(h.getBody(),"br",{"data-mce-bogus":"1"}))}),h.on("PreProcess",function(a){var b=a.node.lastChild;b&&("BR"==b.nodeName||1==b.childNodes.length&&("BR"==b.firstChild.nodeName||"\xa0"==b.firstChild.nodeValue))&&b.previousSibling&&"TABLE"==b.previousSibling.nodeName&&h.dom.remove(b)})}function l(){function a(a,b,c,d){var e,f,g,h=3,i=a.dom.getParent(b.startContainer,"TABLE");return i&&(e=i.parentNode),f=b.startContainer.nodeType==h&&0===b.startOffset&&0===b.endOffset&&d&&("TR"==c.nodeName||c==e),g=("TD"==c.nodeName||"TH"==c.nodeName)&&!d,f||g}function b(){var b=h.selection.getRng(),c=h.selection.getNode(),d=h.dom.getParent(b.startContainer,"TD,TH");if(a(h,b,c,d)){d||(d=c);for(var e=d.lastChild;e.lastChild;)e=e.lastChild;3==e.nodeType&&(b.setEnd(e,e.data.length),h.selection.setRng(b))}}h.on("KeyDown",function(){b()}),h.on("MouseDown",function(a){2!=a.button&&b()})}function m(){function b(a){h.selection.select(a,!0),h.selection.collapse(!0)}function c(a){h.$(a).empty(),e.paddCell(a)}h.on("keydown",function(e){if((e.keyCode==a.DELETE||e.keyCode==a.BACKSPACE)&&!e.isDefaultPrevented()){var f,g,i,j;if(f=h.dom.getParent(h.selection.getStart(),"table")){if(g=h.dom.select("td,th",f),i=d.grep(g,function(a){return!!h.dom.getAttrib(a,"data-mce-selected")}),0===i.length)return j=h.dom.getParent(h.selection.getStart(),"td,th"),void(h.selection.isCollapsed()&&j&&h.dom.isEmpty(j)&&(e.preventDefault(),c(j),b(j)));e.preventDefault(),h.undoManager.transact(function(){g.length==i.length?h.execCommand("mceTableDelete"):(d.each(i,c),b(i[0]))})}}})}function n(){var b="\ufeff",c=function(a){return h.dom.isEmpty(a)||a.firstChild===a.lastChild&&f(a.firstChild)},d=function(a){return a&&"CAPTION"==a.nodeName&&"TABLE"==a.parentNode.nodeName},e=function(a,b){var c=b.firstChild;do if(c===a)return!0;while(c=c.firstChild);return!1},f=function(a){if(3===a.nodeType){if(a.data===b)return!0;a=a.parentNode}return 1===a.nodeType&&a.hasAttribute("data-mce-caret")},g=function(a){var b=h.selection.getRng();return!b.startOffset&&!b.startContainer.previousSibling&&e(b.startContainer,a)},i=function(a,c){var d;d=c?h.dom.create("p",{"data-mce-caret":"after","data-mce-bogus":"all"},''):a.ownerDocument.createTextNode(b),a.appendChild(d)},j=function(a,d){var e=a.lastChild,g=h.selection.getRng(),j=g.startContainer,k=g.startOffset;c(a)?(a.innerHTML=b,j=a.lastChild,k=0):f(e)||i(a,h.dom.isBlock(e)),h.selection.setCursorLocation(j,k)},k=function(a){var b=h.selection.getRng(),c=h.dom.createRng(),d=a.firstChild;b.commonAncestorContainer===a.parentNode&&e(b.startContainer,a)&&(c.setStart(a,0),1===d.nodeType?c.setEnd(a,a.childNodes.length):c.setEnd(d,d.nodeValue.length),h.selection.setRng(c))};h.on("keydown",function(b){if(!(b.keyCode!==a.DELETE&&b.keyCode!==a.BACKSPACE||b.isDefaultPrevented())){var e=h.dom.getParent(h.selection.getStart(),"caption");d(e)&&(h.selection.isCollapsed()?(j(e),(c(e)||b.keyCode===a.BACKSPACE&&g(e))&&b.preventDefault()):(k(e),h.undoManager.transact(function(){h.execCommand("Delete"),j(e)}),b.preventDefault()))}})}n(),m(),c.webkit&&(i(),l()),c.gecko&&(j(),k()),c.ie>9&&(j(),k())}}),g("0",["1","2","3","4","5","6","7","8","9","a"],function(a,b,c,d,e,f,g,h,i,j){function k(a){function c(b){return function(){a.execCommand(b)}}function d(c,d){var e,f,g,h;for(g='',e=0;e",f=0;f"+(b.ie&&b.ie<10?" ":"")+"";g+=""}return g+="",a.undoManager.transact(function(){a.insertContent(g),h=a.dom.get("__mce"),a.dom.setAttrib(h,"id",null),a.$("tr",h).each(function(b,c){a.fire("newrow",{node:c}),a.$("th,td",c).each(function(b,c){a.fire("newcell",{node:c})})}),a.dom.setAttribs(h,a.settings.table_default_attributes||{}),a.dom.setStyles(h,a.settings.table_default_styles||{})}),h}function k(b,c,d){function e(){var e,f,g,h={},i=0;f=a.dom.select("td[data-mce-selected],th[data-mce-selected]"),e=f[0],e||(e=a.selection.getStart()),d&&f.length>0?(l(f,function(a){return h[a.parentNode.parentNode.nodeName]=1}),l(h,function(a){i+=a}),g=1!==i):g=!a.dom.getParent(e,c),b.disabled(g),a.selection.selectorChanged(c,function(a){b.disabled(!a)})}a.initialized?e():a.on("init",e)}function m(){k(this,"table")}function n(){k(this,"td,th")}function o(){k(this,"td,th",!0)}function p(){var a="";a='';for(var b=0;b<10;b++){a+="";for(var c=0;c<10;c++)a+='';a+=""}return a+="",a+='1 x 1'}function q(b,c,d){var e,f,g,h,i,j=d.getEl().getElementsByTagName("table")[0],k=d.isRtl()||"tl-tr"==d.parent().rel;for(j.nextSibling.innerHTML=b+1+" x "+(c+1),k&&(b=9-b),f=0;f<10;f++)for(e=0;e<10;e++)h=j.rows[f].childNodes[e].firstChild,i=(k?e>=b:e<=b)&&f<=c,a.dom.toggleClass(h,"mce-active",i),i&&(g=h);return g.parentNode}function r(){a.addButton("tableprops",{title:"Table properties",onclick:z.tableProps,icon:"table"}),a.addButton("tabledelete",{title:"Delete table",onclick:c("mceTableDelete")}),a.addButton("tablecellprops",{title:"Cell properties",onclick:c("mceTableCellProps")}),a.addButton("tablemergecells",{title:"Merge cells",onclick:c("mceTableMergeCells")}),a.addButton("tablesplitcells",{title:"Split cell",onclick:c("mceTableSplitCells")}),a.addButton("tableinsertrowbefore",{title:"Insert row before",onclick:c("mceTableInsertRowBefore")}),a.addButton("tableinsertrowafter",{title:"Insert row after",onclick:c("mceTableInsertRowAfter")}),a.addButton("tabledeleterow",{title:"Delete row",onclick:c("mceTableDeleteRow")}),a.addButton("tablerowprops",{title:"Row properties",onclick:c("mceTableRowProps")}),a.addButton("tablecutrow",{title:"Cut row",onclick:c("mceTableCutRow")}),a.addButton("tablecopyrow",{title:"Copy row",onclick:c("mceTableCopyRow")}),a.addButton("tablepasterowbefore",{title:"Paste row before",onclick:c("mceTablePasteRowBefore")}),a.addButton("tablepasterowafter",{title:"Paste row after",onclick:c("mceTablePasteRowAfter")}),a.addButton("tableinsertcolbefore",{title:"Insert column before",onclick:c("mceTableInsertColBefore")}),a.addButton("tableinsertcolafter",{title:"Insert column after",onclick:c("mceTableInsertColAfter")}),a.addButton("tabledeletecol",{title:"Delete column",onclick:c("mceTableDeleteCol")})}function s(b){var c=a.dom.is(b,"table")&&a.getBody().contains(b);return c}function t(){var b=a.settings.table_toolbar;""!==b&&b!==!1&&(b||(b="tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol"),a.addContextToolbar(s,b))}function u(){return w}function v(a){w=a}var w,x,y=this,z=new h(a);!a.settings.object_resizing||a.settings.table_resize_bars===!1||a.settings.object_resizing!==!0&&"table"!==a.settings.object_resizing||(x=i(a)),a.settings.table_grid===!1?a.addMenuItem("inserttable",{text:"Table",icon:"table",context:"table",onclick:z.table}):a.addMenuItem("inserttable",{text:"Table",icon:"table",context:"table",ariaHideMenu:!0,onclick:function(a){a.aria&&(this.parent().hideAll(),a.stopImmediatePropagation(),z.table())},onshow:function(){q(0,0,this.menu.items()[0])},onhide:function(){var b=this.menu.items()[0].getEl().getElementsByTagName("a");a.dom.removeClass(b,"mce-active"),a.dom.addClass(b[0],"mce-active")},menu:[{type:"container",html:p(),onPostRender:function(){this.lastX=this.lastY=0},onmousemove:function(a){var b,c,d=a.target;"A"==d.tagName.toUpperCase()&&(b=parseInt(d.getAttribute("data-mce-x"),10),c=parseInt(d.getAttribute("data-mce-y"),10),(this.isRtl()||"tl-tr"==this.parent().rel)&&(b=9-b),b===this.lastX&&c===this.lastY||(q(b,c,a.control),this.lastX=b,this.lastY=c))},onclick:function(b){var c=this;"A"==b.target.tagName.toUpperCase()&&(b.preventDefault(),b.stopPropagation(),c.parent().cancel(),a.undoManager.transact(function(){d(c.lastX+1,c.lastY+1)}),a.addVisual())}}]}),a.addMenuItem("tableprops",{text:"Table properties",context:"table",onPostRender:m,onclick:z.tableProps}),a.addMenuItem("deletetable",{text:"Delete table",context:"table",onPostRender:m,cmd:"mceTableDelete"}),a.addMenuItem("cell",{separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:c("mceTableCellProps"),onPostRender:n},{text:"Merge cells",onclick:c("mceTableMergeCells"),onPostRender:o},{text:"Split cell",onclick:c("mceTableSplitCells"),onPostRender:n}]}),a.addMenuItem("row",{text:"Row",context:"table",menu:[{text:"Insert row before",onclick:c("mceTableInsertRowBefore"),onPostRender:n},{text:"Insert row after",onclick:c("mceTableInsertRowAfter"),onPostRender:n},{text:"Delete row",onclick:c("mceTableDeleteRow"),onPostRender:n},{text:"Row properties",onclick:c("mceTableRowProps"),onPostRender:n},{text:"-"},{text:"Cut row",onclick:c("mceTableCutRow"),onPostRender:n},{text:"Copy row",onclick:c("mceTableCopyRow"),onPostRender:n},{text:"Paste row before",onclick:c("mceTablePasteRowBefore"),onPostRender:n},{text:"Paste row after",onclick:c("mceTablePasteRowAfter"),onPostRender:n}]}),a.addMenuItem("column",{text:"Column",context:"table",menu:[{text:"Insert column before",onclick:c("mceTableInsertColBefore"),onPostRender:n},{text:"Insert column after",onclick:c("mceTableInsertColAfter"),onPostRender:n},{text:"Delete column",onclick:c("mceTableDeleteCol"),onPostRender:n}]});var A=[];l("inserttable tableprops deletetable | cell row column".split(" "),function(b){"|"==b?A.push({text:"-"}):A.push(a.menuItems[b])}),a.addButton("table",{type:"menubutton",title:"Table",menu:A}),b.isIE||a.on("click",function(b){b=b.target,"TABLE"===b.nodeName&&(a.selection.select(b),a.nodeChanged())}),y.quirks=new j(a),a.on("Init",function(){y.cellSelection=new g(a,function(a){a&&x&&x.clearBars()}),y.resizeBars=x}),a.on("PreInit",function(){a.serializer.addAttributeFilter("data-mce-cell-padding,data-mce-border,data-mce-border-color",function(a,b){for(var c=a.length;c--;)a[c].attr(b,null)})}),l({mceTableSplitCells:function(a){a.split()},mceTableMergeCells:function(b){var c;c=a.dom.getParent(a.selection.getStart(),"th,td"),a.dom.select("td[data-mce-selected],th[data-mce-selected]").length?b.merge():z.merge(b,c)},mceTableInsertRowBefore:function(a){a.insertRows(!0)},mceTableInsertRowAfter:function(a){a.insertRows()},mceTableInsertColBefore:function(a){a.insertCols(!0)},mceTableInsertColAfter:function(a){a.insertCols()},mceTableDeleteCol:function(a){a.deleteCols()},mceTableDeleteRow:function(a){a.deleteRows()},mceTableCutRow:function(a){w=a.cutRows()},mceTableCopyRow:function(a){w=a.copyRows()},mceTablePasteRowBefore:function(a){a.pasteRows(w,!0)},mceTablePasteRowAfter:function(a){a.pasteRows(w)},mceSplitColsBefore:function(a){a.splitCols(!0)},mceSplitColsAfter:function(a){a.splitCols(!1)},mceTableDelete:function(a){x&&x.clearBars(),a.deleteTable()}},function(b,c){a.addCommand(c,function(){var c=new f(a);c&&(b(c),a.execCommand("mceRepaint"),y.cellSelection.clear())})}),l({mceInsertTable:z.table,mceTableProps:function(){z.table(!0)},mceTableRowProps:z.row,mceTableCellProps:z.cell},function(b,c){a.addCommand(c,function(a,c){b(c)})}),r(),t(),a.settings.table_tab_navigation!==!1&&a.on("keydown",function(b){var c,d,g,h=a.selection.getStart();if(b.keyCode===e.TAB){if(a.dom.getParent(h,"LI,DT,DD"))return;c=a.dom.getParent(h,"th,td"),c&&(b.preventDefault(),d=new f(a),g=b.shiftKey?-1:1,a.undoManager.transact(function(){!d.moveRelIdx(c,g)&&g>0&&(d.insertRow(),d.refresh(),d.moveRelIdx(c,g))}))}}),y.insertTable=d,y.setClipboardRows=v,y.getClipboardRows=u}var l=d.each;return c.add("table",k),function(){}}),d("0")()}();