fixed user link and back button

This commit is contained in:
Rocky Duan
2012-08-31 23:46:13 -07:00
parent e3728f6898
commit fde77b7a89
7 changed files with 20 additions and 464 deletions

View File

@@ -47,6 +47,7 @@ if Backbone?
initialize: ->
DiscussionUtil.addContent @id, @
@set 'user_url', DiscussionUtil.urlFor('user_profile', @get('user_id'))
@resetComments(@get('children'))

View File

@@ -64,21 +64,25 @@ class @DiscussionUtil
openclose_thread : "/courses/#{$$course_id}/discussion/threads/#{param}/close"
permanent_link_thread : "/courses/#{$$course_id}/discussion/forum/#{param}/threads/#{param1}"
permanent_link_comment : "/courses/#{$$course_id}/discussion/forum/#{param}/threads/#{param1}##{param2}"
user_profile : "/courses/#{$$course_id}/discussion/forum/users/#{param}"
}[name]
@safeAjax: (params) ->
$elem = params.$elem
if $elem.attr("disabled")
if $elem and $elem.attr("disabled")
return
params["url"] = URI(params["url"]).addSearch ajax: 1
params["beforeSend"] = ->
$elem.attr("disabled", "disabled")
if $elem
$elem.attr("disabled", "disabled")
if params["$loading"]
if params["loadingCallback"]?
params["loadingCallback"].apply(params["$loading"])
else
params["$loading"].loading()
$.ajax(params).always ->
$elem.removeAttr("disabled")
if $elem
$elem.removeAttr("disabled")
if params["$loading"]
if params["loadedCallback"]?
params["loadedCallback"].apply(params["$loading"])

View File

@@ -29,10 +29,12 @@ class @DiscussionThreadView extends Backbone.View
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element.attr("id")]
renderResponses: ->
$.ajax @model.id, success: (data, textStatus, xhr) =>
@$(".loading").remove()
comments = new Comments(data['content']['children'])
comments.each @renderResponse
DiscussionUtil.safeAjax
url: @model.id
success: (data, textStatus, xhr) =>
@$(".loading").remove()
comments = new Comments(data['content']['children'])
comments.each @renderResponse
renderResponse: (response) =>
view = new ThreadResponseView(model: response)