diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/_includes/after_footer.html | 4 | ||||
-rw-r--r-- | source/javascripts/slash.js | 45 |
2 files changed, 46 insertions, 3 deletions
diff --git a/source/_includes/after_footer.html b/source/_includes/after_footer.html index f4edb38..35f440f 100644 --- a/source/_includes/after_footer.html +++ b/source/_includes/after_footer.html @@ -1,7 +1,5 @@ <script src="{{ root_url }}/javascripts/jquery.easing.1.3.js"></script> -<script src="{{ root_url }}/javascripts/external.js"></script> -<script src="{{ root_url }}/javascripts/navigation.js"></script> <script src="{{ root_url }}/javascripts/jquery.fancybox.pack.js"></script> -<script src="{{ root_url }}/javascripts/caption.js"></script> +<script src="{{ root_url }}/javascripts/slash.js"></script> {% include disqus.html %} {% include custom/after_footer.html %}
\ No newline at end of file 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 |