diff options
author | SkyArrow <tommy351@gmail.com> | 2012-01-27 17:07:28 +0100 |
---|---|---|
committer | SkyArrow <tommy351@gmail.com> | 2012-01-27 17:07:28 +0100 |
commit | 0da5633be66d1b3686bb5d02abf787b002cbe6ed (patch) | |
tree | 2c0e76e599bfd00f2d37d79e41d478fc5950d683 /source/javascripts | |
parent | f49d174f61bcfcaba2affb0ee671ff74315c8174 (diff) | |
download | octopress-theme-jeyzu-0da5633be66d1b3686bb5d02abf787b002cbe6ed.zip octopress-theme-jeyzu-0da5633be66d1b3686bb5d02abf787b002cbe6ed.tar.gz |
merge javascript
Diffstat (limited to 'source/javascripts')
-rw-r--r-- | source/javascripts/slash.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/source/javascripts/slash.js b/source/javascripts/slash.js new file mode 100644 index 0000000..c23a4a2 --- /dev/null +++ b/source/javascripts/slash.js @@ -0,0 +1,45 @@ +(function($){ + /* external.js */ + var host = location.host; + + $('a').on('click', function(e){ + var href = $(this).attr('href'), + link = href.replace(/(https?:\/\/)(.*)\/(.*)/, '$2'); + + if (href.match('https?') && link != host){ + window.open(href); + e.preventDefault(); + } + }); + + /* navigation.js */ + var appends = '<option>Menu</option>'; + + $('.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>'; + }); + }); + + $('nav.menu').append('<select>'+appends+'</select>').on('change', 'select', function(){ + location.href = $(this).val(); + }); + + /* caption.js */ + $('.entry').each(function(i){ + var _i = i; + $(this).find('img').each(function(){ + var alt = $(this).attr('alt'); + + if (alt == '' || typeof alt == 'undefined'){ + $(this).wrap('<a href="'+$(this).attr('src')+'" class="fancybox" rel="gallery'+_i+'" />'); + } else { + $(this).after('<span class="caption">'+alt+'</span>').wrap('<a href="'+$(this).attr('src')+'" class="fancybox" title="'+alt+'" rel="gallery'+_i+'" />'); + } + }); + }); + $('.fancybox').fancybox(); +})(jQuery);
\ No newline at end of file |