From a52ab83757da6af4be529a0ae2dfae32d689f37f Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Tue, 17 Mar 2015 17:57:50 -0700 Subject: [PATCH] half way done with the new upvoting ux --- public/js/main.js | 11 +++++--- views/stories/show.jade | 60 ++++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index 8c9191db93..661d14b934 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -113,6 +113,7 @@ $(document).ready(function() { window.location = '/challenges/' + (parseInt(l[l.length - 1]) + 1); }); + // Bonfire instructions functions $('#more-info').on('click', function() { ga('send', 'event', 'Challenge', 'more-info', challengeName); @@ -125,8 +126,13 @@ $(document).ready(function() { $('#long-instructions').hide(); }); - var upvoteHandler = function () { - $(".ion-arrow-up-b").hide(); + $('#upvote').on('click', upvoteHandler); + + var upvoteHandler = function (event) { + event.preventDefault(); + var $this = $(this); + $this.addClass('disabled'); + $this.text('Upvoted!'); var _id = storyId; $('#upvote').unbind('click'); var alreadyUpvoted = false; @@ -152,7 +158,6 @@ $(document).ready(function() { }); } }; - $('#upvote').on('click', upvoteHandler); var storySubmitButtonHandler = function storySubmitButtonHandler() { diff --git a/views/stories/show.jade b/views/stories/show.jade index a05ec900dc..30c3ab9b75 100644 --- a/views/stories/show.jade +++ b/views/stories/show.jade @@ -10,39 +10,37 @@ .spacer h3.row - .row.text-left.negative-10 - .col-xs-3.col-sm-1.text-center - .row.negative-5 - .col-xs-12.big-ion-up-arrow + .col-xs-2.col-sm-1 + a(href="/" + author.username) + img(src="#{author.picture}", class='img-news') + .col-xs-10.col-sm-10 + .col-xs-12.negative-28 + a(href="#{link}", target="_blank") + h3= title + h6 + .col-xs-12.positive-15.hidden-element#image-display + .media + .media-left + img.url-preview.media-object(src="#{image}", alt="#{storyMetaDescription}") + .media-body + .col-xs-12.col-sm-12.col-md-6 + h4= storyMetaDescription + .col-xs-12 + h4= description + .negative-5 + a#reply-to-main-post.btn.btn-no-shadow.btn-primary.btn-xs.btn-primary-ghost Reply + |  ·  if !hasUserVoted - a#upvote - i.ion-arrow-up-b - h3.story-up-votes - span#storyRank= rank - .col-xs-2.col-sm-1 - a(href="/" + author.username) - img(src="#{author.picture}", class='img-news') - .col-xs-7.col-sm-10 - - .col-xs-12.negative-28 - a(href="#{link}", target="_blank") - h3= title - h6 - .col-xs-12.positive-15.hidden-element#image-display - .media - .media-left - img.url-preview.media-object(src="#{image}", alt="#{storyMetaDescription}") - .media-body - .col-xs-12.col-sm-12.col-md-6 - h4= storyMetaDescription - .col-xs-12 - h4= description - .negative-5 - a#reply-to-main-post.btn.btn-no-shadow.btn-primary.btn-xs.btn-primary-ghost Reply + a#upvote.btn.btn-no-shadow.btn-primary.btn-xs.btn-primary-ghost |  ·  - span Posted #{timeAgo} - span  by  - a(href="/" + author.username) @#{author.username} + else + a#upvote.btn.disabled.btn-no-shadow.btn-primary.btn-xs.btn-primary-ghost Upvoted! + |  ·  + span#storyRank= rank + (rank > 1 ? " points" : " point") + |  ·  + span Posted #{timeAgo} + span  by  + a(href="/" + author.username) @#{author.username} if (user !== null) .col-xs-12#reply-area