X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fstylescombo%2Fplugin.js;h=f69060281a777324447fa736f9e3ddb8d104d466;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=8ed7f9b429dabef53f6d4ce025f83a5a57b8a590;hpb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1;p=ckeditor.git diff --git a/_source/plugins/stylescombo/plugin.js b/_source/plugins/stylescombo/plugin.js index 8ed7f9b..f690602 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-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -14,7 +14,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var config = editor.config, lang = editor.lang.stylesCombo, styles = {}, - stylesList = []; + stylesList = [], + combo; function loadStylesSet( callback ) { @@ -26,7 +27,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 ]; @@ -34,6 +35,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license style = styles[ styleName ] = new CKEDITOR.style( styleDefinition ); style._name = styleName; + style._.enterMode = config.enterMode; stylesList.push( style ); } @@ -61,21 +63,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license init : function() { - var combo = this; + combo = this; 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 ) { @@ -91,7 +96,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license combo.commit(); - combo.onOpen(); }); }, @@ -101,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' ); }, @@ -117,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]; @@ -151,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 selection = editor.getSelection(), + element = selection.getSelectedElement(), + elementPath = new CKEDITOR.dom.elementPath( element || selection.getStartElement() ), + counter = [ 0, 0, 0, 0 ]; - var element = selection.getSelectedElement(), - elementPath = new CKEDITOR.dom.elementPath( element || selection.getStartElement() ); - - var counter = [ 0, 0, 0, 0 ]; this.showAll(); this.unmarkAll(); for ( var name in styles ) @@ -183,6 +181,22 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( !counter[ CKEDITOR.STYLE_OBJECT ] ) this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_OBJECT ) ] ); + }, + + // Force a reload of the data + reset: function() + { + if ( combo ) + { + delete combo._.panel; + delete combo._.list; + combo._.committed = 0; + combo._.items = {}; + combo._.state = CKEDITOR.TRISTATE_OFF; + } + styles = {}; + stylesList = []; + loadStylesSet(); } });