From 1794320dcfdfcd19572fb1676294f9853a6bbc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 4 Dec 2017 18:55:29 +0100 Subject: Update to 4.7.3 --- sources/plugins/panel/plugin.js | 69 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 7 deletions(-) (limited to 'sources/plugins/panel') 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 ); -- cgit v1.2.3