Avoid error if an edit popup is opened before the calendar tab

This commit is contained in:
Nathan Gray 2015-12-12 00:13:38 +00:00
parent 4503abf1bc
commit e580e7991c

View File

@ -674,55 +674,58 @@ app.classes.calendar = AppJS.extend(
return false; return false;
} }
); );
jQuery(framework.applications.calendar.tab.contentDiv).swipe('destroy') if(framework.applications.calendar && framework.applications.calendar.tab)
.swipe({ {
//Generic swipe handler for all directions jQuery(framework.applications.calendar.tab.contentDiv).swipe('destroy')
swipe:function(event, direction, distance, duration, fingerCount) { .swipe({
if(direction == "up" || direction == "down") //Generic swipe handler for all directions
{ swipe:function(event, direction, distance, duration, fingerCount) {
var at_bottom = direction !== -1; if(direction == "up" || direction == "down")
var at_top = direction !== 1; {
var at_bottom = direction !== -1;
var at_top = direction !== 1;
$j(this).children(":not(.calendar_calGridHeader)").each(function() { $j(this).children(":not(.calendar_calGridHeader)").each(function() {
// Check for less than 2px from edge, as sometimes we can't scroll anymore, but still have // Check for less than 2px from edge, as sometimes we can't scroll anymore, but still have
// 2px left to go // 2px left to go
at_bottom = at_bottom && Math.abs(this.scrollTop - (this.scrollHeight - this.offsetHeight)) <= 2; at_bottom = at_bottom && Math.abs(this.scrollTop - (this.scrollHeight - this.offsetHeight)) <= 2;
}).each(function() { }).each(function() {
at_top = at_top && this.scrollTop === 0; at_top = at_top && this.scrollTop === 0;
}); });
if(!at_bottom && !at_top && fingerCount == 1) return; if(!at_bottom && !at_top && fingerCount == 1) return;
} }
var delta = direction == "down" || direction == "right" ? -1 : 1; var delta = direction == "down" || direction == "right" ? -1 : 1;
// But we animate in the opposite direction to the swipe // But we animate in the opposite direction to the swipe
var opposite = {"down": "up", "up": "down", "left": "right", "right": "left"}; var opposite = {"down": "up", "up": "down", "left": "right", "right": "left"};
direction = opposite[direction]; direction = opposite[direction];
scroll_animate.call($j(event.target).closest('.calendar_calTimeGrid, .calendar_plannerWidget')[0], direction, delta) scroll_animate.call($j(event.target).closest('.calendar_calTimeGrid, .calendar_plannerWidget')[0], direction, delta)
return false; return false;
}, },
allowPageScroll: jQuery.fn.swipe.pageScroll.VERTICAL, allowPageScroll: jQuery.fn.swipe.pageScroll.VERTICAL,
threshold: 100, threshold: 100,
fallbackToMouseEvents: false, fallbackToMouseEvents: false,
triggerOnTouchEnd: false triggerOnTouchEnd: false
});
// Page up & page down
egw_registerGlobalShortcut(jQuery.ui.keyCode.PAGE_UP, false, false, false, function() {
if(app.calendar.state.view == 'listview')
{
return false
}
scroll_animate.call(this,"up", -1);
return true;
}); });
egw_registerGlobalShortcut(jQuery.ui.keyCode.PAGE_DOWN, false, false, false, function() {
// Page up & page down if(app.calendar.state.view == 'listview')
egw_registerGlobalShortcut(jQuery.ui.keyCode.PAGE_UP, false, false, false, function() { {
if(app.calendar.state.view == 'listview') return false
{ }
return false scroll_animate.call(this,"down", 1);
} return true;
scroll_animate.call(this,"up", -1); });
return true; }
});
egw_registerGlobalShortcut(jQuery.ui.keyCode.PAGE_DOWN, false, false, false, function() {
if(app.calendar.state.view == 'listview')
{
return false
}
scroll_animate.call(this,"down", 1);
return true;
});
}, },
/** /**