Apache-SdnFw
view release on metacpan or search on metacpan
lib/Apache/SdnFw/js/calendar_date_select/calendar_date_select.js view on Meta::CPAN
var parent = this.target_element.parentNode;
var style = {}
} else {
var parent = document.body
var style = { position:"absolute", visibility: "hidden", left:0, top:0 }
}
this.calendar_div = $(parent).build('div', {className: "calendar_date_select"}, style);
var that = this;
// create the divs
$w("top header body buttons footer bottom").each(function(name) {
eval("var " + name + "_div = that." + name + "_div = that.calendar_div.build('div', { className: 'cds_"+name+"' }, { clear: 'left'} ); ");
});
this.initHeaderDiv();
this.initButtonsDiv();
this.initCalendarGrid();
this.updateFooter(" ");
this.refresh();
this.setUseTime(this.use_time);
},
initHeaderDiv: function() {
var header_div = this.header_div;
this.close_button = header_div.build("a", { innerHTML: "x", href:"#", onclick:function () { this.close(); return false; }.bindAsEventListener(this), className: "close" });
this.next_month_button = header_div.build("a", { innerHTML: ">", href:"#", onclick:function () { this.navMonth(this.date.getMonth() + 1 ); return false; }.bindAsEventListener(this), className: "next" });
this.prev_month_button = header_div.build("a", { innerHTML: "<", href:"#", onclick:function () { this.navMonth(this.date.getMonth() - 1 ); return false; }.bindAsEventListener(this), className: "prev" });
if (this.options.get("month_year")=="dropdowns") {
this.month_select = new SelectBox(header_div, $R(0,11).map(function(m){return [Date.months[m], m]}), {className: "month", onchange: function () { this.navMonth(this.month_select.getValue()) }.bindAsEventListener(this)});
this.year_select = new SelectBox(header_div, [], {className: "year", onchange: function () { this.navYear(this.year_select.getValue()) }.bindAsEventListener(this)});
this.populateYearRange();
} else {
this.month_year_label = header_div.build("span")
}
},
initCalendarGrid: function() {
var body_div = this.body_div;
this.calendar_day_grid = [];
var days_table = body_div.build("table", { cellPadding: "0px", cellSpacing: "0px", width: "100%" })
// make the weekdays!
var weekdays_row = days_table.build("thead").build("tr");
Date.weekdays.each( function(weekday) {
weekdays_row.build("th", {innerHTML: weekday});
});
var days_tbody = days_table.build("tbody")
// Make the days!
var row_number = 0, weekday;
for(var cell_index = 0; cell_index<42; cell_index++)
{
weekday = (cell_index+Date.first_day_of_week ) % 7;
if ( cell_index % 7==0 ) days_row = days_tbody.build("tr", {className: 'row_'+row_number++});
(this.calendar_day_grid[cell_index] = days_row.build("td", {
calendar_date_select: this,
onmouseover: function () { this.calendar_date_select.dayHover(this); },
onmouseout: function () { this.calendar_date_select.dayHoverOut(this) },
onclick: function() { this.calendar_date_select.updateSelectedDate(this, true); },
className: (weekday==0) || (weekday==6) ? " weekend" : "" //clear the class
},
{ cursor: "pointer" }
)).build("div");
this.calendar_day_grid[cell_index];
}
},
initButtonsDiv: function()
{
var buttons_div = this.buttons_div;
if (this.options.get("time"))
{
var blank_time = $A(this.options.get("time")=="mixed" ? [[" - ", ""]] : []);
buttons_div.build("span", {innerHTML:"@", className: "at_sign"});
var t = new Date();
this.hour_select = new SelectBox(buttons_div,
blank_time.concat($R(0,23).map(function(x) {t.setHours(x); return $A([t.getAMPMHour()+ " " + t.getAMPM(),x])} )),
{
calendar_date_select: this,
onchange: function() { this.calendar_date_select.updateSelectedDate( { hour: this.value });},
className: "hour"
}
);
buttons_div.build("span", {innerHTML:":", className: "seperator"});
var that = this;
this.minute_select = new SelectBox(buttons_div,
blank_time.concat($R(0,59).select(function(x){return (x % that.options.get('minute_interval')==0)}).map(function(x){ return $A([ Date.padded2(x), x]); } ) ),
{
calendar_date_select: this,
onchange: function() { this.calendar_date_select.updateSelectedDate( {minute: this.value }) },
className: "minute"
}
);
} else if (! this.options.get("buttons")) buttons_div.remove();
if (this.options.get("buttons")) {
buttons_div.build("span", {innerHTML: " "});
if (this.options.get("time")=="mixed" || !this.options.get("time")) b = buttons_div.build("a", {
innerHTML: _translations["Today"],
href: "#",
onclick: function() {this.today(false); return false;}.bindAsEventListener(this)
});
if (this.options.get("time")=="mixed") buttons_div.build("span", {innerHTML: " | ", className:"button_seperator"})
if (this.options.get("time")) b = buttons_div.build("a", {
innerHTML: _translations["Now"],
href: "#",
onclick: function() {this.today(true); return false}.bindAsEventListener(this)
});
if (!this.options.get("embedded") && !this.closeOnClick())
{
buttons_div.build("span", {innerHTML: " | ", className:"button_seperator"})
buttons_div.build("a", { innerHTML: _translations["OK"], href: "#", onclick: function() {this.close(); return false;}.bindAsEventListener(this) });
}
if (this.options.get('clear_button')) {
buttons_div.build("span", {innerHTML: " | ", className:"button_seperator"})
buttons_div.build("a", { innerHTML: _translations["Clear"], href: "#", onclick: function() {this.clearDate(); if (!this.options.get("embedded")) this.close(); return false;}.bindAsEventListener(this) });
}
}
( run in 0.538 second using v1.01-cache-2.11-cpan-39bf76dae61 )