TRUNK-3829: Code improvements for calendar.js