Changeset 106707 in spip-zone


Ignore:
Timestamp:
Oct 10, 2017, 9:43:56 AM (3 years ago)
Author:
marcimat@…
Message:

Galleria avec lib à jour et compatible 3.2

Location:
_plugins_/galleria/trunk
Files:
26 added
2 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/galleria/trunk/galleria/LICENSE

    r64242 r106707  
    11The MIT License
    22
    3 Copyright (c) 2012 Aino http://aino.se
     3Copyright (c) 2016 worse is better UG http://wib.io
    44
    55Permission is hereby granted, free of charge, to any person obtaining a copy
  • _plugins_/galleria/trunk/galleria/galleria.js

    r72410 r106707  
    11/**
    2  * Galleria v 1.2.9 2013-02-14
     2 * Galleria v1.5.7 2017-05-10
    33 * http://galleria.io
    44 *
     5 * Copyright (c) 2010 - 2016 worse is better UG
    56 * Licensed under the MIT license
    6  * https://raw.github.com/aino/galleria/master/LICENSE
     7 * https://raw.github.com/worseisbetter/galleria/master/LICENSE
    78 *
    89 */
    910
    10 (function( $ ) {
    11 
    12 /*global jQuery, navigator, Galleria:true, Image */
     11(function( $, window, Galleria, undef ) {
     12
     13/*global jQuery, navigator, Image, module, define */
    1314
    1415// some references
    15 var undef,
    16     window = this,
    17     doc    = window.document,
     16var doc    = window.document,
    1817    $doc   = $( doc ),
    1918    $win   = $( window ),
     
    2322
    2423// internal constants
    25     VERSION = 1.29,
     24    VERSION = 1.57,
    2625    DEBUG = true,
    2726    TIMEOUT = 30000,
     
    2928    NAV = navigator.userAgent.toLowerCase(),
    3029    HASH = window.location.hash.replace(/#\//, ''),
     30    PROT = window.location.protocol == "file:" ? "http:" : window.location.protocol,
     31    M = Math,
    3132    F = function(){},
    3233    FALSE = function() { return false; },
     34    MOBILE = !(
     35        ( window.screen.width > 1279 && window.devicePixelRatio == 1 ) || // there are not so many mobile devices with more than 1280px and pixelRatio equal to 1 (i.e. retina displays are equal to 2...)
     36        ( window.screen.width > 1000 && window.innerWidth < (window.screen.width * .9) ) // this checks in the end if a user is using a resized browser window which is not common on mobile devices
     37    ),
    3338    IE = (function() {
    3439
     
    4146        } while ( all[0] );
    4247
    43         return v > 4 ? v : undef;
     48        return v > 4 ? v : doc.documentMode || undef;
    4449
    4550    }() ),
     
    117122        youtube: {
    118123            reg: /https?:\/\/(?:[a-zA_Z]{2,3}.)?(?:youtube\.com\/watch\?)((?:[\w\d\-\_\=]+&amp;(?:amp;)?)*v(?:&lt;[A-Z]+&gt;)?=([0-9a-zA-Z\-\_]+))/i,
    119             embed: function(id) {
    120                 return 'http://www.youtube.com/embed/'+id;
     124            embed: function() {
     125                return PROT + '//www.youtube.com/embed/' + this.id;
    121126            },
    122             getThumb: function( id, success, fail ) {
    123                 fail = fail || F;
    124                 $.getJSON(window.location.protocol+'//gdata.youtube.com/feeds/api/videos/' + id + '?v=2&alt=json-in-script&callback=?', function(data) {
    125                     try {
    126                         success( data.entry.media$group.media$thumbnail[0].url );
    127                     } catch(e) {
    128                         fail();
    129                     }
    130                 }).error(fail);
    131             }
     127            get_thumb: function( data ) {
     128                return PROT + '//img.youtube.com/vi/'+this.id+'/default.jpg';
     129            },
     130            get_image: function( data ) {
     131                return PROT + '//img.youtube.com/vi/'+this.id+'/hqdefault.jpg';            }
    132132        },
    133133        vimeo: {
    134134            reg: /https?:\/\/(?:www\.)?(vimeo\.com)\/(?:hd#)?([0-9]+)/i,
    135             embed: function(id) {
    136                 return 'http://player.vimeo.com/video/'+id;
     135            embed: function() {
     136                return PROT + '//player.vimeo.com/video/' + this.id;
    137137            },
    138             getThumb: function( id, success, fail ) {
    139                 fail = fail || F;
    140                 $.getJSON('http://vimeo.com/api/v2/video/' + id + '.json?callback=?', function(data) {
    141                     try {
    142                         success( data[0].thumbnail_medium );
    143                     } catch(e) {
    144                         fail();
    145                     }
    146                 }).error(fail);
     138            getUrl: function() {
     139                return PROT + '//vimeo.com/api/v2/video/' + this.id + '.json?callback=?';
     140            },
     141            get_thumb: function( data ) {
     142                return data[0].thumbnail_medium;
     143            },
     144            get_image: function( data ) {
     145                return data[0].thumbnail_large;
    147146            }
    148147        },
    149148        dailymotion: {
    150149            reg: /https?:\/\/(?:www\.)?(dailymotion\.com)\/video\/([^_]+)/,
    151             embed: function(id) {
    152                 return 'http://www.dailymotion.com/embed/video/'+id;
     150            embed: function() {
     151                return PROT + '//www.dailymotion.com/embed/video/' + this.id;
    153152            },
    154             getThumb: function( id, success, fail ) {
    155                 fail = fail || F;
    156                 $.getJSON('https://api.dailymotion.com/video/'+id+'?fields=thumbnail_medium_url&callback=?', function(data) {
    157                     try {
    158                         success( data.thumbnail_medium_url );
    159                     } catch(e) {
    160                         fail();
    161                     }
    162                 }).error(fail);
    163             }
    164         }
     153            getUrl: function() {
     154                return 'https://api.dailymotion.com/video/' + this.id + '?fields=thumbnail_240_url,thumbnail_720_url&callback=?';
     155            },
     156            get_thumb: function( data ) {
     157                return data.thumbnail_240_url;
     158            },
     159            get_image: function( data ) {
     160                return data.thumbnail_720_url;
     161            }
     162        },
     163        _inst: []
     164    },
     165    Video = function( type, id ) {
     166
     167        for( var i=0; i<_video._inst.length; i++ ) {
     168            if ( _video._inst[i].id === id && _video._inst[i].type == type ) {
     169                return _video._inst[i];
     170            }
     171        }
     172
     173        this.type = type;
     174        this.id = id;
     175        this.readys = [];
     176
     177        _video._inst.push(this);
     178
     179        var self = this;
     180
     181        $.extend( this, _video[type] );
     182
     183        _videoThumbs = function(data) {
     184            self.data = data;
     185            $.each( self.readys, function( i, fn ) {
     186                fn( self.data );
     187            });
     188            self.readys = [];
     189        };
     190
     191        if ( this.hasOwnProperty('getUrl') ) {
     192            $.getJSON( this.getUrl(), _videoThumbs);
     193        } else {
     194            window.setTimeout(_videoThumbs, 400);
     195        }
     196
     197        this.getMedia = function( type, callback, fail ) {
     198            fail = fail || F;
     199            var self = this;
     200            var success = function( data ) {
     201                callback( self['get_'+type]( data ) );
     202            };
     203            try {
     204                if ( self.data ) {
     205                    success( self.data );
     206                } else {
     207                    self.readys.push( success );
     208                }
     209            } catch(e) {
     210                fail();
     211            }
     212        };
    165213    },
    166214
     
    169217        var match;
    170218        for ( var v in _video ) {
    171             match = url && url.match( _video[v].reg );
     219            match = url && _video[v].reg && url.match( _video[v].reg );
    172220            if( match && match.length ) {
    173221                return {
     
    185233        support: (function() {
    186234            var html = DOM().html;
    187             return !IFRAME && ( html.requestFullscreen || html.mozRequestFullScreen || html.webkitRequestFullScreen );
     235            return !IFRAME && ( html.requestFullscreen || html.msRequestFullscreen || html.mozRequestFullScreen || html.webkitRequestFullScreen );
    188236        }()),
    189237
     
    200248                elem.requestFullscreen();
    201249            }
     250            else if ( elem.msRequestFullscreen ) {
     251                elem.msRequestFullscreen();
     252            }
    202253            else if ( elem.mozRequestFullScreen ) {
    203254                elem.mozRequestFullScreen();
     
    215266                doc.exitFullscreen();
    216267            }
     268            else if ( doc.msExitFullscreen ) {
     269                doc.msExitFullscreen();
     270            }
    217271            else if ( doc.mozCancelFullScreen ) {
    218272                doc.mozCancelFullScreen();
     
    238292                var fs = _nativeFullscreen.instance._fullscreen;
    239293
    240                 if ( doc.fullscreen || doc.mozFullScreen || doc.webkitIsFullScreen ) {
     294                if ( doc.fullscreen || doc.mozFullScreen || doc.webkitIsFullScreen || ( doc.msFullscreenElement && doc.msFullscreenElement !== null ) ) {
    241295                    fs._enter( _nativeFullscreen.callback );
    242296                } else {
     
    245299            };
    246300            doc.addEventListener( 'fullscreenchange', handler, false );
     301            doc.addEventListener( 'MSFullscreenChange', handler, false );
    247302            doc.addEventListener( 'mozfullscreenchange', handler, false );
    248303            doc.addEventListener( 'webkitfullscreenchange', handler, false );
     
    265320    _pool = [],
    266321
    267     // themeLoad trigger
     322    // Run galleries from theme trigger
     323    _loadedThemes = [],
    268324    _themeLoad = function( theme ) {
    269325
    270         Galleria.theme = theme;
     326        _loadedThemes.push(theme);
    271327
    272328        // run the instances we have in the pool
     329        // and apply the last theme if not specified
    273330        $.each( _pool, function( i, instance ) {
    274             if ( !instance._initialized ) {
     331            if ( instance._options.theme == theme.name || (!instance._initialized && !instance._options.theme) ) {
     332                instance.theme = theme;
    275333                instance._init.call( instance );
    276334            }
    277335        });
    278 
    279         _pool = [];
    280336    },
    281337
     
    430486                    if ( options.stop ) {
    431487                        // clear the animation
    432                         elem.unbind( endEvent );
     488                        elem.off( endEvent );
    433489                        clearStyle( elem );
    434490                    }
     
    518574
    519575            removeAlpha : function( elem ) {
     576                if ( elem instanceof jQuery ) {
     577                    elem = elem[0];
     578                }
    520579                if ( IE < 9 && elem ) {
    521580
     
    563622            },
    564623
    565             elem : function( elem ) {
    566                 if (elem instanceof $) {
    567                     return {
    568                         $: elem,
    569                         dom: elem[0]
    570                     };
    571                 } else {
    572                     return {
    573                         $: $(elem),
    574                         dom: elem
    575                     };
    576                 }
    577             },
    578 
    579624            hide : function( elem, speed, callback ) {
    580625
    581626                callback = callback || F;
    582627
    583                 var el = Utils.elem( elem ),
    584                     $elem = el.$;
    585 
    586                 elem = el.dom;
     628                var $elem = $(elem);
     629                elem = $elem[0];
    587630
    588631                // save the value if not exist
     
    621664                callback = callback || F;
    622665
    623                 var el = Utils.elem( elem ),
    624                     $elem = el.$;
    625 
    626                 elem = el.dom;
     666                var $elem = $(elem);
     667                elem = $elem[0];
    627668
    628669                // bring back saved opacity
     
    660701            },
    661702
    662 
    663             // enhanced click for mobile devices
    664             // we bind a touchend and hijack any click event in the bubble
    665             // then we execute the click directly and save it in a separate data object for later
    666             optimizeTouch: (function() {
    667 
    668                 var node,
    669                     evs,
    670                     fakes,
    671                     travel,
    672                     evt = {},
    673                     handler = function( e ) {
    674                         e.preventDefault();
    675                         evt = $.extend({}, e, true);
    676                     },
    677                     attach = function() {
    678                         this.evt = evt;
    679                     },
    680                     fake = function() {
    681                         this.handler.call(node, this.evt);
    682                     };
    683 
    684                 return function( elem ) {
    685 
    686                     $(elem).bind('touchend', function( e ) {
    687 
    688                         node = e.target;
    689                         travel = true;
    690 
    691                         while( node.parentNode && node != e.currentTarget && travel ) {
    692 
    693                             evs =   $(node).data('events');
    694                             fakes = $(node).data('fakes');
    695 
    696                             if (evs && 'click' in evs) {
    697 
    698                                 travel = false;
    699                                 e.preventDefault();
    700 
    701                                 // fake the click and save the event object
    702                                 $(node).click(handler).click();
    703 
    704                                 // remove the faked click
    705                                 evs.click.pop();
    706 
    707                                 // attach the faked event
    708                                 $.each( evs.click, attach);
    709 
    710                                 // save the faked clicks in a new data object
    711                                 $(node).data('fakes', evs.click);
    712 
    713                                 // remove all clicks
    714                                 delete evs.click;
    715 
    716                             } else if ( fakes ) {
    717 
    718                                 travel = false;
    719                                 e.preventDefault();
    720 
    721                                 // fake all clicks
    722                                 $.each( fakes, fake );
    723                             }
    724 
    725                             // bubble
    726                             node = node.parentNode;
    727                         }
    728                     });
    729                 };
    730             }()),
    731 
    732703            wait : function(options) {
     704
     705                Galleria._waiters = Galleria._waiters || [];
     706
    733707                options = $.extend({
    734708                    until : FALSE,
     
    741715                    elapsed,
    742716                    now,
     717                    tid,
    743718                    fn = function() {
    744719                        now = Utils.timestamp();
    745720                        elapsed = now - start;
     721                        Utils.removeFromArray( Galleria._waiters, tid );
    746722                        if ( options.until( elapsed ) ) {
    747723                            options.success();
    748724                            return false;
    749725                        }
    750 
    751726                        if (typeof options.timeout == 'number' && now >= start + options.timeout) {
    752727                            options.error();
    753728                            return false;
    754729                        }
    755                         window.setTimeout(fn, 10);
     730                        Galleria._waiters.push( tid = window.setTimeout(fn, 10) );
    756731                    };
    757 
    758                 window.setTimeout(fn, 10);
     732                Galleria._waiters.push( tid = window.setTimeout(fn, 10) );
    759733            },
    760734
     
    887861                    }
    888862
    889                     if ( IE ) {
    890 
    891                         // IE has a limit of 31 stylesheets in one document
    892                         if( length >= 31 ) {
    893                             Galleria.raise( 'You have reached the browser stylesheet limit (31)', true );
    894                             return;
    895                         }
     863                    if ( IE && length >= 31 ) {
     864                        Galleria.raise( 'You have reached the browser stylesheet limit (31)', true );
     865                        return;
    896866                    }
    897867                }
     
    904874                    Utils.wait({
    905875                        until: function() {
    906                             return $loader.height() == 1;
     876                            return $loader.height() > 0;
    907877                        },
    908878                        success: function() {
     
    925895        };
    926896    }()),
     897
     898    // play icon
     899    _playIcon = function( container ) {
     900
     901        var css = '.galleria-videoicon{width:60px;height:60px;position:absolute;top:50%;left:50%;z-index:1;' +
     902                  'margin:-30px 0 0 -30px;cursor:pointer;background:#000;background:rgba(0,0,0,.8);border-radius:3px;-webkit-transition:all 150ms}' +
     903                  '.galleria-videoicon i{width:0px;height:0px;border-style:solid;border-width:10px 0 10px 16px;display:block;' +
     904                  'border-color:transparent transparent transparent #ffffff;margin:20px 0 0 22px}.galleria-image:hover .galleria-videoicon{background:#000}';
     905
     906        Utils.insertStyleTag( css, 'galleria-videoicon' );
     907
     908        return $( Utils.create( 'galleria-videoicon' ) ).html( '<i></i>' ).appendTo( container )
     909            .click( function() { $( this ).siblings( 'img' ).mouseup(); });
     910    },
    927911
    928912    // the transitions holder
     
    10781062    }());
    10791063
     1064// listen to fullscreen
    10801065_nativeFullscreen.listen();
     1066
     1067// create special click:fast event for fast touch interaction
     1068$.event.special['click:fast'] = {
     1069    propagate: true,
     1070    add: function(handleObj) {
     1071
     1072        var getCoords = function(e) {
     1073            if ( e.touches && e.touches.length ) {
     1074                var touch = e.touches[0];
     1075                return {
     1076                    x: touch.pageX,
     1077                    y: touch.pageY
     1078                };
     1079            }
     1080        };
     1081
     1082        var def = {
     1083            touched: false,
     1084            touchdown: false,
     1085            coords: { x:0, y:0 },
     1086            evObj: {}
     1087        };
     1088
     1089        $(this).data({
     1090            clickstate: def,
     1091            timer: 0
     1092        }).on('touchstart.fast', function(e) {
     1093            window.clearTimeout($(this).data('timer'));
     1094            $(this).data('clickstate', {
     1095                touched: true,
     1096                touchdown: true,
     1097                coords: getCoords(e.originalEvent),
     1098                evObj: e
     1099            });
     1100        }).on('touchmove.fast', function(e) {
     1101            var coords = getCoords(e.originalEvent),
     1102                state = $(this).data('clickstate'),
     1103                distance = Math.max(
     1104                    Math.abs(state.coords.x - coords.x),
     1105                    Math.abs(state.coords.y - coords.y)
     1106                );
     1107            if ( distance > 6 ) {
     1108                $(this).data('clickstate', $.extend(state, {
     1109                    touchdown: false
     1110                }));
     1111            }
     1112        }).on('touchend.fast', function(e) {
     1113            var $this = $(this),
     1114                state = $this.data('clickstate');
     1115            if(state.touchdown) {
     1116              handleObj.handler.call(this, e);
     1117            }
     1118            $this.data('timer', window.setTimeout(function() {
     1119                $this.data('clickstate', def);
     1120            }, 400));
     1121        }).on('click.fast', function(e) {
     1122            var state = $(this).data('clickstate');
     1123            if ( state.touched ) {
     1124                return false;
     1125            }
     1126            $(this).data('clickstate', def);
     1127            handleObj.handler.call(this, e);
     1128        });
     1129    },
     1130    remove: function() {
     1131        $(this).off('touchstart.fast touchmove.fast touchend.fast click.fast');
     1132    }
     1133};
     1134
     1135// trigger resize on orientationchange (IOS7)
     1136$win.on( 'orientationchange', function() {
     1137    $(this).resize();
     1138});
    10811139
    10821140/**
     
    10881146    @example var gallery = new Galleria();
    10891147
    1090     @author http://aino.se
     1148    @author http://wib.io
    10911149
    10921150    @requires jQuery
     
    11421200
    11431201    // instance id
    1144     this._id = parseInt(Math.random()*10000, 10);
     1202    this._id = parseInt(M.random()*10000, 10);
    11451203
    11461204    // add some elements
     
    12011259            if ( !keyboard.bound ) {
    12021260                keyboard.bound = true;
    1203                 $doc.bind('keydown', keyboard.press);
     1261                $doc.on('keydown', keyboard.press);
    12041262            }
    12051263        },
     
    12081266            keyboard.bound = false;
    12091267            keyboard.map = {};
    1210             $doc.unbind('keydown', keyboard.press);
     1268            $doc.off('keydown', keyboard.press);
    12111269        }
    12121270    };
     
    12261284
    12271285        getActive : function() {
    1228             return controls[ controls.active ];
     1286            return self._options.swipe ? controls.slides[ self._active ] : controls[ controls.active ];
    12291287        },
    12301288
    12311289        getNext : function() {
    1232             return controls[ 1 - controls.active ];
    1233         }
     1290            return self._options.swipe ? controls.slides[ self.getNext( self._active ) ] : controls[ 1 - controls.active ];
     1291        },
     1292
     1293        slides : [],
     1294
     1295        frames: [],
     1296
     1297        layers: []
    12341298    };
    12351299
     
    12631327                if ( thumb.ready ) {
    12641328                    w += thumb.outerWidth || $( thumb.container ).outerWidth( true );
     1329                    // Due to a bug in jquery, outerwidth() returns the floor of the actual outerwidth,
     1330                    // if the browser is zoom to a value other than 100%. height() returns the floating point value.
     1331                    var containerWidth = $( thumb.container).width();
     1332                    w += containerWidth - M.floor(containerWidth);
     1333
    12651334                    hooks[ i+1 ] = w;
    1266                     h = Math.max( h, thumb.outerHeight || $( thumb.container).outerHeight( true ) );
     1335                    h = M.max( h, thumb.outerHeight || $( thumb.container).outerHeight( true ) );
    12671336                }
    12681337            });
     
    12901359            var i;
    12911360
    1292             carousel.next.bind( 'click', function(e) {
     1361            carousel.next.on( 'click:fast', function(e) {
    12931362                e.preventDefault();
    12941363
     
    13071376            });
    13081377
    1309             carousel.prev.bind( 'click', function(e) {
     1378            carousel.prev.on( 'click:fast', function(e) {
    13101379                e.preventDefault();
    13111380
     
    13291398        // calculate and set positions
    13301399        set: function( i ) {
    1331             i = Math.max( i, 0 );
     1400            i = M.max( i, 0 );
    13321401            while ( carousel.hooks[i - 1] + carousel.width >= carousel.max && i >= 0 ) {
    13331402                i--;
     
    13801449                return;
    13811450            }
     1451
     1452            // FF 24 bug
     1453            self.$( 'thumbnails' ).css('left', function() {
     1454                return $(this).css('left');
     1455            });
    13821456
    13831457            Utils.animate(self.get( 'thumbnails' ), {
     
    14391513                y -= ( height+8 );
    14401514
    1441                 x = Math.max( 0, Math.min( maxX, x ) );
    1442                 y = Math.max( 0, Math.min( maxY, y ) );
     1515                x = M.max( 0, M.min( maxX, x ) );
     1516                y = M.max( 0, M.min( maxY, y ) );
    14431517
    14441518                if( mouseY < limitY ) {
     
    14651539
    14661540            var mouseout = function() {
    1467                 self.$( 'container' ).unbind( 'mousemove', tooltip.move );
     1541                self.$( 'container' ).off( 'mousemove', tooltip.move );
    14681542                self.clearTimer( tooltip.timer );
    14691543
     
    14871561
    14881562                    self.clearTimer( tooltip.swapTimer );
    1489                     self.$('container').unbind( 'mousemove', tooltip.move ).bind( 'mousemove', tooltip.move ).trigger( 'mousemove' );
     1563                    self.$('container').off( 'mousemove', tooltip.move ).on( 'mousemove', tooltip.move ).trigger( 'mousemove' );
    14901564                    tooltip.show( elem );
    14911565
     
    15251599                    }( e )), 10);
    15261600
    1527                     elem.unbind( 'mouseup', mouseup );
     1601                    elem.off( 'mouseup', mouseup );
    15281602
    15291603                };
     
    15381612
    15391613            // trigger mousemove on mouseup in case of click
    1540             elem.bind( 'mouseup', mouseup );
     1614            elem.on( 'mouseup', mouseup );
    15411615        },
    15421616
     
    15671641        active: false,
    15681642
     1643        prev: $(),
     1644
     1645        beforeEnter: function(fn){ fn(); },
     1646        beforeExit:  function(fn){ fn(); },
     1647
    15691648        keymap: self._keyboard.map,
    15701649
     
    15921671        enter: function( callback ) {
    15931672
    1594             callback = fullscreen.parseCallback( callback, true );
    1595 
    1596             if ( self._options.trueFullscreen && _nativeFullscreen.support ) {
    1597 
    1598                 // do some stuff prior animation for wmoother transitions
    1599 
    1600                 fullscreen.active = true;
    1601 
    1602                 Utils.forceStyles( self.get('container'), {
    1603                     width: '100%',
    1604                     height: '100%'
    1605                 });
    1606 
    1607                 self.rescale();
    1608 
    1609                 if ( Galleria.MAC ) {
    1610                     if ( Galleria.WEBKIT && !( Galleria.SAFARI && /version\/[1-5]/.test(NAV)) ) {
    1611                         self.$('container').css('opacity', 0).addClass('fullscreen');
    1612                         window.setTimeout(function() {
    1613                             fullscreen.scale();
    1614                             self.$('container').css('opacity', 1);
    1615                         }, 50);
     1673            fullscreen.beforeEnter(function() {
     1674
     1675                callback = fullscreen.parseCallback( callback, true );
     1676
     1677                if ( self._options.trueFullscreen && _nativeFullscreen.support ) {
     1678
     1679                    // do some stuff prior animation for wmoother transitions
     1680
     1681                    fullscreen.active = true;
     1682
     1683                    Utils.forceStyles( self.get('container'), {
     1684                        width: '100%',
     1685                        height: '100%'
     1686                    });
     1687
     1688                    self.rescale();
     1689
     1690                    if ( Galleria.MAC ) {
     1691                        if ( !( Galleria.SAFARI && /version\/[1-5]/.test(NAV)) ) {
     1692                            self.$('container').css('opacity', 0).addClass('fullscreen');
     1693                            window.setTimeout(function() {
     1694                                fullscreen.scale();
     1695                                self.$('container').css('opacity', 1);
     1696                            }, 50);
     1697                        } else {
     1698                            self.$('stage').css('opacity', 0);
     1699                            window.setTimeout(function() {
     1700                                fullscreen.scale();
     1701                                self.$('stage').css('opacity', 1);
     1702                            },4);
     1703                        }
    16161704                    } else {
    1617                         self.$('stage').css('opacity', 0);
    1618                         window.setTimeout(function() {
    1619                             fullscreen.scale();
    1620                             self.$('stage').css('opacity', 1);
    1621                         },4);
    1622                     }
     1705                        self.$('container').addClass('fullscreen');
     1706                    }
     1707
     1708                    $win.resize( fullscreen.scale );
     1709
     1710                    _nativeFullscreen.enter( self, callback, self.get('container') );
     1711
    16231712                } else {
    1624                     self.$('container').addClass('fullscreen');
    1625                 }
    1626 
    1627                 $win.resize( fullscreen.scale );
    1628 
    1629                 _nativeFullscreen.enter( self, callback, self.get('container') );
    1630 
    1631             } else {
    1632 
    1633                 fullscreen.scrolled = $win.scrollTop();
    1634                 window.scrollTo(0, 0);
    1635 
    1636                 fullscreen._enter( callback );
    1637             }
     1713
     1714                    fullscreen.scrolled = $win.scrollTop();
     1715                    if( !Galleria.TOUCH ) {
     1716                        window.scrollTo(0, 0);
     1717                    }
     1718
     1719                    fullscreen._enter( callback );
     1720                }
     1721            });
    16381722
    16391723        },
     
    16971781
    16981782                self.$('container').addClass('fullscreen');
     1783                fullscreen.prev = self.$('container').prev();
     1784
     1785                if ( !fullscreen.prev.length ) {
     1786                    fullscreen.parent = self.$( 'container' ).parent();
     1787                }
     1788
     1789                // move
     1790                self.$( 'container' ).appendTo( 'body' );
    16991791
    17001792                // begin styleforce
    17011793
    17021794                Utils.forceStyles(self.get('container'), {
    1703                     position: 'fixed',
     1795                    position: Galleria.TOUCH ? 'absolute' : 'fixed',
    17041796                    top: 0,
    17051797                    left: 0,
     
    17811873                    });
    17821874                });
     1875
     1876                var n = self.getNext(index),
     1877                    p = new Galleria.Picture(),
     1878                    ndata = self.getData( n );
     1879                p.preload( self.isFullscreen() && ndata.big ? ndata.big : ndata.image );
    17831880            }
    17841881
     
    17961893                        callback.call( self );
    17971894                    }
     1895                    self.rescale();
    17981896
    17991897                }, 100);
     
    18161914        exit: function( callback ) {
    18171915
    1818             callback = fullscreen.parseCallback( callback );
    1819 
    1820             if ( self._options.trueFullscreen && _nativeFullscreen.support ) {
    1821                 _nativeFullscreen.exit( callback );
     1916            fullscreen.beforeExit(function() {
     1917
     1918                callback = fullscreen.parseCallback( callback );
     1919
     1920                if ( self._options.trueFullscreen && _nativeFullscreen.support ) {
     1921                    _nativeFullscreen.exit( callback );
     1922                } else {
     1923                    fullscreen._exit( callback );
     1924                }
     1925            });
     1926        },
     1927
     1928        _exit: function( callback ) {
     1929
     1930            fullscreen.active = false;
     1931
     1932            var inBrowser = !self._options.trueFullscreen || !_nativeFullscreen.support,
     1933                $container = self.$( 'container' ).removeClass( 'fullscreen' );
     1934
     1935            // move back
     1936            if ( fullscreen.parent ) {
     1937                fullscreen.parent.prepend( $container );
    18221938            } else {
    1823                 fullscreen._exit( callback );
    1824             }
    1825         },
    1826 
    1827         _exit: function( callback ) {
    1828 
    1829             fullscreen.active = false;
    1830 
    1831             var inBrowser = !self._options.trueFullscreen || !_nativeFullscreen.support;
    1832 
    1833             self.$('container').removeClass( 'fullscreen' );
     1939                $container.insertAfter( fullscreen.prev );
     1940            }
    18341941
    18351942            if ( inBrowser ) {
     
    18401947
    18411948                // scroll back
    1842                 window.scrollTo(0, fullscreen.scrolled);
     1949                if( !Galleria.TOUCH ) {
     1950                    window.scrollTo(0, fullscreen.scrolled);
     1951                }
     1952
     1953                // reload iframe src manually
     1954                var frame = self._controls.frames[ self._controls.active ];
     1955                if ( frame && frame.image ) {
     1956                    frame.image.src = frame.image.src;
     1957                }
    18431958            }
    18441959
     
    18892004            });
    18902005
    1891             $win.unbind('resize', fullscreen.scale);
     2006            $win.off('resize', fullscreen.scale);
    18922007        }
    18932008    };
     
    19032018
    19042019        add: function(elem, to, from, hide) {
    1905             if (!elem) {
     2020            if ( !elem || Galleria.TOUCH ) {
    19062021                return;
    19072022            }
     
    19612076        addEvent : function() {
    19622077            idle.bound = true;
    1963             self.$('container').bind( 'mousemove click', idle.showAll );
     2078            self.$('container').on( 'mousemove click', idle.showAll );
    19642079            if ( self._options.idleMode == 'hover' ) {
    1965                 self.$('container').bind( 'mouseleave', idle.hide );
     2080                self.$('container').on( 'mouseleave', idle.hide );
    19662081            }
    19672082        },
     
    19692084        removeEvent : function() {
    19702085            idle.bound = false;
    1971             self.$('container').bind( 'mousemove click', idle.showAll );
     2086            self.$('container').on( 'mousemove click', idle.showAll );
    19722087            if ( self._options.idleMode == 'hover' ) {
    1973                 self.$('container').unbind( 'mouseleave', idle.hide );
     2088                self.$('container').off( 'mouseleave', idle.hide );
    19742089            }
    19752090        },
     
    19862101        hide : function() {
    19872102
    1988             if ( !self._options.idleMode || self.getIndex() === false || self.getData().iframe ) {
     2103            if ( !self._options.idleMode || self.getIndex() === false ) {
    19892104                return;
    19902105            }
     
    20692184
    20702185        init : function() {
    2071 
    2072             // trigger the event
    2073             self.trigger( Galleria.LIGHTBOX_OPEN );
    20742186
    20752187            if ( lightbox.initialized ) {
     
    21092221                appends = {};
    21102222
    2111             // IE8 fix for IE's transparent background event "feature"
    2112             if ( IE && IE > 7 ) {
    2113                 cssMap.nextholder += 'background:#000;filter:alpha(opacity=0);';
    2114                 cssMap.prevholder += 'background:#000;filter:alpha(opacity=0);';
    2115             }
     2223            // fix for navigation hovers transparent background event "feature"
     2224            var exs = '';
     2225            if ( IE > 7 ) {
     2226                exs = IE < 9 ? 'background:#000;filter:alpha(opacity=0);' : 'background:rgba(0,0,0,0);';
     2227            } else {
     2228                exs = 'z-index:99999';
     2229            }
     2230
     2231            cssMap.nextholder += exs;
     2232            cssMap.prevholder += exs;
    21162233
    21172234            // create and insert CSS
     
    21562273            $( DOM().body ).append( el.overlay, el.box );
    21572274
    2158             Utils.optimizeTouch( el.box );
    2159 
    21602275            // add the prev/next nav and bind some controls
    21612276
    2162             hover( $( el.close ).bind( 'click', lightbox.hide ).html('&#215;') );
     2277            hover( $( el.close ).on( 'click:fast', lightbox.hide ).html('&#215;') );
    21632278
    21642279            $.each( ['Prev','Next'], function(i, dir) {
     
    21672282                    $e = $( el[ dir.toLowerCase()+'holder'] );
    21682283
    2169                 $e.bind( 'click', function() {
     2284                $e.on( 'click:fast', function() {
    21702285                    lightbox[ 'show' + dir ]();
    21712286                });
     
    21842299
    21852300            });
    2186             $( el.overlay ).bind( 'click', lightbox.hide );
     2301            $( el.overlay ).on( 'click:fast', lightbox.hide );
    21872302
    21882303            // the lightbox animation is slow on ipad
     
    21962311
    21972312            // calculate
    2198              var width = Math.min( $win.width()-40, lightbox.width ),
    2199                 height = Math.min( $win.height()-60, lightbox.height ),
    2200                 ratio = Math.min( width / lightbox.width, height / lightbox.height ),
    2201                 destWidth = Math.round( lightbox.width * ratio ) + 40,
    2202                 destHeight = Math.round( lightbox.height * ratio ) + 60,
     2313             var width = M.min( $win.width()-40, lightbox.width ),
     2314                height = M.min( $win.height()-60, lightbox.height ),
     2315                ratio = M.min( width / lightbox.width, height / lightbox.height ),
     2316                destWidth = M.round( lightbox.width * ratio ) + 40,
     2317                destHeight = M.round( lightbox.height * ratio ) + 60,
    22032318                to = {
    22042319                    width: destWidth,
    22052320                    height: destHeight,
    2206                     'margin-top': Math.ceil( destHeight / 2 ) *- 1,
    2207                     'margin-left': Math.ceil( destWidth / 2 ) *- 1
     2321                    'margin-top': M.ceil( destHeight / 2 ) *- 1,
     2322                    'margin-left': M.ceil( destWidth / 2 ) *- 1
    22082323                };
    22092324
     
    22382353            lightbox.image.image = null;
    22392354
    2240             $win.unbind('resize', lightbox.rescale);
    2241 
    2242             $( lightbox.elems.box ).hide();
     2355            $win.off('resize', lightbox.rescale);
     2356
     2357            $( lightbox.elems.box ).hide().find( 'iframe' ).remove();
    22432358
    22442359            Utils.hide( lightbox.elems.info );
     
    22712386            }
    22722387
     2388            // trigger the event
     2389            self.trigger( Galleria.LIGHTBOX_OPEN );
     2390
    22732391            // temporarily attach some keys
    22742392            // save the old ones first in a cloned object
     
    22842402            }
    22852403
    2286             $win.unbind('resize', lightbox.rescale );
     2404            $win.off('resize', lightbox.rescale );
    22872405
    22882406            var data = self.getData(index),
     
    22972415                    p = new Galleria.Picture();
    22982416                    ndata = self.getData( n );
    2299                     p.preload( 'big' in ndata ? ndata.big : ndata.image );
     2417                    p.preload( ndata.big ? ndata.big : ndata.image );
    23002418                    n = self.getNext( n );
    23012419                }
    23022420            } catch(e) {}
    23032421
    2304             lightbox.image.isIframe = !!data.iframe;
    2305 
    2306             $(lightbox.elems.box).toggleClass( 'iframe', !!data.iframe );
    2307 
    2308             lightbox.image.load( data.iframe || data.big || data.image, function( image ) {
     2422            lightbox.image.isIframe = ( data.iframe && !data.image );
     2423
     2424            $( lightbox.elems.box ).toggleClass( 'iframe', lightbox.image.isIframe );
     2425
     2426            $( lightbox.image.container ).find( '.galleria-videoicon' ).remove();
     2427
     2428            lightbox.image.load( data.big || data.image || data.iframe, function( image ) {
    23092429
    23102430                if ( image.isIframe ) {
     
    23132433                        ch = $(window).height();
    23142434
    2315                     if ( self._options.maxVideoSize ) {
    2316                         var r = Math.min( self._options.maxVideoSize/cw, self._options.maxVideoSize/ch );
     2435                    if ( image.video && self._options.maxVideoSize ) {
     2436                        var r = M.min( self._options.maxVideoSize/cw, self._options.maxVideoSize/ch );
    23172437                        if ( r < 1 ) {
    23182438                            cw *= r;
     
    23322452                    height: image.isIframe ? '100%' : '100.1%',
    23332453                    top: 0,
     2454                    bottom: 0,
    23342455                    zIndex: 99998,
    23352456                    opacity: 0,
    23362457                    visibility: 'visible'
    2337                 });
     2458                }).parent().height('100%');
    23382459
    23392460                lightbox.elems.title.innerHTML = data.title || '';
     
    23412462                $win.resize( lightbox.rescale );
    23422463                lightbox.rescale();
     2464
     2465                if( data.image && data.iframe ) {
     2466
     2467                    $( lightbox.elems.box ).addClass('iframe');
     2468
     2469                    if ( data.video ) {
     2470                        var $icon = _playIcon( image.container ).hide();
     2471                        window.setTimeout(function() {
     2472                            $icon.fadeIn(200);
     2473                        }, 200);
     2474                    }
     2475
     2476                    $( image.image ).css( 'cursor', 'pointer' ).mouseup((function(data, image) {
     2477                        return function(e) {
     2478                            $( lightbox.image.container ).find( '.galleria-videoicon' ).remove();
     2479                            e.preventDefault();
     2480                            image.isIframe = true;
     2481                            image.load( data.iframe + ( data.video ? '&autoplay=1' : '' ), {
     2482                                width: '100%',
     2483                                height: IE < 8 ? $( lightbox.image.container ).height() : '100%'
     2484                            });
     2485                        };
     2486                    }(data, image)));
     2487                }
    23432488            });
    23442489
     
    24112556
    24122557    init: function( target, options ) {
    2413 
    2414         var self = this;
    24152558
    24162559        options = _legacyOptions( options );
     
    24952638            showCounter: true,
    24962639            showImagenav: true,
    2497             swipe: true, // 1.2.4
     2640            swipe: 'auto', // 1.2.4 -> revised in 1.3 -> changed type in 1.3.5
     2641            theme: null,
    24982642            thumbCrop: true,
    2499             thumbEventType: 'click',
    2500             thumbFit: true, // legacy, deprecate at 1.3
     2643            thumbEventType: 'click:fast',
    25012644            thumbMargin: 0,
    25022645            thumbQuality: 'auto',
    25032646            thumbDisplayOrder: true, // 1.2.8
     2647            thumbPosition: '50%', // 1.3
    25042648            thumbnails: true,
    25052649            touchTransition: undef, // 1.2.6
     
    25092653            trueFullscreen: true, // 1.2.7
    25102654            useCanvas: false, // 1.2.4
     2655            variation: '', // 1.3.2
     2656            videoPoster: true, // 1.3
    25112657            vimeo: {
    25122658                title: 0,
     
    25302676        this._options.initialTransition = this._options.initialTransition || this._options.transitionInitial;
    25312677
    2532         // turn off debug
    2533         if ( options && options.debug === false ) {
    2534             DEBUG = false;
    2535         }
    2536 
    2537         // set timeout
    2538         if ( options && typeof options.imageTimeout === 'number' ) {
    2539             TIMEOUT = options.imageTimeout;
    2540         }
    2541 
    2542         // set dummy
    2543         if ( options && typeof options.dummy === 'string' ) {
    2544             DUMMY = options.dummy;
     2678        if ( options ) {
     2679
     2680            // turn off debug
     2681            if ( options.debug === false ) {
     2682                DEBUG = false;
     2683            }
     2684
     2685            // set timeout
     2686            if ( typeof options.imageTimeout === 'number' ) {
     2687                TIMEOUT = options.imageTimeout;
     2688            }
     2689
     2690            // set dummy
     2691            if ( typeof options.dummy === 'string' ) {
     2692                DUMMY = options.dummy;
     2693            }
     2694
     2695            // set theme
     2696            if ( typeof options.theme == 'string' ) {
     2697                this._options.theme = options.theme;
     2698            }
    25452699        }
    25462700
     
    25542708
    25552709        // now we just have to wait for the theme...
    2556         if ( typeof Galleria.theme === 'object' ) {
     2710        // first check if it has already loaded
     2711        if ( _loadedThemes.length ) {
     2712            if ( this._options.theme ) {
     2713                for ( var i=0; i<_loadedThemes.length; i++ ) {
     2714                    if( this._options.theme === _loadedThemes[i].name ) {
     2715                        this.theme = _loadedThemes[i];
     2716                        break;
     2717                    }
     2718                }
     2719            } else {
     2720                // if no theme sepcified, apply the first loaded theme
     2721                this.theme = _loadedThemes[0];
     2722            }
     2723        }
     2724
     2725        if ( typeof this.theme == 'object' ) {
    25572726            this._init();
    25582727        } else {
    2559             // push the instance into the pool and run it when the theme is ready
     2728            // if no theme is loaded yet, push the instance into a pool and run it when the theme is ready
    25602729            _pool.push( this );
    25612730        }
     
    25792748        this._initialized = true;
    25802749
    2581         if ( !Galleria.theme ) {
     2750        if ( !this.theme ) {
    25822751            Galleria.raise( 'Init failed: No theme found.', true );
    25832752            return this;
     
    25852754
    25862755        // merge the theme & caller options
    2587         $.extend( true, options, Galleria.theme.defaults, this._original.options, Galleria.configure.options );
     2756        $.extend( true, options, this.theme.defaults, this._original.options, Galleria.configure.options );
     2757
     2758        // internally we use boolean for swipe
     2759        options.swipe = (function(s) {
     2760
     2761            if ( s == 'enforced' ) { return true; }
     2762
     2763            // legacy patch
     2764            if( s === false || s == 'disabled' ) { return false; }
     2765
     2766            return !!Galleria.TOUCH;
     2767
     2768        }( options.swipe ));
     2769
     2770        // disable options that arent compatible with swipe
     2771        if ( options.swipe ) {
     2772            options.clicknext = false;
     2773            options.imagePan = false;
     2774        }
    25882775
    25892776        // check for canvas support
    25902777        (function( can ) {
    2591 
    25922778            if ( !( 'getContext' in can ) ) {
    25932779                can = null;
    25942780                return;
    25952781            }
    2596 
    25972782            _canvas = _canvas || {
    25982783                elem: can,
     
    26012786                length: 0
    26022787            };
    2603 
    26042788        }( doc.createElement( 'canvas' ) ) );
    26052789
    26062790        // bind the gallery to run when data is ready
    26072791        this.bind( Galleria.DATA, function() {
     2792
     2793            // remove big if total pixels are less than 1024 (most phones)
     2794            if ( window.screen && window.screen.width && Array.prototype.forEach ) {
     2795
     2796                this._data.forEach(function(data) {
     2797
     2798                    var density = 'devicePixelRatio' in window ? window.devicePixelRatio : 1,
     2799                        m = M.max( window.screen.width, window.screen.height );
     2800
     2801                    if ( m*density < 1024 ) {
     2802                        data.big = data.image;
     2803                    }
     2804                });
     2805            }
    26082806
    26092807            // save the new data
     
    26952893
    26962894        // add a notouch class on the container to prevent unwanted :hovers on touch devices
    2697         this.$( 'container' ).addClass( Galleria.TOUCH ? 'touch' : 'notouch' );
     2895        this.$( 'container' ).addClass([
     2896            ( Galleria.TOUCH ? 'touch' : 'notouch' ),
     2897            this._options.variation,
     2898            'galleria-theme-'+this.theme.name
     2899        ].join(' '));
    26982900
    26992901        // add images to the controls
    2700         $.each( new Array(2), function( i ) {
    2701 
    2702             // create a new Picture instance
    2703             var image = new Galleria.Picture();
    2704 
    2705             // apply some styles, create & prepend overlay
    2706             $( image.container ).css({
    2707                 position: 'absolute',
    2708                 top: 0,
    2709                 left: 0
    2710             }).prepend( self._layers[i] = $( Utils.create('galleria-layer') ).css({
    2711                 position: 'absolute',
    2712                 top:0, left:0, right:0, bottom:0,
    2713                 zIndex:2
    2714             })[0] );
    2715 
    2716             // append the image
    2717             self.$( 'images' ).append( image.container );
    2718 
    2719             // reload the controls
    2720             self._controls[i] = image;
    2721 
    2722         });
     2902        if ( !this._options.swipe ) {
     2903            $.each( new Array(2), function( i ) {
     2904
     2905                // create a new Picture instance
     2906                var image = new Galleria.Picture();
     2907
     2908                // apply some styles, create & prepend overlay
     2909                $( image.container ).css({
     2910                    position: 'absolute',
     2911                    top: 0,
     2912                    left: 0
     2913                }).prepend( self._layers[i] = $( Utils.create('galleria-layer') ).css({
     2914                    position: 'absolute',
     2915                    top:0, left:0, right:0, bottom:0,
     2916                    zIndex:2
     2917                })[0] );
     2918
     2919                // append the image
     2920                self.$( 'images' ).append( image.container );
     2921
     2922                // reload the controls
     2923                self._controls[i] = image;
     2924
     2925                // build a frame
     2926                var frame = new Galleria.Picture();
     2927                frame.isIframe = true;
     2928
     2929                $( frame.container ).attr('class', 'galleria-frame').css({
     2930                    position: 'absolute',
     2931                    top: 0,
     2932                    left: 0,
     2933                    zIndex: 4,
     2934                    background: '#000',
     2935                    display: 'none'
     2936                }).appendTo( image.container );
     2937
     2938                self._controls.frames[i] = frame;
     2939
     2940            });
     2941        }
    27232942
    27242943        // some forced generic styling
     
    27312950        });
    27322951
     2952        if ( options.swipe ) {
     2953            this.$( 'images' ).css({
     2954                position: 'absolute',
     2955                top: 0,
     2956                left: 0,
     2957                width: 0,
     2958                height: '100%'
     2959            });
     2960            this.finger = new Galleria.Finger(this.get('stage'), {
     2961                onchange: function(page) {
     2962                    self.pause().show(page);
     2963                },
     2964                oncomplete: function(page) {
     2965
     2966                    var index = M.max( 0, M.min( parseInt( page, 10 ), self.getDataLength() - 1 ) ),
     2967                        data = self.getData(index);
     2968
     2969                    $( self._thumbnails[ index ].container )
     2970                        .addClass( 'active' )
     2971                        .siblings( '.active' )
     2972                        .removeClass( 'active' );
     2973
     2974                    if ( !data ) {
     2975                       return;
     2976                    }
     2977
     2978                    // remove video iframes
     2979                    self.$( 'images' ).find( '.galleria-frame' ).css('opacity', 0).hide().find( 'iframe' ).remove();
     2980
     2981                    if ( self._options.carousel && self._options.carouselFollow ) {
     2982                        self._carousel.follow( index );
     2983                    }
     2984                }
     2985            });
     2986            this.bind( Galleria.RESCALE, function() {
     2987                this.finger.setup();
     2988            });
     2989            this.$('stage').on('click', function(e) {
     2990                var data = self.getData();
     2991                if ( !data ) {
     2992                    return;
     2993                }
     2994                if ( data.iframe ) {
     2995
     2996                    if ( self.isPlaying() ) {
     2997                        self.pause();
     2998                    }
     2999                    var frame = self._controls.frames[ self._active ],
     3000                        w = self._stageWidth,
     3001                        h = self._stageHeight;
     3002
     3003                    if ( $( frame.container ).find( 'iframe' ).length ) {
     3004                        return;
     3005                    }
     3006
     3007                    $( frame.container ).css({
     3008                        width: w,
     3009                        height: h,
     3010                        opacity: 0
     3011                    }).show().animate({
     3012                        opacity: 1
     3013                    }, 200);
     3014
     3015                    window.setTimeout(function() {
     3016                        frame.load( data.iframe + ( data.video ? '&autoplay=1' : '' ), {
     3017                            width: w,
     3018                            height: h
     3019                        }, function( frame ) {
     3020                            self.$( 'container' ).addClass( 'videoplay' );
     3021                            frame.scale({
     3022                                width: self._stageWidth,
     3023                                height: self._stageHeight,
     3024                                iframelimit: data.video ? self._options.maxVideoSize : undef
     3025                            });
     3026                        });
     3027                    }, 100);
     3028
     3029                    return;
     3030                }
     3031
     3032                if ( data.link ) {
     3033                    if ( self._options.popupLinks ) {
     3034                        var win = window.open( data.link, '_blank' );
     3035                    } else {
     3036                        window.location.href = data.link;
     3037                    }
     3038                    return;
     3039                }
     3040            });
     3041            this.bind( Galleria.IMAGE, function(e) {
     3042
     3043                self.setCounter( e.index );
     3044                self.setInfo( e.index );
     3045
     3046                var next = this.getNext(),
     3047                    prev = this.getPrev();
     3048
     3049                var preloads = [prev,next];
     3050                preloads.push(this.getNext(next), this.getPrev(prev), self._controls.slides.length-1);
     3051
     3052                var filtered = [];
     3053
     3054                $.each(preloads, function(i, val) {
     3055                    if ( $.inArray(val, filtered) == -1 ) {
     3056                        filtered.push(val);
     3057                    }
     3058                });
     3059
     3060                $.each(filtered, function(i, loadme) {
     3061                    var d = self.getData(loadme),
     3062                        img = self._controls.slides[loadme],
     3063                        src = self.isFullscreen() && d.big ? d.big : ( d.image || d.iframe );
     3064
     3065                    if ( d.iframe && !d.image ) {
     3066                        img.isIframe = true;
     3067                    }
     3068
     3069                    if ( !img.ready ) {
     3070                        self._controls.slides[loadme].load(src, function(img) {
     3071                            if ( !img.isIframe ) {
     3072                                $(img.image).css('visibility', 'hidden');
     3073                            }
     3074                            self._scaleImage(img, {
     3075                                complete: function(img) {
     3076                                    if ( !img.isIframe ) {
     3077                                        $(img.image).css({
     3078                                            opacity: 0,
     3079                                            visibility: 'visible'
     3080                                        }).animate({
     3081                                            opacity: 1
     3082                                        }, 200);
     3083                                    }
     3084                                }
     3085                            });
     3086                        });
     3087                    }
     3088                });
     3089            });
     3090        }
     3091
    27333092        this.$( 'thumbnails, thumbnails-list' ).css({
    27343093            overflow: 'hidden',
     
    27373096
    27383097        // bind image navigation arrows
    2739         this.$( 'image-nav-right, image-nav-left' ).bind( 'click', function(e) {
    2740 
    2741             // tune the clicknext option
    2742             if ( options.clicknext ) {
    2743                 e.stopPropagation();
    2744             }
     3098        this.$( 'image-nav-right, image-nav-left' ).on( 'click:fast', function(e) {
    27453099
    27463100            // pause if options is set
     
    27533107            self[ fn ]();
    27543108
     3109        }).on('click', function(e) {
     3110
     3111            e.preventDefault();
     3112
     3113            // tune the clicknext option
     3114            if ( options.clicknext || options.swipe ) {
     3115                e.stopPropagation();
     3116            }
    27553117        });
    27563118
     
    27933155        // bind window resize for responsiveness
    27943156        if ( options.responsive ) {
    2795             $win.bind( 'resize', function() {
     3157            $win.on( 'resize', function() {
    27963158                if ( !self.isFullscreen() ) {
    27973159                    self.resize();
     
    28003162        }
    28013163
    2802         // bind swipe gesture
    2803         if ( options.swipe ) {
    2804 
    2805             (function( images ) {
    2806 
    2807                 var swipeStart = [0,0],
    2808                     swipeStop = [0,0],
    2809                     limitX = 30,
    2810                     limitY = 100,
    2811                     multi = false,
    2812                     tid = 0,
    2813                     data,
    2814                     ev = {
    2815                         start: 'touchstart',
    2816                         move: 'touchmove',
    2817                         stop: 'touchend'
    2818                     },
     3164        // double-tap/click fullscreen toggle
     3165
     3166        if ( options.fullscreenDoubleTap ) {
     3167
     3168            this.$( 'stage' ).on( 'touchstart', (function() {
     3169                var last, cx, cy, lx, ly, now,
    28193170                    getData = function(e) {
    28203171                        return e.originalEvent.touches ? e.originalEvent.touches[0] : e;
    2821                     },
    2822                     moveHandler = function( e ) {
    2823 
    2824                         if ( e.originalEvent.touches && e.originalEvent.touches.length > 1 ) {
    2825                             return;
    2826                         }
    2827 
    2828                         data = getData( e );
    2829                         swipeStop = [ data.pageX, data.pageY ];
    2830 
    2831                         if ( !swipeStart[0] ) {
    2832                             swipeStart = swipeStop;
    2833                         }
    2834 
    2835                         if ( Math.abs( swipeStart[0] - swipeStop[0] ) > 10 ) {
    2836                             e.preventDefault();
    2837                         }
    2838                     },
    2839                     upHandler = function( e ) {
    2840 
    2841                         images.unbind( ev.move, moveHandler );
    2842 
    2843                         // if multitouch (possibly zooming), abort
    2844                         if ( ( e.originalEvent.touches && e.originalEvent.touches.length ) || multi ) {
    2845                             multi = !multi;
    2846                             return;
    2847                         }
    2848 
    2849                         if ( Utils.timestamp() - tid < 1000 &&
    2850                              Math.abs( swipeStart[0] - swipeStop[0] ) > limitX &&
    2851                              Math.abs( swipeStart[1] - swipeStop[1] ) < limitY ) {
    2852 
    2853                             e.preventDefault();
    2854                             self[ swipeStart[0] > swipeStop[0] ? 'next' : 'prev' ]();
    2855                         }
    2856 
    2857                         swipeStart = swipeStop = [0,0];
    28583172                    };
    2859 
    2860                 images.bind(ev.start, function(e) {
    2861 
    2862                     if ( e.originalEvent.touches && e.originalEvent.touches.length > 1 ) {
     3173                self.$( 'stage' ).on('touchmove', function() {
     3174                    last = 0;
     3175                });
     3176                return function(e) {
     3177                    if( /(-left|-right)/.test(e.target.className) ) {
    28633178                        return;
    28643179                    }
    2865 
    2866                     data = getData(e);
    2867                     tid = Utils.timestamp();
    2868                     swipeStart = swipeStop = [ data.pageX, data.pageY ];
    2869                     images.bind(ev.move, moveHandler ).one(ev.stop, upHandler);
    2870 
    2871                 });
    2872 
    2873             }( self.$( 'images' ) ));
    2874 
    2875             // double-tap/click fullscreen toggle
    2876 
    2877             if ( options.fullscreenDoubleTap ) {
    2878 
    2879                 this.$( 'stage' ).bind( 'touchstart', (function() {
    2880                     var last, cx, cy, lx, ly, now,
    2881                         getData = function(e) {
    2882                             return e.originalEvent.touches ? e.originalEvent.touches[0] : e;
    2883                         };
    2884                     return function(e) {
    2885                         now = Galleria.utils.timestamp();
    2886                         cx = getData(e).pageX;
    2887                         cy = getData(e).pageY;
    2888                         if ( ( now - last < 500 ) && ( cx - lx < 20) && ( cy - ly < 20) ) {
    2889                             self.toggleFullscreen();
    2890                             e.preventDefault();
    2891                             self.$( 'stage' ).unbind( 'touchend', arguments.callee );
    2892                             return;
    2893                         }
    2894                         last = now;
    2895                         lx = cx;
    2896                         ly = cy;
    2897                     };
    2898                 }()));
    2899             }
    2900 
    2901         }
    2902 
    2903         // optimize touch for container
    2904         Utils.optimizeTouch( this.get( 'container' ) );
     3180                    now = Utils.timestamp();
     3181                    cx = getData(e).pageX;
     3182                    cy = getData(e).pageY;
     3183                    if ( e.originalEvent.touches.length < 2 && ( now - last < 300 ) && ( cx - lx < 20) && ( cy - ly < 20) ) {
     3184                        self.toggleFullscreen();
     3185                        e.preventDefault();
     3186                        return;
     3187                    }
     3188                    last = now;
     3189                    lx = cx;
     3190                    ly = cy;
     3191                };
     3192            }()));
     3193        }
    29053194
    29063195        // bind the ons
     
    29583247
    29593248                // else extract the measures from different sources and grab the highest value
    2960                 num[ m ] = Math.max.apply( Math, arr );
     3249                num[ m ] = M.max.apply( M, arr );
    29613250            }
    29623251        });
     
    29833272            thumb,
    29843273            data,
    2985             special,
    29863274
    29873275            $container,
     
    30723360                    margin:   o.thumbMargin,
    30733361                    canvas:   o.useCanvas,
     3362                    position: o.thumbPosition,
    30743363                    complete: function( thumb ) {
    30753364
     
    30793368                            m,
    30803369                            css,
    3081                             data = self.getData( thumb.index ),
    3082                             special = data.thumb.split(':');
     3370                            data = self.getData( thumb.index );
    30833371
    30843372                        // calculate shrinked positions
    30853373                        $.each(arr, function( i, measure ) {
    30863374                            m = measure.toLowerCase();
    3087                             if ( (o.thumbCrop !== true || o.thumbCrop === m ) && o.thumbFit ) {
     3375                            if ( (o.thumbCrop !== true || o.thumbCrop === m ) ) {
    30883376                                css = {};
    30893377                                css[ m ] = thumb[ m ];
     
    31043392                        );
    31053393
    3106                         // get "special" thumbs from provider
    3107                         if( data.iframe && special.length == 2 && special[0] in _video ) {
    3108 
    3109                             _video[ special[0] ].getThumb( special[1], (function(img) {
    3110                                 return function(src) {
    3111                                     img.src = src;
    3112                                     thumbComplete( thumb, callback );
    3113                                 };
    3114                             }( thumb.image ) ));
    3115 
    3116                         } else if ( o.thumbDisplayOrder && !thumb.lazy ) {
     3394                        if ( o.thumbDisplayOrder && !thumb.lazy ) {
    31173395
    31183396                            $.each( thumbchunk, function( i, th ) {
     
    31813459
    31823460                // grab & reset size for smoother thumbnail loads
    3183                 if ( o.thumbFit && o.thumbCrop !== true ) {
     3461                if ( o.thumbCrop !== true ) {
    31843462                    $container.css( { width: 'auto', height: 'auto' } );
    31853463                } else {
     
    31883466
    31893467                // load the thumbnail
    3190                 special = src.split(':');
    3191 
    3192                 if ( special.length == 2 && special[0] in _video ) {
    3193 
    3194                     thumb.video = true;
    3195                     thumb.ready = true;
    3196 
    3197                     thumb.load( gif, {
    3198                         height: thumb.data.height,
    3199                         width: thumb.data.height*1.25
    3200                     }, onThumbLoad);
    3201 
    3202                 } else if ( optval == 'lazy' ) {
     3468                if ( optval == 'lazy' ) {
    32033469
    32043470                    $container.addClass( 'lazy' );
     
    32213487
    32223488            // create empty spans if thumbnails is set to 'empty'
    3223             } else if ( data.iframe || optval === 'empty' || optval === 'numbers' ) {
    3224 
     3489            } else if ( ( data.iframe && optval !== null ) || optval === 'empty' || optval === 'numbers' ) {
    32253490                thumb = {
    3226                     container:  Utils.create( 'galleria-image' ),
     3491                    container: Utils.create( 'galleria-image' ),
    32273492                    image: Utils.create( 'img', 'span' ),
    3228                     ready: true
     3493                    ready: true,
     3494                    data: {
     3495                        order: i
     3496                    }
    32293497                };
    32303498
     
    32583526
    32593527            $( thumb.container ).add( o.keepSource && o.linkSourceImages ? data.original : null )
    3260                 .data('index', i).bind( o.thumbEventType, onThumbEvent )
     3528                .data('index', i).on( o.thumbEventType, onThumbEvent )
    32613529                .data('thumbload', onThumbLoad);
    32623530
     
    32873555        var arr = index.constructor == Array ? index : [ index ],
    32883556            self = this,
    3289             thumbnails = this.$( 'thumbnails' ).children().filter(function() {
    3290                 return $(this).data('lazy-src');
    3291             }),
    32923557            loaded = 0;
    32933558
     
    33003565            var thumb = self._thumbnails[ ind ],
    33013566                data = thumb.data,
    3302                 special = data.src.split(':'),
    33033567                callback = function() {
    33043568                    if ( ++loaded == arr.length && typeof complete == 'function' ) {
     
    33073571                },
    33083572                thumbload = $( thumb.container ).data( 'thumbload' );
    3309             if ( thumb.video ) {
    3310                 thumbload.call( self, thumb, callback );
    3311             } else {
    3312                 thumb.load( data.src , function( thumb ) {
    3313                     thumbload.call( self, thumb, callback );
    3314                 });
     3573            if (thumbload) {
     3574              if ( thumb.video ) {
     3575                  thumbload.call( self, thumb, callback );
     3576              } else {
     3577                  thumb.load( data.src , function( thumb ) {
     3578                      thumbload.call( self, thumb, callback );
     3579                  });
     3580              }
    33153581            }
    33163582        });
     
    34023668                // postrun some stuff after the gallery is ready
    34033669
     3670                // create the touch slider
     3671                if ( self._options.swipe ) {
     3672
     3673                    var $images = self.$( 'images' ).width( self.getDataLength() * self._stageWidth );
     3674                    $.each( new Array( self.getDataLength() ), function(i) {
     3675
     3676                        var image = new Galleria.Picture(),
     3677                            data = self.getData(i);
     3678
     3679                        $( image.container ).css({
     3680                            position: 'absolute',
     3681                            top: 0,
     3682                            left: self._stageWidth*i
     3683                        }).prepend( self._layers[i] = $( Utils.create('galleria-layer') ).css({
     3684                            position: 'absolute',
     3685                            top:0, left:0, right:0, bottom:0,
     3686                            zIndex:2
     3687                        })[0] ).appendTo( $images );
     3688
     3689                        if( data.video ) {
     3690                            _playIcon( image.container );
     3691                        }
     3692
     3693                        self._controls.slides.push(image);
     3694
     3695                        var frame = new Galleria.Picture();
     3696                        frame.isIframe = true;
     3697
     3698                        $( frame.container ).attr('class', 'galleria-frame').css({
     3699                            position: 'absolute',
     3700                            top: 0,
     3701                            left: 0,
     3702                            zIndex: 4,
     3703                            background: '#000',
     3704                            display: 'none'
     3705                        }).appendTo( image.container );
     3706
     3707                        self._controls.frames.push(frame);
     3708                    });
     3709
     3710                    self.finger.setup();
     3711                }
     3712
    34043713                // show counter
    34053714                Utils.show( self.get('counter') );
     
    34573766
    34583767                // call the theme init method
    3459                 Galleria.theme.init.call( self, self._options );
     3768                self.theme.init.call( self, self._options );
    34603769
    34613770                // Trigger Galleria.ready
     
    35353844
    35363845        // if source is a true object, make it into an array
    3537         if( /^function Object/.test( source.constructor ) ) {
     3846        if( $.isPlainObject( source ) ) {
    35383847            source = [source];
    35393848        }
    35403849
    35413850        // check if the data is an array already
    3542         if ( source.constructor === Array ) {
     3851        if ( $.isArray( source ) ) {
    35433852            if ( this.validate( source ) ) {
    35443853                this._data = source;
     
    35733882
    35743883                // alternative extraction from HTML5 data attribute, added in 1.2.7
    3575                 $.each( 'big title description link layer'.split(' '), function( i, val ) {
     3884                $.each( 'big title description link layer image'.split(' '), function( i, val ) {
    35763885                    if ( elem.data(val) ) {
    3577                         data[ val ] = elem.data(val);
     3886                        data[ val ] = elem.data(val).toString();
    35783887                    }
    35793888                });
     3889
     3890                if ( !data.big ) {
     3891                    data.big = data.image;
     3892                }
    35803893
    35813894                // mix default extractions with the hrefs and config
     
    36003913        } else if ( o.dataSort == 'random' ) {
    36013914            this._data.sort( function() {
    3602                 return Math.round(Math.random())-0.5;
     3915                return M.round(M.random())-0.5;
    36033916            });
    36043917        }
    3605 
    3606 
    36073918
    36083919        // trigger the DATA event and return
    36093920        if ( this.getDataLength() ) {
    3610             this._parseData().trigger( Galleria.DATA );
     3921            this._parseData( function() {
     3922                this.trigger( Galleria.DATA );
     3923            } );
    36113924        }
    36123925        return this;
     
    36153928
    36163929    // make sure the data works properly
    3617     _parseData : function() {
     3930    _parseData : function( callback ) {
    36183931
    36193932        var self = this,
    3620             current;
     3933            current,
     3934            ready = false,
     3935            onload = function() {
     3936                var complete = true;
     3937                $.each( self._data, function( i, data ) {
     3938                    if ( data.loading ) {
     3939                        complete = false;
     3940                        return false;
     3941                    }
     3942                });
     3943                if ( complete && !ready ) {
     3944                    ready = true;
     3945                    callback.call( self );
     3946                }
     3947            };
    36213948
    36223949        $.each( this._data, function( i, data ) {
     
    36293956            }
    36303957            // copy image as big image if no biggie exists
    3631             if ( !'big' in data ) {
     3958            if ( !data.big ) {
    36323959                current.big = data.image;
    36333960            }
     
    36373964
    36383965                if ( result ) {
    3639                     current.iframe = _video[ result.provider ].embed( result.id ) + (function() {
     3966                    current.iframe = new Video(result.provider, result.id ).embed() + (function() {
    36403967
    36413968                        // add options
     
    36543981                        return '';
    36553982                    }());
    3656                     delete current.video;
    3657                     if( !('thumb' in current) || !current.thumb ) {
    3658                         current.thumb = result.provider+':'+result.id;
     3983
     3984                    // pre-fetch video providers media
     3985
     3986                    if( !current.thumb || !current.image ) {
     3987                        $.each( ['thumb', 'image'], function( i, type ) {
     3988                            if ( type == 'image' && !self._options.videoPoster ) {
     3989                                current.image = undef;
     3990                                return;
     3991                            }
     3992                            var video = new Video( result.provider, result.id );
     3993                            if ( !current[ type ] ) {
     3994                                current.loading = true;
     3995                                video.getMedia( type, (function(current, type) {
     3996                                    return function(src) {
     3997                                        current[ type ] = src;
     3998                                        if ( type == 'image' && !current.big ) {
     3999                                            current.big = current.image;
     4000                                        }
     4001                                        delete current.loading;
     4002                                        onload();
     4003                                    };
     4004                                }( current, type )));
     4005                            }
     4006                        });
    36594007                    }
    36604008                }
    36614009            }
    36624010        });
     4011
     4012        onload();
    36634013
    36644014        return this;
     
    36754025    destroy : function() {
    36764026        this.$( 'target' ).data( 'galleria', null );
    3677         this.$( 'container' ).unbind( 'galleria' );
     4027        this.$( 'container' ).off( 'galleria' );
    36784028        this.get( 'target' ).innerHTML = this._original.html;
    36794029        this.clearTimer();
    36804030        Utils.removeFromArray( _instances, this );
    36814031        Utils.removeFromArray( _galleries, this );
     4032        if ( Galleria._waiters !== undefined && Galleria._waiters.length ) {
     4033            $.each( Galleria._waiters, function( i, w ) {
     4034                if ( w ) window.clearTimeout( w );
     4035            });
     4036        }
    36824037        return this;
    36834038    },
     
    36984053        window.setTimeout(function() {
    36994054            protoArray.splice.apply( self._data, args );
    3700             self._parseData()._createThumbnails();
     4055            self._parseData( function() {
     4056                self._createThumbnails();
     4057            });
    37014058        },2);
    37024059        return self;
     
    37234080        window.setTimeout(function() {
    37244081            protoArray.push.apply( self._data, args );
    3725             self._parseData()._createThumbnails( args );
    3726         },2);
     4082            self._parseData( function() {
     4083                self._createThumbnails( args );
     4084            });
     4085        }, 2);
    37274086        return self;
    37284087    },
    37294088
    3730     _getActive: function() {
     4089    _getActive : function() {
    37314090        return this._controls.getActive();
    37324091    },
     
    37534112        type = _patchEvent( type );
    37544113
    3755         this.$( 'container' ).bind( type, this.proxy(fn) );
     4114        this.$( 'container' ).on( type, this.proxy(fn) );
    37564115        return this;
    37574116    },
     
    37694128        type = _patchEvent( type );
    37704129
    3771         this.$( 'container' ).unbind( type );
     4130        this.$( 'container' ).off( type );
    37724131        return this;
    37734132    },
     
    39614320
    39624321    /**
     4322        Check if a variation exists
     4323
     4324        @returns {Boolean} If the variation has been applied
     4325    */
     4326
     4327    hasVariation: function( variation ) {
     4328        return $.inArray( variation, this._options.variation.split(/\s+/) ) > -1;
     4329    },
     4330
     4331    /**
    39634332        Get the currently active image element.
    39644333
     
    39674336
    39684337    getActiveImage: function() {
    3969         return this._getActive().image || undef;
     4338        var active = this._getActive();
     4339        return active ? active.image : undef;
    39704340    },
    39714341
     
    40364406            position = function( dist, cur, pos ) {
    40374407                if ( dist > 0 ) {
    4038                     move = Math.round( Math.max( dist * -1, Math.min( 0, cur ) ) );
     4408                    move = M.round( M.max( dist * -1, M.min( 0, cur ) ) );
    40394409                    if ( cache !== move ) {
    40404410
     
    40934463
    40944464        // unbind and bind event
    4095         this.$( 'stage' ).unbind( 'mousemove', calculate ).bind( 'mousemove', calculate );
     4465        this.$( 'stage' ).off( 'mousemove', calculate ).on( 'mousemove', calculate );
    40964466
    40974467        // loop the loop
     
    41234493
    41244494    /**
     4495        Tells you the theme name of the gallery
     4496
     4497        @returns {String} theme name
     4498    */
     4499
     4500    getThemeName : function() {
     4501        return this.theme.name;
     4502    },
     4503
     4504    /**
    41254505        Removes the panning effect set by addPan()
    41264506
     
    41324512        // todo: doublecheck IE8
    41334513
    4134         this.$( 'stage' ).unbind( 'mousemove' );
     4514        this.$( 'stage' ).off( 'mousemove' );
    41354515
    41364516        this.clearTimer( 'pan' + this._id );
     
    42784658        }
    42794659
    4280         var self = this,
    4281 
    4282             complete,
     4660        var complete,
    42834661
    42844662            scaleLayer = function( img ) {
    42854663                $( img.container ).children(':first').css({
    4286                     top: Math.max(0, Utils.parseValue( img.image.style.top )),
    4287                     left: Math.max(0, Utils.parseValue( img.image.style.left )),
     4664                    top: M.max(0, Utils.parseValue( img.image.style.top )),
     4665                    left: M.max(0, Utils.parseValue( img.image.style.left )),
    42884666                    width: Utils.parseValue( img.image.width ),
    42894667                    height: Utils.parseValue( img.image.height )
     
    43964774            self._stageHeight = height || self.$( 'stage' ).height();
    43974775
    4398             // scale the active image
    4399             self._scaleImage();
     4776            if ( self._options.swipe ) {
     4777                $.each( self._controls.slides, function(i, img) {
     4778                    self._scaleImage( img );
     4779                    $( img.container ).css('left', self._stageWidth * i);
     4780                });
     4781                self.$('images').css('width', self._stageWidth * self.getDataLength());
     4782            } else {
     4783                // scale the active image
     4784                self._scaleImage();
     4785            }
    44004786
    44014787            if ( self._options.carousel ) {
    44024788                self.updateCarousel();
     4789            }
     4790
     4791            var frame = self._controls.frames[ self._controls.active ];
     4792
     4793            if (frame) {
     4794                self._controls.frames[ self._controls.active ].scale({
     4795                    width: self._stageWidth,
     4796                    height: self._stageHeight,
     4797                    iframelimit: self._options.maxVideoSize
     4798                });
    44034799            }
    44044800
     
    44304826    },
    44314827
     4828    _preload: function() {
     4829        if ( this._options.preload ) {
     4830            var p, i,
     4831                n = this.getNext(),
     4832                ndata;
     4833            try {
     4834                for ( i = this._options.preload; i > 0; i-- ) {
     4835                    p = new Galleria.Picture();
     4836                    ndata = this.getData( n );
     4837                    p.preload( this.isFullscreen() && ndata.big ? ndata.big : ndata.image );
     4838                    n = this.getNext( n );
     4839                }
     4840            } catch(e) {}
     4841        }
     4842    },
     4843
    44324844    /**
    44334845        Shows an image by index
     
    44414853    show : function( index, rewind, _history ) {
    44424854
     4855        var swipe = this._options.swipe;
     4856
    44434857        // do nothing queue is long || index is false || queue is false and transition is in progress
    4444         if ( this._queue.length > 3 || index === false || ( !this._options.queue && this._queue.stalled ) ) {
     4858        if ( !swipe &&
     4859            ( this._queue.length > 3 || index === false || ( !this._options.queue && this._queue.stalled ) ) ) {
    44454860            return;
    44464861        }
    44474862
    4448         index = Math.max( 0, Math.min( parseInt( index, 10 ), this.getDataLength() - 1 ) );
     4863        index = M.max( 0, M.min( parseInt( index, 10 ), this.getDataLength() - 1 ) );
    44494864
    44504865        rewind = typeof rewind !== 'undefined' ? !!rewind : index < this.getIndex();
     
    44584873        }
    44594874
     4875        if ( this.finger && index !== this._active ) {
     4876            this.finger.to = -( index*this.finger.width );
     4877            this.finger.index = index;
     4878        }
    44604879        this._active = index;
    44614880
    4462         protoArray.push.call( this._queue, {
    4463             index : index,
    4464             rewind : rewind
    4465         });
    4466         if ( !this._queue.stalled ) {
    4467             this._show();
     4881        // we do things a bit simpler in swipe:
     4882        if ( swipe ) {
     4883
     4884            var data = this.getData(index),
     4885                self = this;
     4886            if ( !data ) {
     4887                return;
     4888            }
     4889
     4890            var src = this.isFullscreen() && data.big ? data.big : ( data.image || data.iframe ),
     4891                image = this._controls.slides[index],
     4892                cached = image.isCached( src ),
     4893                thumb = this._thumbnails[ index ];
     4894
     4895            var evObj = {
     4896                cached: cached,
     4897                index: index,
     4898                rewind: rewind,
     4899                imageTarget: image.image,
     4900                thumbTarget: thumb.image,
     4901                galleriaData: data
     4902            };
     4903
     4904            this.trigger($.extend(evObj, {
     4905                type: Galleria.LOADSTART
     4906            }));
     4907
     4908            self.$('container').removeClass( 'videoplay' );
     4909
     4910            var complete = function() {
     4911
     4912                self._layers[index].innerHTML = self.getData().layer || '';
     4913
     4914                self.trigger($.extend(evObj, {
     4915                    type: Galleria.LOADFINISH
     4916                }));
     4917                self._playCheck();
     4918            };
     4919
     4920            self._preload();
     4921
     4922            window.setTimeout(function() {
     4923
     4924                // load if not ready
     4925                if ( !image.ready || $(image.image).attr('src') != src ) {
     4926                    if ( data.iframe && !data.image ) {
     4927                        image.isIframe = true;
     4928                    }
     4929                    image.load(src, function(image) {
     4930                        evObj.imageTarget = image.image;
     4931                        self._scaleImage(image, complete).trigger($.extend(evObj, {
     4932                            type: Galleria.IMAGE
     4933                        }));
     4934                        complete();
     4935                    });
     4936                } else {
     4937                    self.trigger($.extend(evObj, {
     4938                        type: Galleria.IMAGE
     4939                    }));
     4940                    complete();
     4941                }
     4942            }, 100);
     4943
     4944        } else {
     4945            protoArray.push.call( this._queue, {
     4946                index : index,
     4947                rewind : rewind
     4948            });
     4949            if ( !this._queue.stalled ) {
     4950                this._show();
     4951            }
    44684952        }
    44694953
     
    44834967        }
    44844968
    4485         var src = data.iframe || ( this.isFullscreen() && 'big' in data ? data.big : data.image ), // use big image if fullscreen mode
     4969        var src = this.isFullscreen() && data.big ? data.big : ( data.image || data.iframe ),
    44864970            active = this._controls.getActive(),
    44874971            next = this._controls.getNext(),
     
    44924976            };
    44934977
     4978        self.$('container').toggleClass('iframe', !!data.isIframe).removeClass( 'videoplay' );
     4979
    44944980        // to be fired when loading & transition is complete:
    44954981        var complete = (function( data, next, active, queue, thumb ) {
     
    45134999                }).show();
    45145000
    4515                 if( active.isIframe ) {
    4516                     $( active.container ).find( 'iframe' ).remove();
    4517                 }
    4518 
    4519                 self.$('container').toggleClass('iframe', !!data.iframe);
     5001                $( active.container ).find( 'iframe, .galleria-videoicon' ).remove();
     5002                $( self._controls.frames[ self._controls.active ].container ).hide();
    45205003
    45215004                $( next.container ).css({
     
    45325015                }
    45335016
    4534                 // make the image link or add lightbox
    4535                 // link takes precedence over lightbox if both are detected
    4536                 if ( data.link || self._options.lightbox || self._options.clicknext ) {
     5017                // make the image clickable
     5018                // order of precedence: iframe, link, lightbox, clicknext
     5019                if ( ( data.iframe && data.image ) || data.link || self._options.lightbox || self._options.clicknext ) {
    45375020
    45385021                    $( next.image ).css({
    45395022                        cursor: 'pointer'
    4540                     }).bind( 'mouseup', function( e ) {
     5023                    }).on( 'mouseup', function( e ) {
    45415024
    45425025                        // non-left click
    45435026                        if ( typeof e.which == 'number' && e.which > 1 ) {
     5027                            return;
     5028                        }
     5029
     5030                        // iframe / video
     5031                        if ( data.iframe ) {
     5032
     5033                            if ( self.isPlaying() ) {
     5034                                self.pause();
     5035                            }
     5036                            var frame = self._controls.frames[ self._controls.active ],
     5037                                w = self._stageWidth,
     5038                                h = self._stageHeight;
     5039
     5040                            $( frame.container ).css({
     5041                                width: w,
     5042                                height: h,
     5043                                opacity: 0
     5044                            }).show().animate({
     5045                                opacity: 1
     5046                            }, 200);
     5047
     5048                            window.setTimeout(function() {
     5049                                frame.load( data.iframe + ( data.video ? '&autoplay=1' : '' ), {
     5050                                    width: w,
     5051                                    height: h
     5052                                }, function( frame ) {
     5053                                    self.$( 'container' ).addClass( 'videoplay' );
     5054                                    frame.scale({
     5055                                        width: self._stageWidth,
     5056                                        height: self._stageHeight,
     5057                                        iframelimit: data.video ? self._options.maxVideoSize : undef
     5058                                    });
     5059                                });
     5060                            }, 100);
     5061
    45445062                            return;
    45455063                        }
     
    46035121
    46045122        // preload images
    4605         if ( this._options.preload ) {
    4606 
    4607             var p, i,
    4608                 n = this.getNext(),
    4609                 ndata;
    4610 
    4611             try {
    4612                 for ( i = this._options.preload; i > 0; i-- ) {
    4613                     p = new Galleria.Picture();
    4614                     ndata = self.getData( n );
    4615                     p.preload( this.isFullscreen() && 'big' in ndata ? ndata.big : ndata.image );
    4616                     n = self.getNext( n );
    4617                 }
    4618             } catch(e) {}
    4619         }
     5123        self._preload();
    46205124
    46215125        // show the next image, just in case
    46225126        Utils.show( next.container );
    46235127
    4624         next.isIframe = !!data.iframe;
     5128        next.isIframe = data.iframe && !data.image;
    46255129
    46265130        // add active classes
     
    46725176                        layer.show();
    46735177                        // inherit click events set on image
    4674                         if ( data.link || self._options.lightbox || self._options.clicknext ) {
    4675                             layer.css( 'cursor', 'pointer' ).unbind( 'mouseup' ).mouseup( mousetrigger );
     5178                        if ( ( data.iframe && data.image ) || data.link || self._options.lightbox || self._options.clicknext ) {
     5179                            layer.css( 'cursor', 'pointer' ).off( 'mouseup' ).mouseup( mousetrigger );
    46765180                        }
     5181                    }
     5182
     5183                    // add play icon
     5184                    if( data.video && data.image ) {
     5185                        _playIcon( next.container );
    46775186                    }
    46785187
     
    47195228                        galleriaData: self.getData( queue.index )
    47205229                    });
    4721 
    4722 
    47235230                }
    47245231            });
     
    49705477                    self.trigger({
    49715478                        type:         Galleria.PROGRESS,
    4972                         percent:      Math.ceil( played / self._playtime * 100 ),
    4973                         seconds:      Math.floor( played / 1000 ),
     5479                        percent:      M.ceil( played / self._playtime * 100 ),
     5480                        seconds:      M.floor( played / 1000 ),
    49745481                        milliseconds: played
    49755482                    });
     
    51555662    IPAD:    /ipad/.test( NAV ),
    51565663    ANDROID: /android/.test( NAV ),
    5157     TOUCH:   ('ontouchstart' in doc)
     5664    TOUCH:   ( 'ontouchstart' in doc ) && MOBILE // rule out false positives on Win10
    51585665
    51595666});
     
    51835690    }
    51845691
     5692    // make sure it's compatible
     5693    if ( !theme.version || parseInt(Galleria.version*10) > parseInt(theme.version*10) ) {
     5694        Galleria.raise('This version of Galleria requires '+theme.name+' theme version '+parseInt(Galleria.version*10)/10+' or later', true);
     5695    }
     5696
    51855697    if ( typeof theme.defaults !== 'object' ) {
    51865698        theme.defaults = {};
     
    51905702
    51915703    var css = false,
    5192         reg;
     5704        reg, reg2;
    51935705
    51945706    if ( typeof theme.css === 'string' ) {
     
    52125724        if ( !css ) {
    52135725
    5214             $('script').each(function( i, script ) {
    5215 
    5216                 // look for the theme script
    5217                 reg = new RegExp( 'galleria\\.' + theme.name.toLowerCase() + '\\.' );
    5218                 if( reg.test( script.src )) {
    5219 
    5220                     // we have a match
    5221                     css = script.src.replace(/[^\/]*$/, '') + theme.css;
    5222 
    5223                     window.setTimeout(function() {
    5224                         Utils.loadCSS( css, 'galleria-theme', function() {
    5225 
    5226                             // the themeload trigger
    5227                             _themeLoad( theme );
    5228 
    5229                         });
    5230                     }, 1);
    5231 
    5232                 }
     5726
     5727            $(function() {
     5728                // Try to determine the css-path from the theme script.
     5729                // In IE8/9, the script-dom-element seems to be not present
     5730                // at once, if galleria itself is inserted into the dom
     5731                // dynamically. We therefore try multiple times before raising
     5732                // an error.
     5733                var retryCount = 0;
     5734                var tryLoadCss = function() {
     5735                    $('script').each(function (i, script) {
     5736                        // look for the theme script
     5737                        reg = new RegExp('galleria\\.' + theme.name.toLowerCase() + '\\.');
     5738                        reg2 = new RegExp('galleria\\.io\\/theme\\/' + theme.name.toLowerCase() + '\\/(\\d*\\.*)?(\\d*\\.*)?(\\d*\\/)?js');
     5739                        if (reg.test(script.src) || reg2.test(script.src)) {
     5740                            // we have a match
     5741                            css = script.src.replace(/[^\/]*$/, '') + theme.css;
     5742
     5743                            window.setTimeout(function () {
     5744                                Utils.loadCSS(css, 'galleria-theme-'+theme.name, function () {
     5745
     5746                                    // run galleries with this theme
     5747                                    _themeLoad(theme);
     5748
     5749                                });
     5750                            }, 1);
     5751                        }
     5752                    });
     5753                    if (!css) {
     5754                        if (retryCount++ > 5) {
     5755                            Galleria.raise('No theme CSS loaded');
     5756                        } else {
     5757                            window.setTimeout(tryLoadCss, 500);
     5758                        }
     5759                    }
     5760                };
     5761                tryLoadCss();
    52335762            });
    52345763        }
    52355764
    5236         if ( !css ) {
    5237             Galleria.raise('No theme CSS loaded');
    5238         }
    52395765    } else {
    52405766
     
    52665792
    52675793    // start listening for the timeout onload
    5268     $( window ).load( function() {
     5794    $( window ).on('load', function() {
    52695795        if ( !loaded ) {
    52705796            // give it another 20 seconds
    52715797            err = window.setTimeout(function() {
    5272                 if ( !loaded && !Galleria.theme ) {
     5798                if ( !loaded ) {
    52735799                    Galleria.raise( "Galleria had problems loading theme at " + src + ". Please check theme path or load manually.", true );
    52745800                }
     
    52765802        }
    52775803    });
    5278 
    5279     // first clear the current theme, if exists
    5280     Galleria.unloadTheme();
    52815804
    52825805    // load the theme
     
    52855808        window.clearTimeout( err );
    52865809    });
    5287 
    5288     return Galleria;
    5289 };
    5290 
    5291 /**
    5292     unloadTheme unloads the Galleria theme and prepares for a new theme
    5293 
    5294     @returns Galleria
    5295 */
    5296 
    5297 Galleria.unloadTheme = function() {
    5298 
    5299     if ( typeof Galleria.theme == 'object' ) {
    5300 
    5301         $('script').each(function( i, script ) {
    5302 
    5303             if( new RegExp( 'galleria\\.' + Galleria.theme.name + '\\.' ).test( script.src ) ) {
    5304                 $( script ).remove();
    5305             }
    5306         });
    5307 
    5308         Galleria.theme = undef;
    5309     }
    53105810
    53115811    return Galleria;
     
    55076007    var type = fatal ? 'Fatal error' : 'Error',
    55086008
    5509         self = this,
    5510 
    55116009        css = {
    55126010            color: '#fff',
     
    55656063Galleria.version = VERSION;
    55666064
     6065Galleria.getLoadedThemes = function() {
     6066    return $.map(_loadedThemes, function(theme) {
     6067        return theme.name;
     6068    });
     6069};
     6070
    55676071/**
    55686072    A method for checking what version of Galleria the user has installed and throws a readable error if the user needs to upgrade.
     
    56656169
    56666170    preload: function( src ) {
    5667         $( new Image() ).load((function(src, cache) {
     6171        $( new Image() ).on( 'load', (function(src, cache) {
    56686172            return function() {
    56696173                cache[ src ] = src;
     
    56936197            var id = 'if'+new Date().getTime();
    56946198
    5695             this.image = $('<iframe>', {
     6199            var iframe = this.image = $('<iframe>', {
    56966200                src: src,
    56976201                frameborder: 0,
     
    57016205            })[0];
    57026206
     6207            if ( size ) {
     6208                $( iframe ).css( size );
     6209            }
     6210
    57036211            $( this.container ).find( 'iframe,img' ).remove();
    57046212
    57056213            this.container.appendChild( this.image );
    57066214
    5707             $('#'+id).load( (function( self, callback ) {
     6215            $('#'+id).on( 'load', (function( self, callback ) {
    57086216                return function() {
    57096217                    window.setTimeout(function() {
     
    57266234        }
    57276235
    5728         var i = 0,
    5729             reload = false,
     6236        // FF shaking images bug:
     6237        // http://support.galleria.io/discussions/problems/12245-shaking-photos
     6238        if ( !Galleria.IE && !Galleria.CHROME && !Galleria.SAFARI ) {
     6239            $( this.image ).css( 'image-rendering', 'optimizequality' );
     6240        }
     6241
     6242        var reload = false,
    57306243            resort = false,
    57316244
     
    57406253                    window.setTimeout((function(image, src) {
    57416254                        return function() {
    5742                             image.attr('src', src + '?' + Utils.timestamp() );
     6255                            image.attr('src', src + (src.indexOf('?') > -1 ? '&' : '?') + Utils.timestamp() );
    57436256                        };
    57446257                    }( $(this), src )), 50);
     
    57606273                    var complete = function() {
    57616274
    5762                         $( this ).unbind( 'load' );
     6275                        $( this ).off( 'load' );
    57636276
    57646277                        // save the original size
     
    57686281                        };
    57696282
    5770                         self.container.appendChild( this );
     6283                        // translate3d if needed
     6284                        if ( Galleria.HAS3D ) {
     6285                            this.style.MozTransform = this.style.webkitTransform = 'translate3d(0,0,0)';
     6286                        }
     6287
     6288                        $container.append( this );
    57716289
    57726290                        self.cache[ src ] = src; // will override old cache
     
    57826300                    // http://code.google.com/p/adblockforchrome/issues/detail?id=3701
    57836301                    if ( ( !this.width || !this.height ) ) {
    5784                         window.setTimeout( (function( img ) {
    5785                             return function() {
    5786                                 if ( img.width && img.height ) {
     6302                        (function( img ) {
     6303                            Utils.wait({
     6304                                until: function() {
     6305                                    return img.width && img.height;
     6306                                },
     6307                                success: function() {
    57876308                                    complete.call( img );
    5788                                 } else {
    5789                                     // last resort, this should never happen but just in case it does...
     6309                                },
     6310                                error: function() {
    57906311                                    if ( !resort ) {
    5791                                         $(new Image()).load( onload ).attr( 'src', img.src );
     6312                                        $(new Image()).on( 'load', onload ).attr( 'src', img.src );
    57926313                                        resort = true;
    57936314                                    } else {
     
    57956316                                            '. Traced measures: width:' + img.width + 'px, height: ' + img.height + 'px.');
    57966317                                    }
    5797                                 }
    5798                             };
    5799                         }( this )), 2);
     6318                                },
     6319                                timeout: 100
     6320                            });
     6321                        }( this ));
    58006322                    } else {
    58016323                        complete.call( this );
     
    58196341
    58206342        // begin load and insert in cache when done
    5821         $image.load( onload ).error( onerror ).attr( 'src', src );
     6343        $image.on( 'load', onload ).on( 'error', onerror ).attr( 'src', src );
    58226344
    58236345        // return the container
     
    58656387        if( this.isIframe ) {
    58666388
    5867             var cw = options.width, 
     6389            var cw = options.width,
    58686390                ch = options.height,
    58696391                nw, nh;
    58706392            if ( options.iframelimit ) {
    5871                 var r = Math.min( options.iframelimit/cw, options.iframelimit/ch );
     6393                var r = M.min( options.iframelimit/cw, options.iframelimit/ch );
    58726394                if ( r < 1 ) {
    58736395                    nw = cw * r;
     
    59276449                var newWidth = ( width - options.margin * 2 ) / self.original.width,
    59286450                    newHeight = ( height - options.margin * 2 ) / self.original.height,
    5929                     min = Math.min( newWidth, newHeight ),
    5930                     max = Math.max( newWidth, newHeight ),
     6451                    min = M.min( newWidth, newHeight ),
     6452                    max = M.max( newWidth, newHeight ),
    59316453                    cropMap = {
    59326454                        'true'  : max,
     
    59426464                // allow maxScaleRatio
    59436465                if ( options.max ) {
    5944                     ratio = Math.min( options.max, ratio );
     6466                    ratio = M.min( options.max, ratio );
    59456467                }
    59466468
    59476469                // allow minScaleRatio
    59486470                if ( options.min ) {
    5949                     ratio = Math.max( options.min, ratio );
     6471                    ratio = M.max( options.min, ratio );
    59506472                }
    59516473
    59526474                $.each( ['width','height'], function( i, m ) {
    5953                     $( self.image )[ m ]( self[ m ] = self.image[ m ] = Math.round( self.original[ m ] * ratio ) );
     6475                    $( self.image )[ m ]( self[ m ] = self.image[ m ] = M.round( self.original[ m ] * ratio ) );
    59546476                });
    59556477
     
    59916513                                m = self.image[ measure ] || $( self.image )[ measure ]();
    59926514
    5993                             result = Math.ceil( m * -1 * flt + margin * flt );
     6515                            result = M.ceil( m * -1 * flt + margin * flt );
    59946516                        } else {
    59956517                            result = Utils.parseValue( value );
     
    60676589
    60686590});
     6591
     6592
     6593// Forked version of Ainos Finger.js for native-style touch
     6594
     6595Galleria.Finger = (function() {
     6596
     6597    var abs = M.abs;
     6598
     6599    // test for translate3d support
     6600    var has3d = Galleria.HAS3D = (function() {
     6601
     6602        var el = doc.createElement('p'),
     6603            has3d,
     6604            t = ['webkit','O','ms','Moz',''],
     6605            s,
     6606            i=0,
     6607            a = 'transform';
     6608
     6609        DOM().html.insertBefore(el, null);
     6610
     6611        for (; t[i]; i++) {
     6612            s = t[i] ? t[i]+'Transform' : a;
     6613            if (el.style[s] !== undefined) {
     6614                el.style[s] = "translate3d(1px,1px,1px)";
     6615                has3d = $(el).css(t[i] ? '-'+t[i].toLowerCase()+'-'+a : a);
     6616            }
     6617        }
     6618
     6619        DOM().html.removeChild(el);
     6620        return (has3d !== undefined && has3d.length > 0 && has3d !== "none");
     6621    }());
     6622
     6623    // request animation shim
     6624    var requestFrame = (function(){
     6625        var r = 'RequestAnimationFrame';
     6626        return window.requestAnimationFrame ||
     6627               window['webkit'+r] ||
     6628               window['moz'+r] ||
     6629               window['o'+r] ||
     6630               window['ms'+r] ||
     6631               function( callback ) {
     6632                   window.setTimeout(callback, 1000 / 60);
     6633               };
     6634    }());
     6635
     6636    var Finger = function(elem, options) {
     6637
     6638        // default options
     6639        this.config = {
     6640            start: 0,
     6641            duration: 500,
     6642            onchange: function() {},
     6643            oncomplete: function() {},
     6644            easing: function(x,t,b,c,d) {
     6645                return -c * ((t=t/d-1)*t*t*t - 1) + b; // easeOutQuart
     6646            }
     6647        };
     6648
     6649        this.easeout = function (x, t, b, c, d) {
     6650            return c*((t=t/d-1)*t*t*t*t + 1) + b;
     6651        };
     6652
     6653        if ( !elem.children.length ) {
     6654            return;
     6655        }
     6656
     6657        var self = this;
     6658
     6659        // extend options
     6660        $.extend(this.config, options);
     6661
     6662        this.elem = elem;
     6663        this.child = elem.children[0];
     6664        this.to = this.pos = 0;
     6665        this.touching = false;
     6666        this.start = {};
     6667        this.index = this.config.start;
     6668        this.anim = 0;
     6669        this.easing = this.config.easing;
     6670
     6671        if ( !has3d ) {
     6672          this.child.style.position = 'absolute';
     6673          this.elem.style.position = 'relative';
     6674        }
     6675
     6676        // Bind event handlers to context
     6677        $.each(['ontouchstart','ontouchmove','ontouchend','setup'], function(i, fn) {
     6678            self[fn] = (function(caller) {
     6679                return function() {
     6680                    caller.apply( self, arguments );
     6681                };
     6682            }(self[fn]));
     6683        });
     6684
     6685        // the physical animator
     6686        this.setX = function() {
     6687
     6688            var style = self.child.style;
     6689
     6690            if (!has3d) {
     6691                // this is actually faster than CSS3 translate
     6692                style.left = self.pos+'px';
     6693                return;
     6694            }
     6695            style.MozTransform = style.webkitTransform = style.transform = 'translate3d(' + self.pos + 'px,0,0)';
     6696            return;
     6697        };
     6698
     6699        // bind events
     6700        $(elem).on('touchstart', this.ontouchstart);
     6701        $(window).on('resize', this.setup);
     6702        $(window).on('orientationchange', this.setup);
     6703
     6704        // set up width
     6705        this.setup();
     6706
     6707        // start the animations
     6708        (function animloop(){
     6709          requestFrame(animloop);
     6710          self.loop.call( self );
     6711        }());
     6712
     6713    };
     6714
     6715    Finger.prototype = {
     6716
     6717        constructor: Finger,
     6718
     6719        setup: function() {
     6720            this.width = $( this.elem ).width();
     6721            this.length = M.ceil( $(this.child).width() / this.width );
     6722            if ( this.index !== 0 ) {
     6723                this.index = M.max(0, M.min( this.index, this.length-1 ) );
     6724                this.pos = this.to = -this.width*this.index;
     6725            }
     6726        },
     6727
     6728        setPosition: function(pos) {
     6729            this.pos = pos;
     6730            this.to = pos;
     6731        },
     6732
     6733        ontouchstart: function(e) {
     6734
     6735            var touch = e.originalEvent.touches;
     6736
     6737            this.start = {
     6738                pageX: touch[0].pageX,
     6739                pageY: touch[0].pageY,
     6740                time:  +new Date()
     6741            };
     6742
     6743            this.isScrolling = null;
     6744            this.touching = true;
     6745            this.deltaX = 0;
     6746
     6747            $doc.on('touchmove', this.ontouchmove);
     6748            $doc.on('touchend', this.ontouchend);
     6749        },
     6750
     6751        ontouchmove: function(e) {
     6752
     6753            var touch = e.originalEvent.touches;
     6754
     6755            // ensure swiping with one touch and not pinching
     6756            if( touch && touch.length > 1 || e.scale && e.scale !== 1 ) {
     6757                return;
     6758            }
     6759
     6760            this.deltaX = touch[0].pageX - this.start.pageX;
     6761
     6762            // determine if scrolling test has run - one time test
     6763            if ( this.isScrolling === null ) {
     6764                this.isScrolling = !!(
     6765                    this.isScrolling ||
     6766                    M.abs(this.deltaX) < M.abs(touch[0].pageY - this.start.pageY)
     6767                );
     6768            }
     6769
     6770            // if user is not trying to scroll vertically
     6771            if (!this.isScrolling) {
     6772
     6773                // prevent native scrolling
     6774                e.preventDefault();
     6775
     6776                // increase resistance if first or last slide
     6777                this.deltaX /= ( (!this.index && this.deltaX > 0 || this.index == this.length - 1 && this.deltaX < 0 ) ?
     6778                    ( M.abs(this.deltaX) / this.width + 1.8 )  : 1 );
     6779                this.to = this.deltaX - this.index * this.width;
     6780            }
     6781            e.stopPropagation();
     6782        },
     6783
     6784        ontouchend: function(e) {
     6785
     6786            this.touching = false;
     6787
     6788            // determine if slide attempt triggers next/prev slide
     6789            var isValidSlide = +new Date() - this.start.time < 250 &&
     6790                M.abs(this.deltaX) > 40 ||
     6791                M.abs(this.deltaX) > this.width/2,
     6792
     6793                isPastBounds = !this.index && this.deltaX > 0 ||
     6794                    this.index == this.length - 1 && this.deltaX < 0;
     6795
     6796            // if not scrolling vertically
     6797            if ( !this.isScrolling ) {
     6798                this.show( this.index + ( isValidSlide && !isPastBounds ? (this.deltaX < 0 ? 1 : -1) : 0 ) );
     6799            }
     6800
     6801            $doc.off('touchmove', this.ontouchmove);
     6802            $doc.off('touchend', this.ontouchend);
     6803        },
     6804
     6805        show: function( index ) {
     6806            if ( index != this.index ) {
     6807                this.config.onchange.call(this, index);
     6808            } else {
     6809                this.to = -( index*this.width );
     6810            }
     6811        },
     6812
     6813        moveTo: function( index ) {
     6814            if ( index != this.index ) {
     6815                this.pos = this.to = -( index*this.width );
     6816                this.index = index;
     6817            }
     6818        },
     6819
     6820        loop: function() {
     6821
     6822            var distance = this.to - this.pos,
     6823                factor = 1;
     6824
     6825            if ( this.width && distance ) {
     6826                factor = M.max(0.5, M.min(1.5, M.abs(distance / this.width) ) );
     6827            }
     6828
     6829            // if distance is short or the user is touching, do a 1-1 animation
     6830            if ( this.touching || M.abs(distance) <= 1 ) {
     6831                this.pos = this.to;
     6832                distance = 0;
     6833                if ( this.anim && !this.touching ) {
     6834                    this.config.oncomplete( this.index );
     6835                }
     6836                this.anim = 0;
     6837                this.easing = this.config.easing;
     6838            } else {
     6839                if ( !this.anim ) {
     6840                    // save animation parameters
     6841                    this.anim = { start: this.pos, time: +new Date(), distance: distance, factor: factor, destination: this.to };
     6842                }
     6843                // check if to has changed or time has run out
     6844                var elapsed = +new Date() - this.anim.time;
     6845                var duration = this.config.duration*this.anim.factor;
     6846
     6847                if ( elapsed > duration || this.anim.destination != this.to ) {
     6848                    this.anim = 0;
     6849                    this.easing = this.easeout;
     6850                    return;
     6851                }
     6852                // apply easing
     6853                this.pos = this.easing(
     6854                    null,
     6855                    elapsed,
     6856                    this.anim.start,
     6857                    this.anim.distance,
     6858                    duration
     6859                );
     6860            }
     6861            this.setX();
     6862        }
     6863    };
     6864
     6865    return Finger;
     6866
     6867}());
    60696868
    60706869// the plugin initializer
     
    61176916};
    61186917
     6918// export as AMD or CommonJS
     6919if ( 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
    61196928// phew
    61206929
    6121 }( jQuery ) );
     6930}( jQuery, this ) );
  • _plugins_/galleria/trunk/galleria/galleria.min.js

    r72410 r106707  
    1 (function($){var undef,window=this,doc=window.document,$doc=$(doc),$win=$(window),protoArray=Array.prototype,VERSION=1.29,DEBUG=true,TIMEOUT=3e4,DUMMY=false,NAV=navigator.userAgent.toLowerCase(),HASH=window.location.hash.replace(/#\//,""),F=function(){},FALSE=function(){return false},IE=function(){var v=3,div=doc.createElement("div"),all=div.getElementsByTagName("i");do{div.innerHTML="<!--[if gt IE "+ ++v+"]><i></i><![endif]-->"}while(all[0]);return v>4?v:undef}(),DOM=function(){return{html:doc.documentElement,body:doc.body,head:doc.getElementsByTagName("head")[0],title:doc.title}},IFRAME=window.parent!==window.self,_eventlist="data ready thumbnail loadstart loadfinish image play pause progress "+"fullscreen_enter fullscreen_exit idle_enter idle_exit rescale "+"lightbox_open lightbox_close lightbox_image",_events=function(){var evs=[];$.each(_eventlist.split(" "),function(i,ev){evs.push(ev);if(/_/.test(ev)){evs.push(ev.replace(/_/g,""))}});return evs}(),_legacyOptions=function(options){var n;if(typeof options!=="object"){return options}$.each(options,function(key,value){if(/^[a-z]+_/.test(key)){n="";$.each(key.split("_"),function(i,k){n+=i>0?k.substr(0,1).toUpperCase()+k.substr(1):k});options[n]=value;delete options[key]}});return options},_patchEvent=function(type){if($.inArray(type,_events)>-1){return Galleria[type.toUpperCase()]}return type},_video={youtube:{reg:/https?:\/\/(?:[a-zA_Z]{2,3}.)?(?:youtube\.com\/watch\?)((?:[\w\d\-\_\=]+&amp;(?:amp;)?)*v(?:&lt;[A-Z]+&gt;)?=([0-9a-zA-Z\-\_]+))/i,embed:function(id){return"http://www.youtube.com/embed/"+id},getThumb:function(id,success,fail){fail=fail||F;$.getJSON(window.location.protocol+"//gdata.youtube.com/feeds/api/videos/"+id+"?v=2&alt=json-in-script&callback=?",function(data){try{success(data.entry.media$group.media$thumbnail[0].url)}catch(e){fail()}}).error(fail)}},vimeo:{reg:/https?:\/\/(?:www\.)?(vimeo\.com)\/(?:hd#)?([0-9]+)/i,embed:function(id){return"http://player.vimeo.com/video/"+id},getThumb:function(id,success,fail){fail=fail||F;$.getJSON("http://vimeo.com/api/v2/video/"+id+".json?callback=?",function(data){try{success(data[0].thumbnail_medium)}catch(e){fail()}}).error(fail)}},dailymotion:{reg:/https?:\/\/(?:www\.)?(dailymotion\.com)\/video\/([^_]+)/,embed:function(id){return"http://www.dailymotion.com/embed/video/"+id},getThumb:function(id,success,fail){fail=fail||F;$.getJSON("https://api.dailymotion.com/video/"+id+"?fields=thumbnail_medium_url&callback=?",function(data){try{success(data.thumbnail_medium_url)}catch(e){fail()}}).error(fail)}}},_videoTest=function(url){var match;for(var v in _video){match=url&&url.match(_video[v].reg);if(match&&match.length){return{id:match[2],provider:v}}}return false},_nativeFullscreen={support:function(){var html=DOM().html;return!IFRAME&&(html.requestFullscreen||html.mozRequestFullScreen||html.webkitRequestFullScreen)}(),callback:F,enter:function(instance,callback,elem){this.instance=instance;this.callback=callback||F;elem=elem||DOM().html;if(elem.requestFullscreen){elem.requestFullscreen()}else if(elem.mozRequestFullScreen){elem.mozRequestFullScreen()}else if(elem.webkitRequestFullScreen){elem.webkitRequestFullScreen()}},exit:function(callback){this.callback=callback||F;if(doc.exitFullscreen){doc.exitFullscreen()}else if(doc.mozCancelFullScreen){doc.mozCancelFullScreen()}else if(doc.webkitCancelFullScreen){doc.webkitCancelFullScreen()}},instance:null,listen:function(){if(!this.support){return}var handler=function(){if(!_nativeFullscreen.instance){return}var fs=_nativeFullscreen.instance._fullscreen;if(doc.fullscreen||doc.mozFullScreen||doc.webkitIsFullScreen){fs._enter(_nativeFullscreen.callback)}else{fs._exit(_nativeFullscreen.callback)}};doc.addEventListener("fullscreenchange",handler,false);doc.addEventListener("mozfullscreenchange",handler,false);doc.addEventListener("webkitfullscreenchange",handler,false)}},_galleries=[],_instances=[],_hasError=false,_canvas=false,_pool=[],_themeLoad=function(theme){Galleria.theme=theme;$.each(_pool,function(i,instance){if(!instance._initialized){instance._init.call(instance)}});_pool=[]},Utils=function(){return{clearTimer:function(id){$.each(Galleria.get(),function(){this.clearTimer(id)})},addTimer:function(id){$.each(Galleria.get(),function(){this.addTimer(id)})},array:function(obj){return protoArray.slice.call(obj,0)},create:function(className,nodeName){nodeName=nodeName||"div";var elem=doc.createElement(nodeName);elem.className=className;return elem},removeFromArray:function(arr,elem){$.each(arr,function(i,el){if(el==elem){arr.splice(i,1);return false}});return arr},getScriptPath:function(src){src=src||$("script:last").attr("src");var slices=src.split("/");if(slices.length==1){return""}slices.pop();return slices.join("/")+"/"},animate:function(){var transition=function(style){var props="transition WebkitTransition MozTransition OTransition".split(" "),i;if(window.opera){return false}for(i=0;props[i];i++){if(typeof style[props[i]]!=="undefined"){return props[i]}}return false}((doc.body||doc.documentElement).style);var endEvent={MozTransition:"transitionend",OTransition:"oTransitionEnd",WebkitTransition:"webkitTransitionEnd",transition:"transitionend"}[transition];var easings={_default:[.25,.1,.25,1],galleria:[.645,.045,.355,1],galleriaIn:[.55,.085,.68,.53],galleriaOut:[.25,.46,.45,.94],ease:[.25,0,.25,1],linear:[.25,.25,.75,.75],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]};var setStyle=function(elem,value,suffix){var css={};suffix=suffix||"transition";$.each("webkit moz ms o".split(" "),function(){css["-"+this+"-"+suffix]=value});elem.css(css)};var clearStyle=function(elem){setStyle(elem,"none","transition");if(Galleria.WEBKIT&&Galleria.TOUCH){setStyle(elem,"translate3d(0,0,0)","transform");if(elem.data("revert")){elem.css(elem.data("revert"));elem.data("revert",null)}}};var change,strings,easing,syntax,revert,form,css;return function(elem,to,options){options=$.extend({duration:400,complete:F,stop:false},options);elem=$(elem);if(!options.duration){elem.css(to);options.complete.call(elem[0]);return}if(!transition){elem.animate(to,options);return}if(options.stop){elem.unbind(endEvent);clearStyle(elem)}change=false;$.each(to,function(key,val){css=elem.css(key);if(Utils.parseValue(css)!=Utils.parseValue(val)){change=true}elem.css(key,css)});if(!change){window.setTimeout(function(){options.complete.call(elem[0])},options.duration);return}strings=[];easing=options.easing in easings?easings[options.easing]:easings._default;syntax=" "+options.duration+"ms"+" cubic-bezier("+easing.join(",")+")";window.setTimeout(function(elem,endEvent,to,syntax){return function(){elem.one(endEvent,function(elem){return function(){clearStyle(elem);options.complete.call(elem[0])}}(elem));if(Galleria.WEBKIT&&Galleria.TOUCH){revert={};form=[0,0,0];$.each(["left","top"],function(i,m){if(m in to){form[i]=Utils.parseValue(to[m])-Utils.parseValue(elem.css(m))+"px";revert[m]=to[m];delete to[m]}});if(form[0]||form[1]){elem.data("revert",revert);strings.push("-webkit-transform"+syntax);setStyle(elem,"translate3d("+form.join(",")+")","transform")}}$.each(to,function(p,val){strings.push(p+syntax)});setStyle(elem,strings.join(","));elem.css(to)}}(elem,endEvent,to,syntax),2)}}(),removeAlpha:function(elem){if(IE<9&&elem){var style=elem.style,currentStyle=elem.currentStyle,filter=currentStyle&&currentStyle.filter||style.filter||"";if(/alpha/.test(filter)){style.filter=filter.replace(/alpha\([^)]*\)/i,"")}}},forceStyles:function(elem,styles){elem=$(elem);if(elem.attr("style")){elem.data("styles",elem.attr("style")).removeAttr("style")}elem.css(styles)},revertStyles:function(){$.each(Utils.array(arguments),function(i,elem){elem=$(elem);elem.removeAttr("style");elem.attr("style","");if(elem.data("styles")){elem.attr("style",elem.data("styles")).data("styles",null)}})},moveOut:function(elem){Utils.forceStyles(elem,{position:"absolute",left:-1e4})},moveIn:function(){Utils.revertStyles.apply(Utils,Utils.array(arguments))},elem:function(elem){if(elem instanceof $){return{$:elem,dom:elem[0]}}else{return{$:$(elem),dom:elem}}},hide:function(elem,speed,callback){callback=callback||F;var el=Utils.elem(elem),$elem=el.$;elem=el.dom;if(!$elem.data("opacity")){$elem.data("opacity",$elem.css("opacity"))}var style={opacity:0};if(speed){var complete=IE<9&&elem?function(){Utils.removeAlpha(elem);elem.style.visibility="hidden";callback.call(elem)}:callback;Utils.animate(elem,style,{duration:speed,complete:complete,stop:true})}else{if(IE<9&&elem){Utils.removeAlpha(elem);elem.style.visibility="hidden"}else{$elem.css(style)}}},show:function(elem,speed,callback){callback=callback||F;var el=Utils.elem(elem),$elem=el.$;elem=el.dom;var saved=parseFloat($elem.data("opacity"))||1,style={opacity:saved};if(speed){if(IE<9){$elem.css("opacity",0);elem.style.visibility="visible"}var complete=IE<9&&elem?function(){if(style.opacity==1){Utils.removeAlpha(elem)}callback.call(elem)}:callback;Utils.animate(elem,style,{duration:speed,complete:complete,stop:true})}else{if(IE<9&&style.opacity==1&&elem){Utils.removeAlpha(elem);elem.style.visibility="visible"}else{$elem.css(style)}}},optimizeTouch:function(){var node,evs,fakes,travel,evt={},handler=function(e){e.preventDefault();evt=$.extend({},e,true)},attach=function(){this.evt=evt},fake=function(){this.handler.call(node,this.evt)};return function(elem){$(elem).bind("touchend",function(e){node=e.target;travel=true;while(node.parentNode&&node!=e.currentTarget&&travel){evs=$(node).data("events");fakes=$(node).data("fakes");if(evs&&"click"in evs){travel=false;e.preventDefault();$(node).click(handler).click();evs.click.pop();$.each(evs.click,attach);$(node).data("fakes",evs.click);delete evs.click}else if(fakes){travel=false;e.preventDefault();$.each(fakes,fake)}node=node.parentNode}})}}(),wait:function(options){options=$.extend({until:FALSE,success:F,error:function(){Galleria.raise("Could not complete wait function.")},timeout:3e3},options);var start=Utils.timestamp(),elapsed,now,fn=function(){now=Utils.timestamp();elapsed=now-start;if(options.until(elapsed)){options.success();return false}if(typeof options.timeout=="number"&&now>=start+options.timeout){options.error();return false}window.setTimeout(fn,10)};window.setTimeout(fn,10)},toggleQuality:function(img,force){if(IE!==7&&IE!==8||!img||img.nodeName.toUpperCase()!="IMG"){return}if(typeof force==="undefined"){force=img.style.msInterpolationMode==="nearest-neighbor"}img.style.msInterpolationMode=force?"bicubic":"nearest-neighbor"},insertStyleTag:function(styles,id){if(id&&$("#"+id).length){return}var style=doc.createElement("style");if(id){style.id=id}DOM().head.appendChild(style);if(style.styleSheet){style.styleSheet.cssText=styles}else{var cssText=doc.createTextNode(styles);style.appendChild(cssText)}},loadScript:function(url,callback){var done=false,script=$("<scr"+"ipt>").attr({src:url,async:true}).get(0);script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){done=true;script.onload=script.onreadystatechange=null;if(typeof callback==="function"){callback.call(this,this)}}};DOM().head.appendChild(script)},parseValue:function(val){if(typeof val==="number"){return val}else if(typeof val==="string"){var arr=val.match(/\-?\d|\./g);return arr&&arr.constructor===Array?arr.join("")*1:0}else{return 0}},timestamp:function(){return(new Date).getTime()},loadCSS:function(href,id,callback){var link,length;$("link[rel=stylesheet]").each(function(){if(new RegExp(href).test(this.href)){link=this;return false}});if(typeof id==="function"){callback=id;id=undef}callback=callback||F;if(link){callback.call(link,link);return link}length=doc.styleSheets.length;if($("#"+id).length){$("#"+id).attr("href",href);length--}else{link=$("<link>").attr({rel:"stylesheet",href:href,id:id}).get(0);var styles=$('link[rel="stylesheet"], style');if(styles.length){styles.get(0).parentNode.insertBefore(link,styles[0])}else{DOM().head.appendChild(link)}if(IE){if(length>=31){Galleria.raise("You have reached the browser stylesheet limit (31)",true);return}}}if(typeof callback==="function"){var $loader=$("<s>").attr("id","galleria-loader").hide().appendTo(DOM().body);Utils.wait({until:function(){return $loader.height()==1},success:function(){$loader.remove();callback.call(link,link)},error:function(){$loader.remove();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)},timeout:5e3})}return link}}}(),_transitions=function(){var _slide=function(params,complete,fade,door){var easing=this.getOptions("easing"),distance=this.getStageWidth(),from={left:distance*(params.rewind?-1:1)},to={left:0};if(fade){from.opacity=0;to.opacity=1}else{from.opacity=1}$(params.next).css(from);Utils.animate(params.next,to,{duration:params.speed,complete:function(elems){return function(){complete();elems.css({left:0})}}($(params.next).add(params.prev)),queue:false,easing:easing});if(door){params.rewind=!params.rewind}if(params.prev){from={left:0};to={left:distance*(params.rewind?1:-1)};if(fade){from.opacity=1;to.opacity=0}$(params.prev).css(from);Utils.animate(params.prev,to,{duration:params.speed,queue:false,easing:easing,complete:function(){$(this).css("opacity",0)}})}};return{active:false,init:function(effect,params,complete){if(_transitions.effects.hasOwnProperty(effect)){_transitions.effects[effect].call(this,params,complete)}},effects:{fade:function(params,complete){$(params.next).css({opacity:0,left:0});Utils.animate(params.next,{opacity:1},{duration:params.speed,complete:complete});if(params.prev){$(params.prev).css("opacity",1).show();Utils.animate(params.prev,{opacity:0},{duration:params.speed})}},flash:function(params,complete){$(params.next).css({opacity:0,left:0});if(params.prev){Utils.animate(params.prev,{opacity:0},{duration:params.speed/2,complete:function(){Utils.animate(params.next,{opacity:1},{duration:params.speed,complete:complete})}})}else{Utils.animate(params.next,{opacity:1},{duration:params.speed,complete:complete})}},pulse:function(params,complete){if(params.prev){$(params.prev).hide()}$(params.next).css({opacity:0,left:0}).show();Utils.animate(params.next,{opacity:1},{duration:params.speed,complete:complete})},slide:function(params,complete){_slide.apply(this,Utils.array(arguments))},fadeslide:function(params,complete){_slide.apply(this,Utils.array(arguments).concat([true]))},doorslide:function(params,complete){_slide.apply(this,Utils.array(arguments).concat([false,true]))}}}}();_nativeFullscreen.listen();Galleria=function(){var self=this;this._options={};this._playing=false;this._playtime=5e3;this._active=null;this._queue={length:0};this._data=[];this._dom={};this._thumbnails=[];this._layers=[];this._initialized=false;this._firstrun=false;this._stageWidth=0;this._stageHeight=0;this._target=undef;this._binds=[];this._id=parseInt(Math.random()*1e4,10);var divs="container stage images image-nav image-nav-left image-nav-right "+"info info-text info-title info-description "+"thumbnails thumbnails-list thumbnails-container thumb-nav-left thumb-nav-right "+"loader counter tooltip",spans="current total";$.each(divs.split(" "),function(i,elemId){self._dom[elemId]=Utils.create("galleria-"+elemId)});$.each(spans.split(" "),function(i,elemId){self._dom[elemId]=Utils.create("galleria-"+elemId,"span")});var keyboard=this._keyboard={keys:{UP:38,DOWN:40,LEFT:37,RIGHT:39,RETURN:13,ESCAPE:27,BACKSPACE:8,SPACE:32},map:{},bound:false,press:function(e){var key=e.keyCode||e.which;if(key in keyboard.map&&typeof keyboard.map[key]==="function"){keyboard.map[key].call(self,e)}},attach:function(map){var key,up;for(key in map){if(map.hasOwnProperty(key)){up=key.toUpperCase();if(up in keyboard.keys){keyboard.map[keyboard.keys[up]]=map[key]}else{keyboard.map[up]=map[key]}}}if(!keyboard.bound){keyboard.bound=true;$doc.bind("keydown",keyboard.press)}},detach:function(){keyboard.bound=false;keyboard.map={};$doc.unbind("keydown",keyboard.press)}};var controls=this._controls={0:undef,1:undef,active:0,swap:function(){controls.active=controls.active?0:1},getActive:function(){return controls[controls.active]},getNext:function(){return controls[1-controls.active]}};var carousel=this._carousel={next:self.$("thumb-nav-right"),prev:self.$("thumb-nav-left"),width:0,current:0,max:0,hooks:[],update:function(){var w=0,h=0,hooks=[0];$.each(self._thumbnails,function(i,thumb){if(thumb.ready){w+=thumb.outerWidth||$(thumb.container).outerWidth(true);hooks[i+1]=w;h=Math.max(h,thumb.outerHeight||$(thumb.container).outerHeight(true))}});self.$("thumbnails").css({width:w,height:h});carousel.max=w;carousel.hooks=hooks;carousel.width=self.$("thumbnails-list").width();carousel.setClasses();self.$("thumbnails-container").toggleClass("galleria-carousel",w>carousel.width);carousel.width=self.$("thumbnails-list").width()},bindControls:function(){var i;carousel.next.bind("click",function(e){e.preventDefault();if(self._options.carouselSteps==="auto"){for(i=carousel.current;i<carousel.hooks.length;i++){if(carousel.hooks[i]-carousel.hooks[carousel.current]>carousel.width){carousel.set(i-2);break}}}else{carousel.set(carousel.current+self._options.carouselSteps)}});carousel.prev.bind("click",function(e){e.preventDefault();if(self._options.carouselSteps==="auto"){for(i=carousel.current;i>=0;i--){if(carousel.hooks[carousel.current]-carousel.hooks[i]>carousel.width){carousel.set(i+2);break}else if(i===0){carousel.set(0);break}}}else{carousel.set(carousel.current-self._options.carouselSteps)}})},set:function(i){i=Math.max(i,0);while(carousel.hooks[i-1]+carousel.width>=carousel.max&&i>=0){i--}carousel.current=i;carousel.animate()},getLast:function(i){return(i||carousel.current)-1},follow:function(i){if(i===0||i===carousel.hooks.length-2){carousel.set(i);return}var last=carousel.current;while(carousel.hooks[last]-carousel.hooks[carousel.current]<carousel.width&&last<=carousel.hooks.length){last++}if(i-1<carousel.current){carousel.set(i-1)}else if(i+2>last){carousel.set(i-last+carousel.current+2)}},setClasses:function(){carousel.prev.toggleClass("disabled",!carousel.current);carousel.next.toggleClass("disabled",carousel.hooks[carousel.current]+carousel.width>=carousel.max)},animate:function(to){carousel.setClasses();var num=carousel.hooks[carousel.current]*-1;if(isNaN(num)){return}Utils.animate(self.get("thumbnails"),{left:num},{duration:self._options.carouselSpeed,easing:self._options.easing,queue:false})}};var tooltip=this._tooltip={initialized:false,open:false,timer:"tooltip"+self._id,swapTimer:"swap"+self._id,init:function(){tooltip.initialized=true;var css=".galleria-tooltip{padding:3px 8px;max-width:50%;background:#ffe;color:#000;z-index:3;position:absolute;font-size:11px;line-height:1.3;"+"opacity:0;box-shadow:0 0 2px rgba(0,0,0,.4);-moz-box-shadow:0 0 2px rgba(0,0,0,.4);-webkit-box-shadow:0 0 2px rgba(0,0,0,.4);}";Utils.insertStyleTag(css,"galleria-tooltip");self.$("tooltip").css({opacity:.8,visibility:"visible",display:"none"})},move:function(e){var mouseX=self.getMousePosition(e).x,mouseY=self.getMousePosition(e).y,$elem=self.$("tooltip"),x=mouseX,y=mouseY,height=$elem.outerHeight(true)+1,width=$elem.outerWidth(true),limitY=height+15;var maxX=self.$("container").width()-width-2,maxY=self.$("container").height()-height-2;if(!isNaN(x)&&!isNaN(y)){x+=10;y-=height+8;x=Math.max(0,Math.min(maxX,x));y=Math.max(0,Math.min(maxY,y));if(mouseY<limitY){y=limitY}$elem.css({left:x,top:y})}},bind:function(elem,value){if(Galleria.TOUCH){return}if(!tooltip.initialized){tooltip.init()}var mouseout=function(){self.$("container").unbind("mousemove",tooltip.move);self.clearTimer(tooltip.timer);self.$("tooltip").stop().animate({opacity:0},200,function(){self.$("tooltip").hide();self.addTimer(tooltip.swapTimer,function(){tooltip.open=false},1e3)})};var hover=function(elem,value){tooltip.define(elem,value);$(elem).hover(function(){self.clearTimer(tooltip.swapTimer);self.$("container").unbind("mousemove",tooltip.move).bind("mousemove",tooltip.move).trigger("mousemove");tooltip.show(elem);self.addTimer(tooltip.timer,function(){self.$("tooltip").stop().show().animate({opacity:1});tooltip.open=true},tooltip.open?0:500)},mouseout).click(mouseout)};if(typeof value==="string"){hover(elem in self._dom?self.get(elem):elem,value)}else{$.each(elem,function(elemID,val){hover(self.get(elemID),val)})}},show:function(elem){elem=$(elem in self._dom?self.get(elem):elem);var text=elem.data("tt"),mouseup=function(e){window.setTimeout(function(ev){return function(){tooltip.move(ev)}}(e),10);elem.unbind("mouseup",mouseup)};text=typeof text==="function"?text():text;if(!text){return}self.$("tooltip").html(text.replace(/\s/,"&#160;"));elem.bind("mouseup",mouseup)},define:function(elem,value){if(typeof value!=="function"){var s=value;value=function(){return s}}elem=$(elem in self._dom?self.get(elem):elem).data("tt",value);tooltip.show(elem)}};var fullscreen=this._fullscreen={scrolled:0,crop:undef,active:false,keymap:self._keyboard.map,parseCallback:function(callback,enter){return _transitions.active?function(){if(typeof callback=="function"){callback.call(self)}var active=self._controls.getActive(),next=self._controls.getNext();self._scaleImage(next);self._scaleImage(active);if(enter&&self._options.trueFullscreen){$(active.container).add(next.container).trigger("transitionend")}}:callback},enter:function(callback){callback=fullscreen.parseCallback(callback,true);if(self._options.trueFullscreen&&_nativeFullscreen.support){fullscreen.active=true;Utils.forceStyles(self.get("container"),{width:"100%",height:"100%"});self.rescale();if(Galleria.MAC){if(Galleria.WEBKIT&&!(Galleria.SAFARI&&/version\/[1-5]/.test(NAV))){self.$("container").css("opacity",0).addClass("fullscreen");window.setTimeout(function(){fullscreen.scale();self.$("container").css("opacity",1)},50)}else{self.$("stage").css("opacity",0);window.setTimeout(function(){fullscreen.scale();self.$("stage").css("opacity",1)},4)}}else{self.$("container").addClass("fullscreen")}$win.resize(fullscreen.scale);_nativeFullscreen.enter(self,callback,self.get("container"))}else{fullscreen.scrolled=$win.scrollTop();window.scrollTo(0,0);fullscreen._enter(callback)}},_enter:function(callback){fullscreen.active=true;if(IFRAME){fullscreen.iframe=function(){var elem,refer=doc.referrer,test=doc.createElement("a"),loc=window.location;test.href=refer;if(test.protocol!=loc.protocol||test.hostname!=loc.hostname||test.port!=loc.port){Galleria.raise("Parent fullscreen not available. Iframe protocol, domains and ports must match.");return false}fullscreen.pd=window.parent.document;$(fullscreen.pd).find("iframe").each(function(){var idoc=this.contentDocument||this.contentWindow.document;if(idoc===doc){elem=this;return false}});return elem}()}Utils.hide(self.getActiveImage());if(IFRAME&&fullscreen.iframe){fullscreen.iframe.scrolled=$(window.parent).scrollTop();window.parent.scrollTo(0,0)}var data=self.getData(),options=self._options,inBrowser=!self._options.trueFullscreen||!_nativeFullscreen.support,htmlbody={height:"100%",overflow:"hidden",margin:0,padding:0};if(inBrowser){self.$("container").addClass("fullscreen");Utils.forceStyles(self.get("container"),{position:"fixed",top:0,left:0,width:"100%",height:"100%",zIndex:1e4});Utils.forceStyles(DOM().html,htmlbody);Utils.forceStyles(DOM().body,htmlbody)}if(IFRAME&&fullscreen.iframe){Utils.forceStyles(fullscreen.pd.documentElement,htmlbody);Utils.forceStyles(fullscreen.pd.body,htmlbody);Utils.forceStyles(fullscreen.iframe,$.extend(htmlbody,{width:"100%",height:"100%",top:0,left:0,position:"fixed",zIndex:1e4,border:"none"}))}fullscreen.keymap=$.extend({},self._keyboard.map);self.attachKeyboard({escape:self.exitFullscreen,right:self.next,left:self.prev});fullscreen.crop=options.imageCrop;if(options.fullscreenCrop!=undef){options.imageCrop=options.fullscreenCrop}if(data&&data.big&&data.image!==data.big){var big=new Galleria.Picture,cached=big.isCached(data.big),index=self.getIndex(),thumb=self._thumbnails[index];self.trigger({type:Galleria.LOADSTART,cached:cached,rewind:false,index:index,imageTarget:self.getActiveImage(),thumbTarget:thumb,galleriaData:data});big.load(data.big,function(big){self._scaleImage(big,{complete:function(big){self.trigger({type:Galleria.LOADFINISH,cached:cached,index:index,rewind:false,imageTarget:big.image,thumbTarget:thumb});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)}}})})}self.rescale(function(){self.addTimer(false,function(){if(inBrowser){Utils.show(self.getActiveImage())}if(typeof callback==="function"){callback.call(self)}},100);self.trigger(Galleria.FULLSCREEN_ENTER)});if(!inBrowser){Utils.show(self.getActiveImage())}else{$win.resize(fullscreen.scale)}},scale:function(){self.rescale()},exit:function(callback){callback=fullscreen.parseCallback(callback);if(self._options.trueFullscreen&&_nativeFullscreen.support){_nativeFullscreen.exit(callback)}else{fullscreen._exit(callback)}},_exit:function(callback){fullscreen.active=false;var inBrowser=!self._options.trueFullscreen||!_nativeFullscreen.support;self.$("container").removeClass("fullscreen");if(inBrowser){Utils.hide(self.getActiveImage());Utils.revertStyles(self.get("container"),DOM().html,DOM().body);window.scrollTo(0,fullscreen.scrolled)}if(IFRAME&&fullscreen.iframe){Utils.revertStyles(fullscreen.pd.documentElement,fullscreen.pd.body,fullscreen.iframe);if(fullscreen.iframe.scrolled){window.parent.scrollTo(0,fullscreen.iframe.scrolled)}}self.detachKeyboard();self.attachKeyboard(fullscreen.keymap);self._options.imageCrop=fullscreen.crop;var big=self.getData().big,image=self._controls.getActive().image;if(!self.getData().iframe&&image&&big&&big==image.src){window.setTimeout(function(src){return function(){image.src=src}}(self.getData().image),1)}self.rescale(function(){self.addTimer(false,function(){if(inBrowser){Utils.show(self.getActiveImage())}if(typeof callback==="function"){callback.call(self)}$win.trigger("resize")},50);self.trigger(Galleria.FULLSCREEN_EXIT)});$win.unbind("resize",fullscreen.scale)}};var idle=this._idle={trunk:[],bound:false,active:false,add:function(elem,to,from,hide){if(!elem){return}if(!idle.bound){idle.addEvent()}elem=$(elem);if(typeof from=="boolean"){hide=from;from={}}from=from||{};var extract={},style;for(style in to){if(to.hasOwnProperty(style)){extract[style]=elem.css(style)}}elem.data("idle",{from:$.extend(extract,from),to:to,complete:true,busy:false});if(!hide){idle.addTimer()}else{elem.css(to)}idle.trunk.push(elem)},remove:function(elem){elem=$(elem);$.each(idle.trunk,function(i,el){if(el&&el.length&&!el.not(elem).length){elem.css(elem.data("idle").from);idle.trunk.splice(i,1)}});if(!idle.trunk.length){idle.removeEvent();self.clearTimer(idle.timer)}},addEvent:function(){idle.bound=true;self.$("container").bind("mousemove click",idle.showAll);if(self._options.idleMode=="hover"){self.$("container").bind("mouseleave",idle.hide)}},removeEvent:function(){idle.bound=false;self.$("container").bind("mousemove click",idle.showAll);if(self._options.idleMode=="hover"){self.$("container").unbind("mouseleave",idle.hide)}},addTimer:function(){if(self._options.idleMode=="hover"){return}self.addTimer("idle",function(){idle.hide()},self._options.idleTime)},hide:function(){if(!self._options.idleMode||self.getIndex()===false||self.getData().iframe){return}self.trigger(Galleria.IDLE_ENTER);var len=idle.trunk.length;$.each(idle.trunk,function(i,elem){var data=elem.data("idle");if(!data){return}elem.data("idle").complete=false;Utils.animate(elem,data.to,{duration:self._options.idleSpeed,complete:function(){if(i==len-1){idle.active=false}}})})},showAll:function(){self.clearTimer("idle");$.each(idle.trunk,function(i,elem){idle.show(elem)})},show:function(elem){var data=elem.data("idle");if(!idle.active||!data.busy&&!data.complete){data.busy=true;self.trigger(Galleria.IDLE_EXIT);self.clearTimer("idle");Utils.animate(elem,data.from,{duration:self._options.idleSpeed/2,complete:function(){idle.active=true;$(elem).data("idle").busy=false;$(elem).data("idle").complete=true}})}idle.addTimer()}};var lightbox=this._lightbox={width:0,height:0,initialized:false,active:null,image:null,elems:{},keymap:false,init:function(){self.trigger(Galleria.LIGHTBOX_OPEN);if(lightbox.initialized){return}lightbox.initialized=true;var elems="overlay box content shadow title info close prevholder prev nextholder next counter image",el={},op=self._options,css="",abs="position:absolute;",prefix="lightbox-",cssMap={overlay:"position:fixed;display:none;opacity:"+op.overlayOpacity+";filter:alpha(opacity="+op.overlayOpacity*100+");top:0;left:0;width:100%;height:100%;background:"+op.overlayBackground+";z-index:99990",box:"position:fixed;display:none;width:400px;height:400px;top:50%;left:50%;margin-top:-200px;margin-left:-200px;z-index:99991",shadow:abs+"background:#000;width:100%;height:100%;",content:abs+"background-color:#fff;top:10px;left:10px;right:10px;bottom:10px;overflow:hidden",info:abs+"bottom:10px;left:10px;right:10px;color:#444;font:11px/13px arial,sans-serif;height:13px",close:abs+"top:10px;right:10px;height:20px;width:20px;background:#fff;text-align:center;cursor:pointer;color:#444;font:16px/22px arial,sans-serif;z-index:99999",image:abs+"top:10px;left:10px;right:10px;bottom:30px;overflow:hidden;display:block;",prevholder:abs+"width:50%;top:0;bottom:40px;cursor:pointer;",nextholder:abs+"width:50%;top:0;bottom:40px;right:-1px;cursor:pointer;",prev:abs+"top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;left:20px;display:none;text-align:center;color:#000;font:bold 16px/36px arial,sans-serif",next:abs+"top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;right:20px;left:auto;display:none;font:bold 16px/36px arial,sans-serif;text-align:center;color:#000",title:"float:left",counter:"float:right;margin-left:8px;"},hover=function(elem){return elem.hover(function(){$(this).css("color","#bbb")},function(){$(this).css("color","#444")})},appends={};if(IE&&IE>7){cssMap.nextholder+="background:#000;filter:alpha(opacity=0);";cssMap.prevholder+="background:#000;filter:alpha(opacity=0);"}$.each(cssMap,function(key,value){css+=".galleria-"+prefix+key+"{"+value+"}"});css+=".galleria-"+prefix+"box.iframe .galleria-"+prefix+"prevholder,"+".galleria-"+prefix+"box.iframe .galleria-"+prefix+"nextholder{"+"width:100px;height:100px;top:50%;margin-top:-70px}";Utils.insertStyleTag(css,"galleria-lightbox");$.each(elems.split(" "),function(i,elemId){self.addElement("lightbox-"+elemId);el[elemId]=lightbox.elems[elemId]=self.get("lightbox-"+elemId)});lightbox.image=new Galleria.Picture;$.each({box:"shadow content close prevholder nextholder",info:"title counter",content:"info image",prevholder:"prev",nextholder:"next"},function(key,val){var arr=[];$.each(val.split(" "),function(i,prop){arr.push(prefix+prop)});appends[prefix+key]=arr});self.append(appends);$(el.image).append(lightbox.image.container);$(DOM().body).append(el.overlay,el.box);Utils.optimizeTouch(el.box);hover($(el.close).bind("click",lightbox.hide).html("&#215;"));$.each(["Prev","Next"],function(i,dir){var $d=$(el[dir.toLowerCase()]).html(/v/.test(dir)?"&#8249;&#160;":"&#160;&#8250;"),$e=$(el[dir.toLowerCase()+"holder"]);$e.bind("click",function(){lightbox["show"+dir]()});if(IE<8||Galleria.TOUCH){$d.show();return}$e.hover(function(){$d.show()},function(e){$d.stop().fadeOut(200)})});$(el.overlay).bind("click",lightbox.hide);if(Galleria.IPAD){self._options.lightboxTransitionSpeed=0}},rescale:function(event){var width=Math.min($win.width()-40,lightbox.width),height=Math.min($win.height()-60,lightbox.height),ratio=Math.min(width/lightbox.width,height/lightbox.height),destWidth=Math.round(lightbox.width*ratio)+40,destHeight=Math.round(lightbox.height*ratio)+60,to={width:destWidth,height:destHeight,"margin-top":Math.ceil(destHeight/2)*-1,"margin-left":Math.ceil(destWidth/2)*-1};
    2 if(event){$(lightbox.elems.box).css(to)}else{$(lightbox.elems.box).animate(to,{duration:self._options.lightboxTransitionSpeed,easing:self._options.easing,complete:function(){var image=lightbox.image,speed=self._options.lightboxFadeSpeed;self.trigger({type:Galleria.LIGHTBOX_IMAGE,imageTarget:image.image});$(image.container).show();$(image.image).animate({opacity:1},speed);Utils.show(lightbox.elems.info,speed)}})}},hide:function(){lightbox.image.image=null;$win.unbind("resize",lightbox.rescale);$(lightbox.elems.box).hide();Utils.hide(lightbox.elems.info);self.detachKeyboard();self.attachKeyboard(lightbox.keymap);lightbox.keymap=false;Utils.hide(lightbox.elems.overlay,200,function(){$(this).hide().css("opacity",self._options.overlayOpacity);self.trigger(Galleria.LIGHTBOX_CLOSE)})},showNext:function(){lightbox.show(self.getNext(lightbox.active))},showPrev:function(){lightbox.show(self.getPrev(lightbox.active))},show:function(index){lightbox.active=index=typeof index==="number"?index:self.getIndex()||0;if(!lightbox.initialized){lightbox.init()}if(!lightbox.keymap){lightbox.keymap=$.extend({},self._keyboard.map);self.attachKeyboard({escape:lightbox.hide,right:lightbox.showNext,left:lightbox.showPrev})}$win.unbind("resize",lightbox.rescale);var data=self.getData(index),total=self.getDataLength(),n=self.getNext(index),ndata,p,i;Utils.hide(lightbox.elems.info);try{for(i=self._options.preload;i>0;i--){p=new Galleria.Picture;ndata=self.getData(n);p.preload("big"in ndata?ndata.big:ndata.image);n=self.getNext(n)}}catch(e){}lightbox.image.isIframe=!!data.iframe;$(lightbox.elems.box).toggleClass("iframe",!!data.iframe);lightbox.image.load(data.iframe||data.big||data.image,function(image){if(image.isIframe){var cw=$(window).width(),ch=$(window).height();if(self._options.maxVideoSize){var r=Math.min(self._options.maxVideoSize/cw,self._options.maxVideoSize/ch);if(r<1){cw*=r;ch*=r}}lightbox.width=cw;lightbox.height=ch}else{lightbox.width=image.original.width;lightbox.height=image.original.height}$(image.image).css({width:image.isIframe?"100%":"100.1%",height:image.isIframe?"100%":"100.1%",top:0,zIndex:99998,opacity:0,visibility:"visible"});lightbox.elems.title.innerHTML=data.title||"";lightbox.elems.counter.innerHTML=index+1+" / "+total;$win.resize(lightbox.rescale);lightbox.rescale()});$(lightbox.elems.overlay).show().css("visibility","visible");$(lightbox.elems.box).show()}};var _timer=this._timer={trunk:{},add:function(id,fn,delay,loop){id=id||(new Date).getTime();loop=loop||false;this.clear(id);if(loop){var old=fn;fn=function(){old();_timer.add(id,fn,delay)}}this.trunk[id]=window.setTimeout(fn,delay)},clear:function(id){var del=function(i){window.clearTimeout(this.trunk[i]);delete this.trunk[i]},i;if(!!id&&id in this.trunk){del.call(this,id)}else if(typeof id==="undefined"){for(i in this.trunk){if(this.trunk.hasOwnProperty(i)){del.call(this,i)}}}}};return this};Galleria.prototype={constructor:Galleria,init:function(target,options){var self=this;options=_legacyOptions(options);this._original={target:target,options:options,data:null};this._target=this._dom.target=target.nodeName?target:$(target).get(0);this._original.html=this._target.innerHTML;_instances.push(this);if(!this._target){Galleria.raise("Target not found",true);return}this._options={autoplay:false,carousel:true,carouselFollow:true,carouselSpeed:400,carouselSteps:"auto",clicknext:false,dailymotion:{foreground:"%23EEEEEE",highlight:"%235BCEC5",background:"%23222222",logo:0,hideInfos:1},dataConfig:function(elem){return{}},dataSelector:"img",dataSort:false,dataSource:this._target,debug:undef,dummy:undef,easing:"galleria",extend:function(options){},fullscreenCrop:undef,fullscreenDoubleTap:true,fullscreenTransition:undef,height:0,idleMode:true,idleTime:3e3,idleSpeed:200,imageCrop:false,imageMargin:0,imagePan:false,imagePanSmoothness:12,imagePosition:"50%",imageTimeout:undef,initialTransition:undef,keepSource:false,layerFollow:true,lightbox:false,lightboxFadeSpeed:200,lightboxTransitionSpeed:200,linkSourceImages:true,maxScaleRatio:undef,maxVideoSize:undef,minScaleRatio:undef,overlayOpacity:.85,overlayBackground:"#0b0b0b",pauseOnInteraction:true,popupLinks:false,preload:2,queue:true,responsive:true,show:0,showInfo:true,showCounter:true,showImagenav:true,swipe:true,thumbCrop:true,thumbEventType:"click",thumbFit:true,thumbMargin:0,thumbQuality:"auto",thumbDisplayOrder:true,thumbnails:true,touchTransition:undef,transition:"fade",transitionInitial:undef,transitionSpeed:400,trueFullscreen:true,useCanvas:false,vimeo:{title:0,byline:0,portrait:0,color:"aaaaaa"},wait:5e3,width:"auto",youtube:{modestbranding:1,autohide:1,color:"white",hd:1,rel:0,showinfo:0}};this._options.initialTransition=this._options.initialTransition||this._options.transitionInitial;if(options&&options.debug===false){DEBUG=false}if(options&&typeof options.imageTimeout==="number"){TIMEOUT=options.imageTimeout}if(options&&typeof options.dummy==="string"){DUMMY=options.dummy}$(this._target).children().hide();if(Galleria.QUIRK){Galleria.raise("Your page is in Quirks mode, Galleria may not render correctly. Please validate your HTML and add a correct doctype.")}if(typeof Galleria.theme==="object"){this._init()}else{_pool.push(this)}return this},_init:function(){var self=this,options=this._options;if(this._initialized){Galleria.raise("Init failed: Gallery instance already initialized.");return this}this._initialized=true;if(!Galleria.theme){Galleria.raise("Init failed: No theme found.",true);return this}$.extend(true,options,Galleria.theme.defaults,this._original.options,Galleria.configure.options);(function(can){if(!("getContext"in can)){can=null;return}_canvas=_canvas||{elem:can,context:can.getContext("2d"),cache:{},length:0}})(doc.createElement("canvas"));this.bind(Galleria.DATA,function(){this._original.data=this._data;this.get("total").innerHTML=this.getDataLength();var $container=this.$("container");if(self._options.height<2){self._userRatio=self._ratio=self._options.height}var num={width:0,height:0};var testHeight=function(){return self.$("stage").height()};Utils.wait({until:function(){num=self._getWH();$container.width(num.width).height(num.height);return testHeight()&&num.width&&num.height>50},success:function(){self._width=num.width;self._height=num.height;self._ratio=self._ratio||num.height/num.width;if(Galleria.WEBKIT){window.setTimeout(function(){self._run()},1)}else{self._run()}},error:function(){if(testHeight()){Galleria.raise("Could not extract sufficient width/height of the gallery container. Traced measures: width:"+num.width+"px, height: "+num.height+"px.",true)}else{Galleria.raise("Could not extract a stage height from the CSS. Traced height: "+testHeight()+"px.",true)}},timeout:typeof this._options.wait=="number"?this._options.wait:false})});this.append({"info-text":["info-title","info-description"],info:["info-text"],"image-nav":["image-nav-right","image-nav-left"],stage:["images","loader","counter","image-nav"],"thumbnails-list":["thumbnails"],"thumbnails-container":["thumb-nav-left","thumbnails-list","thumb-nav-right"],container:["stage","thumbnails-container","info","tooltip"]});Utils.hide(this.$("counter").append(this.get("current"),doc.createTextNode(" / "),this.get("total")));this.setCounter("&#8211;");Utils.hide(self.get("tooltip"));this.$("container").addClass(Galleria.TOUCH?"touch":"notouch");$.each(new Array(2),function(i){var image=new Galleria.Picture;$(image.container).css({position:"absolute",top:0,left:0}).prepend(self._layers[i]=$(Utils.create("galleria-layer")).css({position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:2})[0]);self.$("images").append(image.container);self._controls[i]=image});this.$("images").css({position:"relative",top:0,left:0,width:"100%",height:"100%"});this.$("thumbnails, thumbnails-list").css({overflow:"hidden",position:"relative"});this.$("image-nav-right, image-nav-left").bind("click",function(e){if(options.clicknext){e.stopPropagation()}if(options.pauseOnInteraction){self.pause()}var fn=/right/.test(this.className)?"next":"prev";self[fn]()});$.each(["info","counter","image-nav"],function(i,el){if(options["show"+el.substr(0,1).toUpperCase()+el.substr(1).replace(/-/,"")]===false){Utils.moveOut(self.get(el.toLowerCase()))}});this.load();if(!options.keepSource&&!IE){this._target.innerHTML=""}if(this.get("errors")){this.appendChild("target","errors")}this.appendChild("target","container");if(options.carousel){var count=0,show=options.show;this.bind(Galleria.THUMBNAIL,function(){this.updateCarousel();if(++count==this.getDataLength()&&typeof show=="number"&&show>0){this._carousel.follow(show)}})}if(options.responsive){$win.bind("resize",function(){if(!self.isFullscreen()){self.resize()}})}if(options.swipe){(function(images){var swipeStart=[0,0],swipeStop=[0,0],limitX=30,limitY=100,multi=false,tid=0,data,ev={start:"touchstart",move:"touchmove",stop:"touchend"},getData=function(e){return e.originalEvent.touches?e.originalEvent.touches[0]:e},moveHandler=function(e){if(e.originalEvent.touches&&e.originalEvent.touches.length>1){return}data=getData(e);swipeStop=[data.pageX,data.pageY];if(!swipeStart[0]){swipeStart=swipeStop}if(Math.abs(swipeStart[0]-swipeStop[0])>10){e.preventDefault()}},upHandler=function(e){images.unbind(ev.move,moveHandler);if(e.originalEvent.touches&&e.originalEvent.touches.length||multi){multi=!multi;return}if(Utils.timestamp()-tid<1e3&&Math.abs(swipeStart[0]-swipeStop[0])>limitX&&Math.abs(swipeStart[1]-swipeStop[1])<limitY){e.preventDefault();self[swipeStart[0]>swipeStop[0]?"next":"prev"]()}swipeStart=swipeStop=[0,0]};images.bind(ev.start,function(e){if(e.originalEvent.touches&&e.originalEvent.touches.length>1){return}data=getData(e);tid=Utils.timestamp();swipeStart=swipeStop=[data.pageX,data.pageY];images.bind(ev.move,moveHandler).one(ev.stop,upHandler)})})(self.$("images"));if(options.fullscreenDoubleTap){this.$("stage").bind("touchstart",function(){var last,cx,cy,lx,ly,now,getData=function(e){return e.originalEvent.touches?e.originalEvent.touches[0]:e};return function(e){now=Galleria.utils.timestamp();cx=getData(e).pageX;cy=getData(e).pageY;if(now-last<500&&cx-lx<20&&cy-ly<20){self.toggleFullscreen();e.preventDefault();self.$("stage").unbind("touchend",arguments.callee);return}last=now;lx=cx;ly=cy}}())}}Utils.optimizeTouch(this.get("container"));$.each(Galleria.on.binds,function(i,bind){if($.inArray(bind.hash,self._binds)==-1){self.bind(bind.type,bind.callback)}});return this},addTimer:function(){this._timer.add.apply(this._timer,Utils.array(arguments));return this},clearTimer:function(){this._timer.clear.apply(this._timer,Utils.array(arguments));return this},_getWH:function(){var $container=this.$("container"),$target=this.$("target"),self=this,num={},arr;$.each(["width","height"],function(i,m){if(self._options[m]&&typeof self._options[m]==="number"){num[m]=self._options[m]}else{arr=[Utils.parseValue($container.css(m)),Utils.parseValue($target.css(m)),$container[m](),$target[m]()];if(!self["_"+m]){arr.splice(arr.length,Utils.parseValue($container.css("min-"+m)),Utils.parseValue($target.css("min-"+m)))}num[m]=Math.max.apply(Math,arr)}});if(self._userRatio){num.height=num.width*self._userRatio}return num},_createThumbnails:function(push){this.get("total").innerHTML=this.getDataLength();var src,thumb,data,special,$container,self=this,o=this._options,i=push?this._data.length-push.length:0,chunk=i,thumbchunk=[],loadindex=0,gif=IE<8?"http://upload.wikimedia.org/wikipedia/commons/c/c0/Blank.gif":"data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D",active=function(){var a=self.$("thumbnails").find(".active");if(!a.length){return false}return a.find("img").attr("src")}(),optval=typeof o.thumbnails==="string"?o.thumbnails.toLowerCase():null,getStyle=function(prop){return doc.defaultView&&doc.defaultView.getComputedStyle?doc.defaultView.getComputedStyle(thumb.container,null)[prop]:$container.css(prop)},fake=function(image,index,container){return function(){$(container).append(image);self.trigger({type:Galleria.THUMBNAIL,thumbTarget:image,index:index,galleriaData:self.getData(index)})}},onThumbEvent=function(e){if(o.pauseOnInteraction){self.pause()}var index=$(e.currentTarget).data("index");if(self.getIndex()!==index){self.show(index)}e.preventDefault()},thumbComplete=function(thumb,callback){$(thumb.container).css("visibility","visible");self.trigger({type:Galleria.THUMBNAIL,thumbTarget:thumb.image,index:thumb.data.order,galleriaData:self.getData(thumb.data.order)});if(typeof callback=="function"){callback.call(self,thumb)}},onThumbLoad=function(thumb,callback){thumb.scale({width:thumb.data.width,height:thumb.data.height,crop:o.thumbCrop,margin:o.thumbMargin,canvas:o.useCanvas,complete:function(thumb){var top=["left","top"],arr=["Width","Height"],m,css,data=self.getData(thumb.index),special=data.thumb.split(":");$.each(arr,function(i,measure){m=measure.toLowerCase();if((o.thumbCrop!==true||o.thumbCrop===m)&&o.thumbFit){css={};css[m]=thumb[m];$(thumb.container).css(css);css={};css[top[i]]=0;$(thumb.image).css(css)}thumb["outer"+measure]=$(thumb.container)["outer"+measure](true)});Utils.toggleQuality(thumb.image,o.thumbQuality===true||o.thumbQuality==="auto"&&thumb.original.width<thumb.width*3);if(data.iframe&&special.length==2&&special[0]in _video){_video[special[0]].getThumb(special[1],function(img){return function(src){img.src=src;thumbComplete(thumb,callback)}}(thumb.image))}else if(o.thumbDisplayOrder&&!thumb.lazy){$.each(thumbchunk,function(i,th){if(i===loadindex&&th.ready&&!th.displayed){loadindex++;th.displayed=true;thumbComplete(th,callback);return}})}else{thumbComplete(thumb,callback)}}})};if(!push){this._thumbnails=[];this.$("thumbnails").empty()}for(;this._data[i];i++){data=this._data[i];src=data.thumb||data.image;if((o.thumbnails===true||optval=="lazy")&&(data.thumb||data.image)){thumb=new Galleria.Picture(i);thumb.index=i;thumb.displayed=false;thumb.lazy=false;thumb.video=false;this.$("thumbnails").append(thumb.container);$container=$(thumb.container);$container.css("visibility","hidden");thumb.data={width:Utils.parseValue(getStyle("width")),height:Utils.parseValue(getStyle("height")),order:i,src:src};if(o.thumbFit&&o.thumbCrop!==true){$container.css({width:"auto",height:"auto"})}else{$container.css({width:thumb.data.width,height:thumb.data.height})}special=src.split(":");if(special.length==2&&special[0]in _video){thumb.video=true;thumb.ready=true;thumb.load(gif,{height:thumb.data.height,width:thumb.data.height*1.25},onThumbLoad)}else if(optval=="lazy"){$container.addClass("lazy");thumb.lazy=true;thumb.load(gif,{height:thumb.data.height,width:thumb.data.width})}else{thumb.load(src,onThumbLoad)}if(o.preload==="all"){thumb.preload(data.image)}}else if(data.iframe||optval==="empty"||optval==="numbers"){thumb={container:Utils.create("galleria-image"),image:Utils.create("img","span"),ready:true};if(optval==="numbers"){$(thumb.image).text(i+1)}if(data.iframe){$(thumb.image).addClass("iframe")}this.$("thumbnails").append(thumb.container);window.setTimeout(fake(thumb.image,i,thumb.container),50+i*20)}else{thumb={container:null,image:null}}$(thumb.container).add(o.keepSource&&o.linkSourceImages?data.original:null).data("index",i).bind(o.thumbEventType,onThumbEvent).data("thumbload",onThumbLoad);if(active===src){$(thumb.container).addClass("active")}this._thumbnails.push(thumb)}thumbchunk=this._thumbnails.slice(chunk);return this},lazyLoad:function(index,complete){var arr=index.constructor==Array?index:[index],self=this,thumbnails=this.$("thumbnails").children().filter(function(){return $(this).data("lazy-src")}),loaded=0;$.each(arr,function(i,ind){if(ind>self._thumbnails.length-1){return}var thumb=self._thumbnails[ind],data=thumb.data,special=data.src.split(":"),callback=function(){if(++loaded==arr.length&&typeof complete=="function"){complete.call(self)}},thumbload=$(thumb.container).data("thumbload");if(thumb.video){thumbload.call(self,thumb,callback)}else{thumb.load(data.src,function(thumb){thumbload.call(self,thumb,callback)})}});return this},lazyLoadChunks:function(size,delay){var len=this.getDataLength(),i=0,n=0,arr=[],temp=[],self=this;delay=delay||0;for(;i<len;i++){temp.push(i);if(++n==size||i==len-1){arr.push(temp);n=0;temp=[]}}var init=function(wait){var a=arr.shift();if(a){window.setTimeout(function(){self.lazyLoad(a,function(){init(true)})},delay&&wait?delay:0)}};init(false);return this},_run:function(){var self=this;self._createThumbnails();Utils.wait({timeout:1e4,until:function(){if(Galleria.OPERA){self.$("stage").css("display","inline-block")}self._stageWidth=self.$("stage").width();self._stageHeight=self.$("stage").height();return self._stageWidth&&self._stageHeight>50},success:function(){_galleries.push(self);Utils.show(self.get("counter"));if(self._options.carousel){self._carousel.bindControls()}if(self._options.autoplay){self.pause();if(typeof self._options.autoplay==="number"){self._playtime=self._options.autoplay}self._playing=true}if(self._firstrun){if(self._options.autoplay){self.trigger(Galleria.PLAY)}if(typeof self._options.show==="number"){self.show(self._options.show)}return}self._firstrun=true;if(Galleria.History){Galleria.History.change(function(value){if(isNaN(value)){window.history.go(-1)}else{self.show(value,undef,true)}})}self.trigger(Galleria.READY);Galleria.theme.init.call(self,self._options);$.each(Galleria.ready.callbacks,function(i,fn){if(typeof fn=="function"){fn.call(self,self._options)}});self._options.extend.call(self,self._options);if(/^[0-9]{1,4}$/.test(HASH)&&Galleria.History){self.show(HASH,undef,true)}else if(self._data[self._options.show]){self.show(self._options.show)}if(self._options.autoplay){self.trigger(Galleria.PLAY)}},error:function(){Galleria.raise("Stage width or height is too small to show the gallery. Traced measures: width:"+self._stageWidth+"px, height: "+self._stageHeight+"px.",true)}})},load:function(source,selector,config){var self=this,o=this._options;this._data=[];this._thumbnails=[];this.$("thumbnails").empty();if(typeof selector==="function"){config=selector;selector=null}source=source||o.dataSource;selector=selector||o.dataSelector;config=config||o.dataConfig;if(/^function Object/.test(source.constructor)){source=[source]}if(source.constructor===Array){if(this.validate(source)){this._data=source}else{Galleria.raise("Load failed: JSON Array not valid.")}}else{selector+=",.video,.iframe";$(source).find(selector).each(function(i,elem){elem=$(elem);var data={},parent=elem.parent(),href=parent.attr("href"),rel=parent.attr("rel");if(href&&(elem[0].nodeName=="IMG"||elem.hasClass("video"))&&_videoTest(href)){data.video=href}else if(href&&elem.hasClass("iframe")){data.iframe=href}else{data.image=data.big=href}if(rel){data.big=rel}$.each("big title description link layer".split(" "),function(i,val){if(elem.data(val)){data[val]=elem.data(val)}});self._data.push($.extend({title:elem.attr("title")||"",thumb:elem.attr("src"),image:elem.attr("src"),big:elem.attr("src"),description:elem.attr("alt")||"",link:elem.attr("longdesc"),original:elem.get(0)},data,config(elem)))})}if(typeof o.dataSort=="function"){protoArray.sort.call(this._data,o.dataSort)}else if(o.dataSort=="random"){this._data.sort(function(){return Math.round(Math.random())-.5})}if(this.getDataLength()){this._parseData().trigger(Galleria.DATA)}return this},_parseData:function(){var self=this,current;$.each(this._data,function(i,data){current=self._data[i];if("thumb"in data===false){current.thumb=data.image}if(!"big"in data){current.big=data.image}if("video"in data){var result=_videoTest(data.video);if(result){current.iframe=_video[result.provider].embed(result.id)+function(){if(typeof self._options[result.provider]=="object"){var str="?",arr=[];$.each(self._options[result.provider],function(key,val){arr.push(key+"="+val)});if(result.provider=="youtube"){arr=["wmode=opaque"].concat(arr)}return str+arr.join("&")}return""}();delete current.video;if(!("thumb"in current)||!current.thumb){current.thumb=result.provider+":"+result.id}}}});return this},destroy:function(){this.$("target").data("galleria",null);this.$("container").unbind("galleria");this.get("target").innerHTML=this._original.html;this.clearTimer();Utils.removeFromArray(_instances,this);Utils.removeFromArray(_galleries,this);return this},splice:function(){var self=this,args=Utils.array(arguments);window.setTimeout(function(){protoArray.splice.apply(self._data,args);self._parseData()._createThumbnails()},2);return self},push:function(){var self=this,args=Utils.array(arguments);if(args.length==1&&args[0].constructor==Array){args=args[0]}window.setTimeout(function(){protoArray.push.apply(self._data,args);self._parseData()._createThumbnails(args)},2);return self},_getActive:function(){return this._controls.getActive()},validate:function(data){return true},bind:function(type,fn){type=_patchEvent(type);this.$("container").bind(type,this.proxy(fn));return this},unbind:function(type){type=_patchEvent(type);this.$("container").unbind(type);return this},trigger:function(type){type=typeof type==="object"?$.extend(type,{scope:this}):{type:_patchEvent(type),scope:this};this.$("container").trigger(type);return this},addIdleState:function(elem,styles,from,hide){this._idle.add.apply(this._idle,Utils.array(arguments));return this},removeIdleState:function(elem){this._idle.remove.apply(this._idle,Utils.array(arguments));return this},enterIdleMode:function(){this._idle.hide();return this},exitIdleMode:function(){this._idle.showAll();return this},enterFullscreen:function(callback){this._fullscreen.enter.apply(this,Utils.array(arguments));return this},exitFullscreen:function(callback){this._fullscreen.exit.apply(this,Utils.array(arguments));return this},toggleFullscreen:function(callback){this._fullscreen[this.isFullscreen()?"exit":"enter"].apply(this,Utils.array(arguments));return this},bindTooltip:function(elem,value){this._tooltip.bind.apply(this._tooltip,Utils.array(arguments));return this},defineTooltip:function(elem,value){this._tooltip.define.apply(this._tooltip,Utils.array(arguments));return this},refreshTooltip:function(elem){this._tooltip.show.apply(this._tooltip,Utils.array(arguments));return this},openLightbox:function(){this._lightbox.show.apply(this._lightbox,Utils.array(arguments));return this},closeLightbox:function(){this._lightbox.hide.apply(this._lightbox,Utils.array(arguments));return this},getActiveImage:function(){return this._getActive().image||undef},getActiveThumb:function(){return this._thumbnails[this._active].image||undef},getMousePosition:function(e){return{x:e.pageX-this.$("container").offset().left,y:e.pageY-this.$("container").offset().top}},addPan:function(img){if(this._options.imageCrop===false){return}img=$(img||this.getActiveImage());var self=this,x=img.width()/2,y=img.height()/2,destX=parseInt(img.css("left"),10),destY=parseInt(img.css("top"),10),curX=destX||0,curY=destY||0,distX=0,distY=0,active=false,ts=Utils.timestamp(),cache=0,move=0,position=function(dist,cur,pos){if(dist>0){move=Math.round(Math.max(dist*-1,Math.min(0,cur)));if(cache!==move){cache=move;if(IE===8){img.parent()["scroll"+pos](move*-1)}else{var css={};css[pos.toLowerCase()]=move;img.css(css)}}}},calculate=function(e){if(Utils.timestamp()-ts<50){return}active=true;x=self.getMousePosition(e).x;y=self.getMousePosition(e).y},loop=function(e){if(!active){return}distX=img.width()-self._stageWidth;distY=img.height()-self._stageHeight;destX=x/self._stageWidth*distX*-1;destY=y/self._stageHeight*distY*-1;curX+=(destX-curX)/self._options.imagePanSmoothness;curY+=(destY-curY)/self._options.imagePanSmoothness;position(distY,curY,"Top");position(distX,curX,"Left")};if(IE===8){img.parent().scrollTop(curY*-1).scrollLeft(curX*-1);img.css({top:0,left:0})}this.$("stage").unbind("mousemove",calculate).bind("mousemove",calculate);this.addTimer("pan"+self._id,loop,50,true);return this},proxy:function(fn,scope){if(typeof fn!=="function"){return F}scope=scope||this;return function(){return fn.apply(scope,Utils.array(arguments))}},removePan:function(){this.$("stage").unbind("mousemove");this.clearTimer("pan"+this._id);return this},addElement:function(id){var dom=this._dom;$.each(Utils.array(arguments),function(i,blueprint){dom[blueprint]=Utils.create("galleria-"+blueprint)});return this},attachKeyboard:function(map){this._keyboard.attach.apply(this._keyboard,Utils.array(arguments));return this},detachKeyboard:function(){this._keyboard.detach.apply(this._keyboard,Utils.array(arguments));return this},appendChild:function(parentID,childID){this.$(parentID).append(this.get(childID)||childID);return this},prependChild:function(parentID,childID){this.$(parentID).prepend(this.get(childID)||childID);return this},remove:function(elemID){this.$(Utils.array(arguments).join(",")).remove();return this},append:function(data){var i,j;for(i in data){if(data.hasOwnProperty(i)){if(data[i].constructor===Array){for(j=0;data[i][j];j++){this.appendChild(i,data[i][j])}}else{this.appendChild(i,data[i])}}}return this},_scaleImage:function(image,options){image=image||this._controls.getActive();if(!image){return}var self=this,complete,scaleLayer=function(img){$(img.container).children(":first").css({top:Math.max(0,Utils.parseValue(img.image.style.top)),left:Math.max(0,Utils.parseValue(img.image.style.left)),width:Utils.parseValue(img.image.width),height:Utils.parseValue(img.image.height)})};options=$.extend({width:this._stageWidth,height:this._stageHeight,crop:this._options.imageCrop,max:this._options.maxScaleRatio,min:this._options.minScaleRatio,margin:this._options.imageMargin,position:this._options.imagePosition,iframelimit:this._options.maxVideoSize},options);if(this._options.layerFollow&&this._options.imageCrop!==true){if(typeof options.complete=="function"){complete=options.complete;options.complete=function(){complete.call(image,image);scaleLayer(image)}}else{options.complete=scaleLayer}}else{$(image.container).children(":first").css({top:0,left:0})}image.scale(options);return this},updateCarousel:function(){this._carousel.update();return this},resize:function(measures,complete){if(typeof measures=="function"){complete=measures;measures=undef}measures=$.extend({width:0,height:0},measures);var self=this,$container=this.$("container");$.each(measures,function(m,val){if(!val){$container[m]("auto");measures[m]=self._getWH()[m]}});$.each(measures,function(m,val){$container[m](val)});return this.rescale(complete)},rescale:function(width,height,complete){var self=this;if(typeof width==="function"){complete=width;width=undef}var scale=function(){self._stageWidth=width||self.$("stage").width();self._stageHeight=height||self.$("stage").height();self._scaleImage();if(self._options.carousel){self.updateCarousel()}self.trigger(Galleria.RESCALE);if(typeof complete==="function"){complete.call(self)}};scale.call(self);return this},refreshImage:function(){this._scaleImage();if(this._options.imagePan){this.addPan()}return this},show:function(index,rewind,_history){if(this._queue.length>3||index===false||!this._options.queue&&this._queue.stalled){return}index=Math.max(0,Math.min(parseInt(index,10),this.getDataLength()-1));rewind=typeof rewind!=="undefined"?!!rewind:index<this.getIndex();_history=_history||false;if(!_history&&Galleria.History){Galleria.History.set(index.toString());return}this._active=index;protoArray.push.call(this._queue,{index:index,rewind:rewind});if(!this._queue.stalled){this._show()}return this},_show:function(){var self=this,queue=this._queue[0],data=this.getData(queue.index);if(!data){return}var src=data.iframe||(this.isFullscreen()&&"big"in data?data.big:data.image),active=this._controls.getActive(),next=this._controls.getNext(),cached=next.isCached(src),thumb=this._thumbnails[queue.index],mousetrigger=function(){$(next.image).trigger("mouseup")};var complete=function(data,next,active,queue,thumb){return function(){var win;_transitions.active=false;Utils.toggleQuality(next.image,self._options.imageQuality);self._layers[self._controls.active].innerHTML="";$(active.container).css({zIndex:0,opacity:0}).show();if(active.isIframe){$(active.container).find("iframe").remove()}self.$("container").toggleClass("iframe",!!data.iframe);$(next.container).css({zIndex:1,left:0,top:0}).show();self._controls.swap();if(self._options.imagePan){self.addPan(next.image)}if(data.link||self._options.lightbox||self._options.clicknext){$(next.image).css({cursor:"pointer"}).bind("mouseup",function(e){if(typeof e.which=="number"&&e.which>1){return}if(self._options.clicknext&&!Galleria.TOUCH){if(self._options.pauseOnInteraction){self.pause()}self.next();return}if(data.link){if(self._options.popupLinks){win=window.open(data.link,"_blank")}else{window.location.href=data.link}return}if(self._options.lightbox){self.openLightbox()}})}self._playCheck();self.trigger({type:Galleria.IMAGE,index:queue.index,imageTarget:next.image,thumbTarget:thumb.image,galleriaData:data});protoArray.shift.call(self._queue);self._queue.stalled=false;if(self._queue.length){self._show()}}}(data,next,active,queue,thumb);if(this._options.carousel&&this._options.carouselFollow){this._carousel.follow(queue.index)}if(this._options.preload){var p,i,n=this.getNext(),ndata;try{for(i=this._options.preload;i>0;i--){p=new Galleria.Picture;ndata=self.getData(n);p.preload(this.isFullscreen()&&"big"in ndata?ndata.big:ndata.image);n=self.getNext(n)}}catch(e){}}Utils.show(next.container);next.isIframe=!!data.iframe;$(self._thumbnails[queue.index].container).addClass("active").siblings(".active").removeClass("active");self.trigger({type:Galleria.LOADSTART,cached:cached,index:queue.index,rewind:queue.rewind,imageTarget:next.image,thumbTarget:thumb.image,galleriaData:data});self._queue.stalled=true;next.load(src,function(next){var layer=$(self._layers[1-self._controls.active]).html(data.layer||"").hide();self._scaleImage(next,{complete:function(next){if("image"in active){Utils.toggleQuality(active.image,false)}Utils.toggleQuality(next.image,false);self.removePan();self.setInfo(queue.index);self.setCounter(queue.index);if(data.layer){layer.show();if(data.link||self._options.lightbox||self._options.clicknext){layer.css("cursor","pointer").unbind("mouseup").mouseup(mousetrigger)}}var transition=self._options.transition;$.each({initial:active.image===null,touch:Galleria.TOUCH,fullscreen:self.isFullscreen()},function(type,arg){if(arg&&self._options[type+"Transition"]!==undef){transition=self._options[type+"Transition"];return false}});if(transition in _transitions.effects===false){complete()}else{var params={prev:active.container,next:next.container,rewind:queue.rewind,speed:self._options.transitionSpeed||400};_transitions.active=true;_transitions.init.call(self,transition,params,complete)}self.trigger({type:Galleria.LOADFINISH,cached:cached,index:queue.index,rewind:queue.rewind,imageTarget:next.image,thumbTarget:self._thumbnails[queue.index].image,galleriaData:self.getData(queue.index)})}})})},getNext:function(base){base=typeof base==="number"?base:this.getIndex();return base===this.getDataLength()-1?0:base+1},getPrev:function(base){base=typeof base==="number"?base:this.getIndex();return base===0?this.getDataLength()-1:base-1},next:function(){if(this.getDataLength()>1){this.show(this.getNext(),false)}return this},prev:function(){if(this.getDataLength()>1){this.show(this.getPrev(),true)}return this},get:function(elemId){return elemId in this._dom?this._dom[elemId]:null},getData:function(index){return index in this._data?this._data[index]:this._data[this._active]},getDataLength:function(){return this._data.length},getIndex:function(){return typeof this._active==="number"?this._active:false},getStageHeight:function(){return this._stageHeight},getStageWidth:function(){return this._stageWidth},getOptions:function(key){return typeof key==="undefined"?this._options:this._options[key]},setOptions:function(key,value){if(typeof key==="object"){$.extend(this._options,key)}else{this._options[key]=value}return this},play:function(delay){this._playing=true;
    3 this._playtime=delay||this._playtime;this._playCheck();this.trigger(Galleria.PLAY);return this},pause:function(){this._playing=false;this.trigger(Galleria.PAUSE);return this},playToggle:function(delay){return this._playing?this.pause():this.play(delay)},isPlaying:function(){return this._playing},isFullscreen:function(){return this._fullscreen.active},_playCheck:function(){var self=this,played=0,interval=20,now=Utils.timestamp(),timer_id="play"+this._id;if(this._playing){this.clearTimer(timer_id);var fn=function(){played=Utils.timestamp()-now;if(played>=self._playtime&&self._playing){self.clearTimer(timer_id);self.next();return}if(self._playing){self.trigger({type:Galleria.PROGRESS,percent:Math.ceil(played/self._playtime*100),seconds:Math.floor(played/1e3),milliseconds:played});self.addTimer(timer_id,fn,interval)}};self.addTimer(timer_id,fn,interval)}},setPlaytime:function(delay){this._playtime=delay;return this},setIndex:function(val){this._active=val;return this},setCounter:function(index){if(typeof index==="number"){index++}else if(typeof index==="undefined"){index=this.getIndex()+1}this.get("current").innerHTML=index;if(IE){var count=this.$("counter"),opacity=count.css("opacity");if(parseInt(opacity,10)===1){Utils.removeAlpha(count[0])}else{this.$("counter").css("opacity",opacity)}}return this},setInfo:function(index){var self=this,data=this.getData(index);$.each(["title","description"],function(i,type){var elem=self.$("info-"+type);if(!!data[type]){elem[data[type].length?"show":"hide"]().html(data[type])}else{elem.empty().hide()}});return this},hasInfo:function(index){var check="title description".split(" "),i;for(i=0;check[i];i++){if(!!this.getData(index)[check[i]]){return true}}return false},jQuery:function(str){var self=this,ret=[];$.each(str.split(","),function(i,elemId){elemId=$.trim(elemId);if(self.get(elemId)){ret.push(elemId)}});var jQ=$(self.get(ret.shift()));$.each(ret,function(i,elemId){jQ=jQ.add(self.get(elemId))});return jQ},$:function(str){return this.jQuery.apply(this,Utils.array(arguments))}};$.each(_events,function(i,ev){var type=/_/.test(ev)?ev.replace(/_/g,""):ev;Galleria[ev.toUpperCase()]="galleria."+type});$.extend(Galleria,{IE9:IE===9,IE8:IE===8,IE7:IE===7,IE6:IE===6,IE:IE,WEBKIT:/webkit/.test(NAV),CHROME:/chrome/.test(NAV),SAFARI:/safari/.test(NAV)&&!/chrome/.test(NAV),QUIRK:IE&&doc.compatMode&&doc.compatMode==="BackCompat",MAC:/mac/.test(navigator.platform.toLowerCase()),OPERA:!!window.opera,IPHONE:/iphone/.test(NAV),IPAD:/ipad/.test(NAV),ANDROID:/android/.test(NAV),TOUCH:"ontouchstart"in doc});Galleria.addTheme=function(theme){if(!theme.name){Galleria.raise("No theme name specified")}if(typeof theme.defaults!=="object"){theme.defaults={}}else{theme.defaults=_legacyOptions(theme.defaults)}var css=false,reg;if(typeof theme.css==="string"){$("link").each(function(i,link){reg=new RegExp(theme.css);if(reg.test(link.href)){css=true;_themeLoad(theme);return false}});if(!css){$("script").each(function(i,script){reg=new RegExp("galleria\\."+theme.name.toLowerCase()+"\\.");if(reg.test(script.src)){css=script.src.replace(/[^\/]*$/,"")+theme.css;window.setTimeout(function(){Utils.loadCSS(css,"galleria-theme",function(){_themeLoad(theme)})},1)}})}if(!css){Galleria.raise("No theme CSS loaded")}}else{_themeLoad(theme)}return theme};Galleria.loadTheme=function(src,options){if($("script").filter(function(){return $(this).attr("src")==src}).length){return}var loaded=false,err;$(window).load(function(){if(!loaded){err=window.setTimeout(function(){if(!loaded&&!Galleria.theme){Galleria.raise("Galleria had problems loading theme at "+src+". Please check theme path or load manually.",true)}},2e4)}});Galleria.unloadTheme();Utils.loadScript(src,function(){loaded=true;window.clearTimeout(err)});return Galleria};Galleria.unloadTheme=function(){if(typeof Galleria.theme=="object"){$("script").each(function(i,script){if(new RegExp("galleria\\."+Galleria.theme.name+"\\.").test(script.src)){$(script).remove()}});Galleria.theme=undef}return Galleria};Galleria.get=function(index){if(!!_instances[index]){return _instances[index]}else if(typeof index!=="number"){return _instances}else{Galleria.raise("Gallery index "+index+" not found")}};Galleria.configure=function(key,value){var opts={};if(typeof key=="string"&&value){opts[key]=value;key=opts}else{$.extend(opts,key)}Galleria.configure.options=opts;$.each(Galleria.get(),function(i,instance){instance.setOptions(opts)});return Galleria};Galleria.configure.options={};Galleria.on=function(type,callback){if(!type){return}callback=callback||F;var hash=type+callback.toString().replace(/\s/g,"")+Utils.timestamp();$.each(Galleria.get(),function(i,instance){instance._binds.push(hash);instance.bind(type,callback)});Galleria.on.binds.push({type:type,callback:callback,hash:hash});return Galleria};Galleria.on.binds=[];Galleria.run=function(selector,options){if($.isFunction(options)){options={extend:options}}$(selector||"#galleria").galleria(options);return Galleria};Galleria.addTransition=function(name,fn){_transitions.effects[name]=fn;return Galleria};Galleria.utils=Utils;Galleria.log=function(){var args=Utils.array(arguments);if("console"in window&&"log"in window.console){try{return window.console.log.apply(window.console,args)}catch(e){$.each(args,function(){window.console.log(this)})}}else{return window.alert(args.join("<br>"))}};Galleria.ready=function(fn){if(typeof fn!="function"){return Galleria}$.each(_galleries,function(i,gallery){fn.call(gallery,gallery._options)});Galleria.ready.callbacks.push(fn);return Galleria};Galleria.ready.callbacks=[];Galleria.raise=function(msg,fatal){var type=fatal?"Fatal error":"Error",self=this,css={color:"#fff",position:"absolute",top:0,left:0,zIndex:1e5},echo=function(msg){var html='<div style="padding:4px;margin:0 0 2px;background:#'+(fatal?"811":"222")+';">'+(fatal?"<strong>"+type+": </strong>":"")+msg+"</div>";$.each(_instances,function(){var cont=this.$("errors"),target=this.$("target");if(!cont.length){target.css("position","relative");cont=this.addElement("errors").appendChild("target","errors").$("errors").css(css)}cont.append(html)});if(!_instances.length){$("<div>").css($.extend(css,{position:"fixed"})).append(html).appendTo(DOM().body)}};if(DEBUG){echo(msg);if(fatal){throw new Error(type+": "+msg)}}else if(fatal){if(_hasError){return}_hasError=true;fatal=false;echo("Gallery could not load.")}};Galleria.version=VERSION;Galleria.requires=function(version,msg){msg=msg||"You need to upgrade Galleria to version "+version+" to use one or more components.";if(Galleria.version<version){Galleria.raise(msg,true)}return Galleria};Galleria.Picture=function(id){this.id=id||null;this.image=null;this.container=Utils.create("galleria-image");$(this.container).css({overflow:"hidden",position:"relative"});this.original={width:0,height:0};this.ready=false;this.isIframe=false};Galleria.Picture.prototype={cache:{},show:function(){Utils.show(this.image)},hide:function(){Utils.moveOut(this.image)},clear:function(){this.image=null},isCached:function(src){return!!this.cache[src]},preload:function(src){$(new Image).load(function(src,cache){return function(){cache[src]=src}}(src,this.cache)).attr("src",src)},load:function(src,size,callback){if(typeof size=="function"){callback=size;size=null}if(this.isIframe){var id="if"+(new Date).getTime();this.image=$("<iframe>",{src:src,frameborder:0,id:id,allowfullscreen:true,css:{visibility:"hidden"}})[0];$(this.container).find("iframe,img").remove();this.container.appendChild(this.image);$("#"+id).load(function(self,callback){return function(){window.setTimeout(function(){$(self.image).css("visibility","visible");if(typeof callback=="function"){callback.call(self,self)}},10)}}(this,callback));return this.container}this.image=new Image;if(Galleria.IE8){$(this.image).css("filter","inherit")}var i=0,reload=false,resort=false,$container=$(this.container),$image=$(this.image),onerror=function(){if(!reload){reload=true;window.setTimeout(function(image,src){return function(){image.attr("src",src+"?"+Utils.timestamp())}}($(this),src),50)}else{if(DUMMY){$(this).attr("src",DUMMY)}else{Galleria.raise("Image not found: "+src)}}},onload=function(self,callback,src){return function(){var complete=function(){$(this).unbind("load");self.original=size||{height:this.height,width:this.width};self.container.appendChild(this);self.cache[src]=src;if(typeof callback=="function"){window.setTimeout(function(){callback.call(self,self)},1)}};if(!this.width||!this.height){window.setTimeout(function(img){return function(){if(img.width&&img.height){complete.call(img)}else{if(!resort){$(new Image).load(onload).attr("src",img.src);resort=true}else{Galleria.raise("Could not extract width/height from image: "+img.src+". Traced measures: width:"+img.width+"px, height: "+img.height+"px.")}}}}(this),2)}else{complete.call(this)}}}(this,callback,src);$container.find("iframe,img").remove();$image.css("display","block");Utils.hide(this.image);$.each("minWidth minHeight maxWidth maxHeight".split(" "),function(i,prop){$image.css(prop,/min/.test(prop)?"0":"none")});$image.load(onload).error(onerror).attr("src",src);return this.container},scale:function(options){var self=this;options=$.extend({width:0,height:0,min:undef,max:undef,margin:0,complete:F,position:"center",crop:false,canvas:false,iframelimit:undef},options);if(this.isIframe){var cw=options.width,ch=options.height,nw,nh;if(options.iframelimit){var r=Math.min(options.iframelimit/cw,options.iframelimit/ch);if(r<1){nw=cw*r;nh=ch*r;$(this.image).css({top:ch/2-nh/2,left:cw/2-nw/2,position:"absolute"})}else{$(this.image).css({top:0,left:0})}}$(this.image).width(nw||cw).height(nh||ch).removeAttr("width").removeAttr("height");$(this.container).width(cw).height(ch);options.complete.call(self,self);try{if(this.image.contentWindow){$(this.image.contentWindow).trigger("resize")}}catch(e){}return this.container}if(!this.image){return this.container}var width,height,$container=$(self.container),data;Utils.wait({until:function(){width=options.width||$container.width()||Utils.parseValue($container.css("width"));height=options.height||$container.height()||Utils.parseValue($container.css("height"));return width&&height},success:function(){var newWidth=(width-options.margin*2)/self.original.width,newHeight=(height-options.margin*2)/self.original.height,min=Math.min(newWidth,newHeight),max=Math.max(newWidth,newHeight),cropMap={"true":max,width:newWidth,height:newHeight,"false":min,landscape:self.original.width>self.original.height?max:min,portrait:self.original.width<self.original.height?max:min},ratio=cropMap[options.crop.toString()],canvasKey="";if(options.max){ratio=Math.min(options.max,ratio)}if(options.min){ratio=Math.max(options.min,ratio)}$.each(["width","height"],function(i,m){$(self.image)[m](self[m]=self.image[m]=Math.round(self.original[m]*ratio))});$(self.container).width(width).height(height);if(options.canvas&&_canvas){_canvas.elem.width=self.width;_canvas.elem.height=self.height;canvasKey=self.image.src+":"+self.width+"x"+self.height;self.image.src=_canvas.cache[canvasKey]||function(key){_canvas.context.drawImage(self.image,0,0,self.original.width*ratio,self.original.height*ratio);try{data=_canvas.elem.toDataURL();_canvas.length+=data.length;_canvas.cache[key]=data;return data}catch(e){return self.image.src}}(canvasKey)}var pos={},mix={},getPosition=function(value,measure,margin){var result=0;if(/\%/.test(value)){var flt=parseInt(value,10)/100,m=self.image[measure]||$(self.image)[measure]();result=Math.ceil(m*-1*flt+margin*flt)}else{result=Utils.parseValue(value)}return result},positionMap={top:{top:0},left:{left:0},right:{left:"100%"},bottom:{top:"100%"}};$.each(options.position.toLowerCase().split(" "),function(i,value){if(value==="center"){value="50%"}pos[i?"top":"left"]=value});$.each(pos,function(i,value){if(positionMap.hasOwnProperty(value)){$.extend(mix,positionMap[value])}});pos=pos.top?$.extend(pos,mix):mix;pos=$.extend({top:"50%",left:"50%"},pos);$(self.image).css({position:"absolute",top:getPosition(pos.top,"height",height),left:getPosition(pos.left,"width",width)});self.show();self.ready=true;options.complete.call(self,self)},error:function(){Galleria.raise("Could not scale image: "+self.image.src)},timeout:1e3});return this}};$.extend($.easing,{galleria:function(_,t,b,c,d){if((t/=d/2)<1){return c/2*t*t*t+b}return c/2*((t-=2)*t*t+2)+b},galleriaIn:function(_,t,b,c,d){return c*(t/=d)*t+b},galleriaOut:function(_,t,b,c,d){return-c*(t/=d)*(t-2)+b}});$.fn.galleria=function(options){var selector=this.selector;if(!$(this).length){$(function(){if($(selector).length){$(selector).galleria(options)}else{Galleria.utils.wait({until:function(){return $(selector).length},success:function(){$(selector).galleria(options)},error:function(){Galleria.raise('Init failed: Galleria could not find the element "'+selector+'".')},timeout:5e3})}});return this}return this.each(function(){if($.data(this,"galleria")){$.data(this,"galleria").destroy();$(this).find("*").hide()}$.data(this,"galleria",(new Galleria).init(this,options))})}})(jQuery);
     1/**
     2 * Galleria - v1.5.7 2017-05-10
     3 * https://galleria.io
     4 *
     5 * Copyright (c) 2010 - 2017 worse is better UG
     6 * Licensed under the MIT License.
     7 * https://raw.github.com/worseisbetter/galleria/master/LICENSE
     8 *
     9 */
     10
     11!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="<!--[if gt IE "+ ++a+"]><i></i><![endif]-->";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;(?:amp;)?)*v(?:&lt;[A-Z]+&gt;)?=([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<A._inst.length;e++)if(A._inst[e].id===d&&A._inst[e].type==c)return A._inst[e];this.type=c,this.id=d,this.readys=[],A._inst.push(this);var f=this;a.extend(this,A[c]),_videoThumbs=function(b){f.data=b,a.each(f.readys,function(a,b){b(f.data)}),f.readys=[]},this.hasOwnProperty("getUrl")?a.getJSON(this.getUrl(),_videoThumbs):b.setTimeout(_videoThumbs,400),this.getMedia=function(a,b,c){c=c||q;var d=this,e=function(c){b(d["get_"+a](c))};try{d.data?e(d.data):d.readys.push(e)}catch(a){c()}}},C=function(a){var b;for(var c in A)if(b=a&&A[c].reg&&a.match(A[c].reg),b&&b.length)return{id:b[2],provider:c};return!1},D={support:function(){var a=u().html;return!v&&(a.requestFullscreen||a.msRequestFullscreen||a.mozRequestFullScreen||a.webkitRequestFullScreen)}(),callback:q,enter:function(a,b,c){this.instance=a,this.callback=b||q,c=c||u().html,c.requestFullscreen?c.requestFullscreen():c.msRequestFullscreen?c.msRequestFullscreen():c.mozRequestFullScreen?c.mozRequestFullScreen():c.webkitRequestFullScreen&&c.webkitRequestFullScreen()},exit:function(a){this.callback=a||q,e.exitFullscreen?e.exitFullscreen():e.msExitFullscreen?e.msExitFullscreen():e.mozCancelFullScreen?e.mozCancelFullScreen():e.webkitCancelFullScreen&&e.webkitCancelFullScreen()},instance:null,listen:function(){if(this.support){var a=function(){if(D.instance){var a=D.instance._fullscreen;e.fullscreen||e.mozFullScreen||e.webkitIsFullScreen||e.msFullscreenElement&&null!==e.msFullscreenElement?a._enter(D.callback):a._exit(D.callback)}};e.addEventListener("fullscreenchange",a,!1),e.addEventListener("MSFullscreenChange",a,!1),e.addEventListener("mozfullscreenchange",a,!1),e.addEventListener("webkitfullscreenchange",a,!1)}}},E=[],F=[],G=!1,H=!1,I=[],J=[],K=function(b){J.push(b),a.each(I,function(a,c){c._options.theme!=b.name&&(c._initialized||c._options.theme)||(c.theme=b,c._init.call(c))})},L=function(){return{clearTimer:function(b){a.each(c.get(),function(){this.clearTimer(b)})},addTimer:function(b){a.each(c.get(),function(){this.addTimer(b)})},array:function(a){return h.slice.call(a,0)},create:function(a,b){b=b||"div";var c=e.createElement(b);return c.className=a,c},removeFromArray:function(b,c){return a.each(b,function(a,d){if(d==c)return b.splice(a,1),!1}),b},getScriptPath:function(b){b=b||a("script:last").attr("src");var c=b.split("/");return 1==c.length?"":(c.pop(),c.join("/")+"/")},animate:function(){var d,f,g,h,i,j,k,l=function(a){var c,d="transition WebkitTransition MozTransition OTransition".split(" ");if(b.opera)return!1;for(c=0;d[c];c++)if("undefined"!=typeof a[d[c]])return d[c];return!1}((e.body||e.documentElement).style),m={MozTransition:"transitionend",OTransition:"oTransitionEnd",WebkitTransition:"webkitTransitionEnd",transition:"transitionend"}[l],n={_default:[.25,.1,.25,1],galleria:[.645,.045,.355,1],galleriaIn:[.55,.085,.68,.53],galleriaOut:[.25,.46,.45,.94],ease:[.25,0,.25,1],linear:[.25,.25,.75,.75],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]},o=function(b,c,d){var e={};d=d||"transition",a.each("webkit moz ms o".split(" "),function(){e["-"+this+"-"+d]=c}),b.css(e)},p=function(a){o(a,"none","transition"),c.WEBKIT&&c.TOUCH&&(o(a,"translate3d(0,0,0)","transform"),a.data("revert")&&(a.css(a.data("revert")),a.data("revert",null)))};return function(e,r,s){return s=a.extend({duration:400,complete:q,stop:!1},s),e=a(e),s.duration?l?(s.stop&&(e.off(m),p(e)),d=!1,a.each(r,function(a,b){k=e.css(a),L.parseValue(k)!=L.parseValue(b)&&(d=!0),e.css(a,k)}),d?(f=[],g=s.easing in n?n[s.easing]:n._default,h=" "+s.duration+"ms cubic-bezier("+g.join(",")+")",void b.setTimeout(function(b,d,e,g){return function(){b.one(d,function(a){return function(){p(a),s.complete.call(a[0])}}(b)),c.WEBKIT&&c.TOUCH&&(i={},j=[0,0,0],a.each(["left","top"],function(a,c){c in e&&(j[a]=L.parseValue(e[c])-L.parseValue(b.css(c))+"px",i[c]=e[c],delete e[c])}),(j[0]||j[1])&&(b.data("revert",i),f.push("-webkit-transform"+g),o(b,"translate3d("+j.join(",")+")","transform"))),a.each(e,function(a,b){f.push(a+g)}),o(b,f.join(",")),b.css(e)}}(e,m,r,h),2)):void b.setTimeout(function(){s.complete.call(e[0])},s.duration)):void e.animate(r,s):(e.css(r),void s.complete.call(e[0]))}}(),removeAlpha:function(a){if(a instanceof jQuery&&(a=a[0]),t<9&&a){var b=a.style,c=a.currentStyle,d=c&&c.filter||b.filter||"";/alpha/.test(d)&&(b.filter=d.replace(/alpha\([^)]*\)/i,""))}},forceStyles:function(b,c){b=a(b),b.attr("style")&&b.data("styles",b.attr("style")).removeAttr("style"),b.css(c)},revertStyles:function(){a.each(L.array(arguments),function(b,c){c=a(c),c.removeAttr("style"),c.attr("style",""),c.data("styles")&&c.attr("style",c.data("styles")).data("styles",null)})},moveOut:function(a){L.forceStyles(a,{position:"absolute",left:-1e4})},moveIn:function(){L.revertStyles.apply(L,L.array(arguments))},hide:function(b,c,d){d=d||q;var e=a(b);b=e[0],e.data("opacity")||e.data("opacity",e.css("opacity"));var f={opacity:0};if(c){var g=t<9&&b?function(){L.removeAlpha(b),b.style.visibility="hidden",d.call(b)}:d;L.animate(b,f,{duration:c,complete:g,stop:!0})}else t<9&&b?(L.removeAlpha(b),b.style.visibility="hidden"):e.css(f)},show:function(b,c,d){d=d||q;var e=a(b);b=e[0];var f=parseFloat(e.data("opacity"))||1,g={opacity:f};if(c){t<9&&(e.css("opacity",0),b.style.visibility="visible");var h=t<9&&b?function(){1==g.opacity&&L.removeAlpha(b),d.call(b)}:d;L.animate(b,g,{duration:c,complete:h,stop:!0})}else t<9&&1==g.opacity&&b?(L.removeAlpha(b),b.style.visibility="visible"):e.css(g)},wait:function(d){c._waiters=c._waiters||[],d=a.extend({until:r,success:q,error:function(){c.raise("Could not complete wait function.")},timeout:3e3},d);var e,f,g,h=L.timestamp(),i=function(){return f=L.timestamp(),e=f-h,L.removeFromArray(c._waiters,g),d.until(e)?(d.success(),!1):"number"==typeof d.timeout&&f>=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("<script>").attr({src:b,async:!0}).get(0);e.onload=e.onreadystatechange=function(){d||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState||(d=!0,e.onload=e.onreadystatechange=null,"function"==typeof c&&c.call(this,this))},u().head.appendChild(e)},parseValue:function(a){if("number"==typeof a)return a;if("string"==typeof a){var b=a.match(/\-?\d|\./g);return b&&b.constructor===Array?1*b.join(""):0}return 0},timestamp:function(){return(new Date).getTime()},loadCSS:function(b,f,g){var h,i;if(a("link[rel=stylesheet]").each(function(){if(new RegExp(b).test(this.href))return h=this,!1}),"function"==typeof f&&(g=f,f=d),g=g||q,h)return g.call(h,h),h;if(i=e.styleSheets.length,a("#"+f).length)a("#"+f).attr("href",b),i--;else{h=a("<link>").attr({rel:"stylesheet",href:b,id:f}).get(0);var j=a('link[rel="stylesheet"], style');if(j.length?j.get(0).parentNode.insertBefore(h,j[0]):u().head.appendChild(h),t&&i>=31)return void c.raise("You have reached the browser stylesheet limit (31)",!0)}if("function"==typeof g){var k=a("<s>").attr("id","galleria-loader").hide().appendTo(u().body);L.wait({until:function(){return k.height()>0},success:function(){k.remove(),g.call(h,h)},error:function(){k.remove(),c.raise("Theme CSS could not load after 20 sec. "+(c.QUIRK?"Your browser is in Quirks Mode, please add a correct doctype.":"Please download the latest theme at http://galleria.io/customer/."),!0)},timeout:5e3})}return h}}}(),M=function(b){var c=".galleria-videoicon{width:60px;height:60px;position:absolute;top:50%;left:50%;z-index:1;margin:-30px 0 0 -30px;cursor:pointer;background:#000;background:rgba(0,0,0,.8);border-radius:3px;-webkit-transition:all 150ms}.galleria-videoicon i{width:0px;height:0px;border-style:solid;border-width:10px 0 10px 16px;display:block;border-color:transparent transparent transparent #ffffff;margin:20px 0 0 22px}.galleria-image:hover .galleria-videoicon{background:#000}";return L.insertStyleTag(c,"galleria-videoicon"),a(L.create("galleria-videoicon")).html("<i></i>").appendTo(b).click(function(){a(this).siblings("img").mouseup()})},N=function(){var b=function(b,c,d,e){var f=this.getOptions("easing"),g=this.getStageWidth(),h={left:g*(b.rewind?-1:1)},i={left:0};d?(h.opacity=0,i.opacity=1):h.opacity=1,a(b.next).css(h),L.animate(b.next,i,{duration:b.speed,complete:function(a){return function(){c(),a.css({left:0})}}(a(b.next).add(b.prev)),queue:!1,easing:f}),e&&(b.rewind=!b.rewind),b.prev&&(h={left:0},i={left:g*(b.rewind?1:-1)},d&&(h.opacity=1,i.opacity=0),a(b.prev).css(h),L.animate(b.prev,i,{duration:b.speed,queue:!1,easing:f,complete:function(){a(this).css("opacity",0)}}))};return{active:!1,init:function(a,b,c){N.effects.hasOwnProperty(a)&&N.effects[a].call(this,b,c)},effects:{fade:function(b,c){a(b.next).css({opacity:0,left:0}),L.animate(b.next,{opacity:1},{duration:b.speed,complete:c}),b.prev&&(a(b.prev).css("opacity",1).show(),L.animate(b.prev,{opacity:0},{duration:b.speed}))},flash:function(b,c){a(b.next).css({opacity:0,left:0}),b.prev?L.animate(b.prev,{opacity:0},{duration:b.speed/2,complete:function(){L.animate(b.next,{opacity:1},{duration:b.speed,complete:c})}}):L.animate(b.next,{opacity:1},{duration:b.speed,complete:c})},pulse:function(b,c){b.prev&&a(b.prev).hide(),a(b.next).css({opacity:0,left:0}).show(),L.animate(b.next,{opacity:1},{duration:b.speed,complete:c})},slide:function(a,c){b.apply(this,L.array(arguments))},fadeslide:function(a,c){b.apply(this,L.array(arguments).concat([!0]))},doorslide:function(a,c){b.apply(this,L.array(arguments).concat([!1,!0]))}}}}();D.listen(),a.event.special["click:fast"]={propagate:!0,add:function(c){var d=function(a){if(a.touches&&a.touches.length){var b=a.touches[0];return{x:b.pageX,y:b.pageY}}},e={touched:!1,touchdown:!1,coords:{x:0,y:0},evObj:{}};a(this).data({clickstate:e,timer:0}).on("touchstart.fast",function(c){b.clearTimeout(a(this).data("timer")),a(this).data("clickstate",{touched:!0,touchdown:!0,coords:d(c.originalEvent),evObj:c})}).on("touchmove.fast",function(b){var c=d(b.originalEvent),e=a(this).data("clickstate"),f=Math.max(Math.abs(e.coords.x-c.x),Math.abs(e.coords.y-c.y));f>6&&a(this).data("clickstate",a.extend(e,{touchdown:!1}))}).on("touchend.fast",function(d){var f=a(this),g=f.data("clickstate");g.touchdown&&c.handler.call(this,d),f.data("timer",b.setTimeout(function(){f.data("clickstate",e)},400))}).on("click.fast",function(b){var d=a(this).data("clickstate");return!d.touched&&(a(this).data("clickstate",e),void c.handler.call(this,b))})},remove:function(){a(this).off("touchstart.fast touchmove.fast touchend.fast click.fast")}},g.on("orientationchange",function(){a(this).resize()}),c=function(){var h=this;this._options={},this._playing=!1,this._playtime=5e3,this._active=null,this._queue={length:0},this._data=[],this._dom={},this._thumbnails=[],this._layers=[],this._initialized=!1,this._firstrun=!1,this._stageWidth=0,this._stageHeight=0,this._target=d,this._binds=[],this._id=parseInt(1e4*p.random(),10);var i="container stage images image-nav image-nav-left image-nav-right info info-text info-title info-description thumbnails thumbnails-list thumbnails-container thumb-nav-left thumb-nav-right loader counter tooltip",j="current total";a.each(i.split(" "),function(a,b){h._dom[b]=L.create("galleria-"+b)}),a.each(j.split(" "),function(a,b){h._dom[b]=L.create("galleria-"+b,"span")});var k=this._keyboard={keys:{UP:38,DOWN:40,LEFT:37,RIGHT:39,RETURN:13,ESCAPE:27,BACKSPACE:8,SPACE:32},map:{},bound:!1,press:function(a){var b=a.keyCode||a.which;b in k.map&&"function"==typeof k.map[b]&&k.map[b].call(h,a)},attach:function(a){var b,c;for(b in a)a.hasOwnProperty(b)&&(c=b.toUpperCase(),c in k.keys?k.map[k.keys[c]]=a[b]:k.map[c]=a[b]);k.bound||(k.bound=!0,f.on("keydown",k.press))},detach:function(){k.bound=!1,k.map={},f.off("keydown",k.press)}},l=this._controls={0:d,1:d,active:0,swap:function(){l.active=l.active?0:1},getActive:function(){return h._options.swipe?l.slides[h._active]:l[l.active]},getNext:function(){return h._options.swipe?l.slides[h.getNext(h._active)]:l[1-l.active]},slides:[],frames:[],layers:[]},n=this._carousel={next:h.$("thumb-nav-right"),prev:h.$("thumb-nav-left"),width:0,current:0,max:0,hooks:[],update:function(){var b=0,c=0,d=[0];a.each(h._thumbnails,function(e,f){if(f.ready){b+=f.outerWidth||a(f.container).outerWidth(!0);var g=a(f.container).width();b+=g-p.floor(g),d[e+1]=b,c=p.max(c,f.outerHeight||a(f.container).outerHeight(!0))}}),h.$("thumbnails").css({width:b,height:c}),n.max=b,n.hooks=d,n.width=h.$("thumbnails-list").width(),n.setClasses(),h.$("thumbnails-container").toggleClass("galleria-carousel",b>n.width),n.width=h.$("thumbnails-list").width()},bindControls:function(){var a;n.next.on("click:fast",function(b){if(b.preventDefault(),"auto"===h._options.carouselSteps){for(a=n.current;a<n.hooks.length;a++)if(n.hooks[a]-n.hooks[n.current]>n.width){n.set(a-2);break}}else n.set(n.current+h._options.carouselSteps)}),n.prev.on("click:fast",function(b){if(b.preventDefault(),"auto"===h._options.carouselSteps)for(a=n.current;a>=0;a--){if(n.hooks[n.current]-n.hooks[a]>n.width){n.set(a+2);break}if(0===a){n.set(0);break}}else n.set(n.current-h._options.carouselSteps)})},set:function(a){for(a=p.max(a,0);n.hooks[a-1]+n.width>=n.max&&a>=0;)a--;n.current=a,n.animate()},getLast:function(a){return(a||n.current)-1},follow:function(a){if(0===a||a===n.hooks.length-2)return void n.set(a);for(var b=n.current;n.hooks[b]-n.hooks[n.current]<n.width&&b<=n.hooks.length;)b++;a-1<n.current?n.set(a-1):a+2>b&&n.set(a-b+n.current+2)},setClasses:function(){n.prev.toggleClass("disabled",!n.current),n.next.toggleClass("disabled",n.hooks[n.current]+n.width>=n.max)},animate:function(b){n.setClasses();var c=n.hooks[n.current]*-1;isNaN(c)||(h.$("thumbnails").css("left",function(){return a(this).css("left")}),L.animate(h.get("thumbnails"),{left:c},{duration:h._options.carouselSpeed,easing:h._options.easing,queue:!1}))}},o=this._tooltip={initialized:!1,open:!1,timer:"tooltip"+h._id,swapTimer:"swap"+h._id,init:function(){o.initialized=!0;var a=".galleria-tooltip{padding:3px 8px;max-width:50%;background:#ffe;color:#000;z-index:3;position:absolute;font-size:11px;line-height:1.3;opacity:0;box-shadow:0 0 2px rgba(0,0,0,.4);-moz-box-shadow:0 0 2px rgba(0,0,0,.4);-webkit-box-shadow:0 0 2px rgba(0,0,0,.4);}";L.insertStyleTag(a,"galleria-tooltip"),h.$("tooltip").css({opacity:.8,visibility:"visible",display:"none"})},move:function(a){var b=h.getMousePosition(a).x,c=h.getMousePosition(a).y,d=h.$("tooltip"),e=b,f=c,g=d.outerHeight(!0)+1,i=d.outerWidth(!0),j=g+15,k=h.$("container").width()-i-2,l=h.$("container").height()-g-2;isNaN(e)||isNaN(f)||(e+=10,f-=g+8,e=p.max(0,p.min(k,e)),f=p.max(0,p.min(l,f)),c<j&&(f=j),d.css({left:e,top:f}))},bind:function(b,d){if(!c.TOUCH){o.initialized||o.init();var e=function(){h.$("container").off("mousemove",o.move),h.clearTimer(o.timer),h.$("tooltip").stop().animate({opacity:0},200,function(){h.$("tooltip").hide(),h.addTimer(o.swapTimer,function(){o.open=!1},1e3)})},f=function(b,c){o.define(b,c),a(b).hover(function(){h.clearTimer(o.swapTimer),h.$("container").off("mousemove",o.move).on("mousemove",o.move).trigger("mousemove"),o.show(b),h.addTimer(o.timer,function(){h.$("tooltip").stop().show().animate({opacity:1}),o.open=!0},o.open?0:500)},e).click(e)};"string"==typeof d?f(b in h._dom?h.get(b):b,d):a.each(b,function(a,b){f(h.get(a),b)})}},show:function(c){c=a(c in h._dom?h.get(c):c);var d=c.data("tt"),e=function(a){b.setTimeout(function(a){return function(){o.move(a)}}(a),10),c.off("mouseup",e)};d="function"==typeof d?d():d,d&&(h.$("tooltip").html(d.replace(/\s/,"&#160;")),c.on("mouseup",e))},define:function(b,c){if("function"!=typeof c){var d=c;c=function(){return d}}b=a(b in h._dom?h.get(b):b).data("tt",c),o.show(b)}},q=this._fullscreen={scrolled:0,crop:d,active:!1,prev:a(),beforeEnter:function(a){a()},beforeExit:function(a){a()},keymap:h._keyboard.map,parseCallback:function(b,c){return N.active?function(){"function"==typeof b&&b.call(h);var d=h._controls.getActive(),e=h._controls.getNext();h._scaleImage(e),h._scaleImage(d),c&&h._options.trueFullscreen&&a(d.container).add(e.container).trigger("transitionend")}:b},enter:function(a){q.beforeEnter(function(){a=q.parseCallback(a,!0),h._options.trueFullscreen&&D.support?(q.active=!0,L.forceStyles(h.get("container"),{width:"100%",height:"100%"}),h.rescale(),c.MAC?c.SAFARI&&/version\/[1-5]/.test(m)?(h.$("stage").css("opacity",0),b.setTimeout(function(){q.scale(),h.$("stage").css("opacity",1)},4)):(h.$("container").css("opacity",0).addClass("fullscreen"),b.setTimeout(function(){q.scale(),h.$("container").css("opacity",1)},50)):h.$("container").addClass("fullscreen"),g.resize(q.scale),D.enter(h,a,h.get("container"))):(q.scrolled=g.scrollTop(),c.TOUCH||b.scrollTo(0,0),q._enter(a))})},_enter:function(f){q.active=!0,v&&(q.iframe=function(){var d,f=e.referrer,g=e.createElement("a"),h=b.location;return g.href=f,g.protocol!=h.protocol||g.hostname!=h.hostname||g.port!=h.port?(c.raise("Parent fullscreen not available. Iframe protocol, domains and ports must match."),!1):(q.pd=b.parent.document,a(q.pd).find("iframe").each(function(){var a=this.contentDocument||this.contentWindow.document;if(a===e)return d=this,!1}),d)}()),L.hide(h.getActiveImage()),v&&q.iframe&&(q.iframe.scrolled=a(b.parent).scrollTop(),b.parent.scrollTo(0,0));var i=h.getData(),j=h._options,k=!h._options.trueFullscreen||!D.support,l={height:"100%",overflow:"hidden",margin:0,padding:0};if(k&&(h.$("container").addClass("fullscreen"),q.prev=h.$("container").prev(),q.prev.length||(q.parent=h.$("container").parent()),h.$("container").appendTo("body"),L.forceStyles(h.get("container"),{position:c.TOUCH?"absolute":"fixed",top:0,left:0,width:"100%",height:"100%",zIndex:1e4}),L.forceStyles(u().html,l),L.forceStyles(u().body,l)),v&&q.iframe&&(L.forceStyles(q.pd.documentElement,l),L.forceStyles(q.pd.body,l),L.forceStyles(q.iframe,a.extend(l,{width:"100%",height:"100%",top:0,left:0,position:"fixed",zIndex:1e4,border:"none"}))),q.keymap=a.extend({},h._keyboard.map),h.attachKeyboard({escape:h.exitFullscreen,right:h.next,left:h.prev}),q.crop=j.imageCrop,j.fullscreenCrop!=d&&(j.imageCrop=j.fullscreenCrop),i&&i.big&&i.image!==i.big){var m=new c.Picture,n=m.isCached(i.big),o=h.getIndex(),p=h._thumbnails[o];h.trigger({type:c.LOADSTART,cached:n,rewind:!1,index:o,imageTarget:h.getActiveImage(),thumbTarget:p,galleriaData:i}),m.load(i.big,function(b){h._scaleImage(b,{complete:function(b){h.trigger({type:c.LOADFINISH,cached:n,index:o,rewind:!1,imageTarget:b.image,thumbTarget:p});var d=h._controls.getActive().image;d&&a(d).width(b.image.width).height(b.image.height).attr("style",a(b.image).attr("style")).attr("src",b.image.src)}})});var r=h.getNext(o),s=new c.Picture,t=h.getData(r);s.preload(h.isFullscreen()&&t.big?t.big:t.image)}h.rescale(function(){h.addTimer(!1,function(){k&&L.show(h.getActiveImage()),"function"==typeof f&&f.call(h),h.rescale()},100),h.trigger(c.FULLSCREEN_ENTER)}),k?g.resize(q.scale):L.show(h.getActiveImage())},scale:function(){h.rescale()},exit:function(a){q.beforeExit(function(){a=q.parseCallback(a),h._options.trueFullscreen&&D.support?D.exit(a):q._exit(a)})},_exit:function(a){q.active=!1;var d=!h._options.trueFullscreen||!D.support,e=h.$("container").removeClass("fullscreen");if(q.parent?q.parent.prepend(e):e.insertAfter(q.prev),d){L.hide(h.getActiveImage()),L.revertStyles(h.get("container"),u().html,u().body),c.TOUCH||b.scrollTo(0,q.scrolled);var f=h._controls.frames[h._controls.active];f&&f.image&&(f.image.src=f.image.src)}v&&q.iframe&&(L.revertStyles(q.pd.documentElement,q.pd.body,q.iframe),q.iframe.scrolled&&b.parent.scrollTo(0,q.iframe.scrolled)),h.detachKeyboard(),h.attachKeyboard(q.keymap),h._options.imageCrop=q.crop;var i=h.getData().big,j=h._controls.getActive().image;!h.getData().iframe&&j&&i&&i==j.src&&b.setTimeout(function(a){return function(){j.src=a}}(h.getData().image),1),h.rescale(function(){h.addTimer(!1,function(){d&&L.show(h.getActiveImage()),"function"==typeof a&&a.call(h),g.trigger("resize")},50),h.trigger(c.FULLSCREEN_EXIT)}),g.off("resize",q.scale)}},r=this._idle={trunk:[],bound:!1,active:!1,add:function(b,d,e,f){if(b&&!c.TOUCH){r.bound||r.addEvent(),b=a(b),"boolean"==typeof e&&(f=e,e={}),e=e||{};var g,h={};for(g in d)d.hasOwnProperty(g)&&(h[g]=b.css(g));b.data("idle",{from:a.extend(h,e),to:d,complete:!0,busy:!1}),f?b.css(d):r.addTimer(),r.trunk.push(b)}},remove:function(b){b=a(b),a.each(r.trunk,function(a,c){c&&c.length&&!c.not(b).length&&(b.css(b.data("idle").from),r.trunk.splice(a,1))}),r.trunk.length||(r.removeEvent(),h.clearTimer(r.timer))},addEvent:function(){r.bound=!0,h.$("container").on("mousemove click",r.showAll),"hover"==h._options.idleMode&&h.$("container").on("mouseleave",r.hide)},removeEvent:function(){r.bound=!1,h.$("container").on("mousemove click",r.showAll),"hover"==h._options.idleMode&&h.$("container").off("mouseleave",r.hide)},addTimer:function(){"hover"!=h._options.idleMode&&h.addTimer("idle",function(){r.hide()},h._options.idleTime)},hide:function(){if(h._options.idleMode&&h.getIndex()!==!1){h.trigger(c.IDLE_ENTER);var b=r.trunk.length;a.each(r.trunk,function(a,c){var d=c.data("idle");d&&(c.data("idle").complete=!1,L.animate(c,d.to,{duration:h._options.idleSpeed,complete:function(){a==b-1&&(r.active=!1)}}))})}},showAll:function(){h.clearTimer("idle"),a.each(r.trunk,function(a,b){r.show(b)})},show:function(b){var d=b.data("idle");r.active&&(d.busy||d.complete)||(d.busy=!0,h.trigger(c.IDLE_EXIT),h.clearTimer("idle"),L.animate(b,d.from,{duration:h._options.idleSpeed/2,complete:function(){r.active=!0,a(b).data("idle").busy=!1,a(b).data("idle").complete=!0}})),r.addTimer()}},s=this._lightbox={width:0,height:0,initialized:!1,active:null,image:null,elems:{},keymap:!1,init:function(){if(!s.initialized){s.initialized=!0;var b="overlay box content shadow title info close prevholder prev nextholder next counter image",d={},e=h._options,f="",g="position:absolute;",i="lightbox-",j={overlay:"position:fixed;display:none;opacity:"+e.overlayOpacity+";filter:alpha(opacity="+100*e.overlayOpacity+");top:0;left:0;width:100%;height:100%;background:"+e.overlayBackground+";z-index:99990",box:"position:fixed;display:none;width:400px;height:400px;top:50%;left:50%;margin-top:-200px;margin-left:-200px;z-index:99991",shadow:g+"background:#000;width:100%;height:100%;",content:g+"background-color:#fff;top:10px;left:10px;right:10px;bottom:10px;overflow:hidden",info:g+"bottom:10px;left:10px;right:10px;color:#444;font:11px/13px arial,sans-serif;height:13px",close:g+"top:10px;right:10px;height:20px;width:20px;background:#fff;text-align:center;cursor:pointer;color:#444;font:16px/22px arial,sans-serif;z-index:99999",image:g+"top:10px;left:10px;right:10px;bottom:30px;overflow:hidden;display:block;",prevholder:g+"width:50%;top:0;bottom:40px;cursor:pointer;",nextholder:g+"width:50%;top:0;bottom:40px;right:-1px;cursor:pointer;",prev:g+"top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;left:20px;display:none;text-align:center;color:#000;font:bold 16px/36px arial,sans-serif",next:g+"top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;right:20px;left:auto;display:none;font:bold 16px/36px arial,sans-serif;text-align:center;color:#000",title:"float:left",counter:"float:right;margin-left:8px;"},k=function(b){return b.hover(function(){a(this).css("color","#bbb")},function(){a(this).css("color","#444")})},l={},m="";m=t>7?t<9?"background:#000;filter:alpha(opacity=0);":"background:rgba(0,0,0,0);":"z-index:99999",j.nextholder+=m,j.prevholder+=m,a.each(j,function(a,b){f+=".galleria-"+i+a+"{"+b+"}"}),f+=".galleria-"+i+"box.iframe .galleria-"+i+"prevholder,.galleria-"+i+"box.iframe .galleria-"+i+"nextholder{width:100px;height:100px;top:50%;margin-top:-70px}",L.insertStyleTag(f,"galleria-lightbox"),a.each(b.split(" "),function(a,b){h.addElement("lightbox-"+b),d[b]=s.elems[b]=h.get("lightbox-"+b)}),s.image=new c.Picture,a.each({box:"shadow content close prevholder nextholder",info:"title counter",content:"info image",prevholder:"prev",nextholder:"next"},function(b,c){var d=[];a.each(c.split(" "),function(a,b){d.push(i+b)}),l[i+b]=d}),h.append(l),a(d.image).append(s.image.container),a(u().body).append(d.overlay,d.box),k(a(d.close).on("click:fast",s.hide).html("&#215;")),a.each(["Prev","Next"],function(b,e){var f=a(d[e.toLowerCase()]).html(/v/.test(e)?"&#8249;&#160;":"&#160;&#8250;"),g=a(d[e.toLowerCase()+"holder"]);return g.on("click:fast",function(){s["show"+e]()}),t<8||c.TOUCH?void f.show():void g.hover(function(){f.show()},function(a){f.stop().fadeOut(200)})}),a(d.overlay).on("click:fast",s.hide),c.IPAD&&(h._options.lightboxTransitionSpeed=0)}},rescale:function(b){var d=p.min(g.width()-40,s.width),e=p.min(g.height()-60,s.height),f=p.min(d/s.width,e/s.height),i=p.round(s.width*f)+40,j=p.round(s.height*f)+60,k={width:i,height:j,"margin-top":p.ceil(j/2)*-1,"margin-left":p.ceil(i/2)*-1};b?a(s.elems.box).css(k):a(s.elems.box).animate(k,{duration:h._options.lightboxTransitionSpeed,easing:h._options.easing,complete:function(){var b=s.image,d=h._options.lightboxFadeSpeed;h.trigger({type:c.LIGHTBOX_IMAGE,imageTarget:b.image}),a(b.container).show(),a(b.image).animate({opacity:1},d),L.show(s.elems.info,d)}})},hide:function(){s.image.image=null,g.off("resize",s.rescale),a(s.elems.box).hide().find("iframe").remove(),L.hide(s.elems.info),h.detachKeyboard(),h.attachKeyboard(s.keymap),s.keymap=!1,L.hide(s.elems.overlay,200,function(){a(this).hide().css("opacity",h._options.overlayOpacity),h.trigger(c.LIGHTBOX_CLOSE)})},showNext:function(){s.show(h.getNext(s.active))},showPrev:function(){s.show(h.getPrev(s.active))},show:function(d){s.active=d="number"==typeof d?d:h.getIndex()||0,s.initialized||s.init(),h.trigger(c.LIGHTBOX_OPEN),s.keymap||(s.keymap=a.extend({},h._keyboard.map),h.attachKeyboard({escape:s.hide,right:s.showNext,left:s.showPrev})),g.off("resize",s.rescale);var e,f,i,j=h.getData(d),k=h.getDataLength(),l=h.getNext(d);L.hide(s.elems.info);try{for(i=h._options.preload;i>0;i--)f=new c.Picture,e=h.getData(l),f.preload(e.big?e.big:e.image),l=h.getNext(l)}catch(a){}s.image.isIframe=j.iframe&&!j.image,a(s.elems.box).toggleClass("iframe",s.image.isIframe),a(s.image.container).find(".galleria-videoicon").remove(),s.image.load(j.big||j.image||j.iframe,function(c){if(c.isIframe){var e=a(b).width(),f=a(b).height();if(c.video&&h._options.maxVideoSize){var i=p.min(h._options.maxVideoSize/e,h._options.maxVideoSize/f);i<1&&(e*=i,f*=i)}s.width=e,s.height=f}else s.width=c.original.width,s.height=c.original.height;if(a(c.image).css({width:c.isIframe?"100%":"100.1%",height:c.isIframe?"100%":"100.1%",top:0,bottom:0,zIndex:99998,opacity:0,visibility:"visible"}).parent().height("100%"),s.elems.title.innerHTML=j.title||"",s.elems.counter.innerHTML=d+1+" / "+k,g.resize(s.rescale),s.rescale(),j.image&&j.iframe){if(a(s.elems.box).addClass("iframe"),j.video){var l=M(c.container).hide();b.setTimeout(function(){l.fadeIn(200)},200)}a(c.image).css("cursor","pointer").mouseup(function(b,c){return function(d){a(s.image.container).find(".galleria-videoicon").remove(),d.preventDefault(),c.isIframe=!0,c.load(b.iframe+(b.video?"&autoplay=1":""),{width:"100%",height:t<8?a(s.image.container).height():"100%"})}}(j,c))}}),a(s.elems.overlay).show().css("visibility","visible"),a(s.elems.box).show()}},w=this._timer={trunk:{},add:function(a,c,d,e){if(a=a||(new Date).getTime(),e=e||!1,this.clear(a),e){var f=c;c=function(){f(),w.add(a,c,d)}}this.trunk[a]=b.setTimeout(c,d)},clear:function(a){var c,d=function(a){b.clearTimeout(this.trunk[a]),delete this.trunk[a]};if(a&&a in this.trunk)d.call(this,a);else if("undefined"==typeof a)for(c in this.trunk)this.trunk.hasOwnProperty(c)&&d.call(this,c)}};return this},c.prototype={constructor:c,init:function(b,e){if(e=y(e),this._original={target:b,options:e,data:null},this._target=this._dom.target=b.nodeName?b:a(b).get(0),this._original.html=this._target.innerHTML,F.push(this),!this._target)return void c.raise("Target not found",!0);if(this._options={autoplay:!1,carousel:!0,carouselFollow:!0,carouselSpeed:400,carouselSteps:"auto",clicknext:!1,dailymotion:{foreground:"%23EEEEEE",highlight:"%235BCEC5",background:"%23222222",logo:0,hideInfos:1},dataConfig:function(a){return{}},dataSelector:"img",dataSort:!1,dataSource:this._target,debug:d,dummy:d,easing:"galleria",extend:function(a){},fullscreenCrop:d,fullscreenDoubleTap:!0,fullscreenTransition:d,height:0,idleMode:!0,idleTime:3e3,idleSpeed:200,imageCrop:!1,imageMargin:0,imagePan:!1,imagePanSmoothness:12,imagePosition:"50%",imageTimeout:d,initialTransition:d,keepSource:!1,layerFollow:!0,lightbox:!1,lightboxFadeSpeed:200,lightboxTransitionSpeed:200,linkSourceImages:!0,maxScaleRatio:d,maxVideoSize:d,minScaleRatio:d,overlayOpacity:.85,overlayBackground:"#0b0b0b",pauseOnInteraction:!0,popupLinks:!1,preload:2,queue:!0,responsive:!0,show:0,showInfo:!0,showCounter:!0,showImagenav:!0,swipe:"auto",theme:null,thumbCrop:!0,thumbEventType:"click:fast",thumbMargin:0,thumbQuality:"auto",thumbDisplayOrder:!0,thumbPosition:"50%",thumbnails:!0,touchTransition:d,transition:"fade",transitionInitial:d,transitionSpeed:400,trueFullscreen:!0,useCanvas:!1,variation:"",videoPoster:!0,vimeo:{title:0,byline:0,portrait:0,color:"aaaaaa"},wait:5e3,
     12width:"auto",youtube:{modestbranding:1,autohide:1,color:"white",hd:1,rel:0,showinfo:0}},this._options.initialTransition=this._options.initialTransition||this._options.transitionInitial,e&&(e.debug===!1&&(j=!1),"number"==typeof e.imageTimeout&&(k=e.imageTimeout),"string"==typeof e.dummy&&(l=e.dummy),"string"==typeof e.theme&&(this._options.theme=e.theme)),a(this._target).children().hide(),c.QUIRK&&c.raise("Your page is in Quirks mode, Galleria may not render correctly. Please validate your HTML and add a correct doctype."),J.length)if(this._options.theme){for(var f=0;f<J.length;f++)if(this._options.theme===J[f].name){this.theme=J[f];break}}else this.theme=J[0];return"object"==typeof this.theme?this._init():I.push(this),this},_init:function(){var f=this,h=this._options;if(this._initialized)return c.raise("Init failed: Gallery instance already initialized."),this;if(this._initialized=!0,!this.theme)return c.raise("Init failed: No theme found.",!0),this;if(a.extend(!0,h,this.theme.defaults,this._original.options,c.configure.options),h.swipe=function(a){return"enforced"==a||a!==!1&&"disabled"!=a&&!!c.TOUCH}(h.swipe),h.swipe&&(h.clicknext=!1,h.imagePan=!1),function(a){return"getContext"in a?void(H=H||{elem:a,context:a.getContext("2d"),cache:{},length:0}):void(a=null)}(e.createElement("canvas")),this.bind(c.DATA,function(){b.screen&&b.screen.width&&Array.prototype.forEach&&this._data.forEach(function(a){var c="devicePixelRatio"in b?b.devicePixelRatio:1,d=p.max(b.screen.width,b.screen.height);d*c<1024&&(a.big=a.image)}),this._original.data=this._data,this.get("total").innerHTML=this.getDataLength();var a=this.$("container");f._options.height<2&&(f._userRatio=f._ratio=f._options.height);var d={width:0,height:0},e=function(){return f.$("stage").height()};L.wait({until:function(){return d=f._getWH(),a.width(d.width).height(d.height),e()&&d.width&&d.height>50},success:function(){f._width=d.width,f._height=d.height,f._ratio=f._ratio||d.height/d.width,c.WEBKIT?b.setTimeout(function(){f._run()},1):f._run()},error:function(){e()?c.raise("Could not extract sufficient width/height of the gallery container. Traced measures: width:"+d.width+"px, height: "+d.height+"px.",!0):c.raise("Could not extract a stage height from the CSS. Traced height: "+e()+"px.",!0)},timeout:"number"==typeof this._options.wait&&this._options.wait})}),this.append({"info-text":["info-title","info-description"],info:["info-text"],"image-nav":["image-nav-right","image-nav-left"],stage:["images","loader","counter","image-nav"],"thumbnails-list":["thumbnails"],"thumbnails-container":["thumb-nav-left","thumbnails-list","thumb-nav-right"],container:["stage","thumbnails-container","info","tooltip"]}),L.hide(this.$("counter").append(this.get("current"),e.createTextNode(" / "),this.get("total"))),this.setCounter("&#8211;"),L.hide(f.get("tooltip")),this.$("container").addClass([c.TOUCH?"touch":"notouch",this._options.variation,"galleria-theme-"+this.theme.name].join(" ")),this._options.swipe||a.each(new Array(2),function(b){var d=new c.Picture;a(d.container).css({position:"absolute",top:0,left:0}).prepend(f._layers[b]=a(L.create("galleria-layer")).css({position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:2})[0]),f.$("images").append(d.container),f._controls[b]=d;var e=new c.Picture;e.isIframe=!0,a(e.container).attr("class","galleria-frame").css({position:"absolute",top:0,left:0,zIndex:4,background:"#000",display:"none"}).appendTo(d.container),f._controls.frames[b]=e}),this.$("images").css({position:"relative",top:0,left:0,width:"100%",height:"100%"}),h.swipe&&(this.$("images").css({position:"absolute",top:0,left:0,width:0,height:"100%"}),this.finger=new c.Finger(this.get("stage"),{onchange:function(a){f.pause().show(a)},oncomplete:function(b){var c=p.max(0,p.min(parseInt(b,10),f.getDataLength()-1)),d=f.getData(c);a(f._thumbnails[c].container).addClass("active").siblings(".active").removeClass("active"),d&&(f.$("images").find(".galleria-frame").css("opacity",0).hide().find("iframe").remove(),f._options.carousel&&f._options.carouselFollow&&f._carousel.follow(c))}}),this.bind(c.RESCALE,function(){this.finger.setup()}),this.$("stage").on("click",function(c){var e=f.getData();if(e){if(e.iframe){f.isPlaying()&&f.pause();var g=f._controls.frames[f._active],h=f._stageWidth,i=f._stageHeight;if(a(g.container).find("iframe").length)return;return a(g.container).css({width:h,height:i,opacity:0}).show().animate({opacity:1},200),void b.setTimeout(function(){g.load(e.iframe+(e.video?"&autoplay=1":""),{width:h,height:i},function(a){f.$("container").addClass("videoplay"),a.scale({width:f._stageWidth,height:f._stageHeight,iframelimit:e.video?f._options.maxVideoSize:d})})},100)}if(e.link)if(f._options.popupLinks){b.open(e.link,"_blank")}else b.location.href=e.link;else;}}),this.bind(c.IMAGE,function(b){f.setCounter(b.index),f.setInfo(b.index);var c=this.getNext(),d=this.getPrev(),e=[d,c];e.push(this.getNext(c),this.getPrev(d),f._controls.slides.length-1);var g=[];a.each(e,function(b,c){a.inArray(c,g)==-1&&g.push(c)}),a.each(g,function(b,c){var d=f.getData(c),e=f._controls.slides[c],g=f.isFullscreen()&&d.big?d.big:d.image||d.iframe;d.iframe&&!d.image&&(e.isIframe=!0),e.ready||f._controls.slides[c].load(g,function(b){b.isIframe||a(b.image).css("visibility","hidden"),f._scaleImage(b,{complete:function(b){b.isIframe||a(b.image).css({opacity:0,visibility:"visible"}).animate({opacity:1},200)}})})})})),this.$("thumbnails, thumbnails-list").css({overflow:"hidden",position:"relative"}),this.$("image-nav-right, image-nav-left").on("click:fast",function(a){h.pauseOnInteraction&&f.pause();var b=/right/.test(this.className)?"next":"prev";f[b]()}).on("click",function(a){a.preventDefault(),(h.clicknext||h.swipe)&&a.stopPropagation()}),a.each(["info","counter","image-nav"],function(a,b){h["show"+b.substr(0,1).toUpperCase()+b.substr(1).replace(/-/,"")]===!1&&L.moveOut(f.get(b.toLowerCase()))}),this.load(),h.keepSource||t||(this._target.innerHTML=""),this.get("errors")&&this.appendChild("target","errors"),this.appendChild("target","container"),h.carousel){var i=0,j=h.show;this.bind(c.THUMBNAIL,function(){this.updateCarousel(),++i==this.getDataLength()&&"number"==typeof j&&j>0&&this._carousel.follow(j)})}return h.responsive&&g.on("resize",function(){f.isFullscreen()||f.resize()}),h.fullscreenDoubleTap&&this.$("stage").on("touchstart",function(){var a,b,c,d,e,g,h=function(a){return a.originalEvent.touches?a.originalEvent.touches[0]:a};return f.$("stage").on("touchmove",function(){a=0}),function(i){if(!/(-left|-right)/.test(i.target.className)){if(g=L.timestamp(),b=h(i).pageX,c=h(i).pageY,i.originalEvent.touches.length<2&&g-a<300&&b-d<20&&c-e<20)return f.toggleFullscreen(),void i.preventDefault();a=g,d=b,e=c}}}()),a.each(c.on.binds,function(b,c){a.inArray(c.hash,f._binds)==-1&&f.bind(c.type,c.callback)}),this},addTimer:function(){return this._timer.add.apply(this._timer,L.array(arguments)),this},clearTimer:function(){return this._timer.clear.apply(this._timer,L.array(arguments)),this},_getWH:function(){var b,c=this.$("container"),d=this.$("target"),e=this,f={};return a.each(["width","height"],function(a,g){e._options[g]&&"number"==typeof e._options[g]?f[g]=e._options[g]:(b=[L.parseValue(c.css(g)),L.parseValue(d.css(g)),c[g](),d[g]()],e["_"+g]||b.splice(b.length,L.parseValue(c.css("min-"+g)),L.parseValue(d.css("min-"+g))),f[g]=p.max.apply(p,b))}),e._userRatio&&(f.height=f.width*e._userRatio),f},_createThumbnails:function(d){this.get("total").innerHTML=this.getDataLength();var f,g,h,i,j=this,k=this._options,l=d?this._data.length-d.length:0,m=l,n=[],o=0,p=t<8?"http://upload.wikimedia.org/wikipedia/commons/c/c0/Blank.gif":"data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D",q=function(){var a=j.$("thumbnails").find(".active");return!!a.length&&a.find("img").attr("src")}(),r="string"==typeof k.thumbnails?k.thumbnails.toLowerCase():null,s=function(a){return e.defaultView&&e.defaultView.getComputedStyle?e.defaultView.getComputedStyle(g.container,null)[a]:i.css(a)},u=function(b,d,e){return function(){a(e).append(b),j.trigger({type:c.THUMBNAIL,thumbTarget:b,index:d,galleriaData:j.getData(d)})}},v=function(b){k.pauseOnInteraction&&j.pause();var c=a(b.currentTarget).data("index");j.getIndex()!==c&&j.show(c),b.preventDefault()},w=function(b,d){a(b.container).css("visibility","visible"),j.trigger({type:c.THUMBNAIL,thumbTarget:b.image,index:b.data.order,galleriaData:j.getData(b.data.order)}),"function"==typeof d&&d.call(j,b)},x=function(b,c){b.scale({width:b.data.width,height:b.data.height,crop:k.thumbCrop,margin:k.thumbMargin,canvas:k.useCanvas,position:k.thumbPosition,complete:function(b){var d,e,f=["left","top"],g=["Width","Height"];j.getData(b.index);a.each(g,function(c,g){d=g.toLowerCase(),k.thumbCrop===!0&&k.thumbCrop!==d||(e={},e[d]=b[d],a(b.container).css(e),e={},e[f[c]]=0,a(b.image).css(e)),b["outer"+g]=a(b.container)["outer"+g](!0)}),L.toggleQuality(b.image,k.thumbQuality===!0||"auto"===k.thumbQuality&&b.original.width<3*b.width),k.thumbDisplayOrder&&!b.lazy?a.each(n,function(a,b){if(a===o&&b.ready&&!b.displayed)return o++,b.displayed=!0,void w(b,c)}):w(b,c)}})};for(d||(this._thumbnails=[],this.$("thumbnails").empty());this._data[l];l++)h=this._data[l],f=h.thumb||h.image,k.thumbnails!==!0&&"lazy"!=r||!h.thumb&&!h.image?h.iframe&&null!==r||"empty"===r||"numbers"===r?(g={container:L.create("galleria-image"),image:L.create("img","span"),ready:!0,data:{order:l}},"numbers"===r&&a(g.image).text(l+1),h.iframe&&a(g.image).addClass("iframe"),this.$("thumbnails").append(g.container),b.setTimeout(u(g.image,l,g.container),50+20*l)):g={container:null,image:null}:(g=new c.Picture(l),g.index=l,g.displayed=!1,g.lazy=!1,g.video=!1,this.$("thumbnails").append(g.container),i=a(g.container),i.css("visibility","hidden"),g.data={width:L.parseValue(s("width")),height:L.parseValue(s("height")),order:l,src:f},k.thumbCrop!==!0?i.css({width:"auto",height:"auto"}):i.css({width:g.data.width,height:g.data.height}),"lazy"==r?(i.addClass("lazy"),g.lazy=!0,g.load(p,{height:g.data.height,width:g.data.width})):g.load(f,x),"all"===k.preload&&g.preload(h.image)),a(g.container).add(k.keepSource&&k.linkSourceImages?h.original:null).data("index",l).on(k.thumbEventType,v).data("thumbload",x),q===f&&a(g.container).addClass("active"),this._thumbnails.push(g);return n=this._thumbnails.slice(m),this},lazyLoad:function(b,c){var d=b.constructor==Array?b:[b],e=this,f=0;return a.each(d,function(b,g){if(!(g>e._thumbnails.length-1)){var h=e._thumbnails[g],i=h.data,j=function(){++f==d.length&&"function"==typeof c&&c.call(e)},k=a(h.container).data("thumbload");k&&(h.video?k.call(e,h,j):h.load(i.src,function(a){k.call(e,a,j)}))}}),this},lazyLoadChunks:function(a,c){var d=this.getDataLength(),e=0,f=0,g=[],h=[],i=this;for(c=c||0;e<d;e++)h.push(e),++f!=a&&e!=d-1||(g.push(h),f=0,h=[]);var j=function(a){var d=g.shift();d&&b.setTimeout(function(){i.lazyLoad(d,function(){j(!0)})},c&&a?c:0)};return j(!1),this},_run:function(){var e=this;e._createThumbnails(),L.wait({timeout:1e4,until:function(){return c.OPERA&&e.$("stage").css("display","inline-block"),e._stageWidth=e.$("stage").width(),e._stageHeight=e.$("stage").height(),e._stageWidth&&e._stageHeight>50},success:function(){if(E.push(e),e._options.swipe){var f=e.$("images").width(e.getDataLength()*e._stageWidth);a.each(new Array(e.getDataLength()),function(b){var d=new c.Picture,g=e.getData(b);a(d.container).css({position:"absolute",top:0,left:e._stageWidth*b}).prepend(e._layers[b]=a(L.create("galleria-layer")).css({position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:2})[0]).appendTo(f),g.video&&M(d.container),e._controls.slides.push(d);var h=new c.Picture;h.isIframe=!0,a(h.container).attr("class","galleria-frame").css({position:"absolute",top:0,left:0,zIndex:4,background:"#000",display:"none"}).appendTo(d.container),e._controls.frames.push(h)}),e.finger.setup()}return L.show(e.get("counter")),e._options.carousel&&e._carousel.bindControls(),e._options.autoplay&&(e.pause(),"number"==typeof e._options.autoplay&&(e._playtime=e._options.autoplay),e._playing=!0),e._firstrun?(e._options.autoplay&&e.trigger(c.PLAY),void("number"==typeof e._options.show&&e.show(e._options.show))):(e._firstrun=!0,c.History&&c.History.change(function(a){isNaN(a)?b.history.go(-1):e.show(a,d,!0)}),e.trigger(c.READY),e.theme.init.call(e,e._options),a.each(c.ready.callbacks,function(a,b){"function"==typeof b&&b.call(e,e._options)}),e._options.extend.call(e,e._options),/^[0-9]{1,4}$/.test(n)&&c.History?e.show(n,d,!0):e._data[e._options.show]&&e.show(e._options.show),void(e._options.autoplay&&e.trigger(c.PLAY)))},error:function(){c.raise("Stage width or height is too small to show the gallery. Traced measures: width:"+e._stageWidth+"px, height: "+e._stageHeight+"px.",!0)}})},load:function(b,d,e){var f=this,g=this._options;return this._data=[],this._thumbnails=[],this.$("thumbnails").empty(),"function"==typeof d&&(e=d,d=null),b=b||g.dataSource,d=d||g.dataSelector,e=e||g.dataConfig,a.isPlainObject(b)&&(b=[b]),a.isArray(b)?this.validate(b)?this._data=b:c.raise("Load failed: JSON Array not valid."):(d+=",.video,.iframe",a(b).find(d).each(function(b,c){c=a(c);var d={},g=c.parent(),h=g.attr("href"),i=g.attr("rel");h&&("IMG"==c[0].nodeName||c.hasClass("video"))&&C(h)?d.video=h:h&&c.hasClass("iframe")?d.iframe=h:d.image=d.big=h,i&&(d.big=i),a.each("big title description link layer image".split(" "),function(a,b){c.data(b)&&(d[b]=c.data(b).toString())}),d.big||(d.big=d.image),f._data.push(a.extend({title:c.attr("title")||"",thumb:c.attr("src"),image:c.attr("src"),big:c.attr("src"),description:c.attr("alt")||"",link:c.attr("longdesc"),original:c.get(0)},d,e(c)))})),"function"==typeof g.dataSort?h.sort.call(this._data,g.dataSort):"random"==g.dataSort&&this._data.sort(function(){return p.round(p.random())-.5}),this.getDataLength()&&this._parseData(function(){this.trigger(c.DATA)}),this},_parseData:function(b){var c,e=this,f=!1,g=function(){var c=!0;a.each(e._data,function(a,b){if(b.loading)return c=!1,!1}),c&&!f&&(f=!0,b.call(e))};return a.each(this._data,function(b,f){if(c=e._data[b],"thumb"in f==!1&&(c.thumb=f.image),f.big||(c.big=f.image),"video"in f){var h=C(f.video);h&&(c.iframe=new B(h.provider,h.id).embed()+function(){if("object"==typeof e._options[h.provider]){var b="?",c=[];return a.each(e._options[h.provider],function(a,b){c.push(a+"="+b)}),"youtube"==h.provider&&(c=["wmode=opaque"].concat(c)),b+c.join("&")}return""}(),c.thumb&&c.image||a.each(["thumb","image"],function(a,b){if("image"==b&&!e._options.videoPoster)return void(c.image=d);var f=new B(h.provider,h.id);c[b]||(c.loading=!0,f.getMedia(b,function(a,b){return function(c){a[b]=c,"image"!=b||a.big||(a.big=a.image),delete a.loading,g()}}(c,b)))}))}}),g(),this},destroy:function(){return this.$("target").data("galleria",null),this.$("container").off("galleria"),this.get("target").innerHTML=this._original.html,this.clearTimer(),L.removeFromArray(F,this),L.removeFromArray(E,this),void 0!==c._waiters&&c._waiters.length&&a.each(c._waiters,function(a,c){c&&b.clearTimeout(c)}),this},splice:function(){var a=this,c=L.array(arguments);return b.setTimeout(function(){h.splice.apply(a._data,c),a._parseData(function(){a._createThumbnails()})},2),a},push:function(){var a=this,c=L.array(arguments);return 1==c.length&&c[0].constructor==Array&&(c=c[0]),b.setTimeout(function(){h.push.apply(a._data,c),a._parseData(function(){a._createThumbnails(c)})},2),a},_getActive:function(){return this._controls.getActive()},validate:function(a){return!0},bind:function(a,b){return a=z(a),this.$("container").on(a,this.proxy(b)),this},unbind:function(a){return a=z(a),this.$("container").off(a),this},trigger:function(b){return b="object"==typeof b?a.extend(b,{scope:this}):{type:z(b),scope:this},this.$("container").trigger(b),this},addIdleState:function(a,b,c,d){return this._idle.add.apply(this._idle,L.array(arguments)),this},removeIdleState:function(a){return this._idle.remove.apply(this._idle,L.array(arguments)),this},enterIdleMode:function(){return this._idle.hide(),this},exitIdleMode:function(){return this._idle.showAll(),this},enterFullscreen:function(a){return this._fullscreen.enter.apply(this,L.array(arguments)),this},exitFullscreen:function(a){return this._fullscreen.exit.apply(this,L.array(arguments)),this},toggleFullscreen:function(a){return this._fullscreen[this.isFullscreen()?"exit":"enter"].apply(this,L.array(arguments)),this},bindTooltip:function(a,b){return this._tooltip.bind.apply(this._tooltip,L.array(arguments)),this},defineTooltip:function(a,b){return this._tooltip.define.apply(this._tooltip,L.array(arguments)),this},refreshTooltip:function(a){return this._tooltip.show.apply(this._tooltip,L.array(arguments)),this},openLightbox:function(){return this._lightbox.show.apply(this._lightbox,L.array(arguments)),this},closeLightbox:function(){return this._lightbox.hide.apply(this._lightbox,L.array(arguments)),this},hasVariation:function(b){return a.inArray(b,this._options.variation.split(/\s+/))>-1},getActiveImage:function(){var a=this._getActive();return a?a.image:d},getActiveThumb:function(){return this._thumbnails[this._active].image||d},getMousePosition:function(a){return{x:a.pageX-this.$("container").offset().left,y:a.pageY-this.$("container").offset().top}},addPan:function(b){if(this._options.imageCrop!==!1){b=a(b||this.getActiveImage());var c=this,d=b.width()/2,e=b.height()/2,f=parseInt(b.css("left"),10),g=parseInt(b.css("top"),10),h=f||0,i=g||0,j=0,k=0,l=!1,m=L.timestamp(),n=0,o=0,q=function(a,c,d){if(a>0&&(o=p.round(p.max(a*-1,p.min(0,c))),n!==o))if(n=o,8===t)b.parent()["scroll"+d](o*-1);else{var e={};e[d.toLowerCase()]=o,b.css(e)}},r=function(a){L.timestamp()-m<50||(l=!0,d=c.getMousePosition(a).x,e=c.getMousePosition(a).y)},s=function(a){l&&(j=b.width()-c._stageWidth,k=b.height()-c._stageHeight,f=d/c._stageWidth*j*-1,g=e/c._stageHeight*k*-1,h+=(f-h)/c._options.imagePanSmoothness,i+=(g-i)/c._options.imagePanSmoothness,q(k,i,"Top"),q(j,h,"Left"))};return 8===t&&(b.parent().scrollTop(i*-1).scrollLeft(h*-1),b.css({top:0,left:0})),this.$("stage").off("mousemove",r).on("mousemove",r),this.addTimer("pan"+c._id,s,50,!0),this}},proxy:function(a,b){return"function"!=typeof a?q:(b=b||this,function(){return a.apply(b,L.array(arguments))})},getThemeName:function(){return this.theme.name},removePan:function(){return this.$("stage").off("mousemove"),this.clearTimer("pan"+this._id),this},addElement:function(b){var c=this._dom;return a.each(L.array(arguments),function(a,b){c[b]=L.create("galleria-"+b)}),this},attachKeyboard:function(a){return this._keyboard.attach.apply(this._keyboard,L.array(arguments)),this},detachKeyboard:function(){return this._keyboard.detach.apply(this._keyboard,L.array(arguments)),this},appendChild:function(a,b){return this.$(a).append(this.get(b)||b),this},prependChild:function(a,b){return this.$(a).prepend(this.get(b)||b),this},remove:function(a){return this.$(L.array(arguments).join(",")).remove(),this},append:function(a){var b,c;for(b in a)if(a.hasOwnProperty(b))if(a[b].constructor===Array)for(c=0;a[b][c];c++)this.appendChild(b,a[b][c]);else this.appendChild(b,a[b]);return this},_scaleImage:function(b,c){if(b=b||this._controls.getActive()){var d,e=function(b){a(b.container).children(":first").css({top:p.max(0,L.parseValue(b.image.style.top)),left:p.max(0,L.parseValue(b.image.style.left)),width:L.parseValue(b.image.width),height:L.parseValue(b.image.height)})};return c=a.extend({width:this._stageWidth,height:this._stageHeight,crop:this._options.imageCrop,max:this._options.maxScaleRatio,min:this._options.minScaleRatio,margin:this._options.imageMargin,position:this._options.imagePosition,iframelimit:this._options.maxVideoSize},c),this._options.layerFollow&&this._options.imageCrop!==!0?"function"==typeof c.complete?(d=c.complete,c.complete=function(){d.call(b,b),e(b)}):c.complete=e:a(b.container).children(":first").css({top:0,left:0}),b.scale(c),this}},updateCarousel:function(){return this._carousel.update(),this},resize:function(b,c){"function"==typeof b&&(c=b,b=d),b=a.extend({width:0,height:0},b);var e=this,f=this.$("container");return a.each(b,function(a,c){c||(f[a]("auto"),b[a]=e._getWH()[a])}),a.each(b,function(a,b){f[a](b)}),this.rescale(c)},rescale:function(b,e,f){var g=this;"function"==typeof b&&(f=b,b=d);var h=function(){g._stageWidth=b||g.$("stage").width(),g._stageHeight=e||g.$("stage").height(),g._options.swipe?(a.each(g._controls.slides,function(b,c){g._scaleImage(c),a(c.container).css("left",g._stageWidth*b)}),g.$("images").css("width",g._stageWidth*g.getDataLength())):g._scaleImage(),g._options.carousel&&g.updateCarousel();var d=g._controls.frames[g._controls.active];d&&g._controls.frames[g._controls.active].scale({width:g._stageWidth,height:g._stageHeight,iframelimit:g._options.maxVideoSize}),g.trigger(c.RESCALE),"function"==typeof f&&f.call(g)};return h.call(g),this},refreshImage:function(){return this._scaleImage(),this._options.imagePan&&this.addPan(),this},_preload:function(){if(this._options.preload){var a,b,d,e=this.getNext();try{for(b=this._options.preload;b>0;b--)a=new c.Picture,d=this.getData(e),a.preload(this.isFullscreen()&&d.big?d.big:d.image),e=this.getNext(e)}catch(a){}}},show:function(d,e,f){var g=this._options.swipe;if(g||!(this._queue.length>3||d===!1||!this._options.queue&&this._queue.stalled)){if(d=p.max(0,p.min(parseInt(d,10),this.getDataLength()-1)),e="undefined"!=typeof e?!!e:d<this.getIndex(),f=f||!1,!f&&c.History)return void c.History.set(d.toString());if(this.finger&&d!==this._active&&(this.finger.to=-(d*this.finger.width),this.finger.index=d),this._active=d,g){var i=this.getData(d),j=this;if(!i)return;var k=this.isFullscreen()&&i.big?i.big:i.image||i.iframe,l=this._controls.slides[d],m=l.isCached(k),n=this._thumbnails[d],o={cached:m,index:d,rewind:e,imageTarget:l.image,thumbTarget:n.image,galleriaData:i};this.trigger(a.extend(o,{type:c.LOADSTART})),j.$("container").removeClass("videoplay");var q=function(){j._layers[d].innerHTML=j.getData().layer||"",j.trigger(a.extend(o,{type:c.LOADFINISH})),j._playCheck()};j._preload(),b.setTimeout(function(){l.ready&&a(l.image).attr("src")==k?(j.trigger(a.extend(o,{type:c.IMAGE})),q()):(i.iframe&&!i.image&&(l.isIframe=!0),l.load(k,function(b){o.imageTarget=b.image,j._scaleImage(b,q).trigger(a.extend(o,{type:c.IMAGE})),q()}))},100)}else h.push.call(this._queue,{index:d,rewind:e}),this._queue.stalled||this._show();return this}},_show:function(){var e=this,f=this._queue[0],g=this.getData(f.index);if(g){var i=this.isFullscreen()&&g.big?g.big:g.image||g.iframe,j=this._controls.getActive(),k=this._controls.getNext(),l=k.isCached(i),m=this._thumbnails[f.index],n=function(){a(k.image).trigger("mouseup")};e.$("container").toggleClass("iframe",!!g.isIframe).removeClass("videoplay");var o=function(f,g,i,j,k){return function(){var l;N.active=!1,L.toggleQuality(g.image,e._options.imageQuality),e._layers[e._controls.active].innerHTML="",a(i.container).css({zIndex:0,opacity:0}).show(),a(i.container).find("iframe, .galleria-videoicon").remove(),a(e._controls.frames[e._controls.active].container).hide(),a(g.container).css({zIndex:1,left:0,top:0}).show(),e._controls.swap(),e._options.imagePan&&e.addPan(g.image),(f.iframe&&f.image||f.link||e._options.lightbox||e._options.clicknext)&&a(g.image).css({cursor:"pointer"}).on("mouseup",function(g){if(!("number"==typeof g.which&&g.which>1)){if(f.iframe){e.isPlaying()&&e.pause();var h=e._controls.frames[e._controls.active],i=e._stageWidth,j=e._stageHeight;return a(h.container).css({width:i,height:j,opacity:0}).show().animate({opacity:1},200),void b.setTimeout(function(){h.load(f.iframe+(f.video?"&autoplay=1":""),{width:i,height:j},function(a){e.$("container").addClass("videoplay"),a.scale({width:e._stageWidth,height:e._stageHeight,iframelimit:f.video?e._options.maxVideoSize:d})})},100)}return e._options.clicknext&&!c.TOUCH?(e._options.pauseOnInteraction&&e.pause(),void e.next()):f.link?void(e._options.popupLinks?l=b.open(f.link,"_blank"):b.location.href=f.link):void(e._options.lightbox&&e.openLightbox())}}),e._playCheck(),e.trigger({type:c.IMAGE,index:j.index,imageTarget:g.image,thumbTarget:k.image,galleriaData:f}),h.shift.call(e._queue),e._queue.stalled=!1,e._queue.length&&e._show()}}(g,k,j,f,m);this._options.carousel&&this._options.carouselFollow&&this._carousel.follow(f.index),e._preload(),L.show(k.container),k.isIframe=g.iframe&&!g.image,a(e._thumbnails[f.index].container).addClass("active").siblings(".active").removeClass("active"),e.trigger({type:c.LOADSTART,cached:l,index:f.index,rewind:f.rewind,imageTarget:k.image,thumbTarget:m.image,galleriaData:g}),e._queue.stalled=!0,k.load(i,function(b){var h=a(e._layers[1-e._controls.active]).html(g.layer||"").hide();e._scaleImage(b,{complete:function(b){"image"in j&&L.toggleQuality(j.image,!1),L.toggleQuality(b.image,!1),e.removePan(),e.setInfo(f.index),e.setCounter(f.index),g.layer&&(h.show(),(g.iframe&&g.image||g.link||e._options.lightbox||e._options.clicknext)&&h.css("cursor","pointer").off("mouseup").mouseup(n)),g.video&&g.image&&M(b.container);var i=e._options.transition;if(a.each({initial:null===j.image,touch:c.TOUCH,fullscreen:e.isFullscreen()},function(a,b){if(b&&e._options[a+"Transition"]!==d)return i=e._options[a+"Transition"],!1}),i in N.effects==!1)o();else{var k={prev:j.container,next:b.container,rewind:f.rewind,speed:e._options.transitionSpeed||400};N.active=!0,N.init.call(e,i,k,o)}e.trigger({type:c.LOADFINISH,cached:l,index:f.index,rewind:f.rewind,imageTarget:b.image,thumbTarget:e._thumbnails[f.index].image,galleriaData:e.getData(f.index)})}})})}},getNext:function(a){return a="number"==typeof a?a:this.getIndex(),a===this.getDataLength()-1?0:a+1},getPrev:function(a){return a="number"==typeof a?a:this.getIndex(),0===a?this.getDataLength()-1:a-1},next:function(){return this.getDataLength()>1&&this.show(this.getNext(),!1),this},prev:function(){return this.getDataLength()>1&&this.show(this.getPrev(),!0),this},get:function(a){return a in this._dom?this._dom[a]:null},getData:function(a){return a in this._data?this._data[a]:this._data[this._active]},getDataLength:function(){return this._data.length},getIndex:function(){return"number"==typeof this._active&&this._active},getStageHeight:function(){return this._stageHeight},getStageWidth:function(){return this._stageWidth},getOptions:function(a){return"undefined"==typeof a?this._options:this._options[a]},setOptions:function(b,c){return"object"==typeof b?a.extend(this._options,b):this._options[b]=c,this},play:function(a){return this._playing=!0,this._playtime=a||this._playtime,this._playCheck(),this.trigger(c.PLAY),this},pause:function(){return this._playing=!1,this.trigger(c.PAUSE),this},playToggle:function(a){return this._playing?this.pause():this.play(a)},isPlaying:function(){return this._playing},isFullscreen:function(){return this._fullscreen.active},_playCheck:function(){var a=this,b=0,d=20,e=L.timestamp(),f="play"+this._id;if(this._playing){this.clearTimer(f);var g=function(){return b=L.timestamp()-e,b>=a._playtime&&a._playing?(a.clearTimer(f),void a.next()):void(a._playing&&(a.trigger({type:c.PROGRESS,percent:p.ceil(b/a._playtime*100),seconds:p.floor(b/1e3),milliseconds:b}),a.addTimer(f,g,d)))};a.addTimer(f,g,d)}},setPlaytime:function(a){return this._playtime=a,this},setIndex:function(a){return this._active=a,this},setCounter:function(a){if("number"==typeof a?a++:"undefined"==typeof a&&(a=this.getIndex()+1),this.get("current").innerHTML=a,t){var b=this.$("counter"),c=b.css("opacity");1===parseInt(c,10)?L.removeAlpha(b[0]):this.$("counter").css("opacity",c)}return this},setInfo:function(b){var c=this,d=this.getData(b);return a.each(["title","description"],function(a,b){var e=c.$("info-"+b);d[b]?e[d[b].length?"show":"hide"]().html(d[b]):e.empty().hide()}),this},hasInfo:function(a){var b,c="title description".split(" ");for(b=0;c[b];b++)if(this.getData(a)[c[b]])return!0;return!1},jQuery:function(b){var c=this,d=[];a.each(b.split(","),function(b,e){e=a.trim(e),c.get(e)&&d.push(e)});var e=a(c.get(d.shift()));return a.each(d,function(a,b){e=e.add(c.get(b))}),e},$:function(a){return this.jQuery.apply(this,L.array(arguments))}},a.each(x,function(a,b){var d=/_/.test(b)?b.replace(/_/g,""):b;c[b.toUpperCase()]="galleria."+d}),a.extend(c,{IE9:9===t,IE8:8===t,IE7:7===t,IE6:6===t,IE:t,WEBKIT:/webkit/.test(m),CHROME:/chrome/.test(m),SAFARI:/safari/.test(m)&&!/chrome/.test(m),QUIRK:t&&e.compatMode&&"BackCompat"===e.compatMode,MAC:/mac/.test(navigator.platform.toLowerCase()),OPERA:!!b.opera,IPHONE:/iphone/.test(m),IPAD:/ipad/.test(m),ANDROID:/android/.test(m),TOUCH:"ontouchstart"in e&&s}),c.addTheme=function(d){d.name||c.raise("No theme name specified"),(!d.version||parseInt(10*c.version)>parseInt(10*d.version))&&c.raise("This version of Galleria requires "+d.name+" theme version "+parseInt(10*c.version)/10+" or later",!0),"object"!=typeof d.defaults?d.defaults={}:d.defaults=y(d.defaults);var e,f,g=!1;return"string"==typeof d.css?(a("link").each(function(a,b){if(e=new RegExp(d.css),e.test(b.href))return g=!0,K(d),!1}),g||a(function(){var h=0,i=function(){a("script").each(function(a,c){e=new RegExp("galleria\\."+d.name.toLowerCase()+"\\."),f=new RegExp("galleria\\.io\\/theme\\/"+d.name.toLowerCase()+"\\/(\\d*\\.*)?(\\d*\\.*)?(\\d*\\/)?js"),(e.test(c.src)||f.test(c.src))&&(g=c.src.replace(/[^\/]*$/,"")+d.css,b.setTimeout(function(){L.loadCSS(g,"galleria-theme-"+d.name,function(){K(d)})},1))}),g||(h++>5?c.raise("No theme CSS loaded"):b.setTimeout(i,500))};i()})):K(d),d},c.loadTheme=function(d,e){if(!a("script").filter(function(){return a(this).attr("src")==d}).length){var f,g=!1;return a(b).on("load",function(){g||(f=b.setTimeout(function(){g||c.raise("Galleria had problems loading theme at "+d+". Please check theme path or load manually.",!0)},2e4))}),L.loadScript(d,function(){g=!0,b.clearTimeout(f)}),c}},c.get=function(a){return F[a]?F[a]:"number"!=typeof a?F:void c.raise("Gallery index "+a+" not found")},c.configure=function(b,d){var e={};return"string"==typeof b&&d?(e[b]=d,b=e):a.extend(e,b),c.configure.options=e,a.each(c.get(),function(a,b){b.setOptions(e)}),c},c.configure.options={},c.on=function(b,d){if(b){d=d||q;var e=b+d.toString().replace(/\s/g,"")+L.timestamp();return a.each(c.get(),function(a,c){c._binds.push(e),c.bind(b,d)}),c.on.binds.push({type:b,callback:d,hash:e}),c}},c.on.binds=[],c.run=function(b,d){return a.isFunction(d)&&(d={extend:d}),a(b||"#galleria").galleria(d),c},c.addTransition=function(a,b){return N.effects[a]=b,c},c.utils=L,c.log=function(){var c=L.array(arguments);if(!("console"in b&&"log"in b.console))return b.alert(c.join("<br>"));try{return b.console.log.apply(b.console,c)}catch(d){a.each(c,function(){b.console.log(this)})}},c.ready=function(b){return"function"!=typeof b?c:(a.each(E,function(a,c){b.call(c,c._options)}),c.ready.callbacks.push(b),c)},c.ready.callbacks=[],c.raise=function(b,c){var d=c?"Fatal error":"Error",e={color:"#fff",position:"absolute",top:0,left:0,zIndex:1e5},f=function(b){var f='<div style="padding:4px;margin:0 0 2px;background:#'+(c?"811":"222")+';">'+(c?"<strong>"+d+": </strong>":"")+b+"</div>";a.each(F,function(){var a=this.$("errors"),b=this.$("target");a.length||(b.css("position","relative"),a=this.addElement("errors").appendChild("target","errors").$("errors").css(e)),a.append(f)}),F.length||a("<div>").css(a.extend(e,{position:"fixed"})).append(f).appendTo(u().body)};if(j){if(f(b),c)throw new Error(d+": "+b)}else if(c){if(G)return;G=!0,c=!1,f("Gallery could not load.")}},c.version=i,c.getLoadedThemes=function(){return a.map(J,function(a){return a.name})},c.requires=function(a,b){return b=b||"You need to upgrade Galleria to version "+a+" to use one or more components.",c.version<a&&c.raise(b,!0),c},c.Picture=function(b){this.id=b||null,this.image=null,this.container=L.create("galleria-image"),a(this.container).css({overflow:"hidden",position:"relative"}),this.original={width:0,height:0
     13},this.ready=!1,this.isIframe=!1},c.Picture.prototype={cache:{},show:function(){L.show(this.image)},hide:function(){L.moveOut(this.image)},clear:function(){this.image=null},isCached:function(a){return!!this.cache[a]},preload:function(b){a(new Image).on("load",function(a,b){return function(){b[a]=a}}(b,this.cache)).attr("src",b)},load:function(d,e,f){if("function"==typeof e&&(f=e,e=null),this.isIframe){var g="if"+(new Date).getTime(),h=this.image=a("<iframe>",{src:d,frameborder:0,id:g,allowfullscreen:!0,css:{visibility:"hidden"}})[0];return e&&a(h).css(e),a(this.container).find("iframe,img").remove(),this.container.appendChild(this.image),a("#"+g).on("load",function(c,d){return function(){b.setTimeout(function(){a(c.image).css("visibility","visible"),"function"==typeof d&&d.call(c,c)},10)}}(this,f)),this.container}this.image=new Image,c.IE8&&a(this.image).css("filter","inherit"),c.IE||c.CHROME||c.SAFARI||a(this.image).css("image-rendering","optimizequality");var i=!1,j=!1,k=a(this.container),m=a(this.image),n=function(){i?l?a(this).attr("src",l):c.raise("Image not found: "+d):(i=!0,b.setTimeout(function(a,b){return function(){a.attr("src",b+(b.indexOf("?")>-1?"&":"?")+L.timestamp())}}(a(this),d),50))},o=function(d,f,g){return function(){var h=function(){a(this).off("load"),d.original=e||{height:this.height,width:this.width},c.HAS3D&&(this.style.MozTransform=this.style.webkitTransform="translate3d(0,0,0)"),k.append(this),d.cache[g]=g,"function"==typeof f&&b.setTimeout(function(){f.call(d,d)},1)};this.width&&this.height?h.call(this):!function(b){L.wait({until:function(){return b.width&&b.height},success:function(){h.call(b)},error:function(){j?c.raise("Could not extract width/height from image: "+b.src+". Traced measures: width:"+b.width+"px, height: "+b.height+"px."):(a(new Image).on("load",o).attr("src",b.src),j=!0)},timeout:100})}(this)}}(this,f,d);return k.find("iframe,img").remove(),m.css("display","block"),L.hide(this.image),a.each("minWidth minHeight maxWidth maxHeight".split(" "),function(a,b){m.css(b,/min/.test(b)?"0":"none")}),m.on("load",o).on("error",n).attr("src",d),this.container},scale:function(b){var e=this;if(b=a.extend({width:0,height:0,min:d,max:d,margin:0,complete:q,position:"center",crop:!1,canvas:!1,iframelimit:d},b),this.isIframe){var f,g,h=b.width,i=b.height;if(b.iframelimit){var j=p.min(b.iframelimit/h,b.iframelimit/i);j<1?(f=h*j,g=i*j,a(this.image).css({top:i/2-g/2,left:h/2-f/2,position:"absolute"})):a(this.image).css({top:0,left:0})}a(this.image).width(f||h).height(g||i).removeAttr("width").removeAttr("height"),a(this.container).width(h).height(i),b.complete.call(e,e);try{this.image.contentWindow&&a(this.image.contentWindow).trigger("resize")}catch(a){}return this.container}if(!this.image)return this.container;var k,l,m,n=a(e.container);return L.wait({until:function(){return k=b.width||n.width()||L.parseValue(n.css("width")),l=b.height||n.height()||L.parseValue(n.css("height")),k&&l},success:function(){var c=(k-2*b.margin)/e.original.width,d=(l-2*b.margin)/e.original.height,f=p.min(c,d),g=p.max(c,d),h={true:g,width:c,height:d,false:f,landscape:e.original.width>e.original.height?g:f,portrait:e.original.width<e.original.height?g:f},i=h[b.crop.toString()],j="";b.max&&(i=p.min(b.max,i)),b.min&&(i=p.max(b.min,i)),a.each(["width","height"],function(b,c){a(e.image)[c](e[c]=e.image[c]=p.round(e.original[c]*i))}),a(e.container).width(k).height(l),b.canvas&&H&&(H.elem.width=e.width,H.elem.height=e.height,j=e.image.src+":"+e.width+"x"+e.height,e.image.src=H.cache[j]||function(a){H.context.drawImage(e.image,0,0,e.original.width*i,e.original.height*i);try{return m=H.elem.toDataURL(),H.length+=m.length,H.cache[a]=m,m}catch(a){return e.image.src}}(j));var n={},o={},q=function(b,c,d){var f=0;if(/\%/.test(b)){var g=parseInt(b,10)/100,h=e.image[c]||a(e.image)[c]();f=p.ceil(h*-1*g+d*g)}else f=L.parseValue(b);return f},r={top:{top:0},left:{left:0},right:{left:"100%"},bottom:{top:"100%"}};a.each(b.position.toLowerCase().split(" "),function(a,b){"center"===b&&(b="50%"),n[a?"top":"left"]=b}),a.each(n,function(b,c){r.hasOwnProperty(c)&&a.extend(o,r[c])}),n=n.top?a.extend(n,o):o,n=a.extend({top:"50%",left:"50%"},n),a(e.image).css({position:"absolute",top:q(n.top,"height",l),left:q(n.left,"width",k)}),e.show(),e.ready=!0,b.complete.call(e,e)},error:function(){c.raise("Could not scale image: "+e.image.src)},timeout:1e3}),this}},a.extend(a.easing,{galleria:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b*b+c:d/2*((b-=2)*b*b+2)+c},galleriaIn:function(a,b,c,d,e){return d*(b/=e)*b+c},galleriaOut:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c}}),c.Finger=function(){var d=(p.abs,c.HAS3D=function(){var b,c,d=e.createElement("p"),f=["webkit","O","ms","Moz",""],g=0,h="transform";for(u().html.insertBefore(d,null);f[g];g++)c=f[g]?f[g]+"Transform":h,void 0!==d.style[c]&&(d.style[c]="translate3d(1px,1px,1px)",b=a(d).css(f[g]?"-"+f[g].toLowerCase()+"-"+h:h));return u().html.removeChild(d),void 0!==b&&b.length>0&&"none"!==b}()),g=function(){var a="RequestAnimationFrame";return b.requestAnimationFrame||b["webkit"+a]||b["moz"+a]||b["o"+a]||b["ms"+a]||function(a){b.setTimeout(a,1e3/60)}}(),h=function(c,e){if(this.config={start:0,duration:500,onchange:function(){},oncomplete:function(){},easing:function(a,b,c,d,e){return-d*((b=b/e-1)*b*b*b-1)+c}},this.easeout=function(a,b,c,d,e){return d*((b=b/e-1)*b*b*b*b+1)+c},c.children.length){var f=this;a.extend(this.config,e),this.elem=c,this.child=c.children[0],this.to=this.pos=0,this.touching=!1,this.start={},this.index=this.config.start,this.anim=0,this.easing=this.config.easing,d||(this.child.style.position="absolute",this.elem.style.position="relative"),a.each(["ontouchstart","ontouchmove","ontouchend","setup"],function(a,b){f[b]=function(a){return function(){a.apply(f,arguments)}}(f[b])}),this.setX=function(){var a=f.child.style;return d?void(a.MozTransform=a.webkitTransform=a.transform="translate3d("+f.pos+"px,0,0)"):void(a.left=f.pos+"px")},a(c).on("touchstart",this.ontouchstart),a(b).on("resize",this.setup),a(b).on("orientationchange",this.setup),this.setup(),function a(){g(a),f.loop.call(f)}()}};return h.prototype={constructor:h,setup:function(){this.width=a(this.elem).width(),this.length=p.ceil(a(this.child).width()/this.width),0!==this.index&&(this.index=p.max(0,p.min(this.index,this.length-1)),this.pos=this.to=-this.width*this.index)},setPosition:function(a){this.pos=a,this.to=a},ontouchstart:function(a){var b=a.originalEvent.touches;this.start={pageX:b[0].pageX,pageY:b[0].pageY,time:+new Date},this.isScrolling=null,this.touching=!0,this.deltaX=0,f.on("touchmove",this.ontouchmove),f.on("touchend",this.ontouchend)},ontouchmove:function(a){var b=a.originalEvent.touches;b&&b.length>1||a.scale&&1!==a.scale||(this.deltaX=b[0].pageX-this.start.pageX,null===this.isScrolling&&(this.isScrolling=!!(this.isScrolling||p.abs(this.deltaX)<p.abs(b[0].pageY-this.start.pageY))),this.isScrolling||(a.preventDefault(),this.deltaX/=!this.index&&this.deltaX>0||this.index==this.length-1&&this.deltaX<0?p.abs(this.deltaX)/this.width+1.8:1,this.to=this.deltaX-this.index*this.width),a.stopPropagation())},ontouchend:function(a){this.touching=!1;var b=+new Date-this.start.time<250&&p.abs(this.deltaX)>40||p.abs(this.deltaX)>this.width/2,c=!this.index&&this.deltaX>0||this.index==this.length-1&&this.deltaX<0;this.isScrolling||this.show(this.index+(b&&!c?this.deltaX<0?1:-1:0)),f.off("touchmove",this.ontouchmove),f.off("touchend",this.ontouchend)},show:function(a){a!=this.index?this.config.onchange.call(this,a):this.to=-(a*this.width)},moveTo:function(a){a!=this.index&&(this.pos=this.to=-(a*this.width),this.index=a)},loop:function(){var a=this.to-this.pos,b=1;if(this.width&&a&&(b=p.max(.5,p.min(1.5,p.abs(a/this.width)))),this.touching||p.abs(a)<=1)this.pos=this.to,a=0,this.anim&&!this.touching&&this.config.oncomplete(this.index),this.anim=0,this.easing=this.config.easing;else{this.anim||(this.anim={start:this.pos,time:+new Date,distance:a,factor:b,destination:this.to});var c=+new Date-this.anim.time,d=this.config.duration*this.anim.factor;if(c>d||this.anim.destination!=this.to)return this.anim=0,void(this.easing=this.easeout);this.pos=this.easing(null,c,this.anim.start,this.anim.distance,d)}this.setX()}},h}(),a.fn.galleria=function(b){var d=this.selector;return a(this).length?this.each(function(){a.data(this,"galleria")&&(a.data(this,"galleria").destroy(),a(this).find("*").hide()),a.data(this,"galleria",(new c).init(this,b))}):(a(function(){a(d).length?a(d).galleria(b):c.utils.wait({until:function(){return a(d).length},success:function(){a(d).galleria(b)},error:function(){c.raise('Init failed: Galleria could not find the element "'+d+'".')},timeout:5e3})}),this)},"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=c:(b.Galleria=c,"function"==typeof define&&define.amd&&define("galleria",["jquery"],function(){return c}))}(jQuery,this);
  • _plugins_/galleria/trunk/galleria/plugins/flickr/flickr-demo.html

    r72410 r106707  
    2424
    2525        <!-- load Galleria -->
    26         <script src="../../galleria-1.2.9.min.js"></script>
     26        <script src="../../galleria-1.5.7.min.js"></script>
    2727
    2828        <!-- load flickr plugin -->
     
    3939        <div id="galleria"></div>
    4040
    41         <p class="cred">Made by <a href="http://galleria.aino.se">Galleria</a>.</p>
     41        <p class="cred">Made by <a href="http://galleria.io">Galleria</a>.</p>
    4242        <a href="#" id="close">cloase</a>
    4343    </div>
    4444    <script>
     45    $(function() {
     46        // Load the classic theme
     47        Galleria.loadTheme('../../themes/classic/galleria.classic.min.js');
    4548
    46     // Load the classic theme
    47     Galleria.loadTheme('../../themes/classic/galleria.classic.min.js');
     49        // Initialize Galleria
     50        Galleria.run('#galleria', {
    4851
    49     // Initialize Galleria
    50     Galleria.run('#galleria', {
     52            // search flickr for "galleria"
     53            flickr: 'search:galleria',
    5154
    52         // search flickr for "galleria"
    53         flickr: 'search:galleria',
    54        
    55         flickrOptions: {
    56             // sort by interestingness
    57             sort: 'interestingness-desc'
    58         }
     55            flickrOptions: {
     56                // sort by interestingness
     57                sort: 'interestingness-desc'
     58            }
     59        });
    5960    });
    6061    </script>
  • _plugins_/galleria/trunk/galleria/plugins/flickr/galleria.flickr.js

    r72410 r106707  
    11/**
    2  * Galleria Flickr Plugin 2012-09-04
     2 * Galleria Flickr Plugin 2016-09-03
    33 * http://galleria.io
    44 *
     5 * Copyright (c) 2010 - 2017 worse is better UG
    56 * Licensed under the MIT license
    6  * https://raw.github.com/aino/galleria/master/LICENSE
     7 * https://raw.github.com/worseisbetter/galleria/master/LICENSE
    78 *
    89 */
     
    2425    @example var flickr = new Galleria.Flickr();
    2526
    26     @author http://aino.se
     27    @author http://galleria.io
    2728
    2829    @requires jQuery
     
    191192    _call: function( params, callback ) {
    192193
    193         var url = 'http://api.flickr.com/services/rest/?';
     194        var url = 'https://api.flickr.com/services/rest/?';
    194195
    195196        var scope = this;
     
    224225        } else if ( parseInt( photo.width_o, 10 ) > 1280 ) {
    225226
    226             return 'http://farm'+photo.farm + '.static.flickr.com/'+photo.server +
     227            return 'https://farm'+photo.farm + '.static.flickr.com/'+photo.server +
    227228                '/' + photo.id + '_' + photo.secret + '_b.jpg';
    228229        }
     
    294295                    title: photos[i].title,
    295296                    description: this.options.description && photos[i].description ? photos[i].description._content : '',
    296                     link: this.options.backlink ? 'http://flickr.com/photos/' + photo.owner + '/' + photo.id : ''
     297                    link: this.options.backlink ? 'https://flickr.com/photos/' + photo.owner + '/' + photo.id : ''
    297298                });
    298299            }
  • _plugins_/galleria/trunk/galleria/plugins/flickr/galleria.flickr.min.js

    r72410 r106707  
    1 (function($){Galleria.requires(1.25,"The Flickr Plugin requires Galleria version 1.2.5 or later.");var PATH=Galleria.utils.getScriptPath();Galleria.Flickr=function(api_key){this.api_key=api_key||"2a2ce06c15780ebeb0b706650fc890b2";this.options={max:30,imageSize:"medium",thumbSize:"thumb",sort:"interestingness-desc",description:false,complete:function(){},backlink:false}};Galleria.Flickr.prototype={constructor:Galleria.Flickr,search:function(phrase,callback){return this._find({text:phrase},callback)},tags:function(tag,callback){return this._find({tags:tag},callback)},user:function(username,callback){return this._call({method:"flickr.urls.lookupUser",url:"flickr.com/photos/"+username},function(data){this._find({user_id:data.user.id,method:"flickr.people.getPublicPhotos"},callback)})},set:function(photoset_id,callback){return this._find({photoset_id:photoset_id,method:"flickr.photosets.getPhotos"},callback)},gallery:function(gallery_id,callback){return this._find({gallery_id:gallery_id,method:"flickr.galleries.getPhotos"},callback)},groupsearch:function(group,callback){return this._call({text:group,method:"flickr.groups.search"},function(data){this.group(data.groups.group[0].nsid,callback)})},group:function(group_id,callback){return this._find({group_id:group_id,method:"flickr.groups.pools.getPhotos"},callback)},setOptions:function(options){$.extend(this.options,options);return this},_call:function(params,callback){var url="http://api.flickr.com/services/rest/?";var scope=this;params=$.extend({format:"json",jsoncallback:"?",api_key:this.api_key},params);$.each(params,function(key,value){url+="&"+key+"="+value});$.getJSON(url,function(data){if(data.stat==="ok"){callback.call(scope,data)}else{Galleria.raise(data.code.toString()+" "+data.stat+": "+data.message,true)}});return scope},_getBig:function(photo){if(photo.url_l){return photo.url_l}else if(parseInt(photo.width_o,10)>1280){return"http://farm"+photo.farm+".static.flickr.com/"+photo.server+"/"+photo.id+"_"+photo.secret+"_b.jpg"}return photo.url_o||photo.url_z||photo.url_m},_getSize:function(photo,size){var img;switch(size){case"thumb":img=photo.url_t;break;case"small":img=photo.url_s;break;case"big":img=this._getBig(photo);break;case"original":img=photo.url_o?photo.url_o:this._getBig(photo);break;default:img=photo.url_z||photo.url_m;break}return img},_find:function(params,callback){params=$.extend({method:"flickr.photos.search",extras:"url_t,url_m,url_o,url_s,url_l,url_z,description",sort:this.options.sort,per_page:Math.min(this.options.max,500)},params);return this._call(params,function(data){var gallery=[],photos=data.photos?data.photos.photo:data.photoset.photo,len=photos.length,photo,i;for(i=0;i<len;i++){photo=photos[i];gallery.push({thumb:this._getSize(photo,this.options.thumbSize),image:this._getSize(photo,this.options.imageSize),big:this._getBig(photo),title:photos[i].title,description:this.options.description&&photos[i].description?photos[i].description._content:"",link:this.options.backlink?"http://flickr.com/photos/"+photo.owner+"/"+photo.id:""})}callback.call(this,gallery)})}};var load=Galleria.prototype.load;Galleria.prototype.load=function(){if(arguments.length||typeof this._options.flickr!=="string"){load.apply(this,Galleria.utils.array(arguments));return}var self=this,args=Galleria.utils.array(arguments),flickr=this._options.flickr.split(":"),f,opts=$.extend({},self._options.flickrOptions),loader=typeof opts.loader!=="undefined"?opts.loader:$("<div>").css({width:48,height:48,opacity:.7,background:"#000 url("+PATH+"loader.gif) no-repeat 50% 50%"});if(flickr.length){if(typeof Galleria.Flickr.prototype[flickr[0]]!=="function"){Galleria.raise(flickr[0]+" method not found in Flickr plugin");return load.apply(this,args)}if(!flickr[1]){Galleria.raise("No flickr argument found");return load.apply(this,args)}window.setTimeout(function(){self.$("target").append(loader)},100);f=new Galleria.Flickr;if(typeof self._options.flickrOptions==="object"){f.setOptions(self._options.flickrOptions)}f[flickr[0]](flickr[1],function(data){self._data=data;loader.remove();self.trigger(Galleria.DATA);f.options.complete.call(f,data)})}else{load.apply(this,args)}}})(jQuery);
     1(function($){Galleria.requires(1.25,"The Flickr Plugin requires Galleria version 1.2.5 or later.");var PATH=Galleria.utils.getScriptPath();Galleria.Flickr=function(api_key){this.api_key=api_key||"2a2ce06c15780ebeb0b706650fc890b2";this.options={max:30,imageSize:"medium",thumbSize:"thumb",sort:"interestingness-desc",description:false,complete:function(){},backlink:false}};Galleria.Flickr.prototype={constructor:Galleria.Flickr,search:function(phrase,callback){return this._find({text:phrase},callback)},tags:function(tag,callback){return this._find({tags:tag},callback)},user:function(username,callback){return this._call({method:"flickr.urls.lookupUser",url:"flickr.com/photos/"+username},function(data){this._find({user_id:data.user.id,method:"flickr.people.getPublicPhotos"},callback)})},set:function(photoset_id,callback){return this._find({photoset_id:photoset_id,method:"flickr.photosets.getPhotos"},callback)},gallery:function(gallery_id,callback){return this._find({gallery_id:gallery_id,method:"flickr.galleries.getPhotos"},callback)},groupsearch:function(group,callback){return this._call({text:group,method:"flickr.groups.search"},function(data){this.group(data.groups.group[0].nsid,callback)})},group:function(group_id,callback){return this._find({group_id:group_id,method:"flickr.groups.pools.getPhotos"},callback)},setOptions:function(options){$.extend(this.options,options);return this},_call:function(params,callback){var url="https://api.flickr.com/services/rest/?";var scope=this;params=$.extend({format:"json",jsoncallback:"?",api_key:this.api_key},params);$.each(params,function(key,value){url+="&"+key+"="+value});$.getJSON(url,function(data){if(data.stat==="ok"){callback.call(scope,data)}else{Galleria.raise(data.code.toString()+" "+data.stat+": "+data.message,true)}});return scope},_getBig:function(photo){if(photo.url_l){return photo.url_l}else if(parseInt(photo.width_o,10)>1280){return"https://farm"+photo.farm+".static.flickr.com/"+photo.server+"/"+photo.id+"_"+photo.secret+"_b.jpg"}return photo.url_o||photo.url_z||photo.url_m},_getSize:function(photo,size){var img;switch(size){case"thumb":img=photo.url_t;break;case"small":img=photo.url_s;break;case"big":img=this._getBig(photo);break;case"original":img=photo.url_o?photo.url_o:this._getBig(photo);break;default:img=photo.url_z||photo.url_m;break}return img},_find:function(params,callback){params=$.extend({method:"flickr.photos.search",extras:"url_t,url_m,url_o,url_s,url_l,url_z,description",sort:this.options.sort,per_page:Math.min(this.options.max,500)},params);return this._call(params,function(data){var gallery=[],photos=data.photos?data.photos.photo:data.photoset.photo,len=photos.length,photo,i;for(i=0;i<len;i++){photo=photos[i];gallery.push({thumb:this._getSize(photo,this.options.thumbSize),image:this._getSize(photo,this.options.imageSize),big:this._getBig(photo),title:photos[i].title,description:this.options.description&&photos[i].description?photos[i].description._content:"",link:this.options.backlink?"https://flickr.com/photos/"+photo.owner+"/"+photo.id:""})}callback.call(this,gallery)})}};var load=Galleria.prototype.load;Galleria.prototype.load=function(){if(arguments.length||typeof this._options.flickr!=="string"){load.apply(this,Galleria.utils.array(arguments));return}var self=this,args=Galleria.utils.array(arguments),flickr=this._options.flickr.split(":"),f,opts=$.extend({},self._options.flickrOptions),loader=typeof opts.loader!=="undefined"?opts.loader:$("<div>").css({width:48,height:48,opacity:.7,background:"#000 url("+PATH+"loader.gif) no-repeat 50% 50%"});if(flickr.length){if(typeof Galleria.Flickr.prototype[flickr[0]]!=="function"){Galleria.raise(flickr[0]+" method not found in Flickr plugin");return load.apply(this,args)}if(!flickr[1]){Galleria.raise("No flickr argument found");return load.apply(this,args)}window.setTimeout(function(){self.$("target").append(loader)},100);f=new Galleria.Flickr;if(typeof self._options.flickrOptions==="object"){f.setOptions(self._options.flickrOptions)}f[flickr[0]](flickr[1],function(data){self._data=data;loader.remove();self.trigger(Galleria.DATA);f.options.complete.call(f,data)})}else{load.apply(this,args)}}})(jQuery);
  • _plugins_/galleria/trunk/galleria/plugins/history/galleria.history.js

    r64242 r106707  
    11/**
    2  * Galleria History Plugin 2012-04-04
     2 * Galleria History Plugin 2016-09-03
    33 * http://galleria.io
    44 *
     5 * Copyright (c) 2010 - 2017 worse is better UG
    56 * Licensed under the MIT license
    6  * https://raw.github.com/aino/galleria/master/LICENSE
     7 * https://raw.github.com/worseisbetter/galleria/master/LICENSE
    78 *
    89 */
  • _plugins_/galleria/trunk/galleria/plugins/history/history-demo.html

    r72410 r106707  
    2424
    2525        <!-- load Galleria -->
    26         <script src="../../galleria-1.2.9.min.js"></script>
     26        <script src="../../galleria-1.5.7.min.js"></script>
    2727
    2828        <!-- load the History plugin, no need for further scripting -->
     
    8585        </div>
    8686
    87         <p class="cred">Made by <a href="http://galleria.aino.se">Galleria</a>.</p>
     87        <p class="cred">Made by <a href="http://galleria.io">Galleria</a>.</p>
    8888    </div>
    8989
    9090    <script>
     91    $(function() {
     92        // Load the classic theme
     93        Galleria.loadTheme('../../themes/classic/galleria.classic.min.js');
    9194
    92     // Load the classic theme
    93     Galleria.loadTheme('../../themes/classic/galleria.classic.min.js');
    94 
    95     // Initialize Galleria
    96     Galleria.run('#galleria');
    97 
     95        // Initialize Galleria
     96        Galleria.run('#galleria');
     97    });
    9898    </script>
    9999    </body>
  • _plugins_/galleria/trunk/galleria/plugins/picasa/galleria.picasa.js

    r64242 r106707  
    11/**
    2  * Galleria Picasa Plugin 2012-04-04
     2 * Galleria Picasa Plugin 2016-09-03
    33 * http://galleria.io
    44 *
     5 * Copyright (c) 2010 - 2017 worse is better UG
    56 * Licensed under the MIT license
    6  * https://raw.github.com/aino/galleria/master/LICENSE
     7 * https://raw.github.com/worseisbetter/galleria/master/LICENSE
    78 *
    89 */
     
    2425    @example var picasa = new Galleria.Picasa();
    2526
    26     @author http://aino.se
     27    @author http://wib.io
    2728
    2829    @requires jQuery
  • _plugins_/galleria/trunk/galleria/plugins/picasa/picasa-demo.html

    r72410 r106707  
    33    <head>
    44        <meta charset="utf-8">
    5         <title>Galleria Flickr Plugin</title>
     5        <title>Galleria Picasa Plugin</title>
    66        <style>
    77
     
    2424
    2525        <!-- load Galleria -->
    26         <script src="../../galleria-1.2.9.min.js"></script>
     26        <script src="../../galleria-1.5.7.min.js"></script>
    2727
    2828        <!-- load picasa plugin -->
     
    3939        <div id="galleria"></div>
    4040
    41         <p class="cred">Made by <a href="http://galleria.aino.se">Galleria</a>.</p>
     41        <p class="cred">Made by <a href="http://galleria.io">Galleria</a>.</p>
    4242    </div>
    4343    <script>
     44    $(function() {
     45        // Load the classic theme
     46        Galleria.loadTheme('../../themes/classic/galleria.classic.min.js');
    4447
    45     // Load the classic theme
    46     Galleria.loadTheme('../../themes/classic/galleria.classic.min.js');
    47 
    48     Galleria.run('#galleria', {
    49         // The user & album. This example fetches the album "Demo" from the user "galleriajs"
    50         picasa: 'useralbum:galleriajs/Demo'
     48        Galleria.run('#galleria', {
     49            // The user & album. This example fetches the album "Demo" from the user "galleriajs"
     50            picasa: 'useralbum:galleriajs/Demo'
     51        });
    5152    });
    52 
    5353    </script>
    5454    </body>
  • _plugins_/galleria/trunk/galleria/themes/classic/classic-demo.html

    r72410 r106707  
    2121
    2222        <!-- load jQuery -->
    23         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
     23        <!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.js"></script> -->
     24        <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.js"></script>
    2425
    2526        <!-- load Galleria -->
    26         <script src="../../galleria-1.2.9.min.js"></script>
     27        <script src="../../galleria-1.5.7.min.js"></script>
    2728
    2829    </head>
     
    107108                >
    108109            </a>
     110            <a href="https://vimeo.com/25750735">
     111                <span class="video">Works for vimeo too.</span>
     112            </a>
     113            <a href="https://www.youtube.com/watch?v=GOD-RyVB-3Q">
     114                <span class="video">Works for youtube too.</span>
     115            </a>
     116
    109117        </div>
    110 
    111         <p class="cred">Made by <a href="http://galleria.aino.se">Galleria</a>.</p>
     118        <p class="cred">Made by <a href="http://galleria.io">Galleria</a>.</p>
    112119    </div>
    113120
    114121    <script>
     122    $(function() {
     123        // Load the classic theme
     124        Galleria.loadTheme('galleria.classic.min.js');
    115125
    116     // Load the classic theme
    117     Galleria.loadTheme('galleria.classic.min.js');
    118 
    119     // Initialize Galleria
    120     Galleria.run('#galleria');
    121 
     126        // Initialize Galleria
     127        Galleria.run('#galleria');
     128    });
    122129    </script>
    123130    </body>
  • _plugins_/galleria/trunk/galleria/themes/classic/galleria.classic.css

    r72410 r106707  
    1 /* Galleria Classic Theme 2012-08-07 | https://raw.github.com/aino/galleria/master/LICENSE | (c) Aino */
     1/**
     2 * Galleria Classic Theme 2017-02-13
     3 * http://galleria.io
     4 *
     5 * Copyright (c) 2010 - 2017 worse is better UG
     6 * Licensed under the MIT license
     7 * https://raw.github.com/worseisbetter/galleria/master/LICENSE
     8 *
     9 */
    210
    311#galleria-loader{height:1px!important}
    412
    5 .galleria-container {
     13.galleria-theme-classic {
    614    position: relative;
    715    overflow: hidden;
    816    background: #000;
    917}
    10 .galleria-container img {
     18.galleria-theme-classic img {
    1119    -moz-user-select: none;
    1220    -webkit-user-select: none;
    1321    -o-user-select: none;
    1422}
    15 .galleria-stage {
     23.galleria-theme-classic .galleria-stage {
    1624    position: absolute;
    1725    top: 10px;
     
    2129    overflow:hidden;
    2230}
    23 .galleria-thumbnails-container {
     31.galleria-theme-classic .galleria-thumbnails-container {
    2432    height: 50px;
    2533    bottom: 0;
     
    2937    z-index: 2;
    3038}
    31 .galleria-carousel .galleria-thumbnails-list {
     39.galleria-theme-classic .galleria-carousel .galleria-thumbnails-list {
    3240    margin-left: 30px;
    3341    margin-right: 30px;
    3442}
    35 .galleria-thumbnails .galleria-image {
     43.galleria-theme-classic .galleria-thumbnails .galleria-image {
    3644    height: 40px;
    3745    width: 60px;
     
    4250    cursor: pointer;
    4351}
    44 .galleria-counter {
     52.galleria-theme-classic .galleria-counter {
    4553    position: absolute;
    4654    bottom: 10px;
     
    5159    z-index: 1;
    5260}
    53 .galleria-loader {
     61.galleria-theme-classic .galleria-loader {
    5462    background: #000;
    5563    width: 20px;
     
    6270    background: url(classic-loader.gif) no-repeat 2px 2px;
    6371}
    64 .galleria-info {
     72.galleria-theme-classic .galleria-info {
    6573    width: 50%;
    6674    top: 15px;
     
    6977    position: absolute;
    7078}
    71 .galleria-info-text {
     79.galleria-theme-classic .galleria-info-text {
    7280    background-color: #000;
    7381    padding: 12px;
     
    7583    /* IE7 */ zoom:1;
    7684}
    77 .galleria-info-title {
     85.galleria-theme-classic .galleria-info-title {
    7886    font: bold 12px/1.1 arial,sans-serif;
    7987    margin: 0;
     
    8189    margin-bottom: 7px;
    8290}
    83 .galleria-info-description {
     91.galleria-theme-classic .galleria-info-description {
    8492    font: italic 12px/1.4 georgia,serif;
    8593    margin: 0;
    8694    color: #bbb;
    8795}
    88 .galleria-info-close {
     96.galleria-theme-classic .galleria-info-close {
    8997    width: 9px;
    9098    height: 9px;
     
    98106    display: none;
    99107}
    100 .notouch .galleria-info-close:hover{
     108.galleria-theme-classic .notouch .galleria-info-close:hover{
    101109    opacity:1;
    102110    filter: alpha(opacity=100);
    103111}
    104 .touch .galleria-info-close:active{
     112.galleria-theme-classic .touch .galleria-info-close:active{
    105113    opacity:1;
    106114    filter: alpha(opacity=100);
    107115}
    108 .galleria-info-link {
     116.galleria-theme-classic .galleria-info-link {
    109117    background-position: -669px -5px;
    110118    opacity: .7;
     
    116124    background-color: #000;
    117125}
    118 .notouch .galleria-info-link:hover {
    119     opacity: 1;
    120     filter: alpha(opacity=100);
    121 }
    122 .touch .galleria-info-link:active {
    123     opacity: 1;
    124     filter: alpha(opacity=100);
    125 }
    126 .galleria-image-nav {
     126.galleria-theme-classic.notouch .galleria-info-link:hover {
     127    opacity: 1;
     128    filter: alpha(opacity=100);
     129}
     130.galleria-theme-classic.touch .galleria-info-link:active {
     131    opacity: 1;
     132    filter: alpha(opacity=100);
     133}
     134.galleria-theme-classic .galleria-image-nav {
    127135    position: absolute;
    128136    top: 50%;
     
    132140    left: 0;
    133141}
    134 .galleria-image-nav-left,
    135 .galleria-image-nav-right {
     142.galleria-theme-classic .galleria-image-nav-left,
     143.galleria-theme-classic .galleria-image-nav-right {
    136144    opacity: .3;
    137145    filter: alpha(opacity=30);
     
    144152    background-position: 0 46px;
    145153}
    146 .galleria-image-nav-right {
     154.galleria-theme-classic .galleria-image-nav-right {
    147155    left: auto;
    148156    right: 10px;
     
    150158    z-index: 2;
    151159}
    152 .notouch .galleria-image-nav-left:hover,
    153 .notouch .galleria-image-nav-right:hover {
    154     opacity: 1;
    155     filter: alpha(opacity=100);
    156 }
    157 .touch .galleria-image-nav-left:active,
    158 .touch .galleria-image-nav-right:active {
    159     opacity: 1;
    160     filter: alpha(opacity=100);
    161 }
    162 .galleria-thumb-nav-left,
    163 .galleria-thumb-nav-right {
     160.galleria-theme-classic.notouch .galleria-image-nav-left:hover,
     161.galleria-theme-classic.notouch .galleria-image-nav-right:hover {
     162    opacity: 1;
     163    filter: alpha(opacity=100);
     164}
     165.galleria-theme-classic.touch .galleria-image-nav-left:active,
     166.galleria-theme-classic.touch .galleria-image-nav-right:active {
     167    opacity: 1;
     168    filter: alpha(opacity=100);
     169}
     170.galleria-theme-classic .galleria-thumb-nav-left,
     171.galleria-theme-classic .galleria-thumb-nav-right {
    164172    cursor: pointer;
    165173    display: none;
     
    174182    filter: alpha(opacity=80);
    175183}
    176 .galleria-thumb-nav-right {
     184.galleria-theme-classic .galleria-thumb-nav-right {
    177185    background-position: -578px 5px;
    178186    border-right: none;
     
    180188    left: auto;
    181189}
    182 .galleria-thumbnails-container .disabled {
     190.galleria-theme-classic .galleria-thumbnails-container .disabled {
    183191    opacity: .2;
    184192    filter: alpha(opacity=20);
    185193    cursor: default;
    186194}
    187 .notouch .galleria-thumb-nav-left:hover,
    188 .notouch .galleria-thumb-nav-right:hover {
     195.galleria-theme-classic.notouch .galleria-thumb-nav-left:hover,
     196.galleria-theme-classic.notouch .galleria-thumb-nav-right:hover {
    189197    opacity: 1;
    190198    filter: alpha(opacity=100);
    191199    background-color: #111;
    192200}
    193 .touch .galleria-thumb-nav-left:active,
    194 .touch .galleria-thumb-nav-right:active {
     201.galleria-theme-classic.touch .galleria-thumb-nav-left:active,
     202.galleria-theme-classic.touch .galleria-thumb-nav-right:active {
    195203    opacity: 1;
    196204    filter: alpha(opacity=100);
    197205    background-color: #111;
    198206}
    199 .notouch .galleria-thumbnails-container .disabled:hover {
     207.galleria-theme-classic.notouch .galleria-thumbnails-container .disabled:hover {
    200208    opacity: .2;
    201209    filter: alpha(opacity=20);
     
    203211}
    204212
    205 .galleria-carousel .galleria-thumb-nav-left,
    206 .galleria-carousel .galleria-thumb-nav-right {
     213.galleria-theme-classic .galleria-carousel .galleria-thumb-nav-left,
     214.galleria-theme-classic .galleria-carousel .galleria-thumb-nav-right {
    207215    display: block;
    208216}
    209 .galleria-thumb-nav-left,
    210 .galleria-thumb-nav-right,
    211 .galleria-info-link,
    212 .galleria-info-close,
    213 .galleria-image-nav-left,
    214 .galleria-image-nav-right {
     217.galleria-theme-classic .galleria-thumb-nav-left,
     218.galleria-theme-classic .galleria-thumb-nav-right,
     219.galleria-theme-classic .galleria-info-link,
     220.galleria-theme-classic .galleria-info-close,
     221.galleria-theme-classic .galleria-image-nav-left,
     222.galleria-theme-classic .galleria-image-nav-right {
    215223    background-image: url(classic-map.png);
    216224    background-repeat: no-repeat;
    217225}
     226.galleria-theme-classic.galleria-container.videoplay .galleria-info,
     227.galleria-theme-classic.galleria-container.videoplay .galleria-counter{ display:none!important; }
  • _plugins_/galleria/trunk/galleria/themes/classic/galleria.classic.js

    r72410 r106707  
    11/**
    2  * Galleria Classic Theme 2012-08-08
     2 * Galleria Classic Theme 2017-02-13
    33 * http://galleria.io
    44 *
     5 * Copyright (c) 2010 - 2017 worse is better UG
    56 * Licensed under the MIT license
    6  * https://raw.github.com/aino/galleria/master/LICENSE
     7 * https://raw.github.com/worseisbetter/galleria/master/LICENSE
    78 *
    89 */
     
    1011(function($) {
    1112
    12 /*global jQuery, Galleria */
     13/*global window, jQuery, Galleria */
    1314
    1415Galleria.addTheme({
    1516    name: 'classic',
     17    version: 1.5,
    1618    author: 'Galleria',
    1719    css: 'galleria.classic.css',
     
    2527    init: function(options) {
    2628
    27         Galleria.requires(1.28, 'This version of Classic theme requires Galleria 1.2.8 or later');
     29        Galleria.requires(1.4, 'This version of Classic theme requires Galleria 1.4 or later');
    2830
    2931        // add some elements
     
    3537        // cache some stuff
    3638        var info = this.$('info-link,info-close,info-text'),
    37             touch = Galleria.TOUCH,
    38             click = touch ? 'touchstart' : 'click';
     39            touch = Galleria.TOUCH;
    3940
    4041        // show loader & counter with opacity
     
    5051        // toggle info
    5152        if ( options._toggleInfo === true ) {
    52             info.bind( click, function() {
     53            info.bind( 'click:fast', function() {
    5354                info.toggle();
    5455            });
     
    7374                }
    7475            } else {
    75                 $(e.thumbTarget).css('opacity', this.getIndex() ? 1 : 0.6);
     76                $(e.thumbTarget).css('opacity', this.getIndex() ? 1 : 0.6).bind('click:fast', function() {
     77                    $(this).css( 'opacity', 1 ).parent().siblings().children().css('opacity', 0.6);
     78                });
    7679            }
    7780        });
     81
     82        var activate = function(e) {
     83            $(e.thumbTarget).css('opacity',1).parent().siblings().children().css('opacity', 0.6);
     84        };
    7885
    7986        this.bind('loadstart', function(e) {
     
    8188                this.$('loader').show().fadeTo(200, 0.4);
    8289            }
    83 
     90            window.setTimeout(function() {
     91                activate(e);
     92            }, touch ? 300 : 0);
    8493            this.$('info').toggle( this.hasInfo() );
    85 
    86             $(e.thumbTarget).css('opacity',1).parent().siblings().children().css('opacity', 0.6);
    8794        });
    8895
  • _plugins_/galleria/trunk/galleria/themes/classic/galleria.classic.min.js

    r72410 r106707  
    1 (function($){Galleria.addTheme({name:"classic",author:"Galleria",css:"galleria.classic.css",defaults:{transition:"slide",thumbCrop:"height",_toggleInfo:true},init:function(options){Galleria.requires(1.28,"This version of Classic theme requires Galleria 1.2.8 or later");this.addElement("info-link","info-close");this.append({info:["info-link","info-close"]});var info=this.$("info-link,info-close,info-text"),touch=Galleria.TOUCH,click=touch?"touchstart":"click";this.$("loader,counter").show().css("opacity",.4);if(!touch){this.addIdleState(this.get("image-nav-left"),{left:-50});this.addIdleState(this.get("image-nav-right"),{right:-50});this.addIdleState(this.get("counter"),{opacity:0})}if(options._toggleInfo===true){info.bind(click,function(){info.toggle()})}else{info.show();this.$("info-link, info-close").hide()}this.bind("thumbnail",function(e){if(!touch){$(e.thumbTarget).css("opacity",.6).parent().hover(function(){$(this).not(".active").children().stop().fadeTo(100,1)},function(){$(this).not(".active").children().stop().fadeTo(400,.6)});if(e.index===this.getIndex()){$(e.thumbTarget).css("opacity",1)}}else{$(e.thumbTarget).css("opacity",this.getIndex()?1:.6)}});this.bind("loadstart",function(e){if(!e.cached){this.$("loader").show().fadeTo(200,.4)}this.$("info").toggle(this.hasInfo());$(e.thumbTarget).css("opacity",1).parent().siblings().children().css("opacity",.6)});this.bind("loadfinish",function(e){this.$("loader").fadeOut(200)})}})})(jQuery);
     1(function($){Galleria.addTheme({name:"classic",version:1.5,author:"Galleria",css:"galleria.classic.css",defaults:{transition:"slide",thumbCrop:"height",_toggleInfo:true},init:function(options){Galleria.requires(1.4,"This version of Classic theme requires Galleria 1.4 or later");this.addElement("info-link","info-close");this.append({info:["info-link","info-close"]});var info=this.$("info-link,info-close,info-text"),touch=Galleria.TOUCH;this.$("loader,counter").show().css("opacity",.4);if(!touch){this.addIdleState(this.get("image-nav-left"),{left:-50});this.addIdleState(this.get("image-nav-right"),{right:-50});this.addIdleState(this.get("counter"),{opacity:0})}if(options._toggleInfo===true){info.bind("click:fast",function(){info.toggle()})}else{info.show();this.$("info-link, info-close").hide()}this.bind("thumbnail",function(e){if(!touch){$(e.thumbTarget).css("opacity",.6).parent().hover(function(){$(this).not(".active").children().stop().fadeTo(100,1)},function(){$(this).not(".active").children().stop().fadeTo(400,.6)});if(e.index===this.getIndex()){$(e.thumbTarget).css("opacity",1)}}else{$(e.thumbTarget).css("opacity",this.getIndex()?1:.6).bind("click:fast",function(){$(this).css("opacity",1).parent().siblings().children().css("opacity",.6)})}});var activate=function(e){$(e.thumbTarget).css("opacity",1).parent().siblings().children().css("opacity",.6)};this.bind("loadstart",function(e){if(!e.cached){this.$("loader").show().fadeTo(200,.4)}window.setTimeout(function(){activate(e)},touch?300:0);this.$("info").toggle(this.hasInfo())});this.bind("loadfinish",function(e){this.$("loader").fadeOut(200)})}})})(jQuery);
  • _plugins_/galleria/trunk/galleria_pipelines.php

    r64243 r106707  
    99
    1010function galleria_insert_head($flux){
    11         if (!function_exists('url_absolue'))
     11        if (!function_exists('url_absolue')) {
    1212                include_spip("inc/filtres");
     13        }
    1314        $flux .= '<script type="text/javascript" src="'.find_in_path('galleria/galleria.min.js').'"></script>';
    1415        return $flux;
    1516}
    1617
    17 ?>
  • _plugins_/galleria/trunk/paquet.xml

    r103720 r106707  
    22        prefix="galleria"
    33        categorie="multimedia"
    4         version="1.3.5"
     4        version="2.0.0"
    55        etat="stable"
    6         compatibilite="[1.9.2;3.1.*]"
     6        compatibilite="[3.2.0;3.2.*]"
    77        logo="galleria.png"
    88        documentation="https://contrib.spip.net/Galleria"
Note: See TracChangeset for help on using the changeset viewer.