X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2Fpackagist%2Fludivine-ckeditor-component.git;a=blobdiff_plain;f=sources%2Fplugins%2Fpanel%2Fplugin.js;h=816ccc48b2ae4d2fd1710626172b5dd47030d7b6;hp=b64c5407c27ca3f388fd7a7b8a6f4372d1ce5a42;hb=1794320dcfdfcd19572fb1676294f9853a6bbc20;hpb=7183f6a6a21ad9124e70c997e0168459f377a9f2 diff --git a/sources/plugins/panel/plugin.js b/sources/plugins/panel/plugin.js index b64c540..816ccc4 100644 --- a/sources/plugins/panel/plugin.js +++ b/sources/plugins/panel/plugin.js @@ -99,7 +99,7 @@ parentDiv = iframe.getParent(), doc = iframe.getFrameDocument(); - // Make it scrollable on iOS. (#8308) + // Make it scrollable on iOS. (http://dev.ckeditor.com/ticket/8308) CKEDITOR.env.iOS && parentDiv.setStyles( { 'overflow': 'scroll', '-webkit-overflow-scrolling': 'touch' @@ -121,7 +121,7 @@ // Register the CKEDITOR global. win.$.CKEDITOR = CKEDITOR; - // Arrow keys for scrolling is only preventable with 'keypress' event in Opera (#4534). + // Arrow keys for scrolling is only preventable with 'keypress' event in Opera (http://dev.ckeditor.com/ticket/4534). doc.on( 'keydown', function( evt ) { var keystroke = evt.data.getKeystroke(), dir = this.document.getById( this.id ).getAttribute( 'dir' ); @@ -219,7 +219,7 @@ current = this._.currentBlock; // ARIA role works better in IE on the body element, while on the iframe - // for FF. (#8864) + // for FF. (http://dev.ckeditor.com/ticket/8864) var holder = !this.forceIFrame || CKEDITOR.env.ie ? this._.holder : this.document.getById( this.id + '_frame' ); if ( current ) @@ -300,13 +300,68 @@ 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 + // Safari need focus on the iframe window first(http://dev.ckeditor.com/ticket/3389), but we need // lock the blur to avoid hiding the panel. if ( CKEDITOR.env.webkit ) item.getDocument().getWindow().focus(); item.focus(); this.onMark && this.onMark( item ); + }, + + /** + * Marks the first visible item or the one whose `aria-selected` attribute is set to `true`. + * The latter has priority over the former. + * + * @private + * @param beforeMark function to be executed just before marking. + * Used in cases when any preparatory cleanup (like unmarking all items) would simultaneously + * destroy the information that is needed to determine the focused item. + */ + markFirstDisplayed: function( beforeMark ) { + var notDisplayed = function( element ) { + return element.type == CKEDITOR.NODE_ELEMENT && element.getStyle( 'display' ) == 'none'; + }, + links = this._.getItems(), + item, focused; + + for ( var i = links.count() - 1; i >= 0; i-- ) { + item = links.getItem( i ); + + if ( !item.getAscendant( notDisplayed ) ) { + focused = item; + this._.focusIndex = i; + } + + if ( item.getAttribute( 'aria-selected' ) == 'true' ) { + focused = item; + this._.focusIndex = i; + break; + } + } + + if ( !focused ) { + return; + } + + if ( beforeMark ) { + beforeMark(); + } + + if ( CKEDITOR.env.webkit ) + focused.getDocument().getWindow().focus(); + focused.focus(); + + this.onMark && this.onMark( focused ); + }, + + /** + * Returns a `CKEDITOR.dom.nodeList` of block items. + * + * @returns {*|CKEDITOR.dom.nodeList} + */ + getItems: function() { + return this.element.getElementsByTag( 'a' ); } }, @@ -340,7 +395,7 @@ } } - // If no link was found, cycle and restart from the top. (#11125) + // If no link was found, cycle and restart from the top. (http://dev.ckeditor.com/ticket/11125) if ( !link && !noCycle ) { this._.focusIndex = -1; return this.onKeyDown( keystroke, 1 ); @@ -364,11 +419,11 @@ } // Make sure link is null when the loop ends and nothing was - // found (#11125). + // found (http://dev.ckeditor.com/ticket/11125). link = null; } - // If no link was found, cycle and restart from the bottom. (#11125) + // If no link was found, cycle and restart from the bottom. (http://dev.ckeditor.com/ticket/11125) if ( !link && !noCycle ) { this._.focusIndex = links.count(); return this.onKeyDown( keystroke, 1 );