X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Frichcombo%2Fplugin.js;h=1fa8f34b961a17023d8adf1c408e62d19fab6bab;hb=f0610347140239143439a511ee2bd48cb784f470;hp=d7895c8b947fc763b1506427d9b765297e022c4c;hpb=9afde8772159bd3436f1f5b7862960307710ae5a;p=ckeditor.git diff --git a/_source/plugins/richcombo/plugin.js b/_source/plugins/richcombo/plugin.js index d7895c8..1fa8f34 100644 --- a/_source/plugins/richcombo/plugin.js +++ b/_source/plugins/richcombo/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 */ @@ -18,7 +18,7 @@ CKEDITOR.plugins.add( 'richcombo', * @constant * @example */ -CKEDITOR.UI_RICHCOMBO = 3; +CKEDITOR.UI_RICHCOMBO = 'richcombo'; CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( { @@ -128,11 +128,16 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( clickFn : clickFn }; - editor.on( 'mode', function() - { - this.setState( this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED ); - }, - this ); + function updateState() + { + var state = this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; + this.setState( editor.readOnly && !this.readOnly ? CKEDITOR.TRISTATE_DISABLED : state ); + this.setValue( '' ); + } + + editor.on( 'mode', updateState, this ); + // If this combo is sensitive to readOnly state, update it accordingly. + !this.readOnly && editor.on( 'readOnly', updateState, this); var keyDownFn = CKEDITOR.tools.addFunction( function( ev, element ) { @@ -156,18 +161,20 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( ev.preventDefault(); }); + var focusFn = CKEDITOR.tools.addFunction( function() { instance.onfocus && instance.onfocus(); } ); + // For clean up instance.keyDownFn = keyDownFn; output.push( - '', + '', '', + ' role="presentation">', '', this.label, '', '= 10900 && !env.hc ? '' : ' href="javascript:void(\'' + this.label + '\')"', @@ -192,11 +199,13 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( output.push( ' onkeydown="CKEDITOR.tools.callFunction( ', keyDownFn, ', event, this );"' + - ' onclick="CKEDITOR.tools.callFunction(', clickFn, ', this); return false;">' + + ' onfocus="return CKEDITOR.tools.callFunction(', focusFn, ', event);" ' + + ( CKEDITOR.env.ie ? 'onclick="return false;" onmouseup' : 'onclick' ) + // #188 + '="CKEDITOR.tools.callFunction(', clickFn, ', this); return false;">' + '' + '' + this.label + '' + '' + - '' + ( CKEDITOR.env.hc ? '' : CKEDITOR.env.air ? ' ' : '' ) + '' + // BLACK DOWN-POINTING TRIANGLE + '' + ( CKEDITOR.env.hc ? '▼' : CKEDITOR.env.air ? ' ' : '' ) + '' + // BLACK DOWN-POINTING TRIANGLE '' + '' + '' ); @@ -250,7 +259,6 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( panel.onEscape = function() { panel.hide(); - me.document.getById( 'cke_' + me.id ).getFirst().getNext().focus(); }; list.onClick = function( value, marked ) @@ -268,7 +276,7 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( else me.setValue( '' ); - panel.hide(); + panel.hide( false ); }; this._.panel = panel; @@ -289,16 +297,18 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( this._.value = value; var textElement = this.document.getById( 'cke_' + this.id + '_text' ); - - if ( !( value || text ) ) + if ( textElement ) { - text = this.label; - textElement.addClass( 'cke_inline_label' ); - } - else - textElement.removeClass( 'cke_inline_label' ); + if ( !( value || text ) ) + { + text = this.label; + textElement.addClass( 'cke_inline_label' ); + } + else + textElement.removeClass( 'cke_inline_label' ); - textElement.setHtml( typeof text != 'undefined' ? text : value ); + textElement.setHtml( typeof text != 'undefined' ? text : value ); + } }, getValue : function()