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=fb44d5c2e472abb0038345d610cc7528e1d69c07;hpb=039a051ccf3901311661022a30afd60fc38130c9;p=ckeditor.git diff --git a/_source/plugins/stylescombo/plugin.js b/_source/plugins/stylescombo/plugin.js index fb44d5c..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 */ @@ -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, count = stylesList.length ; i < count ; 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,16 +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 if ( style.type == CKEDITOR.STYLE_OBJECT && style.checkActive( elementPath ) ) - style.remove( editor.document ); - else - style.apply( editor.document ); + style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document ); editor.fire( 'saveSnapshot' ); }, @@ -120,9 +117,8 @@ 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. @@ -156,9 +152,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var selection = editor.getSelection(), element = selection.getSelectedElement(), - elementPath = new CKEDITOR.dom.elementPath( element || selection.getStartElement() ); + 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 )