fullcalendar/src/main.js

68 lines
1.4 KiB
JavaScript
Raw Normal View History

2009-09-08 05:01:28 +02:00
2010-10-13 06:23:59 +02:00
var fc = $.fullCalendar = { version: "@VERSION" };
var fcViews = fc.views = {};
2009-09-08 05:01:28 +02:00
$.fn.fullCalendar = function(options) {
2009-09-08 05:01:28 +02:00
// method calling
if (typeof options == 'string') {
var args = Array.prototype.slice.call(arguments, 1);
var res;
2009-09-08 05:01:28 +02:00
this.each(function() {
var calendar = $.data(this, 'fullCalendar');
2010-09-19 14:01:30 +02:00
if (calendar && $.isFunction(calendar[options])) {
var r = calendar[options].apply(calendar, args);
if (res === undefined) {
res = r;
}
if (options == 'destroy') {
$.removeData(this, 'fullCalendar');
}
2009-09-21 06:57:20 +02:00
}
2009-09-08 05:01:28 +02:00
});
if (res !== undefined) {
2009-09-08 05:01:28 +02:00
return res;
}
return this;
}
2010-11-20 07:45:44 +01:00
// would like to have this logic in EventManager, but needs to happen before options are recursively extended
2009-09-08 05:01:28 +02:00
var eventSources = options.eventSources || [];
delete options.eventSources;
if (options.events) {
eventSources.push(options.events);
delete options.events;
2009-09-08 05:01:28 +02:00
}
2011-07-06 14:49:07 +02:00
2009-09-08 05:01:28 +02:00
options = $.extend(true, {},
defaults,
(options.isRTL || options.isRTL===undefined && defaults.isRTL) ? rtlDefaults : {},
2009-09-08 05:01:28 +02:00
options
);
2011-07-06 14:49:07 +02:00
this.each(function(i, _element) {
var element = $(_element);
var calendar = new Calendar(element, options, eventSources);
element.data('fullCalendar', calendar); // TODO: look into memory leak implications
calendar.render();
2009-09-08 05:01:28 +02:00
});
2011-07-06 14:49:07 +02:00
2009-09-14 12:28:23 +02:00
return this;
2011-07-06 14:49:07 +02:00
2009-09-08 05:01:28 +02:00
};
// function for adding/overriding defaults
2011-07-06 14:49:07 +02:00
var setDefaults = function(d) {
$.extend(true, defaults, d);
2009-09-08 05:01:28 +02:00
}
2009-09-08 05:01:28 +02:00
$.fullCalendar.setDefaults = setDefaults;