fcktoolbar.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: fcktoolbar.js
  14.  *  FCKToolbar Class: represents a toolbar in the toolbarset. It is a group of
  15.  *  toolbar items.
  16.  * 
  17.  * File Authors:
  18.  *  Frederico Caldeira Knabben (fredck@fckeditor.net)
  19.  */
  20. var FCKToolbar = function()
  21. {
  22. this.Items = new Array() ;
  23. if ( FCK.IECleanup )
  24. FCK.IECleanup.AddItem( this, FCKToolbar_Cleanup ) ;
  25. }
  26. FCKToolbar.prototype.AddItem = function( item )
  27. {
  28. return this.Items[ this.Items.length ] = item ;
  29. }
  30. FCKToolbar.prototype.AddButton = function( name, label, tooltip, iconPathOrStripInfoArrayOrIndex, style, state )
  31. {
  32. if ( typeof( iconPathOrStripInfoArrayOrIndex ) == 'number' )
  33.  iconPathOrStripInfoArrayOrIndex = [ this.DefaultIconsStrip, this.DefaultIconSize, iconPathOrStripInfoArrayOrIndex ] ;
  34. var oButton = new FCKToolbarButtonUI( name, label, tooltip, iconPathOrStripInfoArrayOrIndex, style, state ) ;
  35. oButton._FCKToolbar = this ;
  36. oButton.OnClick = FCKToolbar_OnItemClick ;
  37. return this.AddItem( oButton ) ;
  38. }
  39. function FCKToolbar_OnItemClick( item )
  40. {
  41. var oToolbar = item._FCKToolbar ;
  42. if ( oToolbar.OnItemClick )
  43. oToolbar.OnItemClick( oToolbar, item ) ;
  44. }
  45. FCKToolbar.prototype.AddSeparator = function()
  46. {
  47. this.AddItem( new FCKToolbarSeparator() ) ;
  48. }
  49. FCKToolbar.prototype.Create = function( parentElement )
  50. {
  51. if ( this.MainElement )
  52. {
  53. // this._Cleanup() ;
  54. if ( this.MainElement.parentNode )
  55. this.MainElement.parentNode.removeChild( this.MainElement ) ;
  56. this.MainElement = null ;
  57. }
  58. var oDoc = FCKTools.GetElementDocument( parentElement ) ;
  59. var e = this.MainElement = oDoc.createElement( 'table' ) ;
  60. e.className = 'TB_Toolbar' ;
  61. e.style.styleFloat = e.style.cssFloat = ( FCKLang.Dir == 'ltr' ? 'left' : 'right' ) ;
  62. e.dir = FCKLang.Dir ;
  63. e.cellPadding = 0 ;
  64. e.cellSpacing = 0 ;
  65. this.RowElement = e.insertRow(-1) ;
  66. // Insert the start cell.
  67. var eCell ;
  68. if ( !this.HideStart )
  69. {
  70. eCell = this.RowElement.insertCell(-1) ;
  71. eCell.appendChild( oDoc.createElement( 'div' ) ).className = 'TB_Start' ;
  72. }
  73. for ( var i = 0 ; i < this.Items.length ; i++ )
  74. {
  75. this.Items[i].Create( this.RowElement.insertCell(-1) ) ;
  76. }
  77. // Insert the ending cell.
  78. if ( !this.HideEnd )
  79. {
  80. eCell = this.RowElement.insertCell(-1) ;
  81. eCell.appendChild( oDoc.createElement( 'div' ) ).className = 'TB_End' ;
  82. }
  83. parentElement.appendChild( e ) ;
  84. }
  85. function FCKToolbar_Cleanup()
  86. {
  87. this.MainElement = null ;
  88. this.RowElement = null ;
  89. }
  90. var FCKToolbarSeparator = function()
  91. {}
  92. FCKToolbarSeparator.prototype.Create = function( parentElement )
  93. {
  94. FCKTools.AppendElement( parentElement, 'div' ).className = 'TB_Separator' ;
  95. }