From 94270a6ab47692520b18fd136342f05c496deaeb Mon Sep 17 00:00:00 2001 From: Tommy Chen Date: Sun, 3 Jun 2012 10:35:21 +0800 Subject: rewrite caption.js & isolate fancybox --- source/_includes/after_footer.html | 2 +- source/_includes/fancybox.html | 6 ++++++ source/javascripts/caption.js | 15 --------------- source/javascripts/slash.js | 30 +++++++++++++++++------------- 4 files changed, 24 insertions(+), 29 deletions(-) create mode 100644 source/_includes/fancybox.html delete mode 100644 source/javascripts/caption.js diff --git a/source/_includes/after_footer.html b/source/_includes/after_footer.html index b7beed2..c49811f 100644 --- a/source/_includes/after_footer.html +++ b/source/_includes/after_footer.html @@ -1,4 +1,4 @@ - +{% include fancybox.html %} {% include disqus.html %} {% include custom/after_footer.html %} \ No newline at end of file diff --git a/source/_includes/fancybox.html b/source/_includes/fancybox.html new file mode 100644 index 0000000..fd5bcfd --- /dev/null +++ b/source/_includes/fancybox.html @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/source/javascripts/caption.js b/source/javascripts/caption.js deleted file mode 100644 index 8dc3856..0000000 --- a/source/javascripts/caption.js +++ /dev/null @@ -1,15 +0,0 @@ -(function($){ - $('.entry').each(function(i){ - var _i = i; - $(this).find('img').each(function(){ - var alt = $(this).attr('alt'); - - if (alt == '' || typeof alt == 'undefined'){ - $(this).wrap(''); - } else { - $(this).after(''+alt+'').wrap(''); - } - }); - }); - $('.fancybox').fancybox(); -})(jQuery); \ No newline at end of file diff --git a/source/javascripts/slash.js b/source/javascripts/slash.js index 0105d69..1e2649d 100644 --- a/source/javascripts/slash.js +++ b/source/javascripts/slash.js @@ -7,7 +7,7 @@ var href = this.href, link = href.replace(/https?:\/\/([^\/]+)(.*)/, '$1'); - if (link != host){ + if (link != '' && link != host && !$(this).hasClass('fancybox')){ window.open(href); e.preventDefault(); } @@ -49,19 +49,23 @@ }); }; - /* caption.js */ - $('.entry').each(function(i){ - var _i = i; - $(this).find('img').each(function(){ - var alt = $(this).attr('alt'); + // Append caption after pictures + var appendCaption = function(){ + $('.entry').each(function(i){ + var _i = i; + $(this).find('img').each(function(){ + var alt = this.alt; - if (alt == '' || typeof alt == 'undefined'){ - $(this).wrap(''); - } else { - $(this).after(''+alt+'').wrap(''); - } + if (alt != ''){ + $(this).after(''+alt+''); + } + + $(this).wrap(''); + }); }); - }); - $('.fancybox').fancybox(); + }; + 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 })(jQuery); \ No newline at end of file -- cgit v1.1-2-g2b99