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