소스 검색

Fix #819: Correct init preview auto replace post `uploadSingle` action in thumbnails

Kartik Visweswaran 8 년 전
부모
커밋
755bab1ca8
3개의 변경된 파일30개의 추가작업 그리고 15개의 파일을 삭제
  1. 1 0
      CHANGE.md
  2. 29 15
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -6,6 +6,7 @@ Change Log: `bootstrap-fileinput`
 **Date:** 24-Dec-2016
 **Date:** 24-Dec-2016
 
 
 - (enh #816): New property `msgFileTypes` to control descriptions/localizations of file types displayed.
 - (enh #816): New property `msgFileTypes` to control descriptions/localizations of file types displayed.
+- (bug #819): Correct init preview auto replace post `uploadSingle` action in thumbnails.
 
 
 ## version 4.3.6
 ## version 4.3.6
 
 

+ 29 - 15
js/fileinput.js

@@ -553,6 +553,11 @@
     toggleFullScreen = function (maximize) {
     toggleFullScreen = function (maximize) {
         var doc = document, de = doc.documentElement;
         var doc = document, de = doc.documentElement;
         if (de && maximize && !checkFullScreen()) {
         if (de && maximize && !checkFullScreen()) {
+            /** @namespace document.requestFullscreen */
+            /** @namespace document.msRequestFullscreen */
+            /** @namespace document.mozRequestFullScreen */
+            /** @namespace document.webkitRequestFullscreen */
+            /** @namespace Element.ALLOW_KEYBOARD_INPUT */
             if (de.requestFullscreen) {
             if (de.requestFullscreen) {
                 de.requestFullscreen();
                 de.requestFullscreen();
             } else if (de.msRequestFullscreen) {
             } else if (de.msRequestFullscreen) {
@@ -1642,7 +1647,7 @@
             self.ajaxRequests.push($.ajax(settings));
             self.ajaxRequests.push($.ajax(settings));
         },
         },
         _initUploadSuccess: function (out, $thumb, allFiles) {
         _initUploadSuccess: function (out, $thumb, allFiles) {
-            var self = this, append, data, index, $newThumb, content, config, tags, i,
+            var self = this, append, data, index, $div, $newCache, content, config, tags, i,
                 mergeArray = function (prop, content) {
                 mergeArray = function (prop, content) {
                     if (!(self[prop] instanceof Array)) {
                     if (!(self[prop] instanceof Array)) {
                         self[prop] = [];
                         self[prop] = [];
@@ -1671,12 +1676,24 @@
                     if (!allFiles) {
                     if (!allFiles) {
                         index = previewCache.add(self.id, content, config[0], tags[0], append);
                         index = previewCache.add(self.id, content, config[0], tags[0], append);
                         data = previewCache.get(self.id, index, false);
                         data = previewCache.get(self.id, index, false);
-                        $newThumb = $(data).hide();
-                        $thumb.after($newThumb).fadeOut('slow', function () {
-                            $newThumb.fadeIn('slow').css('display:inline-block');
+                        $div = $(document.createElement('div')).html(data).hide().insertAfter($thumb);
+                        $newCache = $div.find('.kv-zoom-cache');
+                        if ($newCache && $newCache.length) {
+                            $newCache.insertAfter($thumb);
+                        }
+                        $thumb.fadeOut('slow', function () {
+                            var $newThumb = $div.find('.file-preview-frame'),
+                                $cache = self.$preview.find('#zoom-' + $thumb.attr('id')).closest('.kv-zoom-cache');
+                            if ($newThumb && $newThumb.length) {
+                                $newThumb.insertBefore($thumb).fadeIn('slow').css('display:inline-block');
+                            }
                             self._initPreviewActions();
                             self._initPreviewActions();
                             self._clearFileInput();
                             self._clearFileInput();
+                            if ($cache && $cache.length) {
+                                $cache.remove();
+                            }
                             $thumb.remove();
                             $thumb.remove();
+                            $div.remove();
                         });
                         });
                     } else {
                     } else {
                         i = $thumb.attr('data-fileindex');
                         i = $thumb.attr('data-fileindex');
@@ -2518,7 +2535,7 @@
             });
             });
         },
         },
         _validateAllImages: function () {
         _validateAllImages: function () {
-            var self = this, i, config, $img, $thumb, pid, ind, params = {}, errFunc;
+            var self = this, i, config, $img, pid, ind, errFunc;
             if (self.loadedImages.length !== self.totalImagesCount) {
             if (self.loadedImages.length !== self.totalImagesCount) {
                 return;
                 return;
             }
             }
@@ -2527,17 +2544,14 @@
                 return;
                 return;
             }
             }
             errFunc = self.isUploadable ? self._showUploadError : self._showError;
             errFunc = self.isUploadable ? self._showUploadError : self._showError;
-            var counter = {val: 0};
             for (i = 0; i < self.loadedImages.length; i++) {
             for (i = 0; i < self.loadedImages.length; i++) {
                 config = self.loadedImages[i];
                 config = self.loadedImages[i];
                 $img = config.img;
                 $img = config.img;
-                $thumb = config.thumb;
                 pid = config.pid;
                 pid = config.pid;
                 ind = config.ind;
                 ind = config.ind;
-                params = {id: pid, 'index': ind};
-                if (!self._getResizedImage($img[0], config.typ, pid, ind, counter, self.loadedImages.length)) {
-                    errFunc(self.msgImageResizeError, params, 'fileimageresizeerror');
-                    self._setPreviewError($thumb, ind);
+                if (!self._getResizedImage($img[0], config.typ, pid, ind, {val: 0}, self.loadedImages.length)) {
+                    errFunc(self.msgImageResizeError, {id: pid, 'index': ind}, 'fileimageresizeerror');
+                    self._setPreviewError(config.thumb, ind);
                 }
                 }
             }
             }
         },
         },
@@ -3324,10 +3338,10 @@
             'image': 'image',
             'image': 'image',
             'html': 'HTML',
             'html': 'HTML',
             'text': 'text',
             'text': 'text',
-            'video': 'video', 
-            'audio': 'audio', 
-            'flash': 'flash', 
-            'pdf': 'PDF', 
+            'video': 'video',
+            'audio': 'audio',
+            'flash': 'flash',
+            'pdf': 'PDF',
             'object': 'object'
             'object': 'object'
         },
         },
         msgUploadAborted: 'The file upload was aborted',
         msgUploadAborted: 'The file upload was aborted',

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
js/fileinput.min.js


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.