From 52df18a83bdc80297bcd931b1a74894cc2d88bec Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Mon, 23 Nov 2009 11:50:53 +0200 Subject: [PATCH] option getter, small optimizations, iframe fix for IE, getDate --- src/main.js | 29 ++++++++++++++++++++++++----- tests/methods.html | 14 ++++++++++++-- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/main.js b/src/main.js index 6137696..48c2804 100755 --- a/src/main.js +++ b/src/main.js @@ -213,9 +213,8 @@ $.fn.fullCalendar = function(options) { } function render(inc, forceUpdateSize) { - if (_element.offsetWidth !== 0) { // visible on the screen - if (!elementWidth) { - elementWidth = element.width(); + if ((elementWidth = _element.offsetWidth) !== 0) { // visible on the screen + if (!contentHeight) { contentHeight = calculateContentHeight(); } if (inc || !view.date || +view.date != +date) { // !view.date means it hasn't been rendered yet @@ -286,9 +285,13 @@ $.fn.fullCalendar = function(options) { // called when we know the element size has changed function sizeChanged(fix) { contentHeight = calculateContentHeight(); - if (fix) fixContentSize(); + if (fix) { + fixContentSize(); + } view.updateSize(contentHeight); - if (fix) unfixContentSize(); + if (fix) { + unfixContentSize(); + } sizesDirtyExcept(view); view.rerenderEvents(true); } @@ -403,7 +406,14 @@ $.fn.fullCalendar = function(options) { return view; }, + getDate: function() { + return date; + }, + option: function(name, value) { + if (value == undefined) { + return options[name]; + } if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') { options[name] = value; sizeChanged(); @@ -751,6 +761,15 @@ $.fn.fullCalendar = function(options) { // let's begin... changeView(options.defaultView); + + // in IE, when in 0x0 iframe, initial resize never gets called, so do this... + if ($.browser.msie && !$('body').width()) { + setTimeout(function() { + render(); + content.hide().show(); // needed for IE 6 + view.rerenderEvents(); // needed for IE 7 + }, 0); + } }); diff --git a/tests/methods.html b/tests/methods.html index 6bddafc..e689b73 100644 --- a/tests/methods.html +++ b/tests/methods.html @@ -111,6 +111,14 @@ console.log(view.start + ' --- ' + view.end + ' "' + view.title + '"'); } + function getDate() { + console.log(cal.fullCalendar('getDate')); + } + + function optionGetter() { + console.log(cal.fullCalendar('option', 'editable')); + } + var gcalFeed = $.fullCalendar.gcalFeed("http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic"); var jsonFeed = "../examples/json-events.php"; @@ -163,8 +171,10 @@ - - + + + +