Skip to content

Commit 0278057

Browse files
committed
Add js
1 parent a299d55 commit 0278057

8 files changed

+120
-0
lines changed

assets/js/index.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Main JS file for Casper behaviours
3+
*/
4+
5+
/*globals jQuery, document */
6+
(function ($) {
7+
"use strict";
8+
9+
$(document).ready(function(){
10+
11+
$(".post-content").fitVids();
12+
13+
// Calculates Reading Time
14+
$('.post-content').readingTime({
15+
readingTimeTarget: '.post-reading-time',
16+
wordCountTarget: '.post-word-count',
17+
});
18+
19+
// Creates Captions from Alt tags
20+
$(".post-content img").each(function() {
21+
// Let's put a caption if there is one
22+
if($(this).attr("alt") && !$(this).hasClass("emoji"))
23+
$(this).wrap('<figure class="image"></figure>')
24+
.after('<figcaption>'+$(this).attr("alt")+'</figcaption>');
25+
});
26+
27+
});
28+
29+
}(jQuery));

assets/js/jquery.fitvids.js

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*global jQuery */
2+
/*jshint multistr:true browser:true */
3+
/*!
4+
* FitVids 1.0.3
5+
*
6+
* Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
7+
* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
8+
* Released under the WTFPL license - http://sam.zoy.org/wtfpl/
9+
*
10+
* Date: Thu Sept 01 18:00:00 2011 -0500
11+
*/
12+
13+
(function( $ ){
14+
15+
"use strict";
16+
17+
$.fn.fitVids = function( options ) {
18+
var settings = {
19+
customSelector: null
20+
};
21+
22+
if(!document.getElementById('fit-vids-style')) {
23+
24+
var div = document.createElement('div'),
25+
ref = document.getElementsByTagName('base')[0] || document.getElementsByTagName('script')[0],
26+
cssStyles = '&shy;<style>.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}</style>';
27+
28+
div.className = 'fit-vids-style';
29+
div.id = 'fit-vids-style';
30+
div.style.display = 'none';
31+
div.innerHTML = cssStyles;
32+
33+
ref.parentNode.insertBefore(div,ref);
34+
35+
}
36+
37+
if ( options ) {
38+
$.extend( settings, options );
39+
}
40+
41+
return this.each(function(){
42+
var selectors = [
43+
"iframe[src*='player.vimeo.com']",
44+
"iframe[src*='youtube.com']",
45+
"iframe[src*='youtube-nocookie.com']",
46+
"iframe[src*='kickstarter.com'][src*='video.html']",
47+
"object",
48+
"embed"
49+
];
50+
51+
if (settings.customSelector) {
52+
selectors.push(settings.customSelector);
53+
}
54+
55+
var $allVideos = $(this).find(selectors.join(','));
56+
$allVideos = $allVideos.not("object object"); // SwfObj conflict patch
57+
58+
$allVideos.each(function(){
59+
var $this = $(this);
60+
if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
61+
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
62+
width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
63+
aspectRatio = height / width;
64+
if(!$this.attr('id')){
65+
var videoID = 'fitvid' + Math.floor(Math.random()*999999);
66+
$this.attr('id', videoID);
67+
}
68+
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");
69+
$this.removeAttr('height').removeAttr('width');
70+
});
71+
});
72+
};
73+
// Works with either jQuery or Zepto
74+
})( window.jQuery || window.Zepto );

assets/js/min/highlight.pack-ck.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/min/index-ck.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/min/jquery.fitvids-ck.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)