Fix resize issues with etemplate2 / calendar

This commit is contained in:
Nathan Gray 2016-02-10 16:50:42 +00:00
parent c25403bec7
commit c8cf2d30d8
3 changed files with 22 additions and 22 deletions

View File

@ -3219,6 +3219,7 @@ app.classes.calendar = AppJS.extend(
var preferred_width = $j('#calendar-sidebox_date .ui-datepicker-inline').outerWidth(); var preferred_width = $j('#calendar-sidebox_date .ui-datepicker-inline').outerWidth();
var font_ratio = 12 / parseFloat($j('#calendar-sidebox_date .ui-datepicker-inline').css('font-size')); var font_ratio = 12 / parseFloat($j('#calendar-sidebox_date .ui-datepicker-inline').css('font-size'));
$j(window).on('resize.calendar'+date_widget.dom_id, function() { $j(window).on('resize.calendar'+date_widget.dom_id, function() {
try {
var percent = 1+(($j(date_widget.getDOMNode()).width() - preferred_width) / preferred_width); var percent = 1+(($j(date_widget.getDOMNode()).width() - preferred_width) / preferred_width);
percent *= font_ratio; percent *= font_ratio;
$j('#calendar-sidebox_date .ui-datepicker-inline') $j('#calendar-sidebox_date .ui-datepicker-inline')
@ -3234,6 +3235,9 @@ app.classes.calendar = AppJS.extend(
'top': go_button.css('top') 'top': go_button.css('top')
}); });
} }
} catch (e){
// Resize didn't work
}
}).trigger('resize'); }).trigger('resize');
} }

View File

@ -1706,9 +1706,6 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
return; return;
} }
// Set the max width to avoid animations screwing up the width
this.div.css('max-width',$j(this.getInstanceManager().DOMContainer).width());
/* /*
We expect the timegrid to be in a table with 0 or more other timegrids, We expect the timegrid to be in a table with 0 or more other timegrids,
1 per row. We want each timegrid to be as large as possible, but space 1 per row. We want each timegrid to be as large as possible, but space
@ -1775,7 +1772,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
} }
// Try to resize width, though animations cause problems // Try to resize width, though animations cause problems
var total_width = this.days.width(); var total_width = $j(this.getInstanceManager().DOMContainer).parent().innerWidth() - this.days.position().left;
var day_width = (total_width > 0 ? total_width : $j(this.getInstanceManager().DOMContainer).width())/this.day_widgets.length; var day_width = (total_width > 0 ? total_width : $j(this.getInstanceManager().DOMContainer).width())/this.day_widgets.length;
// update day widgets // update day widgets
for(var i = 0; i < this.day_widgets.length; i++) for(var i = 0; i < this.day_widgets.length; i++)

View File

@ -148,19 +148,18 @@ etemplate2.prototype.resize = function(e)
var appHeader = $j('#divAppboxHeader'); var appHeader = $j('#divAppboxHeader');
//Calculate the excess height //Calculate the excess height
excess_height = egw(window).is_popup()? $j(window).height() - $j('.et2_container').height() - appHeader.outerHeight()+11: false; excess_height = egw(window).is_popup()? $j(window).height() - $j(self.DOMContainer).height() - appHeader.outerHeight()+11: false;
// Recalculate excess height if the appheader is shown // Recalculate excess height if the appheader is shown
if (appHeader.length > 0 && appHeader.is(':visible')) excess_height -= appHeader.outerHeight()-9; if (appHeader.length > 0 && appHeader.is(':visible')) excess_height -= appHeader.outerHeight()-9;
// Do not resize if the template height is bigger than screen available height // Do not resize if the template height is bigger than screen available height
// For templates which have sub templates and they are bigger than screenHeight // For templates which have sub templates and they are bigger than screenHeight
if(screen.availHeight < $j('.et2_container').height()) excess_height = 0; if(screen.availHeight < $j(self.DOMContainer).height()) excess_height = 0;
// Call the "resize" event of all functions which implement the // Call the "resize" event of all functions which implement the
// "IResizeable" interface // "IResizeable" interface
self.widgetContainer.iterateOver(function(_widget) { self.widgetContainer.iterateOver(function(_widget) {
_widget.resize(excess_height);
if (excess_height != 0 || excess_height === false) _widget.resize(excess_height);
}, self, et2_IResizeable); }, self, et2_IResizeable);
} }
},100); },100);