Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Slide mode, photo, thumbs navigation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytro committed Nov 28, 2009
1 parent 775ebbf commit 6b36a05
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 58 deletions.
4 changes: 2 additions & 2 deletions wiphoto/index.html
Expand Up @@ -18,7 +18,7 @@
<A HREF="javascript:show.play();">&nbsp;&nbsp;<img src="wiphoto/images/play-N.png" border=0><br>Slideshow</A>
</DIV>
<DIV CLASS="tools" ID="prevnext">
<A HREF="javascript:showPhoto(prev())"><img style="border-right: 1px solid #aaa" src="wiphoto/images/prev-N.png"></a><a
href="javascript:showPhoto(next())"><img src="wiphoto/images/next-N.png"></a>
<A HREF="javascript:photo.show(false,photo.prev())"><img style="border-right: 1px solid #aaa" src="wiphoto/images/prev-N.png"></a><a
href="javascript:photo.show(false,photo.next())"><img src="wiphoto/images/next-N.png"></a>
</DIV></DIV>
</BODY></HTML>
84 changes: 42 additions & 42 deletions wiphoto/js/functions.js
@@ -1,7 +1,9 @@

defaults = { navigation_width: 200, thumb_size:120, slideShowSpeed:1};
preload = {};
keyCode = {32:'space',33:'pgup',34:'pgdown',35:'end',36:'home',37:'left',38:'up',39:'right',40:'down',27:'escape',9:'tab',13:'enter',48:'0'};
keyCode = { 32:'space',33:'pgup',34:'pgdown',35:'end',36:'home',37:'left',38:'up',39:'right',40:'down',27:'escape',9:'tab',13:'enter',48:'0',
83:'s'
};

