|
|
@@ -29,6 +29,7 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
|
|
|
|
|
|
isRTL: false,
|
|
|
isSelected: false, // boolean whether a range of time is user-selected or not
|
|
|
+ selectedEvent: null,
|
|
|
|
|
|
eventOrderSpecs: null, // criteria for ordering events when they have same date/time
|
|
|
|
|
|
@@ -388,13 +389,14 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
|
|
|
|
|
|
// Binds DOM handlers to elements that reside outside the view container, such as the document
|
|
|
bindGlobalHandlers: function() {
|
|
|
- this.listenTo($(document), 'mousedown', this.documentMousedown);
|
|
|
+ this.listenTo($(document), 'mousedown', this.handleDocumentMousedown);
|
|
|
+ this.listenTo($(document), 'touchend', this.handleDocumentTouchEnd);
|
|
|
},
|
|
|
|
|
|
|
|
|
// Unbinds DOM handlers from elements that reside outside the view container
|
|
|
unbindGlobalHandlers: function() {
|
|
|
- this.stopListeningTo($(document), 'mousedown');
|
|
|
+ this.stopListeningTo($(document));
|
|
|
},
|
|
|
|
|
|
|
|
|
@@ -855,7 +857,7 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
|
|
|
},
|
|
|
|
|
|
|
|
|
- /* Selection
|
|
|
+ /* Selection (time range)
|
|
|
------------------------------------------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
@@ -913,19 +915,69 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
|
|
|
},
|
|
|
|
|
|
|
|
|
- // Handler for unselecting when the user clicks something and the 'unselectAuto' setting is on
|
|
|
- documentMousedown: function(ev) {
|
|
|
- var ignore;
|
|
|
+ /* Event Selection
|
|
|
+ ------------------------------------------------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+
|
|
|
+ selectEvent: function(event) {
|
|
|
+ if (!this.selectedEvent || this.selectedEvent !== event) {
|
|
|
+ this.unselectEvent();
|
|
|
+ this.renderedEventSegEach(function(seg) {
|
|
|
+ seg.el.addClass('fc-event-selected');
|
|
|
+ }, event);
|
|
|
+ this.selectedEvent = event;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ unselectEvent: function() {
|
|
|
+ if (this.selectedEvent) {
|
|
|
+ this.renderedEventSegEach(function(seg) {
|
|
|
+ seg.el.removeClass('fc-event-selected');
|
|
|
+ }, this.selectedEvent);
|
|
|
+ this.selectedEvent = null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ /* Mouse / Touch Unselecting (time range & event unselection)
|
|
|
+ ------------------------------------------------------------------------------------------------------------------*/
|
|
|
+ // TODO: move consistently to down/start or up/end?
|
|
|
|
|
|
- // is there a selection, and has the user made a proper left click?
|
|
|
- if (this.isSelected && this.opt('unselectAuto') && isPrimaryMouseButton(ev)) {
|
|
|
|
|
|
+ handleDocumentMousedown: function(ev) {
|
|
|
+ if (isPrimaryMouseButton(ev)) {
|
|
|
+ this.processUnselect(ev);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ handleDocumentTouchEnd: function(ev) {
|
|
|
+ if (isSingleTouch(ev)) {
|
|
|
+ this.processUnselect(ev);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ processUnselect: function(ev) {
|
|
|
+ var targetEl = $(ev.target);
|
|
|
+ var ignore;
|
|
|
+
|
|
|
+ // is there a time-range selection?
|
|
|
+ if (this.isSelected && this.opt('unselectAuto')) {
|
|
|
// only unselect if the clicked element is not identical to or inside of an 'unselectCancel' element
|
|
|
ignore = this.opt('unselectCancel');
|
|
|
- if (!ignore || !$(ev.target).closest(ignore).length) {
|
|
|
+ if (!ignore || !targetEl.closest(ignore).length) {
|
|
|
this.unselect(ev);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // is there an event selection?
|
|
|
+ if (this.selectedEvent) {
|
|
|
+ if (!targetEl.closest('.fc-event-selected').length) {
|
|
|
+ this.unselectEvent();
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
|