|
1 | 1 | /**
|
2 |
| - * Galleria v1.5.7 2017-05-10 |
| 2 | + * Galleria v1.6.0 2019-10-13 |
3 | 3 | * http://galleria.io
|
4 | 4 | *
|
5 |
| - * Copyright (c) 2010 - 2016 worse is better UG |
| 5 | + * Copyright (c) 2010 - 2019 worse is better UG |
6 | 6 | * Licensed under the MIT license
|
7 | 7 | * https://raw.github.com/worseisbetter/galleria/master/LICENSE
|
8 | 8 | *
|
9 | 9 | */
|
10 | 10 |
|
11 |
| -(function( $, window, Galleria, undef ) { |
| 11 | +( function( window, factory ) { |
| 12 | + if ( typeof define == 'function' && define.amd ) { |
| 13 | + define( [ 'jquery' ], function( jQuery ) { |
| 14 | + return factory( window, jQuery ); |
| 15 | + }); |
| 16 | + } else if ( typeof module == 'object' && module.exports ) { |
| 17 | + module.exports = factory( |
| 18 | + window, |
| 19 | + require('jquery') |
| 20 | + ); |
| 21 | + } else { |
| 22 | + // browser global |
| 23 | + window.Galleria = factory( |
| 24 | + window, |
| 25 | + window.jQuery |
| 26 | + ); |
| 27 | + } |
| 28 | + |
| 29 | +}( window, function factory( window, $, Galleria, undef ) { |
12 | 30 |
|
13 | 31 | /*global jQuery, navigator, Image, module, define */
|
14 | 32 |
|
15 | 33 | // some references
|
16 | 34 | var doc = window.document,
|
17 | 35 | $doc = $( doc ),
|
18 | 36 | $win = $( window ),
|
| 37 | + jQuery = $, |
19 | 38 |
|
20 | 39 | // native prototypes
|
21 | 40 | protoArray = Array.prototype,
|
22 | 41 |
|
23 | 42 | // internal constants
|
24 |
| - VERSION = 1.57, |
| 43 | + VERSION = 1.60, |
25 | 44 | DEBUG = true,
|
26 | 45 | TIMEOUT = 30000,
|
27 | 46 | DUMMY = false,
|
@@ -128,7 +147,7 @@ var doc = window.document,
|
128 | 147 | return PROT + '//img.youtube.com/vi/'+this.id+'/default.jpg';
|
129 | 148 | },
|
130 | 149 | get_image: function( data ) {
|
131 |
| - return PROT + '//img.youtube.com/vi/'+this.id+'/hqdefault.jpg'; } |
| 150 | + return PROT + '//img.youtube.com/vi/'+this.id+'/maxresdefault.jpg'; } |
132 | 151 | },
|
133 | 152 | vimeo: {
|
134 | 153 | reg: /https?:\/\/(?:www\.)?(vimeo\.com)\/(?:hd#)?([0-9]+)/i,
|
@@ -1866,8 +1885,14 @@ Galleria = function() {
|
1866 | 1885 | var image = self._controls.getActive().image;
|
1867 | 1886 | if ( image ) {
|
1868 | 1887 | $( image ).width( big.image.width ).height( big.image.height )
|
1869 |
| - .attr( 'style', $( big.image ).attr('style') ) |
1870 |
| - .attr( 'src', big.image.src ); |
| 1888 | + .attr( 'style', $( big.image ).attr('style') ); |
| 1889 | + if (big.image.src.srcset) { |
| 1890 | + $( image ).attr( 'srcset', big.image.src.srcset ); |
| 1891 | + } |
| 1892 | + if (big.image.src.sizes) { |
| 1893 | + $( image ).attr( 'sizes', big.image.src.sizes ); |
| 1894 | + } |
| 1895 | + $( image ).attr( 'src', big.image.src ); |
1871 | 1896 | }
|
1872 | 1897 | }
|
1873 | 1898 | });
|
@@ -3873,22 +3898,37 @@ Galleria.prototype = {
|
3873 | 3898 | } else if( href && elem.hasClass('iframe') ) {
|
3874 | 3899 | data.iframe = href;
|
3875 | 3900 | } else {
|
3876 |
| - data.image = data.big = href; |
| 3901 | + data.image = href; |
3877 | 3902 | }
|
3878 | 3903 |
|
3879 | 3904 | if ( rel ) {
|
3880 | 3905 | data.big = rel;
|
3881 | 3906 | }
|
3882 | 3907 |
|
3883 |
| - // alternative extraction from HTML5 data attribute, added in 1.2.7 |
3884 |
| - $.each( 'big title description link layer image'.split(' '), function( i, val ) { |
| 3908 | + data.imagesrcset = parent.data( 'srcset' ); |
| 3909 | + data.imagesizes = parent.data( 'sizes' ); |
| 3910 | + data.thumbsizes = elem.attr( 'sizes' ); |
| 3911 | + data.thumbsrcset = elem.attr( 'srcset' ); |
| 3912 | + |
| 3913 | + // alternative extraction from HTML5 data attribute |
| 3914 | + $.each( 'big bigsrcset bigsizes title description link layer image imagesrcset imagesizes'.split(' '), function( i, val ) { |
3885 | 3915 | if ( elem.data(val) ) {
|
3886 | 3916 | data[ val ] = elem.data(val).toString();
|
3887 | 3917 | }
|
3888 | 3918 | });
|
3889 | 3919 |
|
| 3920 | + if (elem.data('srcset')) { |
| 3921 | + data.imagesrcset = elem.data('srcset'); |
| 3922 | + } |
| 3923 | + |
| 3924 | + if (elem.data('sizes')) { |
| 3925 | + data.imagesizes = elem.data('sizes'); |
| 3926 | + } |
| 3927 | + |
3890 | 3928 | if ( !data.big ) {
|
3891 | 3929 | data.big = data.image;
|
| 3930 | + data.bigsrcset = data.imagesrcset; |
| 3931 | + data.bigsizes = data.imagesizes; |
3892 | 3932 | }
|
3893 | 3933 |
|
3894 | 3934 | // mix default extractions with the hrefs and config
|
@@ -3950,6 +3990,15 @@ Galleria.prototype = {
|
3950 | 3990 |
|
3951 | 3991 | current = self._data[ i ];
|
3952 | 3992 |
|
| 3993 | + // q&d hack to attach srcset & sizes to src |
| 3994 | + $.each( 'big image thumb'.split(' '), function( i, val ) { |
| 3995 | + if ( data[ val] ) { |
| 3996 | + data[val] = new String(data[val]); |
| 3997 | + data[val].srcset = data [val + 'srcset']; |
| 3998 | + data[val].sizes = data [val + 'sizes']; |
| 3999 | + } |
| 4000 | + }); |
| 4001 | + |
3953 | 4002 | // copy image as thumb if no thumb exists
|
3954 | 4003 | if ( 'thumb' in data === false ) {
|
3955 | 4004 | current.thumb = data.image;
|
@@ -4029,6 +4078,7 @@ Galleria.prototype = {
|
4029 | 4078 | this.clearTimer();
|
4030 | 4079 | Utils.removeFromArray( _instances, this );
|
4031 | 4080 | Utils.removeFromArray( _galleries, this );
|
| 4081 | + _video._inst = []; |
4032 | 4082 | if ( Galleria._waiters !== undefined && Galleria._waiters.length ) {
|
4033 | 4083 | $.each( Galleria._waiters, function( i, w ) {
|
4034 | 4084 | if ( w ) window.clearTimeout( w );
|
@@ -6168,11 +6218,22 @@ Galleria.Picture.prototype = {
|
6168 | 6218 | */
|
6169 | 6219 |
|
6170 | 6220 | preload: function( src ) {
|
6171 |
| - $( new Image() ).on( 'load', (function(src, cache) { |
| 6221 | + var $image = $( new Image() ).on( 'load', (function(src, cache) { |
6172 | 6222 | return function() {
|
6173 | 6223 | cache[ src ] = src;
|
6174 | 6224 | };
|
6175 |
| - }( src, this.cache ))).attr( 'src', src ); |
| 6225 | + }( src, this.cache ))); |
| 6226 | + |
| 6227 | + // due to a bug in safari, need to set srcset first |
| 6228 | + if (src.srcset) { |
| 6229 | + $image.attr( 'srcset', src.srcset ); |
| 6230 | + } |
| 6231 | + |
| 6232 | + if (src.sizes) { |
| 6233 | + $image.attr( 'sizes', src.sizes ); |
| 6234 | + } |
| 6235 | + |
| 6236 | + $image.attr( 'src', src ); |
6176 | 6237 | },
|
6177 | 6238 |
|
6178 | 6239 | /**
|
@@ -6340,7 +6401,14 @@ Galleria.Picture.prototype = {
|
6340 | 6401 | });
|
6341 | 6402 |
|
6342 | 6403 | // begin load and insert in cache when done
|
6343 |
| - $image.on( 'load', onload ).on( 'error', onerror ).attr( 'src', src ); |
| 6404 | + $image.on( 'load', onload ).on( 'error', onerror ); |
| 6405 | + if (src.srcset) { |
| 6406 | + $image.attr( 'srcset', src.srcset ); |
| 6407 | + } |
| 6408 | + if (src.sizes) { |
| 6409 | + $image.attr( 'sizes', src.sizes ); |
| 6410 | + } |
| 6411 | + $image.attr( 'src', src ); |
6344 | 6412 |
|
6345 | 6413 | // return the container
|
6346 | 6414 | return this.container;
|
@@ -6915,16 +6983,7 @@ $.fn.galleria = function( options ) {
|
6915 | 6983 |
|
6916 | 6984 | };
|
6917 | 6985 |
|
6918 |
| -// export as AMD or CommonJS |
6919 |
| -if ( typeof module === "object" && module && typeof module.exports === "object" ) { |
6920 |
| - module.exports = Galleria; |
6921 |
| -} else { |
6922 |
| - window.Galleria = Galleria; |
6923 |
| - if ( typeof define === "function" && define.amd ) { |
6924 |
| - define( "galleria", ['jquery'], function() { return Galleria; } ); |
6925 |
| - } |
6926 |
| -} |
6927 |
| - |
6928 | 6986 | // phew
|
| 6987 | +return Galleria; |
6929 | 6988 |
|
6930 |
| -}( jQuery, this ) ); |
| 6989 | +})); |
0 commit comments