diff --git a/couchapp/_attachments/jquery.extensions.js b/couchapp/_attachments/jquery.extensions.js new file mode 100644 index 0000000..0770e6d --- /dev/null +++ b/couchapp/_attachments/jquery.extensions.js @@ -0,0 +1,37 @@ +(function($) { + // 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); 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",