Vulcan/packages/telescope-embedly/lib/client/post_thumbnail.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

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({
postLink: function () {
2015-06-18 13:04:38 +09:00
return Posts.getLink(this);
},
target: function () {
return !!this.url? "_blank" : "";
},
playVideoClass: function () {
return !!this.media ? 'post-thumbnail-has-video': '';
},
showVideo: function () {
return Template.instance().showVideo.get();
}
});
2015-05-18 10:12:48 +09:00
Template.post_thumbnail.events({
'click .post-thumbnail-has-video': function (e, instance) {
e.preventDefault();
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');
});
},
'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);
});
}
});