diff options
| author | Sean Fridman <fridman@mail.sfsu.edu> | 2015-06-02 17:29:57 -0400 |
|---|---|---|
| committer | Sean Fridman <fridman@mail.sfsu.edu> | 2015-06-02 17:29:57 -0400 |
| commit | bcca89ebfd9ea93356d934edd5218335430746b6 (patch) | |
| tree | 15ca36b109b7c22dae054106805ba02dba6b88ae | |
| parent | e923cb0e5e1efac4fba534aba87f6b6e9d95d3f0 (diff) | |
Add 'date' field typev0.1.8
| -rw-r--r-- | app/node_modules/okschema/index.js | 4 | ||||
| -rw-r--r-- | themes/okadmin/public/css/main.css | 4 | ||||
| -rw-r--r-- | themes/okadmin/public/js/app.js | 19 | ||||
| -rw-r--r-- | 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 @@ <button class="remove">x</button> </div> </div> + + {% elsif type =='date' %} + + <div class="date"> + <input name="{{name}}" + type="date" + {% if spec.value %} + value="{{spec.value | date: '%Y-%m-%d'}}" + {% endif %} + > + </div> + {% elsif type == 'tag-list' %} <div class="tag-list"> - <input id="{{name}}-input" name="{{name}}" value="{{spec.value}}" - placeholder="Enter a comma separated list of tags."> + <input name="{{name}}" + value="{{spec.value}}" + placeholder="Enter a comma separated list of tags."> </div> {% elsif type == 'link-list' %} |
