diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/_includes/header.html | 21 | ||||
-rw-r--r-- | source/javascripts/slash.js | 53 |
2 files changed, 35 insertions, 39 deletions
diff --git a/source/_includes/header.html b/source/_includes/header.html index fa076d1..64db260 100644 --- a/source/_includes/header.html +++ b/source/_includes/header.html @@ -1,6 +1,21 @@ <h1><a href="{{ root_url }}/">{{ site.title }}</a></h1> -<nav class="menu">{% include navigation.html %}</nav> -<div class="alignright"> +<nav id="main-nav">{% include navigation.html %}</nav> +<nav id="mobile-nav"> + <div class="alignleft menu"> + <a class="button">Menu</a> + <div class="container">{% include navigation.html %}</div> + </div> + <div class="alignright search"> + <a class="button"></a> + <div class="container"> + <form action="{{ site.simple_search }}" method="get"> + <input type="text" name="q" results="0"> + <input type="hidden" name="q" value="site:{{ site.url | shorthand_url }}"> + </form> + </div> + </div> +</nav> +<nav id="sub-nav" class="alignright"> <div class="social"> {% if site.facebook_user %} <a class="facebook" href="http://www.facebook.com/{{ site.facebook_user }}" title="Facebook">Facebook</a> @@ -28,5 +43,5 @@ <input class="alignright" type="text" name="q" results="0"> <input type="hidden" name="q" value="site:{{ site.url | shorthand_url }}"> </form> -</div> +</nav> {% include custom/header.html %} diff --git a/source/javascripts/slash.js b/source/javascripts/slash.js index 6433ba0..c33635a 100644 --- a/source/javascripts/slash.js +++ b/source/javascripts/slash.js @@ -14,41 +14,6 @@ }); }; - // Append menu for mobile device - var navigationMenu = function(){ - var appends = '<option>Menu</option>'; - - var search = function(obj, level){ - var children = obj.children(), - link = children.eq(0), - _level = level + 1; - - appends += '<option value="'+link.attr('href')+'">'; - - if (level > 0) appends += '|'; - - for (var i=0; i<level; i++){ - appends += '—'; - } - - appends += link.text()+'</option>'; - - if (children.length > 1){ - children.eq(1).children('li').each(function(){ - search($(this), _level); - }); - } - }; - - $('#header .menu .main').children('li').each(function(){ - search($(this), 0); - }); - - $('#header .menu').append('<select>'+appends+'</select>').on('change', 'select', function(){ - location.href = $(this).val(); - }); - }; - // Append caption after pictures var appendCaption = function(){ $('.entry-content').each(function(i){ @@ -66,6 +31,22 @@ }; externalLinks(); // Delete or comment this line to disable opening external links in new window - navigationMenu(); // Delete or comment this line to disable menu for mobile device appendCaption(); // Delete or comment this line to disable caption + + var mobilenav = $('#mobile-nav'); + mobilenav.on('click', '.menu .button', function(){ + if (!$(this).hasClass('on')){ + var width = $(this).width() + 42; + $(this).addClass('on').next().show().css({width: width}); + } else { + $(this).removeClass('on').next().hide(); + } + }).on('click', '.search .button', function(){ + if (!$(this).hasClass('on')){ + var width = mobilenav.width() - 51; + $(this).addClass('on').next().show().css({width: width}).children().children().eq(0).focus(); + } else { + $(this).removeClass('on').next().hide().children().children().eq(0).val(''); + } + }); })(jQuery);
\ No newline at end of file |