Commit 8475ffef by Arjun Singh

merge

parents ebae40a3 10887ab1
...@@ -16,7 +16,6 @@ if Backbone? ...@@ -16,7 +16,6 @@ if Backbone?
urlMappers: {} urlMappers: {}
urlFor: (name) -> urlFor: (name) ->
console.log @
@urlMappers[name].apply(@) @urlMappers[name].apply(@)
can: (action) -> can: (action) ->
...@@ -247,7 +246,6 @@ if Backbone? ...@@ -247,7 +246,6 @@ if Backbone?
@model.set('votes_point', response.votes.point) @model.set('votes_point', response.votes.point)
toggleVote: (event) -> toggleVote: (event) ->
console.log("HERE")
$elem = $(event.target) $elem = $(event.target)
value = $elem.attr("value") value = $elem.attr("value")
$elem.toggleClass("is-cast") $elem.toggleClass("is-cast")
...@@ -449,6 +447,14 @@ if Backbone? ...@@ -449,6 +447,14 @@ if Backbone?
@set('subscribed', false) @set('subscribed', false)
@trigger "thread:unfollow" @trigger "thread:unfollow"
vote: ->
@get("votes")["up_count"] = parseInt(@get("votes")["up_count"]) + 1
@trigger "change"
unvote: ->
@get("votes")["up_count"] = parseInt(@get("votes")["up_count"]) - 1
@trigger "change"
display_body: -> display_body: ->
if @has("highlighted_body") if @has("highlighted_body")
String(@get("highlighted_body")).replace(/<highlight>/g, '<mark>').replace(/<\/highlight>/g, '</mark>') String(@get("highlighted_body")).replace(/<highlight>/g, '<mark>').replace(/<\/highlight>/g, '</mark>')
......
...@@ -4,3 +4,11 @@ class @DiscussionUser extends Backbone.Model ...@@ -4,3 +4,11 @@ class @DiscussionUser extends Backbone.Model
voted: (thread) -> voted: (thread) ->
_.include(@get('upvoted_ids'), thread.id) _.include(@get('upvoted_ids'), thread.id)
vote: (thread) ->
@get('upvoted_ids').push(thread.id)
thread.vote()
unvote: (thread) ->
@set('upvoted_ids', _.without(@get('upvoted_ids'), thread.id))
thread.unvote()
...@@ -22,22 +22,32 @@ class @DiscussionThreadView extends DiscussionContentView ...@@ -22,22 +22,32 @@ class @DiscussionThreadView extends DiscussionContentView
template: _.template($("#thread-template").html()) template: _.template($("#thread-template").html())
initialize: ->
@model.on "change", @updateModelDetails
render: -> render: ->
@$el.html(@template(@model.toJSON())) @$el.html(@template(@model.toJSON()))
@model.bind "change", @updateModelDetails @renderDogear()
if window.user.following(@model) @renderVoted()
@$(".dogear").addClass("is-followed")
if window.user.voted(@model)
@$(".vote-btn").addClass("is-cast")
@$("span.timeago").timeago() @$("span.timeago").timeago()
Markdown.makeWmdEditor @$(".reply-body"), "", DiscussionUtil.urlFor("upload"), (text) -> DiscussionUtil.postMathJaxProcessor(text) Markdown.makeWmdEditor @$(".reply-body"), "", DiscussionUtil.urlFor("upload"), (text) -> DiscussionUtil.postMathJaxProcessor(text)
@convertMath() @convertMath()
@renderResponses() @renderResponses()
@ @
renderDogear: ->
if window.user.following(@model)
@$(".dogear").addClass("is-followed")
renderVoted: =>
if window.user.voted(@model)
@$("[data-role=discussion-vote]").addClass("is-cast")
else
@$("[data-role=discussion-vote]").removeClass("is-cast")
updateModelDetails: => updateModelDetails: =>
@$(".discussion-vote .votes-count-number").html(@model.get("votes")["up_count"]) @renderVoted()
@$("[data-role=discussion-vote] .votes-count-number").html(@model.get("votes")["up_count"])
convertMath: -> convertMath: ->
element = @$(".post-body") element = @$(".post-body")
...@@ -64,10 +74,10 @@ class @DiscussionThreadView extends DiscussionContentView ...@@ -64,10 +74,10 @@ class @DiscussionThreadView extends DiscussionContentView
toggleVote: (event) -> toggleVote: (event) ->
event.preventDefault() event.preventDefault()
if not @model.get('voted')#@$(".discussion-vote").hasClass("is-cast") if window.user.voted(@model)
@vote()
else
@unvote() @unvote()
else
@vote()
toggleFollowing: (event) -> toggleFollowing: (event) ->
$elem = $(event.target) $elem = $(event.target)
...@@ -84,9 +94,8 @@ class @DiscussionThreadView extends DiscussionContentView ...@@ -84,9 +94,8 @@ class @DiscussionThreadView extends DiscussionContentView
type: "POST" type: "POST"
vote: -> vote: ->
window.user.vote(@model)
url = @model.urlFor("upvote") url = @model.urlFor("upvote")
@model.set('votes_point', parseInt(@model.get('votes_point')) + 1)
#@$(".discussion-vote .votes-count-number").html(parseInt(@$(".discussion-vote .votes-count-number").html()) + 1)
DiscussionUtil.safeAjax DiscussionUtil.safeAjax
$elem: @$(".discussion-vote") $elem: @$(".discussion-vote")
url: url url: url
...@@ -96,9 +105,8 @@ class @DiscussionThreadView extends DiscussionContentView ...@@ -96,9 +105,8 @@ class @DiscussionThreadView extends DiscussionContentView
@model.set(response) @model.set(response)
unvote: -> unvote: ->
window.user.unvote(@model)
url = @model.urlFor("unvote") url = @model.urlFor("unvote")
@model.set('votes_point', parseInt(@model.get('votes_point')) - 1)
#@$(".discussion-vote .votes-count-number").html(parseInt(@$(".discussion-vote .votes-count-number").html()) - 1)
DiscussionUtil.safeAjax DiscussionUtil.safeAjax
$elem: @$(".discussion-vote") $elem: @$(".discussion-vote")
url: url url: url
......
...@@ -55,12 +55,12 @@ ...@@ -55,12 +55,12 @@
@mixin discussion-wmd-preview { @mixin discussion-wmd-preview {
width: 100%; width: 100%;
min-height: 40px; min-height: 40px;
padding: 10px; padding: 25px 20px 10px 20px;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid #aaa; border: 1px solid #aaa;
border-top: none; border-top: none;
border-radius: 0 0 3px 3px; border-radius: 0 0 3px 3px;
background: #eee; background: #eee;
color: #333; color: #333;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15) inset; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15) inset;
} }
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
.wmd-button-bar { .wmd-button-bar {
width: 100%; width: 100%;
background-color: Silver; background-color: Silver;
} }
.wmd-input { .wmd-input {
...@@ -129,25 +129,25 @@ ...@@ -129,25 +129,25 @@
} }
.wmd-button-row { .wmd-button-row {
position: relative; position: relative;
margin-left: 5px; margin-left: 5px;
margin-right: 5px; margin-right: 5px;
margin-bottom: 5px; margin-bottom: 5px;
margin-top: 10px; margin-top: 10px;
padding: 0px; padding: 0px;
height: 20px; height: 20px;
overflow: hidden; overflow: hidden;
@include transition(all, .2s, easeOut); @include transition(all, .2s, easeOut);
} }
.wmd-spacer { .wmd-spacer {
width: 1px; width: 1px;
height: 20px; height: 20px;
margin-left: 14px; margin-left: 14px;
position: absolute; position: absolute;
background-color: Silver; background-color: Silver;
display: inline-block; display: inline-block;
list-style: none; list-style: none;
} }
...@@ -301,7 +301,8 @@ body.discussion { ...@@ -301,7 +301,8 @@ body.discussion {
border-top: 1px solid #5f5f5f; border-top: 1px solid #5f5f5f;
font-size: 14px; font-size: 14px;
font-weight: 700; font-weight: 700;
color: #eee; line-height: 18px;
color: #eee;
&:hover { &:hover {
background-color: #666; background-color: #666;
...@@ -332,7 +333,7 @@ body.discussion { ...@@ -332,7 +333,7 @@ body.discussion {
width: 100%; width: 100%;
height: 30px; height: 30px;
padding: 0 15px; padding: 0 15px;
box-sizing: border-box; box-sizing: border-box;
border-radius: 30px; border-radius: 30px;
border: 1px solid #333; border: 1px solid #333;
box-shadow: 0 1px 3px rgba(0, 0, 0, .25) inset; box-shadow: 0 1px 3px rgba(0, 0, 0, .25) inset;
...@@ -350,6 +351,14 @@ body.discussion { ...@@ -350,6 +351,14 @@ body.discussion {
padding: 40px; padding: 40px;
box-sizing: border-box; box-sizing: border-box;
} }
.wmd-button {
background: none;
}
.wmd-button span {
background: url(../images/new-post-icons-full.png) no-repeat;
}
} }
.new-post-form { .new-post-form {
...@@ -388,11 +397,11 @@ body.discussion { ...@@ -388,11 +397,11 @@ body.discussion {
width: 100%; width: 100%;
//height: 50px; //height: 50px;
margin-top: -1px; margin-top: -1px;
padding: 10px; padding: 25px 20px 10px 20px;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid #333; border: 1px solid #333;
border-radius: 0 0 3px 3px; border-radius: 0 0 3px 3px;
background: #e6e6e6; background: #e6e6e6;
color: #333; color: #333;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
} }
...@@ -400,10 +409,10 @@ body.discussion { ...@@ -400,10 +409,10 @@ body.discussion {
.new-post-preview-label { .new-post-preview-label {
position: absolute; position: absolute;
top: 4px; top: 4px;
left: 4px; left: 4px;
font-size: 11px; font-size: 11px;
color: #aaa; color: #aaa;
text-transform: uppercase; text-transform: uppercase;
} }
.new-post-title, .new-post-title,
...@@ -468,7 +477,7 @@ body.discussion { ...@@ -468,7 +477,7 @@ body.discussion {
color: #333; color: #333;
background: #c5eeff; background: #c5eeff;
border: 1px solid #90c4d7; border: 1px solid #90c4d7;
font-size: 13px; font-size: 13px;
} }
.thread-title { .thread-title {
...@@ -478,7 +487,7 @@ body.discussion { ...@@ -478,7 +487,7 @@ body.discussion {
color: #333; color: #333;
font-weight: 700; font-weight: 700;
} }
...@@ -567,7 +576,7 @@ body.discussion { ...@@ -567,7 +576,7 @@ body.discussion {
height: 60px; height: 60px;
border-bottom: 1px solid #a3a3a3; border-bottom: 1px solid #a3a3a3;
border-radius: 3px 0 0 0; border-radius: 3px 0 0 0;
.browse, .browse,
.search { .search {
...@@ -716,18 +725,24 @@ body.discussion { ...@@ -716,18 +725,24 @@ body.discussion {
a { a {
display: block; display: block;
height: 50px;
padding: 0 20px; padding: 0 20px;
border-top: 1px solid #5f5f5f; border-top: 1px solid #5f5f5f;
font-size: 14px; font-size: 14px;
font-weight: 700; font-weight: 700;
line-height: 48px; line-height: 22px;
color: #fff; color: #fff;
@include clearfix;
&:hover { &:hover {
background-color: #636363; background-color: #636363;
} }
.board-name {
float: left;
width: 80%;
margin: 13px 0;
}
.unread { .unread {
float: right; float: right;
padding: 0 5px; padding: 0 5px;
...@@ -762,7 +777,7 @@ body.discussion { ...@@ -762,7 +777,7 @@ body.discussion {
width: 100%; width: 100%;
height: 30px; height: 30px;
padding: 0 15px; padding: 0 15px;
box-sizing: border-box; box-sizing: border-box;
border-radius: 30px; border-radius: 30px;
border: 1px solid #333; border: 1px solid #333;
box-shadow: 0 1px 3px rgba(0, 0, 0, .25) inset; box-shadow: 0 1px 3px rgba(0, 0, 0, .25) inset;
...@@ -929,7 +944,7 @@ body.discussion { ...@@ -929,7 +944,7 @@ body.discussion {
box-shadow: 0 1px 0 #4697c1, 0 -1px 0 #4697c1; box-shadow: 0 1px 0 #4697c1, 0 -1px 0 #4697c1;
.title { .title {
color: #333; color: #333;
} }
.votes-count, .votes-count,
...@@ -1077,7 +1092,7 @@ body.discussion { ...@@ -1077,7 +1092,7 @@ body.discussion {
.responses { .responses {
list-style: none; list-style: none;
margin-top: 40px; margin-top: 40px;
padding: 0; padding: 0;
> li { > li {
position: relative; position: relative;
...@@ -1230,8 +1245,8 @@ body.discussion { ...@@ -1230,8 +1245,8 @@ body.discussion {
background: #009FE2; background: #009FE2;
font-size: 9px; font-size: 9px;
font-weight: 700; font-weight: 700;
font-style: normal; font-style: normal;
color: white; color: white;
text-transform: uppercase; text-transform: uppercase;
} }
...@@ -1386,7 +1401,7 @@ body.discussion { ...@@ -1386,7 +1401,7 @@ body.discussion {
} }
#wmd-input { #wmd-input {
@include discussion-wmd-input; @include discussion-wmd-input;
} }
#wmd-preview { #wmd-preview {
...@@ -1401,6 +1416,10 @@ body.discussion { ...@@ -1401,6 +1416,10 @@ body.discussion {
@include blue-button; @include blue-button;
float: left; float: left;
} }
.wmd-button {
width: 15px;
}
} }
...@@ -1418,7 +1437,53 @@ body.discussion { ...@@ -1418,7 +1437,53 @@ body.discussion {
/* For some reason I have to do this to get the SCSS to compile, can't stick it under the above .discussion-module */ /* For some reason I have to do this to get the SCSS to compile, can't stick it under the above .discussion-module */
.discussion-module { .discussion-module {
section.discussion {
/* Course content p has a default margin-bottom of 1.416, this is just to reset that */
.discussion-thread {
padding: 0.5em;
p {
margin-bottom: 0em;
}
.discussion-article {
border: 1px solid;
border-radius: 3px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
.discussion-post {
header {
padding-bottom: 0.1em;
margin-bottom: 10px;
}
.post-body {
font-size: 14px;
}
}
.responses {
margin-top: 10px;
header {
padding-bottom: 0em;
margin-bottom: 5px;
.posted-by {
font-size: 0.8em;
}
}
.response-body {
margin-bottom: 0.2em;
font-size: 14px;
}
}
}
}
}
.discussion-reply-new { .discussion-reply-new {
display:none display:none;
} }
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<a href="javascript:void(0)" class="dogear action-follow"></a> <a href="javascript:void(0)" class="dogear action-follow"></a>
<div class="discussion-post"> <div class="discussion-post">
<header> <header>
<a href="#" class="vote-btn discussion-vote discussion-vote-up"><span class="plus-icon">+</span> <span class='votes-count-number'>${'<%- votes["up_count"] %>'}</span></a> <a href="#" class="vote-btn discussion-vote discussion-vote-up" data-role="discussion-vote"><span class="plus-icon">+</span> <span class='votes-count-number'>${'<%- votes["up_count"] %>'}</span></a>
<h1>${'<%- title %>'}</h1> <h1>${'<%- title %>'}</h1>
<p class="posted-details"> <p class="posted-details">
<span class="timeago" title="${'<%- created_at %>'}">${'<%- created_at %>'}</span> by <span class="timeago" title="${'<%- created_at %>'}">${'<%- created_at %>'}</span> by
......
<section class="discussion"> <section class="discussion">
{{#threads}} {{#threads}}
<article class="discussion-article" data-id="{{id}}" id="thread_{{id}}"> <article class="discussion-thread" id="thread_{{id}}">
</article> </article>
{{/threads}} {{/threads}}
</section> </section>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment