vendor/assets/javascripts/fotorama.js in fotoramajs-4.4.4 vs vendor/assets/javascripts/fotorama.js in fotoramajs-4.4.5

- old
+ new

@@ -1,14 +1,15 @@ /*! - * Fotorama 4.4.4 | http://fotorama.io/license/ + * Fotorama 4.4.5 | http://fotorama.io/license/ */ (function (window, document, location, $, undefined) { "use strict"; var _fotoramaClass = 'fotorama', _fullscreenClass = 'fullscreen', wrapClass = _fotoramaClass + '__wrap', + wrapCss2Class = wrapClass + '--css2', wrapCss3Class = wrapClass + '--css3', wrapVideoClass = wrapClass + '--video', wrapFadeClass = wrapClass + '--fade', wrapSlideClass = wrapClass + '--slide', wrapNoControlsClass = wrapClass + '--no-controls', @@ -77,18 +78,19 @@ videoClass = _fotoramaClass + '__video', videoPlayClass = videoClass + '-play', videoCloseClass = videoClass + '-close', captionClass = _fotoramaClass + '__caption', + captionWrapClass = _fotoramaClass + '__caption__wrap', ooooClass = _fotoramaClass + '__oooo'; var JQUERY_VERSION = $ && $.fn.jquery.split('.'); if (!JQUERY_VERSION || JQUERY_VERSION[0] < 1 || (JQUERY_VERSION[0] == 1 && JQUERY_VERSION[1] < 8)) { - window.console && console['error']('Fotorama requires jQuery 1.8 or later and will not run without it.'); + throw new Error('Fotorama requires jQuery 1.8 or later and will not run without it.'); return; } // My Underscore :-) var _ = {}; /* Modernizr 2.6.2 (Custom Build) | MIT & BSD @@ -740,13 +742,11 @@ height = numberFromMeasure(imgData.height || $img.attr('height')); $.extend(imgData, { width: width, height: height, - thumbratio: getRatio(imgData.thumbratio - || (numberFromMeasure(imgData.thumbwidth || ($child && $child.attr('width')) || separateThumbFLAG || width) - / numberFromMeasure(imgData.thumbheight || ($child && $child.attr('height')) || separateThumbFLAG || height))) + thumbratio: getRatio(imgData.thumbratio || (numberFromMeasure(imgData.thumbwidth || ($child && $child.attr('width')) || separateThumbFLAG || width) / numberFromMeasure(imgData.thumbheight || ($child && $child.attr('height')) || separateThumbFLAG || height))) }); } $el.children().each(function () { var $this = $(this), @@ -961,10 +961,11 @@ } function getDirectionSign (forward) { return forward ? '>' : '<'; } + function slide ($el, options) { var elPos = Math.round(options.pos), onEndFn = options.onEnd || noop; if (typeof options.overPos !== 'undefined' && options.overPos !== options.pos) { @@ -1377,12 +1378,10 @@ }, false); return tail; } - - jQuery.Fotorama = function ($fotorama, opts) { $HTML = $HTML || $('html'); $BODY = $BODY || $('body'); var that = this, @@ -1401,12 +1400,12 @@ $stage = $(div(stageClass)).appendTo($wrap), stage = $stage[0], $stageShaft = $(div(stageShaftClass)).appendTo($stage), $stageFrame = $(), - $arrPrev = $(div(arrClass + ' ' + arrPrevClass, div(arrArrClass))), - $arrNext = $(div(arrClass + ' ' + arrNextClass, div(arrArrClass))), + $arrPrev = $(div(arrClass + ' ' + arrPrevClass/*, div(arrArrClass)*/)), + $arrNext = $(div(arrClass + ' ' + arrNextClass/*, div(arrArrClass)*/)), $arrs = $arrPrev.add($arrNext).appendTo($stage), $navWrap = $(div(navWrapClass)), $nav = $(div(navClass)).appendTo($navWrap), $navShaft = $(div(navShaftClass)).appendTo($nav), $navFrame, @@ -1488,13 +1487,11 @@ toDeactivate[NAV_DOT_FRAME_KEY] = []; toDetach[STAGE_FRAME_KEY] = {}; that.prevent = {}; - if (CSS3) { - $wrap.addClass(wrapCss3Class); - } + $wrap.addClass(CSS3 ? wrapCss3Class : wrapCss2Class); fotoramaData.fotorama = this; function checkForVideo () { $.each(data, function (i, dataFrame) { @@ -1530,14 +1527,14 @@ if (e.keyCode === 27) { stopEvent(e); that.cancelFullScreen(); } else if (e.keyCode === 39 || (e.keyCode === 40 && that.fullScreen)) { stopEvent(e); - that.show({index: '>', slow: e.altKey, direct: true}); + that.show({index: '>', slow: e.altKey, user: true}); } else if (e.keyCode === 37 || (e.keyCode === 38 && that.fullScreen)) { stopEvent(e); - that.show({index: '<', slow: e.altKey, direct: true}); + that.show({index: '<', slow: e.altKey, user: true}); } } }); if (!that.index) { @@ -1974,11 +1971,11 @@ ) .appendTo($frame); } if (opts.captions && dataFrame.caption) { - $('<div class="' + captionClass + '"></div>').append(dataFrame.caption).appendTo($frame); + $(div(captionClass, div(captionWrapClass, dataFrame.caption))).appendTo($frame); } dataFrame.video && $frame .addClass(stageFrameVideoClass) .append($videoPlay.clone()); @@ -2349,22 +2346,27 @@ //setTimeout(function () { unloadVideo($videoPlaying, activeFrame.i !== data[normalizeIndex(repositionIndex)].i); frameDraw(activeIndexes, 'stage'); stageFramePosition([dirtyIndex, getPrevIndex(dirtyIndex), getNextIndex(dirtyIndex)]); updateTouchTails('go', true); - triggerEvent('show', options.direct); + triggerEvent('show', { + user: options.user, + time: time + }); //}, 0); var onEnd = that.show.onEnd = function (skipReposition) { if (onEnd.ok) return; onEnd.ok = true; updateFotoramaState(); loadImg(activeIndexes, 'stage'); skipReposition || stageShaftReposition(true); - triggerEvent('showend', options.direct); + triggerEvent('showend', { + user: options.user + }); updateTouchTails('go', false); stageWheelUpdate(); stageCursor(); @@ -2511,13 +2513,14 @@ width = measures.W = measures.w = $wrap.width(); if (opts.glimpse) { // Glimpse measures.w -= Math.round((numberFromPercent(opts.glimpse) / 100 * width || numberFromMeasure(opts.glimpse)) * 2) - $stageShaft.css({width: measures.w, marginLeft: (measures.W - measures.w) / 2}); } + $stageShaft.css({width: measures.w, marginLeft: (measures.W - measures.w) / 2}); + //console.log('measures.W', measures.W); //console.log('measures.w', measures.w); height = numberFromPercent(height) / 100 * windowHeight || numberFromMeasure(height); @@ -2671,11 +2674,11 @@ } else { triggerEvent('stagetap', undefined, function () { if (toggleControlsFLAG) { toggleControlsClass(); } else if (opts.click) { - that.show({index: e.shiftKey || getDirectionSign(getDirection(e._x)), slow: e.altKey, direct: true}); + that.show({index: e.shiftKey || getDirectionSign(getDirection(e._x)), slow: e.altKey, user: true}); } }); } } @@ -2699,11 +2702,11 @@ var index = getIndexByPos(result.newPos, measures.w, opts.margin, repositionIndex); that.show({ index: index, time: o_fade ? o_transitionDuration : result.time, overPos: result.overPos, - direct: true + user: true }); } else if (!result.aborted) { onStageTap(result.startEvent, toggleControlsFLAG); } }, @@ -2796,20 +2799,20 @@ } ); function onNavFrameClick (e, time) { var index = $(this).data().eq; - that.show({index: index, slow: e.altKey, direct: true, coo: e._x - $nav.offset().left, time: time}); + that.show({index: index, slow: e.altKey, user: true, coo: e._x - $nav.offset().left, time: time}); } smartClick($arrs, function (e) { stopEvent(e); if ($videoPlaying) { unloadVideo($videoPlaying, true, true); } else { onTouchEnd(); - that.show({index: $arrs.index(this) ? '>' : '<', slow: e.altKey, direct: true}); + that.show({index: $arrs.index(this) ? '>' : '<', slow: e.altKey, user: true}); } }, { onStart: function () { onTouchStart(); stageShaftTouchTail.control = true; @@ -2866,10 +2869,10 @@ that[method] = function () { data = data || []; if (method !== 'load') { Array.prototype[method].apply(data, arguments); } else if (arguments[0] && typeof arguments[0] === 'object' && arguments[0].length) { - data = arguments[0]; + data = clone(arguments[0]); } reset(); return that; } });