-
Notifications
You must be signed in to change notification settings - Fork 0
/
will_hover.min.js
1 lines (1 loc) · 1.79 KB
/
will_hover.min.js
1
if(typeof Prototype!=='undefined'){document.observe("dom:loaded",function(){$$('.will_hover').each(function(el,index){Event.observe(el,'mouseover',function(){var ext=this.src.split('.').reverse().first();this.src=this.src.replace('.'+ext,'-hover.'+ext);});Event.observe(el,'mouseout',function(){var ext=this.src.split('.').reverse().first();this.src=this.src.replace('-hover.'+ext,'.'+ext);});});$$('.will_hover_bg').each(function(el,index){Event.observe(el,'mouseover',function(){var ext=this.getStyle('background-image').replace(/^url\(/,'').replace(/\)$/,'').split('.').reverse().first();this.setStyle({backgroundImage:this.getStyle('background-image').replace('.'+ext,'-hover.'+ext)});});Event.observe(el,'mouseout',function(){var ext=this.getStyle('background-image').replace(/^url\(/,'').replace(/\)$/,'').split('.').reverse().first();this.setStyle({backgroundImage:this.getStyle('background-image').replace('-hover.'+ext,'.'+ext)});});});});}else if(typeof jQuery!=='undefined'){$(document).ready(function(){$('.will_hover').bind({mouseover:function(){var ext=this.src.split('.').reverse();ext=ext[0];this.src=this.src.replace('.'+ext,'-hover.'+ext);},mouseout:function(){var ext=this.src.split('.').reverse();ext=ext[0];this.src=this.src.replace('-hover.'+ext,'.'+ext);}});$('.will_hover_bg').bind({mouseover:function(){var ext=$(this).css('background-image').replace(/^url\(/,'').replace(/\)$/,'').split('.').reverse();ext=ext[0];$(this).css({'background-image':$(this).css('background-image').replace('.'+ext,'-hover.'+ext)});},mouseout:function(){var ext=$(this).css('background-image').replace(/^url\(/,'').replace(/\)$/,'').split('.').reverse();ext=ext[0];$(this).css({'background-image':$(this).css('background-image').replace('-hover.'+ext,'.'+ext)});}});});}else{alert('will_hover.js requires Prototype or jQuery.');}