Ham
{% comment %}
Add content to be output at the bottom of each page. (You might use this for analytics scripts, for example)
{% endcomment %}
<!-- Load jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery.noConflict(); // ender.js conflicts with jQuery
</script>
<!-- Load Fancybox -->
<script src="https://raw.github.com/fancyapps/fancyBox/master/source/jquery.fancybox.pack.js" type="text/javascript"></script>
<script src="{{ root_url }}/javascripts/fancybox-integration.js" type="text/javascript"></script>
| 1 | {% comment %} |
| 2 | Add content to be output at the bottom of each page. (You might use this for analytics scripts, for example) |
| 3 | {% endcomment %} |
| 4 | <!-- Load jQuery --> |
| 5 | <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> |
| 6 | <script type="text/javascript"> |
| 7 | jQuery.noConflict(); // ender.js conflicts with jQuery |
| 8 | </script> |
| 9 | <!-- Load Fancybox --> |
| 10 | <script src="https://raw.github.com/fancyapps/fancyBox/master/source/jquery.fancybox.pack.js" type="text/javascript"></script> |
| 11 | <script src="{{ root_url }}/javascripts/fancybox-integration.js" type="text/javascript"></script> |
fancybox-integration.js
· 1.3 KiB · JavaScript
Ham
// taken from https://raw.github.com/ervwalter/octopress-ewal/5dd64d3b52f183e18e1bb035ee288b09ac70c554/source/javascripts/slash.js
(function($){
// Open external links in new window
var externalLinks = function(){
var host = location.host;
$('body').on('click', 'a', function(e){
var href = this.href,
link = href.replace(/https?:\/\/([^\/]+)(.*)/, '$1');
if (link != '' && link != host && !$(this).hasClass('fancybox')){
window.open(href);
e.preventDefault();
}
});
};
// Append caption after pictures
var appendCaption = function(){
$('.entry-content').each(function(i){
var _i = i;
$(this).find('img').each(function(){
var alt = this.alt;
if (alt != ''){
$(this).after('<span class="caption">'+alt+'</span>');
}
$(this).wrap('<a href="'+this.src+'" title="'+alt+'" class="fancybox" rel="gallery'+_i+'" />');
});
});
};
$('.entry-content').each(function(i){
var _i = i;
$(this).find('img.fancybox').each(function(){
var img = $(this);
var title = img.attr("title");
var classes = img.attr("class");
img.removeAttr("class");
img.wrap('<a href="'+this.src+'" class="' + classes + '" rel="gallery'+_i+'" />');
if (title != "")
{
img.parent().attr("title", title);
}
});
});
$('.fancybox').fancybox();
})(jQuery);
| 1 | // taken from https://raw.github.com/ervwalter/octopress-ewal/5dd64d3b52f183e18e1bb035ee288b09ac70c554/source/javascripts/slash.js |
| 2 | |
| 3 | (function($){ |
| 4 | // Open external links in new window |
| 5 | var externalLinks = function(){ |
| 6 | var host = location.host; |
| 7 | |
| 8 | $('body').on('click', 'a', function(e){ |
| 9 | var href = this.href, |
| 10 | link = href.replace(/https?:\/\/([^\/]+)(.*)/, '$1'); |
| 11 | |
| 12 | if (link != '' && link != host && !$(this).hasClass('fancybox')){ |
| 13 | window.open(href); |
| 14 | e.preventDefault(); |
| 15 | } |
| 16 | }); |
| 17 | }; |
| 18 | |
| 19 | // Append caption after pictures |
| 20 | var appendCaption = function(){ |
| 21 | $('.entry-content').each(function(i){ |
| 22 | var _i = i; |
| 23 | $(this).find('img').each(function(){ |
| 24 | var alt = this.alt; |
| 25 | |
| 26 | if (alt != ''){ |
| 27 | $(this).after('<span class="caption">'+alt+'</span>'); |
| 28 | } |
| 29 | |
| 30 | $(this).wrap('<a href="'+this.src+'" title="'+alt+'" class="fancybox" rel="gallery'+_i+'" />'); |
| 31 | }); |
| 32 | }); |
| 33 | }; |
| 34 | |
| 35 | $('.entry-content').each(function(i){ |
| 36 | var _i = i; |
| 37 | $(this).find('img.fancybox').each(function(){ |
| 38 | var img = $(this); |
| 39 | var title = img.attr("title"); |
| 40 | var classes = img.attr("class"); |
| 41 | img.removeAttr("class"); |
| 42 | img.wrap('<a href="'+this.src+'" class="' + classes + '" rel="gallery'+_i+'" />'); |
| 43 | if (title != "") |
| 44 | { |
| 45 | img.parent().attr("title", title); |
| 46 | } |
| 47 | }); |
| 48 | }); |
| 49 | $('.fancybox').fancybox(); |
| 50 | })(jQuery); |
| 1 | <!-- fancybox stylesheet --> |
| 2 | <link href="https://raw.github.com/fancyapps/fancyBox/master/source/jquery.fancybox.css" media="screen, projection" rel="stylesheet" type="text/css"> |