Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/resourceView-2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
zvictor committed Dec 9, 2014
2 parents bcce7ce + c01828a commit fe7d5b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ function Calendar(element, instanceOptions) {
if (elementVisible()) {
freezeContentHeight();
currentView.destroyEvents(); // no performance cost if never rendered
currentView.renderEvents(events);
currentView.renderEvents($.grep(events, function(event) {
return event.end > currentView.start && event.start < currentView.end;
}));
unfreezeContentHeight();
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/ResourceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,24 @@ function ResourceManager(options) {
*/

function fetchResources(useCache, currentView) {
var resources = cache;
var resources;

// if useCache is not defined, default to true
if (useCache || useCache === undefined || cache === undefined) {
// do a fetch resource from source, rebuild cache
cache = [];
var len = resourceSources.length;
for (var i = 0; i < len; i++) {
var resources = fetchResourceSource(resourceSources[i], currentView);
cache = cache.concat(resources);
cache = cache.concat(fetchResourceSource(resourceSources[i], currentView));
}
}

if($.isFunction(options.resourceFilter)) {
resources = $.grep(cache, options.resourceFilter);
}

else {
resources = cache;
}

if($.isFunction(options.resourceSort)) {
//todo! does it need to copy array first?
Expand Down
3 changes: 2 additions & 1 deletion src/resource/ResourceView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ ResourceView.prototype = createObject(AgendaView.prototype); // extends AgendaVi
$.extend(ResourceView.prototype, {

resources: function() {
return this.calendar.fetchResources();
this._resources = this._resources || this.calendar.fetchResources();
return this._resources;
},

hasResource: function(event, resource) {
Expand Down

0 comments on commit fe7d5b2

Please sign in to comment.