JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.1
[ckeditor.git] / _source / plugins / menu / plugin.js
index 731fed4..0165d31 100644 (file)
@@ -14,17 +14,36 @@ CKEDITOR.plugins.add( 'menu',
                for ( var i = 0 ; i < groups.length ; i++ )\r
                        groupsOrder[ groups[ i ] ] = i + 1;\r
 \r
+               /**\r
+                * Registers an item group to the editor context menu in order to make it\r
+                * possible to associate it with menu items later.\r
+                * @name CKEDITOR.editor.prototype.addMenuGroup\r
+                * @param {String} name Specify a group name.\r
+                * @param {Number} [order=100] Define the display sequence of this group\r
+                *      inside the menu. A smaller value gets displayed first.\r
+                */\r
                editor.addMenuGroup = function( name, order )\r
                        {\r
                                groupsOrder[ name ] = order || 100;\r
                        };\r
 \r
+               /**\r
+                * Adds an item from the specified definition to the editor context menu.\r
+                * @name CKEDITOR.editor.prototype.addMenuItem\r
+                * @param {String} name The menu item name.\r
+                * @param {CKEDITOR.menu.definition} definition The menu item definition.\r
+                */\r
                editor.addMenuItem = function( name, definition )\r
                        {\r
                                if ( groupsOrder[ definition.group ] )\r
                                        menuItems[ name ] = new CKEDITOR.menuItem( this, name, definition );\r
                        };\r
 \r
+               /**\r
+                * Adds one or more items from the specified definition array to the editor context menu.\r
+                * @name CKEDITOR.editor.prototype.addMenuItems\r
+                * @param {Array} definitions List of definitions for each menu item as if {@link CKEDITOR.editor.addMenuItem} is called.\r
+                */\r
                editor.addMenuItems = function( definitions )\r
                        {\r
                                for ( var itemName in definitions )\r
@@ -33,10 +52,27 @@ CKEDITOR.plugins.add( 'menu',
                                }\r
                        };\r
 \r
+               /**\r
+                * Retrieves a particular menu item definition from the editor context menu.\r
+                * @name CKEDITOR.editor.prototype.getMenuItem\r
+                * @param {String} name The name of the desired menu item.\r
+                * @return {CKEDITOR.menu.definition}\r
+                */\r
                editor.getMenuItem = function( name )\r
                        {\r
                                return menuItems[ name ];\r
                        };\r
+\r
+               /**\r
+                * Removes a particular menu item added before from the editor context menu.\r
+                * @name CKEDITOR.editor.prototype.removeMenuItem\r
+                * @param {String} name The name of the desired menu item.\r
+                * @since 3.6.1\r
+                */\r
+               editor.removeMenuItem = function( name )\r
+                       {\r
+                               delete menuItems[ name ];\r
+                       };\r
        },\r
 \r
        requires : [ 'floatpanel' ]\r
@@ -109,7 +145,7 @@ CKEDITOR.plugins.add( 'menu',
 \r
                        onClick : function( item )\r
                        {\r
-                               this.hide();\r
+                               this.hide( false );\r
 \r
                                if ( item.onClick )\r
                                        item.onClick();\r
@@ -132,10 +168,8 @@ CKEDITOR.plugins.add( 'menu',
                                        parentBlock._.markItem( parentFocusIndex );\r
                                }\r
                                else if ( keystroke == 27 )\r
-                               {\r
                                        this.hide();\r
-                                       this.editor.focus();\r
-                               }\r
+\r
                                return false;\r
                        },\r
 \r
@@ -265,8 +299,9 @@ CKEDITOR.plugins.add( 'menu',
                                        keys[ 9 ]       = 'next';                                       // TAB\r
                                        keys[ 38 ]      = 'prev';                                       // ARROW-UP\r
                                        keys[ CKEDITOR.SHIFT + 9 ]      = 'prev';       // SHIFT + TAB\r
-                                       keys[ 32 ]      = 'click';                                      // SPACE\r
-                                       keys[ ( editor.lang.dir == 'rtl' ? 37 : 39 ) ]  = 'click';  // ARROW-RIGHT/ARROW-LEFT(rtl)\r
+                                       keys[ ( editor.lang.dir == 'rtl' ? 37 : 39 ) ]= CKEDITOR.env.ie ? 'mouseup' : 'click';  // ARROW-RIGHT/ARROW-LEFT(rtl)\r
+                                       keys[ 32 ]      = CKEDITOR.env.ie ? 'mouseup' : 'click';                                        // SPACE\r
+                                       CKEDITOR.env.ie && ( keys[ 13 ] = 'mouseup' );          // Manage ENTER, since onclick is blocked in IE (#8041).\r
 \r
                                        element = this._.element = block.element;\r
                                        element.addClass( editor.skinClass );\r
@@ -351,10 +386,10 @@ CKEDITOR.plugins.add( 'menu',
                                this._.listeners.push( listenerFn );\r
                        },\r
 \r
-                       hide : function()\r
+                       hide : function( returnFocus )\r
                        {\r
                                this._.onHide && this._.onHide();\r
-                               this._.panel && this._.panel.hide();\r
+                               this._.panel && this._.panel.hide( returnFocus );\r
                        }\r
                }\r
        });\r
@@ -444,8 +479,9 @@ CKEDITOR.plugins.add( 'menu',
                                output.push(\r
 //                                     ' onkeydown="return CKEDITOR.ui.button._.keydown(', index, ', event);"' +\r
                                        ' onmouseover="CKEDITOR.tools.callFunction(', menu._.itemOverFn, ',', index, ');"' +\r
-                                       ' onmouseout="CKEDITOR.tools.callFunction(', menu._.itemOutFn, ',', index, ');"' +\r
-                                       ' onclick="CKEDITOR.tools.callFunction(', menu._.itemClickFn, ',', index, '); return false;"' +\r
+                                       ' onmouseout="CKEDITOR.tools.callFunction(', menu._.itemOutFn, ',', index, ');" ' +\r
+                                       ( CKEDITOR.env.ie ? 'onclick="return false;" onmouseup' : 'onclick' ) +         // #188\r
+                                               '="CKEDITOR.tools.callFunction(', menu._.itemClickFn, ',', index, '); return false;"' +\r
                                        '>' +\r
                                                '<span class="cke_icon_wrapper"><span class="cke_icon"' +\r
                                                        ( this.icon ? ' style="background-image:url(' + CKEDITOR.getUrl( this.icon ) + ');background-position:0 ' + offset + 'px;"'\r
@@ -478,8 +514,8 @@ CKEDITOR.plugins.add( 'menu',
 \r
 \r
 /**\r
- * The amount of time, in milliseconds, the editor waits before showing submenu\r
- * options when moving the mouse over options that contains submenus, like the\r
+ * The amount of time, in milliseconds, the editor waits before displaying submenu\r
+ * options when moving the mouse over options that contain submenus, like the\r
  * "Cell Properties" entry for tables.\r
  * @type Number\r
  * @default 400\r
@@ -490,8 +526,8 @@ CKEDITOR.plugins.add( 'menu',
 \r
 /**\r
  * A comma separated list of items group names to be displayed in the context\r
- * menu. The items order will reflect the order in this list if no priority\r
- * has been definted in the groups.\r
+ * menu. The order of items will reflect the order specified in this list if\r
+ * no priority was defined in the groups.\r
  * @type String\r
  * @default 'clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea'\r
  * @example\r