2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
6 CKEDITOR.plugins.add( 'panelbutton',
\r
8 requires : [ 'button' ],
\r
9 beforeInit : function( editor )
\r
11 editor.ui.addHandler( CKEDITOR.UI_PANELBUTTON, CKEDITOR.ui.panelButton.handler );
\r
16 * Button UI element.
\r
20 CKEDITOR.UI_PANELBUTTON = 4;
\r
24 var clickFn = function( editor )
\r
28 if ( _.state == CKEDITOR.TRISTATE_DISABLED )
\r
31 this.createPanel( editor );
\r
39 _.panel.showBlock( this._.id, this.document.getById( this._.id ), 4 );
\r
43 CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass(
\r
45 base : CKEDITOR.ui.button,
\r
47 $ : function( definition )
\r
49 // We don't want the panel definition in this object.
\r
50 var panelDefinition = definition.panel;
\r
51 delete definition.panel;
\r
53 this.base( definition );
\r
55 this.document = ( panelDefinition
\r
56 && panelDefinition.parent
\r
57 && panelDefinition.parent.getDocument() )
\r
58 || CKEDITOR.document;
\r
60 this.hasArrow = true;
\r
62 this.click = clickFn;
\r
66 panelDefinition : panelDefinition
\r
74 create : function( definition )
\r
76 return new CKEDITOR.ui.panelButton( definition );
\r
83 createPanel : function( editor )
\r
90 var panelDefinition = this._.panelDefinition || {},
\r
91 panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
\r
92 panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),
\r
95 panel.onShow = function()
\r
98 this.element.getFirst().addClass( me.className + '_panel' );
\r
100 _.oldState = me._.state;
\r
101 me.setState( CKEDITOR.TRISTATE_ON );
\r
109 panel.onHide = function()
\r
111 if ( me.className )
\r
112 this.element.getFirst().removeClass( me.className + '_panel' );
\r
114 me.setState( _.oldState );
\r
122 panel.onEscape = function()
\r
125 me.document.getById( _.id ).focus();
\r
128 if ( this.onBlock )
\r
129 this.onBlock( panel, _.id );
\r
131 panel.getBlock( _.id ).onHide = function()
\r
134 me.setState( CKEDITOR.TRISTATE_OFF );
\r