Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update/simplify file upload workaround code for IE

  • Loading branch information...
commit 3cb7e50559b7199d2dec2ef362b206ec1afb4e84 1 parent c682406
@nabcos nabcos authored cstamas committed
Showing with 15 additions and 100 deletions.
  1. +15 −100 nexus/nexus-webapp/src/main/webapp/js/ext/data/connection.js
View
115 nexus/nexus-webapp/src/main/webapp/js/ext/data/connection.js
@@ -13,108 +13,23 @@
/*global require*/
define('ext/data/connection',['extjs'], function(Ext) {
Ext.override(Ext.data.Connection, {
- request : function(o) {
- var effectiveForm, params, url, extras, form, headers, options, method, enctype;
-
- if (this.fireEvent("beforerequest", this, o) !== false) {
- params = o.params;
-
- if (typeof params === "function") {
- params = params.call(o.scope || window, o);
+ extendFormUploadURL : function(url) {
+ // hack for IE: if a non success response is received, we can't
+ // access the response data, because an error page is loaded from local disc
+ // for most response codes, making the containing iframe protected because it has
+ // a different domain (CORS)
+ if (Ext.isIE) {
+ if (url.indexOf('?') >= 0) {
+ url += '&forceSuccess=true';
+ }
+ else {
+ url += '?forceSuccess=true';
}
- if (typeof params === "object") {
- params = Ext.urlEncode(params);
- }
- if (this.extraParams) {
- extras = Ext.urlEncode(this.extraParams);
- params = params ? (params + '&' + extras) : extras;
- }
-
- url = o.url || this.url;
- if (typeof url === 'function') {
- url = url.call(o.scope || window, o);
- }
-
- if (o.form) {
- form = Ext.getDom(o.form);
- url = url || form.action;
-
- enctype = form.getAttribute("enctype");
- if (o.isUpload || (enctype && enctype.toLowerCase() === 'multipart/form-data')) {
- // hack for IE: if a non success response is received, we can't
- // access the response data, because an error page is loaded from local disc
- // for most response codes, making the containing iframe protected because it has
- // a different domain (CORS)
- if (Ext.isIE) {
- if (url.indexOf('?') >= 0) {
- url += '&forceSuccess=true';
- }
- else {
- url += '?forceSuccess=true';
- }
- }
-
- return this.doFormUpload(o, params, url);
- }
- effectiveForm = Ext.lib.Ajax.serializeForm(form);
- params = params ? (params + '&' + effectiveForm) : effectiveForm;
- }
-
- headers = o.headers;
- if (this.defaultHeaders) {
- // Sonatype: default header fix
- headers = Ext.applyIf(headers || {}, this.defaultHeaders);
- if (!o.headers) {
- o.headers = headers;
- }
- }
-
- if (o.xmlData) {
- if (!headers || !headers['Content-Type']) {
- headers['Content-Type'] = 'text/xml; charset=utf-8';
- }
- }
- else if (o.jsonData) {
- if (!headers || !headers['Content-Type']) {
- headers['Content-Type'] = 'application/json; charset=utf-8';
- }
- }
-
- options = {
- success : this.handleResponse,
- failure : this.handleFailure,
- scope : this,
- argument : {
- options : o
- },
- timeout : o.timeout || this.timeout
- };
-
- method = o.method || this.method || (params ? "POST" : "GET");
-
- if ((method === 'GET' && Ext.value(this.disableCaching, false) !== false) || o.disableCaching === true) {
- url += (url.indexOf('?') !== -1 ? '&' : '?') + '_dc=' + (new Date().getTime());
- }
-
- if (typeof o.autoAbort === 'boolean') {
- if (o.autoAbort) {
- this.abort();
- }
- }
- else if (this.autoAbort !== false) {
- this.abort();
- }
- if ((method === 'GET' && params) || o.xmlData || o.jsonData) {
- url += (url.indexOf('?') !== -1 ? '&' : '?') + params;
- params = '';
- }
- this.transId = Ext.lib.Ajax.request(method, url, options, params, o);
- return this.transId;
- }
- else {
- Ext.callback(o.callback, o.scope, [o, null, null]);
- return null;
}
+ return url;
+ },
+ doFormUpload : function(o, ps, url) {
+ this.superclass.doFormUpload.call(this, o, ps, this.extendFormUploadURL(url));
}
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.