Commit 1d993256 by E. Kolpakov Committed by Jonathan Piacenti

Global setting for asynchronous ajax calls - to overcome firefox's strictness…

Global setting for asynchronous ajax calls - to overcome firefox's strictness about using synchronous ajax with credentials
parent a4834094
...@@ -9,6 +9,7 @@ function DiscussionCourseBlock(runtime, element) { ...@@ -9,6 +9,7 @@ function DiscussionCourseBlock(runtime, element) {
var hostname = testUrl.match(/^(.*:\/\/[a-z\-.]+)\//)[1]; var hostname = testUrl.match(/^(.*:\/\/[a-z\-.]+)\//)[1];
DiscussionUtil.setBaseUrl(hostname); DiscussionUtil.setBaseUrl(hostname);
DiscussionUtil.localUrls.push('user_profile'); DiscussionUtil.localUrls.push('user_profile');
DiscussionUtil.force_async = true;
pushState = false pushState = false
} }
......
...@@ -7,10 +7,8 @@ function DiscussionInlineBlock(runtime, element) { ...@@ -7,10 +7,8 @@ function DiscussionInlineBlock(runtime, element) {
if (testUrl.match(/^(http|https):\/\//)) { if (testUrl.match(/^(http|https):\/\//)) {
var hostname = testUrl.match(/^(.*:\/\/[a-z0-9:\-.]+)\//)[1]; var hostname = testUrl.match(/^(.*:\/\/[a-z0-9:\-.]+)\//)[1];
DiscussionUtil.setBaseUrl(hostname); DiscussionUtil.setBaseUrl(hostname);
DiscussionUtil.force_async = true;
} }
new DiscussionModuleView({ new DiscussionModuleView({ el: el });
el: el,
async_thread_views: true
});
} }
...@@ -18,6 +18,8 @@ class @DiscussionUtil ...@@ -18,6 +18,8 @@ class @DiscussionUtil
@localUrls: [] @localUrls: []
@force_async = false
@getTemplate: (id) -> @getTemplate: (id) ->
$("script##{id}").html() $("script##{id}").html()
...@@ -165,6 +167,9 @@ class @DiscussionUtil ...@@ -165,6 +167,9 @@ class @DiscussionUtil
else else
params["$loading"].loading(params["takeFocus"]) params["$loading"].loading(params["takeFocus"])
if @force_async
params["async"] = true
request = $.ajax(params).always -> request = $.ajax(params).always ->
if $elem if $elem
$elem.removeAttr("disabled") $elem.removeAttr("disabled")
......
...@@ -22,8 +22,6 @@ if Backbone? ...@@ -22,8 +22,6 @@ if Backbone?
if @mode not in ["tab", "inline"] if @mode not in ["tab", "inline"]
throw new Error("invalid mode: " + @mode) throw new Error("invalid mode: " + @mode)
@async_thread_views = if options.async_thread_views? then options.async_thread_views else false
# Quick fix to have an actual model when we're receiving new models from # Quick fix to have an actual model when we're receiving new models from
# the server. # the server.
@model.collection.on "reset", (collection) => @model.collection.on "reset", (collection) =>
...@@ -233,7 +231,7 @@ if Backbone? ...@@ -233,7 +231,7 @@ if Backbone?
renderResponseToList: (response, listSelector, options) => renderResponseToList: (response, listSelector, options) =>
response.set('thread', @model) response.set('thread', @model)
view = new ThreadResponseView($.extend({model: response, async: @async_thread_views}, options)) view = new ThreadResponseView($.extend({model: response}, options))
view.on "comment:add", @addComment view.on "comment:add", @addComment
view.on "comment:endorse", @endorseThread view.on "comment:endorse", @endorseThread
view.render() view.render()
......
...@@ -87,7 +87,9 @@ if Backbone? ...@@ -87,7 +87,9 @@ if Backbone?
url: url url: url
type: "POST" type: "POST"
dataType: 'json' dataType: 'json'
async: false # TODO when the rest of the stuff below is made to work properly.. # TODO when the rest of the stuff below is made to work properly..
# Note it can be forced to true on global basis via DiscussionUtils.force_async
async: false
data: data:
thread_type: thread_type thread_type: thread_type
title: title title: title
......
...@@ -12,7 +12,6 @@ if Backbone? ...@@ -12,7 +12,6 @@ if Backbone?
initialize: (options) -> initialize: (options) ->
@collapseComments = options.collapseComments @collapseComments = options.collapseComments
@async = if options.async? then options.async else false;
@createShowView() @createShowView()
renderTemplate: -> renderTemplate: ->
...@@ -200,7 +199,9 @@ if Backbone? ...@@ -200,7 +199,9 @@ if Backbone?
url: url url: url
type: "POST" type: "POST"
dataType: 'json' dataType: 'json'
async: @async # TODO when the rest of the stuff below is made to work properly.. # TODO when the rest of the stuff below is made to work properly..
# Note it can be forced to true on global basis via DiscussionUtils.force_async
async: false
data: data:
body: newBody body: newBody
error: DiscussionUtil.formErrorHandler(@$(".edit-post-form-errors")) error: DiscussionUtil.formErrorHandler(@$(".edit-post-form-errors"))
......
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