mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-10-05 09:32:08 +02:00
Etemplate: Better calculation for all fixed width columns to properly fit given width
This one avoids potential overflow due to rounding
This commit is contained in:
parent
cd2ea60fbd
commit
6ce32d3e85
@ -102,7 +102,7 @@ var et2_dataview_column = (function(){ "use strict"; return ClassWithAttributes.
|
|||||||
* @param {float|string} _value
|
* @param {float|string} _value
|
||||||
*/
|
*/
|
||||||
set_width: function(_value) {
|
set_width: function(_value) {
|
||||||
// Parse the width parameter.
|
// Parse the width parameter.
|
||||||
this.relativeWidth = false;
|
this.relativeWidth = false;
|
||||||
this.fixedWidth = false;
|
this.fixedWidth = false;
|
||||||
var w = _value;
|
var w = _value;
|
||||||
@ -434,12 +434,17 @@ var et2_dataview_columns = (function(){ "use strict"; return Class.extend({
|
|||||||
if(!column)
|
if(!column)
|
||||||
{
|
{
|
||||||
// Distribute shortage over all fixed width columns
|
// Distribute shortage over all fixed width columns
|
||||||
|
var diff = Math.round(remaining_width / fixedCount);
|
||||||
for(var i = 0; i < this.columns.length; i++)
|
for(var i = 0; i < this.columns.length; i++)
|
||||||
{
|
{
|
||||||
var col = this.columns[i];
|
var col = this.columns[i];
|
||||||
|
var col_diff = (diff < 0 ?
|
||||||
|
Math.max(remaining_width, diff) :
|
||||||
|
Math.min(remaining_width, diff)
|
||||||
|
);
|
||||||
if(!col.fixedWidth) continue;
|
if(!col.fixedWidth) continue;
|
||||||
var diff = Math.round(remaining_width / fixedCount);
|
var new_width = this.columnWidths[i] - col_diff;
|
||||||
var new_width = this.columnWidths[i] - diff;
|
remaining_width -= col_diff;
|
||||||
this.columnWidths[i] = Math.max(0, Math.min(new_width,tw));
|
this.columnWidths[i] = Math.max(0, Math.min(new_width,tw));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user