summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/datepicker/datepicker.js
diff options
context:
space:
mode:
authorxue <>2006-04-25 01:27:04 +0000
committerxue <>2006-04-25 01:27:04 +0000
commit1afc913c386bba8e6072c278b0eb4fd9818ab310 (patch)
tree40cc63eb41f47e0ac392c692619640dca57cd262 /framework/Web/Javascripts/datepicker/datepicker.js
parentfd019bf034ef4dbedfc305c77fed0dbd83a732c4 (diff)
Undo previous checkin (which goes int 3.0 branch and will be merged back).
Diffstat (limited to 'framework/Web/Javascripts/datepicker/datepicker.js')
-rw-r--r--framework/Web/Javascripts/datepicker/datepicker.js96
1 files changed, 28 insertions, 68 deletions
diff --git a/framework/Web/Javascripts/datepicker/datepicker.js b/framework/Web/Javascripts/datepicker/datepicker.js
index 79763811..e906120c 100644
--- a/framework/Web/Javascripts/datepicker/datepicker.js
+++ b/framework/Web/Javascripts/datepicker/datepicker.js
@@ -1,51 +1,10 @@
Prado.WebUI.TDatePicker = Class.create();
-Object.extend(Prado.WebUI.TDatePicker,
-{
- /**
- * @return Date the date from drop down list options.
- */
- getDropDownDate : function(control)
- {
- var now=new Date();
- var year=now.getFullYear();
- var month=now.getMonth();
- var day=1;
-
- var month_list = this.getMonthListControl(control);
- var day_list = this.getDayListControl(control);
- var year_list = this.getYearListControl(control);
-
- var day = day_list ? $F(day_list) : 1;
- var month = month_list ? $F(month_list) : now.getMonth();
- var year = year_list ? $F(year_list) : now.getFullYear();
-
- return new Date(year,month,day, 0, 0, 0);
- },
-
- getYearListControl : function(control)
- {
- return $(control.id+"_year");
- },
-
- getMonthListControl : function(control)
- {
- return $(control.id+"_month");
- },
-
- getDayListControl : function(control)
- {
- return $(control.id+"_day");
- }
-});
-
Prado.WebUI.TDatePicker.prototype =
{
MonthNames : [ "January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"
],
- AbbreviatedMonthNames : ["Jan", "Feb", "Mar", "Apr", "May",
- "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
ShortWeekDayNames : ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
@@ -229,7 +188,7 @@ Prado.WebUI.TDatePicker.prototype =
var todayButton = document.createElement("button");
todayButton.className = "todayButton";
var today = this.newDate();
- var buttonText = today.SimpleFormat(this.Format,this);
+ var buttonText = today.SimpleFormat(this.Format);
todayButton.appendChild(document.createTextNode(buttonText));
div.appendChild(todayButton);
@@ -427,27 +386,20 @@ Prado.WebUI.TDatePicker.prototype =
return false;
},
- onChange : function()
+ onchange : function()
{
if(this.options.InputMode == "TextBox")
- {
this.control.value = this.formatDate();
- Event.fireEvent(this.control, "change");
- }
else
{
- var day = Prado.WebUI.TDatePicker.getDayListControl(this.control);
- var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control);
- var year = Prado.WebUI.TDatePicker.getYearListControl(this.control);
+ var day = $(this.options.ID+"_day");
+ var month = $(this.options.ID+"_month");
+ var year = $(this.options.ID+"_year");
var date = this.selectedDate;
if(day)
- {
day.selectedIndex = date.getDate()-1;
- }
if(month)
- {
month.selectedIndex = date.getMonth();
- }
if(year)
{
var years = year.options;
@@ -455,20 +407,19 @@ Prado.WebUI.TDatePicker.prototype =
for(var i = 0; i < years.length; i++)
years[i].selected = years[i].value.toInteger() == currentYear;
}
- Event.fireEvent(day || month || year, "change");
}
},
formatDate : function()
{
- return this.selectedDate ? this.selectedDate.SimpleFormat(this.Format,this) : '';
+ return this.selectedDate ? this.selectedDate.SimpleFormat(this.Format) : '';
},
newDate : function(date)
{
if(!date)
date = new Date();
- if(typeof(date) == "string" || typeof(date) == "number")
+ if(isString(date) || isNumber(date))
date = new Date(date);
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0,0,0);
},
@@ -481,8 +432,8 @@ Prado.WebUI.TDatePicker.prototype =
this.updateHeader();
this.update();
- if (typeof(this.onChange) == "function")
- this.onChange();
+ if (isFunction(this.onchange))
+ this.onchange();
},
getElement : function()
@@ -492,7 +443,7 @@ Prado.WebUI.TDatePicker.prototype =
getSelectedDate : function ()
{
- return this.selectedDate == null ? null : this.newDate(this.selectedDate);
+ return isNull(this.selectedDate) ? null : this.newDate(this.selectedDate);
},
setYear : function(year)
@@ -529,9 +480,8 @@ Prado.WebUI.TDatePicker.prototype =
pos[1] += this.control.offsetHeight;
else
{
- var dayList = Prado.WebUI.TDatePicker.getDayListControl(this.control);
- if(dayList)
- pos[1] += dayList.offsetHeight-1;
+ if($(this.options.ID+"_day"))
+ pos[1] += $(this.options.ID+"_day").offsetHeight-1;
}
this._calDiv.style.display = "block";
@@ -543,7 +493,7 @@ Prado.WebUI.TDatePicker.prototype =
this.documentKeyDownEvent = this.keyPressed.bindEvent(this);
Event.observe(document.body, "click", this.documentClickEvent);
var date = this.getDateFromInput();
- if(date)
+ if(!isNull(date))
{
this.selectedDate = date;
this.setSelectedDate(date);
@@ -558,7 +508,20 @@ Prado.WebUI.TDatePicker.prototype =
if(this.options.InputMode == "TextBox")
return Date.SimpleParse($F(this.control), this.Format);
else
- return Prado.WebUI.TDatePicker.getDropDownDate(this.control);
+ {
+ var now=new Date();
+ var year=now.getFullYear();
+ var month=now.getMonth();
+ var date=1;
+ if($(this.options.ID+"_day"))
+ day = $F(this.options.ID+"_day");
+ if($(this.options.ID+"_month"))
+ month = $F(this.options.ID+"_month");
+ if($(this.options.ID+"_year"))
+ year = $F(this.options.ID+"_year");
+ var newdate=new Date(year,month,day, 0, 0, 0);
+ return newdate;
+ }
},
//hide the calendar when clicked outside any calendar
@@ -647,10 +610,7 @@ Prado.WebUI.TDatePicker.prototype =
hover : function(ev)
{
//conditionally add the hover class to the event target element.
- if(ev.type == "mouseover")
- Event.element(ev).addClassName("hover");
- else
- Event.element(ev).removeClassName("hover");
+ Element.condClassName(Event.element(ev), "hover", ev.type=="mouseover");
},
updateHeader : function () {