Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add padding to calendar to avoid accordion effects

  • Loading branch information...
commit f9fce0a6eb4157dbc1adcbe0cfa1d6a3a3b94f67 1 parent fa13836
@davec authored
View
14 public/javascripts/events_calendar.js
@@ -76,7 +76,16 @@ function makeToolTips() {
});
}
+// Add padding to the calendar to prevent accordion-like effects resulting
+// from different sized calendar months as the user navigates through the year.
+function padCalendar() {
+ var tbody = $$('#events-calendar table tbody').first();
+ var weeks = tbody.childElements();
+ $('events-calendar').setStyle({ paddingBottom: (6-weeks.length)*weeks.last().getHeight()+'px' });
+}
+
Event.onReady(function() {
+ padCalendar();
makeToolTips();
});
@@ -85,11 +94,12 @@ Event.addBehavior({
new Ajax.Request(this.href, { method: 'get',
evalJS: false,
onSuccess: function(response) {
- $('events-calendar').replace(response.responseText),
+ $('events-calendar').replace(response.responseText);
+ padCalendar();
makeToolTips();
Event.addBehavior.reload();
}
});
return false;
}
-});
+});
View
10 public/javascripts/events_calendar_jquery.js
@@ -62,11 +62,21 @@ function makeToolTips() {
});
}
+// Add padding to the calendar to prevent accordion-like effects resulting
+// from different sized calendar months as the user navigates through the year.
+function padCalendar() {
+ var tbody = $('#events-calendar table tbody');
+ var weeks = tbody.children();
+ $('#events-calendar').css('padding-bottom', (6-weeks.length)*weeks.last().height()+'px');
+}
+
$(function() {
+ padCalendar();
makeToolTips();
$('#events-calendar').delegate('.changeMonth a', 'click', function() {
$.get(this.href, function(data) {
$('#events-calendar').empty().append($(data).children());
+ padCalendar();
makeToolTips();
});
return false;
Please sign in to comment.
Something went wrong with that request. Please try again.