summaryrefslogtreecommitdiff
path: root/themes
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-04-13 18:19:41 -0400
committerJules Laplace <jules@okfoc.us>2015-04-13 18:19:41 -0400
commitd45f617dc74a07beb352d04537d47a77193f487f (patch)
treebf87a7f2b1bba238588194b0b29c26e6bd6b9f24 /themes
parent3ac36830841a51f3d3de63f5df849a4bb84b948d (diff)
hide id field
Diffstat (limited to 'themes')
-rw-r--r--themes/okadmin/public/js/app.js16
-rw-r--r--themes/okadmin/templates/partials/inputs.liquid19
2 files changed, 15 insertions, 20 deletions
diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js
index 91a8e1a..009fe4c 100644
--- a/themes/okadmin/public/js/app.js
+++ b/themes/okadmin/public/js/app.js
@@ -51,13 +51,18 @@ var OKAdmin = function(){
// fix post indexing in list-driven inputs
$(".main.resource form").submit(function(e){
- var $id = $("[name=id]")
- if ($id.length && ! $id.val()) {
- alert("Please enter an ID")
- $id.focus()
+ var $id = $("[name=id]"), $title = $("[name=title]")
+
+ if ($title.length && ! $title.val()) {
+ alert("Please enter a title")
+ $title.focus()
e.preventDefault()
return
}
+
+ var slug = slugify( $title.val() )
+ $id.val( slug )
+
$(".image-element").each(function(index){
$(this).find("input,textarea").each(function(){
var field = $(this).attr("name").replace(/\[[0-9]*\]/, "[" + index + "]")
@@ -129,3 +134,6 @@ var OKAdmin = function(){
$(function(){
window.app = new OKAdmin ()
})
+
+
+function slugify (s){ return (s || "").toLowerCase().replace(/\s/g,"-").replace(/[^-_a-zA-Z0-9]/g, '-').replace(/-+/g,"-") }
diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid
index 4d6372d..253b275 100644
--- a/themes/okadmin/templates/partials/inputs.liquid
+++ b/themes/okadmin/templates/partials/inputs.liquid
@@ -3,30 +3,17 @@
{% assign spec = pair[1] %}
{% assign type = spec.type %}
- <div class="property {{type}}">
- <label
- {% if spec.hidden %}
- class="hidden"
- {% endif %}
- for="{{name}}">{{name | capitalize}}</label>
+ <div class="property {{type}} {% if spec.hidden %}hidden{% endif %}">
+ <label for="{{name}}">{{name | capitalize}}</label>
{% if type == 'string' %}
<input
- {% if spec.hidden %}
- class="hidden"
- {% endif %}
- name="{{name}}" type="text" value="{{spec.value}}">
+ name="{{name}}" type="text" value="{{spec.value}}">
{% elsif type == 'text' %}
<textarea
- {% if spec.hidden %}
- class="hidden"
- {% endif %}
name="{{name}}">{{spec.value}}</textarea>
{% elsif type == 'enum' %}
<select
- {% if spec.hidden %}
- class="hidden"
- {% endif %}
name="{{name}}">
{% for option in spec.options %}
<option value="{{option}}" {% if option == spec.value %}selected{% endif %}>{{option | capitalize}}</option>