Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Template.coverSheetEditor.helpers({
  2.     isVisible : function(){
  3.         // if session is not defined, coversheet is visible by default
  4.         if (Session.get("coverSheetVisible") === undefined || Session.get("coverSheetVisible") === true){
  5.             return true;
  6.         } else {
  7.             return false;
  8.         }
  9.     },
  10.  
  11.     coverSheetImage : function(){
  12.         if (!this.project.survey.coverSheet.image) {
  13.             return;
  14.         }
  15.  
  16.         var coverSheetImage = this.project.survey.coverSheet.image;
  17.         if (coverSheetImage){
  18.            return Images.findOne({ '_id': coverSheetImage });
  19.         }
  20.     },
  21.  
  22.     coverSheetLogo: function(){
  23.         if (!this.project.survey.coverSheet.logo) {
  24.             return;
  25.         }
  26.  
  27.         var coverSheetLogo = this.project.survey.coverSheet.logo;
  28.         if (coverSheetLogo){
  29.             return Images.findOne({ '_id': coverSheetLogo });
  30.         } else {
  31.             return false;
  32.         }
  33.     }
  34. });
  35.  
  36. Template.coverSheetEditor.onRendered(function(){
  37.     var instance = this;
  38.     instance.autorun(function(){
  39.         var imageUrl = Images.findOne(Template.currentData().project.survey.coverSheet.image).url({ store : "originals" });
  40.         //if som
  41.         instance.$(".coverSheetContainer").css({
  42.         "background" : "linear-gradient(to bottom, rgba(255,255,255,0.7) 0%,rgba(255,255,255,0.7) 100%), url(" + imageUrl + ") no-repeat",
  43.         "background-size" : "800px 232px"
  44.         });
  45.     });
  46. });
  47.  
  48. Template.coverSheetEditor.events({
  49.  
  50.  
  51.     'click .visibility' : function(event, template){
  52.  
  53.         var $me = template.$(event.target);
  54.  
  55.         if ($me.hasClass("hideCover")){
  56.            Session.set("coverSheetVisible", false);
  57.         } else {
  58.            Session.set("coverSheetVisible", true);
  59.         }
  60.     },
  61.  
  62.     'click .coverImage': function(event, template){
  63.         // redirect to our hidden file upload form
  64.         var fileUpload = template.$(".uploadCoverImage").click();
  65.     },
  66.  
  67.     'change .uploadCoverImage': function(event, template){
  68.  
  69.         var projectId = this.project._id;
  70.  
  71.  
  72.         ImageManager(Images).upload(event, {
  73.             "projectId" : projectId
  74.         }, function(err, updatedFile){
  75.             Dispatcher.call('uploadCoverSheetImage', projectId, updatedFile._id);
  76.  
  77.         });
  78.     },
  79.  
  80.     'click .logo': function(event, template){
  81.  
  82.         // redirect to our hidden file upload form
  83.         var fileUpload = template.$(".uploadLogo").click();
  84.     },
  85.  
  86.     'change .uploadLogo': function(event, template){
  87.  
  88.         var projectId = this.project._id;
  89.  
  90.         ImageManager(Images).upload(event, {
  91.             "projectId" : projectId
  92.         }, function(err, updatedFile){
  93.  
  94.             Dispatcher.call('uploadCoverSheetLogo', projectId, updatedFile._id);
  95.         });
  96.     },
  97.  
  98.     'blur .introductionText' : function(event, template){
  99.  
  100.         var projectId = template.data.project._id;
  101.         var newText = template.$('.introductionText').text();
  102.  
  103.         Dispatcher.call('updateIntroduction', projectId, newText);
  104.  
  105.  
  106.     },
  107.  
  108.     'blur .customText' : function(event, template){
  109.  
  110.         var projectId = template.data.project._id;
  111.         var newText = template.$('.customText').text();
  112.  
  113.         Dispatcher.call('updateCustomButton', projectId, newText);
  114.  
  115.     }
  116. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement