Prechádzať zdrojové kódy

Upgrade to release v4.1.2

Kartik Visweswaran 10 rokov pred
rodič
commit
47db2ccecd
7 zmenil súbory, kde vykonal 90 pridanie a 25 odobranie
  1. 19 0
      CHANGE.md
  2. 50 6
      README.md
  3. 1 1
      bower.json
  4. 1 1
      css/fileinput.css
  5. 1 1
      css/fileinput.min.css
  6. 17 15
      js/fileinput.js
  7. 1 1
      js/fileinput.min.js

+ 19 - 0
CHANGE.md

@@ -1,3 +1,22 @@
+version 4.1.2
+=============
+**Date:** 19-Dec-2014
+
+1. (enh #81): Add new events:
+    - `filebatchuploadsuccess`
+    - `filebatchuploadcomplete`
+    
+2. (enh #80): Allow access to `uploadExtraData` to following events
+    - `filepreupload`
+    - `fileuploaded`
+    - `fileuploaderror`
+    - `filebatchuploaderror`
+    - `filebatchuploadsuccess`
+    - `filebatchuploadcomplete`
+    - `filelock`
+    - `fileunlock`
+
+
 version 4.1.1
 =============
 **Date:** 18-Dec-2014

+ 50 - 6
README.md

@@ -7,7 +7,7 @@ wide variety of files i.e. images, text, html, video, audio, flash, and objects.
 
 ![File Input Screenshot](https://lh3.googleusercontent.com/-3FiEmc_okc4/VBw_d2LBAJI/AAAAAAAAAL8/KbVj5X9Dus0/w596-h454-no/FileInput.jpg)
 
-> NOTE: The latest version of the plugin v4.1.1 has been released. Refer the [CHANGE LOG](https://github.com/kartik-v/bootstrap-fileinput/blob/master/CHANGE.md) for details.
+> NOTE: The latest version of the plugin v4.1.2 has been released. Refer the [CHANGE LOG](https://github.com/kartik-v/bootstrap-fileinput/blob/master/CHANGE.md) for details. 
 
 ## Features  
 
@@ -79,6 +79,8 @@ built upon HTML5 FormData and XMLHttpRequest Level 2 standards. Most modern brow
 10. Ability to cancel and abort ongoing AJAX uploads.
 11. Ensure plugin is still lean in size and optimized for performance inspite of the above features by optimally utilizing HTML5 & jquery features only.
 
+> NOTE: Drag and Drop zone functionality, selectively appending or deleting files, and upload indicator with progress are ONLY AVAILABLE if you use AJAX BASED uploads (by setting `uploadUrl`).
+
 ## Demo
 
 View the [plugin documentation](http://plugins.krajee.com/file-input) and [plugin demos](http://plugins.krajee.com/file-input/demo) at Krajee JQuery plugins. 
@@ -918,9 +920,10 @@ $('#input-id').on('fileselectnone', function(event) {
 This event is triggered when the upload process is launched by clicking a upload button, and the entire widget is locked (disabled) until upload is getting processed. Only the `Cancel` button will be enabled when the file input is locked. Additional parameters available are: 
 
 - `filestack`: the array of selected file objects.
+- `extraData`: the `uploadExtraData` settings for the plugin (will return an empty object if not set).
 
 ```js
-$('#input-id').on('filelock', function(event, filestack) {
+$('#input-id').on('filelock', function(event, filestack, extraData) {
     var fstack = filestack.filter(function(n){ return n != undefined });
     console.log('Files selected - ' + fstack.length);
 });
@@ -930,9 +933,10 @@ $('#input-id').on('filelock', function(event, filestack) {
 This event is triggered when the upload process is completed (successfully or with error). The entire widget is unlocked (enabled) and reverts to initial state. Additional parameters available are: 
 
 - `filestack`: the array of selected file objects.
+- `extraData`: the `uploadExtraData` settings for the plugin (will return an empty object if not set).
 
 ```js
-$('#input-id').on('fileunlock', function(event, filestack) {
+$('#input-id').on('fileunlock', function(event, filestack, extraData) {
     var fstack = filestack.filter(function(n){ return n != undefined });
     console.log('Files selected - ' + fstack.length);
 });
@@ -984,11 +988,12 @@ $('#input-id').on('filedeleteerror', function(event, formdata, preview, index) {
 This event is triggered before upload of each thumbnail file. Additional parameters available are: 
 
 - `formdata`: the FormData object which is passed via XHR2.
+- `extraData`: the `uploadExtraData` settings for the plugin (will return an empty object if not set).
 - `previewId`: the identifier of the preview thumbnail container.
 - `index`: the zero-based index of the file in the preview container.
 
 ```js
-$('#input-id').on('filepreupload', function(event, formdata, preview, index) {
+$('#input-id').on('filepreupload', function(event, formdata, extraData, preview, index) {
     console.log('File pre upload triggered');
 });
 ```
@@ -997,11 +1002,12 @@ $('#input-id').on('filepreupload', function(event, formdata, preview, index) {
 This event is triggered after upload is completed for each thumbnail file. Additional parameters available are: 
 
 - `formdata`: the FormData object which is passed via XHR2.
+- `extraData`: the `uploadExtraData` settings for the plugin (will return an empty object if not set).
 - `previewId`: the identifier of each file's parent thumbnail div element in the preview window.
 - `index`: the zero-based index of the file in the file stack.
 
 ```js
-$('#input-id').on('fileuploaded', function(event, formdata, preview, index) {
+$('#input-id').on('fileuploaded', function(event, formdata, extraData, preview, index) {
     console.log('File uploaded triggered');
 });
 ```
@@ -1010,14 +1016,52 @@ $('#input-id').on('fileuploaded', function(event, formdata, preview, index) {
 This event is triggered when an error is faced in deletion of each thumbnail file in the `initialPreview` content set. Additional parameters available are: 
 
 - `formdata`: the FormData object which is passed via XHR2.
+- `extraData`: the `uploadExtraData` settings for the plugin (will return an empty object if not set).
 - `previewId`: the identifier of each file's parent thumbnail div element in the preview window.
 - `index`: the zero-based index of the file in the file stack.
 
 ```js
-$('#input-id').on('fileuploaderror', function(event, formdata, preview, index) {
+$('#input-id').on('fileuploaderror', function(event, formdata, extraData, preview, index) {
     console.log('File upload error');
 });
 ```
+
+#### filebatchuploadsuccess
+This event is triggered after a successful synchronous batch upload (i.e. when `uploadAsync` is `false`). Additional parameters available are: 
+
+- `filestack`: the array of selected file objects.
+- `extraData`: the `uploadExtraData` settings for the plugin (will return an empty object if not set).
+
+```js
+$('#input-id').on('filebatchuploadsuccess', function(formdata, extraData) {
+    console.log('File batch upload success');
+});
+```
+
+#### filebatchuploaderror
+This event is triggered when any error is faced in the synchronous batch upload (i.e. when `uploadAsync` is `false`). Additional parameters available are: 
+
+- `formdata`: the FormData object which is passed via XHR2.
+- `extraData`: the `uploadExtraData` settings for the plugin (will return an empty object if not set).
+
+```js
+$('#input-id').on('filebatchuploaderror', function(event, formdata, extraData) {
+    console.log('File upload error');
+});
+```
+
+#### filebatchuploadcomplete
+This event is triggered after completion of the synchronous ajax batch upload (i.e. when `uploadAsync` is `false`). Additional parameters available are: 
+
+- `filestack`: the array of selected file objects.
+- `extraData`: the `uploadExtraData` settings for the plugin (will return an empty object if not set).
+
+```js
+$('#input-id').on('filebatchuploadcomplete', function(formdata, extraData) {
+    console.log('File batch upload complete');
+});
+```
+
 ### Plugin Methods
 The plugin supports these methods:
 

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
     "name": "bootstrap-fileinput",
-    "version": "4.1.1",
+    "version": "4.1.2",
     "homepage": "https://github.com/kartik-v/bootstrap-fileinput",
     "authors": [
         "Kartik Visweswaran <[email protected]>"

+ 1 - 1
css/fileinput.css

@@ -1,7 +1,7 @@
 /*!
  * @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
  * @package bootstrap-fileinput
- * @version 4.1.1
+ * @version 4.1.2
  *
  * File input styling for Bootstrap 3.0
  * Built for Yii Framework 2.0

+ 1 - 1
css/fileinput.min.css

@@ -1,7 +1,7 @@
 /*!
  * @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
  * @package bootstrap-fileinput
- * @version 4.1.1
+ * @version 4.1.2
  *
  * File input styling for Bootstrap 3.0
  * Built for Yii Framework 2.0

+ 17 - 15
js/fileinput.js

@@ -1,6 +1,6 @@
 /*!
  * @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
- * @version 4.1.1
+ * @version 4.1.2
  *
  * File input styled for Bootstrap 3.0 that utilizes HTML5 File Input's advanced 
  * features including the FileReader API. 
@@ -389,7 +389,7 @@
             if (self.showCancel) {
                 self.$container.find('.fileinput-cancel').removeClass('hide');
             }
-            self.$element.trigger('filelock', [self.filestack]);
+            self.$element.trigger('filelock', [self.filestack, self.uploadExtraData]);
         },
         unlock: function() {
             var self = this;
@@ -400,7 +400,7 @@
             if (self.showRemove) {
                 self.$container.find('.fileinput-remove').removeClass('hide');
             }
-            self.$element.trigger('fileunlock', [self.filestack]);
+            self.$element.trigger('fileunlock', [self.filestack, self.uploadExtraData]);
         },
         refresh: function (options) {
             var self = this, $el = self.$element,
@@ -888,7 +888,7 @@
                     if (!allFiles) {
                         self.lock();
                     }
-                    self.$element.trigger('filepreupload', [formdata, previewId, i])
+                    self.$element.trigger('filepreupload', [formdata, self.uploadExtraData, previewId, i])
                 },
                 success: function(data, textStatus, jqXHR) {
                     setTimeout(function() {
@@ -897,10 +897,10 @@
                             $btnUpload.hide();
                             $btnDelete.hide();
                             self.filestack[i] = undefined;
-                            self.$element.trigger('fileuploaded', [formdata, previewId, i]);
+                            self.$element.trigger('fileuploaded', [formdata, self.uploadExtraData, previewId, i]);
                         } else {
                             setIndicator('indicatorError', 'indicatorErrorTitle');
-                            self.showUploadError(data.error, formdata, previewId, i, 'fileuploaderror');
+                            self.showUploadError(data.error, formdata, self.uploadExtraData, previewId, i);
                         }
                         updateProgress();
                         resetActions();
@@ -910,9 +910,9 @@
                     setIndicator('indicatorError', 'indicatorErrorTitle');
                     if (allFiles) {
                         var cap = files[i].name;
-                        self.showUploadError('<b>' + cap + '</b>: ' + errorThrown, formdata, previewId, i, 'fileuploaderror');
+                        self.showUploadError('<b>' + cap + '</b>: ' + errorThrown, formdata, self.uploadExtraData, previewId, i);
                     } else {
-                        self.showUploadError(errorThrown, formdata, previewId, i, 'fileuploaderror');
+                        self.showUploadError(errorThrown, formdata, self.uploadExtraData, previewId, i);
                     }
                     updateProgress();
                     resetActions();
@@ -970,6 +970,7 @@
                             } else {
                                 self.reset();
                             }
+                            self.$element.trigger('filebatchuploadsuccess', [self.filestack, self.uploadExtraData]);
                         } else {
                             self.$preview.find('.file-preview-frame').each(function() {
                                 var $thumb = $(this), key = $thumb.attr('data-fileindex');
@@ -991,16 +992,17 @@
                                     self.filestack[key] = undefined;
                                 }
                             });
-                            self.showUploadError(data.error, formdata, null, null, 'filebatchuploaderror');
+                            self.showUploadError(data.error, formdata, self.uploadExtraData, null, null, 'filebatchuploaderror');
                         }
                     }, 100);
                 },
                 complete: function () {
                     self.setProgress(100);
                     self.unlock();
+                    self.$element.trigger('filebatchuploadcomplete', [self.filestack, self.uploadExtraData]);
                 },
                 error: function(jqXHR, textStatus, errorThrown) {
-                    self.showUploadError(errorThrown, formdata, null, null, 'filebatchuploaderror');
+                    self.showUploadError(errorThrown, formdata, self.uploadExtraData, null, null, 'filebatchuploaderror');
                     self.uploadFileCount = total - 1;
                     self.$preview.find('.file-preview-frame').removeClass('file-uploading');
                 }
@@ -1025,16 +1027,16 @@
                 $error.hide();
             }
         },
-        showUploadError: function (msg, file, previewId, index) {
+        showUploadError: function (msg, file, extraData, previewId, index) {
             var self = this, $error = self.$errorContainer, $el = self.$element, 
-                ev = arguments.length > 4 ? arguments[4] : 'fileerror';
+                ev = arguments.length > 4 ? arguments[4] : 'fileuploaderror';
             if ($error.find('ul').length == 0) {
                 $error.html('<ul class="text-left"><li>' + msg + '</li></ul>');
             } else {
                 $error.find('ul').append('<li>' + msg + '</li>');
             }
             $error.fadeIn(800);
-            $el.trigger(ev, [file, previewId, index]);
+            $el.trigger(ev, [file, extraData, previewId, index]);
             addCss(self.$container, 'has-error');
             return true;
         },
@@ -1178,7 +1180,7 @@
                 ctr = self.filestack.length,
                 throwError = function(msg, file, previewId, index) {
                     self.previewDefault(file, previewId, true);
-                    return self.isUploadable ? self.showUploadError(msg, file, previewId, index) : self.showError(msg, file, previewId, index);
+                    return self.isUploadable ? self.showUploadError(msg, file, self.uploadExtraData, previewId, index) : self.showError(msg, file, previewId, index);
                 };
             function readFile(i) {
                 if (isEmpty($el.attr('multiple'))) {
@@ -1311,7 +1313,7 @@
                 numFiles = !isEmpty(files) ? (files.length + self.initialPreviewCount) : 1, tfiles,
                 ctr = self.filestack.length, isAjaxUpload = (self.isUploadable && ctr != 0),
                 throwError = function(msg, file, previewId, index) {
-                    return self.isUploadable ? self.showUploadError(msg, file, previewId, index) : self.showError(msg, file, previewId, index);
+                    return self.isUploadable ? self.showUploadError(msg, file, self.uploadExtraData, previewId, index) : self.showError(msg, file, previewId, index);
                 };
             self.resetUpload();
             

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
js/fileinput.min.js


Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov