
| Current Path : /proc/self/root/usr/share/javascript/ckeditor/plugins/tableresize/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //proc/self/root/usr/share/javascript/ckeditor/plugins/tableresize/plugin.js |
/*
Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
(function(){function w(b){return CKEDITOR.env.ie?b.$.clientWidth:parseInt(b.getComputedStyle("width"),10)}function r(b,d){var a=b.getComputedStyle("border-"+d+"-width"),l={thin:"0px",medium:"1px",thick:"2px"};0>a.indexOf("px")&&(a=a in l&&"none"!=b.getComputedStyle("border-style")?l[a]:0);return parseInt(a,10)}function z(b){var d=[],a={},l="rtl"==b.getComputedStyle("direction");CKEDITOR.tools.array.forEach(b.$.rows,function(f,A){var e=-1,g=0,c=null;f?(g=new CKEDITOR.dom.element(f),c={height:g.$.offsetHeight,
position:g.getDocumentPosition()}):c=void 0;for(var g=c.height,c=c.position,m=0,k=f.cells.length;m<k;m++){var h=new CKEDITOR.dom.element(f.cells[m]),p=f.cells[m+1]&&new CKEDITOR.dom.element(f.cells[m+1]),e=e+(h.$.colSpan||1),s,t,n=h.getDocumentPosition().x;l?t=n+r(h,"left"):s=n+h.$.offsetWidth-r(h,"right");p?(n=p.getDocumentPosition().x,l?s=n+p.$.offsetWidth-r(p,"right"):t=n+r(p,"left")):(n=b.getDocumentPosition().x,l?s=n:t=n+b.$.offsetWidth);h=Math.max(t-s,3);h={table:b,index:e,x:s,y:c.y,width:h,
height:g,rtl:l};a[e]=a[e]||[];a[e].push(h);h.alignedPillars=a[e];d.push(h)}});return d}function y(b){(b.data||b).preventDefault()}function D(b){function d(){m=0;c.setOpacity(0);h&&a();var b=e.table;setTimeout(function(){b.removeCustomData("_cke_table_pillars")},0);g.removeListener("dragstart",y)}function a(){for(var c=e.rtl,l=c?t.length:s.length,a=0,f=0;f<l;f++){var g=s[f],d=t[f],m=e.table;CKEDITOR.tools.setTimeout(function(e,f,g,d,h,n){e&&e.setStyle("width",k(Math.max(f+n,1)));g&&g.setStyle("width",
k(Math.max(d-n,1)));h&&m.setStyle("width",k(h+n*(c?-1:1)));++a==l&&b.fire("saveSnapshot")},0,this,[g,g&&w(g),d,d&&w(d),(!g||!d)&&w(m)+r(m,"left")+r(m,"right"),h])}}function l(l){y(l);b.fire("saveSnapshot");l=e.index;for(var a=CKEDITOR.tools.buildTableMap(e.table),d=[],k=[],p=Number.MAX_VALUE,r=p,v=e.rtl,B=0,z=a.length;B<z;B++){var q=a[B],u=q[l+(v?1:0)],q=q[l+(v?0:1)],u=u&&new CKEDITOR.dom.element(u),q=q&&new CKEDITOR.dom.element(q);if(!u||!q||!u.equals(q))u&&(p=Math.min(p,w(u))),q&&(r=Math.min(r,
w(q))),d.push(u),k.push(q)}s=d;t=k;n=e.x-p;C=e.x+r;c.setOpacity(0.5);x=parseInt(c.getStyle("left"),10);h=0;m=1;c.on("mousemove",A);g.on("dragstart",y);g.on("mouseup",f,this)}function f(c){c.removeListener();d()}function A(c){p(c.data.getPageOffset().x)}var e,g,c,m,x,h,p,s,t,n,C;g=b.document;c=CKEDITOR.dom.element.createFromHtml('\x3cdiv data-cke-temp\x3d1 contenteditable\x3dfalse unselectable\x3don style\x3d"position:absolute;cursor:col-resize;filter:alpha(opacity\x3d0);opacity:0;padding:0;background-color:#004;background-image:none;border:0px none;z-index:10"\x3e\x3c/div\x3e',
g);b.on("destroy",function(){c.remove()});v||g.getDocumentElement().append(c);this.attachTo=function(b){var a,f,d;m||(v&&(g.getBody().append(c),h=0),e=b,a=e.alignedPillars[0],f=e.alignedPillars[e.alignedPillars.length-1],d=a.y,a=f.height+f.y-a.y,c.setStyles({width:k(b.width),height:k(a),left:k(b.x),top:k(d)}),v&&c.setOpacity(0.25),c.on("mousedown",l,this),g.getBody().setStyle("cursor","col-resize"),c.show())};p=this.move=function(b,a){if(!e)return 0;if(!m&&!(b>=e.x&&b<=e.x+e.width&&a>=e.y&&a<=e.y+
e.height))return e=null,m=h=0,g.removeListener("mouseup",f),c.removeListener("mousedown",l),c.removeListener("mousemove",A),g.getBody().setStyle("cursor","auto"),v?c.remove():c.hide(),0;var d=b-Math.round(c.$.offsetWidth/2);if(m){if(d==n||d==C)return 1;d=Math.max(d,n);d=Math.min(d,C);h=d-x}c.setStyle("left",k(d));return 1}}function x(b){var d=b.data.getTarget();if("mouseout"==b.name){if(!d.is("table"))return;for(var a=new CKEDITOR.dom.element(b.data.$.relatedTarget||b.data.$.toElement);a&&a.$&&!a.equals(d)&&
!a.is("body");)a=a.getParent();if(!a||a.equals(d))return}d.getAscendant("table",1).removeCustomData("_cke_table_pillars");b.removeListener()}var k=CKEDITOR.tools.cssLength,v=CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.quirks);CKEDITOR.plugins.add("tableresize",{requires:"tabletools",init:function(b){b.on("contentDom",function(){var d,a=b.editable();a.attachListener(a.isInline()?a:b.document,"mousemove",function(a){a=a.data;var f=a.getTarget();if(f.type==CKEDITOR.NODE_ELEMENT){var k=a.getPageOffset().x,
e=a.getPageOffset().y;if(d&&d.move(k,e))y(a);else if(f.is("table")||f.getAscendant({thead:1,tbody:1,tfoot:1},1))if(a=f.getAscendant("table",1),b.editable().contains(a)){if(!(f=a.getCustomData("_cke_table_pillars")))a.setCustomData("_cke_table_pillars",f=z(a)),a.on("mouseout",x),a.on("mousedown",x);a:{a=f;for(var f=0,g=a.length;f<g;f++){var c=a[f];if(k>=c.x&&k<=c.x+c.width&&e>=c.y&&e<=c.y+c.height){k=c;break a}}k=null}k&&(!d&&(d=new D(b)),d.attachTo(k))}}})})}})})();