mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-07-02 17:00:06 +08:00
new callback: eventDestroy
This commit is contained in:
@@ -155,6 +155,7 @@ function Calendar(element, options, eventSources) {
|
||||
|
||||
if (currentView) {
|
||||
trigger('viewDestroy', currentView, currentView, currentView.element);
|
||||
currentView.triggerEventDestroy(); // trigger 'eventDestroy' for each event
|
||||
freezeContentHeight();
|
||||
currentView.element.remove();
|
||||
header.deactivateButton(currentView.name);
|
||||
@@ -304,6 +305,7 @@ function Calendar(element, options, eventSources) {
|
||||
|
||||
|
||||
function clearEvents() {
|
||||
currentView.triggerEventDestroy(); // trigger 'eventDestroy' for each event
|
||||
currentView.clearEvents(); // actually remove the DOM elements
|
||||
currentView.clearEventData(); // for View.js, TODO: unify with clearEvents
|
||||
}
|
||||
|
||||
+16
-5
@@ -16,6 +16,7 @@ function View(element, calendar, viewName) {
|
||||
t.clearEventData = clearEventData;
|
||||
t.eventEnd = eventEnd;
|
||||
t.reportEventElement = reportEventElement;
|
||||
t.triggerEventDestroy = triggerEventDestroy;
|
||||
t.eventElementHandlers = eventElementHandlers;
|
||||
t.showEvents = showEvents;
|
||||
t.hideEvents = hideEvents;
|
||||
@@ -33,9 +34,9 @@ function View(element, calendar, viewName) {
|
||||
|
||||
|
||||
// locals
|
||||
var eventsByID = {};
|
||||
var eventElements = [];
|
||||
var eventElementsByID = {};
|
||||
var eventsByID = {}; // eventID mapped to array of events (there can be multiple b/c of repeating events)
|
||||
var eventElementsByID = {}; // eventID mapped to array of jQuery elements
|
||||
var eventElementCouples = []; // array of objects, { event, element } // TODO: unify with segment system
|
||||
var options = calendar.options;
|
||||
|
||||
|
||||
@@ -110,8 +111,9 @@ function View(element, calendar, viewName) {
|
||||
|
||||
|
||||
function clearEventData() {
|
||||
eventElements = [];
|
||||
eventsByID = {};
|
||||
eventElementsByID = {};
|
||||
eventElementCouples = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -128,13 +130,20 @@ function View(element, calendar, viewName) {
|
||||
|
||||
// report when view creates an element for an event
|
||||
function reportEventElement(event, element) {
|
||||
eventElements.push(element);
|
||||
eventElementCouples.push({ event: event, element: element });
|
||||
if (eventElementsByID[event._id]) {
|
||||
eventElementsByID[event._id].push(element);
|
||||
}else{
|
||||
eventElementsByID[event._id] = [element];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function triggerEventDestroy() {
|
||||
$.each(eventElementCouples, function(i, couple) {
|
||||
t.trigger('eventDestroy', couple.event, couple.event, couple.element);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// attaches eventClick, eventMouseover, eventMouseout
|
||||
@@ -170,6 +179,8 @@ function View(element, calendar, viewName) {
|
||||
|
||||
|
||||
function eachEventElement(event, exceptElement, funcName) {
|
||||
// NOTE: there may be multiple events per ID (repeating events)
|
||||
// and multiple segments per event
|
||||
var elements = eventElementsByID[event._id],
|
||||
i, len = elements.length;
|
||||
for (i=0; i<len; i++) {
|
||||
|
||||
Reference in New Issue
Block a user