From 786cfbb040a37370cb488c0976c21bb9ad8f2787 Mon Sep 17 00:00:00 2001
From: Nathan Gray <nathangray.bsc@gmail.com>
Date: Tue, 8 Dec 2015 21:54:40 +0000
Subject: [PATCH] Listen to tab changes to avoid scroll to top in Firefox

---
 calendar/js/et2_widget_timegrid.js | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js
index a89e7b0dfd..d570ca6dc6 100644
--- a/calendar/js/et2_widget_timegrid.js
+++ b/calendar/js/et2_widget_timegrid.js
@@ -147,6 +147,9 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
 			window.clearTimeout(this.update_timer);
 		}
 
+		// Stop listening to tab changes
+		$j(framework.getApplicationByName('calendar').tab.contentDiv).off('show.' + this.id);
+
 		this._super.apply(this, arguments);
 
 		// Delete all old objects
@@ -176,7 +179,16 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
 
 	doLoadingFinished: function() {
 		this._super.apply(this, arguments);
-		
+
+		// Listen to tab show to make sure we scroll to the day start, not top
+		$j(framework.getApplicationByName('calendar').tab.contentDiv)
+			.on('show.' + this.id, jQuery.proxy(
+				function()
+				{
+					this.scrolling.scrollTop(this._top_time);
+				},this)
+			);
+
 		// Need to get the correct internal sizing
 		this.resize();