From ea88f9e1a7621ad2bea02013b4884b884e6a0a67 Mon Sep 17 00:00:00 2001 From: Seggy Umboh Date: Tue, 30 Aug 2011 13:53:23 -0700 Subject: [PATCH 1/2] Disable jQuery ajax caching which conflicts with couch auth in IE --- couchapp/_attachments/jquery.extensions.js | 5 +++++ couchapp/_attachments/loader.js | 1 + 2 files changed, 6 insertions(+) create mode 100644 couchapp/_attachments/jquery.extensions.js diff --git a/couchapp/_attachments/jquery.extensions.js b/couchapp/_attachments/jquery.extensions.js new file mode 100644 index 0000000..1673c28 --- /dev/null +++ b/couchapp/_attachments/jquery.extensions.js @@ -0,0 +1,5 @@ +(function($) { + // https://issues.apache.org/jira/browse/COUCHDB-1239 + // fixes IE8 couchapp auth + $.ajaxSetup({ cache: false }); +})(jQuery); diff --git a/couchapp/_attachments/loader.js b/couchapp/_attachments/loader.js index 86b2ed7..4781cd0 100644 --- a/couchapp/_attachments/loader.js +++ b/couchapp/_attachments/loader.js @@ -9,6 +9,7 @@ couchapp_load([ "/_utils/script/sha1.js", "/_utils/script/json2.js", "/_utils/script/jquery.js", + "vendor/couchapp/jquery.extensions.js", "/_utils/script/jquery.couch.js", "vendor/couchapp/jquery.couch.app.js", "vendor/couchapp/jquery.couch.app.util.js", From ee312ba3ac512d35dadfb186d40d71bee396d186 Mon Sep 17 00:00:00 2001 From: Seggy Umboh Date: Tue, 30 Aug 2011 13:54:20 -0700 Subject: [PATCH 2/2] Add jQuery httpData function if it is not available, which is the case with newer versions of jQuery. This was an internal jQuery function used by jquery.couch and jquery.form. --- couchapp/_attachments/jquery.extensions.js | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/couchapp/_attachments/jquery.extensions.js b/couchapp/_attachments/jquery.extensions.js index 1673c28..0770e6d 100644 --- a/couchapp/_attachments/jquery.extensions.js +++ b/couchapp/_attachments/jquery.extensions.js @@ -2,4 +2,36 @@ // https://issues.apache.org/jira/browse/COUCHDB-1239 // fixes IE8 couchapp auth $.ajaxSetup({ cache: false }); + + // adds the jQuery httpData function if it is not available + // fixes jquery.couch and jquery.form calling the obsolete internal function + $.httpData = $.httpData || function( xhr, type, s ) { + var ct = xhr.getResponseHeader("content-type") || "", + xml = type === "xml" || !type && ct.indexOf("xml") >= 0, + data = xml ? xhr.responseXML : xhr.responseText; + + if ( xml && data.documentElement.nodeName === "parsererror" ) { + jQuery.error( "parsererror" ); + } + + // Allow a pre-filtering function to sanitize the response + // s is checked to keep backwards compatibility + if ( s && s.dataFilter ) { + data = s.dataFilter( data, type ); + } + + // The filter can actually parse the response + if ( typeof data === "string" ) { + // Get the JavaScript object, if JSON is used. + if ( type === "json" || !type && ct.indexOf("json") >= 0 ) { + data = jQuery.parseJSON( data ); + + // If the type is "script", eval it in global context + } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) { + jQuery.globalEval( data ); + } + } + + return data; + } })(jQuery);