From f87af86cb4a0e2b64d3d1cb3175b3f1f27841d7b Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 9 Oct 2011 17:02:58 +0530 Subject: [PATCH] URL Hashes --- urbstudio/static/js/projects.js | 15 ++++++++++++++- urbstudio/templates/projects.html | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/urbstudio/static/js/projects.js b/urbstudio/static/js/projects.js index b4e8fa0..1769e64 100644 --- a/urbstudio/static/js/projects.js +++ b/urbstudio/static/js/projects.js @@ -12,6 +12,7 @@ $(function(){ var project_id = $this.attr("data-id"); // doProjectLoading(); $.getJSON("project_json", {'id': project_id}, function(data) { + location.hash = data.slug; $('#projectTitle').next().text(data.title); $('#projectSizeProgram').next().html(nl2br(data.size_program)); $('#projectDesignStatement').next().html(nl2br(data.design_statement)); @@ -30,9 +31,21 @@ $(function(){ }); }); - $('.projectThumb').eq(0).click(); + + var hash = location.hash; + if (hash == '') { + $('.projectThumb').eq(0).click(); + } else { + var $thumb = $('#thumb_' + hash); + if ($thumb.length > 0) { + $thumb.click(); + } else { + $('.projectThumb').eq(0).click(); + } + } }); + function getA(image) { var $a = $('').attr("href", "#"); var $img = $('').attr("src", image.url).appendTo($a); diff --git a/urbstudio/templates/projects.html b/urbstudio/templates/projects.html index 6b79ffd..9a81313 100755 --- a/urbstudio/templates/projects.html +++ b/urbstudio/templates/projects.html @@ -78,7 +78,7 @@ {% load thumbnail %} {% for p in projects %} {% thumbnail p.thumb_image "100x100" crop="center" as im %} -
  • {{ p.title }}
  • +
  • {{ p.title }}
  • {% endthumbnail %} {% endfor %}