From 0610dd615f7ac23f5b79057d4a6cfc055615963d Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Thu, 17 Dec 2020 23:18:22 -0300 Subject: [PATCH] Update galleria to v1.6.1 --- sigal/themes/galleria/static/galleria.js | 111 ++++++++--- sigal/themes/galleria/static/galleria.min.js | 15 +- .../plugins/history/galleria.history.js | 31 ++- .../plugins/history/galleria.history.min.js | 11 +- .../static/themes/classic/classic-loader.gif | Bin 1849 -> 0 bytes .../static/themes/classic/classic-map.png | Bin 1840 -> 0 bytes .../themes/classic/galleria.classic.css | 14 +- .../static/themes/classic/galleria.classic.js | 185 ++++++++++-------- .../themes/classic/galleria.classic.min.css | 2 +- .../themes/classic/galleria.classic.min.js | 11 +- tests/sample/sigal.conf.py | 4 +- 11 files changed, 230 insertions(+), 154 deletions(-) delete mode 100644 sigal/themes/galleria/static/themes/classic/classic-loader.gif delete mode 100644 sigal/themes/galleria/static/themes/classic/classic-map.png diff --git a/sigal/themes/galleria/static/galleria.js b/sigal/themes/galleria/static/galleria.js index 6e3a27f..f9e4602 100644 --- a/sigal/themes/galleria/static/galleria.js +++ b/sigal/themes/galleria/static/galleria.js @@ -1,14 +1,30 @@ /** - * Galleria v1.5.7 2017-05-10 - * http://galleria.io + * Galleria v1.6.1 * - * Copyright (c) 2010 - 2016 worse is better UG + * Copyright (c) 2010 - 2019 worse is better UG * Licensed under the MIT license - * https://raw.github.com/worseisbetter/galleria/master/LICENSE * */ -(function( $, window, Galleria, undef ) { +( function( window, factory ) { + if ( typeof define == 'function' && define.amd ) { + define( [ 'jquery' ], function( jQuery ) { + return factory( window, jQuery ); + }); + } else if ( typeof module == 'object' && module.exports ) { + module.exports = factory( + window, + require('jquery') + ); + } else { + // browser global + window.Galleria = factory( + window, + window.jQuery + ); + } + +}( window, function factory( window, $, Galleria, undef ) { /*global jQuery, navigator, Image, module, define */ @@ -16,12 +32,13 @@ var doc = window.document, $doc = $( doc ), $win = $( window ), + jQuery = $, // native prototypes protoArray = Array.prototype, // internal constants - VERSION = 1.57, + VERSION = 1.61, DEBUG = true, TIMEOUT = 30000, DUMMY = false, @@ -128,7 +145,7 @@ var doc = window.document, return PROT + '//img.youtube.com/vi/'+this.id+'/default.jpg'; }, get_image: function( data ) { - return PROT + '//img.youtube.com/vi/'+this.id+'/hqdefault.jpg'; } + return PROT + '//img.youtube.com/vi/'+this.id+'/maxresdefault.jpg'; } }, vimeo: { reg: /https?:\/\/(?:www\.)?(vimeo\.com)\/(?:hd#)?([0-9]+)/i, @@ -885,7 +902,7 @@ var doc = window.document, // If failed, tell the dev to download the latest theme Galleria.raise( 'Theme CSS could not load after 20 sec. ' + ( Galleria.QUIRK ? 'Your browser is in Quirks Mode, please add a correct doctype.' : - 'Please download the latest theme at http://galleria.io/customer/.' ), true ); + 'Please download the latest theme.' ), true ); }, timeout: 5000 }); @@ -1866,8 +1883,14 @@ Galleria = function() { var image = self._controls.getActive().image; if ( image ) { $( image ).width( big.image.width ).height( big.image.height ) - .attr( 'style', $( big.image ).attr('style') ) - .attr( 'src', big.image.src ); + .attr( 'style', $( big.image ).attr('style') ); + if (big.image.src.srcset) { + $( image ).attr( 'srcset', big.image.src.srcset ); + } + if (big.image.src.sizes) { + $( image ).attr( 'sizes', big.image.src.sizes ); + } + $( image ).attr( 'src', big.image.src ); } } }); @@ -3873,22 +3896,37 @@ Galleria.prototype = { } else if( href && elem.hasClass('iframe') ) { data.iframe = href; } else { - data.image = data.big = href; + data.image = href; } if ( rel ) { data.big = rel; } - // alternative extraction from HTML5 data attribute, added in 1.2.7 - $.each( 'big title description link layer image'.split(' '), function( i, val ) { + data.imagesrcset = parent.data( 'srcset' ); + data.imagesizes = parent.data( 'sizes' ); + data.thumbsizes = elem.attr( 'sizes' ); + data.thumbsrcset = elem.attr( 'srcset' ); + + // alternative extraction from HTML5 data attribute + $.each( 'big bigsrcset bigsizes title description link layer image imagesrcset imagesizes'.split(' '), function( i, val ) { if ( elem.data(val) ) { data[ val ] = elem.data(val).toString(); } }); + if (elem.data('srcset')) { + data.imagesrcset = elem.data('srcset'); + } + + if (elem.data('sizes')) { + data.imagesizes = elem.data('sizes'); + } + if ( !data.big ) { data.big = data.image; + data.bigsrcset = data.imagesrcset; + data.bigsizes = data.imagesizes; } // mix default extractions with the hrefs and config @@ -3950,6 +3988,15 @@ Galleria.prototype = { current = self._data[ i ]; + // q&d hack to attach srcset & sizes to src + $.each( 'big image thumb'.split(' '), function( i, val ) { + if ( data[ val] ) { + data[val] = new String(data[val]); + data[val].srcset = data [val + 'srcset']; + data[val].sizes = data [val + 'sizes']; + } + }); + // copy image as thumb if no thumb exists if ( 'thumb' in data === false ) { current.thumb = data.image; @@ -4029,6 +4076,7 @@ Galleria.prototype = { this.clearTimer(); Utils.removeFromArray( _instances, this ); Utils.removeFromArray( _galleries, this ); + _video._inst = []; if ( Galleria._waiters !== undefined && Galleria._waiters.length ) { $.each( Galleria._waiters, function( i, w ) { if ( w ) window.clearTimeout( w ); @@ -6168,11 +6216,22 @@ Galleria.Picture.prototype = { */ preload: function( src ) { - $( new Image() ).on( 'load', (function(src, cache) { + var $image = $( new Image() ).on( 'load', (function(src, cache) { return function() { cache[ src ] = src; }; - }( src, this.cache ))).attr( 'src', src ); + }( src, this.cache ))); + + // due to a bug in safari, need to set srcset first + if (src.srcset) { + $image.attr( 'srcset', src.srcset ); + } + + if (src.sizes) { + $image.attr( 'sizes', src.sizes ); + } + + $image.attr( 'src', src ); }, /** @@ -6340,7 +6399,14 @@ Galleria.Picture.prototype = { }); // begin load and insert in cache when done - $image.on( 'load', onload ).on( 'error', onerror ).attr( 'src', src ); + $image.on( 'load', onload ).on( 'error', onerror ); + if (src.srcset) { + $image.attr( 'srcset', src.srcset ); + } + if (src.sizes) { + $image.attr( 'sizes', src.sizes ); + } + $image.attr( 'src', src ); // return the container return this.container; @@ -6915,16 +6981,7 @@ $.fn.galleria = function( options ) { }; -// export as AMD or CommonJS -if ( typeof module === "object" && module && typeof module.exports === "object" ) { - module.exports = Galleria; -} else { - window.Galleria = Galleria; - if ( typeof define === "function" && define.amd ) { - define( "galleria", ['jquery'], function() { return Galleria; } ); - } -} - // phew +return Galleria; -}( jQuery, this ) ); +})); diff --git a/sigal/themes/galleria/static/galleria.min.js b/sigal/themes/galleria/static/galleria.min.js index cfda735..dd3c6f1 100644 --- a/sigal/themes/galleria/static/galleria.min.js +++ b/sigal/themes/galleria/static/galleria.min.js @@ -1,13 +1,12 @@ /** - * Galleria - v1.5.7 2017-05-10 - * https://galleria.io + * Galleria - v1.6.1 2019-10-17 + * * - * Copyright (c) 2010 - 2017 worse is better UG + * Copyright (c) 2010 - 2019 worse is better UG * Licensed under the MIT License. - * https://raw.github.com/worseisbetter/galleria/master/LICENSE - * */ -!function(a,b,c,d){var e=b.document,f=a(e),g=a(b),h=Array.prototype,i=1.57,j=!0,k=3e4,l=!1,m=navigator.userAgent.toLowerCase(),n=b.location.hash.replace(/#\//,""),o="file:"==b.location.protocol?"http:":b.location.protocol,p=Math,q=function(){},r=function(){return!1},s=!(b.screen.width>1279&&1==b.devicePixelRatio||b.screen.width>1e3&&b.innerWidth<.9*b.screen.width),t=function(){var a=3,b=e.createElement("div"),c=b.getElementsByTagName("i");do b.innerHTML="";while(c[0]);return a>4?a:e.documentMode||d}(),u=function(){return{html:e.documentElement,body:e.body,head:e.getElementsByTagName("head")[0],title:e.title}},v=b.parent!==b.self,w="data ready thumbnail loadstart loadfinish image play pause progress fullscreen_enter fullscreen_exit idle_enter idle_exit rescale lightbox_open lightbox_close lightbox_image",x=function(){var b=[];return a.each(w.split(" "),function(a,c){b.push(c),/_/.test(c)&&b.push(c.replace(/_/g,""))}),b}(),y=function(b){var c;return"object"!=typeof b?b:(a.each(b,function(d,e){/^[a-z]+_/.test(d)&&(c="",a.each(d.split("_"),function(a,b){c+=a>0?b.substr(0,1).toUpperCase()+b.substr(1):b}),b[c]=e,delete b[d])}),b)},z=function(b){return a.inArray(b,x)>-1?c[b.toUpperCase()]:b},A={youtube:{reg:/https?:\/\/(?:[a-zA_Z]{2,3}.)?(?:youtube\.com\/watch\?)((?:[\w\d\-\_\=]+&(?:amp;)?)*v(?:<[A-Z]+>)?=([0-9a-zA-Z\-\_]+))/i,embed:function(){return o+"//www.youtube.com/embed/"+this.id},get_thumb:function(a){return o+"//img.youtube.com/vi/"+this.id+"/default.jpg"},get_image:function(a){return o+"//img.youtube.com/vi/"+this.id+"/hqdefault.jpg"}},vimeo:{reg:/https?:\/\/(?:www\.)?(vimeo\.com)\/(?:hd#)?([0-9]+)/i,embed:function(){return o+"//player.vimeo.com/video/"+this.id},getUrl:function(){return o+"//vimeo.com/api/v2/video/"+this.id+".json?callback=?"},get_thumb:function(a){return a[0].thumbnail_medium},get_image:function(a){return a[0].thumbnail_large}},dailymotion:{reg:/https?:\/\/(?:www\.)?(dailymotion\.com)\/video\/([^_]+)/,embed:function(){return o+"//www.dailymotion.com/embed/video/"+this.id},getUrl:function(){return"https://api.dailymotion.com/video/"+this.id+"?fields=thumbnail_240_url,thumbnail_720_url&callback=?"},get_thumb:function(a){return a.thumbnail_240_url},get_image:function(a){return a.thumbnail_720_url}},_inst:[]},B=function(c,d){for(var e=0;e=h+d.timeout?(d.error(),!1):void c._waiters.push(g=b.setTimeout(i,10))};c._waiters.push(g=b.setTimeout(i,10))},toggleQuality:function(a,b){7!==t&&8!==t||!a||"IMG"!=a.nodeName.toUpperCase()||("undefined"==typeof b&&(b="nearest-neighbor"===a.style.msInterpolationMode),a.style.msInterpolationMode=b?"bicubic":"nearest-neighbor")},insertStyleTag:function(b,c){if(!c||!a("#"+c).length){var d=e.createElement("style");if(c&&(d.id=c),u().head.appendChild(d),d.styleSheet)d.styleSheet.cssText=b;else{var f=e.createTextNode(b);d.appendChild(f)}}},loadScript:function(b,c){var d=!1,e=a("