Permalink
Browse files

Update image name and descr on image transition

  • Loading branch information...
1 parent 6c9d91d commit 68afced46b07c6b14e537a39425fc1d1ef37308c @toamitkumar committed May 8, 2012
Showing with 12 additions and 8 deletions.
  1. +3 −3 app/views/images/index.html.erb
  2. +9 −5 public/javascripts/images.js
@@ -30,13 +30,13 @@
<div id="caption_image" class="caption-container">
<div>
<div>
- Name: <span class="image-title"><%=@images.first.name%></span>
+ Name: <span class="image-title" id="image-name"><%=@images.first.name%></span>
</div>
<div>
- Description: <span class="image-title"><%=@images.first.description%></span>
+ Description: <span class="image-title" id="image-descr"><%=@images.first.description%></span>
</div>
<!-- <div>
- Category: <span class="image-title"><%#=@images.first.category.name%></span>
+ Category: <span class="image-title" id="image-cat"><%#=@images.first.category.name%></span>
</div> -->
</div>
<% if(current_user.admin?) %>
@@ -14,6 +14,11 @@ jQuery(document).ready(function() {
$("a.thumb").click(function() {
var that = $(this);
+ // data = JSON.parse(that.attr("data-caption"));
+ // console.log(data.name)
+ // $("#image-name").html(data.name);
+ // $("#image-descr").html(data.descr);
+ add_caption(that);
if(that.attr("data-link") != "") {
$("#tagImage").attr("href", that.attr("data-link"));
}
@@ -58,7 +63,7 @@ jQuery(document).ready(function() {
nextLinkText: 'Next Photo &rsaquo;',
nextPageLinkText: 'Next &rsaquo;',
prevPageLinkText: '&lsaquo; Prev',
- enableHistory: true,
+ enableHistory: false,
autoStart: false,
syncTransitions: true,
defaultTransitionDuration: 500,
@@ -79,7 +84,6 @@ jQuery(document).ready(function() {
if(image_edit_link != "") {
$("#tagImage").attr("href", image_edit_link);
}
- add_caption(this.find("ul.thumbs > li.selected a").attr("data-caption"))
},
onPageTransitionIn: function() {
var prevPageLink = this.find('a.prev').css('visibility', 'hidden');
@@ -113,7 +117,7 @@ jQuery(document).ready(function() {
});
function add_caption(data_caption_link) {
- data = JSON.parse(data_caption_link);
- console.log(data.name)
- console.log(data.descr)
+ data = JSON.parse(data_caption_link.attr("data-caption"));
+ $("#image-name").html(data.name);
+ $("#image-descr").html(data.descr);
}

0 comments on commit 68afced

Please sign in to comment.