JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.1
[ckeditor.git] / _source / plugins / indent / plugin.js
index c49ce88..c36370c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -9,16 +9,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
 (function()\r
 {\r
-       var listNodeNames = { ol : 1, ul : 1 };\r
-\r
-       var isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ),\r
+       var listNodeNames = { ol : 1, ul : 1 },\r
+               isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ),\r
                isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true );\r
 \r
-       function setState( editor, state )\r
-       {\r
-               editor.getCommand( this.name ).setState( state );\r
-       }\r
-\r
        function onSelectionChange( evt )\r
        {\r
                var editor = evt.editor;\r
@@ -27,15 +21,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                list = elementPath && elementPath.contains( listNodeNames );\r
 \r
                if ( list )\r
-                               return setState.call( this, editor, CKEDITOR.TRISTATE_OFF );\r
+                               return this.setState( CKEDITOR.TRISTATE_OFF );\r
 \r
                if ( !this.useIndentClasses && this.name == 'indent' )\r
-                       return setState.call( this, editor, CKEDITOR.TRISTATE_OFF );\r
+                       return this.setState( CKEDITOR.TRISTATE_OFF );\r
 \r
                var path = evt.data.path,\r
                        firstBlock = path.block || path.blockLimit;\r
                if ( !firstBlock )\r
-                       return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED );\r
+                       return this.setState( CKEDITOR.TRISTATE_DISABLED );\r
 \r
                if ( this.useIndentClasses )\r
                {\r
@@ -48,8 +42,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        }\r
                        if ( ( this.name == 'outdent' && !indentStep ) ||\r
                                        ( this.name == 'indent' && indentStep == editor.config.indentClasses.length ) )\r
-                               return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED );\r
-                       return setState.call( this, editor, CKEDITOR.TRISTATE_OFF );\r
+                               return this.setState( CKEDITOR.TRISTATE_DISABLED );\r
+                       return this.setState( CKEDITOR.TRISTATE_OFF );\r
                }\r
                else\r
                {\r
@@ -57,8 +51,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        if ( isNaN( indent ) )\r
                                indent = 0;\r
                        if ( indent <= 0 )\r
-                               return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED );\r
-                       return setState.call( this, editor, CKEDITOR.TRISTATE_OFF );\r
+                               return this.setState( CKEDITOR.TRISTATE_DISABLED );\r
+                       return this.setState( CKEDITOR.TRISTATE_OFF );\r
                }\r
        }\r
 \r
@@ -215,7 +209,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                iterator.enforceRealBlocks = true;\r
                                iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;\r
                                var block;\r
-                               while ( ( block = iterator.getNextParagraph() ) )\r
+                               while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )\r
                                        indentElement( block );\r
                        }\r
 \r
@@ -354,10 +348,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                init : function( editor )\r
                {\r
                        // Register commands.\r
-                       var indent = new indentCommand( editor, 'indent' ),\r
-                               outdent = new indentCommand( editor, 'outdent' );\r
-                       editor.addCommand( 'indent', indent );\r
-                       editor.addCommand( 'outdent', outdent );\r
+                       var indent = editor.addCommand( 'indent', new indentCommand( editor, 'indent' ) ),\r
+                               outdent = editor.addCommand( 'outdent', new indentCommand( editor, 'outdent' ) );\r
 \r
                        // Register the toolbar buttons.\r
                        editor.ui.addButton( 'Indent',\r