From 58b62a1d76298a568aa0ded39f986477f889b793 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 13 Apr 2015 18:30:24 -0400 Subject: use type and id for frontend lookups --- site/public/assets/javascripts/_env.js | 36 ++++++++++++++++------------------ site/templates/all.liquid | 22 +++++++++++++++++++-- site/templates/index.liquid | 8 ++++---- themes/okadmin/public/js/app.js | 9 +++++++-- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/site/public/assets/javascripts/_env.js b/site/public/assets/javascripts/_env.js index 2c183aa..8871602 100644 --- a/site/public/assets/javascripts/_env.js +++ b/site/public/assets/javascripts/_env.js @@ -43,16 +43,14 @@ environment.ready = function(){ $("nav a").click(function(e){ e.preventDefault() - var hash = "#" + $(this).data("hash") + var page = "/" + $(this).data("type") + "/" + $(this).data("id") + var hash = "#" + page if (done_loading && window.location.hash == hash) return window.location.hash = hash $("nav a.active").removeClass("active") $(this).addClass("active") open_entry() - - var page = $(this).attr("href") - if (page.indexOf("#") !== -1) page = "#" $("#entry_container").removeClass("visible") @@ -66,8 +64,8 @@ environment.ready = function(){ $("nav .about").click(function(e){ e.preventDefault() - if (done_loading && window.location.hash == "#about") return - window.location.hash = "#about" + if (done_loading && window.location.hash == "#/about") return + window.location.hash = "#/about" $("nav a.active").removeClass("active") open_entry() @@ -81,8 +79,8 @@ environment.ready = function(){ $("nav .contact").click(function(e){ e.preventDefault() - if (done_loading && window.location.hash == "#contact") return - window.location.hash = "#contact" + if (done_loading && window.location.hash == "#/contact") return + window.location.hash = "#/contact" $("nav a.active").removeClass("active") open_entry() @@ -96,8 +94,8 @@ environment.ready = function(){ $("nav .index").click(function(e){ e.preventDefault() - if (done_loading && window.location.hash == "#index") return - window.location.hash = "#index" + if (done_loading && window.location.hash == "#/index") return + window.location.hash = "#/index" $("nav a.active").removeClass("active") open_entry() @@ -107,13 +105,13 @@ environment.ready = function(){ $loader.load("all .entry", function(){ display_entry($loader.children()[0]) }) - }) + }) $(".toggleRapper").click(toggle_menu) $(".toplogo").click(hide_entry) $(document).on("click", ".project", function(){ - var hash = as_hash( $(this).find("span").text() ) - load_hash(hash) + var page = "/" + $(this).data("type") + "/" + $(this).data("id") + load_hash(page) }) $(window).mousedown(function(e){ @@ -146,13 +144,13 @@ environment.ready = function(){ var current_hash = window.location.hash.replace("#","") $("nav a").each(function(){ - var key = as_hash(this.innerHTML) - hashes[key] = this - $(this).data("hash", key) + var page = "/" + $(this).data("type") + "/" + $(this).data("id") + hashes[page] = this + $(this).data("hash", page) }) - hashes['about'] = $("nav .about") - hashes['contact'] = $("nav .contact") - hashes['index'] = $("nav .index") + hashes['/about'] = $("nav .about") + hashes['/contact'] = $("nav .contact") + hashes['/index'] = $("nav .index") if (current_hash in hashes) { toggle_menu() diff --git a/site/templates/all.liquid b/site/templates/all.liquid index 852137f..01ddc3a 100644 --- a/site/templates/all.liquid +++ b/site/templates/all.liquid @@ -1,6 +1,24 @@
- {% for project in projects %} -
+ {% for project in retails %} +
+ + {{ project.shortname }} +
+ {% endfor %} + {% for project in advertisings %} +
+ + {{ project.shortname }} +
+ {% endfor %} + {% for project in experientials %} +
+ + {{ project.shortname }} +
+ {% endfor %} + {% for project in contents %} +
{{ project.shortname }}
diff --git a/site/templates/index.liquid b/site/templates/index.liquid index 0bd6b7d..19bdf88 100644 --- a/site/templates/index.liquid +++ b/site/templates/index.liquid @@ -88,25 +88,25 @@ WEBSITE BY OKFOCUS, http://okfoc.us, Internet Legends.
retail
{% for project in retails %} - {{ project.shortname }} + {{ project.shortname }} {% endfor %}
advertising
{% for project in advertisings %} - {{ project.shortname }} + {{ project.shortname }} {% endfor %}
experiential
{% for project in experientials %} - {{ project.shortname }} + {{ project.shortname }} {% endfor %}
content
{% for project in contents %} - {{ project.shortname }} + {{ project.shortname }} {% endfor %}
diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index 009fe4c..b53d21f 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -51,7 +51,7 @@ var OKAdmin = function(){ // fix post indexing in list-driven inputs $(".main.resource form").submit(function(e){ - var $id = $("[name=id]"), $title = $("[name=title]") + var $id = $("[name=id]"), $title = $("[name=title]"), $shortname = $("[name=shortname]") if ($title.length && ! $title.val()) { alert("Please enter a title") @@ -60,6 +60,11 @@ var OKAdmin = function(){ return } + if ($shortname.length && ! $shortname.val()) { + $shortname.val( $title.val() ) + return + } + var slug = slugify( $title.val() ) $id.val( slug ) @@ -136,4 +141,4 @@ $(function(){ }) -function slugify (s){ return (s || "").toLowerCase().replace(/\s/g,"-").replace(/[^-_a-zA-Z0-9]/g, '-').replace(/-+/g,"-") } +function slugify (s){ return (s || "").toLowerCase().replace(/\s/g,"-").replace(/[^-_a-zA-Z0-9]/g, '-').replace(/-+/g, "-") } -- cgit v1.2.3-70-g09d2