FCKEditor2.4.2版本中并不支持列的合并,下面是原代碼:
           1FCKTableHandler.MergeCells = function()
           2{
           3    // Get all selected cells.
           4    var aCells = FCKTableHandler.GetSelectedCells() ;
           5
           6    // At least 2 cells must be selected.
           7    if ( aCells.length < 2 )
           8        return ;
           9
          10    // The merge can occour only if the selected cells are from the same row.
          11    if ( aCells[0].parentNode != aCells[aCells.length-1].parentNode )
          12        return ;
          13
          14    // Calculate the new colSpan for the first cell.
          15    var iColSpan = isNaN( aCells[0].colSpan ) ? 1 : aCells[0].colSpan ;
          16
          17    var sHtml = '' ;
          18    var oCellsContents = FCK.EditorDocument.createDocumentFragment() ;
          19
          20    for ( var i = aCells.length - 1 ; i >= 0 ; i-- )
          21    {
          22        var eCell = aCells[i] ;
          23
          24        // Move its contents to the document fragment.
          25        for ( var c = eCell.childNodes.length - 1 ; c >= 0 ; c-- )
          26        {
          27            var eChild = eCell.removeChild( eCell.childNodes[c] ) ;
          28
          29            if ( ( eChild.hasAttribute && eChild.hasAttribute('_moz_editor_bogus_node') ) || ( eChild.getAttribute && eChild.getAttribute( 'type', 2 ) == '_moz' ) )
          30                continue ;
          31
          32                oCellsContents.insertBefore( eChild, oCellsContents.firstChild ) ;
          33        }

          34
          35        if ( i > 0 )
          36        {
          37            // Accumulate the colspan of the cell.
          38            iColSpan += isNaN( eCell.colSpan ) ? 1 : eCell.colSpan ;
          39
          40            // Delete the cell.
          41            FCKTableHandler.DeleteCell( eCell ) ;
          42        }

          43    }

          44
          45    // Set the innerHTML of the remaining cell (the first one).
          46    aCells[0].colSpan = iColSpan ;
          47
          48    if ( FCKBrowserInfo.IsGecko && oCellsContents.childNodes.length == 0 )
          49        aCells[0].innerHTML = GECKO_BOGUS ;
          50    else
          51        aCells[0].appendChild( oCellsContents ) ;
          52}
          第10行代碼對列合并做了限制,下面是修改的代碼:
           1FCKTableHandler.MergeCells = function()
           2{
           3    // Get all selected cells.
           4    var aCells = FCKTableHandler.GetSelectedCells() ;
           5
           6    // At least 2 cells must be selected.
           7    if ( aCells.length < 2 )
           8        return ;
           9
          10    // The merge can occour only if the selected cells are from the same row.
          11    //if ( aCells[0].parentNode != aCells[aCells.length-1].parentNode ){
          12    //    alert("xx");
          13    //    return ;
          14    //}
          15    
          16    //*********************************************************************
          17    //在IE下合并單元格修改,主要針對上下單元格不能合并的問題。
          18    //姜海龍
          19    var iLen = aCells.length;
          20    var iStartCol = aCells[0].cellIndex ;
          21    var iStartRow = aCells[0].parentElement.rowIndex ;
          22    
          23    var iEndCol = aCells[iLen-1].cellIndex ;
          24    var iEndRow = aCells[iLen-1].parentElement.rowIndex ;
          25    
          26    var eCells = new Array();
          27    var j = 0;
          28    
          29    for(var i = 0; i < iLen; i++){
          30        if(aCells[i].cellIndex >= iStartCol && aCells[i].cellIndex <= iEndCol){
          31            eCells[j] = aCells[i];
          32            j++;
          33        }

          34    }

          35
          36    aCells[0].colSpan = iEndCol - iStartCol + 1;
          37    aCells[0].rowSpan = iEndRow - iStartRow + 1;
          38
          39    for (var i = 1; i < j; i++){
          40            eCells[i].parentElement.removeChild(eCells[i]);
          41    }

          42    
          43    //alert(aCells[0].rowSpan);
          44    //alert(aCells[0].parentElement.parentElement.innerHTML);
          45    //*********************************************************************
          46
          47
          48}
          該代碼未經全面測試

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          posts - 9, comments - 19, trackbacks - 0, articles - 1

          Copyright © 姜海龍

          主站蜘蛛池模板: 沐川县| 涪陵区| 保定市| 汕头市| 永城市| 九龙坡区| 高安市| 札达县| 阿拉善盟| 安化县| 萨迦县| 遂宁市| 夹江县| 嵊州市| 固镇县| 锡林郭勒盟| 平山县| 根河市| 富蕴县| 清水县| 电白县| 新河县| 大理市| 盱眙县| 苗栗县| 理塘县| 阜宁县| 蓝山县| 顺义区| 开封市| 新晃| 瑞昌市| 竹北市| 莱西市| 揭阳市| 绥江县| 博野县| 四子王旗| 广灵县| 赣榆县| 诸城市|