Commit 91379aa9 by Arjun Singh

improve date search, fix respnding, make sidebar expand when discussion column does

parent 9064f81b
......@@ -24,7 +24,6 @@ if Backbone?
updateInfo: (info) ->
if info
console.log info.ability
@set('ability', info.ability)
@set('voted', info.voted)
@set('subscribed', info.subscribed)
......
......@@ -5,7 +5,7 @@ if Backbone?
initialize: ->
@bind "add", (item) =>
item.discussion = @
@comparator = @sortByDate
@comparator = @sortByDateRecentFirst
find: (id) ->
_.first @where(id: id)
......@@ -19,6 +19,13 @@ if Backbone?
sortByDate: (thread) ->
thread.get("created_at")
sortByDateRecentFirst: (thread) ->
-(new Date(thread.get("created_at")).getTime())
#return String.fromCharCode.apply(String,
# _.map(thread.get("created_at").split(""),
# ((c) -> return 0xffff - c.charChodeAt()))
#)
sortByVotes: (thread1, thread2) ->
thread1_count = parseInt(thread1.get("votes")['up_count'])
thread2_count = parseInt(thread2.get("votes")['up_count'])
......
......@@ -8,6 +8,7 @@ DiscussionApp =
threads = element.data("threads")
content_info = element.data("content-info")
window.user = new DiscussionUser(user_info)
console.log content_info
Content.loadContentInfos(content_info)
discussion = new Discussion(threads)
new DiscussionRouter({discussion: discussion})
......
......@@ -89,7 +89,7 @@ class @DiscussionThreadListView extends Backbone.View
$(event.target).addClass("active")
sortBy = $(event.target).data("sort")
if sortBy == "date"
@displayedCollection.comparator = @displayedCollection.sortByDate
@displayedCollection.comparator = @displayedCollection.sortByDateRecentFirst
else if sortBy == "votes"
@displayedCollection.comparator = @displayedCollection.sortByVotes
else if sortBy == "comments"
......
......@@ -111,7 +111,7 @@ class @DiscussionThreadView extends DiscussionContentView
event.preventDefault()
url = @model.urlFor('reply')
body = @$("#wmd-input").val()
response = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), votes: { up_count: 0 })
response = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), votes: { up_count: 0 }, endorsed: false, user_id: window.user.get("id"))
@renderResponse(response)
@addComment()
......
......@@ -8,6 +8,8 @@ class @ThreadResponseView extends DiscussionContentView
"click .action-endorse": "toggleEndorse"
render: ->
console.log @model
console.log @model.toJSON()
@$el.html(@template(@model.toJSON()))
if window.user.voted(@model)
@$(".vote-btn").addClass("is-cast")
......@@ -65,7 +67,7 @@ class @ThreadResponseView extends DiscussionContentView
body = @$(".comment-form-input").val()
if not body.trim().length
return
comment = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"))
comment = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), user_id: window.user.get("id"))
@renderComment(comment)
@trigger "comment:add"
@$(".comment-form-input").val("")
......
......@@ -68,6 +68,11 @@ $(document).ready(function() {
$(window).bind('resize', updateSidebarDimensions);
$(window).bind('scroll', updateSidebarCoordinates);
$('.discussion-column').bind("input", function (e) {
console.log("resized");
updateSidebarCoordinates();
updateSidebarDimensions();
})
updateSidebarCoordinates();
updateSidebarDimensions();
});
......
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