X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Frichcombo%2Fplugin.js;h=1bc4172018a360dd3b4a503c389399727858ad61;hb=a272c66d841421f8bf933c16535bdcde1c4649fc;hp=8c2e81ba0ac0bbfd79859e8e09840daa7ca17320;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/plugins/richcombo/plugin.js b/_source/plugins/richcombo/plugin.js index 8c2e81b..1bc4172 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-2013, 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( { @@ -106,12 +106,7 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( return; } - if ( !_.committed ) - { - _.list.commit(); - _.committed = 1; - } - + this.commit(); var value = this.getValue(); if ( value ) _.list.mark( value ); @@ -130,14 +125,19 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( var element = CKEDITOR.document.getById( id ).getChild( 1 ); element.focus(); }, - execute : clickFn + 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 ) { @@ -161,15 +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 + '\')"', @@ -194,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 ? '' : '' ) + '' + // BLACK DOWN-POINTING TRIANGLE + '' + ( CKEDITOR.env.hc ? '▼' : CKEDITOR.env.air ? ' ' : '' ) + '' + // BLACK DOWN-POINTING TRIANGLE '' + '' + '' ); @@ -236,23 +243,22 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( me.onOpen(); }; - panel.onHide = function() + panel.onHide = function( preventOnClose ) { if ( me.className ) this.element.getFirst().removeClass( me.className + '_panel' ); - me.setState( CKEDITOR.TRISTATE_OFF ); + me.setState( me.modes && me.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED ); me._.on = 0; - if ( me.onClose ) + if ( !preventOnClose && me.onClose ) me.onClose(); }; panel.onEscape = function() { panel.hide(); - me.document.getById( 'cke_' + me.id ).getFirst().getNext().focus(); }; list.onClick = function( value, marked ) @@ -270,7 +276,7 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( else me.setValue( '' ); - panel.hide(); + panel.hide( false ); }; this._.panel = panel; @@ -291,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() @@ -346,7 +354,13 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( commit : function() { - this._.list.commit(); + if ( !this._.committed ) + { + this._.list.commit(); + this._.committed = 1; + CKEDITOR.ui.fire( 'ready', this ); + } + this._.committed = 1; }, setState : function( state )