Fixes for errors when closing calendar tab, which broke tabs at the framework level

This commit is contained in:
Nathan Gray 2016-01-28 16:59:23 +00:00
parent c3f12efd2e
commit b5be17ad9c
2 changed files with 24 additions and 13 deletions

View File

@ -3176,7 +3176,7 @@ app.classes.calendar = AppJS.extend(
} }
}); });
// Dynamic resize to fill sidebox // Dynamic resize of sidebox calendar to fill sidebox
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 = parseFloat($j(this.sidebox_et2.getDOMNode()).css('font-size')) / parseFloat($j('#calendar-sidebox_date .ui-datepicker-inline').css('font-size')); var font_ratio = parseFloat($j(this.sidebox_et2.getDOMNode()).css('font-size')) / parseFloat($j('#calendar-sidebox_date .ui-datepicker-inline').css('font-size'));
@ -3187,15 +3187,17 @@ app.classes.calendar = AppJS.extend(
.css('font-size',(percent*100)+'%'); .css('font-size',(percent*100)+'%');
// Position today // Position today
var buttons = $j('#calendar-sidebox_date .ui-datepicker-header a'); var buttons = $j('#calendar-sidebox_date .ui-datepicker-header a');
var left = Infinity;
var total = 0; var total = 0;
buttons.each(function() { buttons.each(function() {
total += $j(this).position().left; total += $j(this).position().left;
}); });
// Why doesn't this work properly? // Why doesn't this work properly?
var today = $j('#calendar-sidebox_header_today') var today = $j('#calendar-sidebox_header_today');
.position({my: 'center left', at: 'center right',of: buttons}); if(today.length)
today.css('left',(total/buttons.length)/*+(today.width()/2)*/) {
today.position({my: 'center left', at: 'center right',of: buttons});
today.css('left',(total/buttons.length));
}
}).trigger('resize'); }).trigger('resize');
} }

View File

@ -134,7 +134,10 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
destroy: function() { destroy: function() {
// Stop listening to tab changes // Stop listening to tab changes
if(framework.getApplicationByName('calendar').tab)
{
$j(framework.getApplicationByName('calendar').tab.contentDiv).off('show.' + this.id); $j(framework.getApplicationByName('calendar').tab.contentDiv).off('show.' + this.id);
}
this._super.apply(this, arguments); this._super.apply(this, arguments);
@ -163,13 +166,19 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this._super.apply(this, arguments); this._super.apply(this, arguments);
// Listen to tab show to make sure we scroll to the day start, not top // Listen to tab show to make sure we scroll to the day start, not top
if(framework.getApplicationByName('calendar').tab)
{
$j(framework.getApplicationByName('calendar').tab.contentDiv) $j(framework.getApplicationByName('calendar').tab.contentDiv)
.on('show.' + this.id, jQuery.proxy( .on('show.' + this.id, jQuery.proxy(
function() function()
{
if(this.scrolling)
{ {
this.scrolling.scrollTop(this._top_time); this.scrolling.scrollTop(this._top_time);
}
},this) },this)
); );
}
// Need to get the correct internal sizing // Need to get the correct internal sizing
this.resize(); this.resize();