prevent photho redirect next,prev if textarea has focus

This commit is contained in:
mishudark 2010-09-18 03:32:37 -05:00
parent 02c3cc0ee7
commit 910bd71c78
2 changed files with 19 additions and 2 deletions

View file

@ -7,14 +7,28 @@
$(document).keydown(function(e){
switch(e.keyCode) {
case 37:
window.location.replace( "#{url_to_prev(@photo,@album)}" );
if(flag){//prevent redirect if textarea has focus
window.location.replace( "#{url_to_prev(@photo,@album)}" );
}
break;
case 39:
window.location.replace( "#{url_to_next(@photo,@album)}" );
if(flag){
window.location.replace( "#{url_to_next(@photo,@album)}" );
}
break;
}
});
//asign a flag to determine if textarea has focus
$(document).ready(function(){
$("textarea").live('focus',function(){
flag = 0;
});
$("textarea").live('blur',function(){
flag = 1;
});
});
= content_for :page_title do
= link_to "◂ #{@photo.album.name}", @photo.album

View file

@ -610,3 +610,6 @@ h1.big_text {
#fancybox-close:hover {
background-color: transparent; }
#photo_caption{
margin:auto;}