diff options
Diffstat (limited to '.themes/classic/source/javascripts')
-rw-r--r-- | .themes/classic/source/javascripts/octopress.js | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/.themes/classic/source/javascripts/octopress.js b/.themes/classic/source/javascripts/octopress.js index c3f59156..218a0a1a 100644 --- a/.themes/classic/source/javascripts/octopress.js +++ b/.themes/classic/source/javascripts/octopress.js @@ -1,17 +1,15 @@ function getNav() { - var mobileNav = $('nav[role=navigation] fieldset[role=search]').after('<fieldset class="mobile-nav"></fieldset>').next().append('<select></select>'); - mobileNav.children('select').append('<option value="">Navigate…</option>'); - $('ul[role=main-navigation]').addClass('main-navigation'); - $('ul.main-navigation a').each(function(i, link) { - mobileNav.children('select').append('<option value="'+link.href+'">» '+link.text+'</option>'); - }); - $('ul.subscription a').each(function(i, link) { - mobileNav.children('select').append('<option value="'+link.href+'">» '+link.text+'</option>'); - }); - mobileNav.children('select').bind('change', function(event) { + var mainNav = $('ul.main-navigation, ul[role=main-navigation]').before('<fieldset class="mobile-nav">') + var mobileNav = $('fieldset.mobile-nav').append('<select>'); + mobileNav.find('select').append('<option value="">Navigate…</option>'); + var addOption = function(i, option) { + mobileNav.find('select').append('<option value="' + this.href + '">» ' + $(this).text() + '</option>'); + } + mainNav.find('a').each(addOption); + $('ul.subscription a').each(addOption); + mobileNav.find('select').bind('change', function(event) { if (event.target.value) { window.location.href = event.target.value; } }); - mobileNav.children('select').val(''); } function addSidebarToggler() { @@ -74,10 +72,10 @@ function addCodeLineNumbers() { function flashVideoFallback(){ var flashplayerlocation = "/assets/jwplayer/player.swf", flashplayerskin = "/assets/jwplayer/glow/glow.xml"; - $('video').each(function(video){ + $('video').each(function(i, video){ video = $(video); if (!Modernizr.video.h264 && swfobject.getFlashPlayerVersion() || window.location.hash.indexOf("flash-test") !== -1){ - video.children('source[src$=mp4]').first().map(function(i, source){ + video.children('source[src$=mp4]').first().map(i, function(source){ var src = $(source).attr('src'), id = 'video_'+Math.round(1 + Math.random()*(100000)), width = video.attr('width'), @@ -94,18 +92,12 @@ function flashVideoFallback(){ } function wrapFlashVideos() { - $('object').each(function(object) { - object = $(object); - if ( $('param[name=movie]', object).length ) { - var wrapper = object.before('<div class="flash-video"><div>').previous(); - $(wrapper).children().append(object); + $('object').each(function(i, object) { + if( $(object).find('param[name=movie]').length ){ + $(object).wrap('<div class="flash-video">') } }); - $('iframe[src*=vimeo],iframe[src*=youtube]').each(function(iframe) { - iframe = $(iframe); - var wrapper = iframe.before('<div class="flash-video"><div>').previous(); - $(wrapper).children().append(iframe); - }); + $('iframe[src*=vimeo],iframe[src*=youtube]').wrap('<div class="flash-video">') } function renderDeliciousLinks(items) { |