Bug 1608407 - Create one instance of the calendar navigation bar per window, instead of one for all windows; r+a=pmorris
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 13 Jan 2020 21:53:19 +1300
changeset 37875 a1082c92969ad53a34fa2d7510c2c61172e933f5
parent 37874 796bb4a6c9874ea99591b5c52517f345a170d9a6
child 37876 d7e99ea4d5ce43c8e4aa02c6fb438b2bb6b08286
push id397
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:16:13 +0000
bugs1608407
Bug 1608407 - Create one instance of the calendar navigation bar per window, instead of one for all windows; r+a=pmorris
calendar/base/content/calendar-base-view.js
calendar/base/content/calendar-month-base-view.js
calendar/base/content/calendar-multiday-base-view.js
calendar/base/content/calendar-views-utils.js
--- a/calendar/base/content/calendar-base-view.js
+++ b/calendar/base/content/calendar-base-view.js
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/* globals cal currentView MozElements MozXULElement Services toggleOrientation */
+/* global cal, currentView, calendarNavigationBar, MozElements, MozXULElement, Services,
+   toggleOrientation */
 
 "use strict";
 
 // Wrap in a block to prevent leaking to window scope.
 {
   const { Log4Moz } = ChromeUtils.import("resource:///modules/gloda/log4moz.js");
 
   /**
@@ -919,17 +920,17 @@
 
     removeDropShadows() {
       this.querySelectorAll("[dropbox='true']").forEach(dbox => {
         dbox.setAttribute("dropbox", "false");
       });
     }
 
     setDateRange(startDate, endDate) {
-      cal.navigationBar.setDateRange(startDate, endDate);
+      calendarNavigationBar.setDateRange(startDate, endDate);
     }
 
     getSelectedItems() {
       return this.mSelectedItems;
     }
 
     setSelectedItems(items) {
       this.mSelectedItems = items.concat([]);
--- a/calendar/base/content/calendar-month-base-view.js
+++ b/calendar/base/content/calendar-month-base-view.js
@@ -1,13 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/* global MozElements, MozXULElement, Services, timeIndicator */
+/* global calendarNavigationBar, MozElements, MozXULElement, Services, timeIndicator */
 
 "use strict";
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 // Wrap in a block to prevent leaking to window scope.
 {
   /**
@@ -284,17 +284,17 @@ var { cal } = ChromeUtils.import("resour
         toggleStatus |= this.mToggleStatusFlag.WorkdaysOnly;
       }
       if (this.mShowCompleted) {
         toggleStatus |= this.mToggleStatusFlag.ShowCompleted;
       }
 
       // Update the navigation bar only when changes are related to the current view.
       if (this.isVisible()) {
-        cal.navigationBar.setDateRange(startDate, endDate);
+        calendarNavigationBar.setDateRange(startDate, endDate);
       }
 
       // Check whether view range has been changed since last call to relayout().
       if (
         !this.mViewStart ||
         !this.mViewEnd ||
         this.mViewEnd.compare(viewEnd) != 0 ||
         this.mViewStart.compare(viewStart) != 0 ||
--- a/calendar/base/content/calendar-multiday-base-view.js
+++ b/calendar/base/content/calendar-multiday-base-view.js
@@ -1,13 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/* global currentView, MozElements, MozXULElement, Services,
+/* global calendarNavigationBar, currentView, MozElements, MozXULElement, Services,
    setAttributeToChildren, setBooleanAttribute, timeIndicator, gCurrentMode */
 
 "use strict";
 
 // Wrap in a block to prevent leaking to window scope.
 {
   var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
   /**
@@ -813,17 +813,17 @@
         toggleStatus |= this.mToggleStatusFlag.WorkdaysOnly;
       }
       if (this.mShowCompleted) {
         toggleStatus |= this.mToggleStatusFlag.ShowCompleted;
       }
 
       // Update the navigation bar only when changes are related to the current view.
       if (this.isVisible()) {
-        cal.navigationBar.setDateRange(viewStart, viewEnd);
+        calendarNavigationBar.setDateRange(viewStart, viewEnd);
       }
 
       // Check whether view range has been changed since last call to relayout().
       if (
         !this.mViewStart ||
         !this.mViewEnd ||
         this.mViewEnd.compare(viewEnd) != 0 ||
         this.mViewStart.compare(viewStart) != 0 ||
--- a/calendar/base/content/calendar-views-utils.js
+++ b/calendar/base/content/calendar-views-utils.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* exported switchToView, getSelectedDay, scheduleMidnightUpdate, minimonthPick,
  *          observeViewDaySelect, toggleOrientation,
  *          toggleWorkdaysOnly, toggleTasksInView, toggleShowCompletedInView,
  *          goToDate, getLastCalendarView, deleteSelectedEvents,
- *          editSelectedEvents, selectAllEvents
+ *          editSelectedEvents, selectAllEvents, calendarNavigationBar
  */
 
 /* import-globals-from calendar-chrome-startup.js */
 /* import-globals-from calendar-item-editing.js */
 /* global gCurrentMode */
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { countOccurrences } = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
@@ -586,17 +586,17 @@ function selectAllEvents() {
 
   // Need to move one day out to get all events
   let end = currentView().endDay.clone();
   end.day += 1;
 
   composite.getItems(filter, 0, currentView().startDay, end, listener);
 }
 
-cal.navigationBar = {
+var calendarNavigationBar = {
   setDateRange: function(startDate, endDate) {
     let docTitle = "";
     if (startDate) {
       let intervalLabel = document.getElementById("intervalDescription");
       let firstWeekNo = cal.getWeekInfoService().getWeekTitle(startDate);
       let secondWeekNo = firstWeekNo;
       let weekLabel = document.getElementById("calendarWeek");
       if (startDate.nativeTime == endDate.nativeTime) {