Created
May 16, 2009 20:16
-
-
Save shwoodard/112791 to your computer and use it in GitHub Desktop.
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
$.currActive; | |
$.imageCount; | |
$.fn.preCacheImageFromThumb = function () { | |
return $(this).each(function () { | |
var img = new Image(); | |
img.src = $(this).attr('href'); | |
}); | |
}; | |
$.removeCurrActive = function () { | |
if ($.currActive) { | |
$.currActive.find('.staging_thumb-numb-indicator').removeClass('active'); | |
$.currActive = null; | |
} | |
}; | |
$.setCurrActive = function (currActive) { | |
$.removeCurrActive(); | |
$.currActive = $(currActive); | |
$.currActive.find('.staging_thumb-numb-indicator').addClass('active'); | |
$('#staging_main-image').attr('src', $.currActive.attr('href')); | |
}; | |
$(document).ready(function () { | |
$.imageCount = $('.staging_thumb-link').length; | |
$.currActive = $('.staging_thumb-numb-indicator.active').closest('a'); | |
$('.staging_thumb-link').preCacheImageFromThumb().click(function (evt) { | |
evt.preventDefault(); | |
$.setCurrActive(this); | |
}); | |
$('.staging_secondary-photo-nav').click(function(evt) { | |
evt.preventDefault(); | |
var currIndex = parseInt($.currActive.attr('id').substr("staging_thumb-link-".length), 10); | |
var delta = parseInt($(this).attr('rel'), 10); | |
var nextIndex = (currIndex + ($.imageCount + delta)) % $.imageCount; | |
console.log(nextIndex); | |
$.setCurrActive($("#staging_thumb-link-" + nextIndex)); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment