import rt 3.8.7
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / classes / fcktoolbarpanelbutton.js
diff --git a/rt/share/html/NoAuth/RichText/FCKeditor/editor/_source/classes/fcktoolbarpanelbutton.js b/rt/share/html/NoAuth/RichText/FCKeditor/editor/_source/classes/fcktoolbarpanelbutton.js
new file mode 100644 (file)
index 0000000..a507696
--- /dev/null
@@ -0,0 +1,103 @@
+/*\r
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
+ * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
+ *\r
+ * == BEGIN LICENSE ==\r
+ *\r
+ * Licensed under the terms of any of the following licenses at your\r
+ * choice:\r
+ *\r
+ *  - GNU General Public License Version 2 or later (the "GPL")\r
+ *    http://www.gnu.org/licenses/gpl.html\r
+ *\r
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
+ *    http://www.gnu.org/licenses/lgpl.html\r
+ *\r
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
+ *    http://www.mozilla.org/MPL/MPL-1.1.html\r
+ *\r
+ * == END LICENSE ==\r
+ *\r
+ * FCKToolbarPanelButton Class: represents a special button in the toolbar\r
+ * that shows a panel when pressed.\r
+ */\r
+\r
+var FCKToolbarPanelButton = function( commandName, label, tooltip, style, icon )\r
+{\r
+       this.CommandName = commandName ;\r
+\r
+       var oIcon ;\r
+\r
+       if ( icon == null )\r
+               oIcon = FCKConfig.SkinPath + 'toolbar/' + commandName.toLowerCase() + '.gif' ;\r
+       else if ( typeof( icon ) == 'number' )\r
+               oIcon = [ FCKConfig.SkinPath + 'fck_strip.gif', 16, icon ] ;\r
+\r
+       var oUIButton = this._UIButton = new FCKToolbarButtonUI( commandName, label, tooltip, oIcon, style ) ;\r
+       oUIButton._FCKToolbarPanelButton = this ;\r
+       oUIButton.ShowArrow = true ;\r
+       oUIButton.OnClick = FCKToolbarPanelButton_OnButtonClick ;\r
+}\r
+\r
+FCKToolbarPanelButton.prototype.TypeName = 'FCKToolbarPanelButton' ;\r
+\r
+FCKToolbarPanelButton.prototype.Create = function( parentElement )\r
+{\r
+       parentElement.className += 'Menu' ;\r
+\r
+       this._UIButton.Create( parentElement ) ;\r
+\r
+       var oPanel = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName )._Panel ;\r
+       this.RegisterPanel( oPanel ) ;\r
+}\r
+\r
+FCKToolbarPanelButton.prototype.RegisterPanel = function( oPanel )\r
+{\r
+       if ( oPanel._FCKToolbarPanelButton )\r
+               return ;\r
+\r
+       oPanel._FCKToolbarPanelButton = this ;\r
+\r
+       var eLineDiv = oPanel.Document.body.appendChild( oPanel.Document.createElement( 'div' ) ) ;\r
+       eLineDiv.style.position = 'absolute' ;\r
+       eLineDiv.style.top = '0px' ;\r
+\r
+       var eLine = oPanel._FCKToolbarPanelButtonLineDiv = eLineDiv.appendChild( oPanel.Document.createElement( 'IMG' ) ) ;\r
+       eLine.className = 'TB_ConnectionLine' ;\r
+       eLine.style.position = 'absolute' ;\r
+//     eLine.style.backgroundColor = 'Red' ;\r
+       eLine.src = FCK_SPACER_PATH ;\r
+\r
+       oPanel.OnHide = FCKToolbarPanelButton_OnPanelHide ;\r
+}\r
+\r
+/*\r
+       Events\r
+*/\r
+\r
+function FCKToolbarPanelButton_OnButtonClick( toolbarButton )\r
+{\r
+       var oButton = this._FCKToolbarPanelButton ;\r
+       var e = oButton._UIButton.MainElement ;\r
+\r
+       oButton._UIButton.ChangeState( FCK_TRISTATE_ON ) ;\r
+\r
+       // oButton.LineImg.style.width = ( e.offsetWidth - 2 ) + 'px' ;\r
+\r
+       var oCommand = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oButton.CommandName ) ;\r
+       var oPanel = oCommand._Panel ;\r
+       oPanel._FCKToolbarPanelButtonLineDiv.style.width = ( e.offsetWidth - 2 ) + 'px' ;\r
+       oCommand.Execute( 0, e.offsetHeight - 1, e ) ; // -1 to be over the border\r
+}\r
+\r
+function FCKToolbarPanelButton_OnPanelHide()\r
+{\r
+       var oMenuButton = this._FCKToolbarPanelButton ;\r
+       oMenuButton._UIButton.ChangeState( FCK_TRISTATE_OFF ) ;\r
+}\r
+\r
+// The Panel Button works like a normal button so the refresh state functions\r
+// defined for the normal button can be reused here.\r
+FCKToolbarPanelButton.prototype.RefreshState   = FCKToolbarButton.prototype.RefreshState ;\r
+FCKToolbarPanelButton.prototype.Enable                 = FCKToolbarButton.prototype.Enable ;\r
+FCKToolbarPanelButton.prototype.Disable                        = FCKToolbarButton.prototype.Disable ;\r