zoukankan      html  css  js  c++  java
  • Fckeditor编辑区域高度固定

      fckeditor提供了编辑器高度的设置,但是只对整个编辑器,包括工具条。另外它也提供了一个插件autogrow,处理编辑器高度的自适应。

      但目前这边有个需求,需要只固定可编辑区域高度。上面所述无法满足,尝试修改源码增加这个配置。

      修改办法如下:

      1.修改fckconfig.js,在文件最后增加:

    FCKConfig.AutoHeight = true;    //也可以默认为false

      2.修改fcktoolbarset.js,增加如下红色代码:

      function FCKToolbarSet_Create( overhideLocation )
      {
          var oToolbarSet ;
          var initHeight;
          var sLocation = overhideLocation || FCKConfig.ToolbarLocation ;
          …………………………………………………………………………………….
      
      var FCKToolbarSet = function( targetDocument )
      {
          this._Document = targetDocument ;
          initHeight = parseInt(parent.document.getElementById(FCK.Name+ '___Frame').style.height, 10);
          // Get the element that will hold the elements structure.
          this._TargetElement    = targetDocument.getElementById( 'xToolbar' ) ;
          
          // Setup the expand and collapse handlers.
          var eExpandHandle    = targetDocument.getElementById( 'xExpandHandle' ) ;
          var eCollapseHandle    = targetDocument.getElementById( 'xCollapseHandle' ) ;
      
      ……………………………………………………
      
      FCKToolbarSet.prototype._ChangeVisibility = function( collapse )
      {
          this._Document.getElementById( 'xCollapsed' ).style.display = collapse ? '' : 'none' ;
          this._Document.getElementById( 'xExpanded' ).style.display = collapse ? 'none' : '' ;
          var toolbarHeight = this._Document.getElementById( 'xToolbar' ).scrollHeight;
      
          if(FCKConfig.AutoHeight) {
              if (collapse) {
                  if ( !FCKConfig.ToolbarCanCollapse || FCKConfig.ToolbarStartExpanded ) {
                      parent.document.getElementById(FCK.Name+'___Frame').style.height=initHeight - toolbarHeight+10 +'px';
                  }else {
                      parent.document.getElementById(FCK.Name+'___Frame').style.height=initHeight + 'px';    
                  }
              } else {                
                  if ( !FCKConfig.ToolbarCanCollapse || FCKConfig.ToolbarStartExpanded ) {
                      parent.document.getElementById(FCK.Name+'___Frame').style.height=initHeight+"px";
                  }else {
                      parent.document.getElementById(FCK.Name+'___Frame').style.height=initHeight + toolbarHeight -10+ 'px';    
                  }
              }
          }
          
          if ( window.onresize )
          {
              // I had to use "setTimeout" because Gecko was not responding in a right
              // way when calling window.onresize() directly.
              FCKTools.RunFunction( window.onresize ) ;
          }
      }
      
    …………………………………………………

      3.压缩fcktoolbarset.js并将修改移到fckeditorcode_XXXX.js中

      默认固定编辑区域高度,如要取消这功能,只需要在配置中加入:editor.Config["AutoHeight"] = false;

      至此,功德圆满。技术有限,欢迎拍砖!

  • 相关阅读:
    c#处理3种json数据的实例
    Json to JObject转换的使用方法
    js 中对象属性特性的描述
    js 中对象属性的特性
    js 中对象--对象结构(原型链基础解析)
    js 中对象--属性相关操作
    js 的对象--如何定义一个对象
    js 中特殊形势的函数-匿名函数的应用
    js 默认的参数、可变的参数、变量作用域
    js 通过function来定义函数
  • 原文地址:https://www.cnblogs.com/zhangchaozheng/p/2608125.html
Copyright © 2011-2022 走看看