-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgalleria-1.4.2.js
6919 lines (5373 loc) · 211 KB
/
galleria-1.4.2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Galleria v 1.4.2 2014-08-07
* http://galleria.io
*
* Licensed under the MIT license
* https://raw.github.com/aino/galleria/master/LICENSE
*
*/
(function( $, window, Galleria, undef ) {
/*global jQuery, navigator, Image, module, define */
// some references
var doc = window.document,
$doc = $( doc ),
$win = $( window ),
// native prototypes
protoArray = Array.prototype,
// internal constants
VERSION = 1.41,
DEBUG = true,
TIMEOUT = 30000,
DUMMY = false,
NAV = navigator.userAgent.toLowerCase(),
HASH = window.location.hash.replace(/#\//, ''),
PROT = window.location.protocol,
M = Math,
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 : doc.documentMode || undef;
}() ),
DOM = function() {
return {
html: doc.documentElement,
body: doc.body,
head: doc.getElementsByTagName('head')[0],
title: doc.title
};
},
IFRAME = window.parent !== window.self,
// list of Galleria events
_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 );
// legacy events
if ( /_/.test( ev ) ) {
evs.push( ev.replace( /_/g, '' ) );
}
});
return evs;
}()),
// legacy options
// allows the old my_setting syntax and converts it to camel case
_legacyOptions = function( options ) {
var n;
if ( typeof options !== 'object' ) {
// return whatever it was...
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 ) {
// allow 'image' instead of Galleria.IMAGE
if ( $.inArray( type, _events ) > -1 ) {
return Galleria[ type.toUpperCase() ];
}
return type;
},
// video providers
_video = {
youtube: {
reg: /https?:\/\/(?:[a-zA_Z]{2,3}.)?(?:youtube\.com\/watch\?)((?:[\w\d\-\_\=]+&(?:amp;)?)*v(?:<[A-Z]+>)?=([0-9a-zA-Z\-\_]+))/i,
embed: function() {
return 'http://www.youtube.com/embed/' + this.id;
},
getUrl: function() {
return PROT + '//gdata.youtube.com/feeds/api/videos/' + this.id + '?v=2&alt=json-in-script&callback=?';
},
get_thumb: function(data) {
return data.entry.media$group.media$thumbnail[2].url;
},
get_image: function(data) {
if ( data.entry.yt$hd ) {
return PROT + '//img.youtube.com/vi/'+this.id+'/maxresdefault.jpg';
}
return data.entry.media$group.media$thumbnail[3].url;
}
},
vimeo: {
reg: /https?:\/\/(?:www\.)?(vimeo\.com)\/(?:hd#)?([0-9]+)/i,
embed: function() {
return 'http://player.vimeo.com/video/' + this.id;
},
getUrl: function() {
return PROT + '//vimeo.com/api/v2/video/' + this.id + '.json?callback=?';
},
get_thumb: function( data ) {
return data[0].thumbnail_medium;
},
get_image: function( data ) {
return data[0].thumbnail_large;
}
},
dailymotion: {
reg: /https?:\/\/(?:www\.)?(dailymotion\.com)\/video\/([^_]+)/,
embed: function() {
return PROT + '//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( data ) {
return data.thumbnail_240_url;
},
get_image: function( data ) {
return data.thumbnail_720_url;
}
},
_inst: []
},
Video = function( type, id ) {
for( var i=0; i<_video._inst.length; i++ ) {
if ( _video._inst[i].id === id && _video._inst[i].type == type ) {
return _video._inst[i];
}
}
this.type = type;
this.id = id;
this.readys = [];
_video._inst.push(this);
var self = this;
$.extend( this, _video[type] );
$.getJSON( this.getUrl(), function(data) {
self.data = data;
$.each( self.readys, function( i, fn ) {
fn( self.data );
});
self.readys = [];
});
this.getMedia = function( type, callback, fail ) {
fail = fail || F;
var self = this;
var success = function( data ) {
callback( self['get_'+type]( data ) );
};
try {
if ( self.data ) {
success( self.data );
} else {
self.readys.push( success );
}
} catch(e) {
fail();
}
};
},
// utility for testing the video URL and getting the video ID
_videoTest = function( url ) {
var match;
for ( var v in _video ) {
match = url && _video[v].reg && url.match( _video[v].reg );
if( match && match.length ) {
return {
id: match[2],
provider: v
};
}
}
return false;
},
// native fullscreen handler
_nativeFullscreen = {
support: (function() {
var html = DOM().html;
return !IFRAME && ( html.requestFullscreen || html.msRequestFullscreen || 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.msRequestFullscreen ) {
elem.msRequestFullscreen();
}
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.msExitFullscreen ) {
doc.msExitFullscreen();
}
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 || ( doc.msFullscreenElement && doc.msFullscreenElement !== null ) ) {
fs._enter( _nativeFullscreen.callback );
} else {
fs._exit( _nativeFullscreen.callback );
}
};
doc.addEventListener( 'fullscreenchange', handler, false );
doc.addEventListener( 'MSFullscreenChange', handler, false );
doc.addEventListener( 'mozfullscreenchange', handler, false );
doc.addEventListener( 'webkitfullscreenchange', handler, false );
}
},
// the internal gallery holder
_galleries = [],
// the internal instance holder
_instances = [],
// flag for errors
_hasError = false,
// canvas holder
_canvas = false,
// instance pool, holds the galleries until themeLoad is triggered
_pool = [],
// Run galleries from theme trigger
_loadedThemes = [],
_themeLoad = function( theme ) {
_loadedThemes.push(theme);
// run the instances we have in the pool
// and apply the last theme if not specified
$.each( _pool, function( i, instance ) {
if ( instance._options.theme == theme.name || (!instance._initialized && !instance._options.theme) ) {
instance.theme = theme;
instance._init.call( instance );
}
});
},
// the Utils singleton
Utils = (function() {
return {
// legacy support for clearTimer
clearTimer: function( id ) {
$.each( Galleria.get(), function() {
this.clearTimer( id );
});
},
// legacy support for addTimer
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 ) {
// the currently executing script is always the last
src = src || $('script:last').attr('src');
var slices = src.split('/');
if (slices.length == 1) {
return '';
}
slices.pop();
return slices.join('/') + '/';
},
// CSS3 transitions, added in 1.2.4
animate : (function() {
// detect transition
var transition = (function( style ) {
var props = 'transition WebkitTransition MozTransition OTransition'.split(' '),
i;
// disable css3 animations in opera until stable
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 ));
// map transitionend event
var endEvent = {
MozTransition: 'transitionend',
OTransition: 'oTransitionEnd',
WebkitTransition: 'webkitTransitionEnd',
transition: 'transitionend'
}[ transition ];
// map bezier easing conversions
var easings = {
_default: [0.25, 0.1, 0.25, 1],
galleria: [0.645, 0.045, 0.355, 1],
galleriaIn: [0.55, 0.085, 0.68, 0.53],
galleriaOut: [0.25, 0.46, 0.45, 0.94],
ease: [0.25, 0, 0.25, 1],
linear: [0.25, 0.25, 0.75, 0.75],
'ease-in': [0.42, 0, 1, 1],
'ease-out': [0, 0, 0.58, 1],
'ease-in-out': [0.42, 0, 0.58, 1]
};
// function for setting transition css for all browsers
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 );
};
// clear styles
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);
}
}
};
// various variables
var change, strings, easing, syntax, revert, form, css;
// the actual animation method
return function( elem, to, options ) {
// extend defaults
options = $.extend({
duration: 400,
complete: F,
stop: false
}, options);
// cache jQuery instance
elem = $( elem );
if ( !options.duration ) {
elem.css( to );
options.complete.call( elem[0] );
return;
}
// fallback to jQuery's animate if transition is not supported
if ( !transition ) {
elem.animate(to, options);
return;
}
// stop
if ( options.stop ) {
// clear the animation
elem.off( endEvent );
clearStyle( elem );
}
// see if there is a change
change = false;
$.each( to, function( key, val ) {
css = elem.css( key );
if ( Utils.parseValue( css ) != Utils.parseValue( val ) ) {
change = true;
}
// also add computed styles for FF
elem.css( key, css );
});
if ( !change ) {
window.setTimeout( function() {
options.complete.call( elem[0] );
}, options.duration );
return;
}
// the css strings to be applied
strings = [];
// the easing bezier
easing = options.easing in easings ? easings[ options.easing ] : easings._default;
// the syntax
syntax = ' ' + options.duration + 'ms' + ' cubic-bezier(' + easing.join(',') + ')';
// add a tiny timeout so that the browsers catches any css changes before animating
window.setTimeout( (function(elem, endEvent, to, syntax) {
return function() {
// attach the end event
elem.one(endEvent, (function( elem ) {
return function() {
// clear the animation
clearStyle(elem);
// run the complete method
options.complete.call(elem[0]);
};
}( elem )));
// do the webkit translate3d for better performance on iOS
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);
// 3d animate
setStyle( elem, 'translate3d(' + form.join(',') + ')', 'transform');
}
}
// push the animation props
$.each(to, function( p, val ) {
strings.push(p + syntax);
});
// set the animation styles
setStyle( elem, strings.join(',') );
// animate
elem.css( to );
};
}(elem, endEvent, to, syntax)), 2);
};
}()),
removeAlpha : function( elem ) {
if ( elem instanceof jQuery ) {
elem = elem[0];
}
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',''); // "fixes" webkit bug
if ( elem.data( 'styles' ) ) {
elem.attr( 'style', elem.data('styles') ).data( 'styles', null );
}
});
},
moveOut : function( elem ) {
Utils.forceStyles( elem, {
position: 'absolute',
left: -10000
});
},
moveIn : function() {
Utils.revertStyles.apply( Utils, Utils.array( arguments ) );
},
hide : function( elem, speed, callback ) {
callback = callback || F;
var $elem = $(elem);
elem = $elem[0];
// save the value if not exist
if (! $elem.data('opacity') ) {
$elem.data('opacity', $elem.css('opacity') );
}
// always hide
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 $elem = $(elem);
elem = $elem[0];
// bring back saved opacity
var saved = parseFloat( $elem.data('opacity') ) || 1,
style = { opacity: saved };
// animate or toggle
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 );
}
}
},
wait : function(options) {
Galleria._waiters = Galleria._waiters || [];
options = $.extend({
until : FALSE,
success : F,
error : function() { Galleria.raise('Could not complete wait function.'); },
timeout: 3000
}, options);
var start = Utils.timestamp(),
elapsed,
now,
tid,
fn = function() {
now = Utils.timestamp();
elapsed = now - start;
Utils.removeFromArray( Galleria._waiters, tid );
if ( options.until( elapsed ) ) {
options.success();
return false;
}
if (typeof options.timeout == 'number' && now >= start + options.timeout) {
options.error();
return false;
}
Galleria._waiters.push( tid = window.setTimeout(fn, 10) );
};
Galleria._waiters.push( tid = 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 ) { // IE
style.styleSheet.cssText = styles;
} else {
var cssText = doc.createTextNode( styles );
style.appendChild( cssText );
}
},
// a loadscript method that works for local scripts
loadScript: function( url, callback ) {
var done = false,
script = $('<scr'+'ipt>').attr({
src: url,
async: true
}).get(0);
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
if ( !done && (!this.readyState ||
this.readyState === 'loaded' || this.readyState === 'complete') ) {
done = true;
// Handle memory leak in IE
script.onload = script.onreadystatechange = null;
if (typeof callback === 'function') {
callback.call( this, this );
}
}
};
DOM().head.appendChild( script );
},
// parse anything into a number
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 abstraction
timestamp: function() {
return new Date().getTime();
},
loadCSS : function( href, id, callback ) {
var link,
length;
// look for manual css
$('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; // dirty
// if already present, return
if ( link ) {
callback.call( link, link );
return link;
}
// save the length of stylesheets to check against
length = doc.styleSheets.length;
// check for existing id
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 && length >= 31 ) {
Galleria.raise( 'You have reached the browser stylesheet limit (31)', true );
return;
}
}
if ( typeof callback === 'function' ) {
// First check for dummy element (new in 1.2.8)
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();
// If failed, tell the dev to download the latest theme
Galleria.raise( 'Theme CSS could not load after 20 sec. ' + ( Galleria.QUIRK ?
'Your browser is in Quirks Mode, please add a correct doctype.' :
'Please download the latest theme at http://galleria.io/customer/.' ), true );
},
timeout: 5000
});
}
return link;
}
};
}()),
// play icon
_playIcon = function( container ) {
var css = '.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}';
Utils.insertStyleTag( css, 'galleria-videoicon' );
return $( Utils.create( 'galleria-videoicon' ) ).html( '<i></i>' ).appendTo( container )
.click( function() { $( this ).siblings( 'img' ).mouseup(); });
},
// the transitions holder
_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) {