X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fpanel%2Fplugin.js;h=181fae33796fa2973ece54df9d8e2724f3d47040;hp=7b542b321c4290852cac29a3dd94d0c6cdaee3cc;hb=059b4c2fef02528bf1af189f7996e80652faddfb;hpb=c6e377a02b54abc07129d72b632763c727476a15 diff --git a/_source/plugins/panel/plugin.js b/_source/plugins/panel/plugin.js index 7b542b3..181fae3 100644 --- a/_source/plugins/panel/plugin.js +++ b/_source/plugins/panel/plugin.js @@ -78,11 +78,13 @@ CKEDITOR.ui.panel.prototype = output.push( '
, so it (body) becames immediatelly // available. (#3031) @@ -171,7 +172,8 @@ CKEDITOR.ui.panel.prototype = doc.on( 'keydown', function( evt ) { - var keystroke = evt.data.getKeystroke(); + var keystroke = evt.data.getKeystroke(), + dir = this.document.getById( 'cke_' + this.id ).getAttribute( 'dir' ); // Delegate key processing to block. if ( this._.onKeyDown && this._.onKeyDown( keystroke ) === false ) @@ -180,8 +182,12 @@ CKEDITOR.ui.panel.prototype = return; } - if ( keystroke == 27 ) // ESC - this.onEscape && this.onEscape(); + // ESC/ARROW-LEFT(ltr) OR ARROW-RIGHT(rtl) + if ( keystroke == 27 || keystroke == ( dir == 'rtl' ? 39 : 37 ) ) + { + if ( this.onEscape && this.onEscape( keystroke ) === false ) + evt.data.preventDefault( ); + } }, this ); @@ -198,7 +204,8 @@ CKEDITOR.ui.panel.prototype = addBlock : function( name, block ) { - block = this._.blocks[ name ] = block || new CKEDITOR.ui.panel.block( this.getHolderElement() ); + block = this._.blocks[ name ] = block instanceof CKEDITOR.ui.panel.block ? block + : new CKEDITOR.ui.panel.block( this.getHolderElement(), block ); if ( !this._.currentBlock ) this.showBlock( name ); @@ -215,13 +222,23 @@ CKEDITOR.ui.panel.prototype = { var blocks = this._.blocks, block = blocks[ name ], - current = this._.currentBlock; + current = this._.currentBlock, + holder = this.forceIFrame ? + this.document.getById( 'cke_' + this.id + '_frame' ) + : this._.holder; if ( current ) + { + // Clean up the current block's effects on holder. + holder.removeAttributes( current.attributes ); current.hide(); + } this._.currentBlock = block; + holder.setAttributes( block.attributes ); + CKEDITOR.fire( 'ariaWidget', holder ); + // Reset the focus index, so it will always go into the first one. block._.focusIndex = -1; @@ -240,14 +257,16 @@ CKEDITOR.ui.panel.prototype = CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass( { - $ : function( blockHolder ) + $ : function( blockHolder, blockDefinition ) { this.element = blockHolder.append( blockHolder.getDocument().createElement( 'div', { attributes : { - 'class' : 'cke_panel_block' + 'tabIndex' : -1, + 'class' : 'cke_panel_block', + 'role' : 'presentation' }, styles : { @@ -255,6 +274,10 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass( } }) ); + // Copy all definition properties to this object. + if ( blockDefinition ) + CKEDITOR.tools.extend( this, blockDefinition ); + this.keys = {}; this._.focusIndex = -1; @@ -263,7 +286,25 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass( this.element.disableContextMenu(); }, - _ : {}, + _ : { + + /** + * Mark the item specified by the index as current activated. + */ + markItem: function( index ) + { + if ( index == -1 ) + return; + var links = this.element.getElementsByTag( 'a' ); + var item = links.getItem( this._.focusIndex = index ); + + // Safari need focus on the iframe window first(#3389), but we need + // lock the blur to avoid hiding the panel. + if ( CKEDITOR.env.webkit ) + item.getDocument().getWindow().focus(); + item.focus(); + } + }, proto : {