-
Notifications
You must be signed in to change notification settings - Fork 148
/
videos.html.haml
53 lines (50 loc) · 1.5 KB
/
videos.html.haml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
layout: invasion
title: Videos
javascripts: [ /javascripts/siphon-20120407.js ]
---
%script#video_tmpl{:type=>'text/x-jsrender'}
.video
.preview
%a.thumbnail{:href => '{{:url}}', :target=>'_blank', :title=>'{{:title}}', :rel=>'popover',
:data=>{:raw=>'Duration: {{:~format_duration(duration)}}+ Number of plays: {{:stats_number_of_plays}}+ Tags: {{:tags}}'}}
%img{:src=>'{{:thumbnail_large}}'}
.desc
%h3 {{:title}}
%p {{:~truncate(description, 400)}}
{{if ~not_last()}}
%hr.taper
{{/if}}
%h2 Arquillian Videos on Vimeo
#videos
:javascript
$.views.helpers({
truncate: function(val, len) {
return val.length < len ? val : (val.substr(0, len) + '...');
},
not_last: function() {
var view = this;
return view.index !== view.parent.data.length - 1;
},
format_duration: function(seconds) {
duration = Math.floor(seconds / 60) + 'm'
remainder = seconds % 60
if (remainder > 0) {
duration += ' ' + remainder + 's'
}
return duration
}
});
$.ajax({
url: 'http://vimeo.com/api/v2/channel/arquillian/videos.json',
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback: 'display_videos'
});
function display_videos(data) {
$('#videos').html(
$('#video_tmpl').render(data)
);
// may decide to put this in the paragraph rather than a popover
$('#videos a[rel=popover]').popover({content: function() { return $(this).attr('data-raw').replace(/\+ /g, '<br/>')}});
}