From 712271530b81b10f7c6ab0fc2d6a419d6026443e Mon Sep 17 00:00:00 2001 From: ValeryYafremau Date: Fri, 11 Dec 2015 11:30:06 +0300 Subject: [PATCH] JS-329: Add preview arrows while video is playing (for better navigation) - update UpdateOptions method to don't lose focus and arrows --- lib/web/mage/gallery/gallery.js | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/web/mage/gallery/gallery.js b/lib/web/mage/gallery/gallery.js index 9da939737a284..31b32c99e6e8e 100644 --- a/lib/web/mage/gallery/gallery.js +++ b/lib/web/mage/gallery/gallery.js @@ -401,7 +401,40 @@ define([ * @param {Boolean} isInternal - Is this function called via breakpoints. */ updateOptions: function (configuration, isInternal) { + + var $selectable = + $('a[href], area[href], input, select, textarea, button, iframe, object, embed, *[tabindex], *[contenteditable]') + .not('[tabindex=-1], [disabled], :hidden'), + fotorama = settings.fotoramaApi, + $focus = $(':focus'), + index; + + /** + * Displays navigation arrows on preview if it contains ifraime. + * @param fotorama - object of fotorama + */ + function showArrows (fotorama) { + var $arrows = $('[data-gallery-role="arrow"]'); + + if ((fotorama.activeFrame.$stageFrame.find(':has(iframe)').length && fotorama.fullScreen) || + (fotorama.fullScreen && config.fullscreen.arrows) || + (!fotorama.fullScreen && config.arrows)) { + $arrows.show(); + } else { + $arrows.hide(); + } + }; + if (_.isObject(configuration)) { + + //Saves index of focus + $selectable.each(function (number) { + + if ($(this).is($focus)) { + index = number; + } + }); + if (this.isTouchEnabled) { configuration.arrows = false; } @@ -419,6 +452,11 @@ define([ } $.extend(true, settings.currentConfig.options, configuration); settings.fotoramaApi.setOptions(settings.currentConfig.options); + showArrows(fotorama); + + if (_.isNumber(index)) { + $selectable.eq(index).focus(); + } } },