mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-02-23 02:16:23 +00:00
feat(calendar): Add double click to calendar create events
This commit is contained in:
@@ -66,6 +66,7 @@
|
||||
|
||||
// Update the component being dragged
|
||||
$rootScope.$on('calendar:dragend', updateComponentFromGhost);
|
||||
$rootScope.$on('calendar:doubleclick', updateComponentFromGhost);
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
// Deregister hotkeys
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
// Start dragging on mousedown
|
||||
element.on('mousedown', onDragDetect);
|
||||
element.on('dblclick', onDoubleClick);
|
||||
|
||||
// Deregister listeners when removing the element from the DOM
|
||||
scope.$on('$destroy', function() {
|
||||
@@ -218,6 +219,35 @@
|
||||
});
|
||||
}
|
||||
|
||||
function onDoubleClick(ev) {
|
||||
var block, pointerHandler, startDate, newData, newComponent;
|
||||
|
||||
startDate = calendarDayCtrl.dayString.parseDate(Preferences.$mdDateLocaleProvider, '%Y-%m-%e');
|
||||
newData = {
|
||||
type: 'appointment',
|
||||
pid: Calendar.$defaultCalendar(),
|
||||
summary: l('New Event'),
|
||||
startDate: startDate,
|
||||
isAllDay: 1
|
||||
};
|
||||
newComponent = new Component(newData);
|
||||
block = {
|
||||
component: newComponent,
|
||||
dayNumber: calendarDayCtrl.dayNumber,
|
||||
length: 0
|
||||
};
|
||||
block.component.blocks = [block];
|
||||
|
||||
pointerHandler = new SOGoEventDragPointerHandler('double-click');
|
||||
pointerHandler.initFromBlock(block);
|
||||
|
||||
// Update Component.$ghost
|
||||
Component.$ghost.pointerHandler = pointerHandler;
|
||||
|
||||
Component.$ghost.component = block.component;
|
||||
$rootScope.$emit('calendar:doubleclick');
|
||||
}
|
||||
|
||||
/**
|
||||
* SOGoCoordinates
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user