JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.1
[ckeditor.git] / _source / plugins / stylescombo / plugin.js
index a5d4b7c..d2f8eb3 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
@@ -26,7 +26,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        styleName;\r
 \r
                                                // Put all styles into an Array.\r
-                                               for ( var i = 0 ; i < stylesDefinitions.length ; i++ )\r
+                                               for ( var i = 0, count = stylesDefinitions.length ; i < count ; i++ )\r
                                                {\r
                                                        var styleDefinition = stylesDefinitions[ i ];\r
 \r
@@ -71,7 +71,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                // Loop over the Array, adding all items to the\r
                                                                // combo.\r
                                                                var lastType;\r
-                                                               for ( var i = 0 ; i < stylesList.length ; i++ )\r
+                                                               for ( var i = 0, count = stylesList.length ; i < count ; i++ )\r
                                                                {\r
                                                                        style = stylesList[ i ];\r
                                                                        styleName = style._name;\r
@@ -106,10 +106,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                                var elementPath = new CKEDITOR.dom.elementPath( selection.getStartElement() );\r
 \r
-                                               if ( style.type == CKEDITOR.STYLE_INLINE && style.checkActive( elementPath ) )\r
-                                                       style.remove( editor.document );\r
-                                               else\r
-                                                       style.apply( editor.document );\r
+                                               style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document );\r
 \r
                                                editor.fire( 'saveSnapshot' );\r
                                        },\r
@@ -124,7 +121,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        elements = elementPath.elements;\r
 \r
                                                                // For each element into the elements path.\r
-                                                               for ( var i = 0, element ; i < elements.length ; i++ )\r
+                                                               for ( var i = 0, count = elements.length, element ; i < count ; i++ )\r
                                                                {\r
                                                                        element = elements[i];\r
 \r
@@ -152,9 +149,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                if ( CKEDITOR.env.ie || CKEDITOR.env.webkit )\r
                                                        editor.focus();\r
 \r
-                                               var selection = editor.getSelection();\r
-\r
-                                               var element = selection.getSelectedElement(),\r
+                                               var selection = editor.getSelection(),\r
+                                                       element = selection.getSelectedElement(),\r
                                                        elementPath = new CKEDITOR.dom.elementPath( element || selection.getStartElement() );\r
 \r
                                                var counter = [ 0, 0, 0, 0 ];\r