From eca4ccc998c61d685f57d21595c6d4e609c49293 Mon Sep 17 00:00:00 2001 From: Yung Han Khoe Date: Sun, 3 Aug 2008 14:46:55 +0000 Subject: [PATCH] fixed: DateTime Form Control Bug --- docs/changelog/7.x.x.txt | 1 + .../yui-webgui/build/datepicker/datepicker.js | 53 ++++++++++++------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 0973b10b8..1113ab3fb 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -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 diff --git a/www/extras/yui-webgui/build/datepicker/datepicker.js b/www/extras/yui-webgui/build/datepicker/datepicker.js index bf36c7bbb..f6107af14 100644 --- a/www/extras/yui-webgui/build/datepicker/datepicker.js +++ b/www/extras/yui-webgui/build/datepicker/datepicker.js @@ -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; } }