summaryrefslogtreecommitdiffstats
path: root/source/javascripts/slash.js
diff options
context:
space:
mode:
authorTommy Chen <tommy351@gmail.com>2012-06-03 04:20:50 +0200
committerTommy Chen <tommy351@gmail.com>2012-06-03 04:20:50 +0200
commite3cc2b2ff5d96ed69c982c100692a1745bc261ef (patch)
tree364196089ecf8031a73a00ba5cb4ce3652dbc72f /source/javascripts/slash.js
parent5ba7052e5f584b5859ae3d9b00b1847391989ca1 (diff)
downloadoctopress-theme-jeyzu-e3cc2b2ff5d96ed69c982c100692a1745bc261ef.zip
octopress-theme-jeyzu-e3cc2b2ff5d96ed69c982c100692a1745bc261ef.tar.gz
rewrite navigation.js
Diffstat (limited to 'source/javascripts/slash.js')
-rw-r--r--source/javascripts/slash.js42
1 files changed, 30 insertions, 12 deletions
diff --git a/source/javascripts/slash.js b/source/javascripts/slash.js
index 270f39c..0105d69 100644
--- a/source/javascripts/slash.js
+++ b/source/javascripts/slash.js
@@ -14,22 +14,40 @@
});
};
+ // Append menu for mobile device
+ var navigationMenu = function(){
+ var appends = '<option>Menu</option>';
- /* navigation.js */
- var appends = '<option>Menu</option>';
+ var search = function(obj, level){
+ var children = obj.children(),
+ link = children.eq(0),
+ _level = level + 1;
- $('.menu .main > li').each(function(){
- var link = $(this).children('a');
- appends += '<option value="'+link.attr('href')+'">'+link.html()+'</option>';
- $(this).find('li').each(function(){
- var link = $(this).children('a');
- appends += '<option value="'+link.attr('href')+'">- '+link.html()+'</option>';
+ 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);
});
- });
- $('nav.menu').append('<select>'+appends+'</select>').on('change', 'select', function(){
- location.href = $(this).val();
- });
+ $('#header .menu').append('<select>'+appends+'</select>').on('change', 'select', function(){
+ location.href = $(this).val();
+ });
+ };
/* caption.js */
$('.entry').each(function(i){