Ver Fonte

Fix #162: New property ajaxSettings to allow configuring ajax params

Kartik Visweswaran há 11 anos atrás
pai
commit
d3aacbfeb9
4 ficheiros alterados com 10 adições e 4 exclusões
  1. 1 0
      CHANGE.md
  2. 3 0
      README.md
  3. 6 4
      js/fileinput.js
  4. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -16,6 +16,7 @@ version 4.1.7
        - `progressCompleteClass`: styling for progress bar when upload is complete
        - `progressCompleteClass`: styling for progress bar when upload is complete
 9. (bug #159): Ensure filestack is passed correctly with `outData` for events.
 9. (bug #159): Ensure filestack is passed correctly with `outData` for events.
 10. (bug #160): Correct documentation typo for usage.
 10. (bug #160): Correct documentation typo for usage.
+11. (enh #162): New property ajaxSettings to allow configuring ajax params.
 
 
 version 4.1.6
 version 4.1.6
 =============
 =============

+ 3 - 0
README.md

@@ -894,6 +894,9 @@ _string_ markup for additional action buttons to display within the initial prev
 #### textEncoding
 #### textEncoding
 _string_ the encoding to be used while reading a text file. Applicable only for previewing text files. Defaults to `UTF-8`. 
 _string_ the encoding to be used while reading a text file. Applicable only for previewing text files. Defaults to `UTF-8`. 
 
 
+#### ajaxSettings
+_object_ additional ajax settings to pass to the plugin before submitting the ajax request. Applicable only for ajax uploads. This can be useful to pass additional tokens to headers or one can use it for setting other ajax options for advanced cases. Refer the [jQuery ajax documentation](http://api.jquery.com/jQuery.ajax/) for the various settings you can configure.
+
 ### Plugin Events
 ### Plugin Events
 The plugin supports these events:
 The plugin supports these events:
 
 

+ 6 - 4
js/fileinput.js

@@ -957,9 +957,9 @@
             return xhrobj;
             return xhrobj;
         },
         },
         ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError) {
         ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError) {
-            var self = this;
+            var self = this, settings;
             self.uploadExtra();
             self.uploadExtra();
-            self.ajaxRequests.push($.ajax({
+            settings = $.extend(self.ajaxSettings, {
                 xhr: function () {
                 xhr: function () {
                     var xhrobj = $.ajaxSettings.xhr();
                     var xhrobj = $.ajaxSettings.xhr();
                     return self.initXhr(xhrobj, 98);
                     return self.initXhr(xhrobj, 98);
@@ -975,7 +975,8 @@
                 success: fnSuccess,
                 success: fnSuccess,
                 complete: fnComplete,
                 complete: fnComplete,
                 error: fnError
                 error: fnError
-            }));
+            });
+            self.ajaxRequests.push($.ajax(settings));
         },
         },
         uploadSingle: function (i, files, allFiles) {
         uploadSingle: function (i, files, allFiles) {
             var self = this, total = self.getFileStack().length, formdata = new FormData(), outData,
             var self = this, total = self.getFileStack().length, formdata = new FormData(), outData,
@@ -1757,7 +1758,8 @@
         dropZoneTitleClass: 'file-drop-zone-title',
         dropZoneTitleClass: 'file-drop-zone-title',
         fileActionSettings: {},
         fileActionSettings: {},
         otherActionButtons: '',
         otherActionButtons: '',
-        textEncoding: 'UTF-8'
+        textEncoding: 'UTF-8',
+        ajaxSettings: {}
     };
     };
 
 
     $.fn.fileinput.Constructor = FileInput;
     $.fn.fileinput.Constructor = FileInput;

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
js/fileinput.min.js


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff