fixed: DateTime Form Control Bug

This commit is contained in:
Yung Han Khoe 2008-08-03 14:46:55 +00:00
parent fd62170df6
commit eca4ccc998
2 changed files with 34 additions and 20 deletions

View file

@ -19,6 +19,7 @@
- fixed: EMS purge now functions correctly
- improve behavior of preload.perl for custom lib dirs not ending in lib
- fixed: Server side spellchecker doesn't work
- fixed: DateTime Form Control Bug
7.5.18
- fixed: Collateral Image Manager broken in Firefox 3

View file

@ -34,42 +34,55 @@ YAHOO.WebGUI.Form.DatePicker = {
},
handleRender: function(e) {
if ( this.useTime ) {
this.addTimeBox();
}
},
addTimeBox: function(e) {
this.timediv = document.createElement('div');
YAHOO.util.Dom.setStyle(this.timediv, 'text-align', 'center');
this.calendar.oDomContainer.appendChild(this.timediv);
this.timediv.appendChild(document.createTextNode('Time: '));
this.hourEl = document.createElement('input');
this.hourEl.value = '00';
this.hourEl.value = this.hour;
this.hourEl.setAttribute('size', 2);
this.hourEl.setAttribute('maxlength', 2);
this.timediv.appendChild(this.hourEl);
this.timediv.appendChild(document.createTextNode(' : '));
this.minuteEl = document.createElement('input');
this.minuteEl.value = '00';
this.minuteEl.value = this.min;
this.minuteEl.setAttribute('size', 2);
this.minuteEl.setAttribute('maxlength', 2);
this.timediv.appendChild(this.minuteEl);
this.secEl = document.createElement('input');
this.secEl.value = '00';
this.secEl.value = this.sec;
this.secEl.setAttribute('size', 2);
this.secEl.setAttribute('maxlength', 2);
YAHOO.util.Dom.setStyle(this.secEl, 'display', 'none');
this.timediv.appendChild(this.secEl);
this.calendar.oDomContainer.appendChild(this.timediv);
this.timeBoxAdded = true;
YAHOO.util.Event.on(this.hourEl, 'change', this.handleTimebox, [this.hourEl, 'hour'], this);
YAHOO.util.Event.on(this.minuteEl, 'change', this.handleTimebox, [this.minuteEl, 'minute'], this);
}
},
handleTimebox: function(e, obj) {
var input = obj[0];
var type = obj[1];
var val = parseInt(input.value);
if (type == 'hour'){
this.hour = val;
}
if (type == 'minute'){
this.min = val;
}
if (!val)
val = 0;
val = val % (type == 'hour' ? 24 : 60);
input.value = (val < 10 ? '0' : '') + val;
},
handleBeforeShow: function(e) {
if ( this.useTime && !this.timeBoxAdded) {
this.addTimeBox();
}
YAHOO.util.Event.on(this.inputBox, 'change', this.handleChange, this, true);
this.handleChange();
},
@ -110,24 +123,27 @@ YAHOO.WebGUI.Form.DatePicker = {
this.codeSelect = true;
var date;
var res;
var hour, min, sec;
if(res = this.inputBox.value.match(/(\d+)-(\d+)-(\d+)(?: (\d+):(\d+):(\d+))?/)) {
date = res[1] + '-' + res[2] + '-' + res[3];
if (res[4]) {
hour = (res[4] < 10 ? '0' : '') + (1 * res[4]);
min = (res[5] < 10 ? '0' : '') + (1 * res[5]);
sec = (res[6] < 10 ? '0' : '') + (1 * res[6]);
if (!this.hour){
this.hour = (res[4] < 10 ? '0' : '') + (1 * res[4]);
}
if (!this.min){
this.min = (res[5] < 10 ? '0' : '') + (1 * res[5]);
}
this.sec = (res[6] < 10 ? '0' : '') + (1 * res[6]);
}
}
if (!hour)
hour = '00';
if (!min)
min = '00';
if (!sec)
sec = '00';
this.hourEl.value = hour;
this.minuteEl.value = min;
this.secEl.value = sec;
if (!this.hour)
this.hour = '00';
if (!this.min)
this.min = '00';
if (!this.sec)
this.sec = '00';
this.hourEl.value = this.hour;
this.minuteEl.value = this.min;
this.secEl.value = this.sec;
this.calendar.select(date);
var selectedDates = this.calendar.getSelectedDates();
if (selectedDates.length > 0) {
@ -135,9 +151,6 @@ YAHOO.WebGUI.Form.DatePicker = {
this.calendar.cfg.setProperty("pagedate", (firstDate.getMonth()+1) + "-" + firstDate.getFullYear());
this.calendar.render();
}
this.hourEl.value = hour;
this.minuteEl.value = min;
this.secEl.value = sec;
this.codeSelect = false;
}
}