X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Frichcombo%2Fplugin.js;h=7978abeb085dee6eb8f247db8ec5f2f0559bf008;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hp=f76db4617b1863eb3c63c38d50b0eeb3ca3b8a3d;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/plugins/richcombo/plugin.js b/_source/plugins/richcombo/plugin.js index f76db46..7978abe 100644 --- a/_source/plugins/richcombo/plugin.js +++ b/_source/plugins/richcombo/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, 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 */ @@ -44,6 +44,11 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( || CKEDITOR.document; panelDefinition.className = ( panelDefinition.className || '' ) + ' cke_rcombopanel'; + panelDefinition.block = + { + multiSelect : panelDefinition.multiSelect, + attributes : panelDefinition.attributes + }; this._ = { @@ -83,6 +88,8 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( */ render : function( editor, output ) { + var env = CKEDITOR.env; + var id = 'cke_' + this.id; var clickFn = CKEDITOR.tools.addFunction( function( $element ) { @@ -99,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 ); @@ -123,12 +125,13 @@ 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.setValue( '' ); }, this ); @@ -154,6 +157,9 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( ev.preventDefault(); }); + // For clean up + instance.keyDownFn = keyDownFn; + output.push( '', '' + - '', this.label, '' + - '', + '', this.label, '', + '= 10900 && !env.hc ? '' : ' href="javascript:void(\'' + this.label + '\')"', + ' role="button" aria-labelledby="', id , '_label" aria-describedby="', id, '_text" aria-haspopup="true"' ); // Some browsers don't cancel key events in the keydown but in the // keypress. @@ -187,10 +195,9 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( ' onkeydown="CKEDITOR.tools.callFunction( ', keyDownFn, ', event, this );"' + ' onclick="CKEDITOR.tools.callFunction(', clickFn, ', this); return false;">' + '' + - '' + ( this.voiceLabel ? this.voiceLabel + ' ' : '' ) + '' + '' + this.label + '' + '' + - '' + + '' + ( CKEDITOR.env.hc ? '' : CKEDITOR.env.air ? ' ' : '' ) + '' + // BLACK DOWN-POINTING TRIANGLE '' + '' + '' ); @@ -207,9 +214,10 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( return; var panelDefinition = this._.panelDefinition, + panelBlockDefinition = this._.panelDefinition.block, panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(), panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ), - list = panel.addListBlock( this.id, this.multiSelect ), + list = panel.addListBlock( this.id, panelBlockDefinition ), me = this; panel.onShow = function() @@ -227,16 +235,16 @@ 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(); }; @@ -282,15 +290,18 @@ CKEDITOR.ui.richCombo = CKEDITOR.tools.createClass( this._.value = value; var textElement = this.document.getById( 'cke_' + this.id + '_text' ); - - if ( !value ) + if ( textElement ) { - text = this.label; - textElement.addClass( '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 ); } - else - textElement.removeClass( 'cke_inline_label' ); - textElement.setHtml( typeof text != 'undefined' ? text : value ); }, getValue : function() @@ -336,7 +347,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 )