fckplugin.js
上传用户:ah_jiwei
上传日期:2022-07-24
资源大小:54044k
文件大小:2k
源码类别:

数据库编程

开发平台:

Visual C++

  1. /*
  2.  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  3.  * Copyright (C) 2003-2007 Frederico Caldeira Knabben
  4.  *
  5.  * == BEGIN LICENSE ==
  6.  *
  7.  * Licensed under the terms of any of the following licenses at your
  8.  * choice:
  9.  *
  10.  *  - GNU General Public License Version 2 or later (the "GPL")
  11.  *    http://www.gnu.org/licenses/gpl.html
  12.  *
  13.  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  14.  *    http://www.gnu.org/licenses/lgpl.html
  15.  *
  16.  *  - Mozilla Public License Version 1.1 or later (the "MPL")
  17.  *    http://www.mozilla.org/MPL/MPL-1.1.html
  18.  *
  19.  * == END LICENSE ==
  20.  *
  21.  * Plugin: automatically resizes the editor until a configurable maximun
  22.  * height (FCKConfig.AutoGrowMax), based on its contents.
  23.  */
  24. var FCKAutoGrow_Min = window.frameElement.offsetHeight ;
  25. function FCKAutoGrow_Check()
  26. {
  27. var oInnerDoc = FCK.EditorDocument ;
  28. var iFrameHeight, iInnerHeight ;
  29. if ( FCKBrowserInfo.IsIE )
  30. {
  31. iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
  32. iInnerHeight = oInnerDoc.body.scrollHeight ;
  33. }
  34. else
  35. {
  36. iFrameHeight = FCK.EditorWindow.innerHeight ;
  37. iInnerHeight = oInnerDoc.body.offsetHeight ;
  38. }
  39. var iDiff = iInnerHeight - iFrameHeight ;
  40. if ( iDiff != 0 )
  41. {
  42. var iMainFrameSize = window.frameElement.offsetHeight ;
  43. if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
  44. {
  45. iMainFrameSize += iDiff ;
  46. if ( iMainFrameSize > FCKConfig.AutoGrowMax )
  47. iMainFrameSize = FCKConfig.AutoGrowMax ;
  48. }
  49. else if ( iDiff < 0 && iMainFrameSize > FCKAutoGrow_Min )
  50. {
  51. iMainFrameSize += iDiff ;
  52. if ( iMainFrameSize < FCKAutoGrow_Min )
  53. iMainFrameSize = FCKAutoGrow_Min ;
  54. }
  55. else
  56. return ;
  57. window.frameElement.height = iMainFrameSize ;
  58. }
  59. }
  60. FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
  61. function FCKAutoGrow_SetListeners()
  62. {
  63. if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
  64. return ;
  65. FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow_Check ) ;
  66. FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow_Check ) ;
  67. }
  68. if ( FCKBrowserInfo.IsIE )
  69. {
  70. // FCKAutoGrow_SetListeners() ;
  71. FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow_SetListeners ) ;
  72. }
  73. function FCKAutoGrow_CheckEditorStatus( sender, status )
  74. {
  75. if ( status == FCK_STATUS_COMPLETE )
  76. FCKAutoGrow_Check() ;
  77. }
  78. FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow_CheckEditorStatus ) ;