option getter, small optimizations, iframe fix for IE, getDate

This commit is contained in:
Adam Shaw 2009-11-23 11:50:53 +02:00
parent 32cc6c9744
commit 52df18a83b
2 changed files with 36 additions and 7 deletions

View file

@ -213,9 +213,8 @@ $.fn.fullCalendar = function(options) {
} }
function render(inc, forceUpdateSize) { function render(inc, forceUpdateSize) {
if (_element.offsetWidth !== 0) { // visible on the screen if ((elementWidth = _element.offsetWidth) !== 0) { // visible on the screen
if (!elementWidth) { if (!contentHeight) {
elementWidth = element.width();
contentHeight = calculateContentHeight(); contentHeight = calculateContentHeight();
} }
if (inc || !view.date || +view.date != +date) { // !view.date means it hasn't been rendered yet 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 // called when we know the element size has changed
function sizeChanged(fix) { function sizeChanged(fix) {
contentHeight = calculateContentHeight(); contentHeight = calculateContentHeight();
if (fix) fixContentSize(); if (fix) {
fixContentSize();
}
view.updateSize(contentHeight); view.updateSize(contentHeight);
if (fix) unfixContentSize(); if (fix) {
unfixContentSize();
}
sizesDirtyExcept(view); sizesDirtyExcept(view);
view.rerenderEvents(true); view.rerenderEvents(true);
} }
@ -403,7 +406,14 @@ $.fn.fullCalendar = function(options) {
return view; return view;
}, },
getDate: function() {
return date;
},
option: function(name, value) { option: function(name, value) {
if (value == undefined) {
return options[name];
}
if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') { if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') {
options[name] = value; options[name] = value;
sizeChanged(); sizeChanged();
@ -752,6 +762,15 @@ $.fn.fullCalendar = function(options) {
// let's begin... // let's begin...
changeView(options.defaultView); 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);
}
}); });
return this; return this;

View file

@ -111,6 +111,14 @@
console.log(view.start + ' --- ' + view.end + ' "' + view.title + '"'); 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 gcalFeed = $.fullCalendar.gcalFeed("http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic");
var jsonFeed = "../examples/json-events.php"; var jsonFeed = "../examples/json-events.php";
@ -163,8 +171,10 @@
<button onclick="cal.fullCalendar('changeView', 'month')">change to month</button> <button onclick="cal.fullCalendar('changeView', 'month')">change to month</button>
<button onclick="cal.fullCalendar('changeView', 'basicWeek')">change to basicWeek</button> <button onclick="cal.fullCalendar('changeView', 'basicWeek')">change to basicWeek</button>
<button onclick="cal.fullCalendar('changeView', 'basicDay')">change to basicDay</button> <button onclick="cal.fullCalendar('changeView', 'basicDay')">change to basicDay</button>
<button onclick="getView()">view info</button> <button onclick="getView()">getView</button>
<button onclick="cal.width(1100)" onclick=''>change size</button> <button onclick="getDate()">getDate</button>
<button onclick="optionGetter()">option getter</button>
<button onclick="cal.width(1100)">change size</button>
<button onclick="cal.fullCalendar('render')">render</button> <button onclick="cal.fullCalendar('render')">render</button>
</p> </p>