2015-07-07 10:55:09 +09:00
|
|
|
Template.post_thumbnail.onCreated(function () {
|
|
|
|
var instance = this;
|
|
|
|
instance.showVideo = new ReactiveVar(false);
|
|
|
|
});
|
|
|
|
|
2015-05-18 10:12:48 +09:00
|
|
|
Template.post_thumbnail.helpers({
|
2015-04-22 07:50:11 +09:00
|
|
|
playVideoClass: function () {
|
2015-08-13 09:35:37 +09:00
|
|
|
var url = this.url;
|
|
|
|
var isVideoSite = url && _.some(["youtube", "vimeo"], function (site) {
|
|
|
|
return url.indexOf(site) !== -1;
|
|
|
|
});
|
|
|
|
return (this.media && this.media.type === "video" && isVideoSite) ? 'post-thumbnail-has-video': '';
|
2015-07-07 10:55:09 +09:00
|
|
|
},
|
|
|
|
showVideo: function () {
|
|
|
|
return Template.instance().showVideo.get();
|
2015-04-22 07:50:11 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-05-18 10:12:48 +09:00
|
|
|
Template.post_thumbnail.events({
|
2015-07-07 10:55:09 +09:00
|
|
|
'click .post-thumbnail-has-video': function (e, instance) {
|
|
|
|
|
2015-04-22 07:50:11 +09:00
|
|
|
e.preventDefault();
|
2015-07-07 10:55:09 +09:00
|
|
|
instance.showVideo.set(true);
|
|
|
|
|
|
|
|
// use Meteor.defer to make sure the elements are rendered by Blaze
|
|
|
|
Meteor.defer(function () {
|
|
|
|
$('body').addClass('showing-lightbox');
|
|
|
|
$(e.target).parents('.post').find('.post-video-lightbox').fadeIn('fast');
|
2015-07-20 09:15:12 +09:00
|
|
|
$(".js-video").fitVids();
|
2015-07-07 10:55:09 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
'click .post-video-lightbox-hide, click .post-video-lightbox': function (e, instance) {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
$(e.target).parents('.post').find('.post-video-lightbox').fadeOut('fast');
|
|
|
|
$('body').removeClass('showing-lightbox');
|
|
|
|
|
|
|
|
Meteor.defer(function () {
|
|
|
|
instance.showVideo.set(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
2015-04-22 07:50:11 +09:00
|
|
|
});
|