Skip to content

Commit

Permalink
Trunk-3839: Support for future dates in jQuery calendar
Browse files Browse the repository at this point in the history
Follow up to remove stray alert message - TRUNK-3829
(cherry picked from commit 923e6ab)
  • Loading branch information
bhashitha authored and dkayiwa committed May 29, 2013
1 parent 2785f88 commit 38c528e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions webapp/src/main/webapp/WEB-INF/view/scripts/calendar/calendar.js
Expand Up @@ -11,8 +11,50 @@ function showCalendar(obj, yearsPrevious) {

var dp = new DatePicker(jsDateFormat, obj.id, opts);
jQuery.datepicker.setDefaults(jQuery.datepicker.regional[jsLocale]);
obj.onclick = null;
dp.show();
return false;
}

/**
* Overload the showCalendar(obj, yearsPrevious) function for support
* future dates in jQuery date picker
*
* @param HTMLInputElement obj HTML element
* @param integer yearsPrevious Backward year range
* @param yearsNext yearsNext Forward year range
* @returns {Boolean}
*/
function showCalendar(obj, yearsPrevious, yearsNext) {

// if the object doesn't have an id, just set it to some random text so jq can use it
if(!obj.id) {
obj.id = "something_random" + (Math.random()*1000);
}

//set appendText to something so it doesn't automagically pop into the page
var opts = { appendText: " " };

//set yearPrevious to 110 if it has'nt been parsed in an argument
if (!yearsPrevious){
yearsPrevious= 110;
}

//set yearsNext to 10 if it has'nt been parsed in an argument
if (!yearsNext){
yearsNext= 10;
}

if (yearsPrevious && yearsNext) {
opts["yearRange"] = "-"+yearsPrevious+":+"+yearsNext;
}

var dp = new DatePicker(jsDateFormat, obj.id, opts);
jQuery.datepicker.setDefaults(jQuery.datepicker.regional[jsLocale]);
obj.onclick = null;
dp.show();

return false;

}

0 comments on commit 38c528e

Please sign in to comment.