diff --git a/app/assets/javascripts/app/views/canvas_view.js b/app/assets/javascripts/app/views/canvas_view.js index e3b1e0a6a..10a676289 100644 --- a/app/assets/javascripts/app/views/canvas_view.js +++ b/app/assets/javascripts/app/views/canvas_view.js @@ -63,7 +63,6 @@ app.views.Canvas = app.views.InfScroll.extend({ }, reLayout : function(){ - console.log("relaying out") this.$el.isotope("reLayout") } }); diff --git a/app/assets/javascripts/app/views/feedback_actions.js b/app/assets/javascripts/app/views/feedback_actions.js new file mode 100644 index 000000000..aaf638997 --- /dev/null +++ b/app/assets/javascripts/app/views/feedback_actions.js @@ -0,0 +1,4 @@ +//=require "./feedback_view" +app.views.FeedbackActions = app.views.Feedback.extend({ + templateName : "feedback-actions" +}) \ No newline at end of file diff --git a/app/assets/javascripts/app/views/feedback_view.js b/app/assets/javascripts/app/views/feedback_view.js index 57e3a8ac8..d7f84a653 100644 --- a/app/assets/javascripts/app/views/feedback_view.js +++ b/app/assets/javascripts/app/views/feedback_view.js @@ -4,12 +4,16 @@ app.views.Feedback = app.views.Base.extend({ className : "info", events: { - "click .like_action" : "toggleLike", - "click .reshare_action" : "resharePost" + "click *[rel='auth-required']" : "requireAuth", + "click .like" : "toggleLike", + "click .reshare" : "resharePost" }, + tooltipSelector : ".label", + initialize : function() { this.model.interactions.on('change', this.render, this); + this.initViews && this.initViews() // I don't know why this was failing with $.noop... :( }, presenter : function() { @@ -21,7 +25,7 @@ app.views.Feedback = app.views.Base.extend({ resharesCount : interactions.resharesCount(), userCanReshare : interactions.userCanReshare(), userLike : interactions.userLike(), - userReshare : interactions.userReshare(), + userReshare : interactions.userReshare() }) }, @@ -34,5 +38,11 @@ app.views.Feedback = app.views.Base.extend({ if(evt) { evt.preventDefault(); } if(!window.confirm(Diaspora.I18n.t("reshares.post", {name: this.model.reshareAuthor().name}))) { return } this.model.interactions.reshare(); + }, + + requireAuth : function(evt) { + if( app.currentUser.authenticated() ) { return } + alert("you must be logged in to do that!") + return false; } }); diff --git a/app/assets/javascripts/app/views/post-viewer/feedback.js b/app/assets/javascripts/app/views/post-viewer/feedback.js index de63cbbb1..18437bd4e 100644 --- a/app/assets/javascripts/app/views/post-viewer/feedback.js +++ b/app/assets/javascripts/app/views/post-viewer/feedback.js @@ -1,28 +1,24 @@ //= require ../feedback_view -app.views.PostViewerFeedback = app.views.Feedback.extend({ +app.views.PostViewerFeedback = app.views.Feedback.extend({ id : "user-controls", className : "", templateName: "post-viewer/feedback", - events : { - "click *[rel='auth-required']" : "requireAuth", - - "click .like" : "toggleLike", - "click .reshare" : "resharePost", + subviews : { + ".feedback-actions" : "feedbackActions" + }, + events :_.extend({}, app.views.Feedback.prototype.events, { "click *[rel='invoke-interaction-pane']" : "invokePane", "click *[rel='hide-interaction-pane']" : "hidePane" + }), + + initViews : function(){ + this.feedbackActions = new app.views.FeedbackActions({model : this.model}) }, - tooltipSelector : ".label, .home-button", - - initialize : function(){ - this.model.interactions.on("change", this.render, this) - }, - - postRenderTemplate : function() { this.sneakyVisiblity() }, @@ -35,10 +31,4 @@ app.views.PostViewerFeedback = app.views.Feedback.extend({ invokePane : function(evt){ this.trigger("invokePane") }, hidePane : function(evt){ this.trigger("hidePane") }, - - requireAuth : function(evt) { - if( app.currentUser.authenticated() ) { return } - alert("you must be logged in to do that!") - return false; - } -}); \ No newline at end of file +}); diff --git a/app/assets/javascripts/app/views/post-viewer/reactions.js b/app/assets/javascripts/app/views/post-viewer/reactions.js index 1447bde22..1ade12f74 100644 --- a/app/assets/javascripts/app/views/post-viewer/reactions.js +++ b/app/assets/javascripts/app/views/post-viewer/reactions.js @@ -41,4 +41,4 @@ app.views.PostViewerReactions = app.views.Base.extend({ className : "post-comment media" }).render().el); } -}); \ No newline at end of file +}); diff --git a/app/assets/javascripts/app/views/post/canvas_frame.js b/app/assets/javascripts/app/views/post/canvas_frame.js index e0ed1611c..2558f6ac1 100644 --- a/app/assets/javascripts/app/views/post/canvas_frame.js +++ b/app/assets/javascripts/app/views/post/canvas_frame.js @@ -31,15 +31,12 @@ app.views.Post.CanvasFrame = app.views.Post.SmallFrame.extend({ }, presenter : function(){ - console.log("here") - return _.extend(this.smallFramePresenter(), { adjustedImageHeight : this.adjustedImageHeight() }) }, favoritePost : function(evt) { - console.log("in favorite post") if(evt) { /* follow links instead of faving the targeted post */ if($(evt.target).is('a')) { return } diff --git a/app/assets/javascripts/app/views/post/small_frame.js b/app/assets/javascripts/app/views/post/small_frame.js index cef828864..741ed7ef9 100644 --- a/app/assets/javascripts/app/views/post/small_frame.js +++ b/app/assets/javascripts/app/views/post/small_frame.js @@ -29,11 +29,14 @@ app.views.Post.SmallFrame = app.views.Post.extend({ }, initialize : function() { - this.$el.addClass([this.dimensionsClass(), this.colorClass(), this.frameClass()].join(' ')) - return this; + this.addStylingClasses() }, postRenderTemplate : function() { + this.addStylingClasses() + }, + + addStylingClasses : function() { this.$el.addClass([this.dimensionsClass(), this.colorClass(), this.frameClass()].join(' ')) }, diff --git a/app/assets/javascripts/app/views/post/stream_frame.js b/app/assets/javascripts/app/views/post/stream_frame.js index 2f08d9df3..8d04e08fc 100644 --- a/app/assets/javascripts/app/views/post/stream_frame.js +++ b/app/assets/javascripts/app/views/post/stream_frame.js @@ -1,2 +1,24 @@ app.views.Post.StreamFrame = app.views.Post.SmallFrame.extend({ + events :_.extend({ + 'click .content' : 'fetchInteractions' + }, app.views.Post.SmallFrame.prototype.events), + + subviews :_.extend({ + '.interactions' : 'interactionsView' + }, app.views.Post.SmallFrame.prototype.subviews), + + initialize : function(){ + this.interactionsView = new app.views.StreamInteractions({model : this.model}) + }, + + postRenderTemplate : function(){ + this.addStylingClasses() + this.$el.append($("
")) + }, + + fetchInteractions : function() { + this.model.interactions.fetch().done(_.bind(function(){ + this.interactionsView.render() + }, this)); + } }) \ No newline at end of file diff --git a/app/assets/javascripts/app/views/post/stream_interactions_view.js b/app/assets/javascripts/app/views/post/stream_interactions_view.js new file mode 100644 index 000000000..5a6282aa8 --- /dev/null +++ b/app/assets/javascripts/app/views/post/stream_interactions_view.js @@ -0,0 +1,13 @@ +app.views.StreamInteractions = app.views.Base.extend({ + subviews : { + ".feedback" : "feedback", + ".comments" : "comments" + }, + + templateName : "stream-interactions", + + initialize : function(){ + this.feedback = new app.views.FeedbackActions({ model : this.model }) + this.comments = new app.views.PostViewerFeedback({ model : this.model }) + } +}) \ No newline at end of file diff --git a/app/assets/templates/feedback-actions.jst.hbs b/app/assets/templates/feedback-actions.jst.hbs new file mode 100644 index 000000000..15bd88e8c --- /dev/null +++ b/app/assets/templates/feedback-actions.jst.hbs @@ -0,0 +1,33 @@ + + {{#if userLike}} + + {{else}} + + {{/if}} + {{likesCount}} + + +{{#if userCanReshare}} + + {{#if userReshare}} + + {{else}} + + {{/if}} + {{resharesCount}} + +{{else}} + + {{#if userReshare}} + + {{else}} + + {{/if}} + {{resharesCount}} + +{{/if}} + + + + {{commentsCount}} + diff --git a/app/assets/templates/feedback.jst.hbs b/app/assets/templates/feedback.jst.hbs index bdf99a2af..daeb7a69c 100644 --- a/app/assets/templates/feedback.jst.hbs +++ b/app/assets/templates/feedback.jst.hbs @@ -14,7 +14,7 @@ - + {{#if userLike}} {{t "stream.unlike"}} {{else}} @@ -24,7 +24,7 @@ · {{#if userCanReshare}} - + {{t "stream.reshare"}} · diff --git a/app/assets/templates/post-viewer/feedback.jst.hbs b/app/assets/templates/post-viewer/feedback.jst.hbs index 823db8cf9..1eacdf1dc 100644 --- a/app/assets/templates/post-viewer/feedback.jst.hbs +++ b/app/assets/templates/post-viewer/feedback.jst.hbs @@ -1,36 +1,4 @@ - - {{#if userLike}} - - {{else}} - - {{/if}} - {{likesCount}} - - -{{#if userCanReshare}} - - {{#if userReshare}} - - {{else}} - - {{/if}} - {{resharesCount}} - -{{else}} - - {{#if userReshare}} - - {{else}} - - {{/if}} - {{resharesCount}} - -{{/if}} - - - - {{commentsCount}} - +
diff --git a/app/assets/templates/stream-interactions.jst.hbs b/app/assets/templates/stream-interactions.jst.hbs new file mode 100644 index 000000000..56aa2f895 --- /dev/null +++ b/app/assets/templates/stream-interactions.jst.hbs @@ -0,0 +1,3 @@ +