From 57026202f9ac0b98cc744734a04bcee362b789a3 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Sun, 20 Dec 2015 03:06:47 +0100 Subject: Date type always defaults to current day --- themes/okadmin/public/js/app.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'themes/okadmin/public/js/app.js') diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index b313f22..edf9980 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -20,6 +20,20 @@ var OKAdmin = function(){ } }) + // Add default date + $('.date input').each(function(i, el){ + var value = el.getAttribute('value') + if (!value) { + el.setAttribute('value', toDateInputValue(new Date)) + } + + function toDateInputValue (date) { + var local = new Date(date); + local.setMinutes(date.getMinutes() - date.getTimezoneOffset()); + return local.toJSON().slice(0,10); + } + }) + // initialize our multimedia uploader with an element and a template $(".group.media-list").each(function(){ var parent = this -- cgit v1.2.3-70-g09d2