X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fpanel%2Fplugin.js;h=6dc1616402e6e52889faacb606c7692f475f4017;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=181fae33796fa2973ece54df9d8e2724f3d47040;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/plugins/panel/plugin.js b/_source/plugins/panel/plugin.js index 181fae3..6dc1616 100644 --- a/_source/plugins/panel/plugin.js +++ b/_source/plugins/panel/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -16,7 +16,7 @@ CKEDITOR.plugins.add( 'panel', * @constant * @example */ -CKEDITOR.UI_PANEL = 2; +CKEDITOR.UI_PANEL = 'panel'; CKEDITOR.ui.panel = function( document, definition ) { @@ -31,7 +31,7 @@ CKEDITOR.ui.panel = function( document, definition ) css : [] }); - this.id = CKEDITOR.tools.getNextNumber(); + this.id = CKEDITOR.tools.getNextId(); this.document = document; this._ = @@ -73,7 +73,7 @@ CKEDITOR.ui.panel.prototype = */ render : function( editor, output ) { - var id = 'cke_' + this.id; + var id = this.id; output.push( '
' + '' + '' + + CKEDITOR.tools.buildStyleHtml( this.css ) + '' + '' + - // It looks strange, but for FF2, the styles must go - // after , so it (body) becames immediatelly - // available. (#3031) - CKEDITOR.tools.buildStyleHtml( this.css ) + - '<\/html>' ); - doc.$.close(); + '<\/html>'; + + doc.write( data ); var win = doc.getWindow(); // Register the CKEDITOR global. win.$.CKEDITOR = CKEDITOR; - doc.on( 'keydown', function( evt ) + // Arrow keys for scrolling is only preventable with 'keypress' event in Opera (#4534). + doc.on( 'key' + ( CKEDITOR.env.opera? 'press':'down' ), function( evt ) { var keystroke = evt.data.getKeystroke(), - dir = this.document.getById( 'cke_' + this.id ).getAttribute( 'dir' ); + dir = this.document.getById( this.id ).getAttribute( 'dir' ); // Delegate key processing to block. if ( this._.onKeyDown && this._.onKeyDown( keystroke ) === false ) @@ -186,15 +186,17 @@ CKEDITOR.ui.panel.prototype = if ( keystroke == 27 || keystroke == ( dir == 'rtl' ? 39 : 37 ) ) { if ( this.onEscape && this.onEscape( keystroke ) === false ) - evt.data.preventDefault( ); + evt.data.preventDefault(); } }, this ); holder = doc.getBody(); + holder.unselectable(); + CKEDITOR.env.air && CKEDITOR.tools.callFunction( onLoad ); } else - holder = this.document.getById( 'cke_' + this.id ); + holder = this.document.getById( this.id ); this._.holder = holder; } @@ -222,10 +224,12 @@ CKEDITOR.ui.panel.prototype = { var blocks = this._.blocks, block = blocks[ name ], - current = this._.currentBlock, - holder = this.forceIFrame ? - this.document.getById( 'cke_' + this.id + '_frame' ) - : this._.holder; + current = this._.currentBlock; + + // ARIA role works better in IE on the body element, while on the iframe + // for FF. (#8864) + var holder = !this.forceIFrame || CKEDITOR.env.ie ? + this._.holder : this.document.getById( this.id + '_frame' ); if ( current ) { @@ -278,6 +282,9 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass( if ( blockDefinition ) CKEDITOR.tools.extend( this, blockDefinition ); + if ( !this.attributes.title ) + this.attributes.title = this.attributes[ 'aria-label' ]; + this.keys = {}; this._.focusIndex = -1; @@ -300,9 +307,11 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass( // Safari need focus on the iframe window first(#3389), but we need // lock the blur to avoid hiding the panel. - if ( CKEDITOR.env.webkit ) + if ( CKEDITOR.env.webkit || CKEDITOR.env.opera ) item.getDocument().getWindow().focus(); item.focus(); + + this.onMark && this.onMark( item ); } }, @@ -364,11 +373,12 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass( return false; case 'click' : + case 'mouseup' : index = this._.focusIndex; link = index >= 0 && this.element.getElementsByTag( 'a' ).getItem( index ); if ( link ) - link.$.click ? link.$.click() : link.$.onclick(); + link.$[ keyAction ] ? link.$[ keyAction ]() : link.$[ 'on' + keyAction ](); return false; } @@ -377,3 +387,10 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass( } } }); + +/** + * Fired when a panel is added to the document + * @name CKEDITOR#ariaWidget + * @event + * @param {Object} holder The element wrapping the panel + */