Просмотр исходного кода

allow removing specific sources with removeEventSources

Adam Shaw 9 лет назад
Родитель
Сommit
5916f2e125
2 измененных файлов с 12 добавлено и 4 удалено
  1. 1 0
      src/Calendar.js
  2. 11 4
      src/EventManager.js

+ 1 - 0
src/Calendar.js

@@ -706,6 +706,7 @@ function Calendar_constructor(element, overrides) {
 	}
 	}
 
 
 
 
+	// TODO: move this into EventManager?
 	function refetchEventSources(matchInputs) {
 	function refetchEventSources(matchInputs) {
 		if (matchInputs) {
 		if (matchInputs) {
 
 

+ 11 - 4
src/EventManager.js

@@ -23,7 +23,7 @@ function EventManager(options) { // assumed to be a calendar
 	t.getEventSourcesByMatch = getEventSourcesByMatch;
 	t.getEventSourcesByMatch = getEventSourcesByMatch;
 	t.addEventSource = addEventSource;
 	t.addEventSource = addEventSource;
 	t.removeEventSource = removeEventSource;
 	t.removeEventSource = removeEventSource;
-	t.removeEventSources = removeEventSources; // removes ALL
+	t.removeEventSources = removeEventSources;
 	t.updateEvent = updateEvent;
 	t.updateEvent = updateEvent;
 	t.renderEvent = renderEvent;
 	t.renderEvent = renderEvent;
 	t.removeEvents = removeEvents;
 	t.removeEvents = removeEvents;
@@ -345,9 +345,16 @@ function EventManager(options) { // assumed to be a calendar
 	}
 	}
 
 
 
 
-	// removes ALL event sources
-	function removeEventSources() {
-		removeSpecificEventSources(sources, true); // isAll=true
+	// if called with no arguments, removes all.
+	function removeEventSources(matchInput) {
+		if (matchInput == null) {
+			removeSpecificEventSources(sources, true); // isAll=true
+		}
+		else {
+			removeSpecificEventSources(
+				getEventSourcesByMatch(matchInput)
+			);
+		}
 	}
 	}