Skip to content

Commit

Permalink
Bugfix: Scroll viewport to selected date
Browse files Browse the repository at this point in the history
  • Loading branch information
Suva authored and eeroan committed Mar 5, 2013
1 parent 9feb7bd commit beefdbb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
4 changes: 4 additions & 0 deletions History.textile
@@ -1,3 +1,7 @@
h3. Nightly

* Bugfix: Scroll viewport to selected date

h3. 2.4.2

* Move calendar rendering to separate module
Expand Down
4 changes: 2 additions & 2 deletions build/jquery.continuousCalendar-latest-min.js

Large diffs are not rendered by default.

15 changes: 6 additions & 9 deletions build/jquery.continuousCalendar-latest.js
@@ -1,4 +1,4 @@
$.continuousCalendar = {};$.continuousCalendar.version = '2.4.2';$.continuousCalendar.released = '2013-02-23'
$.continuousCalendar = {};$.continuousCalendar.version = '';$.continuousCalendar.released = '2013-03-05'
;
(function(root, factory) {
if(typeof define === "function" && define.amd) {
Expand Down Expand Up @@ -1275,10 +1275,7 @@ $.continuousCalendar = {};$.continuousCalendar.version = '2.4.2';$.continuousCal
});
(function(root, factory) {
if(typeof define === 'function' && define.amd) {
define(['jquery', 'jquery.tinyscrollbar', './DateFormat', './DateLocale', './DateRange', './DateTime', './CalendarBody', './RangeEvents'],
function($, _tinyscrollbar, DateFormat, DateLocale, DateRange, DateTime, CalendarBody, RangeEvents) {
factory($, DateFormat, DateLocale, DateRange, DateTime, CalendarBody, RangeEvents)
})
define(['jquery', './DateFormat', './DateLocale', './DateRange', './DateTime', './CalendarBody', './RangeEvents', 'jquery.tinyscrollbar'], factory)
} else {
factory(root.jQuery, root.DateFormat, root.DateLocale, root.DateRange, root.DateTime, root.CalendarBody, RangeEvents)
}
Expand Down Expand Up @@ -1360,6 +1357,7 @@ $.continuousCalendar = {};$.continuousCalendar.version = '2.4.2';$.continuousCal
popupBehavior.initState()
dateBehavior.addRangeLengthLabel()
dateBehavior.initEvents()
scrollToSelection()
}

function determineRangeToRenderFormParams(params) {
Expand Down Expand Up @@ -1455,7 +1453,7 @@ $.continuousCalendar = {};$.continuousCalendar.version = '2.4.2';$.continuousCal
}
var inlineVersion = {
initUI : initCalendarTable,
initState : calculateCellHeightAndSetScroll,
initState : calculateCellHeightAndInitScroll,
getContainer : function(newContainer) {
return newContainer
},
Expand Down Expand Up @@ -1484,7 +1482,7 @@ $.continuousCalendar = {};$.continuousCalendar.version = '2.4.2';$.continuousCal
}

function scrollToSelection() {
var selectionStartOrToday = $('.selected, .today', calendarBody.scrollContent).get(0)
var selectionStartOrToday = $('.selected', calendarBody.scrollContent).get(0) || $('.today', calendarBody.scrollContent).get(0)
if(selectionStartOrToday) {
var position = selectionStartOrToday.offsetTop - (calendarBody.scrollContent.height() - selectionStartOrToday.offsetHeight) / 2
if(params.customScroll) {
Expand All @@ -1507,11 +1505,10 @@ $.continuousCalendar = {};$.continuousCalendar.version = '2.4.2';$.continuousCal
calendarBody.yearTitle.text(date.getFullYear())
}

function calculateCellHeightAndSetScroll() {
function calculateCellHeightAndInitScroll() {
initScrollBar()
calculateCellHeight()
setYearLabel()
scrollToSelection()
}

function calculateCellHeight() { averageCellHeight = parseInt(calendarBody.bodyTable.height() / $('tr', calendarBody.bodyTable).size(), 10) }
Expand Down
8 changes: 4 additions & 4 deletions src/main/jquery.continuousCalendar.js
Expand Up @@ -83,6 +83,7 @@
popupBehavior.initState()
dateBehavior.addRangeLengthLabel()
dateBehavior.initEvents()
scrollToSelection()
}

function determineRangeToRenderFormParams(params) {
Expand Down Expand Up @@ -178,7 +179,7 @@
}
var inlineVersion = {
initUI : initCalendarTable,
initState : calculateCellHeightAndSetScroll,
initState : calculateCellHeightAndInitScroll,
getContainer : function(newContainer) {
return newContainer
},
Expand Down Expand Up @@ -207,7 +208,7 @@
}

function scrollToSelection() {
var selectionStartOrToday = $('.selected, .today', calendarBody.scrollContent).get(0)
var selectionStartOrToday = $('.selected', calendarBody.scrollContent).get(0) || $('.today', calendarBody.scrollContent).get(0)
if(selectionStartOrToday) {
var position = selectionStartOrToday.offsetTop - (calendarBody.scrollContent.height() - selectionStartOrToday.offsetHeight) / 2
if(params.customScroll) {
Expand All @@ -230,11 +231,10 @@
calendarBody.yearTitle.text(date.getFullYear())
}

function calculateCellHeightAndSetScroll() {
function calculateCellHeightAndInitScroll() {
initScrollBar()
calculateCellHeight()
setYearLabel()
scrollToSelection()
}

function calculateCellHeight() { averageCellHeight = parseInt(calendarBody.bodyTable.height() / $('tr', calendarBody.bodyTable).size(), 10) }
Expand Down

0 comments on commit beefdbb

Please sign in to comment.