JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.2
[ckeditor.git] / _source / plugins / justify / plugin.js
index 036434d..ad134c5 100644 (file)
@@ -82,6 +82,41 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                }\r
        }\r
 \r
+       function onDirChanged( e )\r
+       {\r
+               var editor = e.editor;\r
+\r
+               var range = new CKEDITOR.dom.range( editor.document );\r
+               range.setStartBefore( e.data );\r
+               range.setEndAfter( e.data );\r
+\r
+               var walker = new CKEDITOR.dom.walker( range ),\r
+                       node;\r
+\r
+               while ( ( node = walker.next() ) )\r
+               {\r
+                       if ( node.type == CKEDITOR.NODE_ELEMENT )\r
+                       {\r
+                               // A child with the defined dir is to be ignored.\r
+                               if ( !node.equals( e.data ) && node.getDirection() )\r
+                               {\r
+                                       range.setStartAfter( node );\r
+                                       walker = new CKEDITOR.dom.walker( range );\r
+                                       continue;\r
+                               }\r
+\r
+                               // Switch the alignment.\r
+                               var style = 'text-align';\r
+                               var align = node.getStyle( style );\r
+\r
+                               if ( align == 'left' )\r
+                                       node.setStyle( style, 'right' );\r
+                               else if ( align == 'right' )\r
+                                       node.setStyle( style, 'left' );\r
+                       }\r
+               }\r
+       }\r
+\r
        justifyCommand.prototype = {\r
                exec : function( editor )\r
                {\r
@@ -178,13 +213,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, right ) );\r
                        editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, center ) );\r
                        editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, justify ) );\r
+                       editor.on( 'dirChanged', onDirChanged );\r
                },\r
 \r
                requires : [ 'domiterator' ]\r
        });\r
 })();\r
-\r
-CKEDITOR.tools.extend( CKEDITOR.config,\r
-       {\r
-               justifyClasses : null\r
-       } );\r