Nation Notes module contributed by Z&H Healthcare.
[openemr.git] / library / custom_template / ckeditor / _source / plugins / panelbutton / plugin.js
blobec8ad6ed17b13f4da1ae0183c28cce3556c3801e
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
6 CKEDITOR.plugins.add( 'panelbutton',
8         requires : [ 'button' ],
9         beforeInit : function( editor )
10         {
11                 editor.ui.addHandler( CKEDITOR.UI_PANELBUTTON, CKEDITOR.ui.panelButton.handler );
12         }
13 });
15 /**
16  * Button UI element.
17  * @constant
18  * @example
19  */
20 CKEDITOR.UI_PANELBUTTON = 4;
22 (function()
24         var clickFn = function( editor )
25         {
26                 var _ = this._;
28                 if ( _.state == CKEDITOR.TRISTATE_DISABLED )
29                         return;
31                 this.createPanel( editor );
33                 if ( _.on )
34                 {
35                         _.panel.hide();
36                         return;
37                 }
39                 _.panel.showBlock( this._.id, this.document.getById( this._.id ), 4 );
40         };
43         CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass(
44         {
45                 base : CKEDITOR.ui.button,
47                 $ : function( definition )
48                 {
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() )
58                                                         || CKEDITOR.document;
60                         panelDefinition.block =
61                         {
62                                 attributes : panelDefinition.attributes
63                         };
65                         this.hasArrow = true;
67                         this.click = clickFn;
69                         this._ =
70                         {
71                                 panelDefinition : panelDefinition
72                         };
73                 },
75                 statics :
76                 {
77                         handler :
78                         {
79                                 create : function( definition )
80                                 {
81                                         return new CKEDITOR.ui.panelButton( definition );
82                                 }
83                         }
84                 },
86                 proto :
87                 {
88                         createPanel : function( editor )
89                         {
90                                 var _ = this._;
92                                 if ( _.panel )
93                                         return;
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 ),
100                                         me = this;
102                                 panel.onShow = function()
103                                         {
104                                                 if ( me.className )
105                                                         this.element.getFirst().addClass( me.className + '_panel' );
107                                                 me.setState( CKEDITOR.TRISTATE_ON );
109                                                 _.on = 1;
111                                                 if ( me.onOpen )
112                                                         me.onOpen();
113                                         };
115                                 panel.onHide = function( preventOnClose )
116                                         {
117                                                 if ( me.className )
118                                                         this.element.getFirst().removeClass( me.className + '_panel' );
120                                                 me.setState( me.modes && me.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
122                                                 _.on = 0;
124                                                 if ( !preventOnClose && me.onClose )
125                                                         me.onClose();
126                                         };
128                                 panel.onEscape = function()
129                                         {
130                                                 panel.hide();
131                                                 me.document.getById( _.id ).focus();
132                                         };
134                                 if ( this.onBlock )
135                                         this.onBlock( panel, block );
137                                 block.onHide = function()
138                                         {
139                                                 _.on = 0;
140                                                 me.setState( CKEDITOR.TRISTATE_OFF );
141                                         };
142                         }
143                 }
144         });
146 })();