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( 'panelbutton',
8 requires : [ 'button' ],
9 beforeInit : function( editor )
11 editor.ui.addHandler( CKEDITOR.UI_PANELBUTTON, CKEDITOR.ui.panelButton.handler );
20 CKEDITOR.UI_PANELBUTTON = 4;
24 var clickFn = function( editor )
28 if ( _.state == CKEDITOR.TRISTATE_DISABLED )
31 this.createPanel( editor );
39 _.panel.showBlock( this._.id, this.document.getById( this._.id ), 4 );
43 CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass(
45 base : CKEDITOR.ui.button,
47 $ : function( definition )
49 // We don't want the panel definition in this object.
50 var panelDefinition = definition.panel;
51 delete definition.panel;
53 this.base( definition );
55 this.document = ( panelDefinition
56 && panelDefinition.parent
57 && panelDefinition.parent.getDocument() )
60 panelDefinition.block =
62 attributes : panelDefinition.attributes
71 panelDefinition : panelDefinition
79 create : function( definition )
81 return new CKEDITOR.ui.panelButton( definition );
88 createPanel : function( editor )
95 var panelDefinition = this._.panelDefinition || {},
96 panelBlockDefinition = this._.panelDefinition.block,
97 panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
98 panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),
99 block = panel.addBlock( _.id, panelBlockDefinition ),
102 panel.onShow = function()
105 this.element.getFirst().addClass( me.className + '_panel' );
107 me.setState( CKEDITOR.TRISTATE_ON );
115 panel.onHide = function( preventOnClose )
118 this.element.getFirst().removeClass( me.className + '_panel' );
120 me.setState( me.modes && me.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
124 if ( !preventOnClose && me.onClose )
128 panel.onEscape = function()
131 me.document.getById( _.id ).focus();
135 this.onBlock( panel, block );
137 block.onHide = function()
140 me.setState( CKEDITOR.TRISTATE_OFF );