]> git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/plugins/menubutton/plugin.js
Upgrade to 4.5.7 and add some plugin
[perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git] / sources / plugins / menubutton / plugin.js
1 /**
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
4 */
5
6 CKEDITOR.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 */
101 CKEDITOR.UI_MENUBUTTON = 'menubutton';