summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTommy Chen <tommy351@gmail.com>2012-06-06 10:50:53 +0200
committerTommy Chen <tommy351@gmail.com>2012-06-06 10:50:53 +0200
commit7cb82d68ebf6aaad388343fcf337a944c1e1ccfd (patch)
tree10c0d7c0f86b5b7d23534d4ec461450617438389
parent1d39e87d87ae442efd2e205f508a28a240bfb06a (diff)
downloadoctopress-theme-jeyzu-7cb82d68ebf6aaad388343fcf337a944c1e1ccfd.zip
octopress-theme-jeyzu-7cb82d68ebf6aaad388343fcf337a944c1e1ccfd.tar.gz
hide navigation when click outside
-rw-r--r--sass/parts/_header.scss3
-rw-r--r--source/javascripts/slash.js10
2 files changed, 13 insertions, 0 deletions
diff --git a/sass/parts/_header.scss b/sass/parts/_header.scss
index 9548dfe..49c06a4 100644
--- a/sass/parts/_header.scss
+++ b/sass/parts/_header.scss
@@ -155,6 +155,9 @@ $header-height: 30px;
a{
display: block;
}
+ .button{
+ cursor: pointer;
+ }
.container{
display: none;
}
diff --git a/source/javascripts/slash.js b/source/javascripts/slash.js
index c33635a..5288572 100644
--- a/source/javascripts/slash.js
+++ b/source/javascripts/slash.js
@@ -34,6 +34,13 @@
appendCaption(); // Delete or comment this line to disable caption
var mobilenav = $('#mobile-nav');
+
+ $('html').click(function(){
+ mobilenav.find('.on').each(function(){
+ $(this).removeClass('on').next().hide();
+ });
+ });
+
mobilenav.on('click', '.menu .button', function(){
if (!$(this).hasClass('on')){
var width = $(this).width() + 42;
@@ -44,9 +51,12 @@
}).on('click', '.search .button', function(){
if (!$(this).hasClass('on')){
var width = mobilenav.width() - 51;
+ mobilenav.children('.menu').children().eq(0).removeClass('on').next().hide();
$(this).addClass('on').next().show().css({width: width}).children().children().eq(0).focus();
} else {
$(this).removeClass('on').next().hide().children().children().eq(0).val('');
}
+ }).click(function(e){
+ e.stopPropagation();
});
})(jQuery); \ No newline at end of file