From e67a520a24bc642ee2c0b2f4ed2a6198570c5b76 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 11 Jun 2014 19:18:59 -0400 Subject: [PATCH] added EsC key to cancel search --- app/assets/javascripts/jquery/EveryPage.js | 16 +++++++++++----- config/routes.rb | 9 +++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/jquery/EveryPage.js b/app/assets/javascripts/jquery/EveryPage.js index 2898883d..1f849653 100644 --- a/app/assets/javascripts/jquery/EveryPage.js +++ b/app/assets/javascripts/jquery/EveryPage.js @@ -89,9 +89,9 @@ $(document).ready(function () { }); } } - var closeSearch = function (closeAfter) { + var closeSearch = function (closeAfter, bypass) { lT = setTimeout(function () { - if (!sliding1 && searchIsOpen && $('.sidebarSearchField').val() == '') { + if (!sliding1 && searchIsOpen && (bypass || $('.sidebarSearchField').val() == '')) { sliding1 = true; $('.sidebarSearchField, .sidebarSearch .tt-hint').css({ padding: '5px 0', @@ -112,7 +112,7 @@ $(document).ready(function () { $(".sidebarSearch").hover(function () { openSearch() }, function () { - closeSearch(800) + closeSearch(800, false) }); $('.sidebarSearchIcon').click(function (e) { @@ -122,10 +122,11 @@ $(document).ready(function () { e.stopPropagation(); }); $('body').click(function (e) { - closeSearch(0); + closeSearch(0, false); }); - // if the search is closed and user hits SHIFT+S + // if the search is closed and user hits ctrl+/ + // close if they hit ESC $('body').bind('keydown', function (e) { switch (e.which) { case 191: @@ -133,6 +134,11 @@ $(document).ready(function () { openSearch(); } break; + case 27: + if (searchIsOpen) { + closeSearch(0, true); + } + break; default: break; //console.log(e.which); } diff --git a/config/routes.rb b/config/routes.rb index 75471303..803dea6d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,10 +1,8 @@ ISSAD::Application.routes.draw do - resources :in_metacode_sets - resources :metacode_sets, :except => [:show] - resources :metacodes, :except => [:show, :destroy] - root to: 'main#home', via: :get + + get '/join', to: redirect('/users/sign_up') match 'request', to: 'main#requestinvite', via: :get, as: :request match 'paq', to: 'main#paq', via: :get, as: :paq @@ -18,6 +16,9 @@ ISSAD::Application.routes.draw do match 'topics/:map_id/:topic_id/removefrommap', to: 'topics#removefrommap', via: :post, as: :removefrommap match 'synapses/:map_id/:synapse_id/removefrommap', to: 'synapses#removefrommap', via: :post, as: :removefrommap + resources :in_metacode_sets + resources :metacode_sets, :except => [:show] + resources :metacodes, :except => [:show, :destroy] resources :topics, except: [:index, :new, :edit] do get :autocomplete_topic, :on => :collection end