From bcca89ebfd9ea93356d934edd5218335430746b6 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Tue, 2 Jun 2015 17:29:57 -0400 Subject: Add 'date' field type --- app/node_modules/okschema/index.js | 4 ++++ themes/okadmin/public/css/main.css | 4 ++++ themes/okadmin/public/js/app.js | 19 +++++++++++++++++++ themes/okadmin/templates/partials/inputs.liquid | 17 +++++++++++++++-- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/node_modules/okschema/index.js b/app/node_modules/okschema/index.js index 0079f51..67f6e42 100644 --- a/app/node_modules/okschema/index.js +++ b/app/node_modules/okschema/index.js @@ -65,6 +65,10 @@ var types = { 'tag-list': { parent: 'string', assertValid: function(spec, value) {} + }, + 'date': { + parent: 'string', + assertValid: function(spec, value) {} } } diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index 094e66b..a5fbdeb 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -211,6 +211,10 @@ label { button, input[type=submit] { cursor: pointer; } +.main.resource .date input { + /* date inputs need font family override */ + font-family: "Helvetica", sans-serif; +} .main.resource form .group { display: block; float: left; diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index f989c7b..d58cb2a 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -162,6 +162,25 @@ var OKAdmin = function(){ $id.val( slug ) } + // Parse date input + $('.property .date').each(function(i, el) { + var name = $(el).parent('.property').data('name') + var $input = $(el).find('input') + var date = new Date($input.val()) + // Set to middle of day so it is the same date + // for all locales + date.setUTCHours(12) + var dateString = date.toUTCString() + var normalizedInput = document.createElement('input') + $(normalizedInput).attr({ + name: name, + type: 'text', + value: dateString + }) + $input.remove() + $(el).append(normalizedInput) + }) + $("ol").each(function(){ $("li", this).each(function(index){ $(this).find("input,textarea").each(function(){ diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid index 0d5321b..e766558 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -50,10 +50,23 @@ + + {% elsif type =='date' %} + +
+ +
+ {% elsif type == 'tag-list' %}
- +
{% elsif type == 'link-list' %} -- cgit v1.2.3-70-g09d2