editor-bidi-min.js revision aa2ac226ad6e45232f8416eecc99d2165ce74d03
YUI.add("editor-bidi",function(h){var g=function(){g.superclass.constructor.apply(this,arguments);},c="host",b="dir",d="BODY",a="nodeChange",f="bidiContextChange",e=d+" > p";h.extend(g,h.Base,{lastDirection:null,firstEvent:null,_checkForChange:function(){var j=this.get(c),l=j.getInstance(),k=new l.Selection(),i,m;if(k.isCollapsed){i=g.blockParent(k.focusNode);m=i.getStyle("direction");if(m!==this.lastDirection){j.fire(f,{changedTo:m});this.lastDirection=m;}}else{j.fire(f,{changedTo:"select"});this.lastDirection=null;}},_afterNodeChange:function(i){if(this.firstEvent||g.EVENTS[i.changedType]){this._checkForChange();this.firstEvent=false;}},_afterMouseUp:function(i){this._checkForChange();this.firstEvent=false;},initializer:function(){var i=this.get(c);this.firstEvent=true;i.after(a,h.bind(this._afterNodeChange,this));i.after("dom:mouseup",h.bind(this._afterMouseUp,this));}},{EVENTS:{"backspace-up":true,"pageup-up":true,"pagedown-down":true,"end-up":true,"home-up":true,"left-up":true,"up-up":true,"right-up":true,"down-up":true,"delete-up":true},BLOCKS:h.Selection.BLOCKS+",LI,HR,"+d,DIV_WRAPPER:"<DIV></DIV>",blockParent:function(k,j){var i=k,m,l;if(!i){i=h.one(d);}if(!i.test(g.BLOCKS)){i=i.ancestor(g.BLOCKS);}if(j&&i.test(d)){m=h.Node.create(g.DIV_WRAPPER);i.get("children").each(function(o,n){if(n===0){l=o;}else{m.append(o);}});l.replace(m);m.prepend(l);i=m;}return i;},_NODE_SELECTED:"bidiSelected",addParents:function(m){var j,l,k;for(j=0;j<m.length;j+=1){m[j].setData(g._NODE_SELECTED,true);}for(j=0;j<m.length;j+=1){l=m[j].get("parentNode");if(!l.test(d)&&!l.getData(g._NODE_SELECTED)){k=true;l.get("children").some(function(i){if(!i.getData(g._NODE_SELECTED)){k=false;return true;}});if(k){m.push(l);l.setData(g._NODE_SELECTED,true);}}}for(j=0;j<m.length;j+=1){m[j].clearData(g._NODE_SELECTED);}return m;},NAME:"editorBidi",NS:"editorBidi",ATTRS:{host:{value:false}}});h.namespace("Plugin");h.Plugin.EditorBidi=g;h.Plugin.ExecCommand.COMMANDS.bidi=function(m,n){var l=this.getInstance(),k=new l.Selection(),j,p,i,o;l.Selection.filterBlocks();if(k.isCollapsed){p=g.blockParent(k.anchorNode);p.setAttribute(b,n);j=p;}else{i=k.getSelected();o=[];i.each(function(q){if(!q.test(d)){o.push(g.blockParent(q));}});o=l.all(g.addParents(o));o.setAttribute(b,n);j=o;}this.get(c).get(c).editorBidi.checkForChange();return j;};},"@VERSION@",{skinnable:false,requires:["editor-base","selection"]});