Skip to content

Instantly share code, notes, and snippets.

@steveh
Created January 17, 2012 03:11
Show Gist options
  • Select an option

  • Save steveh/1624322 to your computer and use it in GitHub Desktop.

Select an option

Save steveh/1624322 to your computer and use it in GitHub Desktop.
var ProphetCalendar = new Class({
initialize: function (a) {
var d = this;
for (var c in a) {
d[c] = a[c];
}
this.calendarShown = false;
this.Date355 = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getDate() + 355);
this.firstMonth = new Date(this.today.getFullYear(), this.today.getMonth(), 1);
this.endFirstMonth = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getLastDayOfMonth());
this.lastMonth = new Date(this.Date355.getFullYear(), this.Date355.getMonth(), 1);
this.fdd = 0;
this.daysOffset = 1;
this.monthsDisplayed = [];
this.daysDisplayed = [];
this.defaultDaysBetween = 2;
this.classes = ["calmain", "monthSlider"];
this.slideSpeed = 250;
this.monthWidth = 197;
this.monthToGoTo = 0;
this.title = "Select Date";
this.daysOfTheWeek = prophetConfig.getValue("wsr.calendar.dayofweek.names", ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]);
this.longMonths = prophetConfig.getValue("wsr.calendar.month.long.names", ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]);
this.shortMonths = prophetConfig.getValue("wsr.calendar.month.names", ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]);
this.prevMonthEnabled = false;
this.nextMonthEnabled = false;
this.prevButton = null;
this.nextButton = null;
this.isDepartureField = true;
this.departureDateField = $("date-one-input");
this.departureTimeField = $("date-one-time");
this.departureDate = null;
this.departureDateTemp = null;
this.returnDateField = $("date-two-input");
this.returnTimeField = $("date-two-time");
this.returnDate = null;
this.returnDateTemp = null;
this.hasTime = false;
var e = this.departureDateField.value;
var b = this.returnDateField.value;
if (this.prophetFinder.mode == "rentalcars") {
e = this.departureDateField.value.substr(0, this.departureDateField.value.indexOf(" at"));
b = this.returnDateField.value.substr(0, this.departureDateField.value.indexOf(" at"));
}
this.departureDateTemp = this.departureDate = this.tryParsingDate(e);
this.returnDateTemp = this.returnDate = this.tryParsingDate(b);
},
showCalendar: function (c, d) {
var b = window.event || c;
if (!b.target) {
b.target = b.srcElement;
}
if (!this.calendarShown) {
this.hasTime = ($$("select.time").length > 0);
if (this.hasTime) {
$$("select.time").addEvents({
"blur": function (f) {
this.updateCalendar(f);
}.bind(this),
"change": function (f) {
this.updateCalendar(f);
}.bind(this)
});
}
var a = this.departureDateField.getPosition("subviewContainer").y - 37;
this.calContainer.setStyle("top", a);
this.calContainer.addEvent("click", function (f) {
f.stop();
});
$(document.body).addEvent("click", function (f) {
f.stop();
if (f.target != this.departureDateField && f.target != this.returnDateField && !f.target.hasClass("time") && f.target.get("tag").toLowerCase() != "option") {
this.closeCalendar();
}
}.bind(this));
if (b.target == this.returnDateField) {
this.isDepartureField = false;
} else {
this.isDepartureField = true;
}
this.setDateInputListener(this.departureDateField);
this.setDateInputListener(this.returnDateField);
this.currentDate = new Date();
this.drawCalendar();
this.updateCalendar(b);
if (this.theCali) {
this.theCali.style.display = "block";
this.theCali.setStyle("top", a);
}
}
this.calendarShown = true;
},
drawCalendar: function () {
this.calContainer.empty();
var c = new Element("div", {
"class": "crss"
});
c.inject(this.calContainer);
var e = new Element("a", {
"class": "btnclosecross",
"href": "javascript:nothing();",
"title": prophetConfig.getValue("wsr.calendar.close.title")
});
var b = function () {
this.closeCalendar();
return false;
}.bind(this);
e.addEvent("click", b);
e.inject(c);
var d = new Element("img", {
"align": "middle",
"src": "https://flightbookings.airnewzealand.co.nz/prophet/fffassets/websiterefreshSS/calendar-close-24x23.png",
"width": "24",
"height": "23",
"alt": "Close calendar",
"border": "0"
});
d.inject(e);
var g = new Element("div", {
"class": "calmain"
});
g.inject(this.calContainer);
this.calDiv = new Element("div", {
"id": "calDiv",
"class": "acldr"
});
this.calDiv.inject(g);
this.prevButton = this.getPrevButton().inject(this.calDiv);
this.nextButton = this.getNextButton().inject(this.calDiv);
if (!this.monthsSlider) {
this.monthsSlider = new Element("div", {
"class": "months-slider"
});
} else {
this.monthsSlider.empty();
}
var f;
var a;
if (this.departureDate) {
f = new Date(this.departureDate);
} else {
if (!this.departureDate && this.returnDate) {
f = new Date(this.returnDate).decrement("month", 1);
} else {
f = new Date(this.today);
}
}
a = new Date(f).increment("month", 1);
this.generateMonth(f, "left");
this.generateMonth(a, "right");
this.updateDateMarkers();
this.updateArrows();
this.monthsSlider.inject(this.calDiv);
this.calContainer.style.display = "block";
},
toggleSearchType: function (b) {
b = new Event(b);
var a = $("search-type");
if (a) {
a.value = (b.target.checked) ? "flexible" : "fixed";
}
},
generateMonth: function (e, d) {
var b = new Date(e.getFullYear(), e.getMonth(), 1);
var c = new Element("div", {
"class": "month"
});
this.generateMonthsDropDown(b, d).inject(c);
var a = new Element("table");
a.addEvents({
"mouseleave": function (g) {
this.departureDateTemp = this.departureDate;
this.returnDateTemp = this.returnDate;
this.updateDateMarkers();
}.bind(this)
});
this.getDayNames().inject(a);
var f = this.generateDays(b);
f.tbody.inject(a);
a.inject(c);
this.addMonthDisplay(b, c, f.validDays, d);
return c;
},
addMonthDisplay: function (c, b, d, a) {
if (this.monthsDisplayed.length > 0) {
if (a === "left") {
b.setStyle("left", (parseInt(this.monthsDisplayed[0][1].getStyle("left")) - 197));
this.monthsDisplayed.unshift([c, b, d]);
} else {
b.setStyle("left", (parseInt(this.monthsDisplayed[this.monthsDisplayed.length - 1][1].getStyle("left")) + 197));
this.monthsDisplayed.push([c, b, d]);
}
} else {
b.setStyle("left", 0);
this.monthsDisplayed.push([c, b, d]);
}
b.inject(this.monthsSlider);
},
generateMonthsDropDown: function (b, g) {
var i = new Element("select", {
"class": g
});
var h = new Date(this.firstMonth.getFullYear(), this.firstMonth.getMonth(), 1).diff(this.lastMonth, "month");
for (var c = 0; c <= h; c++) {
var l = new Date(this.today.getFullYear(), this.today.getMonth() + c);
var k = this.longMonths[l.getMonth()];
var f = l.getFullYear();
var e = prophetConfig.getValue("calendar.header.format", "$0 $1");
var a = prophetCommon.getStr(e, k, f);
var j = new Option(a, l);
try {
i.add(j, null);
} catch (d) {
i.add(j);
}
if (l.getFullYear() == b.getFullYear() && l.getMonth() == b.getMonth()) {
j.selected = "selected";
}
}
i.addEvent("change", function (m) {
this.replaceCalendar(m.target.value, m.target.get("class"));
}.bind(this));
return i;
},
getInactiveDays: function (c) {
var b = [];
var g = new Date(c.getFullYear(), c.getMonth(), c.getDate());
if (+g <= +this.endFirstMonth) {
var f = this.today.getDate();
for (var h = 0; h < f; ++h) {
b.push(h);
}
}
if (+g >= +this.lastMonth) {
var e = this.Date355.getDate() + 1;
var a = this.lastMonth.getLastDayOfMonth() + 1;
for (var h = e; h < a; ++h) {
b.push(h);
}
}
return b;
},
generateDays: function (a) {
var e = new Element("tbody");
var n = [];
var g = a.getLastDayOfMonth();
var k = this.getInactiveDays(a);
var f;
if (a.diff(this.today, "month") > 0) {
f = k[k.length - 1];
k.pop();
}
var l = 1;
var h = (new Date(a.getFullYear(), a.getMonth(), 1).getDay() + 7 - this.daysOffset) % 7;
tr = new Element("tr").injectInside(e);
for (var d = 0; d < 7; d++) {
for (var c = 0; c <= 6; c++) {
var b = new Element("td").injectInside(tr);
if (l <= g && (d > 0 || c >= h)) {
if (!k.contains(l)) {
var m = new Date(a.getFullYear(), a.getMonth(), l);
b.set("title", m.format(this.prophetFinder.dateFormat).trim().clean());
b.addEvents({
"click": function (i) {
this.updateCalendar(i);
}.bind(this),
"mouseover": function (i) {
this.updateCalendar(i);
}.bind(this)
});
n.push({
date: m,
container: b
});
} else {
if (f && l == f) {
var m = new Date(a.getFullYear(), a.getMonth(), l);
b.set("title", m.format(this.prophetFinder.dateFormat));
b.addEvents({
"click": function (i) {
this.updateCalendar(i);
}.bind(this),
"mouseover": function (i) {
this.updateCalendar(i);
}.bind(this)
});
b.addClass("inactive");
n.push({
date: m,
container: b
});
} else {
b.addClass("inactive");
}
}
b.appendText(l++);
}
}
if (l > g) {
break;
} else {
tr = new Element("tr").injectInside(e);
}
}
return new Object({
tbody: e,
validDays: n
});
},
closeCalendar: function () {
this.monthsDisplayed = [];
if ($defined(this.calContainer)) {
this.calContainer.style.display = "none";
}
if ($defined(this.theCali)) {
this.theCali.style.display = "none";
}
this.departureDateField.getParent(".input-container").removeClass("departure-focus");
this.returnDateField.getParent(".input-container").removeClass("return-focus");
this.updateDateDisplay(this.departureDateField);
this.updateDateDisplay(this.returnDateField);
this.calContainer.removeEvents();
$(document.body).removeEvents();
this.calendarShown = false;
},
getDayNames: function () {
var d = new Element("thead");
var c = new Element("tr").injectInside(d);
for (var a = 0; a <= 6; a++) {
var b = this.daysOfTheWeek[(a + this.daysOffset) % 7];
c.adopt(new Element("th", {
"title": b
}).appendText(b));
}
return d;
},
getPrevButton: function () {
var c = "Go to the previous month";
var a = new Element("div", {
"class": "ar prev"
});
var b = new Element("a", {
"href": "javascript:nothing();",
"title": prophetConfig.getValue("wsr.calendar.gopreviousmonth.title", c)
});
b.inject(a);
b.set("id", this.id + "-prev");
a.addEvent("click", function () {
if (this.prevMonthEnabled) {
this.monthToGoTo--;
this.slideCalendar();
this.updateArrows("prev");
return false;
}
}.bind(this));
return a;
},
getNextButton: function () {
var c = "Go to the next month";
var b = new Element("div", {
"class": "ar next"
});
var a = new Element("a", {
"href": "javascript:nothing();",
"title": prophetConfig.getValue("wsr.calendar.gonextmonth.title", c)
});
a.set("id", this.id + "-next");
a.inject(b);
b.addEvent("click", function () {
if (this.nextMonthEnabled) {
this.monthToGoTo++;
this.slideCalendar();
this.updateArrows("next");
return false;
}
}.bind(this));
return b;
},
slideCalendar: function () {
if (!this.isSliding) {
this.isSliding = true;
var b;
if (this.monthToGoTo > 0) {
if (this.setNextButtonActive) {
b = new Date(this.monthsDisplayed[this.monthsDisplayed.length - 1][0]);
b.setMonth(b.getMonth() + 1);
var a = this.generateMonth(b, "right");
}
} else {
b = new Date(this.monthsDisplayed[0][0]);
b.setMonth(b.getMonth() - 1);
var a = this.generateMonth(b, "left");
}
this.updateDateMarkers();
this.monthsDisplayed.each(function (f, c) {
var d = this.monthWidth * c;
if (this.monthToGoTo > 0) {
d -= this.monthWidth;
}
var e = new Fx.Morph(f[1], {
duration: this.slideSpeed,
transition: Fx.Transitions.Sine.easeOut,
onComplete: function () {
this.monthToGoTo = 0;
var g = parseInt(f[1].getStyle("left"));
if (g < 0 || (g >= 2 * this.monthWidth)) {
this.removeMonth(f);
}
this.isSliding = false;
}.bind(this, f)
});
e.start({
"left": d
});
f[1].getElement("select").className = ((c % 2 && this.monthToGoTo > 0) || ((c + 1) % 2 && this.monthToGoTo < 0)) ? "left" : "right";
}.bind(this));
}
},
removeMonth: function (a) {
a[1].destroy();
this.monthsDisplayed.erase(a);
},
replaceCalendar: function (b, c) {
while (this.monthsDisplayed.length > 0) {
this.removeMonth(this.monthsDisplayed[0]);
}
var a = new Date(b);
if (c === "left") {
if (a < this.lastMonth) {
this.generateMonth(a, "left");
var d = new Date(a.getFullYear(), a.getMonth() + 1, 1);
this.generateMonth(d, "right");
} else {
var e = new Date(a.getFullYear(), a.getMonth() - 1, 1);
this.generateMonth(e, "left");
this.generateMonth(a, "right");
}
} else {
if (a > this.firstMonth) {
var e = new Date(a.getFullYear(), a.getMonth() - 1, 1);
this.generateMonth(e, "left");
this.generateMonth(a, "right");
} else {
this.generateMonth(a, "left");
var d = new Date(a.getFullYear(), a.getMonth() + 1, 1);
this.generateMonth(d, "right");
}
}
this.updateDateMarkers();
this.updateArrows();
},
evaluateSpecialKeyInput: function (b) {
var a;
if (b.code === 27) {
b.stop();
a = (this.isDepartureField) ? this.departureDateTemp : this.returnDateTemp;
if (a && !isNaN(a) && a != "" && String(a).toLowerCase() != "invalid date" && this.isInDateRange(a)) {
this.setTypedDate(a);
this.updateDateMarkers();
}
b.target.blur();
this.closeCalendar();
} else {
if (b.code === 9 || b.code === 13) {
b.stop();
a = (this.isDepartureField) ? this.departureDateTemp : this.returnDateTemp;
if (a && !isNaN(a) && a != "" && String(a).toLowerCase() != "invalid date" && this.isInDateRange(a)) {
this.setTypedDate(a);
this.updateDateMarkers();
}
if (!this.hasTime) {
this.moveOn(true);
} else {
b.target.getSiblings(".time")[0].focus();
}
}
}
},
evaluateTypedDateInput: function (b) {
var a;
a = this.tryParsingDate(b.target.value);
if (a && !isNaN(a) && a != "" && String(a).toLowerCase() != "invalid date" && this.isInDateRange(a)) {
this.updateTypedDate(a);
this.updateDateMarkers();
}
},
tryParsingDate: function (f) {
var d = f.toString();
var a = d.replace(new RegExp(this.prophetFinder.dayRegexString, "ig"), "").trim().clean();
var e = new RegExp("^ *[0-9.,-/ ]+ *$", "ig");
if (e.test(a)) {
a = a.replace(/ /gi, "-");
} else {
a = a.replace(/[.,-\/]{1,}/gi, " ").clean();
}
var b = Date.parse(a);
if (b) {
b.clearTime();
}
var c = new Date(this.today).decrement("day", 1);
if (b && b < c) {
if (b.getFullYear() == this.today.getFullYear()) {
if (b.getMonth() == this.today.getMonth()) {
b.increment("month", 1);
} else {
b.increment("year", (this.today.getFullYear() - b.getFullYear() + 1));
}
}
}
return b;
},
setDateInputListener: function (a) {
if (a) {
a.addEvents({
"keydown": function (b) {
this.updateCalendar(b);
}.bind(this),
"keyup": function (b) {
this.updateCalendar(b);
}.bind(this),
"focus": function (b) {
this.updateCalendar(b);
}.bind(this),
"blur": function (b) {
this.updateCalendar(b);
}.bind(this),
"change": function (b) {
this.updateCalendar(b);
}.bind(this)
});
}
},
isInDateRange: function (b) {
var c = true;
var a = new Date(b);
if (a.diff(this.today, "day") > 1 || a.diff(this.Date355, "day") < 0) {
c = false;
}
return c;
},
updateCalendar: function (b) {
switch (true) {
case b.target.get("tag") == "td" && b.type == "click":
var a = this.tryParsingDate(b.target.get("title"));
this.updateTypedDate(a);
this.setClickedDate(a);
this.updateDateMarkers();
break;
case b.target.get("tag") == "td" && b.type == "mouseover":
var a = this.tryParsingDate(b.target.get("title"));
this.updateClickedDate(a);
this.updateDateMarkers();
break;
case b.target === this.departureDateField && b.type == "keyup":
this.evaluateTypedDateInput(b);
break;
case b.target === this.departureDateField && b.type == "keydown":
this.evaluateSpecialKeyInput(b);
break;
case b.target === this.departureDateField && b.type == "focus":
if (this.departureDate) {
b.target.value = this.departureDate.format(this.prophetFinder.dateFormat);
} else {
b.target.value = "";
}
b.target.getParent(".input-container").addClass("departure-focus");
this.returnDateField.getParent(".input-container").removeClass("return-focus");
this.updateDateDisplay(this.returnDateField);
this.isDepartureField = true;
this.focusDateLabel(b.target);
this.updateDateMarkers();
break;
case b.target === this.departureDateField && b.type == "change":
case b.target === this.departureDateField && b.type == "blur":
this.updateDateLabel(b.target);
this.setTypedDate(this.departureDateTemp);
this.updateDateMarkers();
break;
case b.target === this.returnDateField && b.type == "keyup":
this.evaluateTypedDateInput(b);
break;
case b.target === this.returnDateField && b.type == "keydown":
this.evaluateSpecialKeyInput(b);
break;
case b.target === this.returnDateField && b.type == "focus":
if (this.returnDate) {
b.target.value = this.returnDate.format(this.prophetFinder.dateFormat);
} else {
b.target.value = "";
}
b.target.getParent(".input-container").addClass("return-focus");
this.departureDateField.getParent(".input-container").removeClass("departure-focus");
this.updateDateDisplay(this.departureDateField);
this.isDepartureField = false;
this.focusDateLabel(b.target);
this.resetDateMarkers();
break;
case b.target === this.returnDateField && b.type == "change":
case b.target === this.returnDateField && b.type == "blur":
this.updateDateLabel(b.target);
this.setTypedDate(this.returnDateTemp);
this.updateDateMarkers();
break;
case b.target.hasClass("time") && b.type == "blur":
case b.target.hasClass("time") && b.type == "change":
this.moveOn(true);
break;
default:
break;
}
},
resetDepartureDate: function () {
this.departureDateTemp = this.departureDate = null;
this.departureDateField.value = "";
this.prophetFinder.departureDateHidden.value = "";
this.prophetFinder.departureMonthHidden.value = "";
},
resetReturnDate: function () {
this.returnDateTemp = this.returnDate = null;
this.returnDateField.value = "";
this.prophetFinder.returnDateHidden.value = "";
this.prophetFinder.returnMonthHidden.value = "";
},
updateTypedDate: function (b) {
var c = new Date(this.monthsDisplayed[0][0]);
var d = new Date(this.monthsDisplayed[this.monthsDisplayed.length - 1][0].getFullYear(), this.monthsDisplayed[this.monthsDisplayed.length - 1][0].getMonth(), this.monthsDisplayed[this.monthsDisplayed.length - 1][0].getLastDayOfMonth());
var a = (b > c && b < d);
if (!a) {
if (!this.departureDate || this.isDepartureField || (b >= this.departureDate)) {
if (b.diff(this.Date355, "month") > 0 && (this.isDepartureField || b.diff(this.today, "month") <= 0)) {
this.replaceCalendar(b, "left");
} else {
this.replaceCalendar(b, "right");
}
}
}
if (b && this.isInDateRange(b)) {
if (this.isDepartureField) {
this.departureDateTemp = new Date(b);
} else {
this.returnDateTemp = new Date(b);
}
}
},
setTypedDate: function (a) {
this.updateDateData(a);
},
updateClickedDate: function (a) {
if (a && this.isInDateRange(a)) {
if (this.isDepartureField) {
this.departureDateTemp = new Date(a);
} else {
this.returnDateTemp = new Date(a);
}
}
},
setClickedDate: function (a) {
this.updateDateData(a);
if (!this.hasTime) {
this.moveOn(false);
} else {
if (this.isDepartureField) {
this.departureDateField.getSiblings(".time")[0].focus();
} else {
this.returnDateField.getSiblings(".time")[0].focus();
}
}
},
updateDateDisplay: function (a) {
var b;
if (a == this.departureDateField && this.departureDate) {
b = new Date(this.departureDate).format(this.prophetFinder.dateFormat);
if (this.hasTime) {
b += " at " + this.departureTimeField.value + " hrs";
}
this.departureDateField.value = b;
}
if (a == this.returnDateField && this.returnDate) {
var b = new Date(this.returnDate).format(this.prophetFinder.dateFormat);
if (this.hasTime) {
b += " at " + this.returnTimeField.value + " hrs";
}
this.returnDateField.value = b;
this.updateDateLabel(this.returnDateField);
}
},
updateDateData: function (a) {
if (a && this.isInDateRange(a)) {
var b = new Date(a).format(this.prophetFinder.dateFormat);
if (this.isDepartureField) {
this.departureDate = this.departureDateTemp;
this.prophetFinder.setDateOne(a);
if (this.returnDate && (this.departureDate > this.returnDate)) {
this.resetReturnDate();
}
} else {
this.returnDate = this.returnDateTemp;
this.prophetFinder.setDateTwo(a);
if (this.departureDate && (this.departureDate > this.returnDate)) {
this.resetDepartureDate();
}
}
} else {
if (this.isDepartureField) {
this.resetDepartureDate();
} else {
this.resetReturnDate();
}
}
},
moveOn: function (b) {
var a = true;
var c = this.returnDateField.getSiblings("input#return-flight-hidden");
if (c.length > 0) {
a = (c[0].get("value") == "return");
}
if (this.departureDate) {
this.updateDateLabel(this.departureDateField);
this.updateDateDisplay(this.departureDateField);
}
if (this.returnDate) {
this.updateDateLabel(this.returnDateField);
this.updateDateDisplay(this.returnDateField);
}
if ((this.departureDate && this.returnDate) || (this.departureDate && !a)) {
if (b && this.postCalendarFocusField) {
this.postCalendarFocusField.focus();
}
this.closeCalendar();
} else {
if (this.isDepartureField) {
this.returnDateField.focus();
} else {
this.departureDateField.focus();
}
}
},
resetDateMarkers: function () {
this.departureDateTemp = this.departureDate;
this.returnDateTemp = this.returnDate;
this.updateDateMarkers();
},
updateDateMarkers: function () {
this.monthsDisplayed.each(function (a) {
var b = a[2];
b.each(function (c) {
switch (true) {
case (+c.date === +this.departureDate && +c.date === +this.returnDate):
c.container.set("class", "departure-return");
break;
case (+c.date === +this.departureDate && +c.date === +this.returnDateTemp):
c.container.set("class", "departure-return-hover");
break;
case (+c.date === +this.returnDate && +c.date === +this.departureDateTemp):
c.container.set("class", "return-departure-hover");
break;
case (+c.date === +this.departureDate):
c.container.set("class", "departure");
break;
case (+c.date === +this.departureDateTemp):
c.container.set("class", "departure-hover");
break;
case (+c.date === +this.returnDate):
c.container.set("class", "return");
break;
case (+c.date === +this.returnDateTemp):
c.container.set("class", "return-hover");
break;
case (this.departureDateTemp && this.departureDateTemp < c.date && c.date < this.returnDateTemp):
c.container.set("class", "inbetween");
break;
default:
c.container.set("class", "");
break;
}
if (c.date.diff(this.today, "day") > 0) {
c.container.addClass("inactive");
}
}.bind(this));
}.bind(this));
},
updateArrows: function (a) {
if (a == "prev") {
this.setPrevButtonActive((this.monthsDisplayed[0][0] > this.firstMonth) ? true : false);
this.setNextButtonActive((this.monthsDisplayed[this.monthsDisplayed.length - 2][0] < this.lastMonth) ? true : false);
} else {
if (a == "next") {
this.setPrevButtonActive((this.monthsDisplayed[1][0] > this.firstMonth) ? true : false);
this.setNextButtonActive((this.monthsDisplayed[this.monthsDisplayed.length - 1][0] < this.lastMonth) ? true : false);
} else {
this.setPrevButtonActive((this.monthsDisplayed[0][0] > this.firstMonth) ? true : false);
this.setNextButtonActive((this.monthsDisplayed[this.monthsDisplayed.length - 1][0] < this.lastMonth) ? true : false);
}
}
},
focusDateLabel: function (a) {
var b = a.getSiblings("label");
if (a.value.length < 1) {
b.set("html", String(b.get("text")).replace(this.labelAppendix, ""));
} else {
a.select();
}
},
updateDateLabel: function (b) {
var c = b.getSiblings("label");
var d = c.get("text");
var a = String(d).replace(this.labelAppendix, "");
if (b.id == this.departureDateField.id) {
if (!this.departureDateTemp) {
c.set("html", a + this.labelAppendix);
} else {
c.set("html", a);
}
} else {
if (!this.returnDateTemp) {
c.set("html", a + this.labelAppendix);
} else {
c.set("html", a);
}
}
},
setPrevButtonActive: function (a) {
this.prevMonthEnabled = a;
(a) ? this.prevButton.getElement("a").removeClass("inactive") : this.prevButton.getElement("a").addClass("inactive");
},
setNextButtonActive: function (a) {
this.nextMonthEnabled = a;
(a) ? this.nextButton.getElement("a").removeClass("inactive") : this.nextButton.getElement("a").addClass("inactive");
},
disableReturnDate: function () {
this.returnDate = this.returnDateTemp = null;
this.returnDateField.value = "";
this.updateDateMarkers();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment