Commit be3d1144 by David Ormsbee

Merge pull request #320 from edx/dave/ie8_csrf_fix

Remove use of keyword "delete" in forum coffee code to fix IE8 bug LMS-441
parents 38cabe91 aaf3a475
...@@ -109,7 +109,7 @@ if Backbone? ...@@ -109,7 +109,7 @@ if Backbone?
'downvote' : -> DiscussionUtil.urlFor("downvote_#{@get('type')}", @id) 'downvote' : -> DiscussionUtil.urlFor("downvote_#{@get('type')}", @id)
'close' : -> DiscussionUtil.urlFor('openclose_thread', @id) 'close' : -> DiscussionUtil.urlFor('openclose_thread', @id)
'update' : -> DiscussionUtil.urlFor('update_thread', @id) 'update' : -> DiscussionUtil.urlFor('update_thread', @id)
'delete' : -> DiscussionUtil.urlFor('delete_thread', @id) '_delete' : -> DiscussionUtil.urlFor('delete_thread', @id)
'follow' : -> DiscussionUtil.urlFor('follow_thread', @id) 'follow' : -> DiscussionUtil.urlFor('follow_thread', @id)
'unfollow' : -> DiscussionUtil.urlFor('unfollow_thread', @id) 'unfollow' : -> DiscussionUtil.urlFor('unfollow_thread', @id)
'flagAbuse' : -> DiscussionUtil.urlFor("flagAbuse_#{@get('type')}", @id) 'flagAbuse' : -> DiscussionUtil.urlFor("flagAbuse_#{@get('type')}", @id)
...@@ -168,7 +168,7 @@ if Backbone? ...@@ -168,7 +168,7 @@ if Backbone?
'downvote': -> DiscussionUtil.urlFor("downvote_#{@get('type')}", @id) 'downvote': -> DiscussionUtil.urlFor("downvote_#{@get('type')}", @id)
'endorse': -> DiscussionUtil.urlFor('endorse_comment', @id) 'endorse': -> DiscussionUtil.urlFor('endorse_comment', @id)
'update': -> DiscussionUtil.urlFor('update_comment', @id) 'update': -> DiscussionUtil.urlFor('update_comment', @id)
'delete': -> DiscussionUtil.urlFor('delete_comment', @id) '_delete': -> DiscussionUtil.urlFor('delete_comment', @id)
'flagAbuse' : -> DiscussionUtil.urlFor("flagAbuse_#{@get('type')}", @id) 'flagAbuse' : -> DiscussionUtil.urlFor("flagAbuse_#{@get('type')}", @id)
'unFlagAbuse' : -> DiscussionUtil.urlFor("unFlagAbuse_#{@get('type')}", @id) 'unFlagAbuse' : -> DiscussionUtil.urlFor("unFlagAbuse_#{@get('type')}", @id)
......
...@@ -7,7 +7,7 @@ if Backbone? ...@@ -7,7 +7,7 @@ if Backbone?
"click .admin-pin": "togglePin" "click .admin-pin": "togglePin"
"click .action-follow": "toggleFollowing" "click .action-follow": "toggleFollowing"
"click .action-edit": "edit" "click .action-edit": "edit"
"click .action-delete": "delete" "click .action-delete": "_delete"
"click .action-openclose": "toggleClosed" "click .action-openclose": "toggleClosed"
$: (selector) -> $: (selector) ->
...@@ -125,8 +125,8 @@ if Backbone? ...@@ -125,8 +125,8 @@ if Backbone?
edit: (event) -> edit: (event) ->
@trigger "thread:edit", event @trigger "thread:edit", event
delete: (event) -> _delete: (event) ->
@trigger "thread:delete", event @trigger "thread:_delete", event
togglePin: (event) -> togglePin: (event) ->
event.preventDefault() event.preventDefault()
......
...@@ -185,7 +185,7 @@ if Backbone? ...@@ -185,7 +185,7 @@ if Backbone?
@editView = null @editView = null
@showView = new DiscussionThreadShowView(model: @model) @showView = new DiscussionThreadShowView(model: @model)
@showView.bind "thread:delete", @delete @showView.bind "thread:_delete", @_delete
@showView.bind "thread:edit", @edit @showView.bind "thread:edit", @edit
renderShowView: () -> renderShowView: () ->
...@@ -196,9 +196,11 @@ if Backbone? ...@@ -196,9 +196,11 @@ if Backbone?
@createShowView() @createShowView()
@renderShowView() @renderShowView()
# If you use "delete" here, it will compile down into JS that includes the
delete: (event) => # use of DiscussionThreadView.prototype.delete, and that will break IE8
url = @model.urlFor('delete') # because "delete" is a keyword. So, using an underscore to prevent that.
_delete: (event) =>
url = @model.urlFor('_delete')
if not @model.can('can_delete') if not @model.can('can_delete')
return return
if not confirm "Are you sure to delete thread \"#{@model.get('title')}\"?" if not confirm "Are you sure to delete thread \"#{@model.get('title')}\"?"
......
...@@ -48,7 +48,7 @@ if Backbone? ...@@ -48,7 +48,7 @@ if Backbone?
@editView.$el.empty() @editView.$el.empty()
@editView = null @editView = null
@showView = new DiscussionThreadInlineShowView(model: @model) @showView = new DiscussionThreadInlineShowView(model: @model)
@showView.bind "thread:delete", @delete @showView.bind "thread:_delete", @_delete
@showView.bind "thread:edit", @edit @showView.bind "thread:edit", @edit
renderResponses: -> renderResponses: ->
......
...@@ -3,7 +3,7 @@ if Backbone? ...@@ -3,7 +3,7 @@ if Backbone?
events: events:
"click .vote-btn": "toggleVote" "click .vote-btn": "toggleVote"
"click .action-endorse": "toggleEndorse" "click .action-endorse": "toggleEndorse"
"click .action-delete": "delete" "click .action-delete": "_delete"
"click .action-edit": "edit" "click .action-edit": "edit"
"click .discussion-flag-abuse": "toggleFlagAbuse" "click .discussion-flag-abuse": "toggleFlagAbuse"
...@@ -77,8 +77,8 @@ if Backbone? ...@@ -77,8 +77,8 @@ if Backbone?
edit: (event) -> edit: (event) ->
@trigger "response:edit", event @trigger "response:edit", event
delete: (event) -> _delete: (event) ->
@trigger "response:delete", event @trigger "response:_delete", event
toggleEndorse: (event) -> toggleEndorse: (event) ->
event.preventDefault() event.preventDefault()
......
...@@ -93,13 +93,13 @@ if Backbone? ...@@ -93,13 +93,13 @@ if Backbone?
comment.set(response.content) comment.set(response.content)
view.render() # This is just to update the id for the most part, but might be useful in general view.render() # This is just to update the id for the most part, but might be useful in general
delete: (event) => _delete: (event) =>
event.preventDefault() event.preventDefault()
if not @model.can('can_delete') if not @model.can('can_delete')
return return
if not confirm "Are you sure to delete this response? " if not confirm "Are you sure to delete this response? "
return return
url = @model.urlFor('delete') url = @model.urlFor('_delete')
@model.remove() @model.remove()
@$el.remove() @$el.remove()
$elem = $(event.target) $elem = $(event.target)
...@@ -141,7 +141,7 @@ if Backbone? ...@@ -141,7 +141,7 @@ if Backbone?
@editView = null @editView = null
@showView = new ThreadResponseShowView(model: @model) @showView = new ThreadResponseShowView(model: @model)
@showView.bind "response:delete", @delete @showView.bind "response:_delete", @_delete
@showView.bind "response:edit", @edit @showView.bind "response:edit", @edit
renderShowView: () -> renderShowView: () ->
......
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