|
@@ -251,6 +251,21 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /* ---------------------------------------------------------------------------
|
|
|
+ * Toggle search dialog.
|
|
|
+ * --------------------------------------------------------------------------- */
|
|
|
+
|
|
|
+ function toggleSearchDialog() {
|
|
|
+ if ($('body').hasClass('searching')) {
|
|
|
+ $('[id=search-query]').blur();
|
|
|
+ $('body').removeClass('searching');
|
|
|
+ } else {
|
|
|
+ $('body').addClass('searching');
|
|
|
+ $('.search-results').css({opacity: 0, visibility: 'visible'}).animate({opacity: 1}, 200);
|
|
|
+ $('#search-query').focus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/* ---------------------------------------------------------------------------
|
|
|
* On window load.
|
|
|
* --------------------------------------------------------------------------- */
|
|
@@ -370,14 +385,19 @@
|
|
|
// On search icon click toggle search dialog.
|
|
|
$('.js-search').click(function(e) {
|
|
|
e.preventDefault();
|
|
|
- if ($('body').hasClass('searching')) {
|
|
|
- $('body').removeClass('searching');
|
|
|
- } else {
|
|
|
- $('body').addClass('searching');
|
|
|
- $('.search-results').css({opacity: 0, visibility: 'visible'}).animate({opacity: 1}, 200);
|
|
|
- $('#search-query').focus();
|
|
|
+ toggleSearchDialog();
|
|
|
+ });
|
|
|
+ $(document).on('keydown', function(e){
|
|
|
+ if (e.which == 27) {
|
|
|
+ if ($('body').hasClass('searching')) {
|
|
|
+ toggleSearchDialog();
|
|
|
+ }
|
|
|
+ } else if (e.which == 191) {
|
|
|
+ e.preventDefault();
|
|
|
+ toggleSearchDialog();
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
});
|
|
|
|
|
|
})(jQuery);
|