fcktoolbarpanelbutton.js
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:3k
源码类别:

OA系统

开发平台:

C#

  1. /*
  2.  * FCKeditor - The text editor for internet
  3.  * Copyright (C) 2003-2006 Frederico Caldeira Knabben
  4.  * 
  5.  * Licensed under the terms of the GNU Lesser General Public License:
  6.  *  http://www.opensource.org/licenses/lgpl-license.php
  7.  * 
  8.  * For further information visit:
  9.  *  http://www.fckeditor.net/
  10.  * 
  11.  * "Support Open Source software. What about a donation today?"
  12.  * 
  13.  * File Name: fcktoolbarpanelbutton.js
  14.  *  FCKToolbarPanelButton Class: represents a special button in the toolbar
  15.  *  that shows a panel when pressed.
  16.  * 
  17.  * File Authors:
  18.  *  Frederico Caldeira Knabben (fredck@fckeditor.net)
  19.  */
  20. var FCKToolbarPanelButton = function( commandName, label, tooltip, style, icon )
  21. {
  22. this.CommandName = commandName ;
  23. var oIcon ;
  24. if ( icon == null )
  25. oIcon = FCKConfig.SkinPath + 'toolbar/' + commandName.toLowerCase() + '.gif' ;
  26. else if ( typeof( icon ) == 'number' )
  27. oIcon = [ FCKConfig.SkinPath + 'fck_strip.gif', 16, icon ] ;
  28. var oUIButton = this._UIButton = new FCKToolbarButtonUI( commandName, label, tooltip, oIcon, style ) ;
  29. oUIButton._FCKToolbarPanelButton = this ;
  30. oUIButton.ShowArrow = true ;
  31. oUIButton.OnClick = FCKToolbarPanelButton_OnButtonClick ;
  32. }
  33. FCKToolbarPanelButton.prototype.TypeName = 'FCKToolbarPanelButton' ;
  34. FCKToolbarPanelButton.prototype.Create = function( parentElement )
  35. {
  36. parentElement.className += 'Menu' ;
  37. this._UIButton.Create( parentElement ) ;
  38. var oPanel = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName )._Panel ;
  39. oPanel._FCKToolbarPanelButton = this ;
  40. var eLineDiv = oPanel.Document.body.appendChild( oPanel.Document.createElement( 'div' ) ) ;
  41. eLineDiv.style.position = 'absolute' ;
  42. eLineDiv.style.top = '0px' ;
  43. var eLine = this.LineImg = eLineDiv.appendChild( oPanel.Document.createElement( 'IMG' ) ) ;
  44. eLine.className = 'TB_ConnectionLine' ;
  45. // eLine.style.backgroundColor = 'Red' ;
  46. eLine.src = FCK_SPACER_PATH ;
  47. oPanel.OnHide = FCKToolbarPanelButton_OnPanelHide ;
  48. }
  49. /*
  50. Events
  51. */
  52. function FCKToolbarPanelButton_OnButtonClick( toolbarButton )
  53. {
  54. var oButton = this._FCKToolbarPanelButton ;
  55. var e = oButton._UIButton.MainElement ;
  56. oButton._UIButton.ChangeState( FCK_TRISTATE_ON ) ;
  57. oButton.LineImg.style.width = ( e.offsetWidth - 2 ) + 'px' ;
  58. FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oButton.CommandName ).Execute( 0, e.offsetHeight - 1, e ) ; // -1 to be over the border
  59. }
  60. function FCKToolbarPanelButton_OnPanelHide()
  61. {
  62. var oMenuButton = this._FCKToolbarPanelButton ;
  63. oMenuButton._UIButton.ChangeState( FCK_TRISTATE_OFF ) ;
  64. }
  65. // The Panel Button works like a normal button so the refresh state functions
  66. // defined for the normal button can be reused here.
  67. FCKToolbarPanelButton.prototype.RefreshState = FCKToolbarButton.prototype.RefreshState ;
  68. FCKToolbarPanelButton.prototype.Enable = FCKToolbarButton.prototype.Enable ;
  69. FCKToolbarPanelButton.prototype.Disable = FCKToolbarButton.prototype.Disable ;