From 0eec322c9755ec6fe8e4dc678d11677de21826e4 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 23 Jul 2011 16:18:24 +0200 Subject: [PATCH] gallery: add image description bar --- css/style.css | 21 +++++++++++++++++++++ js/gallery.js | 16 ++++++++++++++-- js/gallery.min.js | 2 +- screenshots/index.html.mako | 4 ++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/css/style.css b/css/style.css index 017745c..30d413d 100644 --- a/css/style.css +++ b/css/style.css @@ -322,6 +322,27 @@ img { background-image: url('/img/nextbtn.png'); } +#imgdesc { + position: fixed; + left: 64px; + bottom: 0; + background-color: #333; + width: 100%; + padding-top: 1em; + padding-bottom: 1em; + padding-left: 2em; + border: 1px solid #555; + border-bottom: 0; +} + +#imgdesc .filename { + font-weight: bold; +} + +#imgdesc .description { + padding-left: 1em; +} + /* clearfix */ .clearfix:after { content: "."; diff --git a/js/gallery.js b/js/gallery.js index aede943..1145979 100644 --- a/js/gallery.js +++ b/js/gallery.js @@ -58,11 +58,23 @@ function initGallery() { var img = new Image(); img.src = url; + // position imgdesc + $('#imgdesc').css({ 'width': $('body').width() - (2 * 64) - 4 + 'px' }); + + // get description + var desc = $(".shot a[href='" + url + "']").parent().children('span').text(); + $('#imgdesc .description').text(desc); + + // get filename + var pos = url.lastIndexOf('/'); + var filename = (pos !== -1 ? url.substr(pos+1) : url); + $('#imgdesc .filename').text(filename); + var loadcomplete = function() { var winW = $(window).width(); var winH = $(window).height(); var max_w = winW - (2 * 64); - var max_h = winH - 64; + var max_h = winH - 48; var dims = { 'top': 0, 'left': 0, @@ -74,7 +86,7 @@ function initGallery() { dims.height = max_h; dims.width = (dims.height / img.height) * img.width; } - dims.top = (winH - dims.height) / 2; + dims.top = (max_h - dims.height) / 2 + 2; dims.left = ((max_w - dims.width) / 2) + 64; $('#loading').hide(); var element = $(''); diff --git a/js/gallery.min.js b/js/gallery.min.js index a929555..e941cac 100644 --- a/js/gallery.min.js +++ b/js/gallery.min.js @@ -1,4 +1,4 @@ function initGallery(){ (function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('