diff --git a/examples/basic.html b/examples/basic.html index 20ed56d..576c6cf 100644 --- a/examples/basic.html +++ b/examples/basic.html @@ -25,6 +25,25 @@ $(document).ready(function() { + $('input').click(function() { + + /*$('#calendar').fullCalendar("addEvent", { + id: 999, + title: "Adam Shaw", + start: "2009-05-18" + });*/ + + $('#calendar').fullCalendar("removeEvent", 3); + + /*var events = $('#calendar').fullCalendar('getEventsById', 2); + var ev1 = events[0]; + ev1.title = "yo"; + ev1.start = '2009-05-14'; + ev1.end = '2009-05-16'; + $('#calendar').fullCalendar('updateEvent', ev1);*/ + + }); + var d = new Date(); var y = d.getFullYear(); var m = d.getMonth(); @@ -69,6 +88,7 @@ +
diff --git a/fullcalendar.js b/fullcalendar.js index e61c63b..a32f120 100644 --- a/fullcalendar.js +++ b/fullcalendar.js @@ -20,10 +20,14 @@ if (typeof options == 'string') { var args = Array.prototype.slice.call(arguments, 1); + var ret; // ugly this.each(function() { - $.data(this, 'fullCalendar')[options].apply(this, args); + var r = $.data(this, 'fullCalendar')[options].apply(this, args); + if (typeof ret == 'undefined') ret = r; }); - return this; + if (typeof ret == 'undefined') + return this; + return ret; } options = options || {}; @@ -44,35 +48,33 @@ var weekStart = (options.weekStart || 0) % 7; var timeFormat = options.timeFormat || 'gx'; var titleFormat = options.titleFormat || (r2l ? 'Y F' : 'F Y'); - var tdTopBug, trTopBug, tbodyTopBug, sniffBugs = true; - - var eventSources; - var eo = options.events; - if (eo) { - if (typeof eo == 'string' || $.isFunction(eo)) { - eventSources = [eo]; - }else{ - var item = eo[0]; - if (item) { - if (typeof item == 'string' || $.isFunction(item)) - eventSources = eo; - else { - eventSources = [eo]; - } - } - } - } - else eventSources = []; - - this.each(function() { var date = options.year ? new Date(options.year, options.month || 0, 1) : new Date(); var start, end, today, numWeeks; var ignoreResizes = false; - var events; + var events = []; + + var eventSources; + var eo = options.events; + if (eo) { + if (typeof eo == 'string' || $.isFunction(eo)) { + eventSources = [eo]; + }else{ + var item = eo[0]; + if (item) { + if (typeof item == 'string' || $.isFunction(item)) + eventSources = eo; + else { + eventSources = [eo]; + } + } + } + } + else eventSources = []; + function updateMonth() { clearEvents(); @@ -99,41 +101,80 @@ updateMonth(); } - /*function updateEvent(event) { - } - - function removeEvent(event) { - var eventId = typeof event == 'object' ? event.id : event; - var newEvents = []; - for (var i=0; i