template = {
'albumLink':
Expand All @@ -19,8 +21,7 @@ template = {

// ----------------------------------------
'thumb':

'<A HREF="JAVASCRIPT:showPhoto(${album},${i});"><IMG ID="thumb_${album}_${i}" CLASS="thumb" WIDTH="${dim[0]}" HEIGHT="${dim[1]}" SRC="${photos[key]["thumb"]["path"]};"></A>',
'<A HREF="JAVASCRIPT:photo.mode(${album},${i});"><IMG ID="thumb_${album}_${i}" CLASS="thumb" WIDTH="${dim[0]}" HEIGHT="${dim[1]}" SRC="${photos[key]["thumb"]["path"]};"></A>',
// ----------------------------------------
'photo':
'<CENTER><IMG WIDTH="${dim[0]}" HEIGHT="${dim[1]}" NAME="SlideShow" ID="showPhoto" SRC="${photos[key]["image"]["path"]}"></CENTER>'
Expand Down Expand Up @@ -110,69 +111,68 @@ template = {
}

// --------------------------------------------------------------------------------
function showPhoto (album,index) {
// current.mode('photo');
current.photo = (index==0) ?0 :(index||current.photo)
current.album = album || current.album
// console.log ("show "+album+':'+index);
w = $('viewPanel').clientWidth -20
h = $('viewPanel').clientHeight -20
key = albums[current.album]['photos'][current.photo];
dim = fitInto(w,h,photos[key]['image']);
$('viewPanel').innerHTML =
TrimPath.parseTemplate(template.photo).process({'dim':dim, 'key':key, 'photos':photos})
}
// --------------------------------------------------------------------------------
function last () {
return (albums[current.album].photos.length-1)
}
function next () {
return ( (current.photo==last()) ?0 :current.photo+1 )
}

function prev () {
return ( (current.photo==0)?last():current.photo-1 )
photo = {
show: function (album,index) {
current.photo = (index==0) ?0 :(index||current.photo)
current.album = album || current.album
w = $('viewPanel').clientWidth -20
h = $('viewPanel').clientHeight -20
key = albums[current.album]['photos'][current.photo];
dim = fitInto(w,h,photos[key]['image']);
$('viewPanel').innerHTML = TrimPath.parseTemplate(template.photo).process({'dim':dim, 'key':key, 'photos':photos})
},
// --------------------------------------------------------------------------------
last: function () { return (albums[current.album].photos.length-1) },
next: function () { return ( (current.photo==photo.last()) ? 0 :current.photo+1 ) },
prev: function () { return ( (current.photo==0) ? photo.last():current.photo-1 ) },
mode: function(album,index)
{ current.mode('photo'); photo.show(album,index) }
}


function KeyCheck (e) {
var KeyPress = (window.event) ? keyCode[event.keyCode] : keyCode[e.keyCode];
switch (current.mode()) {
case 'albumThumb':
switch(KeyPress) {
case 'enter':
case 's':
show.play(); break;
case 'space': showThumbs(); break;
}
break
case 'photo':
switch(KeyPress) {
case 'left': showPhoto(null,prev()); break;
case 'left': photo.show(null,photo.prev()); break;
case 'right':
case 'space': showPhoto(null,next()); break;
case 'space': photo.show(null,photo.next()); break;
case 'escape': showThumbs(); break;
case 'enter': show.play(); break;
}
break
case 'thumb':
switch(KeyPress) {
case 'pgup':
case '0': setThumbSelection(current.album,0); break;
case 'right': setThumbSelection(current.album,next ()); break;
case 'left': setThumbSelection(current.album,prev()); break;
case 'pgdown': setThumbSelection(current.album,last()); break;
case 'right': setThumbSelection(current.album, photo.next()); break;
case 'left': setThumbSelection(current.album, photo.prev()); break;
case 'pgdown': setThumbSelection(current.album, photo.last()); break;

case 'space':
case 'enter': current.mode('photo');showPhoto();break;
case 'space': photo.mode();break;
case 'enter': show.play(); break;

case 'escape': showAlbumThumbs(); break;
}
break
case 'albumThumb':
switch(KeyPress) {
case 'enter': show.play(); break;
case 'space': showThumbs(); break;
}
break
case 'slide':
switch(KeyPress) {
case 'escape': show.stop(); break;
case 'space': show.toggle(); break;
case 'escape':
if (show.running) show.stop()
else showThumbs()
break;
case 'space':
case 'enter': show.toggle(); break;
case 'right': show.next(); break;
case 'left': show.prev(); break;
case 'left': show.prev(); break;
}
}
return (true);
Expand Down
24 changes: 10 additions & 14 deletions wiphoto/js/slides.js
Expand Up @@ -9,9 +9,7 @@ show = {
play: function (album,photo) {
current.album = album || current.album
current.photo = (photo == 0) ? 0 : (photo || current.photo)

slides = albums[current.album].photos;

show.preload(0)
show.current = current.photo
show.next();
Expand All @@ -27,7 +25,6 @@ show = {
toggle: function () {
if (show.running) show.stop()
else show.play(current.album,current.photo)
// alert(show.running)
},
prev: function () {
show.current = show.current -2
Expand All @@ -45,24 +42,23 @@ show = {
// document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
// document.images.SlideShow.filters.blendTrans.Apply()
// }

showPhoto()
photo.show(); current.photo++

if (preload[slides[show.current]])
document.images.SlideShow.src = preload[slides[show.current]].src
else
show.preload(show.current)
show.current++
if (show.current > (slides.length-1)) show.current = 0
if (preload[slides[show.current]]) document.images.SlideShow.src = preload[slides[show.current]].src
else show.preload(show.current)

if (++show.current > (slides.length-1)) show.current = 0
show.timeout = setTimeout('show.next()', show.speed*1000)
},
preload: function (startAt) {
show.preloaded = (startAt == 0) ? 0 : (startAt || show.preloaded)
for (i=0; i<5; i=i+1) {
key = slides[show.preloaded]
if (!preload[key]) preload[key] = new Image ()
preload[key].src = photos[key].image.path
show.preloaded = (show.preloaded >= slides.length-1) ? 0 : show.preloaded+1
if (!preload[key]) {
preload[key] = new Image ()
preload[key].src = photos[key].image.path
}
show.preloaded = (show.preloaded > slides.length-1) ? 0 : show.preloaded+1
}
}
}
Expand Down

0 comments on commit 6b36a05

Please sign in to comment.