From 5f61b1be1dcd39b07db3393ad0b523732108ca19 Mon Sep 17 00:00:00 2001 From: birdwing Date: Mon, 27 Jan 2014 18:53:28 -0500 Subject: [PATCH] Add an 'X' button for clearing text in the search field. --- assets/css/modules/header.css | 21 +++++++++++++++++++++ assets/js/modules/init.js | 7 +++++++ index.html | 17 +++++++++-------- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/assets/css/modules/header.css b/assets/css/modules/header.css index 2e6ee7c..48bdc73 100644 --- a/assets/css/modules/header.css +++ b/assets/css/modules/header.css @@ -122,10 +122,31 @@ header { -moz-transition: opacity .3s ease-out, -moz-transform .3s ease-out, box-shadow .3s, width .2s ease-out; transition: opacity .3s ease-out, transform .3s ease-out, box-shadow .3s, width .2s ease-out; } + header #clearSearch { + position: absolute; + font-size: 24px; + right: 61px; + padding-top: 0px; + padding-bottom: 0; + top: 13px; + display: none; + } header #search:focus { width: 140px; } + #search:focus ~ #clearSearch { + display: block; + } + + #clearSearch:hover + #search { + width: 140px; + } + + #clearSearch:hover { + display: block; + } + /* Tools ------------------------------------------------*/ header .tools:first-of-type { margin-right: 6px; diff --git a/assets/js/modules/init.js b/assets/js/modules/init.js index 046f24c..bb98d20 100755 --- a/assets/js/modules/init.js +++ b/assets/js/modules/init.js @@ -100,6 +100,13 @@ $(document).ready(function(){ if (visible.photo()) photo.setTitle(photo.getID()); else album.setTitle(album.getID()); }) + + /* Clear Search */ + .on(event_name, "#clearSearch", function (e) { + e.preventDefault(); + $("#search").val(""); + $("#search").focus(); + }) /* Navigation */ .on("click", ".album", function() { lychee.goto($(this).attr("data-id")) }) diff --git a/index.html b/index.html index 89c2240..ea88389 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ - @@ -25,10 +25,10 @@ - --> + - - + @@ -55,6 +55,7 @@ + ×
@@ -98,7 +99,7 @@ - @@ -113,10 +114,10 @@ - --> + - - + \ No newline at end of file