aboutsummaryrefslogtreecommitdiff
path: root/sources/plugins/menubutton/plugin.js
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-01-25 17:45:33 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-01-25 18:00:33 +0100
commit7adcb81e4f83f98c468889aaa5a85558ba88c770 (patch)
tree0d6ede733777b29060b48df4afaa2c64bfbae276 /sources/plugins/menubutton/plugin.js
downloadconnexionswing-ckeditor-component-7adcb81e4f83f98c468889aaa5a85558ba88c770.tar.gz
connexionswing-ckeditor-component-7adcb81e4f83f98c468889aaa5a85558ba88c770.tar.zst
connexionswing-ckeditor-component-7adcb81e4f83f98c468889aaa5a85558ba88c770.zip
Initial commit4.5.6
Diffstat (limited to 'sources/plugins/menubutton/plugin.js')
-rw-r--r--sources/plugins/menubutton/plugin.js101
1 files changed, 101 insertions, 0 deletions
diff --git a/sources/plugins/menubutton/plugin.js b/sources/plugins/menubutton/plugin.js
new file mode 100644
index 00000000..7f57f876
--- /dev/null
+++ b/sources/plugins/menubutton/plugin.js
@@ -0,0 +1,101 @@
1/**
2 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
4 */
5
6CKEDITOR.plugins.add( 'menubutton', {
7 requires: 'button,menu',
8 onLoad: function() {
9 var clickFn = function( editor ) {
10 var _ = this._,
11 menu = _.menu;
12
13 // Do nothing if this button is disabled.
14 if ( _.state === CKEDITOR.TRISTATE_DISABLED )
15 return;
16
17 if ( _.on && menu ) {
18 menu.hide();
19 return;
20 }
21
22 _.previousState = _.state;
23
24 // Check if we already have a menu for it, otherwise just create it.
25 if ( !menu ) {
26 menu = _.menu = new CKEDITOR.menu( editor, {
27 panel: {
28 className: 'cke_menu_panel',
29 attributes: { 'aria-label': editor.lang.common.options }
30 }
31 } );
32
33 menu.onHide = CKEDITOR.tools.bind( function() {
34 var modes = this.command ? editor.getCommand( this.command ).modes : this.modes;
35 this.setState( !modes || modes[ editor.mode ] ? _.previousState : CKEDITOR.TRISTATE_DISABLED );
36 _.on = 0;
37 }, this );
38
39 // Initialize the menu items at this point.
40 if ( this.onMenu )
41 menu.addListener( this.onMenu );
42 }
43
44 this.setState( CKEDITOR.TRISTATE_ON );
45 _.on = 1;
46
47 // This timeout is needed to give time for the panel get focus
48 // when JAWS is running. (#9842)
49 setTimeout( function() {
50 menu.show( CKEDITOR.document.getById( _.id ), 4 );
51 }, 0 );
52 };
53
54 /**
55 * @class
56 * @extends CKEDITOR.ui.button
57 * @todo
58 */
59 CKEDITOR.ui.menuButton = CKEDITOR.tools.createClass( {
60 base: CKEDITOR.ui.button,
61
62 /**
63 * Creates a menuButton class instance.
64 *
65 * @constructor
66 * @param Object definition
67 * @todo
68 */
69 $: function( definition ) {
70 // We don't want the panel definition in this object.
71 delete definition.panel;
72
73 this.base( definition );
74
75 this.hasArrow = true;
76
77 this.click = clickFn;
78 },
79
80 statics: {
81 handler: {
82 create: function( definition ) {
83 return new CKEDITOR.ui.menuButton( definition );
84 }
85 }
86 }
87 } );
88 },
89 beforeInit: function( editor ) {
90 editor.ui.addHandler( CKEDITOR.UI_MENUBUTTON, CKEDITOR.ui.menuButton.handler );
91 }
92} );
93
94/**
95 * Button UI element.
96 *
97 * @readonly
98 * @property {String} [='menubutton']
99 * @member CKEDITOR
100 */
101CKEDITOR.UI_MENUBUTTON = 'menubutton';