X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fstylescombo%2Fplugin.js;h=086f1097551e6025e3131300e368a575e2156b04;hb=f0610347140239143439a511ee2bd48cb784f470;hp=d2f8eb3efaa7c396a9c2b291b2898c0add803323;hpb=48b1db88210b4160dce439c6e3e32e14af8c106b;p=ckeditor.git diff --git a/_source/plugins/stylescombo/plugin.js b/_source/plugins/stylescombo/plugin.js index d2f8eb3..086f109 100644 --- a/_source/plugins/stylescombo/plugin.js +++ b/_source/plugins/stylescombo/plugin.js @@ -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 ) { @@ -62,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, 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 ) { @@ -92,7 +96,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license combo.commit(); - combo.onOpen(); }); }, @@ -102,9 +105,8 @@ 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() ); style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document ); @@ -115,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. @@ -151,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 ) @@ -180,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(); } });