JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.2
[ckeditor.git] / _source / plugins / panel / plugin.js
index 181fae3..920faa1 100644 (file)
@@ -31,7 +31,7 @@ CKEDITOR.ui.panel = function( document, definition )
                        css : []\r
                });\r
 \r
-       this.id = CKEDITOR.tools.getNextNumber();\r
+       this.id = CKEDITOR.tools.getNextId();\r
        this.document = document;\r
 \r
        this._ =\r
@@ -73,7 +73,7 @@ CKEDITOR.ui.panel.prototype =
         */\r
        render : function( editor, output )\r
        {\r
-               var id = 'cke_' + this.id;\r
+               var id = this.id;\r
 \r
                output.push(\r
                        '<div class="', editor.skinClass ,'"' +\r
@@ -130,7 +130,7 @@ CKEDITOR.ui.panel.prototype =
                {\r
                        if ( this.forceIFrame || this.css.length )\r
                        {\r
-                               var iframe = this.document.getById( 'cke_' + this.id + '_frame' ),\r
+                               var iframe = this.document.getById( this.id + '_frame' ),\r
                                        parentDiv = iframe.getParent(),\r
                                        dir = parentDiv.getAttribute( 'dir' ),\r
                                        className = parentDiv.getParent().getAttribute( 'class' ),\r
@@ -170,10 +170,11 @@ CKEDITOR.ui.panel.prototype =
                                // Register the CKEDITOR global.\r
                                win.$.CKEDITOR = CKEDITOR;\r
 \r
-                               doc.on( 'keydown', function( evt )\r
+                               // Arrow keys for scrolling is only preventable with 'keypress' event in Opera (#4534).\r
+                               doc.on( 'key' + ( CKEDITOR.env.opera? 'press':'down' ), function( evt )\r
                                        {\r
                                                var keystroke = evt.data.getKeystroke(),\r
-                                                       dir = this.document.getById( 'cke_' + this.id ).getAttribute( 'dir' );\r
+                                                       dir = this.document.getById( this.id ).getAttribute( 'dir' );\r
 \r
                                                // Delegate key processing to block.\r
                                                if ( this._.onKeyDown && this._.onKeyDown( keystroke ) === false )\r
@@ -186,15 +187,16 @@ CKEDITOR.ui.panel.prototype =
                                                if ( keystroke == 27 || keystroke == ( dir == 'rtl' ? 39 : 37 ) )\r
                                                {\r
                                                        if ( this.onEscape && this.onEscape( keystroke ) === false )\r
-                                                               evt.data.preventDefault( );\r
+                                                               evt.data.preventDefault();\r
                                                }\r
                                        },\r
                                        this );\r
 \r
                                holder = doc.getBody();\r
+                               holder.unselectable();\r
                        }\r
                        else\r
-                               holder = this.document.getById( 'cke_' + this.id );\r
+                               holder = this.document.getById( this.id );\r
 \r
                        this._.holder = holder;\r
                }\r
@@ -224,9 +226,12 @@ CKEDITOR.ui.panel.prototype =
                        block = blocks[ name ],\r
                        current = this._.currentBlock,\r
                        holder = this.forceIFrame ?\r
-                               this.document.getById( 'cke_' + this.id + '_frame' )\r
+                               this.document.getById( this.id + '_frame' )\r
                                : this._.holder;\r
 \r
+               // Disable context menu for block panel.\r
+               holder.getParent().getParent().disableContextMenu();\r
+\r
                if ( current )\r
                {\r
                        // Clean up the current block's effects on holder.\r
@@ -244,6 +249,16 @@ CKEDITOR.ui.panel.prototype =
 \r
                this._.onKeyDown = block.onKeyDown && CKEDITOR.tools.bind( block.onKeyDown, block );\r
 \r
+               block.onMark = function( item )\r
+               {\r
+                       holder.setAttribute( 'aria-activedescendant', item.getId() + '_option' );\r
+               };\r
+\r
+               block.onUnmark = function()\r
+               {\r
+                       holder.removeAttribute( 'aria-activedescendant' );\r
+               };\r
+\r
                block.show();\r
 \r
                return block;\r
@@ -278,6 +293,9 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass(
                if ( blockDefinition )\r
                        CKEDITOR.tools.extend( this, blockDefinition );\r
 \r
+               if ( !this.attributes.title )\r
+                       this.attributes.title = this.attributes[ 'aria-label' ];\r
+\r
                this.keys = {};\r
 \r
                this._.focusIndex = -1;\r
@@ -300,9 +318,11 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass(
 \r
                        // Safari need focus on the iframe window first(#3389), but we need\r
                        // lock the blur to avoid hiding the panel.\r
-                       if ( CKEDITOR.env.webkit )\r
+                       if ( CKEDITOR.env.webkit || CKEDITOR.env.opera )\r
                                item.getDocument().getWindow().focus();\r
                        item.focus();\r
+\r
+                       this.onMark && this.onMark( item );\r
                }\r
        },\r
 \r