(js) Scroll to user's defined day start hour

This commit is contained in:
Francis Lachapelle
2015-11-23 16:22:32 -05:00
parent edf69e5989
commit c2d539d3c8
3 changed files with 16 additions and 4 deletions

View File

@@ -56,7 +56,7 @@
</div>
</md-toolbar>
<md-content class="md-flex" sg-calendar-scroll-view="monthview">
<md-content class="md-flex" sg-calendar-scroll-view="monthly">
<div class="calendarView monthView">
<md-grid-list
md-cols="7"

View File

@@ -74,7 +74,7 @@
if (Calendar.$view && Calendar.$view.type == scrollViewCtrl.type) {
// The view of the dragging block is the scrolling view of this ghost block
isRelative = scrollViewCtrl.type === 'multiday-allday' || scrollViewCtrl.type === 'monthly';
isRelative = scrollViewCtrl.type === 'multiday-allday';
originalDay = scope.block.pointerHandler.originalEventCoordinates.dayNumber;
currentDay = scope.block.pointerHandler.currentEventCoordinates.dayNumber;
start = scope.block.pointerHandler.currentEventCoordinates.start;

View File

@@ -16,8 +16,8 @@
..
</md-content>
*/
sgCalendarScrollView.$inject = ['$rootScope', '$window', '$document', '$q', '$timeout', '$mdGesture', 'Calendar', 'Component'];
function sgCalendarScrollView($rootScope, $window, $document, $q, $timeout, $mdGesture, Calendar, Component) {
sgCalendarScrollView.$inject = ['$rootScope', '$window', '$document', '$q', '$timeout', '$mdGesture', 'Calendar', 'Component', 'Preferences'];
function sgCalendarScrollView($rootScope, $window, $document, $q, $timeout, $mdGesture, Calendar, Component, Preferences) {
return {
restrict: 'A',
scope: {
@@ -65,6 +65,18 @@
// Compute coordinates of view element; recompute it on window resize
angular.element($window).on('resize', updateCoordinates);
updateCoordinates();
if (type != 'monthly')
// Scroll to the day start hour defined in the user's defaults
Preferences.ready().then(function() {
var time, hourCell, quartersOffset;
if (Preferences.defaults.SOGoDayStartTime) {
time = Preferences.defaults.SOGoDayStartTime.split(':');
hourCell = document.getElementById('hour' + parseInt(time[0]));
quartersOffset = parseInt(time[1]) * quarterHeight;
scrollView.scrollTop = hourCell.offsetTop + quartersOffset;
}
});
}
function getQuarterHeight() {