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:
committed by
Javi Martín
parent
fc9a87a8ab
commit
871b58a4a0
@@ -17,30 +17,7 @@
|
||||
$(".js-calendar").datepicker("option", "disabled", true);
|
||||
}
|
||||
},
|
||||
init_calendar: function() {
|
||||
var locale;
|
||||
locale = $("#js-locale").data("current-locale");
|
||||
$(".js-calendar").datepicker({
|
||||
maxDate: "+0d"
|
||||
});
|
||||
$(".js-calendar-full").datepicker();
|
||||
|
||||
if (!App.AdvancedSearch.browser_supports_date_field()) {
|
||||
$("input[type='date']").datepicker();
|
||||
}
|
||||
|
||||
$.datepicker.setDefaults($.datepicker.regional[locale]);
|
||||
$.datepicker.setDefaults({ dateFormat: "dd/mm/yy" });
|
||||
},
|
||||
browser_supports_date_field: function() {
|
||||
var datefield;
|
||||
|
||||
datefield = document.createElement("input");
|
||||
datefield.setAttribute("type", "date");
|
||||
return datefield.type === "date";
|
||||
},
|
||||
initialize: function() {
|
||||
App.AdvancedSearch.init_calendar();
|
||||
if (App.AdvancedSearch.advanced_search_terms()) {
|
||||
$("#js-advanced-search").show();
|
||||
App.AdvancedSearch.toggle_date_options();
|
||||
|
||||
@@ -163,6 +163,7 @@ var initialize_modules = function() {
|
||||
App.ColumnsSelector.initialize();
|
||||
}
|
||||
App.BudgetEditAssociations.initialize();
|
||||
App.Datepicker.initialize();
|
||||
};
|
||||
|
||||
var destroy_non_idempotent_modules = function() {
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user