Created
May 28, 2009 05:43
-
-
Save sms420/119122 to your computer and use it in GitHub Desktop.
image_viewer.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
//this one was hacked by buddy g-dawg. | |
jQuery(document).ready(function() { | |
// put all your jQuery goodness in here. | |
// get source when page is loaded | |
var original_src = jQuery("#imgvwrFeature img").attr("src"); | |
var original_icon; | |
// now lets setup the hover logic using jquery and | |
// CSS selectors! | |
jQuery("#icons a img").hover( | |
// Mouse over | |
function () { | |
// these vars will use the image you hover on "this" | |
// and attach a suffix modifier to the name to make it featured | |
var feature_suffix = "_big"; | |
var icon_suffix = "_bw"; | |
//sharedLogic | |
var this_img = this.src.substring(0,this.src.length-4); | |
var this_img_type = this.src.substring(this.src.lastIndexOf("."),this.src.length); | |
var featured_image = this_img + feature_suffix + this_img_type; | |
var icon_image = this_img + icon_suffix + this_img_type; | |
// if the hovered image is already black and white then bail out | |
if ( jQuery(this).hasClass('dude') ) { | |
// alert('dude is true'); | |
} else { // continue | |
// reset the bw image to the original icon | |
if ((typeof original_icon != 'undefined')){ | |
jQuery("#icons a img.dude").attr("src",original_icon); | |
} | |
// reset the border on active image | |
jQuery("#icons a img.dude").toggleClass("dude"); | |
// set the original icon to this icon | |
original_icon = jQuery(this).attr("src"); | |
// set active hover | |
jQuery(this).attr("src", icon_image); | |
jQuery(this).toggleClass("dude"); | |
// now do the src swap for the feature | |
jQuery("#imgvwrFeature img").attr("src", featured_image); | |
}; //closes else | |
}, //closes Mouse over function | |
// Mouse out | |
function () { | |
// HAHA, shit, we don't even need to do anything now | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment