From 3ec1e71154e860d9fdfb1f81996f8371139bbf12 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 7 Mar 2012 17:19:48 -0800 Subject: [PATCH] properly addes a default onFailure method to all Requests fixes Bug 733639 - Unable to add Vold Utils and Menuitems libraries into an addon. --- media/base/js/flightdeck/request.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/media/base/js/flightdeck/request.js b/media/base/js/flightdeck/request.js index 6cfbb0d4..38237763 100644 --- a/media/base/js/flightdeck/request.js +++ b/media/base/js/flightdeck/request.js @@ -3,19 +3,22 @@ var Request = require('shipyard/http/Request'), Cookie = require('shipyard/utils/Cookie'), log = require('shipyard/utils/log'), - dom = require('shipyard/dom'), - - fd = dom.window.get('fd'); + dom = require('shipyard/dom'); + +function fd() { + return dom.window.get('fd'); +} Request.prototype.options.headers['X-CSRFToken'] = Cookie.read('csrftoken'); -Request.prototype.options.onFailure = function(text) { +var oldInit = Request.prototype.initialize; +var defaultFailure = function(text) { if (this.status !== 0 && text) { var response; try { response = JSON.parse(text); } catch (notJSON) { - log.warn('Response error is not valid JSON', text); + log.warn('Response error is not valid JSON'); if (text.indexOf('