Browse Source

Fix #1152: Correct preview thumbs stacking post sorting and/or ajax deletion

Kartik Visweswaran 7 years ago
parent
commit
086a1ef43b
3 changed files with 7 additions and 9 deletions
  1. 1 0
      CHANGE.md
  2. 6 9
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -5,6 +5,7 @@ Change Log: `bootstrap-fileinput`
 
 
 **Date:** _work in progress_
 **Date:** _work in progress_
 
 
+- (bug #1152): Correct preview thumbs stacking post sorting and/or ajax deletion.
 - (enh #1149): Enhance download button behavior to allow Firefox browser to download.
 - (enh #1149): Enhance download button behavior to allow Firefox browser to download.
 - (enh #1143): Correct translation path in docs.
 - (enh #1143): Correct translation path in docs.
 - (enh #1142, #1141): Update Georgian translations.
 - (enh #1142, #1141): Update Georgian translations.

+ 6 - 9
js/fileinput.js

@@ -1478,17 +1478,14 @@
                 scroll: false,
                 scroll: false,
                 draggable: selector,
                 draggable: selector,
                 onSort: function (e) {
                 onSort: function (e) {
-                    var oldIndex = e.oldIndex, newIndex = e.newIndex, $frame, $dragEl;
+                    var oldIndex = e.oldIndex, newIndex = e.newIndex, $frame, $dragEl, i = 0;
                     self.initialPreview = $h.moveArray(self.initialPreview, oldIndex, newIndex);
                     self.initialPreview = $h.moveArray(self.initialPreview, oldIndex, newIndex);
                     self.initialPreviewConfig = $h.moveArray(self.initialPreviewConfig, oldIndex, newIndex);
                     self.initialPreviewConfig = $h.moveArray(self.initialPreviewConfig, oldIndex, newIndex);
                     self.previewCache.init();
                     self.previewCache.init();
-                    for (var i = 0; i < self.initialPreviewConfig.length; i++) {
-                        if (self.initialPreviewConfig[i] !== null) {
-                            $dragEl = $(e.item);
-                            $frame = $dragEl.closest($h.FRAMES);
-                            $frame.attr('data-fileindex', 'init_' + i).attr('data-fileindex', 'init_' + i);
-                        }
-                    }
+                    self.getFrames('.file-preview-initial').each(function() {
+                        $(this).attr('data-fileindex', 'init_' + i);
+                        i++;
+                    });
                     self._raise('filesorted', {
                     self._raise('filesorted', {
                         previewId: $(e.item).attr('id'),
                         previewId: $(e.item).attr('id'),
                         'oldIndex': oldIndex,
                         'oldIndex': oldIndex,
@@ -2629,9 +2626,9 @@
                     $frame.fadeOut('slow', function () {
                     $frame.fadeOut('slow', function () {
                         index = parseInt(($frame.attr('data-fileindex')).replace('init_', ''));
                         index = parseInt(($frame.attr('data-fileindex')).replace('init_', ''));
                         self.previewCache.unset(index);
                         self.previewCache.unset(index);
+                        self._deleteFileIndex($frame);
                         n = self.previewCache.count();
                         n = self.previewCache.count();
                         cap = n > 0 ? self._getMsgSelected(n) : '';
                         cap = n > 0 ? self._getMsgSelected(n) : '';
-                        self._deleteFileIndex($frame);
                         self._setCaption(cap);
                         self._setCaption(cap);
                         self._raise('filedeleted', [vKey, jqXHR, extraData]);
                         self._raise('filedeleted', [vKey, jqXHR, extraData]);
                         $h.cleanZoomCache($preview.find('#zoom-' + $frame.attr('id')));
                         $h.cleanZoomCache($preview.find('#zoom-' + $frame.attr('id')));

File diff suppressed because it is too large
+ 0 - 0
js/fileinput.min.js


Some files were not shown because too many files changed in this diff