diff --git a/js/search/search_form_criteria_date.js b/js/search/search_form_criteria_date.js index c208541e0..a7ffc563e 100644 --- a/js/search/search_form_criteria_date.js +++ b/js/search/search_form_criteria_date.js @@ -22,12 +22,14 @@ $(function() "x_picker" : 'datepicker', "value_index": 0, "onclose_show" : "until", + "has_time": false, }, { "code": "until", "code_uc_first":"Until", "x_picker" : 'datepicker', "value_index": 1, + "has_time": false, } ] }, diff --git a/js/search/search_form_criteria_date_abstract.js b/js/search/search_form_criteria_date_abstract.js index 414798b3f..772ec9f07 100644 --- a/js/search/search_form_criteria_date_abstract.js +++ b/js/search/search_form_criteria_date_abstract.js @@ -33,6 +33,7 @@ $(function() // "code_uc_first":"From", => the code used in the translations // "onclose_show" : "until", => on x_picker close, should we open another one (on "from" close shall we show "until") // "value_index": 0, => the widget communicate with an array of values, the index 0 is "from" the index 1 is "until" + // "has_time": true, => wether this field need the time (ie: in its formatting) // Date_time widget specific settings : // > Beware : a lot of those parameters are unused (the intial dev. tested several different UI before the final choice) @@ -189,7 +190,7 @@ $(function() buttonText: "", showOn:'button', changeMonth:true, - changeYear:true + changeYear:true, }; for (var i = 0; i < aInputsParamLength; i++) { var oInputParam = aInputsParam[i]; @@ -241,18 +242,31 @@ $(function() for (var i = 0; i < aInputsParamLength; i++) { var oInputParam = aInputsParam[i]; + var oDate = oOpElem.find('input[name="'+oInputParam.code+'"]').datepicker( "getDate" ); //.val(); + + var sLabel = ''; + + if (oDate != null) + { + sLabel = $.datepicker.formatDate(me.options.datepicker.dateFormat , oDate); + if (oInputParam.has_time) + { + sLabel = sLabel + ' ' + $.datepicker.formatTime(me.options.datepicker.timeFormat , { + hour: oDate.getHours(), + minute: oDate.getMinutes(), + second: oDate.getSeconds() + }); + } + } + - sLabel = oOpElem.find('input[name="'+oInputParam.code+'"]').val(); if (typeof oInputParam.show_on_advanced == 'undefined' || bAdvancedMode == oInputParam.show_on_advanced) { if (typeof oInputParam.getter_code != 'undefined') { - sValue = oOpElem.find('input[name="'+oInputParam.getter_code+'"]').val(); - } - else if (sLabel != "" && typeof oInputParam.getter_suffix != 'undefined') - { - sValue = sLabel + oInputParam.getter_suffix; + sValue = sLabel; //oOpElem.find('input[name="'+oInputParam.getter_code+'"]').datepicker( "getDate" ); //.val(); + //sValue = (sValue == null) ? '' : $.datepicker.formatDate(me.options.datepicker.timeFormat ,sValue); } else { @@ -282,8 +296,46 @@ $(function() var sDate = aValues[oInputParam.value_index].value; if (sDate.trim() != '') { - var oDate = new Date(sDate); - oInputElem[oInputParam.x_picker]('setDate', oDate); + try + { + if (oInputParam.has_time) + { + var iSpacePos = sDate.indexOf(' '); + if (iSpacePos) + { + var sParsableDate = sDate.substring(0, iSpacePos); + var sParsableTime = sDate.substring(iSpacePos + 1); + } + else + { + var sParsableDate = sDate + var sParsableTime = '' + } + + + var oDate = $.datepicker.parseDate( me.options.datepicker.dateFormat, sParsableDate ); + + if ('' != sParsableTime) + { + var oTime = $.datepicker.parseTime( me.options.datepicker.timeFormat, sParsableTime ); + oDate.setHours(oTime.hour); + oDate.setMinutes(oTime.minute); + oDate.setSeconds(oTime.second); + } + } + else + { + var oDate = $.datepicker.parseDate( me.options.datepicker.dateFormat, sDate ); + } + + oInputElem[oInputParam.x_picker]('setDate', oDate); + } + catch (e) { + //the date is not formated (ie : it is the first arrival) + var oDate = new Date(sDate); + oInputElem[oInputParam.x_picker]('setDate', oDate); + } + } else { diff --git a/js/search/search_form_criteria_date_time.js b/js/search/search_form_criteria_date_time.js index 6c5a955f5..43fda7cba 100644 --- a/js/search/search_form_criteria_date_time.js +++ b/js/search/search_form_criteria_date_time.js @@ -69,6 +69,7 @@ $(function() "default_time_add": 0, "value_index": 0, "onclose_show" : "until_time", + "has_time": true, }, { "code": "until_time", @@ -81,6 +82,7 @@ $(function() "second":59 }, "value_index": 1, + "has_time": true, } ] }, diff --git a/js/search/search_form_handler.js b/js/search/search_form_handler.js index 5802302d5..ec6b56e27 100644 --- a/js/search/search_form_handler.js +++ b/js/search/search_form_handler.js @@ -192,7 +192,11 @@ $(function() sNewUrl = sNewUrl + '&debug='+me._extractURLParameter(window.location.href, "debug"); } - history.replaceState(null, null, sNewUrl); + if (typeof history.replaceState != "undefined") + { + history.replaceState(null, null, sNewUrl); + } + $('#itop-breadcrumb') .breadcrumb('destroy') @@ -459,7 +463,7 @@ $(function() { // TODO: Try to put this back in the date widget as it introduced a non necessary coupling. // If using the datetimepicker, do not close anything - if (oEventTargetElem.closest('#ui-datepicker-div, .ui-datepicker-prev, .ui-datepicker-next').length > 0 ) + if (oEventTargetElem.closest('#ui-datepicker-div, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-current').length > 0 ) { // No closing in this case }