Ticket #2329: dragresizetable_use_relative.patch
File dragresizetable_use_relative.patch, 2.1 KB (added by , 16 years ago) |
---|
-
editor/plugins/dragresizetable/fckplugin.js
old new 1 var FCKDragTableHandler =1 var FCKDragTableHandler = 2 2 { 3 3 "_DragState" : 0, 4 4 "_LeftCell" : null, … … 139 139 // Then, build an array of current column width values. 140 140 // This algorithm can be very slow if the cells have insane colSpan values. (e.g. colSpan=1000). 141 141 var table = FCKTools.GetElementAscensor( FCKDragTableHandler._LeftCell, "table" ) ; 142 // Gets the value from the Width or the Style attribute 143 var tableWidth = (table.style.width ? table.style.width : table.width ) ; 144 145 if (tableWidth.indexOf('%') >= 0) // Percentual = % 146 { 147 var relativeWidth = true; 148 } 149 else 150 { 151 var relativeWidth = false; 152 tableWidth = tableWidth = tableWidth.substr(0,tableWidth.length - 2) ; 153 } 154 142 155 var colArray = [] ; 143 156 var tableMap = FCKDragTableHandler._TableMap ; 144 157 for ( var i = 0 ; i < tableMap.length ; i++ ) … … 187 200 for ( var i = colElements.length - 1 ; i >= 0 ; i-- ) 188 201 colElements[i].parentNode.removeChild( colElements[i] ) ; 189 202 203 if ( relativeWidth ) 204 { 205 tableWidth = 0; 206 for (var i = 0 ; i < colArray.length ; i++ ) 207 { 208 tableWidth += colArray[i].width ; 209 } 210 } 211 190 212 // Set new cell widths. 191 213 var processedCells = [] ; 192 214 for ( var i = 0 ; i < tableMap.length ; i++ ) … … 197 219 if ( cell._Processed ) 198 220 continue ; 199 221 if ( tableMap[i][j-1] != cell ) 200 cell.width = colArray[j].width ;222 var colWidth = colArray[j].width ; 201 223 else 202 cell.width = parseInt( cell.width, 10 ) + parseInt( colArray[j].width, 10 ) ; 224 var colWidth = parseInt( cell.width, 10 ) + parseInt( colArray[j].width, 10 ) ; 225 if ( relativeWidth ) 226 { 227 var percentWidth = (colWidth / tableWidth) * 100; 228 cell.width = percentWidth + "%"; 229 } 230 else 231 { 232 cell.width = colWidth; 233 } 203 234 if ( tableMap[i][j+1] != cell ) 204 235 { 205 236 processedCells.push( cell ) ;