added lazyFetching option, other preparations for 1.4.5
This commit is contained in:
parent
98ed1b49aa
commit
12686b21a9
51
src/main.js
51
src/main.js
|
@ -26,6 +26,7 @@ var defaults = {
|
||||||
allDayDefault: true,
|
allDayDefault: true,
|
||||||
|
|
||||||
// event ajax
|
// event ajax
|
||||||
|
lazyFetching: true,
|
||||||
startParam: 'start',
|
startParam: 'start',
|
||||||
endParam: 'end',
|
endParam: 'end',
|
||||||
|
|
||||||
|
@ -189,7 +190,7 @@ $.fn.fullCalendar = function(options) {
|
||||||
|
|
||||||
function changeView(v) {
|
function changeView(v) {
|
||||||
if (v != viewName) {
|
if (v != viewName) {
|
||||||
ignoreWindowResize++;
|
ignoreWindowResize++; // because setMinHeight might change the height before render (and subsequently setSize) is reached
|
||||||
|
|
||||||
var oldView = view,
|
var oldView = view,
|
||||||
newViewElement;
|
newViewElement;
|
||||||
|
@ -231,7 +232,7 @@ $.fn.fullCalendar = function(options) {
|
||||||
}
|
}
|
||||||
content.css('overflow', '');
|
content.css('overflow', '');
|
||||||
if (oldView) {
|
if (oldView) {
|
||||||
setMinHeight(content, 1); // must be called after changing overflow (or mass would change)
|
setMinHeight(content, 1);
|
||||||
}
|
}
|
||||||
if (!newViewElement && view.afterShow) {
|
if (!newViewElement && view.afterShow) {
|
||||||
view.afterShow(); // called after setting min-height/overflow, so in final scroll state (for Opera)
|
view.afterShow(); // called after setting min-height/overflow, so in final scroll state (for Opera)
|
||||||
|
@ -241,9 +242,10 @@ $.fn.fullCalendar = function(options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function render(inc) {
|
function render(inc) {
|
||||||
if (elementVisible()) { // checks to make sure element is visible first
|
if (elementVisible()) {
|
||||||
ignoreWindowResize++;
|
ignoreWindowResize++; // because view.renderEvents might temporarily change the height before setSize is reached
|
||||||
|
|
||||||
if (suggestedViewHeight == undefined) {
|
if (suggestedViewHeight == undefined) {
|
||||||
calcSize();
|
calcSize();
|
||||||
|
@ -252,22 +254,22 @@ $.fn.fullCalendar = function(options) {
|
||||||
if (!view.start || inc || date < view.start || date >= view.end) {
|
if (!view.start || inc || date < view.start || date >= view.end) {
|
||||||
view.render(date, inc || 0); // responsible for clearing events
|
view.render(date, inc || 0); // responsible for clearing events
|
||||||
setSize(true);
|
setSize(true);
|
||||||
if (!eventStart || view.visStart < eventStart || view.visEnd > eventEnd) {
|
if (!eventStart || !options.lazyFetching || view.visStart < eventStart || view.visEnd > eventEnd) {
|
||||||
fetchEvents(function(events) {
|
fetchAndRenderEvents();
|
||||||
ignoreWindowResize++;
|
|
||||||
view.renderEvents(events);
|
|
||||||
ignoreWindowResize--;
|
|
||||||
});
|
|
||||||
}else{
|
}else{
|
||||||
view.renderEvents(events); // don't refetch
|
view.renderEvents(events); // don't refetch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (view.sizeDirty || view.eventsDirty) {
|
else if (view.sizeDirty || view.eventsDirty || !options.lazyFetching) {
|
||||||
view.clearEvents();
|
view.clearEvents();
|
||||||
if (view.sizeDirty) {
|
if (view.sizeDirty) {
|
||||||
setSize();
|
setSize();
|
||||||
}
|
}
|
||||||
view.renderEvents(events);
|
if (options.lazyFetching) {
|
||||||
|
view.renderEvents(events); // don't refetch
|
||||||
|
}else{
|
||||||
|
fetchAndRenderEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elementOuterWidth = element.outerWidth();
|
elementOuterWidth = element.outerWidth();
|
||||||
view.sizeDirty = false;
|
view.sizeDirty = false;
|
||||||
|
@ -285,8 +287,8 @@ $.fn.fullCalendar = function(options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view.trigger('viewDisplay', _element);
|
|
||||||
ignoreWindowResize--;
|
ignoreWindowResize--;
|
||||||
|
view.trigger('viewDisplay', _element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,6 +326,7 @@ $.fn.fullCalendar = function(options) {
|
||||||
calcSize();
|
calcSize();
|
||||||
setSize();
|
setSize();
|
||||||
view.rerenderEvents();
|
view.rerenderEvents();
|
||||||
|
view.sizeDirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,6 +411,14 @@ $.fn.fullCalendar = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for convenience
|
||||||
|
function fetchAndRenderEvents() {
|
||||||
|
fetchEvents(function(events) {
|
||||||
|
view.renderEvents(events); // maintain `this` in view
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Loading State
|
/* Loading State
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
@ -455,10 +466,8 @@ $.fn.fullCalendar = function(options) {
|
||||||
return options[name];
|
return options[name];
|
||||||
}
|
}
|
||||||
if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') {
|
if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') {
|
||||||
if (!contentSizeFixed) {
|
options[name] = value;
|
||||||
options[name] = value;
|
sizeChanged();
|
||||||
sizeChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -622,9 +631,7 @@ $.fn.fullCalendar = function(options) {
|
||||||
|
|
||||||
addEventSource: function(source) {
|
addEventSource: function(source) {
|
||||||
eventSources.push(source);
|
eventSources.push(source);
|
||||||
fetchEventSource(source, function() {
|
fetchEventSource(source, eventsChanged);
|
||||||
eventsChanged();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
removeEventSource: function(source) {
|
removeEventSource: function(source) {
|
||||||
|
@ -784,7 +791,7 @@ $.fn.fullCalendar = function(options) {
|
||||||
setTimeout(function() { // add a delay
|
setTimeout(function() { // add a delay
|
||||||
if (uid == resizeUID && !ignoreWindowResize && elementVisible()) {
|
if (uid == resizeUID && !ignoreWindowResize && elementVisible()) {
|
||||||
if (elementOuterWidth != (elementOuterWidth = element.outerWidth())) {
|
if (elementOuterWidth != (elementOuterWidth = element.outerWidth())) {
|
||||||
ignoreWindowResize++;
|
ignoreWindowResize++; // in case the windowResize callback changes the height
|
||||||
sizeChanged();
|
sizeChanged();
|
||||||
view.trigger('windowResize', _element);
|
view.trigger('windowResize', _element);
|
||||||
ignoreWindowResize--;
|
ignoreWindowResize--;
|
||||||
|
@ -814,7 +821,7 @@ $.fn.fullCalendar = function(options) {
|
||||||
// but we think it's ready now
|
// but we think it's ready now
|
||||||
function lateRender() {
|
function lateRender() {
|
||||||
setTimeout(function() { // IE7 needs this so dimensions are calculated correctly
|
setTimeout(function() { // IE7 needs this so dimensions are calculated correctly
|
||||||
if (bodyVisible() && !view.start) { // !view.start makes sure this never happens more than once
|
if (!view.start && bodyVisible()) { // !view.start makes sure this never happens more than once
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
},0);
|
},0);
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
cal = $('#calendar').fullCalendar({
|
cal = $('#calendar').fullCalendar({
|
||||||
|
//lazyFetching: false,
|
||||||
editable: true,
|
editable: true,
|
||||||
header: {
|
header: {
|
||||||
left: 'prev,next today',
|
left: 'prev,next today',
|
||||||
|
|
Loading…
Reference in a new issue