X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fstylescombo%2Fplugin.js;h=74dd0b73094db13cc5468dfbc60b8c1f9d66cd69;hb=refs%2Ftags%2Fv3.5.3;hp=a5d4b7c3d6ea352020c4fde5c62f89aec99c22a0;hpb=8665a7c6c60586526e32e8941fe2896739b6ebfb;p=ckeditor.git diff --git a/_source/plugins/stylescombo/plugin.js b/_source/plugins/stylescombo/plugin.js index a5d4b7c..74dd0b7 100644 --- a/_source/plugins/stylescombo/plugin.js +++ b/_source/plugins/stylescombo/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -26,7 +26,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license styleName; // Put all styles into an Array. - for ( var i = 0 ; i < stylesDefinitions.length ; i++ ) + for ( var i = 0, count = stylesDefinitions.length ; i < count ; i++ ) { var styleDefinition = stylesDefinitions[ i ]; @@ -66,17 +66,20 @@ For licensing, see LICENSE.html or http://ckeditor.com/license loadStylesSet( function() { - var style, styleName; + var style, + styleName, + lastType, + type, + i, + count; // Loop over the Array, adding all items to the // combo. - var lastType; - for ( var i = 0 ; i < stylesList.length ; i++ ) + for ( i = 0, count = stylesList.length ; i < count ; i++ ) { style = stylesList[ i ]; styleName = style._name; - - var type = style.type; + type = style.type; if ( type != lastType ) { @@ -102,14 +105,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license editor.fire( 'saveSnapshot' ); var style = styles[ value ], - selection = editor.getSelection(); - - var elementPath = new CKEDITOR.dom.elementPath( selection.getStartElement() ); + selection = editor.getSelection(), + elementPath = new CKEDITOR.dom.elementPath( selection.getStartElement() ); - if ( style.type == CKEDITOR.STYLE_INLINE && style.checkActive( elementPath ) ) - style.remove( editor.document ); - else - style.apply( editor.document ); + style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document ); editor.fire( 'saveSnapshot' ); }, @@ -118,13 +117,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { editor.on( 'selectionChange', function( ev ) { - var currentValue = this.getValue(); - - var elementPath = ev.data.path, + var currentValue = this.getValue(), + elementPath = ev.data.path, elements = elementPath.elements; // For each element into the elements path. - for ( var i = 0, element ; i < elements.length ; i++ ) + for ( var i = 0, count = elements.length, element ; i < count ; i++ ) { element = elements[i]; @@ -152,12 +150,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( CKEDITOR.env.ie || CKEDITOR.env.webkit ) editor.focus(); - var selection = editor.getSelection(); - - var element = selection.getSelectedElement(), - elementPath = new CKEDITOR.dom.elementPath( element || selection.getStartElement() ); + var selection = editor.getSelection(), + element = selection.getSelectedElement(), + elementPath = new CKEDITOR.dom.elementPath( element || selection.getStartElement() ), + counter = [ 0, 0, 0, 0 ]; - var counter = [ 0, 0, 0, 0 ]; this.showAll(); this.unmarkAll(); for ( var name in styles )