Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

keyboard support for photo navigation

  • Loading branch information...
commit 1c37d52aca7fc914ae5156ce03349be3ad54616a 1 parent e620094
Eli Horne authored

Showing 1 changed file with 65 additions and 135 deletions. Show diff stats Hide diff stats

  1. +65 135 js/function.js
200 js/function.js
@@ -32,43 +32,61 @@ updateModal = function(nextSource){
32 32
33 33 };
34 34
35   -$('.super-pop.photo .right').live('click', function(){
36   - currentPhoto = $('.active-photo');
37   - nextPhoto = currentPhoto.next();
38   - nextPhotoSrc = nextPhoto.find('img').attr('src');
39   - // update the modal
40   - currentPhoto.removeClass('active-photo');
41   - nextPhoto.addClass('active-photo');
42   - updateModal(nextPhoto);
43   - $('.super-pop img').attr('src', nextPhotoSrc);
44   -
45   - if(nextPhoto.find('.payload').length) {
46   - targetPayload = nextPhoto.find('.payload').html();
  35 +
  36 +
  37 +goLeft = function(){
  38 + if($('.super-pop .left').is(':visible')) {
  39 + currentPhoto = $('.active-photo');
  40 + nextPhoto = currentPhoto.prev();
  41 + nextPhotoSrc = nextPhoto.find('img').attr('src');
  42 + // update the modal
  43 + currentPhoto.removeClass('active-photo');
  44 + nextPhoto.addClass('active-photo');
  45 + updateModal(nextPhoto);
  46 + $('.super-pop img').attr('src', nextPhotoSrc);
47 47
48   - if(typeof targetPayload != 'undefined') {
49   - $('.super-pop .payload').html(targetPayload);
  48 + if(nextPhoto.find('.payload').length) {
  49 + targetPayload = nextPhoto.find('.payload').html();
  50 +
  51 + if(typeof targetPayload != 'undefined') {
  52 + $('.super-pop .payload').html(targetPayload);
  53 + }
50 54 }
  55 + } else {
  56 + killModal();
51 57 }
  58 +};
  59 +
  60 +goRight = function(){
  61 + if($('.super-pop .right').is(':visible')) {
  62 + currentPhoto = $('.active-photo');
  63 + nextPhoto = currentPhoto.next();
  64 + nextPhotoSrc = nextPhoto.find('img').attr('src');
  65 + // update the modal
  66 + currentPhoto.removeClass('active-photo');
  67 + nextPhoto.addClass('active-photo');
  68 + updateModal(nextPhoto);
  69 + $('.super-pop img').attr('src', nextPhotoSrc);
  70 +
  71 + if(nextPhoto.find('.payload').length) {
  72 + targetPayload = nextPhoto.find('.payload').html();
  73 +
  74 + if(typeof targetPayload != 'undefined') {
  75 + $('.super-pop .payload').html(targetPayload);
  76 + }
  77 + }
  78 + } else {
  79 + killModal();
  80 + };
  81 +};
  82 +
  83 +$('.super-pop.photo .right').live('click', function(){
  84 + goRight();
52 85 event.preventDefault();
53 86 });
54 87
55 88 $('.super-pop.photo .left').live('click', function(){
56   - currentPhoto = $('.active-photo');
57   - nextPhoto = currentPhoto.prev();
58   - nextPhotoSrc = nextPhoto.find('img').attr('src');
59   - // update the modal
60   - currentPhoto.removeClass('active-photo');
61   - nextPhoto.addClass('active-photo');
62   - updateModal(nextPhoto);
63   - $('.super-pop img').attr('src', nextPhotoSrc);
64   -
65   - if(nextPhoto.find('.payload').length) {
66   - targetPayload = nextPhoto.find('.payload').html();
67   -
68   - if(typeof targetPayload != 'undefined') {
69   - $('.super-pop .payload').html(targetPayload);
70   - }
71   - }
  89 + goLeft();
72 90 event.preventDefault();
73 91 });
74 92
@@ -165,9 +183,6 @@ $('.thumb').live('click', function(){
165 183
166 184
167 185
168   -
169   -
170   -
171 186 $('.gallery-toggle').live('click', function(){
172 187 targetThumb = $(this).parents().find('.gallery .photo-item:first');
173 188 targetThumb.addClass('active-photo');
@@ -203,10 +218,6 @@ $('.gallery-toggle').live('click', function(){
203 218
204 219
205 220
206   -
207   -
208   -
209   -
210 221 $('.super-pop .close').live('click',function(){
211 222 killModal();
212 223 })
@@ -251,77 +262,16 @@ lightbox = function(targetImage) {
251 262
252 263
253 264 showViaKeypress = function(message){
254   - if($('.super-pop').length) {
255   - $('.super-pop').remove();
256   - } else {
257   - $('body').append('<div class="super-pop">'+message+'</div>');
258   - $('.super-pop').fadeIn('fast');
259   - setTimeout("$('.super-pop').remove();", 1500);
260   - };
261   -
  265 +
262 266
263 267 if(message == 'right') {
264   - if($('.active-photo').is(':last-child')) {
265   - return false;
266   - } else {
267   - $('article.active .active-photo').removeClass('active-photo').next().addClass('active-photo');
268   - };
  268 + goRight();
269 269 };
270 270
271 271 if(message == 'left') {
272   - if($('.active-photo').is(':first-child')) {
273   - return false;
274   - } else {
275   - $('article.active .active-photo').removeClass('active-photo').prev().addClass('active-photo');
276   - };
277   -
278   - };
279   -
280   - if(message == 'down') {
281   - if($('.thumb.active').is(':last-child')) {
282   - return false;
283   - } else {
284   -
285   - xCount = 1 + $('.thumb.active').prevAll().length;
286   - console.log(xCount);
287   -
288   -
289   - //$('thumb.active').removeClass('active-photo');
290   -
291   - //if(xCount > $('article.active').next().find('li').length) {
292   - // console.log('inequity!');
293   - // xCount = $('article.active').next().find('li').length;
294   - //};
295   -
296   - $('.thumb.active').removeClass('active').next().find('li:nth-child('+xCount+')').addClass('active');
297   -
298   - targetThumb = $('.thumb.active');
299   - showModal(targetThumb);
300   - //$('article.active').removeClass('active').addClass('inactive').next().addClass('active');
301   -
302   - };
303   - };
304   -
305   - if(message == 'up') {
306   - if($('article.active').is(':first-child')) {
307   - return false;
308   - } else {
309   -
310   - xCount = 1 + $('.active-photo').prevAll().length;
311   - //console.log(xCount);
312   -
313   - $('.active-photo').removeClass('active-photo');
314   -
315   -
316   -
317   - if(xCount > $('article.active').prev().find('li').length) {
318   - //console.log('inequity!');
319   - xCount = $('article.active').prev().find('li').length;
320   - };
321   - $('article.active').prev().find('li:nth-child('+xCount+')').addClass('active-photo');
322   - $('article.active').removeClass('active').addClass('inactive').prev().addClass('active');
323   - };
  272 + goLeft();
324 273 };
  274 +
325 275
326 276 };
327 277
@@ -367,40 +317,20 @@ deepLink = function(){
367 317
368 318 deepLink();
369 319
370   -
371   -
372   -
373   -/*
374 320 $(window).keydown(function(e) {
375 321 if($('.super-pop').length) {
376   - switch(e.which)
377   - {
378   - // user presses the "escape"
379   - case 27: killModal();
380   - break;
381   -
382   - case 13: showViaKeypress('enter');
383   - break;
384   -
385   - // user presses the "right" key
386   - case 39: showViaKeypress('right');
387   - break;
388   -
389   - // user presses the "left" key
390   - case 37: showViaKeypress("left", "&#8612;");
391   - break;
392   -
393   - // user presses the "top" key
394   - case 38: showViaKeypress("up");
395   - break;
396   -
397   - // user presses the "g" key
398   - case 40: showViaKeypress("down");
399   - break;
400   -
401   - // user presses the "f" key
402   - case 32: showViaKeypress("spacebar");
403   - }
  322 + switch(e.which) {
  323 + // user presses "escape"
  324 + case 27: killModal();
  325 + break;
  326 +
  327 + // user presses the "right" key
  328 + case 39: showViaKeypress('right');
  329 + break;
  330 +
  331 + // user presses the "left" key
  332 + case 37: showViaKeypress("left", "&#8612;");
  333 + break;
  334 + }
404 335 }
405 336 });
406   -*/

0 comments on commit 1c37d52

Please sign in to comment.
Something went wrong with that request. Please try again.