remove obsolete prototype indicator code, as the jquery one seems to work better

pull/120/head
jwollert 12 years ago committed by Nils Kenneweg
parent c717bb4c40
commit 58dba65d36
  1. 45
      app/assets/javascripts/application.js

@ -452,41 +452,6 @@ var WarnLeavingUnsaved = Class.create({
}
});
/*
* 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
*/
document.observe("dom:loaded", function() {
Ajax.Responders.register({
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) {
Element.show('ajax-indicator');
}
},
onComplete: function(){
if ($('ajax-indicator') && Ajax.activeRequestCount == 0) {
Element.hide('ajax-indicator');
}
addClickEventToAllErrorMessages();
}
});
});
function hideOnLoad() {
$$('.hol').each(function(el) {
el.hide();
@ -550,8 +515,14 @@ jQuery.viewportHeight = function() {
/* TODO: integrate with existing code and/or refactor */
jQuery(document).ready(function($) {
/* TODO: This duplicates the ajax indicator code for Prototype.
Switch to one implementation that does it all */
/*
* 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
*/
$(document).ajaxSend(function (event, request) {
var csrf_meta_tag = $('meta[name=csrf-token]');

Loading…
Cancel
Save