Explorar o código

Fix #1727: Correct zoom navigation for reverse preview order

Kartik Visweswaran %!s(int64=3) %!d(string=hai) anos
pai
achega
7a6e99e6f0
Modificáronse 3 ficheiros con 19 adicións e 11 borrados
  1. 1 0
      CHANGE.md
  2. 18 11
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -5,6 +5,7 @@ Change Log: `bootstrap-fileinput`
 
 
 **Date**: _under development_
 **Date**: _under development_
 
 
+- (enh #1727): Correct zoom navigation for reverse preview order.
 - (enh #1726): Update Chinese translations.
 - (enh #1726): Update Chinese translations.
 - (enh #1722): Enhance zoom cache rendering and carousel navigation indicators.
 - (enh #1722): Enhance zoom cache rendering and carousel navigation indicators.
 - (enh #1720): Enhance parsing of `zoomData` to lazy load content asynchronously only on zoom.
 - (enh #1720): Enhance parsing of `zoomData` to lazy load content asynchronously only on zoom.

+ 18 - 11
js/fileinput.js

@@ -2901,6 +2901,9 @@
             $last = $(thumbs[len - 1]);
             $last = $(thumbs[len - 1]);
             $prev.removeAttr('disabled');
             $prev.removeAttr('disabled');
             $next.removeAttr('disabled');
             $next.removeAttr('disabled');
+            if (self.reversePreviewOrder) {
+                [$prev, $next] = [$next, $prev]; // swap
+            }
             if ($first.length && $first.attr('id') === previewId) {
             if ($first.length && $first.attr('id') === previewId) {
                 $prev.attr('disabled', true);
                 $prev.attr('disabled', true);
             }
             }
@@ -3040,23 +3043,24 @@
                 $modal.focus();
                 $modal.focus();
             });
             });
             self._handler($modal, 'keydown', function (e) {
             self._handler($modal, 'keydown', function (e) {
-                var key = e.which || e.keyCode, $prev = $(this).find('.btn-kv-prev'),
-                    $next = $(this).find('.btn-kv-next'), vId = $(this).data('previewId'),
-                    vPrevKey = self.rtl ? 39 : 37, vNextKey = self.rtl ? 37 : 39,
-                    listen = function (dir) {
-                        var $btn = dir === 'prev' ? $prev : $next, vKey = dir === 'prev' ? vPrevKey : vNextKey;
-                        if (key === vKey && $btn.length && !$btn.attr('disabled')) {
+                var key = e.which || e.keyCode, delay = self.processDelay + 1, $prev = $(this).find('.btn-kv-prev'),
+                    $next = $(this).find('.btn-kv-next'), vId = $(this).data('previewId'), vPrevKey, vNextKey;
+                [vPrevKey, vNextKey] = self.rtl ? [39, 37] : [37, 39];
+                $.each({prev: [$prev, vPrevKey], next: [$next, vNextKey]}, function (direction, config) {
+                    var $btn = config[0], vKey = config[1];
+                    if (key === vKey && $btn.length) {
+                        $modal.focus();
+                        if (!$btn.attr('disabled')) {
                             $btn.focus();
                             $btn.focus();
-                            self._zoomSlideShow(dir, vId);
+                            self._zoomSlideShow(direction, vId);
                             setTimeout(function () {
                             setTimeout(function () {
                                 if ($btn.attr('disabled')) {
                                 if ($btn.attr('disabled')) {
                                     $modal.focus();
                                     $modal.focus();
                                 }
                                 }
-                            }, self.processDelay + 1);
+                            }, delay);
                         }
                         }
-                    };
-                listen('prev');
-                listen('next');
+                    }
+                });
             });
             });
         },
         },
         _showModal: function ($frame) {
         _showModal: function ($frame) {
@@ -3083,6 +3087,9 @@
         _zoomSlideShow: function (dir, previewId) {
         _zoomSlideShow: function (dir, previewId) {
             var self = this, $btn = self.$modal.find('.kv-zoom-actions .btn-kv-' + dir), $targFrame, i, $thumb,
             var self = this, $btn = self.$modal.find('.kv-zoom-actions .btn-kv-' + dir), $targFrame, i, $thumb,
                 thumbsData = self.getFrames().toArray(), thumbs = [], len = thumbsData.length, out;
                 thumbsData = self.getFrames().toArray(), thumbs = [], len = thumbsData.length, out;
+            if (self.reversePreviewOrder) {
+                dir = dir === 'prev' ? 'next' : 'prev';
+            }
             if ($btn.attr('disabled')) {
             if ($btn.attr('disabled')) {
                 return;
                 return;
             }
             }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
js/fileinput.min.js


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio