6f0753179740fae46a600915e5666fa49c2bb778
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
6 CKEDITOR
.plugins
.add( 'menubutton',
8 requires
: [ 'button', 'menu' ],
9 beforeInit : function( editor
)
11 editor
.ui
.addHandler( CKEDITOR
.UI_MENUBUTTON
, CKEDITOR
.ui
.menuButton
.handler
);
20 CKEDITOR
.UI_MENUBUTTON
= 'menubutton';
24 var clickFn = function( editor
)
28 // Do nothing if this button is disabled.
29 if ( _
.state
=== CKEDITOR
.TRISTATE_DISABLED
)
32 _
.previousState
= _
.state
;
34 // Check if we already have a menu for it, otherwise just create it.
38 menu
= _
.menu
= new CKEDITOR
.menu( editor
,
42 className
: editor
.skinClass
+ ' cke_contextmenu',
43 attributes
: { 'aria-label' : editor
.lang
.common
.options
}
47 menu
.onHide
= CKEDITOR
.tools
.bind( function()
49 this.setState( this.modes
&& this.modes
[ editor
.mode
] ? _
.previousState
: CKEDITOR
.TRISTATE_DISABLED
);
53 // Initialize the menu items at this point.
55 menu
.addListener( this.onMenu
);
64 this.setState( CKEDITOR
.TRISTATE_ON
);
66 menu
.show( CKEDITOR
.document
.getById( this._
.id
), 4 );
70 CKEDITOR
.ui
.menuButton
= CKEDITOR
.tools
.createClass(
72 base
: CKEDITOR
.ui
.button
,
74 $ : function( definition
)
76 // We don't want the panel definition in this object.
77 var panelDefinition
= definition
.panel
;
78 delete definition
.panel
;
80 this.base( definition
);
91 create : function( definition
)
93 return new CKEDITOR
.ui
.menuButton( definition
);