]> CRI, Mines Paris - PSL - ckeditor.git/blobdiff - skins/ckeditor/_source/plugins/menubutton/plugin.js
Mimimum syndical pour en faire un produit zope / cmf.
[ckeditor.git] / skins / ckeditor / _source / plugins / menubutton / plugin.js
diff --git a/skins/ckeditor/_source/plugins/menubutton/plugin.js b/skins/ckeditor/_source/plugins/menubutton/plugin.js
new file mode 100644 (file)
index 0000000..6f07531
--- /dev/null
@@ -0,0 +1,98 @@
+/*\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+CKEDITOR.plugins.add( 'menubutton',\r
+{\r
+       requires : [ 'button', 'menu' ],\r
+       beforeInit : function( editor )\r
+       {\r
+               editor.ui.addHandler( CKEDITOR.UI_MENUBUTTON, CKEDITOR.ui.menuButton.handler );\r
+       }\r
+});\r
+\r
+/**\r
+ * Button UI element.\r
+ * @constant\r
+ * @example\r
+ */\r
+CKEDITOR.UI_MENUBUTTON = 'menubutton';\r
+\r
+(function()\r
+{\r
+       var clickFn = function( editor )\r
+       {\r
+               var _ = this._;\r
+\r
+               // Do nothing if this button is disabled.\r
+               if ( _.state === CKEDITOR.TRISTATE_DISABLED )\r
+                       return;\r
+\r
+               _.previousState = _.state;\r
+\r
+               // Check if we already have a menu for it, otherwise just create it.\r
+               var menu = _.menu;\r
+               if ( !menu )\r
+               {\r
+                       menu = _.menu = new CKEDITOR.menu( editor,\r
+                       {\r
+                               panel:\r
+                               {\r
+                                       className : editor.skinClass + ' cke_contextmenu',\r
+                                       attributes : { 'aria-label' : editor.lang.common.options }\r
+                               }\r
+                       });\r
+\r
+                       menu.onHide = CKEDITOR.tools.bind( function()\r
+                               {\r
+                                       this.setState( this.modes && this.modes[ editor.mode ] ? _.previousState : CKEDITOR.TRISTATE_DISABLED );\r
+                               },\r
+                               this );\r
+\r
+                       // Initialize the menu items at this point.\r
+                       if ( this.onMenu )\r
+                               menu.addListener( this.onMenu );\r
+               }\r
+\r
+               if ( _.on )\r
+               {\r
+                       menu.hide();\r
+                       return;\r
+               }\r
+\r
+               this.setState( CKEDITOR.TRISTATE_ON );\r
+\r
+               menu.show( CKEDITOR.document.getById( this._.id ), 4 );\r
+       };\r
+\r
+\r
+       CKEDITOR.ui.menuButton = CKEDITOR.tools.createClass(\r
+       {\r
+               base : CKEDITOR.ui.button,\r
+\r
+               $ : function( definition )\r
+               {\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.hasArrow = true;\r
+\r
+                       this.click = clickFn;\r
+               },\r
+\r
+               statics :\r
+               {\r
+                       handler :\r
+                       {\r
+                               create : function( definition )\r
+                               {\r
+                                       return new CKEDITOR.ui.menuButton( definition );\r
+                               }\r
+                       }\r
+               }\r
+       });\r
+})();\r