Mercurial > hg > orthanc
annotate OrthancExplorer/libs/jquery-file-upload/js/jquery.fileupload.js @ 3066:5713952f60c0 update-jquery
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
author | am@osimis.io |
---|---|
date | Wed, 26 Dec 2018 16:58:21 +0100 |
parents | 4bc019d2f969 |
children |
rev | line source |
---|---|
0 | 1 /* |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
2 * jQuery File Upload Plugin 5.32.0 |
0 | 3 * https://github.com/blueimp/jQuery-File-Upload |
4 * | |
5 * Copyright 2010, Sebastian Tschan | |
6 * https://blueimp.net | |
7 * | |
8 * Licensed under the MIT license: | |
9 * http://www.opensource.org/licenses/MIT | |
10 */ | |
11 | |
12 /*jslint nomen: true, unparam: true, regexp: true */ | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
13 /*global define, window, document, location, File, Blob, FormData */ |
0 | 14 |
15 (function (factory) { | |
16 'use strict'; | |
17 if (typeof define === 'function' && define.amd) { | |
18 // Register as an anonymous AMD module: | |
19 define([ | |
20 'jquery', | |
21 'jquery.ui.widget' | |
22 ], factory); | |
23 } else { | |
24 // Browser globals: | |
25 factory(window.jQuery); | |
26 } | |
27 }(function ($) { | |
28 'use strict'; | |
29 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
30 // Detect file input support, based on |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
31 // http://viljamis.com/blog/2012/file-upload-support-on-mobile/ |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
32 $.support.fileInput = !(new RegExp( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
33 // Handle devices which give false positives for the feature detection: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
34 '(Android (1\\.[0156]|2\\.[01]))' + |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
35 '|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)' + |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
36 '|(w(eb)?OSBrowser)|(webOS)' + |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
37 '|(Kindle/(1\\.0|2\\.[05]|3\\.0))' |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
38 ).test(window.navigator.userAgent) || |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
39 // Feature detection for all other devices: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
40 $('<input type="file">').prop('disabled')); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
41 |
0 | 42 // The FileReader API is not actually used, but works as feature detection, |
43 // as e.g. Safari supports XHR file uploads via the FormData API, | |
44 // but not non-multipart XHR file uploads: | |
45 $.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader); | |
46 $.support.xhrFormDataFileUpload = !!window.FormData; | |
47 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
48 // Detect support for Blob slicing (required for chunked uploads): |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
49 $.support.blobSlice = window.Blob && (Blob.prototype.slice || |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
50 Blob.prototype.webkitSlice || Blob.prototype.mozSlice); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
51 |
0 | 52 // The fileupload widget listens for change events on file input fields defined |
53 // via fileInput setting and paste or drop events of the given dropZone. | |
54 // In addition to the default jQuery Widget methods, the fileupload widget | |
55 // exposes the "add" and "send" methods, to add or directly send files using | |
56 // the fileupload API. | |
57 // By default, files added via file input selection, paste, drag & drop or | |
58 // "add" method are uploaded immediately, but it is possible to override | |
59 // the "add" callback option to queue file uploads. | |
60 $.widget('blueimp.fileupload', { | |
61 | |
62 options: { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
63 // The drop target element(s), by the default the complete document. |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
64 // Set to null to disable drag & drop support: |
0 | 65 dropZone: $(document), |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
66 // The paste target element(s), by the default the complete document. |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
67 // Set to null to disable paste support: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
68 pasteZone: $(document), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
69 // The file input field(s), that are listened to for change events. |
0 | 70 // If undefined, it is set to the file input fields inside |
71 // of the widget element on plugin initialization. | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
72 // Set to null to disable the change listener. |
0 | 73 fileInput: undefined, |
74 // By default, the file input field is replaced with a clone after | |
75 // each input field change event. This is required for iframe transport | |
76 // queues and allows change events to be fired for the same file | |
77 // selection, but can be disabled by setting the following option to false: | |
78 replaceFileInput: true, | |
79 // The parameter name for the file form data (the request argument name). | |
80 // If undefined or empty, the name property of the file input field is | |
81 // used, or "files[]" if the file input name property is also empty, | |
82 // can be a string or an array of strings: | |
83 paramName: undefined, | |
84 // By default, each file of a selection is uploaded using an individual | |
85 // request for XHR type uploads. Set to false to upload file | |
86 // selections in one request each: | |
87 singleFileUploads: true, | |
88 // To limit the number of files uploaded with one XHR request, | |
89 // set the following option to an integer greater than 0: | |
90 limitMultiFileUploads: undefined, | |
91 // Set the following option to true to issue all file upload requests | |
92 // in a sequential order: | |
93 sequentialUploads: false, | |
94 // To limit the number of concurrent uploads, | |
95 // set the following option to an integer greater than 0: | |
96 limitConcurrentUploads: undefined, | |
97 // Set the following option to true to force iframe transport uploads: | |
98 forceIframeTransport: false, | |
99 // Set the following option to the location of a redirect url on the | |
100 // origin server, for cross-domain iframe transport uploads: | |
101 redirect: undefined, | |
102 // The parameter name for the redirect url, sent as part of the form | |
103 // data and set to 'redirect' if this option is empty: | |
104 redirectParamName: undefined, | |
105 // Set the following option to the location of a postMessage window, | |
106 // to enable postMessage transport uploads: | |
107 postMessage: undefined, | |
108 // By default, XHR file uploads are sent as multipart/form-data. | |
109 // The iframe transport is always using multipart/form-data. | |
110 // Set to false to enable non-multipart XHR uploads: | |
111 multipart: true, | |
112 // To upload large files in smaller chunks, set the following option | |
113 // to a preferred maximum chunk size. If set to 0, null or undefined, | |
114 // or the browser does not support the required Blob API, files will | |
115 // be uploaded as a whole. | |
116 maxChunkSize: undefined, | |
117 // When a non-multipart upload or a chunked multipart upload has been | |
118 // aborted, this option can be used to resume the upload by setting | |
119 // it to the size of the already uploaded bytes. This option is most | |
120 // useful when modifying the options object inside of the "add" or | |
121 // "send" callbacks, as the options are cloned for each file upload. | |
122 uploadedBytes: undefined, | |
123 // By default, failed (abort or error) file uploads are removed from the | |
124 // global progress calculation. Set the following option to false to | |
125 // prevent recalculating the global progress data: | |
126 recalculateProgress: true, | |
127 // Interval in milliseconds to calculate and trigger progress events: | |
128 progressInterval: 100, | |
129 // Interval in milliseconds to calculate progress bitrate: | |
130 bitrateInterval: 500, | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
131 // By default, uploads are started automatically when adding files: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
132 autoUpload: true, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
133 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
134 // Error and info messages: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
135 messages: { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
136 uploadedBytes: 'Uploaded bytes exceed file size' |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
137 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
138 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
139 // Translation function, gets the message key to be translated |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
140 // and an object with context specific data as arguments: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
141 i18n: function (message, context) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
142 message = this.messages[message] || message.toString(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
143 if (context) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
144 $.each(context, function (key, value) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
145 message = message.replace('{' + key + '}', value); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
146 }); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
147 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
148 return message; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
149 }, |
0 | 150 |
151 // Additional form data to be sent along with the file uploads can be set | |
152 // using this option, which accepts an array of objects with name and | |
153 // value properties, a function returning such an array, a FormData | |
154 // object (for XHR file uploads), or a simple object. | |
155 // The form of the first fileInput is given as parameter to the function: | |
156 formData: function (form) { | |
157 return form.serializeArray(); | |
158 }, | |
159 | |
160 // The add callback is invoked as soon as files are added to the fileupload | |
161 // widget (via file input selection, drag & drop, paste or add API call). | |
162 // If the singleFileUploads option is enabled, this callback will be | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
163 // called once for each file in the selection for XHR file uploads, else |
0 | 164 // once for each file selection. |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
165 // |
0 | 166 // The upload starts when the submit method is invoked on the data parameter. |
167 // The data object contains a files property holding the added files | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
168 // and allows you to override plugin options as well as define ajax settings. |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
169 // |
0 | 170 // Listeners for this callback can also be bound the following way: |
171 // .bind('fileuploadadd', func); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
172 // |
0 | 173 // data.submit() returns a Promise object and allows to attach additional |
174 // handlers using jQuery's Deferred callbacks: | |
175 // data.submit().done(func).fail(func).always(func); | |
176 add: function (e, data) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
177 if (data.autoUpload || (data.autoUpload !== false && |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
178 $(this).fileupload('option', 'autoUpload'))) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
179 data.process().done(function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
180 data.submit(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
181 }); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
182 } |
0 | 183 }, |
184 | |
185 // Other callbacks: | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
186 |
0 | 187 // Callback for the submit event of each file upload: |
188 // submit: function (e, data) {}, // .bind('fileuploadsubmit', func); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
189 |
0 | 190 // Callback for the start of each file upload request: |
191 // send: function (e, data) {}, // .bind('fileuploadsend', func); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
192 |
0 | 193 // Callback for successful uploads: |
194 // done: function (e, data) {}, // .bind('fileuploaddone', func); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
195 |
0 | 196 // Callback for failed (abort or error) uploads: |
197 // fail: function (e, data) {}, // .bind('fileuploadfail', func); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
198 |
0 | 199 // Callback for completed (success, abort or error) requests: |
200 // always: function (e, data) {}, // .bind('fileuploadalways', func); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
201 |
0 | 202 // Callback for upload progress events: |
203 // progress: function (e, data) {}, // .bind('fileuploadprogress', func); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
204 |
0 | 205 // Callback for global upload progress events: |
206 // progressall: function (e, data) {}, // .bind('fileuploadprogressall', func); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
207 |
0 | 208 // Callback for uploads start, equivalent to the global ajaxStart event: |
209 // start: function (e) {}, // .bind('fileuploadstart', func); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
210 |
0 | 211 // Callback for uploads stop, equivalent to the global ajaxStop event: |
212 // stop: function (e) {}, // .bind('fileuploadstop', func); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
213 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
214 // Callback for change events of the fileInput(s): |
0 | 215 // change: function (e, data) {}, // .bind('fileuploadchange', func); |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
216 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
217 // Callback for paste events to the pasteZone(s): |
0 | 218 // paste: function (e, data) {}, // .bind('fileuploadpaste', func); |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
219 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
220 // Callback for drop events of the dropZone(s): |
0 | 221 // drop: function (e, data) {}, // .bind('fileuploaddrop', func); |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
222 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
223 // Callback for dragover events of the dropZone(s): |
0 | 224 // dragover: function (e) {}, // .bind('fileuploaddragover', func); |
225 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
226 // Callback for the start of each chunk upload request: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
227 // chunksend: function (e, data) {}, // .bind('fileuploadchunksend', func); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
228 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
229 // Callback for successful chunk uploads: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
230 // chunkdone: function (e, data) {}, // .bind('fileuploadchunkdone', func); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
231 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
232 // Callback for failed (abort or error) chunk uploads: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
233 // chunkfail: function (e, data) {}, // .bind('fileuploadchunkfail', func); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
234 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
235 // Callback for completed (success, abort or error) chunk upload requests: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
236 // chunkalways: function (e, data) {}, // .bind('fileuploadchunkalways', func); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
237 |
0 | 238 // The plugin options are used as settings object for the ajax calls. |
239 // The following are jQuery ajax settings required for the file uploads: | |
240 processData: false, | |
241 contentType: false, | |
242 cache: false | |
243 }, | |
244 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
245 // A list of options that require reinitializing event listeners and/or |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
246 // special initialization code: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
247 _specialOptions: [ |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
248 'fileInput', |
0 | 249 'dropZone', |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
250 'pasteZone', |
0 | 251 'multipart', |
252 'forceIframeTransport' | |
253 ], | |
254 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
255 _blobSlice: $.support.blobSlice && function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
256 var slice = this.slice || this.webkitSlice || this.mozSlice; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
257 return slice.apply(this, arguments); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
258 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
259 |
0 | 260 _BitrateTimer: function () { |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
261 this.timestamp = ((Date.now) ? Date.now() : (new Date()).getTime()); |
0 | 262 this.loaded = 0; |
263 this.bitrate = 0; | |
264 this.getBitrate = function (now, loaded, interval) { | |
265 var timeDiff = now - this.timestamp; | |
266 if (!this.bitrate || !interval || timeDiff > interval) { | |
267 this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8; | |
268 this.loaded = loaded; | |
269 this.timestamp = now; | |
270 } | |
271 return this.bitrate; | |
272 }; | |
273 }, | |
274 | |
275 _isXHRUpload: function (options) { | |
276 return !options.forceIframeTransport && | |
277 ((!options.multipart && $.support.xhrFileUpload) || | |
278 $.support.xhrFormDataFileUpload); | |
279 }, | |
280 | |
281 _getFormData: function (options) { | |
282 var formData; | |
283 if (typeof options.formData === 'function') { | |
284 return options.formData(options.form); | |
285 } | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
286 if ($.isArray(options.formData)) { |
0 | 287 return options.formData; |
288 } | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
289 if ($.type(options.formData) === 'object') { |
0 | 290 formData = []; |
291 $.each(options.formData, function (name, value) { | |
292 formData.push({name: name, value: value}); | |
293 }); | |
294 return formData; | |
295 } | |
296 return []; | |
297 }, | |
298 | |
299 _getTotal: function (files) { | |
300 var total = 0; | |
301 $.each(files, function (index, file) { | |
302 total += file.size || 1; | |
303 }); | |
304 return total; | |
305 }, | |
306 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
307 _initProgressObject: function (obj) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
308 var progress = { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
309 loaded: 0, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
310 total: 0, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
311 bitrate: 0 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
312 }; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
313 if (obj._progress) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
314 $.extend(obj._progress, progress); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
315 } else { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
316 obj._progress = progress; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
317 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
318 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
319 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
320 _initResponseObject: function (obj) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
321 var prop; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
322 if (obj._response) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
323 for (prop in obj._response) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
324 if (obj._response.hasOwnProperty(prop)) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
325 delete obj._response[prop]; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
326 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
327 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
328 } else { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
329 obj._response = {}; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
330 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
331 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
332 |
0 | 333 _onProgress: function (e, data) { |
334 if (e.lengthComputable) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
335 var now = ((Date.now) ? Date.now() : (new Date()).getTime()), |
0 | 336 loaded; |
337 if (data._time && data.progressInterval && | |
338 (now - data._time < data.progressInterval) && | |
339 e.loaded !== e.total) { | |
340 return; | |
341 } | |
342 data._time = now; | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
343 loaded = Math.floor( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
344 e.loaded / e.total * (data.chunkSize || data._progress.total) |
0 | 345 ) + (data.uploadedBytes || 0); |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
346 // Add the difference from the previously loaded state |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
347 // to the global loaded counter: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
348 this._progress.loaded += (loaded - data._progress.loaded); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
349 this._progress.bitrate = this._bitrateTimer.getBitrate( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
350 now, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
351 this._progress.loaded, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
352 data.bitrateInterval |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
353 ); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
354 data._progress.loaded = data.loaded = loaded; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
355 data._progress.bitrate = data.bitrate = data._bitrateTimer.getBitrate( |
0 | 356 now, |
357 loaded, | |
358 data.bitrateInterval | |
359 ); | |
360 // Trigger a custom progress event with a total data property set | |
361 // to the file size(s) of the current upload and a loaded data | |
362 // property calculated accordingly: | |
363 this._trigger('progress', e, data); | |
364 // Trigger a global progress event for all current file uploads, | |
365 // including ajax calls queued for sequential file uploads: | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
366 this._trigger('progressall', e, this._progress); |
0 | 367 } |
368 }, | |
369 | |
370 _initProgressListener: function (options) { | |
371 var that = this, | |
372 xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); | |
373 // Accesss to the native XHR object is required to add event listeners | |
374 // for the upload progress event: | |
375 if (xhr.upload) { | |
376 $(xhr.upload).bind('progress', function (e) { | |
377 var oe = e.originalEvent; | |
378 // Make sure the progress event properties get copied over: | |
379 e.lengthComputable = oe.lengthComputable; | |
380 e.loaded = oe.loaded; | |
381 e.total = oe.total; | |
382 that._onProgress(e, options); | |
383 }); | |
384 options.xhr = function () { | |
385 return xhr; | |
386 }; | |
387 } | |
388 }, | |
389 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
390 _isInstanceOf: function (type, obj) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
391 // Cross-frame instanceof check |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
392 return Object.prototype.toString.call(obj) === '[object ' + type + ']'; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
393 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
394 |
0 | 395 _initXHRData: function (options) { |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
396 var that = this, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
397 formData, |
0 | 398 file = options.files[0], |
399 // Ignore non-multipart setting if not supported: | |
400 multipart = options.multipart || !$.support.xhrFileUpload, | |
401 paramName = options.paramName[0]; | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
402 options.headers = options.headers || {}; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
403 if (options.contentRange) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
404 options.headers['Content-Range'] = options.contentRange; |
0 | 405 } |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
406 if (!multipart || options.blob || !this._isInstanceOf('File', file)) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
407 options.headers['Content-Disposition'] = 'attachment; filename="' + |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
408 encodeURI(file.name) + '"'; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
409 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
410 if (!multipart) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
411 options.contentType = file.type; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
412 options.data = options.blob || file; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
413 } else if ($.support.xhrFormDataFileUpload) { |
0 | 414 if (options.postMessage) { |
415 // window.postMessage does not allow sending FormData | |
416 // objects, so we just add the File/Blob objects to | |
417 // the formData array and let the postMessage window | |
418 // create the FormData object out of this array: | |
419 formData = this._getFormData(options); | |
420 if (options.blob) { | |
421 formData.push({ | |
422 name: paramName, | |
423 value: options.blob | |
424 }); | |
425 } else { | |
426 $.each(options.files, function (index, file) { | |
427 formData.push({ | |
428 name: options.paramName[index] || paramName, | |
429 value: file | |
430 }); | |
431 }); | |
432 } | |
433 } else { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
434 if (that._isInstanceOf('FormData', options.formData)) { |
0 | 435 formData = options.formData; |
436 } else { | |
437 formData = new FormData(); | |
438 $.each(this._getFormData(options), function (index, field) { | |
439 formData.append(field.name, field.value); | |
440 }); | |
441 } | |
442 if (options.blob) { | |
443 formData.append(paramName, options.blob, file.name); | |
444 } else { | |
445 $.each(options.files, function (index, file) { | |
446 // This check allows the tests to run with | |
447 // dummy objects: | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
448 if (that._isInstanceOf('File', file) || |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
449 that._isInstanceOf('Blob', file)) { |
0 | 450 formData.append( |
451 options.paramName[index] || paramName, | |
452 file, | |
453 file.name | |
454 ); | |
455 } | |
456 }); | |
457 } | |
458 } | |
459 options.data = formData; | |
460 } | |
461 // Blob reference is not needed anymore, free memory: | |
462 options.blob = null; | |
463 }, | |
464 | |
465 _initIframeSettings: function (options) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
466 var targetHost = $('<a></a>').prop('href', options.url).prop('host'); |
0 | 467 // Setting the dataType to iframe enables the iframe transport: |
468 options.dataType = 'iframe ' + (options.dataType || ''); | |
469 // The iframe transport accepts a serialized array as form data: | |
470 options.formData = this._getFormData(options); | |
471 // Add redirect url to form data on cross-domain uploads: | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
472 if (options.redirect && targetHost && targetHost !== location.host) { |
0 | 473 options.formData.push({ |
474 name: options.redirectParamName || 'redirect', | |
475 value: options.redirect | |
476 }); | |
477 } | |
478 }, | |
479 | |
480 _initDataSettings: function (options) { | |
481 if (this._isXHRUpload(options)) { | |
482 if (!this._chunkedUpload(options, true)) { | |
483 if (!options.data) { | |
484 this._initXHRData(options); | |
485 } | |
486 this._initProgressListener(options); | |
487 } | |
488 if (options.postMessage) { | |
489 // Setting the dataType to postmessage enables the | |
490 // postMessage transport: | |
491 options.dataType = 'postmessage ' + (options.dataType || ''); | |
492 } | |
493 } else { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
494 this._initIframeSettings(options); |
0 | 495 } |
496 }, | |
497 | |
498 _getParamName: function (options) { | |
499 var fileInput = $(options.fileInput), | |
500 paramName = options.paramName; | |
501 if (!paramName) { | |
502 paramName = []; | |
503 fileInput.each(function () { | |
504 var input = $(this), | |
505 name = input.prop('name') || 'files[]', | |
506 i = (input.prop('files') || [1]).length; | |
507 while (i) { | |
508 paramName.push(name); | |
509 i -= 1; | |
510 } | |
511 }); | |
512 if (!paramName.length) { | |
513 paramName = [fileInput.prop('name') || 'files[]']; | |
514 } | |
515 } else if (!$.isArray(paramName)) { | |
516 paramName = [paramName]; | |
517 } | |
518 return paramName; | |
519 }, | |
520 | |
521 _initFormSettings: function (options) { | |
522 // Retrieve missing options from the input field and the | |
523 // associated form, if available: | |
524 if (!options.form || !options.form.length) { | |
525 options.form = $(options.fileInput.prop('form')); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
526 // If the given file input doesn't have an associated form, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
527 // use the default widget file input's form: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
528 if (!options.form.length) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
529 options.form = $(this.options.fileInput.prop('form')); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
530 } |
0 | 531 } |
532 options.paramName = this._getParamName(options); | |
533 if (!options.url) { | |
534 options.url = options.form.prop('action') || location.href; | |
535 } | |
536 // The HTTP request method must be "POST" or "PUT": | |
537 options.type = (options.type || options.form.prop('method') || '') | |
538 .toUpperCase(); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
539 if (options.type !== 'POST' && options.type !== 'PUT' && |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
540 options.type !== 'PATCH') { |
0 | 541 options.type = 'POST'; |
542 } | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
543 if (!options.formAcceptCharset) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
544 options.formAcceptCharset = options.form.attr('accept-charset'); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
545 } |
0 | 546 }, |
547 | |
548 _getAJAXSettings: function (data) { | |
549 var options = $.extend({}, this.options, data); | |
550 this._initFormSettings(options); | |
551 this._initDataSettings(options); | |
552 return options; | |
553 }, | |
554 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
555 // jQuery 1.6 doesn't provide .state(), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
556 // while jQuery 1.8+ removed .isRejected() and .isResolved(): |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
557 _getDeferredState: function (deferred) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
558 if (deferred.state) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
559 return deferred.state(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
560 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
561 if (deferred.isResolved()) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
562 return 'resolved'; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
563 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
564 if (deferred.isRejected()) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
565 return 'rejected'; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
566 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
567 return 'pending'; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
568 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
569 |
0 | 570 // Maps jqXHR callbacks to the equivalent |
571 // methods of the given Promise object: | |
572 _enhancePromise: function (promise) { | |
573 promise.success = promise.done; | |
574 promise.error = promise.fail; | |
575 promise.complete = promise.always; | |
576 return promise; | |
577 }, | |
578 | |
579 // Creates and returns a Promise object enhanced with | |
580 // the jqXHR methods abort, success, error and complete: | |
581 _getXHRPromise: function (resolveOrReject, context, args) { | |
582 var dfd = $.Deferred(), | |
583 promise = dfd.promise(); | |
584 context = context || this.options.context || promise; | |
585 if (resolveOrReject === true) { | |
586 dfd.resolveWith(context, args); | |
587 } else if (resolveOrReject === false) { | |
588 dfd.rejectWith(context, args); | |
589 } | |
590 promise.abort = dfd.promise; | |
591 return this._enhancePromise(promise); | |
592 }, | |
593 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
594 // Adds convenience methods to the data callback argument: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
595 _addConvenienceMethods: function (e, data) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
596 var that = this, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
597 getPromise = function (data) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
598 return $.Deferred().resolveWith(that, [data]).promise(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
599 }; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
600 data.process = function (resolveFunc, rejectFunc) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
601 if (resolveFunc || rejectFunc) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
602 data._processQueue = this._processQueue = |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
603 (this._processQueue || getPromise(this)) |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
604 .pipe(resolveFunc, rejectFunc); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
605 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
606 return this._processQueue || getPromise(this); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
607 }; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
608 data.submit = function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
609 if (this.state() !== 'pending') { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
610 data.jqXHR = this.jqXHR = |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
611 (that._trigger('submit', e, this) !== false) && |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
612 that._onSend(e, this); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
613 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
614 return this.jqXHR || that._getXHRPromise(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
615 }; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
616 data.abort = function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
617 if (this.jqXHR) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
618 return this.jqXHR.abort(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
619 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
620 return that._getXHRPromise(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
621 }; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
622 data.state = function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
623 if (this.jqXHR) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
624 return that._getDeferredState(this.jqXHR); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
625 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
626 if (this._processQueue) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
627 return that._getDeferredState(this._processQueue); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
628 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
629 }; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
630 data.progress = function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
631 return this._progress; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
632 }; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
633 data.response = function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
634 return this._response; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
635 }; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
636 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
637 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
638 // Parses the Range header from the server response |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
639 // and returns the uploaded bytes: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
640 _getUploadedBytes: function (jqXHR) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
641 var range = jqXHR.getResponseHeader('Range'), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
642 parts = range && range.split('-'), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
643 upperBytesPos = parts && parts.length > 1 && |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
644 parseInt(parts[1], 10); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
645 return upperBytesPos && upperBytesPos + 1; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
646 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
647 |
0 | 648 // Uploads a file in multiple, sequential requests |
649 // by splitting the file up in multiple blob chunks. | |
650 // If the second parameter is true, only tests if the file | |
651 // should be uploaded in chunks, but does not invoke any | |
652 // upload requests: | |
653 _chunkedUpload: function (options, testOnly) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
654 options.uploadedBytes = options.uploadedBytes || 0; |
0 | 655 var that = this, |
656 file = options.files[0], | |
657 fs = file.size, | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
658 ub = options.uploadedBytes, |
0 | 659 mcs = options.maxChunkSize || fs, |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
660 slice = this._blobSlice, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
661 dfd = $.Deferred(), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
662 promise = dfd.promise(), |
0 | 663 jqXHR, |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
664 upload; |
0 | 665 if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) || |
666 options.data) { | |
667 return false; | |
668 } | |
669 if (testOnly) { | |
670 return true; | |
671 } | |
672 if (ub >= fs) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
673 file.error = options.i18n('uploadedBytes'); |
0 | 674 return this._getXHRPromise( |
675 false, | |
676 options.context, | |
677 [null, 'error', file.error] | |
678 ); | |
679 } | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
680 // The chunk upload method: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
681 upload = function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
682 // Clone the options object for each chunk upload: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
683 var o = $.extend({}, options), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
684 currentLoaded = o._progress.loaded; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
685 o.blob = slice.call( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
686 file, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
687 ub, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
688 ub + mcs, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
689 file.type |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
690 ); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
691 // Store the current chunk size, as the blob itself |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
692 // will be dereferenced after data processing: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
693 o.chunkSize = o.blob.size; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
694 // Expose the chunk bytes position range: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
695 o.contentRange = 'bytes ' + ub + '-' + |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
696 (ub + o.chunkSize - 1) + '/' + fs; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
697 // Process the upload data (the blob and potential form data): |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
698 that._initXHRData(o); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
699 // Add progress listeners for this chunk upload: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
700 that._initProgressListener(o); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
701 jqXHR = ((that._trigger('chunksend', null, o) !== false && $.ajax(o)) || |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
702 that._getXHRPromise(false, o.context)) |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
703 .done(function (result, textStatus, jqXHR) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
704 ub = that._getUploadedBytes(jqXHR) || |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
705 (ub + o.chunkSize); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
706 // Create a progress event if no final progress event |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
707 // with loaded equaling total has been triggered |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
708 // for this chunk: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
709 if (currentLoaded + o.chunkSize - o._progress.loaded) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
710 that._onProgress($.Event('progress', { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
711 lengthComputable: true, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
712 loaded: ub - o.uploadedBytes, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
713 total: ub - o.uploadedBytes |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
714 }), o); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
715 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
716 options.uploadedBytes = o.uploadedBytes = ub; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
717 o.result = result; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
718 o.textStatus = textStatus; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
719 o.jqXHR = jqXHR; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
720 that._trigger('chunkdone', null, o); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
721 that._trigger('chunkalways', null, o); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
722 if (ub < fs) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
723 // File upload not yet complete, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
724 // continue with the next chunk: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
725 upload(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
726 } else { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
727 dfd.resolveWith( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
728 o.context, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
729 [result, textStatus, jqXHR] |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
730 ); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
731 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
732 }) |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
733 .fail(function (jqXHR, textStatus, errorThrown) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
734 o.jqXHR = jqXHR; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
735 o.textStatus = textStatus; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
736 o.errorThrown = errorThrown; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
737 that._trigger('chunkfail', null, o); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
738 that._trigger('chunkalways', null, o); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
739 dfd.rejectWith( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
740 o.context, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
741 [jqXHR, textStatus, errorThrown] |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
742 ); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
743 }); |
0 | 744 }; |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
745 this._enhancePromise(promise); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
746 promise.abort = function () { |
0 | 747 return jqXHR.abort(); |
748 }; | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
749 upload(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
750 return promise; |
0 | 751 }, |
752 | |
753 _beforeSend: function (e, data) { | |
754 if (this._active === 0) { | |
755 // the start callback is triggered when an upload starts | |
756 // and no other uploads are currently running, | |
757 // equivalent to the global ajaxStart event: | |
758 this._trigger('start'); | |
759 // Set timer for global bitrate progress calculation: | |
760 this._bitrateTimer = new this._BitrateTimer(); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
761 // Reset the global progress values: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
762 this._progress.loaded = this._progress.total = 0; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
763 this._progress.bitrate = 0; |
0 | 764 } |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
765 // Make sure the container objects for the .response() and |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
766 // .progress() methods on the data object are available |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
767 // and reset to their initial state: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
768 this._initResponseObject(data); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
769 this._initProgressObject(data); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
770 data._progress.loaded = data.loaded = data.uploadedBytes || 0; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
771 data._progress.total = data.total = this._getTotal(data.files) || 1; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
772 data._progress.bitrate = data.bitrate = 0; |
0 | 773 this._active += 1; |
774 // Initialize the global progress values: | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
775 this._progress.loaded += data.loaded; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
776 this._progress.total += data.total; |
0 | 777 }, |
778 | |
779 _onDone: function (result, textStatus, jqXHR, options) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
780 var total = options._progress.total, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
781 response = options._response; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
782 if (options._progress.loaded < total) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
783 // Create a progress event if no final progress event |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
784 // with loaded equaling total has been triggered: |
0 | 785 this._onProgress($.Event('progress', { |
786 lengthComputable: true, | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
787 loaded: total, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
788 total: total |
0 | 789 }), options); |
790 } | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
791 response.result = options.result = result; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
792 response.textStatus = options.textStatus = textStatus; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
793 response.jqXHR = options.jqXHR = jqXHR; |
0 | 794 this._trigger('done', null, options); |
795 }, | |
796 | |
797 _onFail: function (jqXHR, textStatus, errorThrown, options) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
798 var response = options._response; |
0 | 799 if (options.recalculateProgress) { |
800 // Remove the failed (error or abort) file upload from | |
801 // the global progress calculation: | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
802 this._progress.loaded -= options._progress.loaded; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
803 this._progress.total -= options._progress.total; |
0 | 804 } |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
805 response.jqXHR = options.jqXHR = jqXHR; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
806 response.textStatus = options.textStatus = textStatus; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
807 response.errorThrown = options.errorThrown = errorThrown; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
808 this._trigger('fail', null, options); |
0 | 809 }, |
810 | |
811 _onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
812 // jqXHRorResult, textStatus and jqXHRorError are added to the |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
813 // options object via done and fail callbacks |
0 | 814 this._trigger('always', null, options); |
815 }, | |
816 | |
817 _onSend: function (e, data) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
818 if (!data.submit) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
819 this._addConvenienceMethods(e, data); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
820 } |
0 | 821 var that = this, |
822 jqXHR, | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
823 aborted, |
0 | 824 slot, |
825 pipe, | |
826 options = that._getAJAXSettings(data), | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
827 send = function () { |
0 | 828 that._sending += 1; |
829 // Set timer for bitrate progress calculation: | |
830 options._bitrateTimer = new that._BitrateTimer(); | |
831 jqXHR = jqXHR || ( | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
832 ((aborted || that._trigger('send', e, options) === false) && |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
833 that._getXHRPromise(false, options.context, aborted)) || |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
834 that._chunkedUpload(options) || $.ajax(options) |
0 | 835 ).done(function (result, textStatus, jqXHR) { |
836 that._onDone(result, textStatus, jqXHR, options); | |
837 }).fail(function (jqXHR, textStatus, errorThrown) { | |
838 that._onFail(jqXHR, textStatus, errorThrown, options); | |
839 }).always(function (jqXHRorResult, textStatus, jqXHRorError) { | |
840 that._onAlways( | |
841 jqXHRorResult, | |
842 textStatus, | |
843 jqXHRorError, | |
844 options | |
845 ); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
846 that._sending -= 1; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
847 that._active -= 1; |
0 | 848 if (options.limitConcurrentUploads && |
849 options.limitConcurrentUploads > that._sending) { | |
850 // Start the next queued upload, | |
851 // that has not been aborted: | |
852 var nextSlot = that._slots.shift(); | |
853 while (nextSlot) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
854 if (that._getDeferredState(nextSlot) === 'pending') { |
0 | 855 nextSlot.resolve(); |
856 break; | |
857 } | |
858 nextSlot = that._slots.shift(); | |
859 } | |
860 } | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
861 if (that._active === 0) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
862 // The stop callback is triggered when all uploads have |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
863 // been completed, equivalent to the global ajaxStop event: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
864 that._trigger('stop'); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
865 } |
0 | 866 }); |
867 return jqXHR; | |
868 }; | |
869 this._beforeSend(e, options); | |
870 if (this.options.sequentialUploads || | |
871 (this.options.limitConcurrentUploads && | |
872 this.options.limitConcurrentUploads <= this._sending)) { | |
873 if (this.options.limitConcurrentUploads > 1) { | |
874 slot = $.Deferred(); | |
875 this._slots.push(slot); | |
876 pipe = slot.pipe(send); | |
877 } else { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
878 this._sequence = this._sequence.pipe(send, send); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
879 pipe = this._sequence; |
0 | 880 } |
881 // Return the piped Promise object, enhanced with an abort method, | |
882 // which is delegated to the jqXHR object of the current upload, | |
883 // and jqXHR callbacks mapped to the equivalent Promise methods: | |
884 pipe.abort = function () { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
885 aborted = [undefined, 'abort', 'abort']; |
0 | 886 if (!jqXHR) { |
887 if (slot) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
888 slot.rejectWith(options.context, aborted); |
0 | 889 } |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
890 return send(); |
0 | 891 } |
892 return jqXHR.abort(); | |
893 }; | |
894 return this._enhancePromise(pipe); | |
895 } | |
896 return send(); | |
897 }, | |
898 | |
899 _onAdd: function (e, data) { | |
900 var that = this, | |
901 result = true, | |
902 options = $.extend({}, this.options, data), | |
903 limit = options.limitMultiFileUploads, | |
904 paramName = this._getParamName(options), | |
905 paramNameSet, | |
906 paramNameSlice, | |
907 fileSet, | |
908 i; | |
909 if (!(options.singleFileUploads || limit) || | |
910 !this._isXHRUpload(options)) { | |
911 fileSet = [data.files]; | |
912 paramNameSet = [paramName]; | |
913 } else if (!options.singleFileUploads && limit) { | |
914 fileSet = []; | |
915 paramNameSet = []; | |
916 for (i = 0; i < data.files.length; i += limit) { | |
917 fileSet.push(data.files.slice(i, i + limit)); | |
918 paramNameSlice = paramName.slice(i, i + limit); | |
919 if (!paramNameSlice.length) { | |
920 paramNameSlice = paramName; | |
921 } | |
922 paramNameSet.push(paramNameSlice); | |
923 } | |
924 } else { | |
925 paramNameSet = paramName; | |
926 } | |
927 data.originalFiles = data.files; | |
928 $.each(fileSet || data.files, function (index, element) { | |
929 var newData = $.extend({}, data); | |
930 newData.files = fileSet ? element : [element]; | |
931 newData.paramName = paramNameSet[index]; | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
932 that._initResponseObject(newData); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
933 that._initProgressObject(newData); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
934 that._addConvenienceMethods(e, newData); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
935 result = that._trigger('add', e, newData); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
936 return result; |
0 | 937 }); |
938 return result; | |
939 }, | |
940 | |
941 _replaceFileInput: function (input) { | |
942 var inputClone = input.clone(true); | |
943 $('<form></form>').append(inputClone)[0].reset(); | |
944 // Detaching allows to insert the fileInput on another form | |
945 // without loosing the file input value: | |
946 input.after(inputClone).detach(); | |
947 // Avoid memory leaks with the detached file input: | |
948 $.cleanData(input.unbind('remove')); | |
949 // Replace the original file input element in the fileInput | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
950 // elements set with the clone, which has been copied including |
0 | 951 // event handlers: |
952 this.options.fileInput = this.options.fileInput.map(function (i, el) { | |
953 if (el === input[0]) { | |
954 return inputClone[0]; | |
955 } | |
956 return el; | |
957 }); | |
958 // If the widget has been initialized on the file input itself, | |
959 // override this.element with the file input clone: | |
960 if (input[0] === this.element[0]) { | |
961 this.element = inputClone; | |
962 } | |
963 }, | |
964 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
965 _handleFileTreeEntry: function (entry, path) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
966 var that = this, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
967 dfd = $.Deferred(), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
968 errorHandler = function (e) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
969 if (e && !e.entry) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
970 e.entry = entry; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
971 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
972 // Since $.when returns immediately if one |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
973 // Deferred is rejected, we use resolve instead. |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
974 // This allows valid files and invalid items |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
975 // to be returned together in one set: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
976 dfd.resolve([e]); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
977 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
978 dirReader; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
979 path = path || ''; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
980 if (entry.isFile) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
981 if (entry._file) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
982 // Workaround for Chrome bug #149735 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
983 entry._file.relativePath = path; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
984 dfd.resolve(entry._file); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
985 } else { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
986 entry.file(function (file) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
987 file.relativePath = path; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
988 dfd.resolve(file); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
989 }, errorHandler); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
990 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
991 } else if (entry.isDirectory) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
992 dirReader = entry.createReader(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
993 dirReader.readEntries(function (entries) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
994 that._handleFileTreeEntries( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
995 entries, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
996 path + entry.name + '/' |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
997 ).done(function (files) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
998 dfd.resolve(files); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
999 }).fail(errorHandler); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1000 }, errorHandler); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1001 } else { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1002 // Return an empy list for file system items |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1003 // other than files or directories: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1004 dfd.resolve([]); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1005 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1006 return dfd.promise(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1007 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1008 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1009 _handleFileTreeEntries: function (entries, path) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1010 var that = this; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1011 return $.when.apply( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1012 $, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1013 $.map(entries, function (entry) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1014 return that._handleFileTreeEntry(entry, path); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1015 }) |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1016 ).pipe(function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1017 return Array.prototype.concat.apply( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1018 [], |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1019 arguments |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1020 ); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1021 }); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1022 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1023 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1024 _getDroppedFiles: function (dataTransfer) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1025 dataTransfer = dataTransfer || {}; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1026 var items = dataTransfer.items; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1027 if (items && items.length && (items[0].webkitGetAsEntry || |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1028 items[0].getAsEntry)) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1029 return this._handleFileTreeEntries( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1030 $.map(items, function (item) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1031 var entry; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1032 if (item.webkitGetAsEntry) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1033 entry = item.webkitGetAsEntry(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1034 if (entry) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1035 // Workaround for Chrome bug #149735: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1036 entry._file = item.getAsFile(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1037 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1038 return entry; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1039 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1040 return item.getAsEntry(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1041 }) |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1042 ); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1043 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1044 return $.Deferred().resolve( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1045 $.makeArray(dataTransfer.files) |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1046 ).promise(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1047 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1048 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1049 _getSingleFileInputFiles: function (fileInput) { |
0 | 1050 fileInput = $(fileInput); |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1051 var entries = fileInput.prop('webkitEntries') || |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1052 fileInput.prop('entries'), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1053 files, |
0 | 1054 value; |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1055 if (entries && entries.length) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1056 return this._handleFileTreeEntries(entries); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1057 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1058 files = $.makeArray(fileInput.prop('files')); |
0 | 1059 if (!files.length) { |
1060 value = fileInput.prop('value'); | |
1061 if (!value) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1062 return $.Deferred().resolve([]).promise(); |
0 | 1063 } |
1064 // If the files property is not available, the browser does not | |
1065 // support the File API and we add a pseudo File object with | |
1066 // the input value as name with path information removed: | |
1067 files = [{name: value.replace(/^.*\\/, '')}]; | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1068 } else if (files[0].name === undefined && files[0].fileName) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1069 // File normalization for Safari 4 and Firefox 3: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1070 $.each(files, function (index, file) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1071 file.name = file.fileName; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1072 file.size = file.fileSize; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1073 }); |
0 | 1074 } |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1075 return $.Deferred().resolve(files).promise(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1076 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1077 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1078 _getFileInputFiles: function (fileInput) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1079 if (!(fileInput instanceof $) || fileInput.length === 1) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1080 return this._getSingleFileInputFiles(fileInput); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1081 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1082 return $.when.apply( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1083 $, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1084 $.map(fileInput, this._getSingleFileInputFiles) |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1085 ).pipe(function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1086 return Array.prototype.concat.apply( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1087 [], |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1088 arguments |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1089 ); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1090 }); |
0 | 1091 }, |
1092 | |
1093 _onChange: function (e) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1094 var that = this, |
0 | 1095 data = { |
1096 fileInput: $(e.target), | |
1097 form: $(e.target.form) | |
1098 }; | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1099 this._getFileInputFiles(data.fileInput).always(function (files) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1100 data.files = files; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1101 if (that.options.replaceFileInput) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1102 that._replaceFileInput(data.fileInput); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1103 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1104 if (that._trigger('change', e, data) !== false) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1105 that._onAdd(e, data); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1106 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1107 }); |
0 | 1108 }, |
1109 | |
1110 _onPaste: function (e) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1111 var items = e.originalEvent && e.originalEvent.clipboardData && |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1112 e.originalEvent.clipboardData.items, |
0 | 1113 data = {files: []}; |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1114 if (items && items.length) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1115 $.each(items, function (index, item) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1116 var file = item.getAsFile && item.getAsFile(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1117 if (file) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1118 data.files.push(file); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1119 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1120 }); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1121 if (this._trigger('paste', e, data) === false || |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1122 this._onAdd(e, data) === false) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1123 return false; |
0 | 1124 } |
1125 } | |
1126 }, | |
1127 | |
1128 _onDrop: function (e) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1129 e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1130 var that = this, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1131 dataTransfer = e.dataTransfer, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1132 data = {}; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1133 if (dataTransfer && dataTransfer.files && dataTransfer.files.length) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1134 e.preventDefault(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1135 this._getDroppedFiles(dataTransfer).always(function (files) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1136 data.files = files; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1137 if (that._trigger('drop', e, data) !== false) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1138 that._onAdd(e, data); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1139 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1140 }); |
0 | 1141 } |
1142 }, | |
1143 | |
1144 _onDragOver: function (e) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1145 e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1146 var dataTransfer = e.dataTransfer; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1147 if (dataTransfer) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1148 if (this._trigger('dragover', e) === false) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1149 return false; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1150 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1151 if ($.inArray('Files', dataTransfer.types) !== -1) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1152 dataTransfer.dropEffect = 'copy'; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1153 e.preventDefault(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1154 } |
0 | 1155 } |
1156 }, | |
1157 | |
1158 _initEventHandlers: function () { | |
1159 if (this._isXHRUpload(this.options)) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1160 this._on(this.options.dropZone, { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1161 dragover: this._onDragOver, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1162 drop: this._onDrop |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1163 }); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1164 this._on(this.options.pasteZone, { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1165 paste: this._onPaste |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1166 }); |
0 | 1167 } |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1168 if ($.support.fileInput) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1169 this._on(this.options.fileInput, { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1170 change: this._onChange |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1171 }); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1172 } |
0 | 1173 }, |
1174 | |
1175 _destroyEventHandlers: function () { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1176 this._off(this.options.dropZone, 'dragover drop'); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1177 this._off(this.options.pasteZone, 'paste'); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1178 this._off(this.options.fileInput, 'change'); |
0 | 1179 }, |
1180 | |
1181 _setOption: function (key, value) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1182 var reinit = $.inArray(key, this._specialOptions) !== -1; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1183 if (reinit) { |
0 | 1184 this._destroyEventHandlers(); |
1185 } | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1186 this._super(key, value); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1187 if (reinit) { |
0 | 1188 this._initSpecialOptions(); |
1189 this._initEventHandlers(); | |
1190 } | |
1191 }, | |
1192 | |
1193 _initSpecialOptions: function () { | |
1194 var options = this.options; | |
1195 if (options.fileInput === undefined) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1196 options.fileInput = this.element.is('input[type="file"]') ? |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1197 this.element : this.element.find('input[type="file"]'); |
0 | 1198 } else if (!(options.fileInput instanceof $)) { |
1199 options.fileInput = $(options.fileInput); | |
1200 } | |
1201 if (!(options.dropZone instanceof $)) { | |
1202 options.dropZone = $(options.dropZone); | |
1203 } | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1204 if (!(options.pasteZone instanceof $)) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1205 options.pasteZone = $(options.pasteZone); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1206 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1207 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1208 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1209 _getRegExp: function (str) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1210 var parts = str.split('/'), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1211 modifiers = parts.pop(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1212 parts.shift(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1213 return new RegExp(parts.join('/'), modifiers); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1214 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1215 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1216 _isRegExpOption: function (key, value) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1217 return key !== 'url' && $.type(value) === 'string' && |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1218 /^\/.*\/[igm]{0,3}$/.test(value); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1219 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1220 |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1221 _initDataAttributes: function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1222 var that = this, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1223 options = this.options; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1224 // Initialize options set via HTML5 data-attributes: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1225 $.each( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1226 $(this.element[0].cloneNode(false)).data(), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1227 function (key, value) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1228 if (that._isRegExpOption(key, value)) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1229 value = that._getRegExp(value); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1230 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1231 options[key] = value; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1232 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1233 ); |
0 | 1234 }, |
1235 | |
1236 _create: function () { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1237 this._initDataAttributes(); |
0 | 1238 this._initSpecialOptions(); |
1239 this._slots = []; | |
1240 this._sequence = this._getXHRPromise(true); | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1241 this._sending = this._active = 0; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1242 this._initProgressObject(this); |
0 | 1243 this._initEventHandlers(); |
1244 }, | |
1245 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1246 // This method is exposed to the widget API and allows to query |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1247 // the number of active uploads: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1248 active: function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1249 return this._active; |
0 | 1250 }, |
1251 | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1252 // This method is exposed to the widget API and allows to query |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1253 // the widget upload progress. |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1254 // It returns an object with loaded, total and bitrate properties |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1255 // for the running uploads: |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1256 progress: function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1257 return this._progress; |
0 | 1258 }, |
1259 | |
1260 // This method is exposed to the widget API and allows adding files | |
1261 // using the fileupload API. The data parameter accepts an object which | |
1262 // must have a files property and can contain additional options: | |
1263 // .fileupload('add', {files: filesList}); | |
1264 add: function (data) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1265 var that = this; |
0 | 1266 if (!data || this.options.disabled) { |
1267 return; | |
1268 } | |
1269 if (data.fileInput && !data.files) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1270 this._getFileInputFiles(data.fileInput).always(function (files) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1271 data.files = files; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1272 that._onAdd(null, data); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1273 }); |
0 | 1274 } else { |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1275 data.files = $.makeArray(data.files); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1276 this._onAdd(null, data); |
0 | 1277 } |
1278 }, | |
1279 | |
1280 // This method is exposed to the widget API and allows sending files | |
1281 // using the fileupload API. The data parameter accepts an object which | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1282 // must have a files or fileInput property and can contain additional options: |
0 | 1283 // .fileupload('send', {files: filesList}); |
1284 // The method returns a Promise object for the file upload call. | |
1285 send: function (data) { | |
1286 if (data && !this.options.disabled) { | |
1287 if (data.fileInput && !data.files) { | |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1288 var that = this, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1289 dfd = $.Deferred(), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1290 promise = dfd.promise(), |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1291 jqXHR, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1292 aborted; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1293 promise.abort = function () { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1294 aborted = true; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1295 if (jqXHR) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1296 return jqXHR.abort(); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1297 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1298 dfd.reject(null, 'abort', 'abort'); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1299 return promise; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1300 }; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1301 this._getFileInputFiles(data.fileInput).always( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1302 function (files) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1303 if (aborted) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1304 return; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1305 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1306 data.files = files; |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1307 jqXHR = that._onSend(null, data).then( |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1308 function (result, textStatus, jqXHR) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1309 dfd.resolve(result, textStatus, jqXHR); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1310 }, |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1311 function (jqXHR, textStatus, errorThrown) { |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1312 dfd.reject(jqXHR, textStatus, errorThrown); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1313 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1314 ); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1315 } |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1316 ); |
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1317 return this._enhancePromise(promise); |
0 | 1318 } |
3066
5713952f60c0
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents:
57
diff
changeset
|
1319 data.files = $.makeArray(data.files); |
0 | 1320 if (data.files.length) { |
1321 return this._onSend(null, data); | |
1322 } | |
1323 } | |
1324 return this._getXHRPromise(false, data && data.context); | |
1325 } | |
1326 | |
1327 }); | |
1328 | |
1329 })); |