X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fmenu%2Fplugin.js;h=0165d31041297c431818dc672e997019b615397a;hp=731fed4afac65f7ba24aa3b7a72e6a9ab7585ca2;hb=refs%2Ftags%2Fv3.6.1;hpb=4e70ea24db840898be8cc21c950363a52a2a6aba diff --git a/_source/plugins/menu/plugin.js b/_source/plugins/menu/plugin.js index 731fed4..0165d31 100644 --- a/_source/plugins/menu/plugin.js +++ b/_source/plugins/menu/plugin.js @@ -14,17 +14,36 @@ CKEDITOR.plugins.add( 'menu', for ( var i = 0 ; i < groups.length ; i++ ) groupsOrder[ groups[ i ] ] = i + 1; + /** + * Registers an item group to the editor context menu in order to make it + * possible to associate it with menu items later. + * @name CKEDITOR.editor.prototype.addMenuGroup + * @param {String} name Specify a group name. + * @param {Number} [order=100] Define the display sequence of this group + * inside the menu. A smaller value gets displayed first. + */ editor.addMenuGroup = function( name, order ) { groupsOrder[ name ] = order || 100; }; + /** + * Adds an item from the specified definition to the editor context menu. + * @name CKEDITOR.editor.prototype.addMenuItem + * @param {String} name The menu item name. + * @param {CKEDITOR.menu.definition} definition The menu item definition. + */ editor.addMenuItem = function( name, definition ) { if ( groupsOrder[ definition.group ] ) menuItems[ name ] = new CKEDITOR.menuItem( this, name, definition ); }; + /** + * Adds one or more items from the specified definition array to the editor context menu. + * @name CKEDITOR.editor.prototype.addMenuItems + * @param {Array} definitions List of definitions for each menu item as if {@link CKEDITOR.editor.addMenuItem} is called. + */ editor.addMenuItems = function( definitions ) { for ( var itemName in definitions ) @@ -33,10 +52,27 @@ CKEDITOR.plugins.add( 'menu', } }; + /** + * Retrieves a particular menu item definition from the editor context menu. + * @name CKEDITOR.editor.prototype.getMenuItem + * @param {String} name The name of the desired menu item. + * @return {CKEDITOR.menu.definition} + */ editor.getMenuItem = function( name ) { return menuItems[ name ]; }; + + /** + * Removes a particular menu item added before from the editor context menu. + * @name CKEDITOR.editor.prototype.removeMenuItem + * @param {String} name The name of the desired menu item. + * @since 3.6.1 + */ + editor.removeMenuItem = function( name ) + { + delete menuItems[ name ]; + }; }, requires : [ 'floatpanel' ] @@ -109,7 +145,7 @@ CKEDITOR.plugins.add( 'menu', onClick : function( item ) { - this.hide(); + this.hide( false ); if ( item.onClick ) item.onClick(); @@ -132,10 +168,8 @@ CKEDITOR.plugins.add( 'menu', parentBlock._.markItem( parentFocusIndex ); } else if ( keystroke == 27 ) - { this.hide(); - this.editor.focus(); - } + return false; }, @@ -265,8 +299,9 @@ CKEDITOR.plugins.add( 'menu', keys[ 9 ] = 'next'; // TAB keys[ 38 ] = 'prev'; // ARROW-UP keys[ CKEDITOR.SHIFT + 9 ] = 'prev'; // SHIFT + TAB - keys[ 32 ] = 'click'; // SPACE - keys[ ( editor.lang.dir == 'rtl' ? 37 : 39 ) ] = 'click'; // ARROW-RIGHT/ARROW-LEFT(rtl) + keys[ ( editor.lang.dir == 'rtl' ? 37 : 39 ) ]= CKEDITOR.env.ie ? 'mouseup' : 'click'; // ARROW-RIGHT/ARROW-LEFT(rtl) + keys[ 32 ] = CKEDITOR.env.ie ? 'mouseup' : 'click'; // SPACE + CKEDITOR.env.ie && ( keys[ 13 ] = 'mouseup' ); // Manage ENTER, since onclick is blocked in IE (#8041). element = this._.element = block.element; element.addClass( editor.skinClass ); @@ -351,10 +386,10 @@ CKEDITOR.plugins.add( 'menu', this._.listeners.push( listenerFn ); }, - hide : function() + hide : function( returnFocus ) { this._.onHide && this._.onHide(); - this._.panel && this._.panel.hide(); + this._.panel && this._.panel.hide( returnFocus ); } } }); @@ -444,8 +479,9 @@ CKEDITOR.plugins.add( 'menu', output.push( // ' onkeydown="return CKEDITOR.ui.button._.keydown(', index, ', event);"' + ' onmouseover="CKEDITOR.tools.callFunction(', menu._.itemOverFn, ',', index, ');"' + - ' onmouseout="CKEDITOR.tools.callFunction(', menu._.itemOutFn, ',', index, ');"' + - ' onclick="CKEDITOR.tools.callFunction(', menu._.itemClickFn, ',', index, '); return false;"' + + ' onmouseout="CKEDITOR.tools.callFunction(', menu._.itemOutFn, ',', index, ');" ' + + ( CKEDITOR.env.ie ? 'onclick="return false;" onmouseup' : 'onclick' ) + // #188 + '="CKEDITOR.tools.callFunction(', menu._.itemClickFn, ',', index, '); return false;"' + '>' + '