mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-20 06:52:15 +00:00
Update polyfill for datetime-local
Bloody Firefox. We love to hate you. Proper CSS of the fill to come, SoonTM. Closes #391
This commit is contained in:
33
templates/partials/datetime-fix.html
Normal file
33
templates/partials/datetime-fix.html
Normal file
@@ -0,0 +1,33 @@
|
||||
{% load static %}
|
||||
<script>
|
||||
function initDatetime() {
|
||||
$('input[type=datetime-local]').not(':disabled').flatpickr({
|
||||
dateFormat: 'Y-m-dTH:m',
|
||||
enableTime: true,
|
||||
altInput: true,
|
||||
altFormat: "d/m/y H:m",
|
||||
});
|
||||
}
|
||||
$(document).ready(function () {
|
||||
function supportsDateTime() {
|
||||
var input = document.createElement('input');
|
||||
input.setAttribute('type','datetime-local');
|
||||
return input.type !== "text";
|
||||
}
|
||||
//Firefox reports support for datetime-local without properly supporting it. Bah.
|
||||
if(!supportsDateTime() || navigator.userAgent.toLowerCase().indexOf('firefox') > -1){
|
||||
$('<link>')
|
||||
.appendTo('head')
|
||||
.attr({type : 'text/css', rel : 'stylesheet'})
|
||||
.attr('href', '{% static "css/flatpickr.css" %}');
|
||||
$.when(
|
||||
$.getScript( '{% static "js/flatpickr.min.js" %}' ),
|
||||
$.Deferred(function(deferred){
|
||||
$(deferred.resolve);
|
||||
})
|
||||
).done(function(){
|
||||
initDatetime();
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user