-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f039de
commit 8b3409f
Showing
6 changed files
with
280 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
photo_docs = undefined | ||
max_i = undefined | ||
i = undefined | ||
summary_image_tag_loader = undefined | ||
summary_image_div_tag = undefined | ||
|
||
get_thumb_url = () -> | ||
photo_docs[i]['thumb_url'] | ||
|
||
get_next = () -> | ||
i = 0 if i > max_i | ||
summary_image_tag_loader.attr 'src', get_thumb_url() | ||
|
||
success_get_next = () -> | ||
i++ | ||
get_next() | ||
|
||
error_get_next = () -> | ||
photo_docs.splice i, 1 | ||
max_i-- | ||
get_next() unless max_i < 0 | ||
|
||
summary_init = (_photo_docs) -> | ||
photo_docs = _photo_docs | ||
max_i = _photo_docs.length - 1 | ||
i = 0 | ||
|
||
summary_image_div_tag = $('.this_photo') | ||
summary_image_tag_loader = $('.deckster_photos_summary_photo_loader') | ||
|
||
summary_image_tag_loader.load () -> | ||
summary_image_div_tag.fadeOut 350, () => | ||
summary_image_div_tag.css 'background-image', 'url(' + get_thumb_url() + ')' | ||
summary_image_div_tag.fadeIn 350 | ||
setTimeout success_get_next, 3000 | ||
|
||
summary_image_tag_loader.error () -> | ||
error_get_next() | ||
|
||
get_next() unless max_i < 0 | ||
|
||
detail_init = (_photo_docs) -> | ||
card_height = $('#photos').height() | ||
if(card_height != null && card_height >= 506) | ||
$('.deckster_photos_scroll').css('height', card_height - 506) | ||
|
||
$('.deckster_photos_preview > li > img').load () -> | ||
$preview_img = $(this) | ||
EXIF.getData $preview_img[0], () -> | ||
$preview_img.siblings('.metadata').find('.data').find('.exif').append EXIF.pretty_html($preview_img[0]) | ||
|
||
$('.deckster_photos_preview > li > img').error () -> | ||
$preview_img = $(this) | ||
doc_id = $preview_img.parent('li').attr 'data-doc-id' | ||
$(".deckster_photos_thumbnail[data-doc-id=#{doc_id}]").addClass 'full_image_error' | ||
|
||
$('.deckster_photos_thumbnail > img').error () -> | ||
$thumbnail_img = $(this) | ||
$thumbnail_img.parent('li').addClass 'thumb_image_error' | ||
$thumbnail_img.siblings('.thumbnail_cropped').css 'background-image', 'url(<%= image_path 'x.png' %>)' | ||
|
||
$('.deckster_photos_thumbnail > img').load () -> | ||
$thumbnail_img = $(this) | ||
url = $thumbnail_img.attr 'src' | ||
$thumbnail_img.siblings('.thumbnail_cropped').css 'background-image', 'url(' + url + ')' | ||
|
||
$('.deckster_photos_thumbnail').click () -> | ||
$thumbnail = $(this) | ||
doc_id = $thumbnail.attr 'data-doc-id' | ||
|
||
$('.deckster_photos_thumbnail').removeClass 'highlight' | ||
$thumbnail.addClass 'highlight' | ||
|
||
$(".deckster_photos_preview > li").fadeOut() | ||
$(".deckster_photos_preview > li[data-doc-id=#{doc_id}]").fadeIn() | ||
|
||
$(".deckster_photos_thumbnail:first").click() | ||
|
||
preview_prev = () -> | ||
prev = $(".deckster_photos_preview > li:visible").prev(); | ||
prev = $(".deckster_photos_preview > li:last") if prev.length == 0 | ||
|
||
doc_id = prev.attr 'data-doc-id' | ||
$(".deckster_photos_thumbnail[data-doc-id=#{doc_id}]").click() | ||
|
||
preview_next = () -> | ||
next = $(".deckster_photos_preview > li:visible").next(); | ||
next = $(".deckster_photos_preview > li:first") if next.length == 0 | ||
|
||
doc_id = next.attr 'data-doc-id' | ||
$(".deckster_photos_thumbnail[data-doc-id=#{doc_id}]").click() | ||
|
||
window.deckster_photos = | ||
summary_init: summary_init | ||
detail_init: detail_init | ||
preview_prev: preview_prev | ||
preview_next: preview_next | ||
|
||
$(document).on('ready', ()-> | ||
$('body').on('keydown', (event) -> | ||
return unless $('.gallery').length > 0 | ||
switch event.which | ||
when 37 then $('.control.previmg').click() | ||
when 39 then $('.control.nextimg').click() | ||
event.preventDefault() | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<div class="gallery"> | ||
<a onclick="window.deckster_photos.preview_prev();" class="control previmg">PREV</a> | ||
<ol class="deckster_photos_preview"> | ||
<% deckster_photo_docs.each do |doc| %> | ||
<li data-doc-id="<%= doc[:id] %>" style="display: none;"> | ||
<img src="<%= doc[:full_url] %>" height="500" alt="preview not available" /> | ||
<div class="metadata"> | ||
<div class="data"> | ||
|
||
<div class="info"> | ||
id: <%= doc[:id] %><br/> | ||
thumb_url: <%= doc[:thumb_url] %><br/> | ||
full_url: <%= doc[:full_url] %> | ||
</div> | ||
<div class="exif"></div> | ||
|
||
</div> | ||
</div> | ||
</li> | ||
<% end %> | ||
</ol> | ||
<a onclick="window.deckster_photos.preview_next();" class="control nextimg">NEXT</a> | ||
</div> | ||
|
||
<div class="key"> | ||
<p><span class="full_image_error"></span> <span>No preview image available</span></p> | ||
<p><span class="thumb_image_error"></span> <span>No thumbnail image available</span></p> | ||
</div> | ||
<div class="deckster_photos_scroll"> | ||
<ol class="deckster_photos_thumbs"> | ||
<% deckster_photo_docs.each do |doc| %> | ||
<li class="deckster_photos_thumbnail" data-doc-id="<%= doc[:id] %>"> | ||
<img src='<%= doc[:thumb_url] %>' style="display: none;"/> | ||
<div class="thumbnail_cropped" style="background-image:url(<%= image_path 'spinner.gif' %>);"></div> | ||
</li> | ||
<% end %> | ||
</ol> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
$(document).ready(function () { | ||
window.svg_icons.init(); | ||
$('[data-toggle="tooltip"]').tooltip(); | ||
window.deckster_photos.detail_init(<%= deckster_photo_docs.to_json.html_safe %>); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div class="deckster_photos_summary"> | ||
<div class="deckster_photos_preview"> | ||
<div class="deckster_photos_summary_photos rotate"></div> | ||
<div class="deckster_photos_summary_photos"> | ||
<img class="deckster_photos_summary_photo_loader" style="display: none;"/> | ||
<div class="deckster_photos_summary_photo" > | ||
<div class="this_photo"></div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="deckster_photos_count"> | ||
<%= deckster_photo_docs.count %> | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
$(document).ready(function () { | ||
window.svg_icons.init(); | ||
$('[data-toggle="tooltip"]').tooltip(); | ||
|
||
window.deckster_photos.summary_init(<%= deckster_photo_docs.to_json.html_safe %>); | ||
}); | ||
</script> |