From 910bd71c78fc31b42ea909c0bef0e7c1bf190899 Mon Sep 17 00:00:00 2001 From: mishudark Date: Sat, 18 Sep 2010 03:32:37 -0500 Subject: [PATCH] prevent photho redirect next,prev if textarea has focus --- app/views/photos/show.html.haml | 18 ++++++++++++++++-- public/stylesheets/application.css | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 654bea892..77ef6da1f 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -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 diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 83b6bfc80..ed7dae38e 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -610,3 +610,6 @@ h1.big_text { #fancybox-close:hover { background-color: transparent; } +#photo_caption{ + margin:auto;} +