From b7bc4b86154d8ca5244f45d3bac412556b1cc5bc Mon Sep 17 00:00:00 2001 From: mishudark Date: Sat, 18 Sep 2010 04:14:44 -0500 Subject: [PATCH] prevent next prev when youre add writting --- app/views/photos/show.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 77ef6da1f..bbef1cbef 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -7,12 +7,12 @@ $(document).keydown(function(e){ switch(e.keyCode) { case 37: - if(flag){//prevent redirect if textarea has focus + if(!$("textarea").hasClass("hasfocus")){//prevent redirect if textarea has focus window.location.replace( "#{url_to_prev(@photo,@album)}" ); } break; case 39: - if(flag){ + if(!$("textarea").hasClass("hasfocus")){ window.location.replace( "#{url_to_next(@photo,@album)}" ); } break; @@ -22,10 +22,10 @@ //asign a flag to determine if textarea has focus $(document).ready(function(){ $("textarea").live('focus',function(){ - flag = 0; + $(this).addClass("hasfocus"); }); $("textarea").live('blur',function(){ - flag = 1; + $(this).removeClass("hasfocus"); }); });