diff options
| -rw-r--r-- | app/node_modules/okschema/index.js | 4 | ||||
| -rw-r--r-- | site/templates/index.liquid | 2 | ||||
| -rw-r--r-- | themes/okadmin/public/css/main.css | 10 | ||||
| -rw-r--r-- | themes/okadmin/public/js/app.js | 58 | ||||
| -rw-r--r-- | themes/okadmin/templates/partials/inputs.liquid | 42 |
5 files changed, 111 insertions, 5 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/site/templates/index.liquid b/site/templates/index.liquid index 75fe389..0308a79 100644 --- a/site/templates/index.liquid +++ b/site/templates/index.liquid @@ -67,7 +67,7 @@ WEBSITE BY OKFOCUS, http://okfoc.us, Internet Legends. <meta name="google" content="notranslate"> <meta http-equiv="Content-Language" content="en"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> -<meta name="description" content="OKFocus, Internet Legends"> +<meta name="description" content="Two Hustlers is a creative collective of radical thinkers, designers and storytellers. We build transformative experiences for passionate brands."> <meta property="og:title" content="TWOHUSTLERS"> <meta property="og:type" content="website"> <meta property="og:image" content="http://twohustlers.com/assets/images/2H_LOGOMARK.png"> diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index e5af10c..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; @@ -301,6 +305,12 @@ button, input[type=submit] { .main.resource form .video-element input[type=text] { width: 15em; } +.main .link-list .add-link-btn, +.main .link-list .remove-link-btn { + margin: 0; + height: 2em; + line-height: 1em; +} .add-image-button { background: #ddd; clear: left; diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index 2667ce6..d58cb2a 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -99,7 +99,44 @@ var OKAdmin = function(){ $el.parent().find(".video-thumb").val( media.thumbnail ) }) })) - + + // Add a new link to the list + $('.link-list').on('click', '.add-link-btn', function(e) { + e.preventDefault() + e.stopPropagation() + var $delegate = $(e.delegateTarget) + var $list = $delegate.find('.links') + var length = $list.find('input').length + var name = $delegate.parent('.property').data('name') + var $new = $delegate.find('.link-input-new') + var input = document.createElement('input') + var delBtn = document.createElement('button') + var inputName = name + '[' + length + ']' + $(input).attr({ + name: inputName, + type: 'text', + value: $new.val() + }) + $list.append(input) + $(delBtn).addClass('remove-link-btn') + $(delBtn).data('for', inputName) + delBtn.innerHTML = '-' + $list.append(delBtn) + $new.val('') + }) + + // Remove a link from the list + $('.link-list').on('click', '.remove-link-btn', function(e) { + e.preventDefault() + e.stopPropagation() + var $delegate = $(e.delegateTarget) + var $target = $(e.target) + var inputName = $target.data('for') + var $input = $delegate.find('[name="' + inputName + '"]') + $input.remove() + $target.remove() + }) + // fix post indexing in list-driven inputs $(".main.resource form").submit(function(e){ var $id = $("[name=id]"), $title = $("[name=title]"), $menu = $("[name=menu]"), $section = $(".resource.main") @@ -125,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 25ad197..e766558 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -3,7 +3,8 @@ {% assign spec = pair[1] %} {% assign type = spec.type %} - <div class="property {{type}} {% if spec.hidden %}hidden{% endif %}"> + <div class="property {{type}} {% if spec.hidden %}hidden{% endif %}" + data-name="{{name}}"> <label for="{{name}}">{{name | capitalize}}</label> {% if type == 'string' %} @@ -49,11 +50,46 @@ <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' %} + + <div class="link-list group"> + <div class="links"> + {% for url in spec.value %} + <input + name="{{name}}[{{forloop.index0}}]" + value="{{url}}" + type="text" + class="link-input"> + <button class="remove-link-btn" + data-for="{{name}}[{{forloop.index0}}]"> + - + </button> + {% endfor %} + </div> + <input type="text" + class="link-input-new" + placeholder="http://www.example.com"> + <button class="add-link-btn">+</button> + </div> + {% elsif type == 'media-list' %} <div class="media-list group loaded"> <div class="fields"> |
