1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/**
* @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/
CKEDITOR.plugins.add( 'panelbutton', {
requires: 'button',
onLoad: function() {
function clickFn( editor ) {
var _ = this._;
if ( _.state == CKEDITOR.TRISTATE_DISABLED )
return;
this.createPanel( editor );
if ( _.on ) {
_.panel.hide();
return;
}
_.panel.showBlock( this._.id, this.document.getById( this._.id ), 4 );
}
/**
* @class
* @extends CKEDITOR.ui.button
* @todo class and methods
*/
CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass( {
base: CKEDITOR.ui.button,
/**
* Creates a panelButton class instance.
*
* @constructor
*/
$: function( definition ) {
// We don't want the panel definition in this object.
var panelDefinition = definition.panel || {};
delete definition.panel;
this.base( definition );
this.document = ( panelDefinition.parent && panelDefinition.parent.getDocument() ) || CKEDITOR.document;
panelDefinition.block = {
attributes: panelDefinition.attributes
};
panelDefinition.toolbarRelated = true;
this.hasArrow = true;
this.click = clickFn;
this._ = {
panelDefinition: panelDefinition
};
},
statics: {
handler: {
create: function( definition ) {
return new CKEDITOR.ui.panelButton( definition );
}
}
},
proto: {
createPanel: function( editor ) {
var _ = this._;
if ( _.panel )
return;
var panelDefinition = this._.panelDefinition,
panelBlockDefinition = this._.panelDefinition.block,
panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),
block = panel.addBlock( _.id, panelBlockDefinition ),
me = this;
panel.onShow = function() {
if ( me.className )
this.element.addClass( me.className + '_panel' );
me.setState( CKEDITOR.TRISTATE_ON );
_.on = 1;
me.editorFocus && editor.focus();
if ( me.onOpen )
me.onOpen();
};
panel.onHide = function( preventOnClose ) {
if ( me.className )
this.element.getFirst().removeClass( me.className + '_panel' );
me.setState( me.modes && me.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
_.on = 0;
if ( !preventOnClose && me.onClose )
me.onClose();
};
panel.onEscape = function() {
panel.hide( 1 );
me.document.getById( _.id ).focus();
};
if ( this.onBlock )
this.onBlock( panel, block );
block.onHide = function() {
_.on = 0;
me.setState( CKEDITOR.TRISTATE_OFF );
};
}
}
} );
},
beforeInit: function( editor ) {
editor.ui.addHandler( CKEDITOR.UI_PANELBUTTON, CKEDITOR.ui.panelButton.handler );
}
} );
/**
* Button UI element.
*
* @readonly
* @property {String} [='panelbutton']
* @member CKEDITOR
*/
CKEDITOR.UI_PANELBUTTON = 'panelbutton';
|