Fixed datepicker.js
This commit is contained in:
parent
060827560d
commit
6925b943b4
|
@ -9,16 +9,18 @@ this.ckan.module('daterangepicker-module', function ($, _) {
|
|||
};
|
||||
|
||||
// Pick out relevant parameters
|
||||
param_start = $.urlParam('ext_startdate');
|
||||
param_end = $.urlParam('ext_enddate');
|
||||
var param_start = $.urlParam('ext_startdate');
|
||||
var param_end = $.urlParam('ext_enddate');
|
||||
|
||||
var fs = 'YYYY-MM-DD';
|
||||
|
||||
// Populate the datepicker and hidden fields
|
||||
if (param_start) {
|
||||
$('#datepicker #start').val(moment.utc(param_start).format());
|
||||
$('#datepicker #start').val(moment.utc(param_start).format(fs));
|
||||
$('#ext_startdate').val(param_start);
|
||||
}
|
||||
if (param_end) {
|
||||
$('#datepicker #end').val(moment.utc(param_end).format());
|
||||
$('#datepicker #end').val(moment.utc(param_end).format(fs));
|
||||
$('#ext_enddate').val(param_end);
|
||||
}
|
||||
|
||||
|
@ -49,12 +51,13 @@ this.ckan.module('daterangepicker-module', function ($, _) {
|
|||
// Format the start and end dates into strings in a date format that Solr understands.
|
||||
var v = moment(ev.date);
|
||||
var fs = 'YYYY-MM-DDTHH:mm:ss';
|
||||
var dateFormatted = v.format(fs) + 'Z';
|
||||
|
||||
switch (ev.target.name) {
|
||||
case 'start':
|
||||
// Set the value of the hidden <input id="ext_startdate"> to the chosen start date.
|
||||
if (ev.date) {
|
||||
$('#ext_startdate').val(v.format(fs) + 'Z');
|
||||
$('#ext_startdate').val(dateFormatted);
|
||||
} else {
|
||||
$('#ext_startdate').val('');
|
||||
}
|
||||
|
@ -62,7 +65,7 @@ this.ckan.module('daterangepicker-module', function ($, _) {
|
|||
case 'end':
|
||||
// Set the value of the hidden <input id="ext_enddate"> to the chosen end date.
|
||||
if (ev.date) {
|
||||
$('#ext_enddate').val(v.add('y', 1).subtract('s', 1).format(fs) + 'Z');
|
||||
$('#ext_enddate').val(v.add('d', 1).subtract('s', 1).format(fs) + 'Z');
|
||||
} else {
|
||||
$('#ext_enddate').val('');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue