Move datepicker initialization code to datepicker.js file

Now we have a file named 'datepicker.js' it should be easier to
have all code related to datepicker plugin within the same file.
This commit is contained in:
Senén Rodero Rodríguez
2020-08-28 11:59:24 +02:00
committed by Javi Martín
parent fc9a87a8ab
commit 871b58a4a0
3 changed files with 23 additions and 23 deletions

View File

@@ -15,6 +15,21 @@
(function() {
"use strict";
App.Datepicker = {
initialize: function() {
var locale;
locale = $("#js-locale").data("current-locale");
$(".js-calendar").datepicker({
maxDate: "+0d"
});
$(".js-calendar-full").datepicker();
if (!App.Datepicker.browser_supports_date_field()) {
$("input[type='date']").datepicker();
}
$.datepicker.setDefaults($.datepicker.regional[locale]);
$.datepicker.setDefaults({ dateFormat: "dd/mm/yy" });
},
destroy: function() {
$.datepicker.dpDiv.remove();
@@ -22,6 +37,13 @@
$(input).datepicker("hide");
$(input).datepicker("destroy");
});
},
browser_supports_date_field: function() {
var datefield;
datefield = document.createElement("input");
datefield.setAttribute("type", "date");
return datefield.type === "date";
}
};