]> git.immae.eu Git - perso/Immae/Projets/packagist/ludivine-ckeditor-component.git/blobdiff - sources/plugins/panelbutton/plugin.js
Add audio, color and fonts
[perso/Immae/Projets/packagist/ludivine-ckeditor-component.git] / sources / plugins / panelbutton / plugin.js
diff --git a/sources/plugins/panelbutton/plugin.js b/sources/plugins/panelbutton/plugin.js
new file mode 100644 (file)
index 0000000..111d475
--- /dev/null
@@ -0,0 +1,138 @@
+/**\r
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.\r
+ * For licensing, see LICENSE.md or http://ckeditor.com/license\r
+ */\r
+\r
+CKEDITOR.plugins.add( 'panelbutton', {\r
+       requires: 'button',\r
+       onLoad: function() {\r
+               function clickFn( editor ) {\r
+                       var _ = this._;\r
+\r
+                       if ( _.state == CKEDITOR.TRISTATE_DISABLED )\r
+                               return;\r
+\r
+                       this.createPanel( editor );\r
+\r
+                       if ( _.on ) {\r
+                               _.panel.hide();\r
+                               return;\r
+                       }\r
+\r
+                       _.panel.showBlock( this._.id, this.document.getById( this._.id ), 4 );\r
+               }\r
+\r
+               /**\r
+                * @class\r
+                * @extends CKEDITOR.ui.button\r
+                * @todo class and methods\r
+                */\r
+               CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass( {\r
+                       base: CKEDITOR.ui.button,\r
+\r
+                       /**\r
+                        * Creates a panelButton class instance.\r
+                        *\r
+                        * @constructor\r
+                        */\r
+                       $: function( definition ) {\r
+                               // We don't want the panel definition in this object.\r
+                               var panelDefinition = definition.panel || {};\r
+                               delete definition.panel;\r
+\r
+                               this.base( definition );\r
+\r
+                               this.document = ( panelDefinition.parent && panelDefinition.parent.getDocument() ) || CKEDITOR.document;\r
+\r
+                               panelDefinition.block = {\r
+                                       attributes: panelDefinition.attributes\r
+                               };\r
+                               panelDefinition.toolbarRelated = true;\r
+\r
+                               this.hasArrow = true;\r
+\r
+                               this.click = clickFn;\r
+\r
+                               this._ = {\r
+                                       panelDefinition: panelDefinition\r
+                               };\r
+                       },\r
+\r
+                       statics: {\r
+                               handler: {\r
+                                       create: function( definition ) {\r
+                                               return new CKEDITOR.ui.panelButton( definition );\r
+                                       }\r
+                               }\r
+                       },\r
+\r
+                       proto: {\r
+                               createPanel: function( editor ) {\r
+                                       var _ = this._;\r
+\r
+                                       if ( _.panel )\r
+                                               return;\r
+\r
+                                       var panelDefinition = this._.panelDefinition,\r
+                                               panelBlockDefinition = this._.panelDefinition.block,\r
+                                               panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),\r
+                                               panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),\r
+                                               block = panel.addBlock( _.id, panelBlockDefinition ),\r
+                                               me = this;\r
+\r
+                                       panel.onShow = function() {\r
+                                               if ( me.className )\r
+                                                       this.element.addClass( me.className + '_panel' );\r
+\r
+                                               me.setState( CKEDITOR.TRISTATE_ON );\r
+\r
+                                               _.on = 1;\r
+\r
+                                               me.editorFocus && editor.focus();\r
+\r
+                                               if ( me.onOpen )\r
+                                                       me.onOpen();\r
+                                       };\r
+\r
+                                       panel.onHide = function( preventOnClose ) {\r
+                                               if ( me.className )\r
+                                                       this.element.getFirst().removeClass( me.className + '_panel' );\r
+\r
+                                               me.setState( me.modes && me.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );\r
+\r
+                                               _.on = 0;\r
+\r
+                                               if ( !preventOnClose && me.onClose )\r
+                                                       me.onClose();\r
+                                       };\r
+\r
+                                       panel.onEscape = function() {\r
+                                               panel.hide( 1 );\r
+                                               me.document.getById( _.id ).focus();\r
+                                       };\r
+\r
+                                       if ( this.onBlock )\r
+                                               this.onBlock( panel, block );\r
+\r
+                                       block.onHide = function() {\r
+                                               _.on = 0;\r
+                                               me.setState( CKEDITOR.TRISTATE_OFF );\r
+                                       };\r
+                               }\r
+                       }\r
+               } );\r
+\r
+       },\r
+       beforeInit: function( editor ) {\r
+               editor.ui.addHandler( CKEDITOR.UI_PANELBUTTON, CKEDITOR.ui.panelButton.handler );\r
+       }\r
+} );\r
+\r
+/**\r
+ * Button UI element.\r
+ *\r
+ * @readonly\r
+ * @property {String} [='panelbutton']\r
+ * @member CKEDITOR\r
+ */\r
+CKEDITOR.UI_PANELBUTTON = 'panelbutton';\r