|
|
@ -299,9 +299,27 @@ var WarnLeavingUnsaved = Class.create({ |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/* shows and hides ajax indicator */ |
|
|
|
/* |
|
|
|
|
|
|
|
* 1 - registers a callback which copies the csrf token into the |
|
|
|
|
|
|
|
* X-CSRF-Token header with each ajax request. Necessary to
|
|
|
|
|
|
|
|
* work with rails applications which have fixed |
|
|
|
|
|
|
|
* CVE-2011-0447 |
|
|
|
|
|
|
|
* 2 - shows and hides ajax indicator |
|
|
|
|
|
|
|
*/ |
|
|
|
Ajax.Responders.register({ |
|
|
|
Ajax.Responders.register({ |
|
|
|
onCreate: function(){ |
|
|
|
onCreate: function(request){ |
|
|
|
|
|
|
|
var csrf_meta_tag = $$('meta[name=csrf-token]')[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (csrf_meta_tag) { |
|
|
|
|
|
|
|
var header = 'X-CSRF-Token', |
|
|
|
|
|
|
|
token = csrf_meta_tag.readAttribute('content'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!request.options.requestHeaders) { |
|
|
|
|
|
|
|
request.options.requestHeaders = {}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
request.options.requestHeaders[header] = token; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($('ajax-indicator') && Ajax.activeRequestCount > 0) { |
|
|
|
if ($('ajax-indicator') && Ajax.activeRequestCount > 0) { |
|
|
|
Element.show('ajax-indicator'); |
|
|
|
Element.show('ajax-indicator'); |
|
|
|
} |
|
|
|
} |
|
|
|