JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2
[ckeditor.git] / _source / plugins / contextmenu / plugin.js
index 1c83546..60aad92 100644 (file)
@@ -35,6 +35,18 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass(
                                editor.execCommand( commandName );\r
                        },\r
                        this);\r
+\r
+               this._.definiton =\r
+               {\r
+                       panel:\r
+                       {\r
+                               className : editor.skinClass + ' cke_contextmenu',\r
+                               attributes :\r
+                               {\r
+                                       'aria-label' : editor.lang.common.options\r
+                               }\r
+                       }\r
+               };\r
        },\r
 \r
        _ :\r
@@ -51,7 +63,7 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass(
                        }\r
                        else\r
                        {\r
-                               menu = this._.menu = new CKEDITOR.menu( editor );\r
+                               menu = this._.menu = new CKEDITOR.menu( editor, this._.definiton );\r
                                menu.onClick = CKEDITOR.tools.bind( function( item )\r
                                {\r
                                        menu.hide();\r
@@ -63,9 +75,26 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass(
 \r
                                }, this );\r
 \r
-                               menu.onEscape = function()\r
+                               menu.onEscape = function( keystroke )\r
                                {\r
-                                       editor.focus();\r
+                                       var parent = this.parent;\r
+                                       // 1. If it's sub-menu, restore the last focused item\r
+                                       // of upper level menu.\r
+                                       // 2. In case of a top-menu, close it.\r
+                                       if ( parent )\r
+                                       {\r
+                                               parent._.panel.hideChild();\r
+                                               // Restore parent block item focus.\r
+                                               var parentBlock = parent._.panel._.panel._.currentBlock,\r
+                                                       parentFocusIndex =  parentBlock._.focusIndex;\r
+                                               parentBlock._.markItem( parentFocusIndex );\r
+                                       }\r
+                                       else if ( keystroke == 27 )\r
+                                       {\r
+                                               this.hide();\r
+                                               editor.focus();\r
+                                       }\r
+                                       return false;\r
                                };\r
                        }\r
 \r
@@ -196,7 +225,7 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass(
 \r
                                        CKEDITOR.tools.setTimeout( function()\r
                                                {\r
-                                                       this._.onMenu( offsetParent, null, offsetX, offsetY );\r
+                                                       this.show( offsetParent, null, offsetX, offsetY );\r
                                                },\r
                                                0, this );\r
                                },\r