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' ],
11 function clickFn( editor )
15 if ( _.state == CKEDITOR.TRISTATE_DISABLED )
18 this.createPanel( editor );
26 _.panel.showBlock( this._.id, this.document.getById( this._.id ), 4 );
29 CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass(
31 base : CKEDITOR.ui.button,
33 $ : function( definition )
35 // We don't want the panel definition in this object.
36 var panelDefinition = definition.panel;
37 delete definition.panel;
39 this.base( definition );
41 this.document = ( panelDefinition
42 && panelDefinition.parent
43 && panelDefinition.parent.getDocument() )
46 panelDefinition.block =
48 attributes : panelDefinition.attributes
57 panelDefinition : panelDefinition
65 create : function( definition )
67 return new CKEDITOR.ui.panelButton( definition );
74 createPanel : function( editor )
81 var panelDefinition = this._.panelDefinition || {},
82 panelBlockDefinition = this._.panelDefinition.block,
83 panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
84 panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),
85 block = panel.addBlock( _.id, panelBlockDefinition ),
88 panel.onShow = function()
91 this.element.getFirst().addClass( me.className + '_panel' );
93 me.setState( CKEDITOR.TRISTATE_ON );
101 panel.onHide = function( preventOnClose )
104 this.element.getFirst().removeClass( me.className + '_panel' );
106 me.setState( me.modes && me.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
110 if ( !preventOnClose && me.onClose )
114 panel.onEscape = function()
117 me.document.getById( _.id ).focus();
121 this.onBlock( panel, block );
123 block.onHide = function()
126 me.setState( CKEDITOR.TRISTATE_OFF );
133 beforeInit : function( editor )
135 editor.ui.addHandler( CKEDITOR.UI_PANELBUTTON, CKEDITOR.ui.panelButton.handler );
144 CKEDITOR.UI_PANELBUTTON = 'panelbutton';