From 9e4837278ba88ca483e67c0a6edc813a77996a67 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 23 Jul 2011 14:09:02 +0200 Subject: [PATCH] gallery: add proper previous / next buttons, progress indicator --- css/style.css | 15 +++++++++------ img/loading.gif | Bin 0 -> 1805 bytes img/nextbtn.png | Bin 0 -> 777 bytes img/prevbtn.png | Bin 0 -> 812 bytes js/gallery.js | 24 +++++++++++++----------- js/gallery.min.js | 2 +- 6 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 img/loading.gif create mode 100644 img/nextbtn.png create mode 100644 img/prevbtn.png diff --git a/css/style.css b/css/style.css index 564611f..b568027 100644 --- a/css/style.css +++ b/css/style.css @@ -270,9 +270,10 @@ img { position: fixed; left: 50%; top: 50%; - width: 64px; - height: 64px; - background-color: red; + width: 58px; + height: 60px; + background-color: black; + background-image: url('/img/loading.gif'); opacity: 0.9; z-index: 20; display: none; @@ -305,17 +306,19 @@ img { width: 64px; height: 64px; border-radius: 4px; - background-color: green; - z-index: 19; + background-color: black; + z-index: 22; + opacity: 0.7; } #imgleft { left: 0; + background-image: url('/img/prevbtn.png'); } #imgright { right: 0; - background-color: blue; + background-image: url('/img/nextbtn.png'); } /* clearfix */ diff --git a/img/loading.gif b/img/loading.gif new file mode 100644 index 0000000000000000000000000000000000000000..f51f9c65a76aed60cb061c7026697b91a5ceedcf GIT binary patch literal 1805 zcmcK4X;2eq7zgkr+0B8q^#F8if=eQ3B^)YV;1Lu>s$3ogLQ!HlM6M7+MNvpX*dPKL z2q6YYKp=*2C|7`lGXw;=>QU676`9srohdrjj<%iBO>D=b{o4Kf&c4s@eV+g0?Xz>k zM&>$TJ@A4EAP6!&J^k$2GY1C;wOUP~P~6?!H5v_v!vX&5vzwjcw`2dl?VbTURy(_5 zEzmP|e=gb1j%0EoBjDpPoFg#vC^IE4ks09}lMs~%*u4gcmH-i;nf_+F6aYtDhkR-} zH#{BH&4#bYi-?g|B@y(@vgP_Q45k3*+kL$4N$qwQ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000000000000..f5d1190ea4672064e70bd4d47d6358a2b947214b GIT binary patch literal 777 zcmeAS@N?(olHy`uVBq!ia0vp^4nXY4!3-qBUI%#sDaPU;cPEB*=VV?2Ih+L^k;Op8 z*Fl)kNn>^eP>{XE)7O>#HoG{thFrptPM|4_ngKo`u0SbD0231v3kwSy8yhz_HxCbw zfPjFIkdTOoh^VNjn3$Nnyu6Zv9YnKsj024t)ru(v$M0S ztE-2HhnJU^x3{;Ck56P|WK>jCbaZq=LPAnfQc6lnW@ctqR#skKUVeUlK|w)FOG|5O zYgboSUtiypDO09Rn>Ky=^x3m#FIu!{@#4kn*RS8OVZ+9a8#is*v~SC2ZdU%!6+{{8#UpFjWp{rm6VzyJULPn^xZ8W>U{B|(0{42;ZXHhxjD%~R(uTD)?@ zrY)z={d<)boeB(8H%}MGkch)aZ-fUi1q!r2%swX>c%&ie*qRx|4kE@}Y$50N|99Qd zZkc-V{pV2svwLOLSnQ>4Su4A_d&hDtG)!}e=2&>UqE11~=|!p05B`KZ%w`WtuQ9YS zY!sD^U}`vi;(!suqvDH94sR+M9-U-v@H)nFWFosloSP2AN9%k>25~(H!&D}v$BYNI za&~OrGMzE$F0+8ST!V&x6vKgi+y&Ne7#~&NI?Yh{g0aKt5);ES8;3`C&N$pr)n!<5 z%+?`ix5G6imz$NWfoCJv*)nva^hIHbG?1mmTSN5`TsG*WOroMe0~Z} No}R9LF6*2UngF9>HNXG> literal 0 HcmV?d00001 diff --git a/img/prevbtn.png b/img/prevbtn.png new file mode 100644 index 0000000000000000000000000000000000000000..79506e925865cdfec048deebc78ce554a8e4e70c GIT binary patch literal 812 zcmeAS@N?(olHy`uVBq!ia0vp^4nXY4!3-qBUI%#sDaPU;cPEB*=VV?2Ih+L^k;Op8 z*Fl)kNn>^eP>{XE)7O>#HoG{tKF96ARY!n&0s?$OT!B&)0!BtgCMG6kW@Z)^7FJeP zHa0dcE-r3vZhn4#K|w(wAt7O5VG$7#QBhGbF);}V2{}1A1qB5~MMX6=HFb4$EiEl$ zV`CE&6H`-D3kwT7J3D)Odq+n{H#awLZ|~61(Ae16xVX5)#Kfeeq~zq})YR0pw6y&E z{Gy_w^78VAhK81wmX3~&i4!MIpFVx&%$ZA;ELpZ}+4AMfSFc{ZVZ(;an>TOSvSsVm zt=qP3+rEAKjvYG=95`_J@Zn>}j-5Gk=KT5dmo8npdiCnfn>X*=xpVjK-Fx@$J$Ufo z;lqcI9zA;UgPoF(|_Wb$tmoHzwdiCnfn>U|7fByFE+xPF^fBg9I^XJcBzkdDx z{rk_KKmY#y`~UyHcyo0bFhE61g8YIREUj!DoZXvRIy$?jO`kby_OeyK{<_VX28=OA zM^6{Wkch)qZ@7jt6$r3=5Zzt8f!WYN@Qs5`j?NpWoWL3H>pw3t*ZX&z`!i$R`?smz z&(3WR>=X zjh>U9Y*RKU^5mRRvykae&wHMd0Wp2$7!U;fsO<-%5F zrVnnHq!@Z)yBYqpD>3LSb!Au_uEcPE9|yzce5Hm5x}HUc_v(LnGwF;UXY1kJ6D;PR x|9okx^oqa+uC3PMGiHiTooc=8%4h!b&H0C|r~WIm>|X^+zMigrF6*2UngH46MZ*99 literal 0 HcmV?d00001 diff --git a/js/gallery.js b/js/gallery.js index 284fb21..e601b2e 100644 --- a/js/gallery.js +++ b/js/gallery.js @@ -5,6 +5,14 @@ function initGallery() { $(document).ready(function() { $('.shot span').css('color', '#888'); + $('#imgleft, #imgright').mouseover(function() { + $(this).css('opacity', 0.9); + }); + + $('#imgleft, #imgright').mouseout(function() { + $(this).css('opacity', 0.7); + }); + $('.shot img').mouseover(function() { $(this).parent().parent().children('span').css('color', 'white'); }); @@ -28,8 +36,6 @@ function initGallery() { }); var wheelhandler = function(event, delta) { - //console.log('event = ' + event + ', delta = ' + delta); - // if we are not in the slideshow mode, process the event as normal if (!$('#mask').is(':visible')) { return true; @@ -74,7 +80,7 @@ function initGallery() { $('#loading').hide(); var element = $(''); element.attr({ 'src': url, 'width':dims.width }); - element.css({ 'position': 'absolute', 'top':dims.top + 'px', 'left':dims.left + 'px' }); + element.css({ 'z-index': 21, 'position': 'absolute', 'top':dims.top + 'px', 'left':dims.left + 'px' }); if (direction !== undefined) { // slide from right to left if (direction === 'left') { @@ -100,10 +106,8 @@ function initGallery() { }; if (img.complete) { - //console.log('image already in cache'); loadcomplete(); } else { - //console.log('loading image'); img.onload = loadcomplete; } }; @@ -136,8 +140,7 @@ function initGallery() { showmask(); var full = $(this).parent().attr('href'); - var loading = $('#loading'); - loading.show(); + $('#loading').show(); loadimage(full, undefined, false); @@ -152,13 +155,13 @@ function initGallery() { var next = images[idx+1]; if (next === undefined) { - //console.log('there is no next image'); return false; } - //console.log('loading next one: ' + next); + $('#imgright').css('opacity', 1.0).animate({ opacity: 0.7 }, 500); // slide out the current image var winW = $(window).width(); + $('#loading').show(); $('#maskinner img').animate({ 'left': '-=' + (winW - 64) }, 'fast', function() { $(this).remove(); }); @@ -176,11 +179,10 @@ function initGallery() { var prev = images[idx-1]; if (prev === undefined) { - //console.log('there is no next image'); return false; } - //console.log('loading prev one: ' + prev); + $('#imgleft').css('opacity', 1.0).animate({ opacity: 0.7 }, 500); // slide out the current image var winW = $(window).width(); $('#maskinner img').animate({ 'left': '+=' + winW }, 'fast', function() { diff --git a/js/gallery.min.js b/js/gallery.min.js index 623d4ff..a2bafac 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=$('