Created
June 22, 2011 09:59
-
-
Save connor/1039789 to your computer and use it in GitHub Desktop.
Improvements in the overall UX via some more inclusive JS
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
updateNav: function() { | |
Element.show('hoverNav'); | |
// if not first image in set, display prev image button | |
if((activeImage != 0) && ($("lightbox2").getStyle('display') === 'block')){ // only register these event handlers if the lightbox is active | |
Element.show('prevLink'); | |
document.getElementById('prevLink').onclick = function() { | |
myLightbox.changeImage(activeImage - 1); return false; | |
} | |
document.onkeyup = function(e) { // on a key up, run this function | |
if(e.which == 37){ // if that key is the LEFT arrow key | |
if(activeImage != 0){ // if there are images to the left of the image array... | |
myLightbox.changeImage(activeImage - 1); return false; // show the correct image; return false. | |
} else { | |
return false; // otherwise, just return false | |
} | |
} else if(e.which == 27){ // if that key is the ESC key | |
myLightbox.end(); return false; // close the lightbox. | |
} | |
} | |
} | |
// if not last image in set, display next image button | |
if(activeImage != (imageArray.length - 1) && ($("lightbox2").getStyle('display') === 'block')){// only register these event handlers if the lightbox is active | |
Element.show('nextLink'); | |
document.getElementById('nextLink').onclick = function() { | |
myLightbox.changeImage(activeImage + 1); return false; | |
} | |
document.onkeyup = function(e) { // on a key up, run this function | |
if(e.which == 39){ // if that key is the RIGHT arrow key | |
if(activeImage != imageArray.length - 1){ // if there are more images in the carousel | |
myLightbox.changeImage(activeImage + 1); return false; // change the image; return false. | |
} else { | |
return false; // otherwise, just return false. | |
} | |
} else if(e.which == 27){ // if that key is the ESC key | |
myLightbox.end(); return false; // close the lightbox. | |
} | |
} | |
} | |
// added by Adam Shaw (Weebly Inc) to resize the overlay (for really tall images) | |
var arrayPageSize = getPageSize(); | |
Element.setHeight('lightbox2-overlay', Math.max(arrayPageSize[1], $('lightbox2').getHeight() + this.lightboxTop)); | |
this.enableKeyboardNav(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment