fix for enable the onchange event in the new calendar widget

This commit is contained in:
Erik Amaru Ortiz
2010-12-24 13:38:03 +00:00
parent bd60568f84
commit f9b1a5a8ad
2 changed files with 39 additions and 7 deletions

View File

@@ -1859,7 +1859,17 @@ function datePicker4(obj, id, mask, startDate, endDate, showTIme){
animation: _BROWSER.name =='msie'? false: true, animation: _BROWSER.name =='msie'? false: true,
showTime: showTIme, showTime: showTIme,
opacity: 1, opacity: 1,
onSelect: function() { this.hide(); }} onSelect: function() {
this.hide();
fireEvent(document.getElementById(id),'change');
//if(document.getElementById(id).onchange)
//document.getElementById(id).onchange();
}
}
); );
if( _BROWSER.name != 'msie' ) if( _BROWSER.name != 'msie' )
@@ -1867,6 +1877,21 @@ function datePicker4(obj, id, mask, startDate, endDate, showTIme){
} }
function fireEvent(element,event){
if (document.createEventObject){
// dispatch for IE
var evt = document.createEventObject();
return element.fireEvent('on'+event,evt)
}
else{
// dispatch for firefox + others
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true ); // event type,bubbling,cancelable
return !element.dispatchEvent(evt);
}
}
function elementAttributesNS(e, ns) { function elementAttributesNS(e, ns) {
if (!this.__namespaceRegexps) if (!this.__namespaceRegexps)
this.__namespaceRegexps = {}; this.__namespaceRegexps = {};

View File

@@ -2914,6 +2914,7 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
public $dependentFields = ''; public $dependentFields = '';
public $editable; public $editable;
var $hint; var $hint;
var $onchange;
/** /**
* Verify the format of a date * Verify the format of a date
* @param <Date> $date * @param <Date> $date
@@ -3120,6 +3121,12 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
} }
} }
//onchange
if( isset($this->onchange) && $this->onchange != '' )
$onchange = 'onchange="'.$this->onchange.'"';
else
$onchange = '';
#the validations field was moved to javascript routines ;) #the validations field was moved to javascript routines ;)
if ($this->mode == 'edit') { if ($this->mode == 'edit') {
if( $startDate=='1969-12-31' ) { if( $startDate=='1969-12-31' ) {
@@ -3140,11 +3147,11 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
$sizeend = $maskleng + 2; $sizeend = $maskleng + 2;
} }
if ( $this->editable != "0") { if ( $this->editable != "0") {
$html = '<input id="'.$pID.'" name="'.$pID.'" class="module_app_input___gray" size="'.$sizeend.'" value="'.$value.'"/> $html = '<input id="'.$pID.'" name="'.$pID.'" '.$onchange.' class="module_app_input___gray" size="'.$sizeend.'" value="'.$value.'"/>
<a onclick="removeValue(\''.$pID.'\'); return false;"/> <img src="/images/icons_silk/calendar_x_button.png" style="position:relative;left:-17px;top:5px;"/></a> <a onclick="removeValue(\''.$pID.'\'); return false;"/> <img src="/images/icons_silk/calendar_x_button.png" style="position:relative;left:-17px;top:5px;"/></a>
<a id="'.$pID.'[btn]" onmouseover="datePicker4(this, \''.$pID.'\', \''.$mask.'\', \''.$startDate.'\', \''.$endDate.'\','.$Time.')"><img src="/images/pmdateicon.png" border="0" width="12" height="12" style="position:relative;left:-17px;top:0px;"/></a>'; <a id="'.$pID.'[btn]" onmouseover="datePicker4(this, \''.$pID.'\', \''.$mask.'\', \''.$startDate.'\', \''.$endDate.'\','.$Time.')"><img src="/images/pmdateicon.png" border="0" width="12" height="12" style="position:relative;left:-17px;top:0px;"/></a>';
} else { } else {
$html = '<input id="'.$pID.'" name="'.$pID.'" class="module_app_input___gray" size="'.$sizeend.'" value="'.$value.'" readonly/> $html = '<input id="'.$pID.'" name="'.$pID.'" '.$onchange.' class="module_app_input___gray" size="'.$sizeend.'" value="'.$value.'" readonly/>
<a onclick="removeValue(\''.$pID.'\'); return false;"/> <img src="/images/icons_silk/calendar_x_button.png" style="position:relative;left:-17px;top:5px;"/></a> <a onclick="removeValue(\''.$pID.'\'); return false;"/> <img src="/images/icons_silk/calendar_x_button.png" style="position:relative;left:-17px;top:5px;"/></a>
<a id="'.$pID.'[btn]" onmouseover="datePicker4(this, \''.$pID.'\', \''.$mask.'\', \''.$startDate.'\', \''.$endDate.'\', '.$Time.')"><img src="/images/pmdateicon.png" border="0" width="12" height="12" style="position:relative;left:-17px;top:0px;"/></a>'; <a id="'.$pID.'[btn]" onmouseover="datePicker4(this, \''.$pID.'\', \''.$mask.'\', \''.$startDate.'\', \''.$endDate.'\', '.$Time.')"><img src="/images/pmdateicon.png" border="0" width="12" height="12" style="position:relative;left:-17px;top:0px;"/></a>';
} }