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 | (function (factory) {
|
32 | "use strict";
|
33 | if (typeof define === 'function' && define.amd) {
|
34 |
|
35 |
|
36 | define(['jquery'], factory);
|
37 | } else if (typeof exports === 'object' && typeof require === 'function') {
|
38 |
|
39 | factory(require('jquery'));
|
40 | } else {
|
41 |
|
42 | factory(jQuery);
|
43 | }
|
44 | }(function ($) {
|
45 |
|
46 | "use strict";
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | function ColorHelperToRGB( color ) {
|
52 | var obj = document.getElementById('ngyColorHelperToRGB');
|
53 | if (obj === null) {
|
54 | obj = document.createElement('div');
|
55 | obj.id = "ngyColorHelperToRGB";
|
56 | obj.style.cssText = 'display: none; color:' + color + ';';
|
57 | document.body.appendChild(obj);
|
58 | }
|
59 |
|
60 | var rgb = getComputedStyle(obj).color;
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | return rgb;
|
70 | }
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | function ShadeBlendConvert (p, from, to) {
|
80 | var rgba='';
|
81 | if( from.toUpperCase().substring(0,5) == 'RGBA(' ) {
|
82 | rgba='a';
|
83 | from='rgb('+from.substring(5);
|
84 | }
|
85 |
|
86 | if(typeof(p)!="number"||p<-1||p>1||typeof(from)!="string"||(from[0]!='r'&&from[0]!='#')||(typeof(to)!="string"&&typeof(to)!="undefined"))return null;
|
87 |
|
88 | function sbcRip(d){
|
89 | var l=d.length,RGB=new Object();
|
90 | if(l>9){
|
91 | d=d.split(",");
|
92 | if(d.length<3||d.length>4)return null;
|
93 | RGB[0]=i(d[0].slice(4)),RGB[1]=i(d[1]),RGB[2]=i(d[2]),RGB[3]=d[3]?parseFloat(d[3]):-1;
|
94 | }else{
|
95 | if(l==8||l==6||l<4)return null;
|
96 | if(l<6)d="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]+(l>4?d[4]+""+d[4]:"");
|
97 | d=i(d.slice(1),16),RGB[0]=d>>16&255,RGB[1]=d>>8&255,RGB[2]=d&255,RGB[3]=l==9||l==5?r(((d>>24&255)/255)*10000)/10000:-1;
|
98 | }
|
99 | return RGB;
|
100 | }
|
101 | var i=parseInt,r=Math.round,h=from.length>9,h=typeof(to)=="string"?to.length>9?true:to=="c"?!h:false:h,b=p<0,p=b?p*-1:p,to=to&&to!="c"?to:b?"#000000":"#FFFFFF",f=sbcRip(from),t=sbcRip(to);
|
102 | if(!f||!t)return null;
|
103 | if(h)return "rgb"+rgba+"("+r((t[0]-f[0])*p+f[0])+","+r((t[1]-f[1])*p+f[1])+","+r((t[2]-f[2])*p+f[2])+(f[3]<0&&t[3]<0?")":","+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*10000)/10000:t[3]<0?f[3]:t[3])+")");
|
104 | else return "#"+(0x100000000+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*255):t[3]>-1?r(t[3]*255):f[3]>-1?r(f[3]*255):255)*0x1000000+r((t[0]-f[0])*p+f[0])*0x10000+r((t[1]-f[1])*p+f[1])*0x100+r((t[2]-f[2])*p+f[2])).toString(16).slice(f[3]>-1||t[3]>-1?1:3);
|
105 | }
|
106 |
|
107 |
|
108 |
|
109 | function cloneJSObject( obj ) {
|
110 | if (obj === null || typeof obj !== 'object') {
|
111 | return obj;
|
112 | }
|
113 |
|
114 | var temp = obj.constructor();
|
115 | for (var key in obj) {
|
116 | temp[key] = cloneJSObject(obj[key]);
|
117 | }
|
118 | return temp;
|
119 | }
|
120 |
|
121 |
|
122 | function getViewport() {
|
123 | var $win = jQuery(window);
|
124 | return {
|
125 | l: $win.scrollLeft(),
|
126 | t: $win.scrollTop(),
|
127 | w: $win.width(),
|
128 | h: $win.height()
|
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 | function inViewportVert( $elt, threshold ) {
|
157 | var wp = getViewport(),
|
158 | eltOS = $elt.offset(),
|
159 | th = $elt.outerHeight(true);
|
160 |
|
161 |
|
162 | if( wp.t == 0 && (eltOS.top) <= (wp.t + wp.h ) ) { return true; }
|
163 |
|
164 | if( eltOS.top >= wp.t && (eltOS.top + th) <= (wp.t + wp.h - threshold) ) {
|
165 | return true;
|
166 | }
|
167 | else {
|
168 | return false;
|
169 | }
|
170 | }
|
171 |
|
172 | function topInViewportVert( $elt, threshold ) {
|
173 | var wp = getViewport(),
|
174 | eltOS = $elt.offset();
|
175 |
|
176 | if( eltOS.top >= wp.t && eltOS.top <= (wp.t + wp.h - threshold) ) {
|
177 | return true;
|
178 | }
|
179 | else {
|
180 | return false;
|
181 | }
|
182 | }
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 | function setElementOnTop( start, elt ) {
|
200 | var highest_index = 0;
|
201 | if( start == '' ) { start = '*'; }
|
202 | jQuery(start).each(function() {
|
203 | var cur = parseInt(jQuery(this).css('z-index'));
|
204 | highest_index = cur > highest_index ? cur : highest_index;
|
205 | });
|
206 | highest_index++;
|
207 | jQuery(elt).css('z-index',highest_index);
|
208 | }
|
209 |
|
210 |
|
211 | var toType = function( obj ) {
|
212 |
|
213 | return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
|
214 | };
|
215 |
|
216 |
|
217 | $.nanogallery2 = function (elt, options) {
|
218 |
|
219 |
|
220 | var _this = this;
|
221 |
|
222 |
|
223 | _this.$e = jQuery(elt);
|
224 | _this.e = elt;
|
225 |
|
226 |
|
227 | _this.$e.data('nanogallery2data', _this);
|
228 |
|
229 | _this.init = function () {
|
230 |
|
231 |
|
232 | if (typeof window.NGY2Item === 'undefined') {
|
233 |
|
234 | window.NGY2Tools = (function () {
|
235 |
|
236 | function NGY2Tools() {
|
237 | var nextId = 1;
|
238 | }
|
239 |
|
240 |
|
241 | NGY2Tools.FilterAlbumName = function( title, ID ) {
|
242 | var s = title.toUpperCase();
|
243 | if( this.albumList.length > 0 ) {
|
244 | for( var j=0; j < this.albumList.length; j++) {
|
245 | if( s === this.albumList[j].toUpperCase() || ID === this.albumList[j] ) {
|
246 | return true;
|
247 | }
|
248 | }
|
249 | }
|
250 | else {
|
251 | var found = false;
|
252 | if( this.allowList !== null ) {
|
253 |
|
254 | for( var j = 0; j < this.allowList.length; j++) {
|
255 | if( s.indexOf(this.allowList[j]) !== -1 ) {
|
256 | found = true;
|
257 | }
|
258 | }
|
259 | if( !found ) { return false; }
|
260 | }
|
261 |
|
262 |
|
263 | if( this.blockList !== null ) {
|
264 |
|
265 | for( var j = 0; j < this.blockList.length; j++) {
|
266 | if( s.indexOf(this.blockList[j]) !== -1 ) {
|
267 | return false;
|
268 | }
|
269 | }
|
270 | }
|
271 | return true;
|
272 | }
|
273 | };
|
274 |
|
275 |
|
276 |
|
277 |
|
278 | NGY2Tools.NanoAlert = function(context, msg, verbose) {
|
279 | NGY2Tools.NanoConsoleLog.call(context, msg);
|
280 | if( context.$E.conConsole != null ) {
|
281 | context.$E.conConsole.css({visibility: 'visible', minHeight: '100px'});
|
282 | if( verbose == false ) {
|
283 | context.$E.conConsole.append('<p>' + msg + '</p>');
|
284 | }
|
285 | else {
|
286 | context.$E.conConsole.append('<p>nanogallery2: '+ msg + ' [' + context.baseEltID + ']</p>');
|
287 | }
|
288 | }
|
289 | };
|
290 |
|
291 |
|
292 |
|
293 |
|
294 | NGY2Tools.NanoConsoleLog = function(context, msg) {
|
295 | if (window.console) { console.log('nanogallery2: ' + msg + ' [' + context.baseEltID + ']'); }
|
296 |
|
297 | };
|
298 |
|
299 |
|
300 |
|
301 |
|
302 | NGY2Tools.PreloaderDisplay = function(display) {
|
303 | if( display === true ) {
|
304 |
|
305 | this.$E.conLoadingB.removeClass('nanoGalleryLBarOff').addClass('nanoGalleryLBar');
|
306 |
|
307 | if( this.GOM.albumIdxLoading != undefined && this.GOM.albumIdxLoading != -1 ) {
|
308 | let item = this.I[this.GOM.albumIdxLoading];
|
309 | item.$Elts['.nGY2TnImg'].addClass('nGY2GThumbnailLoaderDisplayed');
|
310 | }
|
311 | }
|
312 | else {
|
313 |
|
314 | this.$E.conLoadingB.removeClass('nanoGalleryLBar').addClass('nanoGalleryLBarOff');
|
315 |
|
316 | if( this.GOM.albumIdxLoading != undefined && this.GOM.albumIdxLoading != -1 ) {
|
317 | let item = this.I[this.GOM.albumIdxLoading];
|
318 | item.$Elts['.nGY2TnImg'].removeClass('nGY2GThumbnailLoaderDisplayed');
|
319 | }
|
320 | }
|
321 | };
|
322 |
|
323 |
|
324 |
|
325 |
|
326 | NGY2Tools.AreaShuffle = function (o) {
|
327 | for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
|
328 | return o;
|
329 | };
|
330 |
|
331 |
|
332 |
|
333 | NGY2Tools.GetImageTitleFromURL = function( imageURL ) {
|
334 | if( this.O.thumbnailLabel.get('title') == '%filename' ) {
|
335 | return (imageURL.split('/').pop()).replace('_',' ');
|
336 | }
|
337 |
|
338 | if( this.O.thumbnailLabel.get('title') == '%filenameNoExt' ) {
|
339 | var s=imageURL.split('/').pop();
|
340 | return (s.split('.').shift()).replace('_',' ');
|
341 | }
|
342 |
|
343 | return '';
|
344 | };
|
345 |
|
346 |
|
347 |
|
348 |
|
349 | NGY2Tools.AlbumPostProcess = function(albumID) {
|
350 |
|
351 |
|
352 |
|
353 | var sortOrder = this.gallerySorting[this.GOM.curNavLevel];
|
354 | var maxItems = this.galleryMaxItems[this.GOM.curNavLevel];
|
355 |
|
356 | if( sortOrder != '' || maxItems > 0 ) {
|
357 |
|
358 |
|
359 | var currentAlbum = this.I.filter( function( obj ) {
|
360 | return( obj.albumID == albumID && obj.kind != 'albumUp' );
|
361 | });
|
362 |
|
363 |
|
364 | switch( sortOrder ) {
|
365 | case 'RANDOM':
|
366 | currentAlbum = NGY2Tools.AreaShuffle(currentAlbum);
|
367 | break;
|
368 | case 'REVERSED':
|
369 | currentAlbum = currentAlbum.reverse();
|
370 | break;
|
371 | case 'TITLEASC':
|
372 | currentAlbum.sort(function (a, b) {
|
373 | return( (a.title.toUpperCase() < b.title.toUpperCase()) ? -1 : ((a.title.toUpperCase() > b.title.toUpperCase()) ? 1 : 0) );
|
374 | });
|
375 | break;
|
376 | case 'TITLEDESC':
|
377 | currentAlbum.sort(function (a, b) {
|
378 | return( (a.title.toUpperCase() > b.title.toUpperCase()) ? -1 : ((a.title.toUpperCase() < b.title.toUpperCase()) ? 1 : 0) );
|
379 | });
|
380 | break;
|
381 | }
|
382 |
|
383 |
|
384 | if( maxItems > 0 && currentAlbum.length > maxItems ) {
|
385 | currentAlbum.splice(maxItems - 1, currentAlbum.length-maxItems );
|
386 | }
|
387 |
|
388 |
|
389 | this.I.ngy2removeIf( function( obj ) {
|
390 | return( obj.albumID == albumID && obj.kind != 'albumUp' );
|
391 | });
|
392 |
|
393 |
|
394 | this.I.push.apply(this.I, currentAlbum);
|
395 |
|
396 | }
|
397 | };
|
398 |
|
399 | return NGY2Tools;
|
400 | })();
|
401 |
|
402 |
|
403 |
|
404 |
|
405 | window.NGY2Item = (function() {
|
406 | var nextId = 1;
|
407 |
|
408 |
|
409 | function NGY2Item( itemID ) {
|
410 |
|
411 | var ID = 0;
|
412 |
|
413 |
|
414 | if( itemID === undefined || itemID === null ) {
|
415 | ID = nextId++;
|
416 | }
|
417 | else {
|
418 | ID = itemID;
|
419 | }
|
420 | this.GetID = function () { return ID; };
|
421 |
|
422 |
|
423 | this.kind = '';
|
424 | this.mediaKind = 'img';
|
425 | this.mediaMarkup = '';
|
426 | this.G = null;
|
427 | this.title = '';
|
428 | this.description = '';
|
429 | this.albumID = 0;
|
430 | this.src = '';
|
431 | this.width = 0;
|
432 | this.height = 0;
|
433 | this.destinationURL = '';
|
434 | this.downloadURL = '';
|
435 | this.author = '';
|
436 | this.left = 0;
|
437 | this.top = 0;
|
438 | this.width = 0;
|
439 | this.height = 0;
|
440 | this.resizedContentWidth= 0;
|
441 | this.resizedContentHeight= 0;
|
442 | this.thumbs = {
|
443 | url: { l1: { xs: '', sm:'', me: '', la: '', xl: '' }, lN: { xs: '', sm: '', me: '', la:'', xl: '' } },
|
444 | width: { l1: { xs: 0, sm: 0, me: 0, la: 0 , xl: 0 }, lN: { xs: 0 , sm: 0, me: 0, la: 0, xl: 0 } },
|
445 | height: { l1: { xs: 0, sm: 0, me: 0, la: 0 , xl: 0 }, lN: { xs: 0, sm: 0, me: 0, la: 0, xl: 0 } }
|
446 | };
|
447 | this.thumbnailImgRevealed = false;
|
448 | this.imageDominantColors = null;
|
449 | this.imageDominantColor = null;
|
450 | this.featured = false;
|
451 | this.flickrThumbSizes = {};
|
452 | this.picasaThumbs = null;
|
453 | this.hovered = false;
|
454 | this.hoverInitDone = false;
|
455 | this.contentIsLoaded = false;
|
456 | this.contentLength = 0;
|
457 | this.numberItems = 0;
|
458 | this.mediaNumber = 0;
|
459 | this.mediaCounter = 0;
|
460 | this.eltTransform = [];
|
461 | this.eltFilter = [];
|
462 | this.eltEffect = [];
|
463 | this.paginationLastPage = 0;
|
464 | this.paginationLastWidth = 0;
|
465 | this.customData = {};
|
466 | this.selected = false;
|
467 | this.imageWidth = 0;
|
468 | this.imageHeight = 0;
|
469 | this.$elt = null;
|
470 | this.$Elts = [];
|
471 | this.tags = [];
|
472 | this.albumTagList = [];
|
473 | this.albumTagListSel = [];
|
474 | this.exif = { exposure: '', flash: '', focallength: '', fstop: '', iso: '', model: '', time: '', location: ''};
|
475 | this.deleted = false;
|
476 | this.rotationAngle = 0;
|
477 | }
|
478 |
|
479 |
|
480 |
|
481 | NGY2Item.Get = function( instance, ID ) {
|
482 | var l = instance.I.length;
|
483 | for( var i = 0; i < l; i++ ) {
|
484 | if( instance.I[i].GetID() == ID ) {
|
485 | return instance.I[i];
|
486 | }
|
487 | }
|
488 | return null;
|
489 | };
|
490 |
|
491 | NGY2Item.GetIdx = function( instance, ID ) {
|
492 | var l = instance.I.length;
|
493 | for( var i = 0; i < l; i++ ) {
|
494 | if( instance.I[i].GetID() == ID ) {
|
495 | return i;
|
496 | }
|
497 | }
|
498 | return -1;
|
499 | };
|
500 |
|
501 |
|
502 | NGY2Item.New = function( instance, title, description, ID, albumID, kind, tags ) {
|
503 | var album = NGY2Item.Get( instance, albumID );
|
504 |
|
505 |
|
506 | if( instance.O.titleTranslationMap !== null ) {
|
507 | let obj = instance.O.titleTranslationMap.find(o => o.title === title);
|
508 | if( obj !== undefined ) {
|
509 | title = obj.replace;
|
510 | }
|
511 | }
|
512 |
|
513 |
|
514 | if( albumID != -1 && albumID != 0 && title !='image gallery by nanogallery2 [build]' ) {
|
515 | if( instance.O.thumbnailLevelUp && album.getContentLength(false) == 0 && instance.O.album == '' ) {
|
516 |
|
517 | let item = new NGY2Item('0');
|
518 | instance.I.push( item );
|
519 | album.contentLength += 1;
|
520 | item.title = 'UP';
|
521 | item.albumID = albumID;
|
522 | item.kind = 'albumUp';
|
523 | item.G = instance;
|
524 |
|
525 | jQuery.extend( true, item.thumbs.width, instance.tn.defaultSize.width);
|
526 | jQuery.extend( true, item.thumbs.height, instance.tn.defaultSize.height);
|
527 | }
|
528 | }
|
529 |
|
530 | var item = NGY2Item.Get(instance, ID);
|
531 | if( item === null ){
|
532 |
|
533 | item = new NGY2Item(ID);
|
534 | instance.I.push(item);
|
535 | if( albumID != -1 && title !='image gallery by nanogallery2 [build]' ) {
|
536 | album.contentLength+=1;
|
537 | }
|
538 | }
|
539 | item.G = instance;
|
540 |
|
541 | item.albumID = albumID;
|
542 | item.kind = kind;
|
543 | if( kind == 'image' ) {
|
544 | album.mediaCounter += 1;
|
545 | item.mediaNumber = album.mediaCounter;
|
546 | }
|
547 |
|
548 |
|
549 | var kw = instance.O.thumbnailFeaturedKeyword;
|
550 | if( kw != '' ) {
|
551 |
|
552 | kw = kw.toUpperCase();
|
553 | var p = title.toUpperCase().indexOf(kw);
|
554 | if( p > -1) {
|
555 | item.featured = true;
|
556 |
|
557 | title = title.substring(0, p) + title.substring(p+kw.length, title.length);
|
558 | }
|
559 | p = description.toUpperCase().indexOf(kw);
|
560 | if( p > -1) {
|
561 | item.featured=true;
|
562 |
|
563 | description=description.substring(0, p) + description.substring(p + kw.length, description.length);
|
564 | }
|
565 | }
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 | if( typeof instance.galleryFilterTags.Get() == 'string' ) {
|
578 | switch( instance.galleryFilterTags.Get().toUpperCase() ) {
|
579 | case 'TITLE': {
|
580 | let re = /(?:^|\W)#(\w+)(?!\w)/g, match, matches = [];
|
581 |
|
582 | while (match = re.exec(title)) {
|
583 | matches.push(match[1].replace(/^\s*|\s*$/, ''));
|
584 | }
|
585 | item.setTags(matches);
|
586 | title = title.split('#').join('');
|
587 | break;
|
588 | }
|
589 | case 'DESCRIPTION': {
|
590 | let re = /(?:^|\W)#(\w+)(?!\w)/g, match2, matches2 = [];
|
591 |
|
592 | while (match2 = re.exec(description)) {
|
593 | matches2.push(match2[1].replace(/^\s*|\s*$/, ''));
|
594 | }
|
595 | item.setTags(matches2);
|
596 | description = description.split('#').join('');
|
597 | break;
|
598 | }
|
599 | }
|
600 | }
|
601 | else {
|
602 | if( tags != '' && tags != undefined ) {
|
603 |
|
604 | item.setTags(tags.split(' '));
|
605 | }
|
606 | }
|
607 |
|
608 |
|
609 |
|
610 |
|
611 | item.title = escapeHtml(instance, title);
|
612 | item.description = escapeHtml(instance, description);
|
613 | return item;
|
614 | };
|
615 |
|
616 |
|
617 |
|
618 | NGY2Item.prototype.delete = function( ) {
|
619 | this.deleted = true;
|
620 |
|
621 |
|
622 | this.G.I[NGY2Item.GetIdx(this.G, this.albumID)].contentLength--;
|
623 | this.G.I[NGY2Item.GetIdx(this.G, this.albumID)].numberItems--;
|
624 |
|
625 |
|
626 | var nbTn = this.G.GOM.items.length;
|
627 | var ID = this.GetID();
|
628 | var foundIdx = -1;
|
629 | var foundGOMidx = -1;
|
630 | for( var i = 0; i < nbTn ; i++ ) {
|
631 | var curTn = this.G.GOM.items[i];
|
632 | var item=this.G.I[curTn.thumbnailIdx];
|
633 | if( item.GetID() == ID ) {
|
634 |
|
635 | if( !curTn.neverDisplayed ) {
|
636 | foundIdx = curTn.thumbnailIdx;
|
637 | foundGOMidx = i;
|
638 | }
|
639 | }
|
640 | else {
|
641 | if( foundIdx != -1 ) {
|
642 | if( !curTn.neverDisplayed ) {
|
643 |
|
644 | item.$getElt('.nGY2GThumbnail').data('index', i-1);
|
645 | item.$getElt('.nGY2GThumbnailImg').data('index', i-1);
|
646 | }
|
647 | }
|
648 | }
|
649 | }
|
650 | if( foundIdx != -1 ) {
|
651 |
|
652 | var G = this.G;
|
653 | if( this.selected == true ) {
|
654 | this.selected = false;
|
655 | G.GOM.nbSelected--;
|
656 | }
|
657 | if( G.I[foundIdx].$elt !== null ) {
|
658 | G.I[foundIdx].$elt.remove();
|
659 | }
|
660 | G.GOM.items.splice(foundGOMidx, 1);
|
661 | if( G.GOM.lastDisplayedIdx != -1 ) {
|
662 | G.GOM.lastDisplayedIdx -= 1;
|
663 | }
|
664 | }
|
665 |
|
666 |
|
667 | }
|
668 |
|
669 | NGY2Item.prototype.addToGOM = function( ) {
|
670 |
|
671 | var ID = this.GetID();
|
672 | var l = this.G.I.length;
|
673 | for( var idx = 0; idx < l; idx++ ) {
|
674 | var item = this.G.I[idx];
|
675 | if( item.GetID() == ID ) {
|
676 | var w = item.thumbImg().width;
|
677 | var h = item.thumbImg().height;
|
678 |
|
679 | if( h == 0 ) {
|
680 | h = this.G.tn.defaultSize.getHeight();
|
681 | }
|
682 | if( w == 0 ) {
|
683 | w = this.G.tn.defaultSize.getWidth();
|
684 | }
|
685 |
|
686 | var tn = new this.G.GOM.GTn(idx, w, h);
|
687 | this.G.GOM.items.push(tn);
|
688 | break;
|
689 | }
|
690 | }
|
691 |
|
692 | }
|
693 |
|
694 |
|
695 |
|
696 |
|
697 | var entityMap = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '/': '/', '`': '`', '=': '=' };
|
698 | function escapeHtml (instance, string) {
|
699 | if( instance.O.allowHTMLinData == true ) {
|
700 | return string;
|
701 | }
|
702 | else {
|
703 | return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
|
704 | return entityMap[s];
|
705 | });
|
706 | }
|
707 | }
|
708 |
|
709 |
|
710 | NGY2Item.get_nextId = function () {
|
711 | return nextId;
|
712 | };
|
713 |
|
714 |
|
715 |
|
716 |
|
717 | NGY2Item.prototype.$getElt = function( elt, forceRefresh ) {
|
718 | if( this.$elt == null ) { return null; }
|
719 | if( this.$Elts[elt] !== undefined && !forceRefresh == true ) {
|
720 | return this.$Elts[elt];
|
721 | }
|
722 | else {
|
723 | if( elt == '.nGY2GThumbnail' ) {
|
724 | this.$Elts[elt]=this.$elt;
|
725 | }
|
726 | else {
|
727 | this.$Elts[elt]=this.$elt.find(elt);
|
728 | }
|
729 | return this.$Elts[elt];
|
730 | }
|
731 | };
|
732 |
|
733 |
|
734 | NGY2Item.prototype.removeElt = function( elt ) {
|
735 | if( this.$elt == null ) { return; }
|
736 | if( this.$Elts[elt] == undefined) { return; }
|
737 | this.$Elts[elt].remove();
|
738 | var index = this.$Elts.indexOf(elt);
|
739 | this.$Elts.splice(index, 1);
|
740 | };
|
741 |
|
742 |
|
743 | NGY2Item.prototype.album = function() {
|
744 | return this.G.I[NGY2Item.GetIdx(this.G, this.albumID)];
|
745 | };
|
746 |
|
747 |
|
748 | NGY2Item.prototype.mediaTransition = function( ) {
|
749 | if( this.G.O.viewerTransitionMediaKind.indexOf( this.mediaKind ) > -1 ) {
|
750 | return true;
|
751 | }
|
752 | return false;
|
753 | };
|
754 |
|
755 |
|
756 | NGY2Item.prototype.imageSet = function( src, w, h ) {
|
757 | this.src = src;
|
758 | this.width = w;
|
759 | this.height = h;
|
760 | };
|
761 |
|
762 |
|
763 | NGY2Item.prototype.thumbSet = function( src, w, h, screenSize, level ) {
|
764 | var lst=['xs','sm','me','la','xl'];
|
765 | if( typeof screenSize === 'undefined' || screenSize == '' || screenSize == null ) {
|
766 | for( var i=0; i< lst.length; i++ ) {
|
767 | if( typeof level === 'undefined' || level == '' ) {
|
768 | this.thumbs.url.l1[lst[i]]=src;
|
769 | this.thumbs.height.l1[lst[i]]=h;
|
770 | this.thumbs.width.l1[lst[i]]=w;
|
771 | this.thumbs.url.lN[lst[i]]=src;
|
772 | this.thumbs.height.lN[lst[i]]=h;
|
773 | this.thumbs.width.lN[lst[i]]=w;
|
774 | }
|
775 | else {
|
776 | this.thumbs.url[level][lst[i]]=src;
|
777 | this.thumbs.height[level][lst[i]]=h;
|
778 | this.thumbs.width[level][lst[i]]=w;
|
779 | }
|
780 | }
|
781 | }
|
782 | else {
|
783 | if( typeof level === 'undefined' || level == '' || level == null ) {
|
784 | this.thumbs.url.l1[screenSize]=src;
|
785 | this.thumbs.height.l1[screenSize]=h;
|
786 | this.thumbs.width.l1[screenSize]=w;
|
787 | this.thumbs.url.lN[screenSize]=src;
|
788 | this.thumbs.height.lN[screenSize]=h;
|
789 | this.thumbs.width.lN[screenSize]=w;
|
790 | }
|
791 | else {
|
792 | this.thumbs.url[level][screenSize]=src;
|
793 | this.thumbs.height[level][screenSize]=h;
|
794 | this.thumbs.width[level][screenSize]=w;
|
795 | }
|
796 | }
|
797 |
|
798 | for( var i=0; i< lst.length; i++ ) {
|
799 | this.thumbs.height.l1[lst[i]]=h;
|
800 | }
|
801 | for( var i=0; i< lst.length; i++ ) {
|
802 | if( this.G.tn.settings.height.lN[lst[i]] == this.G.tn.settings.getH() && this.G.tn.settings.width.l1[lst[i]] == this.G.tn.settings.getW() ) {
|
803 | this.thumbs.height.lN[lst[i]]=h;
|
804 | }
|
805 | }
|
806 | };
|
807 |
|
808 |
|
809 | NGY2Item.prototype.thumbSetImgHeight = function( h ) {
|
810 | var lst=['xs','sm','me','la','xl'];
|
811 | for( var i=0; i< lst.length; i++ ) {
|
812 | if( this.G.tn.settings.height.l1[lst[i]] == this.G.tn.settings.getH() && this.G.tn.settings.width.l1[lst[i]] == this.G.tn.settings.getW() ) {
|
813 | this.thumbs.height.l1[lst[i]]=h;
|
814 | }
|
815 | }
|
816 | for( var i=0; i< lst.length; i++ ) {
|
817 | if( this.G.tn.settings.height.lN[lst[i]] == this.G.tn.settings.getH() && this.G.tn.settings.width.l1[lst[i]] == this.G.tn.settings.getW() ) {
|
818 | this.thumbs.height.lN[lst[i]]=h;
|
819 | }
|
820 | }
|
821 | };
|
822 |
|
823 |
|
824 | NGY2Item.prototype.thumbSetImgWidth = function( w ) {
|
825 | var lst=['xs','sm','me','la','xl'];
|
826 | for( var i=0; i< lst.length; i++ ) {
|
827 | if( this.G.tn.settings.height.l1[lst[i]] == this.G.tn.settings.getH() && this.G.tn.settings.width.l1[lst[i]] == this.G.tn.settings.getW() ) {
|
828 | this.thumbs.width.l1[lst[i]]=w;
|
829 | }
|
830 | }
|
831 | for( var i=0; i< lst.length; i++ ) {
|
832 | if( this.G.tn.settings.height.lN[lst[i]] == this.G.tn.settings.getH() && this.G.tn.settings.width.l1[lst[i]] == this.G.tn.settings.getW() ) {
|
833 | this.thumbs.width.lN[lst[i]]=w;
|
834 | }
|
835 | }
|
836 | };
|
837 |
|
838 |
|
839 | NGY2Item.prototype.thumbImg = function () {
|
840 | var tnImg = { src: '', width: 0, height: 0 };
|
841 |
|
842 | if( this.title == 'image gallery by nanogallery2 [build]' ) {
|
843 | tnImg.src = this.G.emptyGif;
|
844 | tnImg.url = this.G.emptyGif;
|
845 | return tnImg;
|
846 | }
|
847 | tnImg.src = this.thumbs.url[this.G.GOM.curNavLevel][this.G.GOM.curWidth];
|
848 | tnImg.width = this.thumbs.width[this.G.GOM.curNavLevel][this.G.GOM.curWidth];
|
849 | tnImg.height = this.thumbs.height[this.G.GOM.curNavLevel][this.G.GOM.curWidth];
|
850 | return tnImg;
|
851 | };
|
852 |
|
853 |
|
854 | NGY2Item.prototype.setTags = function( tags ) {
|
855 | if( tags.length > 0 ) {
|
856 | this.tags = tags;
|
857 | var lstTags = this.album().albumTagList;
|
858 | for( var i = 0; i < tags.length; i++ ) {
|
859 | var tfound = false;
|
860 | for( var j = 0; j < lstTags.length; j++ ) {
|
861 | if( tags[i].toUpperCase() == lstTags[j].toUpperCase() ) {
|
862 | tfound = true;
|
863 | }
|
864 | }
|
865 | if( tfound == false) {
|
866 | this.album().albumTagList.push(tags[i])
|
867 |
|
868 | }
|
869 | }
|
870 | }
|
871 | };
|
872 |
|
873 |
|
874 | NGY2Item.prototype.checkTagFilter = function() {
|
875 | if( this.G.galleryFilterTags.Get() != false && this.album().albumTagList.length > 0 ) {
|
876 | if( this.G.O.thumbnailLevelUp && this.kind == 'albumUp' ) {
|
877 | return true;
|
878 | }
|
879 | var found = false;
|
880 | var lstTags = this.album().albumTagListSel;
|
881 | if( lstTags.length == 0 ) {
|
882 |
|
883 | return true;
|
884 | }
|
885 | for( var i = 0; i < this.tags.length; i++ ) {
|
886 | for( var j = 0; j < lstTags.length; j++ ) {
|
887 | if( this.tags[i].toUpperCase() == lstTags[j].toUpperCase() ) {
|
888 | found = true;
|
889 | break;
|
890 | }
|
891 | }
|
892 | }
|
893 | return found;
|
894 | }
|
895 | else
|
896 | return true;
|
897 | };
|
898 |
|
899 |
|
900 | NGY2Item.prototype.isSearchTagFound = function() {
|
901 | if( this.G.GOM.albumSearchTags == '' ) { return true; }
|
902 | if( this.G.O.thumbnailLevelUp && this.kind == 'albumUp' ) { return true; }
|
903 |
|
904 |
|
905 | for( var i = 0; i < this.tags.length; i++ ) {
|
906 | if( this.tags[i].toUpperCase().indexOf( this.G.GOM.albumSearchTags ) >= 0 ) {
|
907 | return true;
|
908 | }
|
909 | }
|
910 | return false;
|
911 | };
|
912 |
|
913 |
|
914 |
|
915 | NGY2Item.prototype.setMediaURL = function( url, mediaKind ) {
|
916 | this.src = url;
|
917 | this.mediaKind = mediaKind;
|
918 | if( mediaKind == 'img' ) {
|
919 | this.mediaMarkup = '<img class="nGY2ViewerMedia" src="' + url + '" alt=" " itemprop="contentURL" draggable="false">';
|
920 | }
|
921 | };
|
922 |
|
923 |
|
924 |
|
925 | NGY2Item.prototype.isToDisplay = function( albumID ) {
|
926 | return this.albumID == albumID && this.checkTagFilter() && this.isSearchFound() && this.isSearchTagFound() && this.deleted == false;
|
927 | };
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 | NGY2Item.prototype.getContentLength = function( filterTags ) {
|
934 | if( filterTags == false || this.albumTagList.length == 0 || this.G.galleryFilterTags.Get() == false ) {
|
935 | return this.contentLength;
|
936 | }
|
937 | else {
|
938 | var l = this.G.I.length;
|
939 | var cnt = 0;
|
940 | var albumID = this.GetID();
|
941 | for( var idx = 0; idx < l; idx++ ) {
|
942 | var item = this.G.I[idx];
|
943 | if( item.isToDisplay(albumID) ) {
|
944 | cnt++;
|
945 | }
|
946 | }
|
947 | return cnt;
|
948 | }
|
949 | };
|
950 |
|
951 | NGY2Item.prototype.isSearchFound = function() {
|
952 | if( this.G.GOM.albumSearch != '' ) {
|
953 | if( this.title.toUpperCase().indexOf( this.G.GOM.albumSearch ) == -1 ) {
|
954 | return false;
|
955 | }
|
956 | }
|
957 | return true;
|
958 | }
|
959 |
|
960 |
|
961 |
|
962 | NGY2Item.prototype.responsiveURL = function () {
|
963 | var url = '';
|
964 | switch(this.G.O.kind) {
|
965 | case '':
|
966 | url = this.src;
|
967 | break;
|
968 | case 'flickr':
|
969 | url = this.src;
|
970 | break;
|
971 | case 'picasa':
|
972 | case 'google':
|
973 | case 'google2':
|
974 | default:
|
975 | url = this.src;
|
976 | break;
|
977 | }
|
978 | return url;
|
979 | };
|
980 |
|
981 |
|
982 |
|
983 | NGY2Item.prototype.ThumbnailImageReveal = function () {
|
984 |
|
985 | if( this.thumbnailImgRevealed == false ) {
|
986 | this.thumbnailImgRevealed = true;
|
987 | new NGTweenable().tween({
|
988 | from: { opacity: 0 },
|
989 | to: { opacity: 1 },
|
990 | attachment: { item: this },
|
991 | delay: 30,
|
992 | duration: 400,
|
993 | easing: 'easeOutQuart',
|
994 | step: function (state, att) {
|
995 | var $e=att.item.$getElt('.nGY2TnImg');
|
996 | if( $e != null ) {
|
997 | $e.css( state );
|
998 | }
|
999 | }
|
1000 | });
|
1001 | }
|
1002 | };
|
1003 |
|
1004 |
|
1005 |
|
1006 | function ValueApplyPercent( str, percent ) {
|
1007 | str=String(str);
|
1008 | if( str === '0' || percent == 1 ) { return str; }
|
1009 | var n = Number(str.replace(/[a-zA-Z]/g, ''));
|
1010 | var ar = str.match(/([^\-0-9\.]+)/g);
|
1011 | var a = '';
|
1012 | if( ar != null && ar.length > 0 ) {
|
1013 | a = ar.join();
|
1014 | }
|
1015 |
|
1016 | if( isNaN(n) || n == 0 ) {
|
1017 | return str;
|
1018 | }
|
1019 |
|
1020 | n = n * percent;
|
1021 | return n + a;
|
1022 | }
|
1023 |
|
1024 |
|
1025 | NGY2Item.prototype.CSSTransformApply = function ( eltClass ) {
|
1026 | var obj = this.eltTransform[eltClass];
|
1027 |
|
1028 | if( eltClass == '.nGY2GThumbnail' ) {
|
1029 |
|
1030 | var nbStacks = obj.$elt.length-1;
|
1031 | var pTranslateX = 1;
|
1032 | var pTranslateY = 1;
|
1033 | var pTranslateZ = 1;
|
1034 | var pTranslate = 1;
|
1035 | var pRotateX = 1;
|
1036 | var pRotateY = 1;
|
1037 | var pRotateZ = 1;
|
1038 | var pRotate = 1;
|
1039 | var pScale = 1;
|
1040 | for( var n = nbStacks; n >= 0; n-- ) {
|
1041 |
|
1042 | var v = 'translateX(' + ValueApplyPercent(obj.translateX,pTranslateX) + ') translateY(' + ValueApplyPercent(obj.translateY,pTranslateY) + ') translateZ(' + ValueApplyPercent(obj.translateZ,pTranslateZ) + ') scale(' + ValueApplyPercent(obj.scale,pScale) + ') translate(' + ValueApplyPercent(obj.translate,pTranslate) + ')';
|
1043 | if( !(this.G.IE <= 9) && !this.G.isGingerbread ) {
|
1044 | v += ' rotateX(' + ValueApplyPercent(obj.rotateX,pRotateX) + ') rotateY(' + ValueApplyPercent(obj.rotateY,pRotateY) + ') rotateZ(' + ValueApplyPercent(obj.rotateZ,pRotateZ) + ') rotate(' + ValueApplyPercent(obj.rotate,pRotate) + ')';
|
1045 | }
|
1046 | else {
|
1047 | v += ' rotate(' + ValueApplyPercent(obj.rotateZ,pRotateZ) + ')';
|
1048 | }
|
1049 | obj.$elt[n].style[this.G.CSStransformName] = v;
|
1050 |
|
1051 | if( nbStacks > 0 ) {
|
1052 |
|
1053 | pTranslateX -= this.G.tn.opt.Get('stacksTranslateX');
|
1054 | pTranslateY -= this.G.tn.opt.Get('stacksTranslateY');
|
1055 | pTranslateZ -= this.G.tn.opt.Get('stacksTranslateZ');
|
1056 | pRotateX -= this.G.tn.opt.Get('stacksRotateX');
|
1057 | pRotateY -= this.G.tn.opt.Get('stacksRotateY');
|
1058 | pRotateZ -= this.G.tn.opt.Get('stacksRotateZ');
|
1059 | pScale -= this.G.tn.opt.Get('stacksScale');
|
1060 | }
|
1061 | }
|
1062 | }
|
1063 | else {
|
1064 |
|
1065 | if( obj.$elt != null ) {
|
1066 | for( var n = 0; n < obj.$elt.length; n++ ) {
|
1067 | if( obj.$elt[n] != undefined ) {
|
1068 |
|
1069 | var v = 'translateX(' + obj.translateX + ') translateY(' + obj.translateY + ') translateZ(' + obj.translateZ + ') scale(' + obj.scale + ') translate(' + obj.translate + ')';
|
1070 | if( !(this.G.IE <= 9) && !this.G.isGingerbread ) {
|
1071 | v += ' rotateX(' + obj.rotateX + ') rotateY(' + obj.rotateY + ') rotateZ(' + obj.rotateZ + ') rotate(' + obj.rotate + ')';
|
1072 | }
|
1073 | else {
|
1074 | v += ' rotate(' + obj.rotateZ + ')';
|
1075 | }
|
1076 | obj.$elt[n].style[this.G.CSStransformName] = v;
|
1077 | }
|
1078 | }
|
1079 | }
|
1080 | }
|
1081 | };
|
1082 |
|
1083 |
|
1084 | NGY2Item.prototype.CSSTransformSet = function ( eltClass, transform, value, forceRefresh ) {
|
1085 | if( this.eltTransform[eltClass] == undefined ) {
|
1086 | this.eltTransform[eltClass] = { translateX: 0, translateY: 0, translateZ: 0, rotateX: 0, rotateY: 0, rotateZ: 0, scale: 1, translate: '0px,0px', rotate: 0 };
|
1087 | this.eltTransform[eltClass].$elt = this.$getElt(eltClass);
|
1088 | }
|
1089 | this.eltTransform[eltClass][transform] = value;
|
1090 | if( forceRefresh === true ) {
|
1091 | this.eltTransform[eltClass].$elt = this.$getElt(eltClass, true);
|
1092 | }
|
1093 | };
|
1094 |
|
1095 |
|
1096 | NGY2Item.prototype.CSSFilterApply = function ( eltClass ) {
|
1097 | var obj = this.eltFilter[eltClass];
|
1098 | var v = 'blur(' + obj.blur + ') brightness(' + obj.brightness + ') grayscale(' + obj.grayscale + ') sepia(' + obj.sepia + ') contrast(' + obj.contrast + ') opacity(' + obj.opacity + ') saturate(' + obj.saturate + ')';
|
1099 | if( obj.$elt != null ) {
|
1100 | for( var n = 0; n < obj.$elt.length; n++ ) {
|
1101 | if( obj.$elt[n] != undefined ) {
|
1102 | obj.$elt[n].style.WebkitFilter = v;
|
1103 | obj.$elt[n].style.filter = v;
|
1104 | }
|
1105 | }
|
1106 | }
|
1107 | };
|
1108 |
|
1109 |
|
1110 | NGY2Item.prototype.CSSFilterSet = function ( eltClass, filter, value, forceRefresh ) {
|
1111 | if( this.eltFilter[eltClass] == undefined ) {
|
1112 | this.eltFilter[eltClass] = { blur: 0, brightness: '100%', grayscale: '0%', sepia: '0%', contrast: '100%', opacity: '100%', saturate: '100%' };
|
1113 | this.eltFilter[eltClass].$elt = this.$getElt(eltClass);
|
1114 | }
|
1115 | this.eltFilter[eltClass][filter] = value;
|
1116 | if( forceRefresh === true ) {
|
1117 | this.eltTransform[eltClass].$elt = this.$getElt(eltClass, true);
|
1118 | }
|
1119 | };
|
1120 |
|
1121 |
|
1122 | NGY2Item.prototype.animate = function ( effect, delay, hoverIn ) {
|
1123 | if( this.$getElt() == null ) { return; }
|
1124 |
|
1125 | var context = {};
|
1126 | context.G = this.G;
|
1127 | context.item = this;
|
1128 | context.effect = effect;
|
1129 | context.hoverIn = hoverIn;
|
1130 | context.cssKind = '';
|
1131 | if( hoverIn ) {
|
1132 |
|
1133 |
|
1134 | if( this.eltEffect[effect.element] == undefined ) {
|
1135 | this.eltEffect[effect.element] = [];
|
1136 | }
|
1137 | if( this.eltEffect[effect.element][effect.type] == undefined ) {
|
1138 | this.eltEffect[effect.element][effect.type] = { initialValue: 0, lastValue: 0 };
|
1139 | }
|
1140 | if( effect.firstKeyframe ) {
|
1141 |
|
1142 | this.eltEffect[effect.element][effect.type] = { initialValue: effect.from, lastValue: effect.from};
|
1143 | }
|
1144 |
|
1145 | context.animeFrom = effect.from;
|
1146 | context.animeTo = effect.to;
|
1147 | context.animeDuration = parseInt(effect.duration);
|
1148 | context.animeDelay = 30 + parseInt(effect.delay + delay);
|
1149 | context.animeEasing = effect.easing;
|
1150 | }
|
1151 | else {
|
1152 |
|
1153 |
|
1154 | context.animeFrom = this.eltEffect[effect.element][effect.type].lastValue;
|
1155 | context.animeTo = this.eltEffect[effect.element][effect.type].initialValue;
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 | context.animeDuration = parseInt(effect.durationBack);
|
1167 | context.animeDelay = 30 + parseInt(effect.delayBack + delay);
|
1168 | context.animeEasing = effect.easingBack;
|
1169 | }
|
1170 |
|
1171 |
|
1172 |
|
1173 | var transform=['translateX', 'translateY', 'translateZ', 'scale', 'rotateX', 'rotateY', 'rotateZ'];
|
1174 | for( var i = 0; i < transform.length; i++ ) {
|
1175 | if( effect.type == transform[i] ) {
|
1176 | context.cssKind = 'transform';
|
1177 | break;
|
1178 | }
|
1179 | }
|
1180 |
|
1181 |
|
1182 | var filter=['blur', 'brightness', 'grayscale', 'sepia', 'contrast', 'opacity', 'saturate'];
|
1183 | for( var i = 0; i < filter.length; i++ ) {
|
1184 | if( effect.type == filter[i] ) {
|
1185 | context.cssKind = 'filter';
|
1186 | break;
|
1187 | }
|
1188 | }
|
1189 |
|
1190 | if( hoverIn && effect.element == '.nGY2GThumbnail' && ( effect.type == 'scale' || effect.type == 'rotateX') ) {
|
1191 | this.G.GOM.lastZIndex++;
|
1192 | this.$getElt(effect.element).css('z-index', this.G.GOM.lastZIndex);
|
1193 |
|
1194 | }
|
1195 |
|
1196 |
|
1197 | var tweenable = new NGTweenable();
|
1198 | context.tweenable=tweenable;
|
1199 | tweenable.tween({
|
1200 | attachment: context,
|
1201 | from: { 'v': context.animeFrom },
|
1202 | to: { 'v': context.animeTo },
|
1203 | duration: context.animeDuration,
|
1204 | delay: context.animeDelay,
|
1205 | easing: context.animeEasing,
|
1206 |
|
1207 | step: function (state, att) {
|
1208 | if( att.item.$getElt() == null ) {
|
1209 |
|
1210 | att.tweenable.stop(false);
|
1211 |
|
1212 | return;
|
1213 | }
|
1214 | if( att.hoverIn && !att.item.hovered ) {
|
1215 |
|
1216 | att.tweenable.stop(false);
|
1217 |
|
1218 | return;
|
1219 | }
|
1220 |
|
1221 | if( att.G.VOM.viewerDisplayed ) {
|
1222 | att.tweenable.stop(false);
|
1223 |
|
1224 | return;
|
1225 | }
|
1226 |
|
1227 |
|
1228 | if( state.v == att.animeFrom ) { return; }
|
1229 |
|
1230 | switch( att.cssKind ) {
|
1231 | case 'transform':
|
1232 |
|
1233 | att.item.CSSTransformSet(att.effect.element, att.effect.type, state.v);
|
1234 | att.item.CSSTransformApply( att.effect.element );
|
1235 |
|
1236 | break;
|
1237 | case 'filter':
|
1238 |
|
1239 | att.item.CSSFilterSet(att.effect.element, att.effect.type, state.v);
|
1240 | att.item.CSSFilterApply( att.effect.element );
|
1241 |
|
1242 | break;
|
1243 | default:
|
1244 | var v=state.v;
|
1245 | if( state.v.substring(0,4) == 'rgb(' || state.v.substring(0,5) == 'rgba(' ) {
|
1246 |
|
1247 |
|
1248 | v = ShadeBlendConvert(0, v);
|
1249 | }
|
1250 |
|
1251 | att.item.$getElt( att.effect.element ).css( att.effect.type, v );
|
1252 |
|
1253 | break;
|
1254 | }
|
1255 | if( hoverIn ) {
|
1256 |
|
1257 | att.item.eltEffect[att.effect.element][att.effect.type].lastValue = state.v;
|
1258 | }
|
1259 | },
|
1260 |
|
1261 | finish: function (state, att) {
|
1262 | if( hoverIn ) {
|
1263 |
|
1264 | att.item.eltEffect[att.effect.element][att.effect.type].lastValue = state.v;
|
1265 | }
|
1266 |
|
1267 | if( att.item.$getElt() == null ) {
|
1268 |
|
1269 | return;
|
1270 | }
|
1271 | if( att.hoverIn && !att.item.hovered ) {
|
1272 |
|
1273 | return;
|
1274 | }
|
1275 |
|
1276 | if( att.G.VOM.viewerDisplayed ) {
|
1277 | return;
|
1278 | }
|
1279 |
|
1280 |
|
1281 | switch( att.cssKind ) {
|
1282 | case 'transform':
|
1283 | att.item.CSSTransformSet(att.effect.element, att.effect.type, att.animeTo);
|
1284 | att.item.CSSTransformApply(att.effect.element);
|
1285 | break;
|
1286 | case 'filter':
|
1287 | att.item.CSSFilterSet(att.effect.element, att.effect.type, att.animeTo);
|
1288 | att.item.CSSFilterApply(att.effect.element);
|
1289 | break;
|
1290 | default:
|
1291 | att.item.$getElt(att.effect.element).css(att.effect.type, att.animeTo);
|
1292 | break;
|
1293 | }
|
1294 |
|
1295 | }
|
1296 | });
|
1297 | };
|
1298 |
|
1299 | return NGY2Item;
|
1300 | })();
|
1301 |
|
1302 | }
|
1303 |
|
1304 | _this.options = jQuery.extend(true, {}, jQuery.nanogallery2.defaultOptions, options);
|
1305 |
|
1306 | _this.nG2 = null;
|
1307 | _this.nG2 = new nanoGALLERY2();
|
1308 | _this.nG2.initiateGallery2(_this.e, _this.options );
|
1309 |
|
1310 | };
|
1311 |
|
1312 |
|
1313 | _this.test = function() {
|
1314 |
|
1315 |
|
1316 |
|
1317 |
|
1318 |
|
1319 | }
|
1320 |
|
1321 |
|
1322 |
|
1323 | _this.init();
|
1324 | };
|
1325 |
|
1326 | jQuery.nanogallery2.defaultOptions = {
|
1327 | kind : '',
|
1328 | userID : '',
|
1329 | photoset : '',
|
1330 | album: '',
|
1331 | blockList : 'scrapbook|profil|auto backup',
|
1332 | tagBlockList: '',
|
1333 | allowList : '',
|
1334 | albumList : '',
|
1335 | albumList2 : null,
|
1336 | RTL : false,
|
1337 | flickrSkipOriginal : true,
|
1338 | flickrAPIKey: '',
|
1339 | breadcrumbAutoHideTopLevel : true,
|
1340 | displayBreadcrumb : true,
|
1341 | breadcrumbOnlyCurrentLevel : true,
|
1342 | breadcrumbHideIcons : true,
|
1343 | theme : 'nGY2',
|
1344 | galleryTheme : 'dark',
|
1345 | viewerTheme : 'dark',
|
1346 | items : null,
|
1347 | itemsBaseURL : '',
|
1348 | thumbnailSelectable : false,
|
1349 | dataProvider: '',
|
1350 | allowHTMLinData: false,
|
1351 | locationHash : true,
|
1352 | slideshowDelay : 3000,
|
1353 | slideshowAutoStart : false,
|
1354 |
|
1355 | debugMode: false,
|
1356 |
|
1357 | titleTranslationMap: null,
|
1358 | galleryDisplayMoreStep : 2,
|
1359 | galleryDisplayMode : 'fullContent',
|
1360 | galleryL1DisplayMode : null,
|
1361 | galleryPaginationMode : 'rectangles',
|
1362 | galleryPaginationTopButtons : true,
|
1363 | galleryMaxRows : 2,
|
1364 | galleryL1MaxRows : null,
|
1365 | galleryLastRowFull: false,
|
1366 | galleryL1LastRowFull: null,
|
1367 | galleryLayoutEngine : 'default',
|
1368 | paginationSwipe: true,
|
1369 | paginationVisiblePages : 10,
|
1370 | galleryFilterTags : false,
|
1371 | galleryL1FilterTags : null,
|
1372 | galleryFilterTagsMode : 'single',
|
1373 | galleryL1FilterTagsMode : null,
|
1374 | galleryMaxItems : 0,
|
1375 | galleryL1MaxItems : null,
|
1376 | gallerySorting : '',
|
1377 | galleryL1Sorting : null,
|
1378 | galleryDisplayTransition : 'none',
|
1379 | galleryL1DisplayTransition : null,
|
1380 | galleryDisplayTransitionDuration : 1000,
|
1381 | galleryL1DisplayTransitionDuration : null,
|
1382 | galleryResizeAnimation : false,
|
1383 | galleryRenderDelay : 10,
|
1384 |
|
1385 | thumbnailCrop : true,
|
1386 | thumbnailL1Crop : null,
|
1387 | thumbnailCropScaleFactor : 1.5,
|
1388 | thumbnailLevelUp : false,
|
1389 | thumbnailAlignment : 'fillWidth',
|
1390 | thumbnailWidth : 300,
|
1391 | thumbnailL1Width : null,
|
1392 | thumbnailHeight : 200,
|
1393 | thumbnailL1Height : null,
|
1394 | thumbnailBaseGridHeight : 0,
|
1395 | thumbnailL1BaseGridHeight : null,
|
1396 | thumbnailGutterWidth : 2,
|
1397 | thumbnailL1GutterWidth : null,
|
1398 | thumbnailGutterHeight : 2,
|
1399 | thumbnailL1GutterHeight : null,
|
1400 | thumbnailBorderVertical : 2,
|
1401 | thumbnailL1BorderVertical : null,
|
1402 | thumbnailBorderHorizontal : 2,
|
1403 | thumbnailL1BorderHorizontal : null,
|
1404 | thumbnailFeaturedKeyword : '*featured',
|
1405 | thumbnailAlbumDisplayImage : false,
|
1406 | thumbnailHoverEffect2 : 'toolsAppear',
|
1407 | thumbnailBuildInit2 : '',
|
1408 | thumbnailStacks : 0,
|
1409 | thumbnailL1Stacks : null,
|
1410 | thumbnailStacksTranslateX : 0,
|
1411 | thumbnailL1StacksTranslateX : null,
|
1412 | thumbnailStacksTranslateY : 0,
|
1413 | thumbnailL1StacksTranslateY : null,
|
1414 | thumbnailStacksTranslateZ : 0,
|
1415 | thumbnailL1StacksTranslateZ : null,
|
1416 | thumbnailStacksRotateX : 0,
|
1417 | thumbnailL1StacksRotateX : null,
|
1418 | thumbnailStacksRotateY : 0,
|
1419 | thumbnailL1StacksRotateY : null,
|
1420 | thumbnailStacksRotateZ : 0,
|
1421 | thumbnailL1StacksRotateZ : null,
|
1422 | thumbnailStacksScale : 0,
|
1423 | thumbnailL1StacksScale : null,
|
1424 | thumbnailDisplayOutsideScreen: true,
|
1425 | thumbnailWaitImageLoaded: true,
|
1426 | thumbnailSliderDelay: 2000,
|
1427 | galleryBuildInit2 : '',
|
1428 | portable : false,
|
1429 | eventsDebounceDelay: 10,
|
1430 |
|
1431 | touchAnimation : false,
|
1432 | touchAnimationL1 : undefined,
|
1433 | touchAutoOpenDelay : 0,
|
1434 |
|
1435 | thumbnailLabel : {
|
1436 | position : 'overImage',
|
1437 | align: 'center',
|
1438 | valign: 'bottom',
|
1439 | display : true,
|
1440 | displayDescription : false,
|
1441 | titleMaxLength : 0,
|
1442 | titleMultiLine : false,
|
1443 | descriptionMaxLength : 0,
|
1444 | descriptionMultiLine : false,
|
1445 | hideIcons : true,
|
1446 | title : ''
|
1447 | },
|
1448 |
|
1449 | thumbnailToolbarImage : { topLeft: 'select', topRight : 'featured' },
|
1450 | thumbnailToolbarAlbum : { topLeft: 'select', topRight : 'counter' },
|
1451 | thumbnailDisplayOrder : '',
|
1452 | thumbnailL1DisplayOrder : null,
|
1453 | thumbnailDisplayInterval : 15,
|
1454 | thumbnailL1DisplayInterval : null,
|
1455 | thumbnailDisplayTransition : 'fadeIn',
|
1456 | thumbnailL1DisplayTransition : null,
|
1457 | thumbnailDisplayTransitionEasing : 'easeOutQuart',
|
1458 | thumbnailL1DisplayTransitionEasing : null,
|
1459 | thumbnailDisplayTransitionDuration: 240,
|
1460 | thumbnailL1DisplayTransitionDuration: null,
|
1461 | thumbnailOpenInLightox : true,
|
1462 | thumbnailOpenOriginal : false,
|
1463 |
|
1464 | lightboxStandalone: false,
|
1465 | viewer : 'internal',
|
1466 | viewerFullscreen: false,
|
1467 | imageTransition : 'swipe2',
|
1468 | viewerTransitionMediaKind : 'img',
|
1469 | viewerZoom : true,
|
1470 | viewerImageDisplay : '',
|
1471 | openOnStart : '',
|
1472 | viewerHideToolsDelay : 4000,
|
1473 | viewerToolbar : {
|
1474 | display : false,
|
1475 | position : 'bottom',
|
1476 | fullWidth : false,
|
1477 | align : 'center',
|
1478 | autoMinimize : 0,
|
1479 | standard : 'minimizeButton,label',
|
1480 | minimized : 'minimizeButton,label,infoButton,shareButton,fullscreenButton'
|
1481 | },
|
1482 | viewerTools : {
|
1483 | topLeft : 'pageCounter,playPauseButton',
|
1484 | topRight : 'rotateLeft,rotateRight,fullscreenButton,closeButton'
|
1485 | },
|
1486 | viewerGallery: 'bottomOverMedia',
|
1487 | viewerGalleryTWidth: 40,
|
1488 | viewerGalleryTHeight: 40,
|
1489 |
|
1490 | breakpointSizeSM : 480,
|
1491 | breakpointSizeME : 992,
|
1492 | breakpointSizeLA : 1200,
|
1493 | breakpointSizeXL : 1800,
|
1494 |
|
1495 | fnThumbnailInit : null,
|
1496 | fnThumbnailHoverInit : null,
|
1497 | fnThumbnailHover : null,
|
1498 | fnThumbnailHoverOut : null,
|
1499 | fnThumbnailDisplayEffect : null,
|
1500 | fnViewerInfo : null,
|
1501 | fnImgToolbarCustInit : null,
|
1502 | fnImgToolbarCustDisplay : null,
|
1503 | fnImgToolbarCustClick : null,
|
1504 | fnProcessData : null,
|
1505 | fnThumbnailSelection : null,
|
1506 | fnGalleryRenderStart : null,
|
1507 | fnGalleryRenderEnd : null,
|
1508 | fnGalleryObjectModelBuilt : null,
|
1509 | fnGalleryLayoutApplied : null,
|
1510 | fnThumbnailClicked : null,
|
1511 | fnShoppingCartUpdated : null,
|
1512 | fnThumbnailToolCustAction : null,
|
1513 | fnThumbnailOpen : null,
|
1514 | fnImgDisplayed : null,
|
1515 | fnPopupMediaInfo : null,
|
1516 |
|
1517 | i18n : {
|
1518 | 'breadcrumbHome' : 'Galleries', 'breadcrumbHome_FR' : 'Galeries',
|
1519 | 'thumbnailImageTitle' : '', 'thumbnailAlbumTitle' : '',
|
1520 | 'thumbnailImageDescription' : '', 'thumbnailAlbumDescription' : '',
|
1521 | 'infoBoxPhoto' : 'Photo', 'infoBoxDate' : 'Date', 'infoBoxAlbum' : 'Album', 'infoBoxDimensions' : 'Dimensions', 'infoBoxFilename' : 'Filename', 'infoBoxFileSize' : 'File size', 'infoBoxCamera' : 'Camera', 'infoBoxFocalLength' : 'Focal length', 'infoBoxExposure' : 'Exposure', 'infoBoxFNumber' : 'F Number', 'infoBoxISO' : 'ISO', 'infoBoxMake' : 'Make', 'infoBoxFlash' : 'Flash', 'infoBoxViews' : 'Views', 'infoBoxComments' : 'Comments'
|
1522 | },
|
1523 | icons : {
|
1524 |
|
1525 | thumbnailAlbum: '<i class="nGY2Icon-folder-empty"></i>',
|
1526 | thumbnailImage: '<i class="nGY2Icon-picture"></i>',
|
1527 | breadcrumbAlbum: '<i class="nGY2Icon-folder-empty"></i>',
|
1528 | breadcrumbHome: '<i class="nGY2Icon-home"></i>',
|
1529 | breadcrumbSeparator: '<i class="nGY2Icon-left-open"></i>',
|
1530 | breadcrumbSeparatorRtl: '<i class="nGY2Icon-right-open"></i>',
|
1531 | navigationFilterSelected: '<i style="color:#fff;" class="nGY2Icon-ok"></i>',
|
1532 | navigationFilterUnselected: '<i style="color:#ddd;opacity:0.3;" class="nGY2Icon-circle-empty"></i>',
|
1533 | navigationFilterSelectedAll: '<i class="nGY2Icon-ccw"></i>',
|
1534 | navigationPaginationPrevious: '<i class="nGY2Icon-ngy2_chevron-left"></i>',
|
1535 | navigationPaginationNext: '<i class="nGY2Icon-ngy2_chevron-right"></i>',
|
1536 | thumbnailSelected: '<i style="color:#bff;" class="nGY2Icon-ok-circled"></i>',
|
1537 | thumbnailUnselected: '<i style="color:#bff;" class="nGY2Icon-circle-empty"></i>',
|
1538 | thumbnailFeatured: '<i style="color:#dd5;" class="nGY2Icon-star"></i>',
|
1539 | thumbnailCounter: '<i class="nGY2Icon-picture"></i>',
|
1540 | thumbnailShare: '<i class="nGY2Icon-ngy2_share2"></i>',
|
1541 | thumbnailDownload: '<i class="nGY2Icon-ngy2_download2"></i>',
|
1542 | thumbnailInfo: '<i class="nGY2Icon-ngy2_info2"></i>',
|
1543 | thumbnailShoppingcart: '<i class="nGY2Icon-basket"></i>',
|
1544 | thumbnailDisplay: '<i class="nGY2Icon-resize-full"></i>',
|
1545 | thumbnailCustomTool1: 'T1',
|
1546 | thumbnailCustomTool2: 'T2',
|
1547 | thumbnailCustomTool3: 'T3',
|
1548 | thumbnailCustomTool4: 'T4',
|
1549 | thumbnailCustomTool5: 'T5',
|
1550 | thumbnailCustomTool6: 'T6',
|
1551 | thumbnailCustomTool7: 'T7',
|
1552 | thumbnailCustomTool8: 'T8',
|
1553 | thumbnailCustomTool9: 'T9',
|
1554 | thumbnailCustomTool10: 'T10',
|
1555 | thumbnailAlbumUp: '<i style="font-size: 3em;" class="nGY2Icon-ngy2_chevron_up2"></i>',
|
1556 | paginationNext: '<i class="nGY2Icon-right-open"></i>',
|
1557 | paginationPrevious: '<i class="nGY2Icon-left-open"></i>',
|
1558 | galleryMoreButton: '<i class="nGY2Icon-picture"></i> <i class="nGY2Icon-right-open"></i>',
|
1559 | buttonClose: '<i class="nGY2Icon-ngy2_close2"></i>',
|
1560 | viewerPrevious: '<i class="nGY2Icon-ngy2_chevron-left"></i>',
|
1561 | viewerNext: '<i class="nGY2Icon-ngy2_chevron-right"></i>',
|
1562 | viewerImgPrevious: '<i class="nGY2Icon-ngy2_chevron_left3"></i>',
|
1563 | viewerImgNext: '<i class="nGY2Icon-ngy2_chevron_right3"></i>',
|
1564 | viewerDownload: '<i class="nGY2Icon-ngy2_download2"></i>',
|
1565 | viewerToolbarMin: '<i class="nGY2Icon-ellipsis-vert"></i>',
|
1566 | viewerToolbarStd: '<i class="nGY2Icon-menu"></i>',
|
1567 | viewerPlay: '<i class="nGY2Icon-play"></i>',
|
1568 | viewerPause: '<i class="nGY2Icon-pause"></i>',
|
1569 | viewerFullscreenOn: '<i class="nGY2Icon-resize-full"></i>',
|
1570 | viewerFullscreenOff: '<i class="nGY2Icon-resize-small"></i>',
|
1571 | viewerZoomIn: '<i class="nGY2Icon-ngy2_zoom_in2"></i>',
|
1572 | viewerZoomOut: '<i class="nGY2Icon-ngy2_zoom_out2"></i>',
|
1573 | viewerLinkOriginal: '<i class="nGY2Icon-ngy2_external2"></i>',
|
1574 | viewerInfo: '<i class="nGY2Icon-ngy2_info2"></i>',
|
1575 | viewerShare: '<i class="nGY2Icon-ngy2_share2"></i>',
|
1576 | viewerRotateLeft: '<i class="nGY2Icon-ccw"></i>',
|
1577 | viewerRotateRight: '<i class="nGY2Icon-cw"></i>',
|
1578 | viewerShoppingcart: '<i class="nGY2Icon-basket"></i>',
|
1579 | user: '<i class="nGY2Icon-user"></i>',
|
1580 | location: '<i class="nGY2Icon-location"></i>',
|
1581 | picture: '<i class="nGY2Icon-picture"></i>',
|
1582 | config: '<i class="nGY2Icon-wrench"></i>',
|
1583 | shareFacebook: '<i style="color:#3b5998;" class="nGY2Icon-facebook-squared"></i>',
|
1584 | shareTwitter: '<i style="color:#00aced;" class="nGY2Icon-twitter-squared"></i>',
|
1585 |
|
1586 | shareTumblr: '<i style="color:#32506d;" class="nGY2Icon-tumblr-squared"></i>',
|
1587 | sharePinterest: '<i style="color:#cb2027;" class="nGY2Icon-pinterest-squared"></i>',
|
1588 | shareVK: '<i style="color:#3b5998;" class="nGY2Icon-vkontakte"></i>',
|
1589 | shareMail: '<i style="color:#555;" class="nGY2Icon-mail-alt"></i>',
|
1590 | viewerCustomTool1: 'T1',
|
1591 | viewerCustomTool2: 'T2',
|
1592 | viewerCustomTool3: 'T3',
|
1593 | viewerCustomTool4: 'T4',
|
1594 | viewerCustomTool5: 'T5',
|
1595 | viewerCustomTool6: 'T6',
|
1596 | viewerCustomTool7: 'T7',
|
1597 | viewerCustomTool8: 'T8',
|
1598 | viewerCustomTool9: 'T9',
|
1599 | viewerCustomTool10: 'T10'
|
1600 | }
|
1601 | };
|
1602 |
|
1603 | jQuery.fn.nanogallery2 = function (args, option, value) {
|
1604 |
|
1605 | if( typeof jQuery(this).data('nanogallery2data') === 'undefined'){
|
1606 | if( args == 'destroy' ) {
|
1607 |
|
1608 | return;
|
1609 | }
|
1610 |
|
1611 | return this.each( function(){
|
1612 | (new jQuery.nanogallery2(this, args));
|
1613 | });
|
1614 | }
|
1615 | else {
|
1616 |
|
1617 |
|
1618 | var nG2 = $(this).data('nanogallery2data').nG2;
|
1619 |
|
1620 |
|
1621 |
|
1622 | if( args !== undefined && args.lightboxStandalone === true ) {
|
1623 |
|
1624 | nG2.LightboxReOpen();
|
1625 | return;
|
1626 | }
|
1627 |
|
1628 | switch(args){
|
1629 | case 'displayItem':
|
1630 | nG2.DisplayItem(option);
|
1631 | break;
|
1632 |
|
1633 | case 'search':
|
1634 | return( nG2.Search(option));
|
1635 | break;
|
1636 |
|
1637 | case 'search2':
|
1638 | return nG2.Search2(option, value);
|
1639 | break;
|
1640 |
|
1641 | case 'search2Execute':
|
1642 | return nG2.Search2Execute();
|
1643 | break;
|
1644 |
|
1645 | case 'refresh':
|
1646 | nG2.Refresh();
|
1647 | break;
|
1648 |
|
1649 | case 'resize':
|
1650 | nG2.Resize();
|
1651 | break;
|
1652 |
|
1653 | case 'instance':
|
1654 | return nG2;
|
1655 | break;
|
1656 |
|
1657 | case 'data':
|
1658 | nG2.data= {
|
1659 | items: nG2.I,
|
1660 | gallery: nG2.GOM,
|
1661 | lightbox: nG2.VOM,
|
1662 | shoppingcart: nG2.shoppingCart
|
1663 | };
|
1664 | return nG2.data;
|
1665 | break;
|
1666 |
|
1667 | case 'reload':
|
1668 | nG2.ReloadAlbum();
|
1669 | return $(this);
|
1670 | break;
|
1671 |
|
1672 | case 'itemsSelectedGet':
|
1673 | return nG2.ItemsSelectedGet();
|
1674 | break;
|
1675 |
|
1676 | case 'itemsSetSelectedValue':
|
1677 | nG2.ItemsSetSelectedValue(option, value);
|
1678 | break;
|
1679 |
|
1680 | case 'option':
|
1681 | if(typeof value === 'undefined'){
|
1682 | return nG2.Get(option);
|
1683 | }else{
|
1684 | nG2.Set(option,value);
|
1685 | if( option == 'demoViewportWidth' ) {
|
1686 |
|
1687 | $(window).trigger('resize');
|
1688 | }
|
1689 | }
|
1690 | break;
|
1691 |
|
1692 | case 'destroy':
|
1693 | nG2.Destroy();
|
1694 | $(this).removeData('nanogallery2data');
|
1695 | break;
|
1696 |
|
1697 | case 'shoppingCartGet':
|
1698 |
|
1699 | return nG2.shoppingCart;
|
1700 | break;
|
1701 |
|
1702 | case 'shoppingCartUpdate':
|
1703 |
|
1704 |
|
1705 |
|
1706 |
|
1707 | if( typeof value === 'undefined' || typeof option === 'undefined' ){
|
1708 | return false;
|
1709 | }
|
1710 |
|
1711 | var item_ID = option;
|
1712 | var new_qty = value;
|
1713 |
|
1714 | for( var i=0; i < nG2.shoppingCart.length; i++) {
|
1715 | if( nG2.shoppingCart[i].ID == item_ID ) {
|
1716 |
|
1717 |
|
1718 | nG2.shoppingCart[i].qty = new_qty;
|
1719 |
|
1720 | let item = nG2.I[nG2.shoppingCart[i].idx];
|
1721 |
|
1722 |
|
1723 | nG2.ThumbnailToolbarOneCartUpdate( item );
|
1724 |
|
1725 | if( new_qty == 0 ) {
|
1726 |
|
1727 | nG2.shoppingCart.splice(i, 1);
|
1728 | }
|
1729 |
|
1730 | var fu = nG2.O.fnShoppingCartUpdated;
|
1731 | if( fu !== null ) {
|
1732 | typeof fu == 'function' ? fu(nG2.shoppingCart, item, 'api') : window[fu](nG2.shoppingCart, item, 'api');
|
1733 | }
|
1734 |
|
1735 | break;
|
1736 | }
|
1737 | }
|
1738 |
|
1739 | return nG2.shoppingCart;
|
1740 | break;
|
1741 |
|
1742 | case 'shoppingCartRemove':
|
1743 |
|
1744 |
|
1745 | if( typeof option === 'undefined' ){
|
1746 | return false;
|
1747 | }
|
1748 | var ID = option;
|
1749 | for( var i=0; i < nG2.shoppingCart.length; i++) {
|
1750 | if( nG2.shoppingCart[i].ID == ID ) {
|
1751 |
|
1752 | var item = nG2.I[nG2.shoppingCart[i].idx];
|
1753 |
|
1754 |
|
1755 | nG2.shoppingCart[i].qty = 0;
|
1756 | nG2.ThumbnailToolbarOneCartUpdate( item );
|
1757 |
|
1758 |
|
1759 | nG2.shoppingCart.splice(i, 1);
|
1760 |
|
1761 |
|
1762 | var fu = nG2.O.fnShoppingCartUpdated;
|
1763 | if( fu !== null ) {
|
1764 | typeof fu == 'function' ? fu(nG2.shoppingCart, item, 'api') : window[fu](nG2.shoppingCart, item, 'api');
|
1765 | }
|
1766 |
|
1767 | break;
|
1768 | }
|
1769 | }
|
1770 |
|
1771 | return nG2.shoppingCart;
|
1772 | break;
|
1773 |
|
1774 | case 'closeViewer':
|
1775 | nG2.CloseViewer();
|
1776 | break;
|
1777 | case 'minimizeToolbar':
|
1778 | nG2.MinimizeToolbar();
|
1779 | break;
|
1780 | case 'maximizeToolbar':
|
1781 | nG2.MaximizeToolbar();
|
1782 | break;
|
1783 | case 'paginationPreviousPage':
|
1784 | nG2.PaginationPreviousPage();
|
1785 | break;
|
1786 | case 'paginationNextPage':
|
1787 | nG2.paginationNextPage();
|
1788 | break;
|
1789 | case 'paginationGotoPage':
|
1790 | nG2.PaginationGotoPage( option );
|
1791 | break;
|
1792 | case 'paginationCountPages':
|
1793 | nG2.PaginationCountPages();
|
1794 | break;
|
1795 |
|
1796 | }
|
1797 | return $(this);
|
1798 |
|
1799 | }
|
1800 | };
|
1801 |
|
1802 |
|
1803 |
|
1804 |
|
1805 |
|
1806 |
|
1807 |
|
1808 | function nanoGALLERY2() {
|
1809 | "use strict";
|
1810 |
|
1811 | |
1812 |
|
1813 |
|
1814 | this.LightboxReOpen = function(){
|
1815 | LightboxStandaloneDisplay();
|
1816 | }
|
1817 |
|
1818 | |
1819 |
|
1820 |
|
1821 | this.ReloadAlbum = function(){
|
1822 | if( G.O.kind === '' ) {
|
1823 | throw 'Not supported for this content source:' + G.O.kind;
|
1824 | }
|
1825 |
|
1826 | var albumIdx = G.GOM.albumIdx;
|
1827 | if( albumIdx == -1 ) {
|
1828 | throw ('Current album not found.');
|
1829 | }
|
1830 |
|
1831 | var albumID = G.I[albumIdx].GetID();
|
1832 |
|
1833 |
|
1834 | var l = G.I.length;
|
1835 | for( var i = 0; i < l ; i++ ) {
|
1836 | var item = G.I[i];
|
1837 | if( item.albumID == albumID ) {
|
1838 | item.selected = false;
|
1839 | }
|
1840 | }
|
1841 |
|
1842 | G.I[albumIdx].contentIsLoaded = false;
|
1843 |
|
1844 | DisplayAlbum('-1', albumID);
|
1845 | };
|
1846 |
|
1847 | |
1848 |
|
1849 |
|
1850 |
|
1851 | this.ItemsSetSelectedValue = function(items, value){
|
1852 | var l = items.length;
|
1853 | for( var j = 0; j < l ; j++) {
|
1854 | ThumbnailSelectionSet(items[j], value);
|
1855 | }
|
1856 | };
|
1857 |
|
1858 | |
1859 |
|
1860 |
|
1861 |
|
1862 | this.ItemsSelectedGet = function(){
|
1863 | var selectedItems = [];
|
1864 | var l = G.I.length;
|
1865 | for( var i = 0; i < l ; i++ ) {
|
1866 | if( G.I[i].selected == true ) {
|
1867 | selectedItems.push(G.I[i]);
|
1868 | }
|
1869 | }
|
1870 | return selectedItems;
|
1871 | };
|
1872 |
|
1873 | |
1874 |
|
1875 |
|
1876 |
|
1877 |
|
1878 | this.Get = function(option){
|
1879 | return G.O[option];
|
1880 | };
|
1881 |
|
1882 | |
1883 |
|
1884 |
|
1885 |
|
1886 | this.Set = function(option, value){
|
1887 | G.O[option] = value;
|
1888 | switch( option ) {
|
1889 | case 'thumbnailSelectable':
|
1890 | ThumbnailSelectionClear();
|
1891 |
|
1892 | GalleryRender( G.GOM.albumIdx );
|
1893 | break;
|
1894 | }
|
1895 | };
|
1896 |
|
1897 | |
1898 |
|
1899 |
|
1900 | this.Refresh = function() {
|
1901 |
|
1902 | GalleryRender( G.GOM.albumIdx );
|
1903 | };
|
1904 | |
1905 |
|
1906 |
|
1907 | this.Resize = function() {
|
1908 |
|
1909 | GalleryResize();
|
1910 | };
|
1911 |
|
1912 | |
1913 |
|
1914 |
|
1915 |
|
1916 |
|
1917 |
|
1918 | this.DisplayItem = function( itemID ) {
|
1919 | var IDs=parseIDs( itemID );
|
1920 | if( IDs.imageID != '0' ) {
|
1921 | DisplayPhoto( IDs.imageID, IDs.albumID );
|
1922 | }
|
1923 | else {
|
1924 | DisplayAlbum( '-1', IDs.albumID );
|
1925 | }
|
1926 | };
|
1927 |
|
1928 | this.ThumbnailToolbarOneCartUpdate = function ( item ) {
|
1929 | ThumbnailBuildToolbarOneCartUpdate( item );
|
1930 | }
|
1931 |
|
1932 |
|
1933 |
|
1934 | var CountItemsToDisplay = function( gIdx ) {
|
1935 | if( G.I[gIdx] == undefined ) { return 0; }
|
1936 | var albumID = G.I[gIdx].GetID();
|
1937 | var l = G.I.length;
|
1938 | var cnt = 0;
|
1939 | for( var idx = 0; idx < l; idx++ ) {
|
1940 | var item = G.I[idx];
|
1941 | if( item.isToDisplay(albumID) ) {
|
1942 | cnt++;
|
1943 | }
|
1944 | }
|
1945 | return cnt;
|
1946 | }
|
1947 | |
1948 |
|
1949 |
|
1950 | this.Search = function( search ) {
|
1951 | G.GOM.albumSearch = search.toUpperCase();
|
1952 | var gIdx = G.GOM.albumIdx;
|
1953 | GalleryRender( G.GOM.albumIdx );
|
1954 | return CountItemsToDisplay( gIdx );
|
1955 | };
|
1956 |
|
1957 | |
1958 |
|
1959 |
|
1960 | this.Search2 = function( searchTitle, searchTags ) {
|
1961 | if( searchTitle != undefined && searchTitle != null ) {
|
1962 | G.GOM.albumSearch = searchTitle.toUpperCase().trim();
|
1963 | }
|
1964 | else {
|
1965 | G.GOM.albumSearch = '';
|
1966 | }
|
1967 |
|
1968 | if( searchTags != null && searchTags != undefined ) {
|
1969 | G.GOM.albumSearchTags = searchTags.toUpperCase().trim();
|
1970 | }
|
1971 | else {
|
1972 | G.GOM.albumSearchTags = '';
|
1973 | }
|
1974 | return CountItemsToDisplay( G.GOM.albumIdx );
|
1975 | };
|
1976 |
|
1977 | |
1978 |
|
1979 |
|
1980 | this.Search2Execute = function() {
|
1981 | var gIdx = G.GOM.albumIdx;
|
1982 | GalleryRender( G.GOM.albumIdx );
|
1983 | return CountItemsToDisplay( gIdx );
|
1984 | };
|
1985 |
|
1986 |
|
1987 | |
1988 |
|
1989 |
|
1990 | this.Destroy = function(){
|
1991 |
|
1992 | if( G.GOM.hammertime != null ) {
|
1993 | G.GOM.hammertime.destroy();
|
1994 | G.GOM.hammertime = null;
|
1995 | }
|
1996 |
|
1997 | if( G.VOM.hammertime != null ) {
|
1998 | G.VOM.hammertime.destroy();
|
1999 | G.VOM.hammertime = null;
|
2000 | }
|
2001 |
|
2002 |
|
2003 | $('#ngycs_' + G.baseEltID).remove()
|
2004 |
|
2005 | G.GOM.items = [];
|
2006 | NGY2Item.New( G, G.i18nTranslations.breadcrumbHome, '', '0', '-1', 'album' );
|
2007 | G.GOM.navigationBar.$newContent = null;
|
2008 | G.$E.base.empty();
|
2009 | G.$E.base.removeData();
|
2010 | if( G.O.locationHash ) {
|
2011 | jQuery(window).off('hashchange.nanogallery2.' + G.baseEltID);
|
2012 | }
|
2013 |
|
2014 | jQuery(window).off('resize.nanogallery2.' + G.baseEltID);
|
2015 | jQuery(window).off('orientationChange.nanogallery2.' + G.baseEltID);
|
2016 | jQuery(window).off('scroll.nanogallery2.' + G.baseEltID);
|
2017 | if( G.$E.scrollableParent !== null ) {
|
2018 | G.$E.scrollableParent.off('scroll.nanogallery2.' + G.baseEltID);
|
2019 | }
|
2020 | G.GOM.firstDisplay = true;
|
2021 | };
|
2022 |
|
2023 | |
2024 |
|
2025 |
|
2026 | this.CloseViewer = function() {
|
2027 | LightboxClose(null);
|
2028 | return false;
|
2029 | };
|
2030 |
|
2031 | |
2032 |
|
2033 |
|
2034 | this.MinimizeToolbar = function() {
|
2035 | ViewerToolbarForVisibilityMin();
|
2036 | return false;
|
2037 | };
|
2038 |
|
2039 | |
2040 |
|
2041 |
|
2042 | this.MaximizeToolbar = function() {
|
2043 | ViewerToolbarForVisibilityStd();
|
2044 | return false;
|
2045 | };
|
2046 |
|
2047 | |
2048 |
|
2049 |
|
2050 | this.PaginationPreviousPage = function() {
|
2051 | paginationPreviousPage();
|
2052 | return false;
|
2053 | };
|
2054 |
|
2055 |
|
2056 | |
2057 |
|
2058 |
|
2059 | this.PaginationNextPage = function() {
|
2060 | paginationNextPage();
|
2061 | return false;
|
2062 | };
|
2063 |
|
2064 |
|
2065 | |
2066 |
|
2067 |
|
2068 | this.PaginationGotoPage = function( page ) {
|
2069 |
|
2070 | if( page > 1 ) { page--; }
|
2071 | G.GOM.pagination.currentPage = page;
|
2072 |
|
2073 |
|
2074 | G.GOM.ScrollToTop();
|
2075 |
|
2076 | GalleryDisplayPart1();
|
2077 | GalleryDisplayPart2( true );
|
2078 | return false;
|
2079 | };
|
2080 |
|
2081 | |
2082 |
|
2083 |
|
2084 | this.PaginationCountPages = function() {
|
2085 | if( G.GOM.items.length == 0 ) { return 0; }
|
2086 |
|
2087 | var nbPages = Math.ceil((G.GOM.items[G.GOM.items.length - 1].row + 1) / G.galleryMaxRows.Get());
|
2088 | return nbPages;
|
2089 | };
|
2090 |
|
2091 | |
2092 |
|
2093 |
|
2094 |
|
2095 |
|
2096 |
|
2097 |
|
2098 |
|
2099 |
|
2100 |
|
2101 |
|
2102 |
|
2103 | var throttle = function(func, wait, options) {
|
2104 | var context, args, result;
|
2105 | var timeout = null;
|
2106 | var previous = 0;
|
2107 | if (!options) options = {};
|
2108 | var later = function() {
|
2109 | previous = options.leading === false ? 0 : new Date().getTime();
|
2110 | timeout = null;
|
2111 | result = func.apply(context, args);
|
2112 | if (!timeout) context = args = null;
|
2113 | };
|
2114 | return function() {
|
2115 | var now = new Date().getTime();
|
2116 | if (!previous && options.leading === false) previous = now;
|
2117 | var remaining = wait - (now - previous);
|
2118 | context = this;
|
2119 | args = arguments;
|
2120 | if (remaining <= 0 || remaining > wait) {
|
2121 | if (timeout) {
|
2122 | clearTimeout(timeout);
|
2123 | timeout = null;
|
2124 | }
|
2125 | previous = now;
|
2126 | result = func.apply(context, args);
|
2127 | if (!timeout) context = args = null;
|
2128 | } else if (!timeout && options.trailing !== false) {
|
2129 | timeout = setTimeout(later, remaining);
|
2130 | }
|
2131 | return result;
|
2132 | };
|
2133 | };
|
2134 |
|
2135 |
|
2136 |
|
2137 |
|
2138 |
|
2139 | var debounce = function (func, threshold, execAsap) {
|
2140 | var timeout;
|
2141 | return function debounced () {
|
2142 | var obj = this, args = arguments;
|
2143 | function delayed () {
|
2144 | if (!execAsap)
|
2145 | func.apply(obj, args);
|
2146 | timeout = null;
|
2147 | };
|
2148 |
|
2149 | if (timeout)
|
2150 | clearTimeout(timeout);
|
2151 |
|
2152 | else if (execAsap)
|
2153 | func.apply(obj, args);
|
2154 | timeout = setTimeout(delayed, threshold || 100);
|
2155 |
|
2156 | };
|
2157 | }
|
2158 |
|
2159 |
|
2160 |
|
2161 | window.ng_draf = function (cb) {
|
2162 | return requestAnimationFrame(function() {
|
2163 | window.requestAnimationFrame(cb)
|
2164 | })
|
2165 | }
|
2166 |
|
2167 |
|
2168 | |
2169 |
|
2170 |
|
2171 |
|
2172 |
|
2173 |
|
2174 | window.requestTimeout = function(fn, delay) {
|
2175 | if( !window.requestAnimationFrame &&
|
2176 | !window.webkitRequestAnimationFrame &&
|
2177 | !(window.mozRequestAnimationFrame && window.mozCancelRequestAnimationFrame) &&
|
2178 | !window.oRequestAnimationFrame &&
|
2179 | !window.msRequestAnimationFrame)
|
2180 | return window.setTimeout(fn, delay);
|
2181 |
|
2182 | var start = new Date().getTime(),
|
2183 | handle = new Object();
|
2184 |
|
2185 | function loop(){
|
2186 | var current = new Date().getTime(),
|
2187 | delta = current - start;
|
2188 |
|
2189 |
|
2190 | delta >= delay ? fn.call() : handle.value = requestAnimFrame(loop);
|
2191 | };
|
2192 |
|
2193 | handle.value = requestAnimFrame(loop);
|
2194 | return handle;
|
2195 | };
|
2196 |
|
2197 |
|
2198 |
|
2199 |
|
2200 | window.requestAnimFrame = (function() {
|
2201 | return window.requestAnimationFrame ||
|
2202 | window.webkitRequestAnimationFrame ||
|
2203 | window.mozRequestAnimationFrame ||
|
2204 | window.oRequestAnimationFrame ||
|
2205 | window.msRequestAnimationFrame ||
|
2206 | function(/* function */ callback, /* DOMElement */ element){
|
2207 | window.setTimeout(callback, 1000 / 60);
|
2208 | };
|
2209 | })();
|
2210 |
|
2211 |
|
2212 |
|
2213 | |
2214 |
|
2215 |
|
2216 |
|
2217 | window.clearRequestTimeout = function(handle) {
|
2218 | window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) :
|
2219 | window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) :
|
2220 | window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) :
|
2221 | window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) :
|
2222 | window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) :
|
2223 | window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) :
|
2224 | clearTimeout(handle);
|
2225 | };
|
2226 |
|
2227 |
|
2228 |
|
2229 | |
2230 |
|
2231 |
|
2232 | var G=this;
|
2233 | G.I = [];
|
2234 | G.Id = [];
|
2235 | G.O = null;
|
2236 | G.baseEltID = null;
|
2237 | G.$E = {
|
2238 | base: null,
|
2239 | conTnParent: null,
|
2240 | conLoadingB: null,
|
2241 | conConsole: null,
|
2242 | conNavigationBar: null,
|
2243 | conTnBottom: null,
|
2244 | scrollableParent: null
|
2245 | };
|
2246 | G.shoppingCart = [];
|
2247 | G.layout = {
|
2248 | internal : true,
|
2249 | engine : '',
|
2250 | support : { rows: false },
|
2251 | prerequisite : { imageSize: false },
|
2252 | SetEngine: function() {
|
2253 |
|
2254 | if( G.layout.internal ) {
|
2255 | if( G.tn.settings.width[G.GOM.curNavLevel][G.GOM.curWidth] == 'auto' || G.tn.settings.width[G.GOM.curNavLevel][G.GOM.curWidth] == '' ) {
|
2256 |
|
2257 | G.layout.engine = 'JUSTIFIED';
|
2258 | G.layout.support.rows = true;
|
2259 | G.layout.prerequisite.imageSize = true;
|
2260 | return;
|
2261 | }
|
2262 | if( G.tn.settings.height[G.GOM.curNavLevel][G.GOM.curWidth] == 'auto' || G.tn.settings.height[G.GOM.curNavLevel][G.GOM.curWidth] == '' ) {
|
2263 |
|
2264 | G.layout.engine = 'CASCADING';
|
2265 | G.layout.support.rows = false;
|
2266 | G.layout.prerequisite.imageSize = true;
|
2267 | return;
|
2268 | }
|
2269 |
|
2270 | if( G.tn.settings.getMosaic() != null ) {
|
2271 | G.layout.engine = 'MOSAIC';
|
2272 | G.layout.support.rows = true;
|
2273 | G.layout.prerequisite.imageSize = false;
|
2274 | return;
|
2275 | }
|
2276 |
|
2277 | G.layout.engine = 'GRID';
|
2278 | G.layout.support.rows=true;
|
2279 |
|
2280 |
|
2281 |
|
2282 |
|
2283 | G.layout.prerequisite.imageSize = false;
|
2284 |
|
2285 | }
|
2286 | }
|
2287 | };
|
2288 | G.galleryResizeEventEnabled = false;
|
2289 | G.galleryMaxRows = { l1: 0, lN: 0,
|
2290 | Get: function() {
|
2291 | return G.galleryMaxRows[G.GOM.curNavLevel];
|
2292 | }
|
2293 | };
|
2294 | G.galleryMaxItems = { l1: 0, lN: 0,
|
2295 | Get: function() {
|
2296 | return G.galleryMaxItems[G.GOM.curNavLevel];
|
2297 | }
|
2298 | };
|
2299 | G.galleryFilterTags = { l1: 0, lN: 0,
|
2300 | Get: function() {
|
2301 | return G.galleryFilterTags[G.GOM.curNavLevel];
|
2302 | }
|
2303 | };
|
2304 | G.galleryFilterTagsMode = { l1: 0, lN: 0,
|
2305 | Get: function() {
|
2306 | return G.galleryFilterTagsMode[G.GOM.curNavLevel];
|
2307 | }
|
2308 | };
|
2309 | G.galleryDisplayMode = { l1: 'FULLCONTENT', lN: 'FULLCONTENT',
|
2310 | Get: function() {
|
2311 | return G.galleryDisplayMode[G.GOM.curNavLevel];
|
2312 | }
|
2313 | };
|
2314 | G.galleryLastRowFull = { l1: false, lN: false,
|
2315 | Get: function() {
|
2316 | return G.galleryLastRowFull[G.GOM.curNavLevel];
|
2317 | }
|
2318 | };
|
2319 | G.gallerySorting = { l1: '', lN: '',
|
2320 | Get: function() {
|
2321 | return G.gallerySorting[G.GOM.curNavLevel];
|
2322 | }
|
2323 | };
|
2324 | G.galleryDisplayTransition = { l1: 'none', lN: 'none',
|
2325 | Get: function() {
|
2326 | return G.galleryDisplayTransition[G.GOM.curNavLevel];
|
2327 | }
|
2328 | };
|
2329 | G.galleryDisplayTransitionDuration = { l1: 500, lN: 500,
|
2330 | Get: function() {
|
2331 | return G.galleryDisplayTransitionDuration[G.GOM.curNavLevel];
|
2332 | }
|
2333 | };
|
2334 | G.$currentTouchedThumbnail = null;
|
2335 |
|
2336 |
|
2337 |
|
2338 |
|
2339 |
|
2340 | G.tn = {
|
2341 |
|
2342 | opt: {
|
2343 | l1: { crop: true, stacks: 0, stacksTranslateX: 0, stacksTranslateY: 0, stacksTranslateZ: 0, stacksRotateX: 0, stacksRotateY: 0, stacksRotateZ: 0, stacksScale: 0, borderHorizontal: 0, borderVertical: 0, baseGridHeight: 0, displayTransition: 'FADEIN', displayTransitionStartVal: 0, displayTransitionEasing: 'easeOutQuart', displayTransitionDuration: 240, displayInterval: 15 },
|
2344 | lN: { crop: true, stacks: 0, stacksTranslateX: 0, stacksTranslateY: 0, stacksTranslateZ: 0, stacksRotateX: 0, stacksRotateY: 0, stacksRotateZ: 0, stacksScale: 0, borderHorizontal: 0, borderVertical: 0, baseGridHeight: 0, displayTransition: 'FADEIN', displayTransitionStartVal: 0, displayTransitionEasing: 'easeOutQuart', displayTransitionDuration: 240, displayInterval: 15 },
|
2345 | Get: function(opt) {
|
2346 | return G.tn.opt[G.GOM.curNavLevel][opt];
|
2347 | }
|
2348 | },
|
2349 | scale: 1,
|
2350 | labelHeight: {
|
2351 | l1: 0, lN: 0,
|
2352 | get: function() {
|
2353 | return G.tn.labelHeight[G.GOM.curNavLevel];
|
2354 | }
|
2355 | },
|
2356 | defaultSize: {
|
2357 |
|
2358 | width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
2359 | height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
2360 | getWidth: function() {
|
2361 | return G.tn.defaultSize.width[G.GOM.curNavLevel][G.GOM.curWidth];
|
2362 | },
|
2363 | getOuterWidth: function() {
|
2364 | G.tn.borderWidth = G.tn.opt.Get('borderHorizontal');
|
2365 | G.tn.borderHeight = G.tn.opt.Get('borderVertical');
|
2366 | var w = G.tn.defaultSize.width[G.GOM.curNavLevel][G.GOM.curWidth] + G.tn.opt.Get('borderHorizontal') * 2;
|
2367 | if( G.O.thumbnailLabel.get('position') == 'right' || G.O.thumbnailLabel.get('position') == 'left' ) {
|
2368 | w += G.tn.defaultSize.width[G.GOM.curNavLevel][G.GOM.curWidth];
|
2369 | }
|
2370 | return w;
|
2371 | },
|
2372 | getHeight: function() {
|
2373 | return G.tn.defaultSize.height[G.GOM.curNavLevel][G.GOM.curWidth];
|
2374 | },
|
2375 | getOuterHeight: function() {
|
2376 | return G.tn.defaultSize.height[G.GOM.curNavLevel][G.GOM.curWidth]+G.tn.opt.Get('borderVertical')*2;
|
2377 | }
|
2378 | },
|
2379 | settings: {
|
2380 | width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0, xsc:'u', smc:'u', mec:'u', lac:'u', xlc:'u' },
|
2381 | lN : { xs:0, sm:0, me:0, la:0, xl:0, xsc:'u', smc:'u', mec:'u', lac:'u', xlc:'u' } },
|
2382 | height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0, xsc:'u', smc:'u', mec:'u', lac:'u', xlc:'u' },
|
2383 | lN : { xs:0, sm:0, me:0, la:0, xl:0, xsc:'u', smc:'u', mec:'u', lac:'u', xlc:'u' } },
|
2384 | getH: function(l, w) {
|
2385 | var cl = (l == undefined ? G.GOM.curNavLevel : l);
|
2386 | var cw = (w == undefined ? G.GOM.curWidth : w);
|
2387 | if( G.layout.engine == 'MOSAIC' ) {
|
2388 | return this.height[cl][cw] * this.mosaic[cl+'Factor']['h'][cw];
|
2389 | }
|
2390 | else {
|
2391 | return this.height[cl][cw];
|
2392 | }
|
2393 | },
|
2394 | getW: function(l, w) {
|
2395 | var cl = (l == undefined ? G.GOM.curNavLevel : l);
|
2396 | var cw = (w == undefined ? G.GOM.curWidth : w);
|
2397 | if( G.layout.engine == 'MOSAIC' ) {
|
2398 | return this.width[cl][cw] * this.mosaic[cl+'Factor']['w'][cw];
|
2399 | }
|
2400 | else {
|
2401 | return this.width[cl][cw];
|
2402 |
|
2403 | }
|
2404 | },
|
2405 | mosaic: { l1 : { xs: null, sm: null, me: null, la: null, xl: null },
|
2406 | lN : { xs: null, sm: null, me: null, la: null, xl: null },
|
2407 | l1Factor : { h :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }, w :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }},
|
2408 | lNFactor : { h :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }, w :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }}
|
2409 | },
|
2410 | getMosaic: function() {
|
2411 | return this.mosaic[G.GOM.curNavLevel][G.GOM.curWidth];
|
2412 | },
|
2413 | mosaicCalcFactor: function(l, w) {
|
2414 |
|
2415 | var maxW = 1;
|
2416 | var maxH = 1;
|
2417 | for( var n = 0; n < G.tn.settings.mosaic[l][w].length; n++ ) {
|
2418 | maxW = Math.max(maxW, this.mosaic[l][w][n]['w']);
|
2419 | maxH = Math.max(maxH, this.mosaic[l][w][n]['h']);
|
2420 | }
|
2421 | this.mosaic[l + 'Factor']['h'][w] = maxH;
|
2422 | this.mosaic[l + 'Factor']['w'][w] = maxW;
|
2423 | },
|
2424 | gutterHeight: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
2425 | gutterWidth: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
2426 | GetResponsive: function( setting ) {
|
2427 | return this[setting][G.GOM.curNavLevel][G.GOM.curWidth];
|
2428 | }
|
2429 | },
|
2430 |
|
2431 | hoverEffects : {
|
2432 | std : [],
|
2433 | level1: [],
|
2434 | get: function() {
|
2435 | if( G.GOM.curNavLevel == 'l1' && this.level1.length !== 0 ) {
|
2436 | return this.level1;
|
2437 | }
|
2438 | else {
|
2439 | return this.std;
|
2440 | }
|
2441 | }
|
2442 | },
|
2443 |
|
2444 | buildInit : {
|
2445 | std : [],
|
2446 | level1: [],
|
2447 | get: function() {
|
2448 | if( G.GOM.curNavLevel == 'l1' && this.level1.length !== 0 ) {
|
2449 | return this.level1;
|
2450 | }
|
2451 | else {
|
2452 | return this.std;
|
2453 | }
|
2454 | }
|
2455 | },
|
2456 |
|
2457 | toolbar: {
|
2458 | album : { topLeft : '', topRight: '', bottomLeft: '', bottomRight: '' },
|
2459 | image : { topLeft : '', topRight: '', bottomLeft: '', bottomRight: '' },
|
2460 | albumUp : { topLeft : '', topRight: '', bottomLeft: '', bottomRight: '' },
|
2461 | get: function( item ) {
|
2462 | return this[item.kind];
|
2463 | },
|
2464 | },
|
2465 | style: {
|
2466 |
|
2467 | l1 : { label: '', title: '', desc: '' },
|
2468 | lN : { label: '', title: '', desc: '' },
|
2469 | getTitle : function() {
|
2470 | return ('style="' + this[G.GOM.curNavLevel].title + '"');
|
2471 | },
|
2472 | getDesc : function() {
|
2473 | return ('style="' + this[G.GOM.curNavLevel].desc + '"');
|
2474 | },
|
2475 | getLabel: function() {
|
2476 | var s='style="'+ this[G.GOM.curNavLevel].label;
|
2477 | s+= (G.O.RTL ? '"direction:RTL;"' :'');
|
2478 | s+='"';
|
2479 | return s;
|
2480 | }
|
2481 | }
|
2482 | };
|
2483 | G.scrollTimeOut = 0;
|
2484 | G.i18nTranslations = {'paginationPrevious':'Previous', 'paginationNext':'Next', 'breadcrumbHome':'List of Albums', 'thumbnailImageTitle':'', 'thumbnailAlbumTitle':'', 'thumbnailImageDescription':'', 'thumbnailAlbumDescription':'' };
|
2485 | G.emptyGif = 'data:image/gif;base64,R0lGODlhEAAQAIAAAP///////yH5BAEKAAEALAAAAAAQABAAAAIOjI+py+0Po5y02ouzPgUAOw==';
|
2486 | G.CSStransformName = FirstSupportedPropertyName(["transform", "msTransform", "MozTransform", "WebkitTransform", "OTransform"]);
|
2487 |
|
2488 | G.CSStransformStyle = FirstSupportedPropertyName(["transformStyle", "msTransformStyle", "MozTransformStyle", "WebkitTransformStyle", "OTransformStyle"]);
|
2489 | G.CSSperspective = FirstSupportedPropertyName(["perspective", "msPerspective", "MozPerspective", "WebkitPerspective", "OPerspective"]);
|
2490 | G.CSSbackfaceVisibilityName = FirstSupportedPropertyName(["backfaceVisibility", "msBackfaceVisibility", "MozBackfaceVisibility", "WebkitBackfaceVisibility", "OBackfaceVisibility"]);
|
2491 | G.CSStransitionName = FirstSupportedPropertyName(["transition", "msTransition", "MozTransition", "WebkitTransition", "OTransition"]);
|
2492 | G.CSSanimationName = FirstSupportedPropertyName(["animation", "msAnimation", "MozAnimation", "WebkitAnimation", "OAnimation"]);
|
2493 | G.GalleryResizeThrottled = throttle(GalleryResize, 15, {leading: false});
|
2494 |
|
2495 | G.blockList = null;
|
2496 | G.allowList = null;
|
2497 | G.albumList = [];
|
2498 | G.locationHashLastUsed = '';
|
2499 | G.custGlobals = {};
|
2500 | G.touchAutoOpenDelayTimerID = 0;
|
2501 | G.i18nLang = '';
|
2502 | G.timeLastTouchStart = 0;
|
2503 | G.custGlobals = {};
|
2504 | G.markupOrApiProcessed = false;
|
2505 |
|
2506 |
|
2507 |
|
2508 | G.GOM = {
|
2509 | albumIdx : -1,
|
2510 | clipArea : { top: 0, height: 0 },
|
2511 | displayArea : { width: 0 , height: 0 },
|
2512 | displayAreaLast : { width: 0 , height: 0 },
|
2513 | displayedMoreSteps : 0,
|
2514 | items: [],
|
2515 | $imgPreloader: [],
|
2516 | thumbnails2Display: [],
|
2517 | itemsDisplayed : 0,
|
2518 | firstDisplay : true,
|
2519 | firstDisplayTime : 0,
|
2520 | navigationBar : {
|
2521 | displayed: false,
|
2522 | $newContent: ''
|
2523 | },
|
2524 | cache : {
|
2525 | viewport: null,
|
2526 | containerOffset: null,
|
2527 | areaWidth: 100
|
2528 | },
|
2529 | nbSelected : 0,
|
2530 | pagination : { currentPage: 0 },
|
2531 | panThreshold: 60,
|
2532 | panYOnly: false,
|
2533 | lastFullRow : -1,
|
2534 | lastDisplayedIdx: -1,
|
2535 | displayInterval : { from: 0, len: 0 },
|
2536 | hammertime: null,
|
2537 | curNavLevel: 'l1',
|
2538 | curWidth: 'me',
|
2539 | albumSearch: '',
|
2540 | albumSearchTags: '',
|
2541 | lastZIndex: 0,
|
2542 | lastRandomValue: 0,
|
2543 | slider : {
|
2544 | hostIdx: -1,
|
2545 | hostItem: null,
|
2546 | currentIdx: 0,
|
2547 | nextIdx: 0,
|
2548 | timerID: 0,
|
2549 | tween: null
|
2550 | },
|
2551 | NGY2Item: function( idx ) {
|
2552 | if( G.GOM.items[idx] == undefined || G.GOM.items[idx] == null ) { return null; }
|
2553 | var i = G.GOM.items[idx].thumbnailIdx;
|
2554 | return G.I[i];
|
2555 | },
|
2556 |
|
2557 |
|
2558 | GTn: function(index, width, height) {
|
2559 | this.thumbnailIdx = index;
|
2560 | this.width = 0;
|
2561 | this.height = 0;
|
2562 | this.top = 0;
|
2563 | this.left = 0;
|
2564 | this.row = 0;
|
2565 | this.imageWidth = width;
|
2566 | this.imageHeight = height;
|
2567 | this.resizedContentWidth = 0;
|
2568 | this.resizedContentHeight = 0;
|
2569 | this.displayed = false;
|
2570 | this.neverDisplayed = true;
|
2571 | this.inDisplayArea = false;
|
2572 | },
|
2573 |
|
2574 | ScrollToTop: function() {
|
2575 |
|
2576 | if( G.GOM.firstDisplay ) {
|
2577 |
|
2578 | return;
|
2579 | }
|
2580 |
|
2581 | if( G.$E.scrollableParent === null && !topInViewportVert(G.$E.base, 20) ) {
|
2582 |
|
2583 | G.$E.base.get(0).scrollIntoView();
|
2584 | }
|
2585 |
|
2586 | if( G.$E.scrollableParent !== null ) {
|
2587 |
|
2588 |
|
2589 | var scrollTop = G.$E.scrollableParent.scrollTop();
|
2590 |
|
2591 | var dist = Math.abs(G.$E.scrollableParent.offset().top - G.$E.base.offset().top - scrollTop);
|
2592 | if( scrollTop > dist ) {
|
2593 | window.ng_draf( function() {
|
2594 |
|
2595 | G.$E.scrollableParent.scrollTop(dist);
|
2596 | });
|
2597 | }
|
2598 | }
|
2599 | }
|
2600 | };
|
2601 |
|
2602 |
|
2603 |
|
2604 |
|
2605 |
|
2606 | G.VOM = {
|
2607 | viewerDisplayed: false,
|
2608 | viewerIsFullscreen: false,
|
2609 | infoDisplayed: false,
|
2610 | toolbarsDisplayed: true,
|
2611 | toolsHide: null,
|
2612 | zoom : {
|
2613 | posX: 0,
|
2614 | posY: 0,
|
2615 | userFactor: 1,
|
2616 | isZooming: false
|
2617 | },
|
2618 | padding: { H: 0, V: 0 },
|
2619 | window: { lastWidth: 0, lastHeight: 0 },
|
2620 | $viewer: null,
|
2621 | $toolbar: null,
|
2622 | $toolbarTL: null,
|
2623 | $toolbarTR: null,
|
2624 |
|
2625 | toolbarMode: 'std',
|
2626 | playSlideshow : false,
|
2627 | playSlideshowTimerID: 0,
|
2628 | slideshowDelay: 3000,
|
2629 | albumID: -1,
|
2630 | viewerMediaIsChanged: false,
|
2631 | items: [],
|
2632 |
|
2633 | panMode: 'off',
|
2634 |
|
2635 | $baseCont: null,
|
2636 | $content: null,
|
2637 | content: {
|
2638 | previous : {
|
2639 | vIdx: -1,
|
2640 | $media: null,
|
2641 | NGY2Item: function() {
|
2642 | return G.I[ G.VOM.items[G.VOM.content.previous.vIdx].ngy2ItemIdx ];
|
2643 | }
|
2644 | },
|
2645 | current : {
|
2646 | vIdx: -1,
|
2647 | $media: null,
|
2648 | NGY2Item: function() {
|
2649 | return G.I[ G.VOM.items[G.VOM.content.current.vIdx].ngy2ItemIdx ];
|
2650 | }
|
2651 | },
|
2652 | next : {
|
2653 | vIdx: -1,
|
2654 | $media: null,
|
2655 | NGY2Item: function() {
|
2656 | return G.I[ G.VOM.items[G.VOM.content.next.vIdx].ngy2ItemIdx ];
|
2657 | }
|
2658 | }
|
2659 | },
|
2660 | IdxNext: function() {
|
2661 | var n = 0;
|
2662 |
|
2663 | if( G.VOM.content.current.vIdx < (G.VOM.items.length-1) ) {
|
2664 | n = G.VOM.content.current.vIdx + 1;
|
2665 | }
|
2666 | return n;
|
2667 | },
|
2668 | IdxPrevious: function() {
|
2669 | var n = G.VOM.content.current.vIdx - 1;
|
2670 | if( G.VOM.content.current.vIdx == 0 ) {
|
2671 | n = G.VOM.items.length - 1;
|
2672 | }
|
2673 | return n;
|
2674 | },
|
2675 |
|
2676 | gallery: {
|
2677 | $elt: null,
|
2678 | $tmbCont: null,
|
2679 | gwidth: 0,
|
2680 | vwidth: 0,
|
2681 | oneTmbWidth: 0,
|
2682 | firstDisplay: true,
|
2683 | posX: 0,
|
2684 | SetThumbnailActive() {
|
2685 | if( G.O.viewerGallery == 'none' ) { return; }
|
2686 | this.$tmbCont.children().removeClass('activeVThumbnail');
|
2687 | this.$tmbCont.children().eq( G.VOM.content.current.vIdx ).addClass('activeVThumbnail');
|
2688 | this.firstDisplay = false;
|
2689 | },
|
2690 | Resize: function() {
|
2691 | if( G.O.viewerGallery == 'none' ) { return; }
|
2692 |
|
2693 | if( !this.firstDisplay ) {
|
2694 | var viewerW = G.VOM.$viewer.width();
|
2695 |
|
2696 |
|
2697 | var maxTmb = Math.trunc(viewerW / this.oneTmbWidth);
|
2698 | this.vwidth = maxTmb * this.oneTmbWidth;
|
2699 | this.$elt.css({ width: this.vwidth, left: (viewerW - this.vwidth)/2 });
|
2700 |
|
2701 |
|
2702 | if( G.VOM.items.length >= maxTmb ) {
|
2703 | var tmbPos = this.oneTmbWidth * G.VOM.content.current.vIdx;
|
2704 |
|
2705 | if( (tmbPos + this.posX) < this.vwidth ) {
|
2706 | if( tmbPos + this.posX < 0 ) {
|
2707 | this.posX = -tmbPos;
|
2708 | }
|
2709 | }
|
2710 | else {
|
2711 | if( tmbPos + this.posX >= this.vwidth ) {
|
2712 | this.posX = this.vwidth - (tmbPos + this.oneTmbWidth)
|
2713 | }
|
2714 | }
|
2715 | }
|
2716 |
|
2717 | this.PanGallery(0);
|
2718 | }
|
2719 | else {
|
2720 |
|
2721 | new NGTweenable().tween({
|
2722 | from: { opacity: 0 },
|
2723 | to: { opacity: 1 },
|
2724 | easing: 'easeInOutSine',
|
2725 | duration: 1000,
|
2726 | step: function (state) {
|
2727 |
|
2728 | },
|
2729 | finish: function (state) {
|
2730 |
|
2731 | }
|
2732 | });
|
2733 |
|
2734 | }
|
2735 | },
|
2736 | PanGallery: function( panX ){
|
2737 |
|
2738 |
|
2739 | if( this.gwidth < G.VOM.$viewer.width() ) {
|
2740 | this.posX = (G.VOM.$viewer.width() - this.gwidth) / 2;
|
2741 | panX = 0;
|
2742 | }
|
2743 |
|
2744 |
|
2745 | if( this.posX > (this.vwidth - this.oneTmbWidth) ) {
|
2746 |
|
2747 | this.posX = this.vwidth - this.oneTmbWidth;
|
2748 | }
|
2749 | if( (this.posX+this.gwidth) < this.oneTmbWidth ) {
|
2750 |
|
2751 | this.posX = -this.gwidth + this.oneTmbWidth;
|
2752 | }
|
2753 |
|
2754 | this.$tmbCont.css( G.CSStransformName , 'translateX(' + (this.posX + panX) + 'px)');
|
2755 | },
|
2756 | PanGalleryEnd: function( velocity ) {
|
2757 |
|
2758 | var d = velocity * 100;
|
2759 | new NGTweenable().tween({
|
2760 | from: { pan: G.VOM.gallery.posX },
|
2761 | to: { pan: G.VOM.gallery.posX + d },
|
2762 | easing: 'easeOutQuad',
|
2763 | duration: 500,
|
2764 | step: function (state) {
|
2765 | G.VOM.gallery.posX = state.pan;
|
2766 | G.VOM.gallery.PanGallery( 0 );
|
2767 | }
|
2768 | });
|
2769 | }
|
2770 |
|
2771 | },
|
2772 | hammertime: null,
|
2773 | swipePosX: 0,
|
2774 | panPosX: 0,
|
2775 | panPosY: 0,
|
2776 | panThreshold: 60,
|
2777 | panXOnly: false,
|
2778 | singletapTime: 0,
|
2779 | viewerTheme: '',
|
2780 | timeImgChanged: 0,
|
2781 | ImageLoader: {
|
2782 |
|
2783 |
|
2784 | maxChecks: 1000,
|
2785 | list: [],
|
2786 | intervalHandle : null,
|
2787 |
|
2788 | loadImage : function (callback, ngitem) {
|
2789 | if( ngitem.mediaKind != 'img' ) { return; }
|
2790 | var img = new Image ();
|
2791 | img.src = ngitem.responsiveURL();
|
2792 | if (img.width && img.height) {
|
2793 | callback (img.width, img.height, ngitem, 0);
|
2794 | }
|
2795 | else {
|
2796 | var obj = {image: img, url: ngitem.responsiveURL(), ngitem: ngitem, callback: callback, checks: 1};
|
2797 | var i;
|
2798 | for (i=0; i < this.list.length; i++) {
|
2799 | if (this.list[i] == null)
|
2800 | break;
|
2801 | }
|
2802 | this.list[i] = obj;
|
2803 | if (!this.intervalHandle)
|
2804 | this.intervalHandle = setInterval(this.interval, 50);
|
2805 | }
|
2806 | },
|
2807 |
|
2808 |
|
2809 | interval : function () {
|
2810 | var count = 0;
|
2811 | var list = G.VOM.ImageLoader.list, item;
|
2812 | for (var i=0; i<list.length; i++) {
|
2813 | item = list[i];
|
2814 | if (item != null) {
|
2815 | if (item.image.width && item.image.height) {
|
2816 | G.VOM.ImageLoader.list[i] = null;
|
2817 | item.callback (item.image.width, item.image.height, item.ngitem, item.checks);
|
2818 | }
|
2819 | else if (item.checks > G.VOM.ImageLoader.maxChecks) {
|
2820 | G.VOM.ImageLoader.list[i] = null;
|
2821 | item.callback (0, 0, item.ngitem, item.checks);
|
2822 | }
|
2823 | else {
|
2824 | count++;
|
2825 | item.checks++;
|
2826 | }
|
2827 | }
|
2828 | }
|
2829 | if (count == 0) {
|
2830 | G.VOM.ImageLoader.list = [];
|
2831 | clearInterval (G.VOM.ImageLoader.intervalHandle);
|
2832 | delete G.VOM.ImageLoader.intervalHandle;
|
2833 | }
|
2834 | }
|
2835 | }
|
2836 | }
|
2837 |
|
2838 | function VImg( index ) {
|
2839 | this.$e = null;
|
2840 | this.ngy2ItemIdx = index;
|
2841 | this.mediaNumber = G.VOM.items.length + 1;
|
2842 | this.posX = 0;
|
2843 | this.posY = 0;
|
2844 | }
|
2845 |
|
2846 |
|
2847 |
|
2848 |
|
2849 | G.popup = {
|
2850 | isDisplayed: false,
|
2851 | $elt: null,
|
2852 | close: function() {
|
2853 | if( this.$elt != null ) {
|
2854 | var tweenable = new NGTweenable();
|
2855 | tweenable.tween({
|
2856 | from: { opacity:1 },
|
2857 | to: { opacity:0 },
|
2858 | attachment: { t: this },
|
2859 | easing: 'easeInOutSine',
|
2860 | duration: 100,
|
2861 | step: function (state, att) {
|
2862 | if( att.t.$elt != null ) {
|
2863 | att.t.$elt.css('opacity',state.opacity);
|
2864 | }
|
2865 | },
|
2866 | finish: function (state, att) {
|
2867 | if( att.t.$elt != null ) {
|
2868 | att.t.$elt.remove();
|
2869 | att.t.$elt=null;
|
2870 | }
|
2871 | att.t.isDisplayed=false;
|
2872 | }
|
2873 | });
|
2874 | }
|
2875 | }
|
2876 | }
|
2877 |
|
2878 |
|
2879 |
|
2880 |
|
2881 | G.galleryTheme_dark = {
|
2882 | navigationBar : { background: 'none', borderTop: '', borderBottom: '', borderRight: '', borderLeft: '' },
|
2883 | navigationBreadcrumb : { background: '#111', color: '#fff', colorHover: '#ccc', borderRadius: '4px' },
|
2884 | navigationFilter : { color: '#ddd', background: '#111', colorSelected: '#fff', backgroundSelected: '#111', borderRadius: '4px' },
|
2885 | navigationPagination : { background: '#111', color: '#fff', colorHover: '#ccc', borderRadius: '4px' },
|
2886 | thumbnail : { background: '#444', backgroundImage: 'linear-gradient(315deg, #111 0%, #445 90%)', borderColor: '#000', borderRadius: '0px', labelOpacity : 1, labelBackground: 'rgba(34, 34, 34, 0)', titleColor: '#fff', titleBgColor: 'transparent', titleShadow: '', descriptionColor: '#ccc', descriptionBgColor: 'transparent', descriptionShadow: '', stackBackground: '#aaa' },
|
2887 | thumbnailIcon : { padding: '5px', color: '#fff', shadow:'' },
|
2888 | pagination : { background: '#181818', backgroundSelected: '#666', color: '#fff', borderRadius: '2px', shapeBorder: '3px solid #666', shapeColor: '#444', shapeSelectedColor: '#aaa'}
|
2889 | };
|
2890 |
|
2891 | G.galleryTheme_light = {
|
2892 | navigationBar : { background: 'none', borderTop: '', borderBottom: '', borderRight: '', borderLeft: '' },
|
2893 | navigationBreadcrumb : { background: '#eee', color: '#000', colorHover: '#333', borderRadius: '4px' },
|
2894 | navigationFilter : { background: '#eee', color: '#222', colorSelected: '#000', backgroundSelected: '#eee', borderRadius: '4px' },
|
2895 | navigationPagination : { background: '#eee', color: '#000', colorHover: '#333', borderRadius: '4px' },
|
2896 | thumbnail : { background: '#444', backgroundImage: 'linear-gradient(315deg, #111 0%, #445 90%)', borderColor: '#000', labelOpacity : 1, labelBackground: 'rgba(34, 34, 34, 0)', titleColor: '#fff', titleBgColor: 'transparent', titleShadow: '', descriptionColor: '#ccc', descriptionBgColor: 'transparent', descriptionShadow: '', stackBackground: '#888' },
|
2897 | thumbnailIcon : { padding: '5px', color: '#fff' },
|
2898 | pagination : { background: '#eee', backgroundSelected: '#aaa', color: '#000', borderRadius: '2px', shapeBorder: '3px solid #666', shapeColor: '#444', shapeSelectedColor: '#aaa'}
|
2899 | };
|
2900 |
|
2901 |
|
2902 | G.viewerTheme_dark = {
|
2903 | background: '#000',
|
2904 | barBackground: 'rgba(4, 4, 4, 0.2)',
|
2905 | barBorder: '0px solid #111',
|
2906 | barColor: '#fff',
|
2907 | barDescriptionColor: '#ccc'
|
2908 | };
|
2909 | G.viewerTheme_light = {
|
2910 | background: '#f8f8f8',
|
2911 | barBackground: 'rgba(4, 4, 4, 0.7)',
|
2912 | barBorder: '0px solid #111',
|
2913 | barColor: '#fff',
|
2914 | barDescriptionColor: '#ccc'
|
2915 | };
|
2916 |
|
2917 |
|
2918 |
|
2919 |
|
2920 |
|
2921 |
|
2922 | var NanoAlert = NGY2Tools.NanoAlert;
|
2923 | var NanoConsoleLog = NGY2Tools.NanoConsoleLog;
|
2924 |
|
2925 |
|
2926 |
|
2927 | this.initiateGallery2 = function( element, params ) {
|
2928 |
|
2929 |
|
2930 | G.O = params;
|
2931 |
|
2932 | G.$E.base = jQuery(element);
|
2933 | G.baseEltID = G.$E.base.attr('id');
|
2934 | if( G.baseEltID == undefined ) {
|
2935 |
|
2936 | var base_id = 'my_nanogallery';
|
2937 | var c = '';
|
2938 | var f = true;
|
2939 | while( f ) {
|
2940 | if (document.getElementById(base_id + c)) {
|
2941 |
|
2942 | if( c == '' ) {
|
2943 | c = 1;
|
2944 | }
|
2945 | else {
|
2946 | c++;
|
2947 | }
|
2948 | }
|
2949 | else {
|
2950 | f = false;
|
2951 | G.baseEltID = 'my_nanogallery' + c;
|
2952 | }
|
2953 | }
|
2954 | G.$E.base.attr('id', G.baseEltID)
|
2955 | }
|
2956 | G.O.$markup = [];
|
2957 |
|
2958 | DefineVariables();
|
2959 | SetPolyFills();
|
2960 | BuildSkeleton();
|
2961 | G.GOM.firstDisplayTime = Date.now();
|
2962 |
|
2963 | SetGlobalEvents();
|
2964 |
|
2965 |
|
2966 | if( !G.O.lightboxStandalone ) {
|
2967 | var albumToDisplay = G.O.album;
|
2968 | if( albumToDisplay == '' && G.O.photoset != '' ) {
|
2969 | albumToDisplay = G.O.photoset;
|
2970 | G.O.album = G.O.photoset;
|
2971 | }
|
2972 | if( albumToDisplay != '' ) {
|
2973 | G.O.displayBreadcrumb = false;
|
2974 | if( albumToDisplay.toUpperCase() != 'NONE' ) {
|
2975 |
|
2976 | if( G.O.kind == "nano_photos_provider2") {
|
2977 | if( albumToDisplay == decodeURIComponent(albumToDisplay)) {
|
2978 |
|
2979 | albumToDisplay = encodeURIComponent(albumToDisplay);
|
2980 | G.O.album = albumToDisplay;
|
2981 | }
|
2982 | }
|
2983 | NGY2Item.New( G, '', '', albumToDisplay, '-1', 'album' );
|
2984 | if( !ProcessLocationHash() ) {
|
2985 | DisplayAlbum('-1', albumToDisplay);
|
2986 | }
|
2987 | return;
|
2988 | }
|
2989 | }
|
2990 | }
|
2991 |
|
2992 |
|
2993 |
|
2994 | NGY2Item.New( G, G.i18nTranslations.breadcrumbHome, '', '0', '-1', 'album' );
|
2995 |
|
2996 | processStartOptions();
|
2997 |
|
2998 | }
|
2999 |
|
3000 |
|
3001 |
|
3002 | function processStartOptions() {
|
3003 |
|
3004 |
|
3005 |
|
3006 |
|
3007 |
|
3008 |
|
3009 |
|
3010 |
|
3011 |
|
3012 |
|
3013 |
|
3014 |
|
3015 | if( !ProcessLocationHash() ) {
|
3016 | processStartOptionsPart2();
|
3017 | }
|
3018 | }
|
3019 |
|
3020 |
|
3021 | function processStartOptionsPart2() {
|
3022 |
|
3023 |
|
3024 | if( G.O.lightboxStandalone ) {
|
3025 | LightboxStandaloneFindContent();
|
3026 | }
|
3027 | else {
|
3028 |
|
3029 | if( G.O.openOnStart != '' ) {
|
3030 | var IDs = parseIDs(G.O.openOnStart);
|
3031 | if( IDs.imageID != '0' ) {
|
3032 | DisplayPhoto(IDs.imageID, IDs.albumID);
|
3033 | }
|
3034 | else {
|
3035 | DisplayAlbum('-1', IDs.albumID);
|
3036 | }
|
3037 | }
|
3038 | else {
|
3039 |
|
3040 | DisplayAlbum('-1', 0);
|
3041 | }
|
3042 | }
|
3043 | }
|
3044 |
|
3045 |
|
3046 |
|
3047 |
|
3048 |
|
3049 | function LightboxStandaloneFindContent() {
|
3050 |
|
3051 | G.GOM.curNavLevel = 'l1';
|
3052 |
|
3053 | if( G.O.items == null ) {
|
3054 |
|
3055 | var elts = jQuery('[data-nanogallery2-Lightbox');
|
3056 |
|
3057 | var g = G.$E.base[0].dataset.nanogallery2Lgroup;
|
3058 |
|
3059 | GetContentMarkup( elts, g );
|
3060 | }
|
3061 | else {
|
3062 |
|
3063 | GetContentApiObject();
|
3064 | }
|
3065 |
|
3066 | LightboxStandaloneDisplay();
|
3067 |
|
3068 | }
|
3069 |
|
3070 |
|
3071 |
|
3072 | function LightboxStandaloneDisplay() {
|
3073 |
|
3074 | G.VOM.items = [];
|
3075 | G.VOM.albumID = '0';
|
3076 | G.GOM.curNavLevel = 'l1';
|
3077 | var vcnt = 0;
|
3078 |
|
3079 | var elt = G.$E.base[0].attributes;
|
3080 | var thumbsrc = '';
|
3081 |
|
3082 | if( elt.hasOwnProperty('src') ) {
|
3083 | thumbsrc = elt['src'].nodeValue;
|
3084 | }
|
3085 |
|
3086 | if( thumbsrc == '' && elt.hasOwnProperty('data-ngthumb') ) {
|
3087 | thumbsrc = elt['data-ngthumb'].nodeValue;
|
3088 | }
|
3089 |
|
3090 | var displayIdx = undefined;
|
3091 | for( var idx = 0; idx < G.I.length; idx++ ) {
|
3092 | if( G.I[idx].kind == 'image' ) {
|
3093 | var vimg = new VImg(idx);
|
3094 | G.VOM.items.push(vimg);
|
3095 |
|
3096 | if( G.I[idx].thumbImg().src == thumbsrc ) {
|
3097 |
|
3098 | displayIdx = vcnt;
|
3099 | }
|
3100 | vcnt++;
|
3101 | }
|
3102 |
|
3103 | }
|
3104 | if( G.VOM.items.length > 0 ) {
|
3105 | LightboxOpen( displayIdx );
|
3106 | }
|
3107 | else {
|
3108 | NanoConsoleLog(G, 'No content for Lightbox standalone.');
|
3109 | }
|
3110 | }
|
3111 |
|
3112 |
|
3113 |
|
3114 |
|
3115 | function parseIDs( IDs ) {
|
3116 | var r = { albumID: '0', imageID: '0' };
|
3117 |
|
3118 | var t = IDs.split('/');
|
3119 | if( t.length > 0 ) {
|
3120 | r.albumID = t[0];
|
3121 | if( t.length > 1 ) {
|
3122 | r.imageID = t[1];
|
3123 | }
|
3124 | }
|
3125 | return r;
|
3126 | }
|
3127 |
|
3128 |
|
3129 |
|
3130 | function DisplayAlbum( imageID, albumID ) {
|
3131 |
|
3132 | if( G.VOM.viewerDisplayed ) {
|
3133 | LightboxClose(null);
|
3134 | }
|
3135 |
|
3136 |
|
3137 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
3138 | G.GOM.curNavLevel = 'lN';
|
3139 | if( albumIdx == 0 ) {
|
3140 | G.GOM.curNavLevel = 'l1';
|
3141 | }
|
3142 | G.layout.SetEngine();
|
3143 | G.galleryResizeEventEnabled = false;
|
3144 |
|
3145 | if( albumIdx == -1 ) {
|
3146 | NGY2Item.New( G, '', '', albumID, '0', 'album' );
|
3147 | albumIdx = G.I.length - 1;
|
3148 | }
|
3149 |
|
3150 | if( !G.I[albumIdx].contentIsLoaded ) {
|
3151 |
|
3152 | AlbumGetContent( albumID, DisplayAlbum, imageID, albumID );
|
3153 | return;
|
3154 | }
|
3155 |
|
3156 | ThumbnailSelectionClear();
|
3157 |
|
3158 | G.GOM.pagination.currentPage = 0;
|
3159 | SetLocationHash( albumID, '' );
|
3160 | GalleryRender( albumIdx );
|
3161 |
|
3162 | }
|
3163 |
|
3164 |
|
3165 |
|
3166 | function GalleryBottomManage() {
|
3167 |
|
3168 | switch( G.galleryDisplayMode.Get() ) {
|
3169 | case 'PAGINATION':
|
3170 | if( G.layout.support.rows && G.galleryMaxRows.Get() > 0 ) {
|
3171 | ManagePagination();
|
3172 | }
|
3173 | break;
|
3174 | case 'MOREBUTTON':
|
3175 | G.$E.conTnBottom.off('click');
|
3176 | var nb = G.GOM.items.length-G.GOM.itemsDisplayed;
|
3177 | if( nb == 0 ) {
|
3178 | G.$E.conTnBottom.empty();
|
3179 | }
|
3180 | else {
|
3181 | G.$E.conTnBottom.html('<div class="nGY2GalleryMoreButton"><div class="nGY2GalleryMoreButtonAnnotation">+'+nb+' ' + G.O.icons.galleryMoreButton +'</div></div>');
|
3182 | G.$E.conTnBottom.on('click', function(e) {
|
3183 | G.GOM.displayedMoreSteps++;
|
3184 | GalleryResize();
|
3185 | });
|
3186 | }
|
3187 | break;
|
3188 | case 'FULLCONTENT':
|
3189 | default:
|
3190 | break;
|
3191 | }
|
3192 | }
|
3193 |
|
3194 |
|
3195 |
|
3196 | function breadcrumbAdd( albumIdx ) {
|
3197 |
|
3198 | var ic='';
|
3199 | if( !G.O.breadcrumbHideIcons ) {
|
3200 | ic=G.O.icons.breadcrumbAlbum;
|
3201 | if( albumIdx == 0 ) {
|
3202 | ic=G.O.icons.breadcrumbHome;
|
3203 | }
|
3204 | }
|
3205 | var $newDiv =jQuery('<div class="oneItem">'+ic + G.I[albumIdx].title+'</div>').appendTo(G.GOM.navigationBar.$newContent.find('.nGY2Breadcrumb'));
|
3206 | if( G.O.breadcrumbOnlyCurrentLevel ) {
|
3207 |
|
3208 | if( albumIdx == 0 ) {
|
3209 |
|
3210 | jQuery($newDiv).data('albumID','0');
|
3211 | }
|
3212 | else {
|
3213 | jQuery($newDiv).data('albumID',G.I[albumIdx].albumID);
|
3214 | }
|
3215 | }
|
3216 | else {
|
3217 |
|
3218 | jQuery($newDiv).data('albumID',G.I[albumIdx].GetID());
|
3219 | }
|
3220 | $newDiv.click(function() {
|
3221 | var cAlbumID = jQuery(this).data('albumID');
|
3222 | DisplayAlbum('-1', cAlbumID);
|
3223 | return;
|
3224 | });
|
3225 | }
|
3226 |
|
3227 |
|
3228 | function breadcrumbAddSeparator( lastAlbumID ) {
|
3229 | var $newSep=jQuery('<div class="oneItem">'+(G.O.RTL ? G.O.icons.breadcrumbSeparatorRtl : G.O.icons.breadcrumbSeparator)+'</div>').appendTo(G.GOM.navigationBar.$newContent.find('.nGY2Breadcrumb'));
|
3230 | jQuery($newSep).data('albumIdx',lastAlbumID);
|
3231 | $newSep.click(function() {
|
3232 | var sepAlbumIdx=jQuery(this).data('albumIdx');
|
3233 | DisplayAlbum('-1', G.I[sepAlbumIdx].GetID());
|
3234 | return;
|
3235 | });
|
3236 | }
|
3237 |
|
3238 |
|
3239 |
|
3240 |
|
3241 | function GalleryNavigationBar( albumIdx ) {
|
3242 |
|
3243 |
|
3244 |
|
3245 |
|
3246 |
|
3247 |
|
3248 |
|
3249 |
|
3250 |
|
3251 |
|
3252 |
|
3253 |
|
3254 |
|
3255 |
|
3256 |
|
3257 |
|
3258 | G.GOM.navigationBar.$newContent=jQuery('<div class="nGY2Navigationbar"></div>');
|
3259 |
|
3260 |
|
3261 |
|
3262 |
|
3263 | if( G.O.displayBreadcrumb == true && !G.O.thumbnailAlbumDisplayImage) {
|
3264 |
|
3265 | var newLevel = 0,
|
3266 | lstItems=[];
|
3267 | if( albumIdx != 0 ) {
|
3268 | var l=G.I.length,
|
3269 | parentID=0;
|
3270 |
|
3271 | lstItems.push(albumIdx);
|
3272 | var curIdx=albumIdx;
|
3273 | newLevel++;
|
3274 |
|
3275 | while( G.I[curIdx].albumID != 0 && G.I[curIdx].albumID != -1) {
|
3276 | for(var i=1; i < l; i++ ) {
|
3277 | if( G.I[i].GetID() == G.I[curIdx].albumID ) {
|
3278 | curIdx=i;
|
3279 | lstItems.push(curIdx);
|
3280 | newLevel++;
|
3281 | break;
|
3282 | }
|
3283 | }
|
3284 | }
|
3285 | }
|
3286 |
|
3287 |
|
3288 | if( !(G.O.breadcrumbAutoHideTopLevel && newLevel == 0) ) {
|
3289 | BreadcrumbBuild( lstItems );
|
3290 | }
|
3291 | }
|
3292 |
|
3293 |
|
3294 |
|
3295 | if( G.galleryFilterTags.Get() != false ) {
|
3296 | var nTags = G.I[albumIdx].albumTagList.length;
|
3297 | if( nTags > 0 ) {
|
3298 | for(var i = 0; i < nTags; i++ ) {
|
3299 | var s = G.I[albumIdx].albumTagList[i];
|
3300 | var ic = G.O.icons.navigationFilterUnselected;
|
3301 | var tagClass = 'Unselected';
|
3302 | if( jQuery.inArray(s, G.I[albumIdx].albumTagListSel) >= 0 ) {
|
3303 | tagClass = 'Selected';
|
3304 | ic = G.O.icons.navigationFilterSelected;
|
3305 | }
|
3306 |
|
3307 | var $newTag = jQuery('<div class="nGY2NavigationbarItem nGY2NavFilter' + tagClass + '">'+ ic +' '+ s +'</div>').appendTo(G.GOM.navigationBar.$newContent);
|
3308 |
|
3309 | $newTag.click(function() {
|
3310 |
|
3311 | var $this = jQuery(this);
|
3312 | var tag = $this.text().replace(/^\s*|\s*$/, '');
|
3313 |
|
3314 | if( G.galleryFilterTagsMode.Get() == 'single' ) {
|
3315 |
|
3316 | G.I[albumIdx].albumTagListSel = [];
|
3317 | G.I[albumIdx].albumTagListSel.push(tag);
|
3318 | }
|
3319 | else {
|
3320 |
|
3321 |
|
3322 | if( $this.hasClass('nGY2NavFilterUnselected') ){
|
3323 | G.I[albumIdx].albumTagListSel.push(tag);
|
3324 | }
|
3325 | else {
|
3326 | var tidx=jQuery.inArray(tag,G.I[albumIdx].albumTagListSel);
|
3327 | if( tidx != -1 ) {
|
3328 | G.I[albumIdx].albumTagListSel.splice(tidx,1);
|
3329 | }
|
3330 | }
|
3331 | $this.toggleClass('nGY2NavFilters-oneTagUnselected nGY2NavFilters-oneTagSelected');
|
3332 | }
|
3333 |
|
3334 | DisplayAlbum('-1', G.I[albumIdx].GetID());
|
3335 | });
|
3336 | }
|
3337 |
|
3338 |
|
3339 | var $newClearFilter=jQuery('<div class="nGY2NavigationbarItem nGY2NavFilterSelectAll">'+ G.O.icons.navigationFilterSelectedAll +'</div>').appendTo(G.GOM.navigationBar.$newContent);
|
3340 | $newClearFilter.click(function() {
|
3341 |
|
3342 | G.I[albumIdx].albumTagListSel = [];
|
3343 |
|
3344 |
|
3345 |
|
3346 |
|
3347 | DisplayAlbum('-1', G.I[albumIdx].GetID());
|
3348 | });
|
3349 | }
|
3350 | }
|
3351 |
|
3352 |
|
3353 | if( G.galleryDisplayMode.Get() == "PAGINATION" && G.O.galleryPaginationTopButtons ) {
|
3354 | if( G.layout.support.rows && G.galleryMaxRows.Get() > 0 ) {
|
3355 |
|
3356 | var $newTagPrev = jQuery('<div class="nGY2NavigationbarItem nGY2NavPagination">'+G.O.icons.navigationPaginationPrevious+'</div>').appendTo(G.GOM.navigationBar.$newContent);
|
3357 | $newTagPrev.click(function() {
|
3358 | paginationPreviousPage();
|
3359 | });
|
3360 | var $newTagNext = jQuery('<div class="nGY2NavigationbarItem nGY2NavPagination">'+G.O.icons.navigationPaginationNext+'</div>').appendTo(G.GOM.navigationBar.$newContent);
|
3361 | $newTagNext.click(function() {
|
3362 | paginationNextPage();
|
3363 | });
|
3364 | }
|
3365 | }
|
3366 |
|
3367 | }
|
3368 |
|
3369 | function BreadcrumbBuild(lstItems) {
|
3370 |
|
3371 |
|
3372 | jQuery('<div class="nGY2NavigationbarItem nGY2Breadcrumb"></div>').appendTo(G.GOM.navigationBar.$newContent);
|
3373 |
|
3374 |
|
3375 | if( G.O.breadcrumbOnlyCurrentLevel ) {
|
3376 |
|
3377 | if( lstItems.length == 0 ) {
|
3378 | breadcrumbAdd(0);
|
3379 | }
|
3380 | else {
|
3381 |
|
3382 | if( lstItems.length == 1 ) {
|
3383 | breadcrumbAddSeparator(0);
|
3384 | }
|
3385 | else {
|
3386 | breadcrumbAddSeparator(lstItems[0]);
|
3387 | }
|
3388 | breadcrumbAdd(lstItems[0]);
|
3389 | }
|
3390 | }
|
3391 | else {
|
3392 |
|
3393 | breadcrumbAdd(0);
|
3394 | if( lstItems.length > 0 ) {
|
3395 | breadcrumbAddSeparator(0);
|
3396 | for(var i=lstItems.length-1; i>=0 ; i-- ) {
|
3397 | breadcrumbAdd(lstItems[i]);
|
3398 | if( i > 0 ) {
|
3399 | breadcrumbAddSeparator(lstItems[i-1]);
|
3400 | }
|
3401 | }
|
3402 | }
|
3403 | }
|
3404 |
|
3405 | }
|
3406 |
|
3407 |
|
3408 |
|
3409 | function ManagePagination() {
|
3410 |
|
3411 | G.$E.conTnBottom.css('opacity', 0);
|
3412 | G.$E.conTnBottom.children().remove();
|
3413 |
|
3414 | if( G.GOM.items.length == 0 ) { return; }
|
3415 |
|
3416 |
|
3417 | var nbPages = Math.ceil((G.GOM.items[G.GOM.items.length - 1].row + 1)/G.galleryMaxRows.Get());
|
3418 |
|
3419 |
|
3420 | if( nbPages == 1 ) { return; }
|
3421 |
|
3422 |
|
3423 | if( G.GOM.pagination.currentPage > (nbPages-1) ) {
|
3424 | G.GOM.pagination.currentPage = nbPages-1;
|
3425 | }
|
3426 |
|
3427 | GalleryRenderGetInterval();
|
3428 |
|
3429 | if( G.GOM.displayInterval.len == 0 ) { return; }
|
3430 |
|
3431 |
|
3432 | if( G.O.galleryPaginationMode == 'NUMBERS' && G.GOM.pagination.currentPage > 0 ) {
|
3433 | var $eltPrev = jQuery('<div class="nGY2PaginationPrev">'+G.O.icons.paginationPrevious+'</div>').appendTo(G.$E.conTnBottom);
|
3434 | $eltPrev.click(function(e) {
|
3435 | paginationPreviousPage();
|
3436 | });
|
3437 | }
|
3438 |
|
3439 | var firstPage = 0;
|
3440 | var lastPage = nbPages;
|
3441 | if( G.O.galleryPaginationMode != 'NUMBERS' ) {
|
3442 |
|
3443 | firstPage = 0;
|
3444 | }
|
3445 | else {
|
3446 |
|
3447 |
|
3448 | var numberOfPagesToDisplay = G.O.paginationVisiblePages;
|
3449 | if( numberOfPagesToDisplay >= nbPages ) {
|
3450 | firstPage = 0;
|
3451 | }
|
3452 | else {
|
3453 |
|
3454 | var nbBeforeAfter = 0;
|
3455 | if( isOdd(numberOfPagesToDisplay) ) {
|
3456 | nbBeforeAfter = (numberOfPagesToDisplay + 1) / 2;
|
3457 | }
|
3458 | else {
|
3459 | nbBeforeAfter = numberOfPagesToDisplay / 2;
|
3460 | }
|
3461 |
|
3462 | if( G.GOM.pagination.currentPage < nbBeforeAfter ) {
|
3463 | firstPage = 0;
|
3464 | lastPage = numberOfPagesToDisplay - 1;
|
3465 | if( lastPage > nbPages ) {
|
3466 | lastPage = nbPages - 1;
|
3467 | }
|
3468 | }
|
3469 | else {
|
3470 | firstPage = G.GOM.pagination.currentPage - nbBeforeAfter;
|
3471 | lastPage = firstPage + numberOfPagesToDisplay;
|
3472 | if( lastPage > nbPages ) {
|
3473 | lastPage = nbPages - 1;
|
3474 | }
|
3475 | }
|
3476 |
|
3477 | if( (lastPage - firstPage) < numberOfPagesToDisplay ) {
|
3478 | firstPage = lastPage - numberOfPagesToDisplay;
|
3479 | if( firstPage < 0 ) {
|
3480 | firstPage = 0;
|
3481 | }
|
3482 | }
|
3483 |
|
3484 | }
|
3485 | }
|
3486 |
|
3487 |
|
3488 | for(var i = firstPage; i < lastPage; i++ ) {
|
3489 | var c = '';
|
3490 | var p = '';
|
3491 |
|
3492 | switch( G.O.galleryPaginationMode ) {
|
3493 | case 'NUMBERS':
|
3494 | c = 'nGY2paginationItem';
|
3495 | p = i + 1;
|
3496 | break;
|
3497 | case 'DOTS':
|
3498 | c = 'nGY2paginationDot';
|
3499 | break;
|
3500 | case 'RECTANGLES':
|
3501 | c = 'nGY2paginationRectangle';
|
3502 | break;
|
3503 | }
|
3504 | if( i == G.GOM.pagination.currentPage ) {
|
3505 | c += 'CurrentPage';
|
3506 | }
|
3507 |
|
3508 | var elt$ = jQuery('<div class="' + c + '">' + p + '</div>').appendTo(G.$E.conTnBottom);
|
3509 | elt$.data('pageNumber', i );
|
3510 | elt$.click( function(e) {
|
3511 | G.GOM.pagination.currentPage = jQuery(this).data('pageNumber');
|
3512 | TriggerCustomEvent('pageChanged');
|
3513 |
|
3514 |
|
3515 | G.GOM.ScrollToTop();
|
3516 |
|
3517 | GalleryDisplayPart1();
|
3518 | GalleryDisplayPart2( true );
|
3519 | });
|
3520 |
|
3521 | }
|
3522 |
|
3523 |
|
3524 | if( G.O.galleryPaginationMode == 'NUMBERS' && (G.GOM.pagination.currentPage + 1) < nbPages ) {
|
3525 | var $eltNext = jQuery('<div class="nGY2PaginationNext">' + G.O.icons.paginationNext + '</div>').appendTo(G.$E.conTnBottom);
|
3526 | $eltNext.click( function(e) {
|
3527 | paginationNextPage();
|
3528 | });
|
3529 | }
|
3530 |
|
3531 | G.$E.conTnBottom.css('opacity', 1);
|
3532 |
|
3533 | }
|
3534 | function isOdd(num) { return (num % 2) == 1;}
|
3535 |
|
3536 |
|
3537 | function paginationNextPage() {
|
3538 |
|
3539 | var n1 = 0;
|
3540 | ThumbnailHoverOutAll();
|
3541 |
|
3542 |
|
3543 | if( G.galleryMaxRows.Get() > 0 ) {
|
3544 |
|
3545 | n1 = (G.GOM.items[G.GOM.items.length - 1].row + 1) / G.galleryMaxRows.Get();
|
3546 | }
|
3547 | var n2 = Math.ceil(n1);
|
3548 | var pn = G.GOM.pagination.currentPage;
|
3549 | if( pn < (n2-1) ) {
|
3550 | pn++;
|
3551 | }
|
3552 | else {
|
3553 | pn = 0;
|
3554 | }
|
3555 |
|
3556 | G.GOM.pagination.currentPage = pn;
|
3557 | TriggerCustomEvent('pageChanged');
|
3558 |
|
3559 |
|
3560 | G.GOM.ScrollToTop();
|
3561 |
|
3562 | GalleryDisplayPart1();
|
3563 | GalleryDisplayPart2( true );
|
3564 | }
|
3565 |
|
3566 |
|
3567 | function paginationPreviousPage() {
|
3568 |
|
3569 |
|
3570 | var n1 = 0;
|
3571 |
|
3572 | ThumbnailHoverOutAll();
|
3573 |
|
3574 |
|
3575 | if( G.galleryMaxRows.Get() > 0 ) {
|
3576 |
|
3577 | n1 = (G.GOM.items[G.GOM.items.length - 1].row + 1) / G.galleryMaxRows.Get();
|
3578 | }
|
3579 | var n2 = Math.ceil(n1);
|
3580 |
|
3581 |
|
3582 | var pn = G.GOM.pagination.currentPage;
|
3583 | if( pn > 0 ) {
|
3584 | pn--;
|
3585 | }
|
3586 | else {
|
3587 | pn = n2 - 1;
|
3588 | }
|
3589 |
|
3590 | G.GOM.pagination.currentPage = pn;
|
3591 | TriggerCustomEvent('pageChanged');
|
3592 |
|
3593 |
|
3594 | G.GOM.ScrollToTop();
|
3595 |
|
3596 | GalleryDisplayPart1();
|
3597 | GalleryDisplayPart2( true );
|
3598 | }
|
3599 |
|
3600 |
|
3601 | function GalleryRenderGetInterval() {
|
3602 | G.GOM.displayInterval.from = 0;
|
3603 | G.GOM.displayInterval.len = G.I.length;
|
3604 |
|
3605 | switch( G.galleryDisplayMode.Get() ) {
|
3606 | case 'PAGINATION':
|
3607 | if( G.layout.support.rows ) {
|
3608 | let nbTn = G.GOM.items.length;
|
3609 | var firstRow = G.GOM.pagination.currentPage * G.galleryMaxRows.Get();
|
3610 | var lastRow = firstRow + G.galleryMaxRows.Get();
|
3611 | var firstTn = -1;
|
3612 | G.GOM.displayInterval.len = 0;
|
3613 | for( var i = 0; i < nbTn ; i++ ) {
|
3614 | let curTn = G.GOM.items[i];
|
3615 | if( curTn.row >= firstRow && curTn.row < lastRow ) {
|
3616 | if( firstTn == -1 ) {
|
3617 | G.GOM.displayInterval.from = i;
|
3618 | firstTn = i;
|
3619 | }
|
3620 | G.GOM.displayInterval.len++;
|
3621 | }
|
3622 | }
|
3623 | }
|
3624 | break;
|
3625 | case 'MOREBUTTON':
|
3626 | if( G.layout.support.rows ) {
|
3627 | let nbTn = G.GOM.items.length;
|
3628 | let lastRow = G.O.galleryDisplayMoreStep * (G.GOM.displayedMoreSteps+1);
|
3629 | G.GOM.displayInterval.len = 0;
|
3630 | for( var i = 0; i < nbTn ; i++ ) {
|
3631 | let curTn = G.GOM.items[i];
|
3632 | if( curTn.row < lastRow ) {
|
3633 | G.GOM.displayInterval.len++;
|
3634 | }
|
3635 | }
|
3636 | }
|
3637 | break;
|
3638 | case 'ROWS':
|
3639 | if( G.layout.support.rows ) {
|
3640 | let nbTn = G.GOM.items.length;
|
3641 | let lastRow = G.galleryMaxRows.Get();
|
3642 | if( G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1 ) {
|
3643 | if( lastRow > (G.GOM.lastFullRow + 1) ) {
|
3644 | lastRow = G.GOM.lastFullRow + 1;
|
3645 | }
|
3646 | }
|
3647 | G.GOM.displayInterval.len = 0;
|
3648 | for( var i = 0; i < nbTn ; i++ ) {
|
3649 | let curTn = G.GOM.items[i];
|
3650 | if( curTn.row < lastRow ) {
|
3651 | G.GOM.displayInterval.len++;
|
3652 | }
|
3653 | }
|
3654 | }
|
3655 | break;
|
3656 | default:
|
3657 | case 'FULLCONTENT':
|
3658 | if( G.layout.support.rows && G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1 ) {
|
3659 | let nbTn = G.GOM.items.length;
|
3660 | let lastRow = G.GOM.lastFullRow + 1;
|
3661 | G.GOM.displayInterval.len = 0;
|
3662 | for( var i = 0; i < nbTn ; i++ ) {
|
3663 | let curTn = G.GOM.items[i];
|
3664 | if( curTn.row < lastRow ) {
|
3665 | G.GOM.displayInterval.len++;
|
3666 | }
|
3667 | }
|
3668 | }
|
3669 | break;
|
3670 | }
|
3671 | }
|
3672 |
|
3673 |
|
3674 |
|
3675 | function GalleryRender( albumIdx ) {
|
3676 | TriggerCustomEvent('galleryRenderStart');
|
3677 | clearTimeout(G.GOM.slider.timerID);
|
3678 | G.GOM.slider.hostIdx = -1;
|
3679 |
|
3680 | var fu=G.O.fnGalleryRenderStart;
|
3681 | if( fu !== null ) {
|
3682 |
|
3683 | typeof fu == 'function' ? fu( G.I[G.GOM.albumIdx] ) : window[fu]( G.I[G.GOM.albumIdx] );
|
3684 | }
|
3685 |
|
3686 | G.layout.SetEngine();
|
3687 | G.galleryResizeEventEnabled = false;
|
3688 | G.GOM.albumIdx = -1;
|
3689 | G.GOM.lastDisplayedIdx = -1;
|
3690 |
|
3691 |
|
3692 | if( G.$E.conTnBottom !== undefined ) {
|
3693 |
|
3694 | G.$E.conTnBottom.empty();
|
3695 | }
|
3696 |
|
3697 |
|
3698 | GalleryNavigationBar(albumIdx);
|
3699 |
|
3700 | if( G.GOM.firstDisplay ) {
|
3701 |
|
3702 | G.GOM.firstDisplay = false;
|
3703 | var d = Date.now()-G.GOM.firstDisplayTime;
|
3704 | if( d < G.O.galleryRenderDelay ) {
|
3705 |
|
3706 |
|
3707 | requestTimeout( function() { GalleryRenderPart1( albumIdx )}, G.O.galleryRenderDelay-d );
|
3708 | }
|
3709 | else {
|
3710 | GalleryRenderPart1( albumIdx );
|
3711 | }
|
3712 | G.O.galleryRenderDelay = 0;
|
3713 |
|
3714 | }
|
3715 | else {
|
3716 | var hideNavigationBar = false;
|
3717 | if( G.GOM.navigationBar.$newContent.children().length == 0 ) {
|
3718 | hideNavigationBar = true;
|
3719 | }
|
3720 |
|
3721 |
|
3722 | var tweenable = new NGTweenable();
|
3723 | tweenable.tween({
|
3724 | from: { 'opacity': 1 },
|
3725 | to: { 'opacity': 0 },
|
3726 | duration: 300,
|
3727 | easing: 'easeInQuart',
|
3728 | attachment: { h: hideNavigationBar },
|
3729 | step: function (state, att) {
|
3730 | G.$E.conTnParent.css({'opacity': state.opacity });
|
3731 | if( att.h ) {
|
3732 | G.$E.conNavigationBar.css({ 'opacity': state.opacity });
|
3733 | }
|
3734 | },
|
3735 | finish: function (state, att) {
|
3736 | if( att.h ) {
|
3737 | G.$E.conNavigationBar.css({ 'opacity': 0, 'display': 'none' });
|
3738 | }
|
3739 |
|
3740 |
|
3741 | G.GOM.ScrollToTop();
|
3742 |
|
3743 | GalleryRenderPart1( albumIdx );
|
3744 | }
|
3745 | });
|
3746 | }
|
3747 | }
|
3748 |
|
3749 |
|
3750 | function GalleryRenderPart1( albumIdx ) {
|
3751 |
|
3752 | var oldN = G.$E.conNavigationBar.children().length;
|
3753 | G.$E.conNavigationBar.empty();
|
3754 | G.GOM.navigationBar.$newContent.children().clone(true,true).appendTo(G.$E.conNavigationBar);
|
3755 |
|
3756 | if( G.$E.conNavigationBar.children().length > 0 && oldN == 0 ) {
|
3757 | G.$E.conNavigationBar.css({ 'opacity': 0, 'display': 'block' });
|
3758 | var tweenable = new NGTweenable();
|
3759 | tweenable.tween({
|
3760 | from: { opacity: 0 },
|
3761 | to: { opacity: 1 },
|
3762 | duration: 200,
|
3763 | easing: 'easeInQuart',
|
3764 | step: function (state) {
|
3765 |
|
3766 | G.$E.conNavigationBar.css( state );
|
3767 |
|
3768 | },
|
3769 | finish: function (state) {
|
3770 |
|
3771 | G.$E.conNavigationBar.css({ 'opacity': 1 });
|
3772 |
|
3773 |
|
3774 |
|
3775 | requestTimeout(function(){ GalleryRenderPart2(albumIdx) }, 20);
|
3776 |
|
3777 | }
|
3778 | });
|
3779 | }
|
3780 | else {
|
3781 | requestTimeout(function(){ GalleryRenderPart2(albumIdx) }, 20);
|
3782 | }
|
3783 |
|
3784 | }
|
3785 |
|
3786 |
|
3787 | function GalleryRenderPart2(albumIdx) {
|
3788 |
|
3789 | G.GOM.lastZIndex = parseInt(G.$E.base.css('z-index'));
|
3790 | if( isNaN(G.GOM.lastZIndex) ) {
|
3791 | G.GOM.lastZIndex=0;
|
3792 | }
|
3793 | G.$E.conTnParent.css({ 'opacity': 0 });
|
3794 | G.$E.conTn.off().empty();
|
3795 | var l = G.I.length;
|
3796 | for( var i = 0; i < l ; i++ ) {
|
3797 |
|
3798 | var item = G.I[i];
|
3799 | item.hovered = false;
|
3800 | item.$elt = null;
|
3801 | item.$Elts = [];
|
3802 | item.eltTransform = [];
|
3803 | item.eltFilter = [];
|
3804 | item.width = 0;
|
3805 | item.height = 0;
|
3806 | item.left = 0;
|
3807 | item.top = 0;
|
3808 | item.resizedContentWidth = 0;
|
3809 | item.resizedContentHeight = 0;
|
3810 | item.thumbnailImgRevealed = false;
|
3811 | }
|
3812 |
|
3813 | if( G.CSStransformName == null ) {
|
3814 | G.$E.conTn.css('left', '0px');
|
3815 | }
|
3816 | else {
|
3817 |
|
3818 | G.$E.conTn.css( G.CSStransformName, 'none');
|
3819 | }
|
3820 |
|
3821 |
|
3822 | requestTimeout(function(){ GalleryRenderPart3(albumIdx) }, 20);
|
3823 |
|
3824 |
|
3825 | }
|
3826 |
|
3827 |
|
3828 | function GalleryRenderPart3(albumIdx) {
|
3829 | var d = new Date();
|
3830 |
|
3831 | G.$E.conTnParent.css( 'opacity', 1);
|
3832 |
|
3833 | G.GOM.items = [];
|
3834 | G.GOM.displayedMoreSteps = 0;
|
3835 |
|
3836 | if( G.O.thumbnailLabel.get('position') == 'onBottom' ) {
|
3837 |
|
3838 | G.tn.labelHeight[G.GOM.curNavLevel] = ThumbnailGetLabelHeight();
|
3839 | }
|
3840 | else {
|
3841 | G.tn.labelHeight[G.GOM.curNavLevel] = 0;
|
3842 | }
|
3843 | G.GOM.albumIdx=albumIdx;
|
3844 |
|
3845 | TriggerCustomEvent('galleryRenderEnd');
|
3846 | var fu=G.O.fnGalleryRenderEnd;
|
3847 | if( fu !== null ) {
|
3848 |
|
3849 | typeof fu == 'function' ? fu(G.I[G.GOM.albumIdx] ) : window[fu](G.I[G.GOM.albumIdx] );
|
3850 | }
|
3851 |
|
3852 |
|
3853 | if( GalleryPopulateGOM() ) {
|
3854 |
|
3855 | GallerySetLayout();
|
3856 |
|
3857 |
|
3858 | GalleryAppear();
|
3859 |
|
3860 |
|
3861 | GalleryDisplayPart1();
|
3862 | requestTimeout(function(){ GalleryDisplayPart2( false ) }, 20);
|
3863 | }
|
3864 | else {
|
3865 |
|
3866 | G.galleryResizeEventEnabled = true;
|
3867 | }
|
3868 |
|
3869 | if( G.O.debugMode ) { console.log('GalleryRenderPart3: '+ (new Date()-d)); }
|
3870 |
|
3871 | }
|
3872 |
|
3873 |
|
3874 |
|
3875 | function GalleryResize() {
|
3876 | var d = new Date();
|
3877 | G.galleryResizeEventEnabled = false;
|
3878 |
|
3879 | if( GallerySetLayout() == false ) {
|
3880 | G.galleryResizeEventEnabled = true;
|
3881 | if( G.O.debugMode ) { console.log('GalleryResize1: '+ (new Date()-d)); }
|
3882 | return;
|
3883 | }
|
3884 | if( G.O.debugMode ) { console.log('GalleryResizeSetLayout: '+ (new Date()-d)); }
|
3885 |
|
3886 | GalleryDisplayPart1();
|
3887 | GalleryDisplayPart2( false );
|
3888 |
|
3889 | if( G.O.debugMode ) { console.log('GalleryResizeFull: '+ (new Date()-d)); }
|
3890 | }
|
3891 |
|
3892 |
|
3893 |
|
3894 |
|
3895 |
|
3896 |
|
3897 | function GalleryPopulateGOM() {
|
3898 |
|
3899 | var preloadImages = '';
|
3900 | var albumID = G.I[G.GOM.albumIdx].GetID();
|
3901 | var l = G.I.length;
|
3902 | var cnt = 0;
|
3903 |
|
3904 | for( var idx = 0; idx < l; idx++ ) {
|
3905 | var item = G.I[idx];
|
3906 |
|
3907 | if( item.isToDisplay(albumID) ) {
|
3908 | var w = item.thumbImg().width;
|
3909 | var h = item.thumbImg().height;
|
3910 |
|
3911 | if( G.layout.prerequisite.imageSize && ( w == 0 || h == 0) ) {
|
3912 | preloadImages += '<img src="'+item.thumbImg().src+'" data-idx="'+cnt+'" data-albumidx="'+G.GOM.albumIdx+'">';
|
3913 | }
|
3914 |
|
3915 |
|
3916 | if( h == 0 ) {
|
3917 | h = G.tn.defaultSize.getHeight();
|
3918 | }
|
3919 | if( w == 0 ) {
|
3920 | w = G.tn.defaultSize.getWidth();
|
3921 | }
|
3922 | var tn = new G.GOM.GTn(idx, w, h);
|
3923 | G.GOM.items.push(tn);
|
3924 | cnt++;
|
3925 | }
|
3926 | }
|
3927 |
|
3928 | TriggerCustomEvent('galleryObjectModelBuilt');
|
3929 | var fu = G.O.fnGalleryObjectModelBuilt;
|
3930 | if( fu !== null ) {
|
3931 | typeof fu == 'function' ? fu() : window[fu]();
|
3932 | }
|
3933 |
|
3934 | if( preloadImages != '' ) {
|
3935 |
|
3936 | var $newImg = jQuery(preloadImages);
|
3937 | var gi_imgLoad = ngimagesLoaded( $newImg );
|
3938 | $newImg = null;
|
3939 | gi_imgLoad.on( 'progress', function( instance, image ) {
|
3940 |
|
3941 | if( image.isLoaded ) {
|
3942 | var idx = image.img.getAttribute('data-idx');
|
3943 | var albumIdx = image.img.getAttribute('data-albumidx');
|
3944 | if( albumIdx == G.GOM.albumIdx ) {
|
3945 |
|
3946 | var curTn = G.GOM.items[idx];
|
3947 | curTn.imageWidth = image.img.naturalWidth;
|
3948 | curTn.imageHeight = image.img.naturalHeight;
|
3949 | var item = G.I[curTn.thumbnailIdx];
|
3950 | item.thumbs.width[G.GOM.curNavLevel][G.GOM.curWidth] = curTn.imageWidth;
|
3951 | item.thumbs.height[G.GOM.curNavLevel][G.GOM.curWidth] = curTn.imageHeight;
|
3952 |
|
3953 |
|
3954 | G.GalleryResizeThrottled();
|
3955 |
|
3956 |
|
3957 | var object = item.thumbs.width.l1;
|
3958 | for (let property in object) {
|
3959 | if (object.hasOwnProperty(property)) {
|
3960 | if( property != G.GOM.curWidth ) {
|
3961 | if( G.tn.settings.width.l1[property] == G.tn.settings.getW() && G.tn.settings.height.l1[property] == G.tn.settings.getH() ) {
|
3962 | item.thumbs.width.l1[property] = curTn.imageWidth;
|
3963 | item.thumbs.height.l1[property] = curTn.imageHeight;
|
3964 | }
|
3965 | }
|
3966 | }
|
3967 | }
|
3968 | object = item.thumbs.width.lN;
|
3969 | for (let property in object) {
|
3970 | if (object.hasOwnProperty(property)) {
|
3971 | if( property != G.GOM.curWidth ) {
|
3972 | if( G.tn.settings.width.lN[property] == G.tn.settings.getW() && G.tn.settings.height.lN[property] == G.tn.settings.getH() ) {
|
3973 | item.thumbs.width.lN[property] = curTn.imageWidth;
|
3974 | item.thumbs.height.lN[property] = curTn.imageHeight;
|
3975 | }
|
3976 | }
|
3977 | }
|
3978 | }
|
3979 | }
|
3980 | }
|
3981 | });
|
3982 | G.galleryResizeEventEnabled = true;
|
3983 | return false;
|
3984 | }
|
3985 | else {
|
3986 | return true;
|
3987 | }
|
3988 |
|
3989 | }
|
3990 |
|
3991 |
|
3992 | function GallerySetLayout() {
|
3993 | var r = true;
|
3994 |
|
3995 | G.GOM.cache.areaWidth = G.$E.conTnParent.width();
|
3996 | G.GOM.displayArea = { width:0, height:0 };
|
3997 |
|
3998 | switch( G.layout.engine ) {
|
3999 | case 'JUSTIFIED':
|
4000 | r = GallerySetLayoutWidthtAuto();
|
4001 | break;
|
4002 | case 'CASCADING':
|
4003 | r = GallerySetLayoutHeightAuto();
|
4004 | break;
|
4005 | case 'MOSAIC':
|
4006 | r = GallerySetLayoutMosaic();
|
4007 | break;
|
4008 | case 'GRID':
|
4009 | default:
|
4010 | r = GallerySetLayoutGrid();
|
4011 | break;
|
4012 | }
|
4013 |
|
4014 | TriggerCustomEvent('galleryLayoutApplied');
|
4015 | var fu = G.O.fnGalleryLayoutApplied;
|
4016 | if( fu !== null ) {
|
4017 | typeof fu == 'function' ? fu() : window[fu]();
|
4018 | }
|
4019 | return r;
|
4020 |
|
4021 | }
|
4022 |
|
4023 |
|
4024 |
|
4025 | function GallerySetLayoutHeightAuto() {
|
4026 | var curCol = 0,
|
4027 | areaWidth = G.GOM.cache.areaWidth,
|
4028 | curRow = 0,
|
4029 | colHeight = [],
|
4030 | maxCol = NbThumbnailsPerRow(areaWidth),
|
4031 | gutterWidth = 0,
|
4032 | gutterHeight = G.tn.settings.GetResponsive('gutterHeight');
|
4033 | var w = 0;
|
4034 | var scaleFactor = 1;
|
4035 | var tnWidth = G.tn.defaultSize.getOuterWidth();
|
4036 | var nbTn = G.GOM.items.length;
|
4037 | var curPosY = 0;
|
4038 |
|
4039 | if( G.O.thumbnailAlignment == 'justified' ) {
|
4040 | maxCol = Math.min(maxCol, nbTn);
|
4041 | gutterWidth = ( maxCol == 1 ? 0 : (areaWidth - (maxCol * tnWidth) ) / (maxCol - 1) );
|
4042 | }
|
4043 | else {
|
4044 | gutterWidth = G.tn.settings.GetResponsive('gutterWidth');
|
4045 | }
|
4046 |
|
4047 |
|
4048 | var borderWidth = G.tn.opt.Get('borderHorizontal') * 2;
|
4049 | var borderHeight = G.tn.opt.Get('borderVertical') * 2;
|
4050 |
|
4051 | G.GOM.lastFullRow=-1;
|
4052 |
|
4053 |
|
4054 | if( G.O.thumbnailAlignment == 'fillWidth' ) {
|
4055 |
|
4056 | var totalGutterWidth = (maxCol - 1) * gutterWidth;
|
4057 | scaleFactor = (areaWidth - totalGutterWidth) / (maxCol * tnWidth);
|
4058 | if( scaleFactor > 1 ) {
|
4059 | maxCol++;
|
4060 | }
|
4061 | totalGutterWidth = (maxCol - 1) * gutterWidth;
|
4062 | scaleFactor = Math.min( (areaWidth - totalGutterWidth) / (maxCol*tnWidth), 1);
|
4063 | }
|
4064 |
|
4065 |
|
4066 | tnWidth = Math.round( tnWidth * scaleFactor);
|
4067 | var contentWidth = tnWidth - borderWidth;
|
4068 |
|
4069 |
|
4070 | var baseHeight = Math.round( G.tn.opt.Get('baseGridHeight') * scaleFactor );
|
4071 | for( var i = 0; i < nbTn ; i++ ) {
|
4072 | var curTn = G.GOM.items[i];
|
4073 | if( curTn.deleted == true ) { break; }
|
4074 | if( curTn.imageHeight > 0 && curTn.imageWidth > 0 ) {
|
4075 | var curPosX = 0,
|
4076 | curPosY = 0;
|
4077 | var imageRatio = curTn.imageHeight / curTn.imageWidth;
|
4078 |
|
4079 | curTn.resizedContentWidth = contentWidth;
|
4080 | curTn.resizedContentHeight = curTn.resizedContentWidth * imageRatio;
|
4081 | if( baseHeight > 0 ) {
|
4082 |
|
4083 | var t = Math.max( Math.trunc(curTn.resizedContentHeight/baseHeight), 1) ;
|
4084 | curTn.resizedContentHeight = baseHeight * t + ((t-1)*(borderHeight+gutterHeight));
|
4085 | }
|
4086 |
|
4087 | curTn.height = curTn.resizedContentHeight + borderHeight + G.tn.labelHeight.get();
|
4088 | curTn.width = tnWidth;
|
4089 | curTn.row = 0;
|
4090 |
|
4091 | if( curRow == 0 ) {
|
4092 |
|
4093 | curPosX = curCol * (tnWidth + gutterWidth);
|
4094 | colHeight[curCol] = curTn.height + gutterHeight;
|
4095 |
|
4096 | curCol++;
|
4097 | if( curCol >= maxCol ) {
|
4098 | curCol = 0;
|
4099 | curRow++;
|
4100 | }
|
4101 | }
|
4102 | else {
|
4103 | var c=0,
|
4104 | minColHeight=colHeight[0];
|
4105 | for( var j = 1; j < maxCol; j++) {
|
4106 | if( (colHeight[j] + 5) < minColHeight ) {
|
4107 | minColHeight = colHeight[j];
|
4108 | c = j;
|
4109 |
|
4110 | }
|
4111 | }
|
4112 | curPosY = colHeight[c];
|
4113 | curPosX = c * (tnWidth + gutterWidth);
|
4114 | colHeight[c] = curPosY + curTn.height + gutterHeight;
|
4115 | }
|
4116 |
|
4117 | var x = curPosX;
|
4118 | if( G.O.RTL) {
|
4119 | x= w - curPosX - tnWidth;
|
4120 | }
|
4121 |
|
4122 | curTn.left = x;
|
4123 | curTn.top = curPosY;
|
4124 | }
|
4125 | }
|
4126 |
|
4127 | G.GOM.displayArea.width= maxCol * (tnWidth + gutterWidth) - gutterWidth;
|
4128 | return true;
|
4129 | }
|
4130 |
|
4131 |
|
4132 |
|
4133 | function GallerySetLayoutWidthtAuto() {
|
4134 | var curWidth = 0,
|
4135 | areaWidth = G.GOM.cache.areaWidth,
|
4136 | lastPosX = 0,
|
4137 | curPosY = 0,
|
4138 | rowLastItem = [],
|
4139 | rowNum = 0,
|
4140 | rowHeight = [],
|
4141 | bNewRow = false,
|
4142 | cnt = 0,
|
4143 | gutterWidth = G.tn.settings.GetResponsive('gutterWidth'),
|
4144 | gutterHeight = G.tn.settings.GetResponsive('gutterHeight');
|
4145 |
|
4146 | var maxRowHeightVertical = 0;
|
4147 | var maxRowHeightHorizontal = 0;
|
4148 | var rowHasVertical = false;
|
4149 | var rowHasHorizontal = false;
|
4150 |
|
4151 | var tnHeight = G.tn.defaultSize.getOuterHeight();
|
4152 | var borderWidth = G.tn.opt.Get('borderHorizontal') * 2;
|
4153 | var borderHeight = G.tn.opt.Get('borderVertical') * 2;
|
4154 | var nbTnInCurrRow = 1;
|
4155 | var nbTn = G.GOM.items.length;
|
4156 |
|
4157 |
|
4158 | for( var i = 0; i < nbTn ; i++ ) {
|
4159 | let curTn = G.GOM.items[i];
|
4160 | if( curTn.deleted == true ) { break; }
|
4161 | if( curTn.imageWidth > 0 ) {
|
4162 | let imageRatio = curTn.imageWidth / curTn.imageHeight;
|
4163 | let imageWidth = Math.floor( tnHeight * imageRatio );
|
4164 |
|
4165 | if( bNewRow ) {
|
4166 | bNewRow = false;
|
4167 | rowNum++;
|
4168 | curWidth = 0;
|
4169 | rowHasVertical = false;
|
4170 | rowHasHorizontal = false;
|
4171 | nbTnInCurrRow = 1;
|
4172 | }
|
4173 |
|
4174 | if( curTn.imageHeight > curTn.imageWidth ) {
|
4175 | rowHasVertical = true;
|
4176 | }
|
4177 | else {
|
4178 | rowHasHorizontal = true;
|
4179 | }
|
4180 |
|
4181 | if( (curWidth + gutterWidth + imageWidth) < (areaWidth - (nbTnInCurrRow * borderWidth)) ) {
|
4182 |
|
4183 | curWidth += imageWidth + gutterWidth;
|
4184 | rowHeight[rowNum] = tnHeight;
|
4185 |
|
4186 |
|
4187 |
|
4188 | var rowHeightLimit = Math.max(rowHasVertical ? maxRowHeightVertical : 0, rowHasHorizontal ? maxRowHeightHorizontal : 0);
|
4189 | if( rowHeightLimit > 0 ) {
|
4190 | rowHeight[rowNum] = Math.min(rowHeight[rowNum], rowHeightLimit);
|
4191 | }
|
4192 |
|
4193 | rowLastItem[rowNum] = i;
|
4194 | }
|
4195 | else {
|
4196 |
|
4197 | curWidth += gutterWidth+imageWidth;
|
4198 | let ratio = (areaWidth - nbTnInCurrRow * borderWidth) / curWidth;
|
4199 | let rH = Math.floor(tnHeight * ratio);
|
4200 | rowHeight[rowNum] = rH;
|
4201 |
|
4202 |
|
4203 |
|
4204 | if( rowHasVertical ) {
|
4205 | maxRowHeightVertical = Math.max( maxRowHeightVertical, rH );
|
4206 | }
|
4207 | if( rowHasHorizontal ) {
|
4208 | maxRowHeightHorizontal = Math.max( maxRowHeightHorizontal, rH );
|
4209 | }
|
4210 |
|
4211 | rowLastItem[rowNum] = i;
|
4212 | bNewRow = true;
|
4213 | }
|
4214 | cnt++;
|
4215 | nbTnInCurrRow++;
|
4216 | }
|
4217 | }
|
4218 |
|
4219 | rowNum = 0;
|
4220 | curPosY = 0;
|
4221 | lastPosX = 0;
|
4222 | cnt = 0;
|
4223 |
|
4224 | G.GOM.lastFullRow = 0;
|
4225 |
|
4226 |
|
4227 | for( var i = 0; i < nbTn ; i++ ) {
|
4228 | let curTn = G.GOM.items[i];
|
4229 | if( curTn.imageWidth > 0 ) {
|
4230 | let imageRatio = curTn.imageWidth / curTn.imageHeight;
|
4231 | let imageWidth = Math.floor( imageRatio * rowHeight[rowNum] );
|
4232 |
|
4233 | if( i == rowLastItem[rowNum] ) {
|
4234 |
|
4235 | if( rowLastItem.length != (rowNum+1) ) {
|
4236 |
|
4237 | imageWidth = areaWidth - lastPosX - borderWidth;
|
4238 | }
|
4239 | else {
|
4240 |
|
4241 | if( (lastPosX + gutterWidth + imageWidth + borderWidth ) > areaWidth ) {
|
4242 |
|
4243 | imageWidth = areaWidth - lastPosX - borderWidth;
|
4244 | }
|
4245 | }
|
4246 | }
|
4247 |
|
4248 | let rh = parseInt( rowHeight[rowNum] );
|
4249 | imageWidth = parseInt( imageWidth );
|
4250 |
|
4251 |
|
4252 | curTn.resizedContentWidth = imageWidth;
|
4253 | curTn.resizedContentHeight = rh;
|
4254 |
|
4255 | curTn.width = imageWidth + borderWidth;
|
4256 | curTn.height= rh + G.tn.labelHeight.get() + borderHeight;
|
4257 | curTn.row = rowNum;
|
4258 |
|
4259 | curTn.top = curPosY;
|
4260 | let x = lastPosX;
|
4261 | if( G.O.RTL) {
|
4262 | x = areaWidth - lastPosX - curTn.width ;
|
4263 | }
|
4264 | curTn.left = x;
|
4265 |
|
4266 | lastPosX += curTn.width + gutterWidth;
|
4267 |
|
4268 | if( i == rowLastItem[rowNum] ) {
|
4269 |
|
4270 | curPosY += curTn.height + gutterHeight;
|
4271 | G.GOM.lastFullRow = rowNum - 1;
|
4272 | rowNum++;
|
4273 | lastPosX = 0;
|
4274 | }
|
4275 | cnt++;
|
4276 | }
|
4277 | else {
|
4278 | return false;
|
4279 | }
|
4280 | }
|
4281 |
|
4282 |
|
4283 | if( false ) {
|
4284 | var newTop = 0;
|
4285 | if( typeof GOMidx !== 'undefined' ) {
|
4286 | if( G.GOM.albumIdx != -1 ) {
|
4287 | var hoveredTn = G.GOM.items[GOMidx];
|
4288 |
|
4289 |
|
4290 | hoveredTn.width += 40;
|
4291 | hoveredTn.height += 40;
|
4292 |
|
4293 | for( var i = 0; i < nbTn ; i++ ) {
|
4294 | var curTn = G.GOM.items[i];
|
4295 | if( curTn.imageWidth > 0 ) {
|
4296 | if( curTn.row == hoveredTn.row ) {
|
4297 |
|
4298 | newTop = 40;
|
4299 | if( hoveredTn.thumbnailIdx != curTn.thumbnailIdx ) {
|
4300 |
|
4301 | curTn.top += 30;
|
4302 | curTn.width -= 20;
|
4303 | curTn.height -= 20;
|
4304 | }
|
4305 | }
|
4306 | else {
|
4307 |
|
4308 | if( curTn.row == 0 ) {
|
4309 |
|
4310 | }
|
4311 | else {
|
4312 | curTn.top += newTop;
|
4313 | }
|
4314 | }
|
4315 | }
|
4316 | }
|
4317 | }
|
4318 | }
|
4319 | }
|
4320 |
|
4321 | G.GOM.displayArea.width = areaWidth;
|
4322 | return true;
|
4323 | }
|
4324 |
|
4325 |
|
4326 |
|
4327 |
|
4328 |
|
4329 | function GallerySetLayoutMosaic() {
|
4330 | var areaWidth = G.GOM.cache.areaWidth;
|
4331 | var gutterHeight = G.tn.settings.GetResponsive('gutterHeight');
|
4332 | var gutterWidth = G.tn.settings.GetResponsive('gutterWidth');
|
4333 | var borderWidth = G.tn.opt.Get('borderHorizontal') * 2;
|
4334 | var borderHeight = G.tn.opt.Get('borderVertical') * 2;
|
4335 |
|
4336 | var nbTn = G.GOM.items.length;
|
4337 | var row = 0;
|
4338 | var h = 0;
|
4339 | var n = 0;
|
4340 |
|
4341 |
|
4342 |
|
4343 | var nbCols = 0;
|
4344 | var maxW = 0;
|
4345 | let mosaicPattern = G.tn.settings.getMosaic();
|
4346 | for( var i = 0; i < nbTn ; i++ ) {
|
4347 | let curPatternElt = mosaicPattern[n];
|
4348 |
|
4349 | var cLeft = (curPatternElt.c - 1) * G.tn.defaultSize.getOuterWidth() + (curPatternElt.c - 1) * gutterWidth;
|
4350 | var cWidth = curPatternElt.w * G.tn.defaultSize.getOuterWidth() + (curPatternElt.w - 1) * gutterWidth;
|
4351 |
|
4352 | maxW = Math.max(maxW, cLeft + cWidth );
|
4353 |
|
4354 | nbCols = Math.max(nbCols, (curPatternElt.c - 1) + curPatternElt.w );
|
4355 |
|
4356 | n++;
|
4357 | if( n >= mosaicPattern.length ) {
|
4358 |
|
4359 | break;
|
4360 | }
|
4361 | }
|
4362 | var totalGutterWidth = (nbCols - 1) * gutterWidth;
|
4363 | var scaleFactor = Math.min( (areaWidth - totalGutterWidth ) / ( maxW - totalGutterWidth ), 1);
|
4364 |
|
4365 |
|
4366 | row = 0;
|
4367 | n = 0;
|
4368 |
|
4369 | for( var i = 0; i < nbTn ; i++ ) {
|
4370 | let curTn = G.GOM.items[i];
|
4371 | let curPatternElt = mosaicPattern[n];
|
4372 |
|
4373 | curTn.top = Math.round((curPatternElt.r - 1) * G.tn.defaultSize.getOuterHeight()*scaleFactor) + (curPatternElt.r - 1) * gutterHeight + row * h + (G.tn.labelHeight.get()*(curPatternElt.r-1)) ;
|
4374 | if( row > 0 ) {
|
4375 | curTn.top += gutterHeight;
|
4376 | }
|
4377 |
|
4378 | curTn.left = (curPatternElt.c - 1) * Math.round(G.tn.defaultSize.getOuterWidth()*scaleFactor) + (curPatternElt.c - 1) * gutterWidth;
|
4379 |
|
4380 | curTn.height = Math.round(curPatternElt.h * G.tn.defaultSize.getOuterHeight() * scaleFactor) + (curPatternElt.h - 1) * gutterHeight + (G.tn.labelHeight.get() * curPatternElt.h);
|
4381 | curTn.resizedContentHeight = curTn.height - G.tn.labelHeight.get() - borderHeight;
|
4382 |
|
4383 | curTn.width = Math.round(curPatternElt.w * G.tn.defaultSize.getOuterWidth()*scaleFactor) + (curPatternElt.w - 1) * gutterWidth;
|
4384 | curTn.resizedContentWidth = curTn.width - borderWidth ;
|
4385 |
|
4386 | curTn.row = row;
|
4387 | if( row == 0 ) {
|
4388 | h=Math.max(h, curTn.top + curTn.height);
|
4389 | }
|
4390 |
|
4391 | n++;
|
4392 | if( n >= mosaicPattern.length ) {
|
4393 |
|
4394 | n = 0;
|
4395 | row++;
|
4396 | }
|
4397 | }
|
4398 |
|
4399 | G.GOM.displayArea.width = (maxW - totalGutterWidth) * scaleFactor + totalGutterWidth;
|
4400 | return true;
|
4401 | }
|
4402 |
|
4403 |
|
4404 |
|
4405 |
|
4406 | function GallerySetLayoutGrid() {
|
4407 | var curPosX= 0,
|
4408 | curPosY= 0,
|
4409 | areaWidth= G.GOM.cache.areaWidth,
|
4410 | gutterWidth= 0,
|
4411 | gutterHeight= G.tn.settings.GetResponsive('gutterHeight'),
|
4412 | maxCol= NbThumbnailsPerRow(areaWidth),
|
4413 | w= 0,
|
4414 | cols= [],
|
4415 | curCol= 0,
|
4416 | newAreaWidth = areaWidth,
|
4417 | tnWidth= G.tn.defaultSize.getOuterWidth();
|
4418 | var scaleFactor = 1;
|
4419 | var nbTn= G.GOM.items.length;
|
4420 | var borderWidth = G.tn.opt.Get('borderHorizontal') * 2;
|
4421 | var borderHeight = G.tn.opt.Get('borderVertical') * 2;
|
4422 |
|
4423 |
|
4424 | if( G.O.thumbnailAlignment == 'justified' ) {
|
4425 | maxCol = Math.min( maxCol, nbTn);
|
4426 | gutterWidth = (maxCol==1 ? 0 : (areaWidth-(maxCol*tnWidth))/(maxCol-1));
|
4427 | }
|
4428 | else {
|
4429 | gutterWidth = G.tn.settings.GetResponsive('gutterWidth');
|
4430 | }
|
4431 |
|
4432 |
|
4433 |
|
4434 | if( G.O.RTL || G.O.thumbnailAlignment == 'fillWidth' ) {
|
4435 |
|
4436 | var totalGutterWidth = (maxCol-1) * gutterWidth;
|
4437 | scaleFactor = (areaWidth - totalGutterWidth) / (maxCol*tnWidth);
|
4438 | if( scaleFactor > 1 ) {
|
4439 | maxCol++;
|
4440 | }
|
4441 | totalGutterWidth = (maxCol-1) * gutterWidth;
|
4442 | scaleFactor = Math.min( (areaWidth - totalGutterWidth) / (maxCol*tnWidth), 1);
|
4443 | newAreaWidth = (maxCol*tnWidth) + totalGutterWidth;
|
4444 | }
|
4445 |
|
4446 |
|
4447 | G.GOM.lastFullRow = 0 ;
|
4448 |
|
4449 | var row = 0;
|
4450 |
|
4451 | tnWidth = Math.round(tnWidth * scaleFactor);
|
4452 | var contentWidth = tnWidth - borderWidth;
|
4453 | var tnHeight = Math.round(G.tn.defaultSize.getOuterHeight() * scaleFactor) + G.tn.labelHeight.get();
|
4454 | var contentHeight = Math.round( G.tn.defaultSize.getOuterHeight() * scaleFactor) - borderHeight;
|
4455 |
|
4456 |
|
4457 | for( var i = 0; i < nbTn ; i++ ) {
|
4458 | if( curPosY == 0 ) {
|
4459 | curPosX = curCol * (tnWidth + gutterWidth)
|
4460 | cols[curCol] = curPosX;
|
4461 | w = curPosX + tnWidth;
|
4462 | }
|
4463 | else {
|
4464 | curPosX = cols[curCol];
|
4465 | }
|
4466 |
|
4467 | var x = curPosX;
|
4468 | if( G.O.RTL ) {
|
4469 | x = parseInt(newAreaWidth) - curPosX - tnWidth;
|
4470 | }
|
4471 |
|
4472 |
|
4473 | var curTn=G.GOM.items[i];
|
4474 | curTn.top = curPosY;
|
4475 | curTn.left = x;
|
4476 | curTn.height = tnHeight;
|
4477 | curTn.width = tnWidth;
|
4478 |
|
4479 | if( G.O.thumbnailAlignment == 'fillWidth' ) {
|
4480 | curTn.resizedContentWidth = contentWidth;
|
4481 | curTn.resizedContentHeight = contentHeight;
|
4482 | }
|
4483 | curTn.row = row;
|
4484 |
|
4485 |
|
4486 | curCol++;
|
4487 | if( curCol >= maxCol ){
|
4488 |
|
4489 | curCol = 0;
|
4490 | curPosY += tnHeight + gutterHeight;
|
4491 | G.GOM.lastFullRow = row;
|
4492 | row++;
|
4493 | }
|
4494 | }
|
4495 | G.GOM.displayArea.width = w;
|
4496 |
|
4497 | return true;
|
4498 | }
|
4499 |
|
4500 |
|
4501 |
|
4502 |
|
4503 |
|
4504 | function GalleryDisplayPart1() {
|
4505 | if( G.CSStransformName == null ) {
|
4506 | G.$E.conTn.css( 'left' , '0px');
|
4507 | }
|
4508 | else {
|
4509 | G.$E.conTn.css( G.CSStransformName , 'none');
|
4510 | }
|
4511 |
|
4512 | }
|
4513 |
|
4514 | function CacheViewport() {
|
4515 | G.GOM.cache.viewport = getViewport();
|
4516 |
|
4517 | G.GOM.cache.areaWidth = G.$E.base.width();
|
4518 |
|
4519 |
|
4520 |
|
4521 |
|
4522 |
|
4523 |
|
4524 | if( !G.O.lightboxStandalone ) {
|
4525 | G.GOM.cache.containerOffset = G.$E.conLoadingB.offset();
|
4526 | }
|
4527 | }
|
4528 |
|
4529 |
|
4530 |
|
4531 | function GalleryDisplayPart2( forceTransition ) {
|
4532 | CacheViewport();
|
4533 |
|
4534 | var nbTn = G.GOM.items.length;
|
4535 | G.GOM.itemsDisplayed = 0;
|
4536 | var threshold = 50;
|
4537 | var cnt = 0;
|
4538 |
|
4539 |
|
4540 | GalleryRenderGetInterval();
|
4541 |
|
4542 | for( var i = 0; i < nbTn ; i++ ) {
|
4543 | let curTn = G.GOM.items[i];
|
4544 | if( i >= G.GOM.displayInterval.from && cnt < G.GOM.displayInterval.len ) {
|
4545 | curTn.inDisplayArea = true;
|
4546 | if( forceTransition ) {
|
4547 | curTn.neverDisplayed = true;
|
4548 | }
|
4549 | G.GOM.itemsDisplayed++;
|
4550 | cnt++;
|
4551 | }
|
4552 | else{
|
4553 | curTn.inDisplayArea = false;
|
4554 | }
|
4555 | }
|
4556 |
|
4557 |
|
4558 | GalleryBottomManage();
|
4559 |
|
4560 | var tnToDisplay = [];
|
4561 | var tnToReDisplay = [];
|
4562 |
|
4563 | CacheViewport();
|
4564 | G.GOM.clipArea.top = -1;
|
4565 | cnt = 0 ;
|
4566 | var lastTnIdx = -1;
|
4567 | G.GOM.clipArea.height = 0;
|
4568 |
|
4569 | for( var i = 0; i < nbTn ; i++ ) {
|
4570 | let curTn = G.GOM.items[i];
|
4571 | if( curTn.inDisplayArea ) {
|
4572 | if( G.GOM.clipArea.top == -1 ) {
|
4573 | G.GOM.clipArea.top = curTn.top;
|
4574 | }
|
4575 | if( (curTn.top - G.GOM.clipArea.top) <= -1 ) {
|
4576 |
|
4577 | G.GOM.clipArea.top = curTn.top;
|
4578 | }
|
4579 |
|
4580 | G.GOM.clipArea.height = Math.max( G.GOM.clipArea.height, curTn.top-G.GOM.clipArea.top + curTn.height);
|
4581 |
|
4582 | if( curTn.neverDisplayed ) {
|
4583 |
|
4584 | var top = G.GOM.cache.containerOffset.top + (curTn.top - G.GOM.clipArea.top);
|
4585 |
|
4586 | if( (top + curTn.height) >= (G.GOM.cache.viewport.t - threshold) && top <= (G.GOM.cache.viewport.t + G.GOM.cache.viewport.h + threshold) ) {
|
4587 |
|
4588 | let item = G.I[curTn.thumbnailIdx];
|
4589 | if( item.$elt == null ) {
|
4590 |
|
4591 | ThumbnailBuild( item, curTn.thumbnailIdx, i );
|
4592 | }
|
4593 | tnToDisplay.push({idx:i, delay:cnt, top: curTn.top, left: curTn.left});
|
4594 | cnt++;
|
4595 | }
|
4596 | }
|
4597 | else {
|
4598 | tnToReDisplay.push({idx: i, delay: 0, top: curTn.top, left: curTn.left});
|
4599 | }
|
4600 |
|
4601 | lastTnIdx = i;
|
4602 | }
|
4603 | else {
|
4604 | curTn.displayed = false;
|
4605 | let item = G.I[curTn.thumbnailIdx];
|
4606 | if( item.$elt != null ){
|
4607 | item.$elt.css({ opacity: 0, display: 'none' });
|
4608 | }
|
4609 | }
|
4610 | }
|
4611 |
|
4612 | var areaWidth = G.$E.conTnParent.width();
|
4613 |
|
4614 |
|
4615 |
|
4616 | if( G.GOM.displayArea.width != G.GOM.displayAreaLast.width || G.GOM.clipArea.height != G.GOM.displayAreaLast.height ) {
|
4617 | G.$E.conTn.width( G.GOM.displayArea.width ).height( G.GOM.clipArea.height );
|
4618 | G.GOM.displayAreaLast.width = G.GOM.displayArea.width;
|
4619 | G.GOM.displayAreaLast.height = G.GOM.clipArea.height;
|
4620 |
|
4621 | }
|
4622 |
|
4623 | if( areaWidth != G.$E.conTnParent.width() ) {
|
4624 |
|
4625 |
|
4626 | G.GOM.cache.areaWidth = G.$E.conTnParent.width();
|
4627 | GallerySetLayout();
|
4628 | GalleryDisplayPart1();
|
4629 | GalleryDisplayPart2( forceTransition );
|
4630 | return;
|
4631 | }
|
4632 |
|
4633 |
|
4634 | if( G.layout.support.rows ) {
|
4635 | if( G.galleryDisplayMode.Get() == 'ROWS' || (G.galleryDisplayMode.Get() == 'FULLCONTENT' && G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1) ){
|
4636 | if( lastTnIdx < (nbTn - 1) ) {
|
4637 | G.GOM.lastDisplayedIdxNew = lastTnIdx;
|
4638 | }
|
4639 | else {
|
4640 | G.GOM.lastDisplayedIdxNew =- 1;
|
4641 | }
|
4642 |
|
4643 | if( G.GOM.lastDisplayedIdx != -1 ) {
|
4644 | let item = G.I[G.GOM.items[G.GOM.lastDisplayedIdx].thumbnailIdx];
|
4645 | item.$getElt('.nGY2GThumbnailIconsFullThumbnail').html('');
|
4646 | }
|
4647 | }
|
4648 | }
|
4649 |
|
4650 |
|
4651 |
|
4652 |
|
4653 |
|
4654 | G.GOM.thumbnails2Display=[];
|
4655 |
|
4656 | var duration = ThumbnailPreparePosition( tnToDisplay );
|
4657 | ThumbnailPreparePosition( tnToReDisplay );
|
4658 |
|
4659 | ThumbnailDisplayAnimBatch();
|
4660 |
|
4661 | if( G.tn.opt.Get('displayTransition') == 'NONE' ) {
|
4662 | G.galleryResizeEventEnabled = true;
|
4663 |
|
4664 | TriggerCustomEvent('galleryDisplayed');
|
4665 | }
|
4666 | else {
|
4667 |
|
4668 | requestTimeout( function() {
|
4669 |
|
4670 | G.galleryResizeEventEnabled = true;
|
4671 |
|
4672 | TriggerCustomEvent('galleryDisplayed');
|
4673 |
|
4674 | }, duration * G.tn.opt.Get('displayInterval'));
|
4675 | }
|
4676 |
|
4677 | }
|
4678 |
|
4679 |
|
4680 | function ThumbnailPreparePosition( lstThumb ) {
|
4681 |
|
4682 | var nbBuild = lstThumb.length;
|
4683 | if( nbBuild == 0 ) { return 0; }
|
4684 |
|
4685 |
|
4686 | var displayOrder = G.tn.opt.Get('displayOrder');
|
4687 |
|
4688 | if( displayOrder == 'random' ) {
|
4689 | NGY2Tools.AreaShuffle( lstThumb );
|
4690 | }
|
4691 | else {
|
4692 | if( displayOrder == 'rowByRow' && !( G.layout.engine == 'JUSTIFIED' || G.layout.engine == 'GRID' )) {
|
4693 | displayOrder = '';
|
4694 | }
|
4695 | if( (displayOrder == 'colFromRight' || displayOrder == 'colFromLeft' ) && !(G.layout.engine == 'CASCADING' || G.layout.engine == 'GRID' )) {
|
4696 | displayOrder = '';
|
4697 | }
|
4698 | }
|
4699 |
|
4700 |
|
4701 |
|
4702 | if( displayOrder == 'colFromRight' || displayOrder == 'colFromLeft' ) {
|
4703 | var tab = [];
|
4704 | var cols = [];
|
4705 | for( var i = 0; i < nbBuild ; i++ ) {
|
4706 | if( tab[lstThumb[i].left] == undefined ) {
|
4707 | tab[lstThumb[i].left] = [];
|
4708 | cols.push( lstThumb[i].left );
|
4709 | }
|
4710 | tab[lstThumb[i].left].push( lstThumb[i].idx )
|
4711 | }
|
4712 | if( displayOrder == 'colFromRight' ) {
|
4713 | cols = cols.reverse();
|
4714 | }
|
4715 | for( var i = 0; i < cols.length; i++ ) {
|
4716 | var col = cols[i];
|
4717 | for( var j = 0; j < tab[col].length; j++ ) {
|
4718 | ThumbnailSetPosition( tab[col][j], i);
|
4719 | }
|
4720 | }
|
4721 | return(i);
|
4722 | }
|
4723 |
|
4724 |
|
4725 |
|
4726 | var d = 0;
|
4727 | var top = lstThumb[0].top;
|
4728 | for( var i = 0; i < nbBuild ; i++ ) {
|
4729 |
|
4730 |
|
4731 |
|
4732 | if( displayOrder == 'rowByRow' ) {
|
4733 |
|
4734 | if( lstThumb[i].top > top ) {
|
4735 | d++;
|
4736 | top = lstThumb[i].top;
|
4737 | }
|
4738 | }
|
4739 | else {
|
4740 | d++;
|
4741 | }
|
4742 | ThumbnailSetPosition(lstThumb[i].idx, d);
|
4743 | }
|
4744 | return(d);
|
4745 |
|
4746 | }
|
4747 |
|
4748 |
|
4749 | function ThumbnailSetPosition( GOMidx, cnt ) {
|
4750 | var newTop= 0;
|
4751 | var curTn= G.GOM.items[GOMidx];
|
4752 | var idx= G.GOM.items[GOMidx].thumbnailIdx;
|
4753 | var item= G.I[idx];
|
4754 |
|
4755 | if( curTn.neverDisplayed ) {
|
4756 |
|
4757 | var top = curTn.top - G.GOM.clipArea.top;
|
4758 | if( G.tn.opt.Get('stacks') > 0 ) {
|
4759 |
|
4760 | item.$elt.last().css({ display: 'block'});
|
4761 | item.$elt.css({ top: top , left: curTn.left });
|
4762 | }
|
4763 | else {
|
4764 | item.$elt.css({ display: 'block', top: top , left: curTn.left });
|
4765 | }
|
4766 | newTop=top;
|
4767 |
|
4768 |
|
4769 | if( G.O.thumbnailWaitImageLoaded === true ) {
|
4770 | var gi_imgLoad = ngimagesLoaded( item.$getElt('.nGY2TnImg2') );
|
4771 | gi_imgLoad.on( 'progress', function( instance, image ) {
|
4772 | if( image.isLoaded ) {
|
4773 | var albumIdx = image.img.getAttribute('data-albumidx');
|
4774 | if( albumIdx == G.GOM.albumIdx ) {
|
4775 |
|
4776 | var idx = image.img.getAttribute('data-idx');
|
4777 | G.I[idx].ThumbnailImageReveal();
|
4778 | }
|
4779 | }
|
4780 | });
|
4781 | }
|
4782 |
|
4783 | ThumbnailAppear(GOMidx, cnt);
|
4784 |
|
4785 | curTn.displayed = true;
|
4786 | curTn.neverDisplayed = false;
|
4787 | }
|
4788 | else {
|
4789 | var topOld = G.GOM.cache.containerOffset.top + item.top;
|
4790 | var top = G.GOM.cache.containerOffset.top + (curTn.top - G.GOM.clipArea.top);
|
4791 | newTop = curTn.top - G.GOM.clipArea.top;
|
4792 | var vp = G.GOM.cache.viewport;
|
4793 | if( G.O.thumbnailDisplayOutsideScreen || ( ( (topOld + curTn.height) >= (vp.t - vp.h) && topOld <= (vp.t + vp.h * 4) ) ||
|
4794 | ( (top + curTn.height) >= (vp.t - vp.h) && top <= (vp.t + vp.h * 4) ) ) ) {
|
4795 |
|
4796 | if( curTn.displayed ) {
|
4797 |
|
4798 | if( item.top != curTn.top || item.left != curTn.left ) {
|
4799 |
|
4800 | if( G.O.galleryResizeAnimation == true ) {
|
4801 |
|
4802 | var tweenable = new NGTweenable();
|
4803 | tweenable.tween({
|
4804 | from: { top: item.top, left: item.left, height: item.height, width: item.width },
|
4805 | to: { top: newTop, left: curTn.left, height: curTn.height, width: curTn.width },
|
4806 | attachment: { $e: item.$elt },
|
4807 | duration: 100,
|
4808 | delay: cnt * G.tn.opt.Get('displayInterval') / 5,
|
4809 |
|
4810 | easing: 'easeOutQuart',
|
4811 | step: function (state, att) {
|
4812 |
|
4813 | att.$e.css(state);
|
4814 |
|
4815 | },
|
4816 | finish: function (state, att) {
|
4817 | var _this=this;
|
4818 |
|
4819 | _this.dispose();
|
4820 |
|
4821 | }
|
4822 | });
|
4823 | }
|
4824 | else {
|
4825 |
|
4826 |
|
4827 | item.$elt.css({ top: newTop , left: curTn.left });
|
4828 | }
|
4829 | }
|
4830 | }
|
4831 | else {
|
4832 |
|
4833 | curTn.displayed = true;
|
4834 |
|
4835 | item.$elt.css({ display: 'block', top: newTop, left: curTn.left, opacity: 1 });
|
4836 | ThumbnailAppearFinish(item);
|
4837 | }
|
4838 | }
|
4839 | else {
|
4840 |
|
4841 | curTn.displayed = false;
|
4842 | item.$elt.css({ display: 'none'});
|
4843 | }
|
4844 | }
|
4845 | item.left = curTn.left;
|
4846 | item.top = newTop;
|
4847 |
|
4848 |
|
4849 | if( item.width != curTn.width || item.height != curTn.height ) {
|
4850 | item.$elt.css({ width: curTn.width , height: curTn.height });
|
4851 | item.width = curTn.width;
|
4852 | item.height = curTn.height;
|
4853 |
|
4854 |
|
4855 |
|
4856 | if( item.resizedContentWidth != curTn.resizedContentWidth || item.resizedContentHeight != curTn.resizedContentHeight ) {
|
4857 | if( item.kind == 'albumUp' ) {
|
4858 |
|
4859 | }
|
4860 | else {
|
4861 | item.$getElt('.nGY2GThumbnailImage').css({'height': curTn.resizedContentHeight, 'width': curTn.resizedContentWidth});
|
4862 |
|
4863 | if( G.layout.engine == 'JUSTIFIED' ) {
|
4864 | item.$getElt('.nGY2GThumbnailImg').css({'height': curTn.resizedContentHeight, 'width': curTn.resizedContentWidth});
|
4865 | }
|
4866 | }
|
4867 | item.resizedContentWidth = curTn.resizedContentWidth;
|
4868 | item.resizedContentHeight = curTn.resizedContentHeight;
|
4869 | }
|
4870 | }
|
4871 |
|
4872 |
|
4873 |
|
4874 | if( G.GOM.lastDisplayedIdxNew == GOMidx && G.layout.support.rows ) {
|
4875 | if( (G.galleryDisplayMode.Get() == 'ROWS' && G.galleryMaxRows.Get() > 0) || (G.galleryDisplayMode.Get() == 'FULLCONTENT' && G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1) ){
|
4876 |
|
4877 | var nb = G.GOM.items.length - GOMidx - 1;
|
4878 | if( item.albumID != '0' && G.O.thumbnailLevelUp ) {
|
4879 | nb--;
|
4880 | }
|
4881 |
|
4882 | if( nb > 0 ) {
|
4883 |
|
4884 | if( G.O.thumbnailOpenInLightox || G.O.thumbnailSliderDelay > 0 ) {
|
4885 | item.$getElt('.nGY2GThumbnailIconsFullThumbnail').html( '+' + nb);
|
4886 | }
|
4887 |
|
4888 |
|
4889 |
|
4890 | if( G.O.thumbnailLabel.get('position') != 'right' && G.O.thumbnailLabel.get('position') != 'left' ) {
|
4891 | if( G.GOM.slider.hostItem != G.GOM.NGY2Item(GOMidx) ) {
|
4892 |
|
4893 |
|
4894 | GalleryThumbnailSliderSetContent( G.GOM.slider.hostItem );
|
4895 |
|
4896 | G.GOM.slider.hostIdx = GOMidx;
|
4897 | G.GOM.slider.hostItem = G.GOM.NGY2Item(GOMidx);
|
4898 | G.GOM.slider.nextIdx = GOMidx;
|
4899 | G.GOM.slider.currentIdx = GOMidx;
|
4900 | GalleryThumbnailSliderBuildAndStart();
|
4901 |
|
4902 | }
|
4903 | }
|
4904 | }
|
4905 | else {
|
4906 |
|
4907 | GalleryThumbnailSliderSetContent( G.GOM.slider.hostItem );
|
4908 | G.GOM.slider.hostIdx = -1;
|
4909 | }
|
4910 |
|
4911 | G.GOM.lastDisplayedIdx = GOMidx;
|
4912 | }
|
4913 | }
|
4914 |
|
4915 | }
|
4916 |
|
4917 |
|
4918 |
|
4919 |
|
4920 | function GalleryThumbnailSliderBuildAndStart() {
|
4921 |
|
4922 | if( G.O.thumbnailSliderDelay == 0 || G.GOM.slider.hostIdx == -1 ) {
|
4923 | return;
|
4924 | }
|
4925 | clearTimeout(G.GOM.slider.timerID);
|
4926 |
|
4927 | var item = G.GOM.slider.hostItem;
|
4928 |
|
4929 |
|
4930 | if( item.$getElt('.nGY2TnImgNext').length == 0 ) {
|
4931 | item.$getElt('.nGY2TnImg').clone().removeClass('nGY2TnImg').addClass('nGY2TnImgNext').insertAfter(item.$getElt('.nGY2TnImg'));
|
4932 | item.$getElt('.nGY2TnImgBack').clone().removeClass('nGY2TnImgBack').addClass('nGY2TnImgBackNext').insertAfter(item.$getElt('.nGY2TnImg', true));
|
4933 | item.$getElt('.nGY2GThumbnailImage', true);
|
4934 | item.$getElt('.nGY2GThumbnailImg', true);
|
4935 | }
|
4936 |
|
4937 | item.CSSTransformSet('.nGY2TnImgNext', 'translateX', '100%', true);
|
4938 | item.CSSTransformApply( '.nGY2TnImgNext' );
|
4939 | item.CSSTransformSet('.nGY2TnImgBackNext', 'translateX', '100%', true);
|
4940 | item.CSSTransformApply( '.nGY2TnImgBackNext' );
|
4941 |
|
4942 | GalleryThumbnailSliderSetNextContent();
|
4943 |
|
4944 |
|
4945 |
|
4946 | G.GOM.slider.timerID = requestTimeout(function(){ GalleryThumbnailSliderStartTransition() }, G.O.thumbnailSliderDelay);
|
4947 | }
|
4948 |
|
4949 |
|
4950 | function GalleryThumbnailSliderSetNextContent() {
|
4951 |
|
4952 | G.GOM.slider.nextIdx++;
|
4953 | if( G.GOM.slider.nextIdx >= G.GOM.items.length ) {
|
4954 | G.GOM.slider.nextIdx = G.GOM.slider.hostIdx;
|
4955 | }
|
4956 |
|
4957 |
|
4958 | var newItem = G.GOM.NGY2Item(G.GOM.slider.nextIdx);
|
4959 |
|
4960 | var bgImg = "url('" + G.emptyGif + "')";
|
4961 | if( newItem.imageDominantColors != null ) {
|
4962 |
|
4963 | bgImg = "url('" + newItem.imageDominantColors + "')";
|
4964 | }
|
4965 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgBackNext', true).css({'background-image': bgImg, opacity: 1 });
|
4966 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgNext', true).css({ 'background-image': "url('" + newItem.thumbImg().src + "')", opacity: 1 });
|
4967 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgNext .nGY2GThumbnailImg', true).attr('src', newItem.thumbImg().src );
|
4968 |
|
4969 |
|
4970 | }
|
4971 |
|
4972 |
|
4973 | function GalleryThumbnailSliderStartTransition() {
|
4974 |
|
4975 | if( G.GOM.slider.hostItem.$getElt() != null ) {
|
4976 |
|
4977 |
|
4978 | var tweenable = new NGTweenable();
|
4979 | G.GOM.slider.tween = tweenable;
|
4980 | tweenable.tween({
|
4981 | from: { 'left': 100 },
|
4982 | to: { 'left': 0 },
|
4983 | duration: 800,
|
4984 | delay: 0,
|
4985 |
|
4986 | easing: 'easeOutQuart',
|
4987 |
|
4988 | step: function (state) {
|
4989 | if( G.GOM.slider.hostItem.$getElt() == null ) {
|
4990 |
|
4991 | G.GOM.slider.tween.stop(false);
|
4992 | return;
|
4993 | }
|
4994 |
|
4995 |
|
4996 |
|
4997 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBack', 'translateX', -(100 - state.left) + '%');
|
4998 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBack' );
|
4999 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImg', 'translateX', -(100 - state.left) + '%');
|
5000 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImg' );
|
5001 |
|
5002 |
|
5003 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBackNext', 'translateX', state.left + '%');
|
5004 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBackNext' );
|
5005 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgNext', 'translateX', state.left + '%');
|
5006 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgNext' );
|
5007 |
|
5008 |
|
5009 |
|
5010 | },
|
5011 | finish: function (state) {
|
5012 | if( G.GOM.slider.hostItem.$getElt() == null ) {
|
5013 |
|
5014 | return;
|
5015 | }
|
5016 |
|
5017 | if( G.GOM.NGY2Item(G.GOM.slider.nextIdx) == null ) { return; }
|
5018 |
|
5019 |
|
5020 |
|
5021 | GalleryThumbnailSliderSetContent( G.GOM.NGY2Item(G.GOM.slider.nextIdx) );
|
5022 | G.GOM.slider.currentIdx = G.GOM.slider.nextIdx;
|
5023 | GalleryThumbnailSliderSetNextContent();
|
5024 |
|
5025 | clearTimeout(G.GOM.slider.timerID);
|
5026 |
|
5027 | G.GOM.slider.timerID = requestTimeout(function(){ GalleryThumbnailSliderStartTransition() }, G.O.thumbnailSliderDelay);
|
5028 |
|
5029 | }
|
5030 | });
|
5031 | }
|
5032 | }
|
5033 |
|
5034 |
|
5035 |
|
5036 | function GalleryThumbnailSliderSetContent( ngy2itemContent ) {
|
5037 | if( G.GOM.slider.hostIdx == -1 ) { return; }
|
5038 |
|
5039 | if( G.GOM.slider.tween != null ) {
|
5040 | if( G.GOM.slider.tween._isTweening == true ) {
|
5041 | G.GOM.slider.tween.stop(false);
|
5042 | }
|
5043 | }
|
5044 |
|
5045 | var bgImg = "url('" + G.emptyGif + "')";
|
5046 | if( ngy2itemContent.imageDominantColors != null ) {
|
5047 | bgImg = "url('" + ngy2itemContent.imageDominantColors + "')";
|
5048 | }
|
5049 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgBack').css('background-image', bgImg);
|
5050 | G.GOM.slider.hostItem.$getElt('.nGY2TnImg').css('background-image', "url('" + ngy2itemContent.thumbImg().src + "')" );
|
5051 | G.GOM.slider.hostItem.$getElt('.nGY2TnImg .nGY2GThumbnailImg').attr('src', ngy2itemContent.thumbImg().src );
|
5052 |
|
5053 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBack', 'translateX', '0');
|
5054 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBack' );
|
5055 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImg', 'translateX', '0');
|
5056 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImg' );
|
5057 |
|
5058 |
|
5059 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBackNext', 'translateX', '100%', true);
|
5060 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBackNext' );
|
5061 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgNext', 'translateX', '100%', true);
|
5062 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgNext' );
|
5063 |
|
5064 |
|
5065 | if( G.O.thumbnailLabel.get('display') == true ) {
|
5066 | var icons = G.O.icons.thumbnailAlbum;
|
5067 | if( ngy2itemContent.kind != 'album' ) {
|
5068 | icons = G.O.icons.thumbnailImage;
|
5069 | }
|
5070 | G.GOM.slider.hostItem.$getElt('.nGY2GThumbnailTitle').html(icons + getThumbnailTitle(ngy2itemContent));
|
5071 | G.GOM.slider.hostItem.$getElt('.nGY2GThumbnailDescription').html(icons + getTumbnailDescription(ngy2itemContent));
|
5072 | }
|
5073 | }
|
5074 |
|
5075 |
|
5076 |
|
5077 |
|
5078 | function ThumbnailGetLabelHeight() {
|
5079 | var newElt = [],
|
5080 | newEltIdx = 0;
|
5081 |
|
5082 |
|
5083 | if( G.O.thumbnailLabel.get('display') == false ) {
|
5084 | return 0;
|
5085 | }
|
5086 |
|
5087 |
|
5088 |
|
5089 |
|
5090 |
|
5091 |
|
5092 |
|
5093 | newElt[newEltIdx++] = '<div class="nGY2GThumbnail ' + G.O.theme + '" style="display:block;visibility:hidden;position:absolute;top:-9999px;left:-9999px;" ><div class="nGY2GThumbnailSub">';
|
5094 | if( G.O.thumbnailLabel.get('display') == true ) {
|
5095 |
|
5096 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailLabel" '+ G.tn.style.getLabel() +'>';
|
5097 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailAlbumTitle" '+G.tn.style.getTitle()+'>aAzZjJ</div>';
|
5098 | if( G.O.thumbnailLabel.get('displayDescription') == true ) {
|
5099 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailDescription" '+G.tn.style.getDesc()+'>'+'aAzZjJ'+'</div>';
|
5100 | }
|
5101 | newElt[newEltIdx++] = ' </div>';
|
5102 | }
|
5103 |
|
5104 | newElt[newEltIdx++] = '</div></div>';
|
5105 |
|
5106 | var $newDiv = jQuery(newElt.join('')).appendTo(G.$E.conTn);
|
5107 | var h = $newDiv.find('.nGY2GThumbnailLabel').outerHeight(true);
|
5108 | $newDiv.remove();
|
5109 |
|
5110 | return h;
|
5111 | }
|
5112 |
|
5113 | function ThumbnailBuildStacks( bgColor ) {
|
5114 | var ns=G.tn.opt.Get('stacks');
|
5115 | if( ns == 0 ) { return ''; }
|
5116 |
|
5117 | var s='';
|
5118 | for( var i=0; i<ns; i++ ) {
|
5119 | s='<div class="nGY2GThumbnailStack " style="display:none;'+bgColor+'"></div>'+s;
|
5120 | }
|
5121 | return s;
|
5122 | }
|
5123 |
|
5124 |
|
5125 | function ThumbnailBuildAlbumpUp( item, GOMidx ) {
|
5126 |
|
5127 | var newElt = [],
|
5128 | newEltIdx = 0;
|
5129 |
|
5130 | var mp = '';
|
5131 | if( G.O.thumbnailOpenInLightox === false ) {
|
5132 | mp = 'cursor:default;'
|
5133 | }
|
5134 |
|
5135 | newElt[newEltIdx++] = ThumbnailBuildStacks('') + '<div class="nGY2GThumbnail" style="display:none;opacity:0;' + mp + '" >';
|
5136 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailSub">';
|
5137 |
|
5138 | var h=G.tn.defaultSize.getHeight(),
|
5139 | w=G.tn.defaultSize.getWidth();
|
5140 |
|
5141 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailImage" style="width:'+w+'px;height:'+h+'px;"><img class="nGY2GThumbnailImg" src="'+G.emptyGif+'" alt="" style="max-width:'+w+'px;max-height:'+h+'px;" ></div>';
|
5142 |
|
5143 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailAlbumUp" >'+G.O.icons.thumbnailAlbumUp+'</div>';
|
5144 | newElt[newEltIdx++] = ' </div>';
|
5145 | newElt[newEltIdx++] = '</div>';
|
5146 |
|
5147 | var $newDiv = jQuery(newElt.join('')).appendTo(G.$E.conTn);
|
5148 |
|
5149 | item.$elt = $newDiv;
|
5150 | $newDiv.data('index', GOMidx);
|
5151 | item.$getElt('.nGY2GThumbnailImg').data('index', GOMidx);
|
5152 |
|
5153 | return;
|
5154 | }
|
5155 |
|
5156 |
|
5157 |
|
5158 | function ThumbnailBuild( item, idx, GOMidx ) {
|
5159 |
|
5160 | item.eltTransform = [];
|
5161 | item.eltFilter = [];
|
5162 | item.hoverInitDone = false;
|
5163 | item.$Elts = [];
|
5164 |
|
5165 | if( item.kind == 'albumUp' ) {
|
5166 | ThumbnailBuildAlbumpUp( item, GOMidx);
|
5167 | return;
|
5168 | }
|
5169 |
|
5170 | var newElt = [],
|
5171 | newEltIdx = 0;
|
5172 |
|
5173 | var mp = '';
|
5174 | if( G.O.thumbnailOpenInLightox === false ) {
|
5175 | mp = 'cursor:default;'
|
5176 | }
|
5177 |
|
5178 |
|
5179 |
|
5180 | var src = (item.thumbImg().src).replace(/'/g, "%27"),
|
5181 | sTitle = getThumbnailTitle(item);
|
5182 |
|
5183 |
|
5184 | var bg = '';
|
5185 | var bgImg = "background-image: url('" + G.emptyGif + "');";
|
5186 | if( item.imageDominantColors != null ) {
|
5187 |
|
5188 | bgImg = "background-image: url('" + item.imageDominantColors + "');";
|
5189 | }
|
5190 | else {
|
5191 |
|
5192 | if( item.imageDominantColor != null ) {
|
5193 | bg = 'background-color:' + item.imageDominantColor + ';';
|
5194 | }
|
5195 | else {
|
5196 | bgImg = '';
|
5197 | }
|
5198 | }
|
5199 |
|
5200 | var op = 'opacity:1;';
|
5201 | if( G.O.thumbnailWaitImageLoaded == true ) {
|
5202 | op = 'opacity:0;';
|
5203 | }
|
5204 |
|
5205 |
|
5206 | newElt[newEltIdx++] = ThumbnailBuildStacks(bg) + '<div class="nGY2GThumbnail nGY2GThumbnail_'+G.GOM.curNavLevel+'" style="display:none;opacity:0;' + mp + '"><div class="nGY2GThumbnailSub ' + ( G.O.thumbnailSelectable && item.selected ? "nGY2GThumbnailSubSelected" : "" ) + '">';
|
5207 |
|
5208 |
|
5209 |
|
5210 | var w = G.tn.settings.getW();
|
5211 | var h = G.tn.settings.getH();
|
5212 | if( G.tn.settings.getMosaic() !== null ) {
|
5213 |
|
5214 | w = G.GOM.items[GOMidx].width;
|
5215 | h = G.GOM.items[GOMidx].height;
|
5216 | }
|
5217 |
|
5218 | var bgSize = 'contain';
|
5219 | if( G.tn.opt.Get('crop') ) {
|
5220 | bgSize = 'cover';
|
5221 | }
|
5222 |
|
5223 |
|
5224 | var s1 = "position: absolute; top: 0px; left: 0px; width:" + w + "px; height:" + h + "px;"+ bg + bgImg + " background-position: center center; background-repeat: no-repeat; background-size:" + bgSize + "; overflow: hidden;";
|
5225 | newElt[newEltIdx++]='<div class="nGY2GThumbnailImage nGY2TnImgBack" style="' + s1 + '"></div>';
|
5226 |
|
5227 |
|
5228 |
|
5229 | var s2 = op + "position: absolute; top: 0px; left: 0px; width:" + w + "px; height:" + h + "px; background-image: url('" + src.replace(/\\/g, '\\\\') + "'); background-position: center center; background-repeat: no-repeat; background-size:" + bgSize + "; overflow: hidden;";
|
5230 | newElt[newEltIdx++]='<div class="nGY2GThumbnailImage nGY2TnImg" style="' + s2 + '">';
|
5231 | newElt[newEltIdx++]=' <img class="nGY2GThumbnailImg nGY2TnImg2" src="' + src + '" alt="' + sTitle + '" style="opacity:0;" data-idx="' + idx + '" data-albumidx="' + G.GOM.albumIdx + '" >';
|
5232 | newElt[newEltIdx++]='</div>';
|
5233 |
|
5234 |
|
5235 | newElt[newEltIdx++]='<div class="nGY2GThumbnailCustomLayer"></div>';
|
5236 |
|
5237 |
|
5238 | if( G.O.thumbnailLabel.get('display') == true ) {
|
5239 |
|
5240 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailLabel" '+ G.tn.style.getLabel(item) + '>';
|
5241 | if( item.kind == 'album' ) {
|
5242 |
|
5243 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailTitle nGY2GThumbnailAlbumTitle" ' + G.tn.style.getTitle() + '>' + G.O.icons.thumbnailAlbum + sTitle + '</div>';
|
5244 | }
|
5245 | else {
|
5246 |
|
5247 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailTitle nGY2GThumbnailImageTitle" ' + G.tn.style.getTitle() + '>' + G.O.icons.thumbnailImage + sTitle + '</div>';
|
5248 | }
|
5249 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailDescription" ' + G.tn.style.getDesc() + '>' + getTumbnailDescription(item) + '</div>';
|
5250 | newElt[newEltIdx++]= ' </div>';
|
5251 | }
|
5252 |
|
5253 |
|
5254 |
|
5255 | newElt[newEltIdx++] = ThumbnailBuildTools(item);
|
5256 |
|
5257 |
|
5258 | newElt[newEltIdx++]='</div></div>';
|
5259 |
|
5260 | var $newDiv =jQuery(newElt.join('')).appendTo(G.$E.conTn);
|
5261 |
|
5262 | item.$elt=$newDiv;
|
5263 | $newDiv.data('index',GOMidx);
|
5264 | item.$getElt('.nGY2GThumbnailImg').data('index',GOMidx);
|
5265 |
|
5266 |
|
5267 | var fu=G.O.fnThumbnailInit;
|
5268 | if( fu !== null ) {
|
5269 | typeof fu == 'function' ? fu($newDiv, item, GOMidx) : window[fu]($newDiv, item, GOMidx);
|
5270 | }
|
5271 |
|
5272 | if( item.title != 'image gallery by nanogallery2 [build]' ) {
|
5273 | ThumbnailOverInit(GOMidx);
|
5274 | }
|
5275 |
|
5276 | return ;
|
5277 | }
|
5278 |
|
5279 |
|
5280 |
|
5281 | function ThumbnailBuildTools( item ) {
|
5282 |
|
5283 |
|
5284 | var tb = ThumbnailBuildToolbarOne(item, 'topLeft') + ThumbnailBuildToolbarOne(item, 'topRight') + ThumbnailBuildToolbarOne(item, 'bottomLeft') + ThumbnailBuildToolbarOne(item, 'bottomRight');
|
5285 |
|
5286 |
|
5287 | tb += '<div class="nGY2GThumbnailIconsFullThumbnail"></div>';
|
5288 |
|
5289 | return tb;
|
5290 | }
|
5291 |
|
5292 | function ThumbnailBuildToolbarOne( item, position ) {
|
5293 | var toolbar = '';
|
5294 | var tb = G.tn.toolbar.get(item);
|
5295 | var width = { xs:0, sm:1, me:2, la:3, xl:4 };
|
5296 | var cnt = 0;
|
5297 |
|
5298 | if( tb[position] != '' ) {
|
5299 | var pos='top: 0; right: 0; text-align: right;';
|
5300 | switch( position ) {
|
5301 | case 'topLeft':
|
5302 | pos = 'top: 0; left: 0; text-align: left;';
|
5303 | break;
|
5304 | case 'bottomRight':
|
5305 | pos = 'bottom: 0; right: 0; text-align: right;';
|
5306 | break;
|
5307 | case 'bottomLeft':
|
5308 | pos = 'bottom: 0; left: 0; text-align: left;';
|
5309 | break;
|
5310 | }
|
5311 |
|
5312 | toolbar += ' <ul class="nGY2GThumbnailIcons" style="' + pos + '">';
|
5313 |
|
5314 | var icons = tb[position].split(',');
|
5315 | var nb = icons.length;
|
5316 | for( var i = 0; i < nb; i++ ) {
|
5317 | var icon = icons[i].replace(/^\s*|\s*$/, '');
|
5318 |
|
5319 | var minWidth = icon.substring(0,2).toLowerCase();
|
5320 | var tIcon = icon;
|
5321 | var display = true;
|
5322 | if( /xs|sm|me|la|xl/i.test(minWidth) ) {
|
5323 |
|
5324 | if( width[minWidth] > width[G.GOM.curWidth] ) {
|
5325 | display = false;
|
5326 | }
|
5327 | tIcon = icon.substring(2);
|
5328 | }
|
5329 |
|
5330 | if( display ) {
|
5331 | var sp=(i+1<nb ? ' ' :'');
|
5332 | switch( tIcon ) {
|
5333 | case 'COUNTER':
|
5334 | if( item.kind == 'album' ) {
|
5335 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="">';
|
5336 | toolbar += ' <div class="nGY2GThumbnailIconImageCounter"></div>';
|
5337 | toolbar += ' <div class="nGY2GThumbnailIconText">' + G.O.icons.thumbnailCounter+Math.max((item.getContentLength(false)),item.numberItems) + sp + '</div>';
|
5338 | toolbar += ' </li>';
|
5339 | cnt++;
|
5340 | }
|
5341 | break;
|
5342 | case 'COUNTER2':
|
5343 | if( item.kind == 'album' ) {
|
5344 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="">';
|
5345 | toolbar += ' <div class="nGY2GThumbnailIconTextBadge">' + G.O.icons.thumbnailCounter+Math.max((item.getContentLength(false)),item.numberItems) + sp + '</div>';
|
5346 | toolbar += ' </li>';
|
5347 | cnt++;
|
5348 | }
|
5349 | break;
|
5350 | case 'SHARE':
|
5351 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
5352 | toolbar += ' <div>' + G.O.icons.thumbnailShare + '</div>';
|
5353 | toolbar += ' </li>';
|
5354 | cnt++;
|
5355 | break;
|
5356 | case 'DOWNLOAD':
|
5357 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
5358 | toolbar += ' <div>' + G.O.icons.thumbnailDownload + '</div>';
|
5359 | toolbar += ' </li>';
|
5360 | cnt++;
|
5361 | break;
|
5362 | case 'INFO':
|
5363 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
5364 | toolbar += ' <div>' + G.O.icons.thumbnailInfo + '</div>';
|
5365 | toolbar += ' </li>';
|
5366 | cnt++;
|
5367 | break;
|
5368 | case 'SHOPPINGCART':
|
5369 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
5370 |
|
5371 | toolbar += ThumbnailBuildToolbarOneCart( item );
|
5372 |
|
5373 | toolbar += ' </li>';
|
5374 | cnt++;
|
5375 | break;
|
5376 | case 'DISPLAY':
|
5377 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="DISPLAY">';
|
5378 | toolbar += ' <div class="nGY2GThumbnailIconImageShare">' + G.O.icons.thumbnailDisplay + '</div>';
|
5379 | toolbar += ' </li>';
|
5380 | cnt++;
|
5381 | break;
|
5382 | case 'CUSTOM1':
|
5383 | case 'CUSTOM2':
|
5384 | case 'CUSTOM3':
|
5385 | case 'CUSTOM4':
|
5386 | case 'CUSTOM5':
|
5387 | case 'CUSTOM6':
|
5388 | case 'CUSTOM7':
|
5389 | case 'CUSTOM8':
|
5390 | case 'CUSTOM9':
|
5391 | case 'CUSTOM10':
|
5392 | var cust = tIcon.replace('CUSTOM', '');
|
5393 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon.toLowerCase() + '">';
|
5394 | toolbar += ' <div class="nGY2GThumbnailIconImageShare">' + G.O.icons['thumbnailCustomTool' + cust] + '</div>';
|
5395 | toolbar += ' </li>';
|
5396 | cnt++;
|
5397 | break;
|
5398 | case 'FEATURED':
|
5399 | if( item.featured === true ) {
|
5400 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="">';
|
5401 | toolbar += ' <div class="nGY2GThumbnailIconImageFeatured">' + G.O.icons.thumbnailFeatured + '</div>';
|
5402 | toolbar += ' </li>';
|
5403 | cnt++;
|
5404 | }
|
5405 | break;
|
5406 | case 'SELECT':
|
5407 | if( G.O.thumbnailSelectable == true ) {
|
5408 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="TOGGLESELECT">';
|
5409 | if( item.selected === true ) {
|
5410 | toolbar += ' <div class="nGY2GThumbnailIconImageSelect nGY2ThumbnailSelected">' + G.O.icons.thumbnailSelected + '</div>';
|
5411 | }
|
5412 | else {
|
5413 | toolbar += ' <div class="nGY2GThumbnailIconImageSelect nGY2ThumbnailUnselected">' + G.O.icons.thumbnailUnselected + '</div>';
|
5414 | }
|
5415 | toolbar += ' </li>';
|
5416 | cnt++;
|
5417 | }
|
5418 | break;
|
5419 | }
|
5420 | }
|
5421 | }
|
5422 | toolbar += ' </ul>';
|
5423 | }
|
5424 |
|
5425 | if( cnt > 0 ) {
|
5426 | return toolbar;
|
5427 | }
|
5428 | else {
|
5429 | return '';
|
5430 | }
|
5431 | }
|
5432 |
|
5433 |
|
5434 | function ThumbnailBuildToolbarOneCart( item ) {
|
5435 | var q = 0;
|
5436 |
|
5437 | var id = item.GetID()
|
5438 | for( var i=0; i<G.shoppingCart.length; i++ ) {
|
5439 | if( G.I[G.shoppingCart[i].idx].GetID() == id ) {
|
5440 | q = G.shoppingCart[i].qty;
|
5441 | }
|
5442 | }
|
5443 | if( q == 0 ) {
|
5444 | q = '';
|
5445 | }
|
5446 |
|
5447 | return ' <div>' + G.O.icons.thumbnailShoppingcart + q + '</div>';
|
5448 | }
|
5449 | function ThumbnailBuildToolbarOneCartUpdate( item ) {
|
5450 | var $e = item.$elt;
|
5451 |
|
5452 | if( $e != null ) {
|
5453 | var $q = $e.find('*[data-ngy2action="SHOPPINGCART"]');
|
5454 | if( $q !== undefined ) {
|
5455 | $q.html( ThumbnailBuildToolbarOneCart( item ) );
|
5456 | }
|
5457 | }
|
5458 | }
|
5459 |
|
5460 | function getThumbnailTitle( item ) {
|
5461 |
|
5462 | var sTitle = item.title;
|
5463 | if( G.O.thumbnailLabel.get('display') == true ) {
|
5464 | if( sTitle === undefined || sTitle.length == 0 ) { sTitle = ' '; }
|
5465 |
|
5466 | if( G.i18nTranslations.thumbnailImageTitle != '' ) {
|
5467 | sTitle = G.i18nTranslations.thumbnailImageTitle;
|
5468 | }
|
5469 | var ml = G.O.thumbnailLabel.get('titleMaxLength');
|
5470 | if( ml > 3 && sTitle.length > ml ){
|
5471 | sTitle = sTitle.substring(0, ml) + '...';
|
5472 | }
|
5473 | }
|
5474 |
|
5475 | return sTitle;
|
5476 | }
|
5477 |
|
5478 | function getTumbnailDescription( item ) {
|
5479 | var sDesc = '';
|
5480 | if( G.O.thumbnailLabel.get('displayDescription') == true ) {
|
5481 | if( item.kind == 'album' ) {
|
5482 | if( G.i18nTranslations.thumbnailImageDescription != '' ) {
|
5483 | sDesc = G.i18nTranslations.thumbnailAlbumDescription;
|
5484 | }
|
5485 | else {
|
5486 | sDesc = item.description;
|
5487 | }
|
5488 | }
|
5489 | else {
|
5490 | if( G.i18nTranslations.thumbnailImageDescription != '' ) {
|
5491 | sDesc = G.i18nTranslations.thumbnailImageDescription;
|
5492 | }
|
5493 | else {
|
5494 | sDesc = item.description;
|
5495 | }
|
5496 | }
|
5497 | var ml = G.O.thumbnailLabel.get('descriptionMaxLength');
|
5498 | if( ml > 3 && sDesc.length > ml ){
|
5499 | sDesc = sDesc.substring(0, ml) + '...';
|
5500 | }
|
5501 | if( sDesc.length == 0 ) {
|
5502 | sDesc = ' ';
|
5503 | }
|
5504 | }
|
5505 |
|
5506 | return sDesc;
|
5507 | }
|
5508 |
|
5509 |
|
5510 |
|
5511 |
|
5512 | function NbThumbnailsPerRow( areaWidth ) {
|
5513 | var tnW = G.tn.defaultSize.getOuterWidth();
|
5514 |
|
5515 | var nbMaxTn = 0;
|
5516 | if( G.O.thumbnailAlignment == 'justified' ) {
|
5517 | nbMaxTn = Math.floor((areaWidth)/(tnW));
|
5518 | }
|
5519 | else {
|
5520 | nbMaxTn = Math.floor((areaWidth + G.tn.settings.GetResponsive('gutterWidth'))/(tnW + G.tn.settings.GetResponsive('gutterWidth')));
|
5521 | }
|
5522 |
|
5523 | if( G.O.maxItemsPerLine >0 && nbMaxTn > G.O.maxItemsPerLine ) {
|
5524 | nbMaxTn = G.O.maxItemsPerLine;
|
5525 | }
|
5526 |
|
5527 | if( nbMaxTn < 1 ) { nbMaxTn = 1; }
|
5528 |
|
5529 | return nbMaxTn
|
5530 | }
|
5531 |
|
5532 |
|
5533 | function ThumbnailAppear( n, cnt ) {
|
5534 | var curTn = G.GOM.items[n];
|
5535 | var item = G.I[curTn.thumbnailIdx];
|
5536 |
|
5537 |
|
5538 | if( G.tn.opt.Get('displayTransition') == 'NONE' ) {
|
5539 | item.$elt.css({ opacity: 1 });
|
5540 | ThumbnailAppearFinish( item );
|
5541 | }
|
5542 | else {
|
5543 | if( item.$elt == null ) { return; }
|
5544 | var top = G.GOM.cache.containerOffset.top + ( curTn.top - G.GOM.clipArea.top );
|
5545 | var vp = G.GOM.cache.viewport;
|
5546 | if( (top + (curTn.top - G.GOM.clipArea.top)) >= (vp.t - 50) && top <= (vp.t + vp.h + 50) ) {
|
5547 |
|
5548 | var delay = cnt * G.tn.opt.Get('displayInterval');
|
5549 | if( G.tn.opt.Get('displayTransition') == 'CUSTOM' ) {
|
5550 | if( G.GOM.curNavLevel == 'lN' ) {
|
5551 | G.O.fnThumbnailDisplayEffect(item.$elt, item, n, delay);
|
5552 | }
|
5553 | else {
|
5554 | G.O.fnThumbnailL1DisplayEffect(item.$elt, item, n, delay);
|
5555 | }
|
5556 | }
|
5557 | else {
|
5558 | G.GOM.thumbnails2Display.push({itm: item, d: delay});
|
5559 |
|
5560 | }
|
5561 | return;
|
5562 | }
|
5563 | else {
|
5564 | item.$elt.css({ opacity: 1 });
|
5565 | ThumbnailAppearFinish(item);
|
5566 | }
|
5567 | }
|
5568 | }
|
5569 |
|
5570 |
|
5571 |
|
5572 | function ThumbnailAppearFinish( item ) {
|
5573 |
|
5574 |
|
5575 | var ns = G.tn.opt.Get('stacks');
|
5576 | if( ns > 0 ) {
|
5577 |
|
5578 | item.$elt.css({ display: 'block'});
|
5579 | var o = 0.9;
|
5580 |
|
5581 | for( var i = ns-1; i>=0; i-- ) {
|
5582 | item.$elt.eq(i).css('opacity', o);
|
5583 | o = o - 0.2;
|
5584 | }
|
5585 |
|
5586 | }
|
5587 | }
|
5588 |
|
5589 |
|
5590 | function ThumbnailDisplayAnim2( item, delay ) {
|
5591 | function randomIntFromInterval(min,max) {
|
5592 | return Math.floor(Math.random()*(max-min+1)+min);
|
5593 | }
|
5594 | var oFrom = {};
|
5595 | var oTo = {};
|
5596 |
|
5597 | switch (G.tn.opt.Get('displayTransition')) {
|
5598 | case 'RANDOMSCALE': {
|
5599 | var scales = [0.95, 1, 1.05, 1.1];
|
5600 | var zi = [1, 2, 3, 4];
|
5601 |
|
5602 | var r = randomIntFromInterval(0,3);
|
5603 | while( r == G.GOM.lastRandomValue ) {
|
5604 | r = randomIntFromInterval(0,3);
|
5605 | }
|
5606 | G.GOM.lastRandomValue = r;
|
5607 | let f = scales[r];
|
5608 |
|
5609 | item.$elt.css({ 'z-index': G.GOM.lastZIndex+zi[r], 'box-shadow': '0px 0px 5px 3px rgba(0,0,0,0.74)' });
|
5610 |
|
5611 | oFrom = { scale: 0.5, opacity:0 };
|
5612 | oTo = { scale: f, opacity:1 };
|
5613 | break;
|
5614 | }
|
5615 |
|
5616 | case 'SCALEUP': {
|
5617 | let f = G.tn.opt.Get('displayTransitionStartVal');
|
5618 | if( f == 0 ) { f = 0.6; }
|
5619 | oFrom = { scale: f, opacity: 0 };
|
5620 | oTo = { scale: 1, opacity: 1 };
|
5621 | break;
|
5622 | }
|
5623 |
|
5624 | case 'SCALEDOWN': {
|
5625 | let f = G.tn.opt.Get('displayTransitionStartVal');
|
5626 | if( f == 0 ) { f=1.3; }
|
5627 | oFrom = { scale: f, opacity: 0 };
|
5628 | oTo = { scale: 1, opacity: 1 };
|
5629 | break;
|
5630 | }
|
5631 | case 'SLIDEUP': {
|
5632 | let f = G.tn.opt.Get('displayTransitionStartVal');
|
5633 | if( f == 0 ) { f=50; }
|
5634 | oFrom = { opacity: 0, translateY: f };
|
5635 | oTo = { opacity: 1, translateY: 0 };
|
5636 | break;
|
5637 | }
|
5638 | case 'SLIDEDOWN': {
|
5639 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5640 | if( f == 0 ) { f=-50; }
|
5641 | oFrom = { opacity: 0, translateY: f };
|
5642 | oTo = { opacity: 1, translateY: 0 };
|
5643 | break;
|
5644 | }
|
5645 | case 'FLIPUP': {
|
5646 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5647 | if( f == 0 ) { f=100; }
|
5648 | oFrom = { opacity: 0, translateY: f, rotateX: 45 };
|
5649 | oTo = { opacity: 1, translateY: 0, rotateX: 0 };
|
5650 | break;
|
5651 | }
|
5652 | case 'FLIPDOWN': {
|
5653 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5654 | if( f == 0 ) { f=-100; }
|
5655 | oFrom = { opacity: 0, translateY: f, rotateX: -45 };
|
5656 | oTo = { opacity: 1, translateY: 0, rotateX: 0 };
|
5657 | break;
|
5658 | }
|
5659 | case 'SLIDEUP2': {
|
5660 | let f = G.tn.opt.Get('displayTransitionStartVal');
|
5661 | if( f == 0 ) { f=100; }
|
5662 | oFrom = { opacity: 0, translateY: f, rotateY: 40 };
|
5663 | oTo = { opacity: 1, translateY: 0, rotateY: 0 };
|
5664 | break;
|
5665 | }
|
5666 | case 'IMAGESLIDEUP': {
|
5667 |
|
5668 |
|
5669 | oFrom = { opacity: 0, top: '100%' };
|
5670 | oTo = { opacity: 1, top: '0%' };
|
5671 | break;
|
5672 | }
|
5673 | case 'SLIDEDOWN2': {
|
5674 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5675 | if( f == 0 ) { f=-100; }
|
5676 | oFrom = { opacity: 0, translateY: f, rotateY: 40 };
|
5677 | oTo = { opacity: 1, translateY: 0, rotateY: 0 };
|
5678 | break;
|
5679 | }
|
5680 | case 'SLIDERIGHT': {
|
5681 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5682 | if( f == 0 ) { f=-150; }
|
5683 | oFrom = { opacity: 0, translateX: f };
|
5684 | oTo = { opacity: 1, translateX: 0 };
|
5685 | break;
|
5686 | }
|
5687 | case 'SLIDELEFT': {
|
5688 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5689 | if( f == 0 ) { f=150; }
|
5690 | oFrom = { opacity: 0, translateX: f };
|
5691 | oTo = { opacity: 1, translateX: 0 };
|
5692 | break;
|
5693 | }
|
5694 | case 'FADEIN':
|
5695 | oFrom = { opacity: 0 };
|
5696 | oTo = { opacity: 1 };
|
5697 | break;
|
5698 |
|
5699 |
|
5700 | }
|
5701 |
|
5702 | var tweenable = new NGTweenable();
|
5703 | tweenable.tween({
|
5704 | from: oFrom,
|
5705 | to: oTo,
|
5706 | attachment: { $e:item.$elt, item: item, tw: tweenable },
|
5707 | delay: delay,
|
5708 | duration: G.tn.opt.Get('displayTransitionDuration'),
|
5709 | easing: G.tn.opt.Get('displayTransitionEasing'),
|
5710 | step: function (state, att) {
|
5711 | window.requestAnimationFrame( function() {
|
5712 | if( att.item.$elt === null ) {
|
5713 | att.tw.stop(false);
|
5714 | return;
|
5715 | }
|
5716 | switch (G.tn.opt.Get('displayTransition')) {
|
5717 | case 'RANDOMSCALE':
|
5718 | att.$e.css( G.CSStransformName , 'scale(' + state.scale + ')').css('opacity', state.opacity);
|
5719 | break;
|
5720 | case 'SCALEUP':
|
5721 | att.$e.css( G.CSStransformName , 'scale('+state.scale+')').css('opacity',state.opacity);
|
5722 | break;
|
5723 | case 'SCALEDOWN':
|
5724 | att.item.$elt.last().css('opacity', state.opacity);
|
5725 | att.item.CSSTransformSet('.nGY2GThumbnail', 'scale', state.scale);
|
5726 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5727 | break;
|
5728 | case 'SLIDEUP':
|
5729 | att.item.$elt.css('opacity', state.opacity);
|
5730 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px, '+state.translateY + 'px');
|
5731 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5732 | break;
|
5733 | case 'SLIDEDOWN':
|
5734 | att.item.$elt.css('opacity', state.opacity);
|
5735 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,'+state.translateY+'px');
|
5736 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5737 | break;
|
5738 | case 'FLIPUP':
|
5739 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,'+state.translateY+'px');
|
5740 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateX', state.rotateX+'deg');
|
5741 | att.item.$elt.css('opacity', state.opacity);
|
5742 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5743 | break;
|
5744 | case 'FLIPDOWN':
|
5745 | att.item.$elt.css('opacity', state.opacity);
|
5746 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,' + state.translateY + 'px');
|
5747 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateX', state.rotateX + 'deg');
|
5748 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5749 | break;
|
5750 | case 'SLIDEUP2':
|
5751 | att.item.$elt.css('opacity', state.opacity);
|
5752 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,' + state.translateY + 'px');
|
5753 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateY', state.rotateY + 'deg');
|
5754 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5755 | break;
|
5756 | case 'IMAGESLIDEUP':
|
5757 | att.item.$elt.css('opacity', state.opacity);
|
5758 | att.item.$Elts['.nGY2GThumbnailImage'].css('top', state.top);
|
5759 | break;
|
5760 | case 'SLIDEDOWN2':
|
5761 | att.item.$elt.css('opacity', state.opacity);
|
5762 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px, ' + state.translateY + 'px');
|
5763 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateY', state.rotateY + 'deg');
|
5764 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5765 | break;
|
5766 | case 'SLIDERIGHT':
|
5767 | att.item.$elt.css('opacity', state.opacity);
|
5768 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', state.translateX + 'px, 0px');
|
5769 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5770 | break;
|
5771 | case 'SLIDELEFT':
|
5772 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', state.translateX + 'px, 0px');
|
5773 | att.item.$elt.css('opacity', state.opacity);
|
5774 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5775 | break;
|
5776 | case 'FADEIN':
|
5777 | att.$e.css(state);
|
5778 | break;
|
5779 | }
|
5780 | });
|
5781 |
|
5782 | },
|
5783 | finish: function (state, att) {
|
5784 | window.requestAnimationFrame( function() {
|
5785 | if( att.item.$elt === null ) { return; }
|
5786 |
|
5787 | switch (G.tn.opt.Get('displayTransition')) {
|
5788 | case 'RANDOMSCALE':
|
5789 | att.$e.css( G.CSStransformName , 'scale('+state.scale+')').css('opacity', '');
|
5790 | break;
|
5791 | case 'SCALEUP':
|
5792 | att.$e.css( G.CSStransformName , '').css('opacity', '');
|
5793 | break;
|
5794 | case 'SCALEDOWN':
|
5795 | att.item.$elt.last().css('opacity', '');
|
5796 | att.item.CSSTransformSet('.nGY2GThumbnail', 'scale', state.scale);
|
5797 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5798 | break;
|
5799 | case 'IMAGESLIDEUP':
|
5800 | att.item.$elt.css('opacity', '');
|
5801 | att.item.$Elts['.nGY2GThumbnailImage'].css('top', 0);
|
5802 | break;
|
5803 | case 'SLIDEDOWN2':
|
5804 | att.item.$elt.css('opacity', '');
|
5805 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5806 | break;
|
5807 | default :
|
5808 |
|
5809 |
|
5810 |
|
5811 |
|
5812 |
|
5813 |
|
5814 |
|
5815 |
|
5816 | att.item.$elt.css('opacity', '');
|
5817 | }
|
5818 | ThumbnailAppearFinish(att.item);
|
5819 | });
|
5820 |
|
5821 | }
|
5822 | });
|
5823 |
|
5824 | }
|
5825 |
|
5826 |
|
5827 | function ThumbnailDisplayAnimBatch() {
|
5828 |
|
5829 | G.GOM.thumbnails2Display.forEach( function(one) {
|
5830 | ThumbnailDisplayAnim2(one.itm, one.d);
|
5831 | });
|
5832 | G.GOM.thumbnails2Display=[];
|
5833 | }
|
5834 |
|
5835 |
|
5836 |
|
5837 |
|
5838 |
|
5839 | function GalleryAppear() {
|
5840 |
|
5841 | var d=G.galleryDisplayTransitionDuration.Get();
|
5842 | switch( G.galleryDisplayTransition.Get() ){
|
5843 | case 'ROTATEX':
|
5844 | G.$E.base.css({ perspective: '1000px', 'perspective-origin': '50% 0%' });
|
5845 | new NGTweenable().tween({
|
5846 | from: { r: 50 },
|
5847 | to: { r: 0 },
|
5848 | attachment: { orgIdx: G.GOM.albumIdx },
|
5849 | duration: d,
|
5850 | easing: 'easeOutCirc',
|
5851 | step: function (state, att) {
|
5852 | if( att.orgIdx == G.GOM.albumIdx ) {
|
5853 |
|
5854 | G.$E.conTnParent.css( G.CSStransformName , 'rotateX(' + state.r + 'deg)');
|
5855 |
|
5856 | }
|
5857 | }
|
5858 | });
|
5859 | break;
|
5860 | case 'SLIDEUP':
|
5861 | G.$E.conTnParent.css({ opacity: 0 });
|
5862 | new NGTweenable().tween({
|
5863 | from: { y: 200, o: 0 },
|
5864 | to: { y: 0, o: 1 },
|
5865 | attachment: { orgIdx: G.GOM.albumIdx },
|
5866 | duration: d,
|
5867 | easing: 'easeOutCirc',
|
5868 | step: function (state, att) {
|
5869 | if( att.orgIdx == G.GOM.albumIdx ) {
|
5870 |
|
5871 | G.$E.conTnParent.css( G.CSStransformName , 'translate( 0px, '+state.y + 'px)').css('opacity', state.o);
|
5872 |
|
5873 | }
|
5874 | }
|
5875 | });
|
5876 | break;
|
5877 | case 'NONE':
|
5878 | default:
|
5879 | break;
|
5880 | }
|
5881 |
|
5882 |
|
5883 | }
|
5884 |
|
5885 |
|
5886 |
|
5887 |
|
5888 |
|
5889 | function ThumbnailOverInit( GOMidx ) {
|
5890 |
|
5891 |
|
5892 |
|
5893 |
|
5894 |
|
5895 | var curTn = G.GOM.items[GOMidx];
|
5896 | var item = G.I[curTn.thumbnailIdx];
|
5897 |
|
5898 | if( item.$elt == null ) { return; }
|
5899 |
|
5900 | var fu = G.O.fnThumbnailHoverInit;
|
5901 | if( fu !== null ) {
|
5902 | typeof fu == 'function' ? fu($e, item, GOMidx) : window[fu]($e, item, GOMidx);
|
5903 | }
|
5904 |
|
5905 |
|
5906 | var inits = G.tn.buildInit.get();
|
5907 | for( var j = 0; j < inits.length; j++) {
|
5908 | switch( inits[j].property ) {
|
5909 |
|
5910 | case 'scale':
|
5911 | case 'rotateX':
|
5912 | case 'rotateY':
|
5913 | case 'rotateZ':
|
5914 | case 'translateX':
|
5915 | case 'translateY':
|
5916 | case 'translateZ':
|
5917 | item.CSSTransformSet(inits[j].element, inits[j].property, inits[j].value);
|
5918 | item.CSSTransformApply(inits[j].element);
|
5919 | break;
|
5920 |
|
5921 | case 'blur':
|
5922 | case 'brightness':
|
5923 | case 'grayscale':
|
5924 | case 'sepia':
|
5925 | case 'contrast':
|
5926 | case 'opacity':
|
5927 | case 'saturate':
|
5928 | item.CSSFilterSet(inits[j].element, inits[j].property, inits[j].value);
|
5929 | item.CSSFilterApply(inits[j].element);
|
5930 | break;
|
5931 | default:
|
5932 | var $t=item.$getElt(inits[j].element);
|
5933 | $t.css( inits[j].property, inits[j].value );
|
5934 | break;
|
5935 | }
|
5936 | }
|
5937 |
|
5938 |
|
5939 | var effects = G.tn.hoverEffects.get();
|
5940 | for( var j = 0; j < effects.length; j++) {
|
5941 | if( effects[j].firstKeyframe === true ) {
|
5942 | switch( effects[j].type ) {
|
5943 | case 'scale':
|
5944 | case 'rotateX':
|
5945 | case 'rotateY':
|
5946 | case 'rotateZ':
|
5947 | case 'translateX':
|
5948 | case 'translateY':
|
5949 | case 'translateZ':
|
5950 | item.CSSTransformSet(effects[j].element, effects[j].type, effects[j].from);
|
5951 | item.CSSTransformApply(effects[j].element);
|
5952 | break;
|
5953 | case 'blur':
|
5954 | case 'brightness':
|
5955 | case 'grayscale':
|
5956 | case 'sepia':
|
5957 | case 'contrast':
|
5958 | case 'opacity':
|
5959 | case 'saturate':
|
5960 | item.CSSFilterSet(effects[j].element, effects[j].type, effects[j].from);
|
5961 | item.CSSFilterApply(effects[j].element);
|
5962 | break;
|
5963 | default:
|
5964 | var $t = item.$getElt(effects[j].element);
|
5965 | $t.css( effects[j].type, effects[j].from );
|
5966 | break;
|
5967 |
|
5968 | }
|
5969 | }
|
5970 | }
|
5971 | item.hoverInitDone=true;
|
5972 | }
|
5973 |
|
5974 | function ThumbnailHoverReInitAll() {
|
5975 | if( G.GOM.albumIdx == -1 ) { return; };
|
5976 | var l = G.GOM.items.length;
|
5977 | for( var i = 0; i < l ; i++ ) {
|
5978 | ThumbnailOverInit(i);
|
5979 |
|
5980 | G.I[G.GOM.items[i].thumbnailIdx].hovered = false;
|
5981 | }
|
5982 | }
|
5983 |
|
5984 |
|
5985 | function ThumbnailHover( GOMidx ) {
|
5986 | if( G.GOM.albumIdx == -1 || !G.galleryResizeEventEnabled ) { return; };
|
5987 | if( G.GOM.slider.hostIdx == GOMidx ) {
|
5988 |
|
5989 | return;
|
5990 | }
|
5991 | var curTn = G.GOM.items[GOMidx];
|
5992 | var item = G.I[curTn.thumbnailIdx];
|
5993 | if( item.kind == 'albumUp' || item.$elt == null ) { return; }
|
5994 |
|
5995 | item.hovered = true;
|
5996 |
|
5997 | var fu = G.O.fnThumbnailHover;
|
5998 | if( fu !== null ) {
|
5999 | typeof fu == 'function' ? fu(item.$elt, item, GOMidx) : window[fu](item.$elt, item, GOMidx);
|
6000 | }
|
6001 | var effects = G.tn.hoverEffects.get();
|
6002 |
|
6003 | try {
|
6004 | for( var j = 0; j < effects.length; j++) {
|
6005 | if( effects[j].hoverin === true ) {
|
6006 |
|
6007 | item.animate( effects[j], 0, true );
|
6008 | }
|
6009 | }
|
6010 |
|
6011 |
|
6012 | }
|
6013 | catch (e) {
|
6014 | NanoAlert(G, 'error on hover: ' + e.message );
|
6015 | }
|
6016 |
|
6017 | }
|
6018 |
|
6019 | function ThumbnailHoverOutAll() {
|
6020 | if( G.GOM.albumIdx == -1 ) { return; };
|
6021 | var l = G.GOM.items.length;
|
6022 | for( var i = 0; i < l ; i++ ) {
|
6023 | if( G.GOM.items[i].inDisplayArea ) {
|
6024 | ThumbnailHoverOut(i);
|
6025 | }
|
6026 | else {
|
6027 | G.I[G.GOM.items[i].thumbnailIdx].hovered = false;
|
6028 | }
|
6029 | }
|
6030 | }
|
6031 |
|
6032 |
|
6033 | function ThumbnailHoverOut( GOMidx ) {
|
6034 | if( G.GOM.albumIdx == -1 || !G.galleryResizeEventEnabled ) { return; }
|
6035 |
|
6036 | if( G.GOM.slider.hostIdx == GOMidx ) {
|
6037 |
|
6038 | return;
|
6039 | }
|
6040 |
|
6041 | var curTn = G.GOM.items[GOMidx];
|
6042 | var item = G.I[curTn.thumbnailIdx];
|
6043 | if( item.kind == 'albumUp' || !item.hovered ) { return; }
|
6044 | item.hovered = false;
|
6045 | if( item.$elt == null ) { return; }
|
6046 |
|
6047 | var fu = G.O.fnThumbnailHoverOut;
|
6048 | if( fu !== null ) {
|
6049 | typeof fu == 'function' ? fu(item.$elt, item, GOMidx) : window[fu](item.$elt, item, GOMidx);
|
6050 | }
|
6051 |
|
6052 | var effects = G.tn.hoverEffects.get();
|
6053 | try {
|
6054 | for( var j = 0; j < effects.length; j++) {
|
6055 | if( effects[j].hoverout === true ) {
|
6056 |
|
6057 | item.animate( effects[j], 0, false );
|
6058 | }
|
6059 | }
|
6060 |
|
6061 |
|
6062 | }
|
6063 | catch (e) {
|
6064 | NanoAlert(G, 'error on hoverOut: ' + e.message );
|
6065 | }
|
6066 |
|
6067 | }
|
6068 |
|
6069 |
|
6070 |
|
6071 | function DisplayPhoto( imageID, albumID ) {
|
6072 |
|
6073 | if( G.O.debugMode ) { console.log('#DisplayPhoto : '+ albumID +'-'+ imageID); }
|
6074 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
6075 | if( albumIdx == 0 ) {
|
6076 | G.GOM.curNavLevel = 'l1';
|
6077 | }
|
6078 | else {
|
6079 | G.GOM.curNavLevel = 'lN';
|
6080 | }
|
6081 |
|
6082 | if( albumIdx == -1 ) {
|
6083 |
|
6084 | if( G.O.kind != '' ) {
|
6085 |
|
6086 | NGY2Item.New( G, '', '', albumID, '0', 'album' );
|
6087 |
|
6088 | }
|
6089 | }
|
6090 |
|
6091 | var ngy2ItemIdx = NGY2Item.GetIdx(G, imageID);
|
6092 | if( ngy2ItemIdx == -1 ) {
|
6093 |
|
6094 | AlbumGetContent( albumID, DisplayPhoto, imageID, albumID );
|
6095 | return;
|
6096 | }
|
6097 |
|
6098 | if( G.O.debugMode ) { console.log('#DisplayPhoto : '+ ngy2ItemIdx); }
|
6099 |
|
6100 | DisplayPhotoIdx(ngy2ItemIdx);
|
6101 |
|
6102 | }
|
6103 |
|
6104 |
|
6105 | function AlbumGetContent( albumID, fnToCall, fnParam1, fnParam2 ) {
|
6106 |
|
6107 |
|
6108 |
|
6109 |
|
6110 |
|
6111 | switch( G.O.kind ) {
|
6112 |
|
6113 | case '':
|
6114 | AlbumGetMarkupOrApi(fnToCall, fnParam1, fnParam2);
|
6115 | break;
|
6116 |
|
6117 | default:
|
6118 | jQuery.nanogallery2['data_'+G.O.kind](G, 'AlbumGetContent', albumID, fnToCall, fnParam1, fnParam2 );
|
6119 | }
|
6120 |
|
6121 | }
|
6122 |
|
6123 | var mediaList = {
|
6124 | youtube : {
|
6125 | getID: function( url ) {
|
6126 |
|
6127 | var s = url.match( /(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/ );
|
6128 | return s != null ? s[1] : null;
|
6129 | },
|
6130 | thumbUrl: function( id ) {
|
6131 | return 'https://img.youtube.com/vi/' + id + '/hqdefault.jpg';
|
6132 | },
|
6133 | url: function( id ) {
|
6134 | return 'https://www.youtube.com/embed/' + id;
|
6135 | },
|
6136 | markup: function( id ) {
|
6137 |
|
6138 | return '<iframe class="nGY2ViewerMedia" src="https://www.youtube.com/embed/' + id + '?rel=0" frameborder="0" allow="autoplay" allowfullscreen></iframe>';
|
6139 | },
|
6140 | kind: 'iframe'
|
6141 | },
|
6142 | vimeo : {
|
6143 | getID: function( url ) {
|
6144 |
|
6145 |
|
6146 | var s = url.match( /(http|https)?:\/\/(www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|)(\d+)(?:|\/\?)/ );
|
6147 | return s != null ? s[4] : null;
|
6148 | },
|
6149 | url: function( id ) {
|
6150 | return 'https://player.vimeo.com/video/' + id;
|
6151 | },
|
6152 | markup: function( id ) {
|
6153 |
|
6154 |
|
6155 | return '<iframe class="nGY2ViewerMedia" src="https://player.vimeo.com/video/' + id + '" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>';
|
6156 | },
|
6157 | kind: 'iframe'
|
6158 | },
|
6159 | dailymotion : {
|
6160 | getID: function( url ) {
|
6161 |
|
6162 | var m = url.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);
|
6163 | if (m !== null) {
|
6164 | if(m[4] !== undefined) {
|
6165 | return m[4];
|
6166 | }
|
6167 | return m[2];
|
6168 | }
|
6169 | return null;
|
6170 | },
|
6171 | thumbUrl: function( id ) {
|
6172 | return 'https://www.dailymotion.com/thumbnail/video/' + id;
|
6173 | },
|
6174 | url: function( id ) {
|
6175 | return 'https://www.dailymotion.com/embed/video/' + id;
|
6176 | },
|
6177 | markup: function( id ) {
|
6178 |
|
6179 | return '<iframe class="nGY2ViewerMedia" src="https://www.dailymotion.com/embed/video/' + id + '?rel=0" frameborder="0" allow="autoplay" allowfullscreen></iframe>';
|
6180 | },
|
6181 | kind: 'iframe'
|
6182 | },
|
6183 | selfhosted : {
|
6184 |
|
6185 | getID: function( url ) {
|
6186 |
|
6187 |
|
6188 |
|
6189 | var extension = url.split('.').pop().toLowerCase();
|
6190 |
|
6191 |
|
6192 | var s = ( extension === 'mp4' || extension === 'webm' || extension === 'ogv' || extension === '3gp' ) ? extension : null ;
|
6193 | return s;
|
6194 | },
|
6195 | markup: function( url ) {
|
6196 |
|
6197 | var extension = url.split('.').pop();
|
6198 | return '<video controls class="nGY2ViewerMedia"><source src="'+ url +'" type="video/'+ extension +'" preload="auto">Your browser does not support the video tag (HTML 5).</video>';
|
6199 | },
|
6200 | kind: 'video',
|
6201 | selfhosted : true
|
6202 | }
|
6203 | };
|
6204 |
|
6205 | function AlbumGetMarkupOrApi ( fnToCall, fnParam1, fnParam2 ) {
|
6206 |
|
6207 | if( G.markupOrApiProcessed === true ) {
|
6208 |
|
6209 | DisplayAlbum('-1', 0);
|
6210 | return;
|
6211 | }
|
6212 |
|
6213 | if( G.O.items !== undefined && G.O.items !== null ) {
|
6214 |
|
6215 | GetContentApiObject();
|
6216 | }
|
6217 | else {
|
6218 | if( G.O.$markup.length > 0 ) {
|
6219 |
|
6220 | GetContentMarkup( G.O.$markup );
|
6221 | G.O.$markup=[] ;
|
6222 | }
|
6223 | else {
|
6224 | NanoConsoleLog(G, 'error: no media to process.');
|
6225 | return;
|
6226 | }
|
6227 | }
|
6228 |
|
6229 | G.markupOrApiProcessed = true;
|
6230 | if( fnToCall !== null && fnToCall !== undefined) {
|
6231 | fnToCall( fnParam1, fnParam2, null );
|
6232 | }
|
6233 | }
|
6234 |
|
6235 | function StartsWithProtocol ( path ) {
|
6236 | if( path == undefined ) { return false; }
|
6237 |
|
6238 |
|
6239 | var pattern = /^((http|https|ftp|ftps|file):\/\/)/;
|
6240 | if( !pattern.test(path) ) {
|
6241 |
|
6242 | return false;
|
6243 | }
|
6244 | return true;
|
6245 | }
|
6246 |
|
6247 | function GetContentApiObject() {
|
6248 | var foundAlbumID=false;
|
6249 | var nbTitles = 0;
|
6250 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
6251 |
|
6252 | G.I[0].contentIsLoaded = true;
|
6253 |
|
6254 | jQuery.each(G.O.items, function(i,item){
|
6255 |
|
6256 | var title = '';
|
6257 | title = GetI18nItem(item, 'title');
|
6258 | if( title === undefined ) { title=''; }
|
6259 |
|
6260 | var src='';
|
6261 | if( item['src'+RetrieveCurWidth().toUpperCase()] !== undefined ) {
|
6262 | src = item['src'+RetrieveCurWidth().toUpperCase()];
|
6263 | }
|
6264 | else {
|
6265 | src = item.src;
|
6266 | }
|
6267 | if( !StartsWithProtocol(src) ) {
|
6268 | src = G.O.itemsBaseURL + src;
|
6269 | }
|
6270 |
|
6271 | var thumbsrc = '';
|
6272 | if( item.srct !== undefined && item.srct.length > 0 ) {
|
6273 | thumbsrc = item.srct;
|
6274 | if( !StartsWithProtocol(thumbsrc) ) {
|
6275 | thumbsrc = G.O.itemsBaseURL + thumbsrc;
|
6276 | }
|
6277 | }
|
6278 | else {
|
6279 | thumbsrc = src;
|
6280 | }
|
6281 |
|
6282 | if( G.O.thumbnailLabel.get('title') != '' ) {
|
6283 | title = GetImageTitle(src);
|
6284 | }
|
6285 |
|
6286 | var description='';
|
6287 | description=GetI18nItem(item,'description');
|
6288 | if( description === undefined ) { description=''; }
|
6289 |
|
6290 |
|
6291 |
|
6292 |
|
6293 | var tags = GetI18nItem(item, 'tags');
|
6294 | if( tags === undefined ) { tags=''; }
|
6295 |
|
6296 | var albumID = 0;
|
6297 | if( item.albumID !== undefined ) {
|
6298 | albumID=item.albumID;
|
6299 | foundAlbumID = true;
|
6300 | }
|
6301 | var ID = null;
|
6302 | if( item.ID !== undefined ) {
|
6303 | ID = item.ID;
|
6304 | }
|
6305 | var kind = 'image';
|
6306 | if( item.kind !== undefined && item.kind.length > 0 ) {
|
6307 | kind = item.kind;
|
6308 | }
|
6309 |
|
6310 | var newItem=NGY2Item.New( G, title, description, ID, albumID, kind, tags );
|
6311 | if( title != '' ) {
|
6312 | nbTitles++;
|
6313 | }
|
6314 |
|
6315 |
|
6316 | newItem.setMediaURL( src, 'img');
|
6317 |
|
6318 |
|
6319 | jQuery.each(mediaList, function ( n, media ) {
|
6320 | var id = media.getID(src);
|
6321 | if( id != null ) {
|
6322 | if( thumbsrc == src && typeof media.thumbUrl == 'function' ) {
|
6323 | thumbsrc = media.thumbUrl(id);
|
6324 | }
|
6325 | if( typeof media.url == 'function' ) { src = media.url(id); }
|
6326 | newItem.mediaKind = media.kind;
|
6327 | newItem.mediaMarkup = ( media.selfhosted ) ? media.markup( src ) : media.markup(id);
|
6328 | return false;
|
6329 | }
|
6330 | });
|
6331 |
|
6332 |
|
6333 | if( item.imageWidth !== undefined ) { newItem.imageWidth = item.width; }
|
6334 | if( item.imageHeight !== undefined ) { newItem.imageHeight = item.height; }
|
6335 |
|
6336 |
|
6337 |
|
6338 |
|
6339 | var tw = item.imgtWidth !== undefined ? item.imgtWidth : 0;
|
6340 | var th = item.imgtHeight !== undefined ? item.imgtHeight : 0;
|
6341 |
|
6342 |
|
6343 | newItem.thumbs = {
|
6344 | url: { l1 : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc }, lN : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc } },
|
6345 | width: { l1 : { xs: tw, sm: tw, me: tw, la: tw, xl: tw }, lN : { xs: tw, sm: tw, me: tw, la: tw, xl: tw } },
|
6346 | height: { l1 : { xs: th, sm: th, me: th, la: th, xl: th }, lN : { xs: th, sm: th, me: th, la: th, xl: th } }
|
6347 | };
|
6348 |
|
6349 |
|
6350 | if( newItem.mediaKind == 'img' ) {
|
6351 |
|
6352 |
|
6353 | var lst=['xs', 'sm', 'me', 'la', 'xl'];
|
6354 | for( var i=0; i< lst.length; i++ ) {
|
6355 |
|
6356 | var turl = item['srct' + lst[i].toUpperCase()];
|
6357 | if( turl !== undefined ) {
|
6358 | if( !StartsWithProtocol(turl) ) {
|
6359 | turl = G.O.itemsBaseURL + turl;
|
6360 | }
|
6361 | newItem.url.l1[lst[i]] = turl;
|
6362 | newItem.url.lN[lst[i]] = turl;
|
6363 | }
|
6364 |
|
6365 | var tw = item['imgt' + lst[i].toUpperCase() + 'Width'];
|
6366 | if( tw != undefined ) {
|
6367 | newItem.width.l1[lst[i]] = parseInt(tw);
|
6368 | newItem.width.lN[lst[i]] = parseInt(tw);
|
6369 | }
|
6370 |
|
6371 | var th = item['imgt' + lst[i].toUpperCase() + 'Height'];
|
6372 | if( th != undefined ) {
|
6373 | newItem.height.l1[lst[i]] = parseInt(th);
|
6374 | newItem.height.lN[lst[i]] = parseInt(th);
|
6375 | }
|
6376 | }
|
6377 | }
|
6378 |
|
6379 |
|
6380 | if( item.imageDominantColors !== undefined ) {
|
6381 | newItem.imageDominantColors = item.imageDominantColors;
|
6382 | }
|
6383 |
|
6384 | if( item.imageDominantColor !== undefined ) {
|
6385 | newItem.imageDominantColor = item.imageDominantColor;
|
6386 | }
|
6387 |
|
6388 |
|
6389 | if( item.destURL !== undefined && item.destURL.length>0 ) {
|
6390 | newItem.destinationURL = item.destURL;
|
6391 | }
|
6392 |
|
6393 |
|
6394 | if( item.downloadURL !== undefined && item.downloadURL.length>0 ) {
|
6395 | newItem.downloadURL = item.downloadURL;
|
6396 | }
|
6397 |
|
6398 |
|
6399 |
|
6400 | if( item.exifModel !== undefined ) { newItem.exif.model = item.exifModel; }
|
6401 |
|
6402 | if( item.exifFlash !== undefined ) { newItem.exif.flash = item.exifFlash; }
|
6403 |
|
6404 | if( item.exifFocalLength !== undefined ) { newItem.exif.focallength = item.exifFocalLength; }
|
6405 |
|
6406 | if( item.exifFStop !== undefined ) { newItem.exif.fstop = item.exifFStop; }
|
6407 |
|
6408 | if( item.exifExposure !== undefined ) { newItem.exif.exposure = item.exifExposure; }
|
6409 |
|
6410 | if( item.exifIso !== undefined ) { newItem.exif.iso = item.exifIso; }
|
6411 |
|
6412 | if( item.exifTime !== undefined ) { newItem.exif.time = item.exifTime; }
|
6413 |
|
6414 | if( item.exifLocation !== undefined ) { newItem.exif.location = item.exifLocation; }
|
6415 |
|
6416 |
|
6417 |
|
6418 | if( item.customData !== null ) {
|
6419 | newItem.customData = cloneJSObject( item.customData );
|
6420 | }
|
6421 |
|
6422 | newItem.contentIsLoaded = true;
|
6423 |
|
6424 | var fu = G.O.fnProcessData;
|
6425 | if( fu !== null ) {
|
6426 | typeof fu == 'function' ? fu(newItem, 'api', item) : window[fu](newItem, 'api', item);
|
6427 | }
|
6428 |
|
6429 | AlbumPostProcess(albumID);
|
6430 | });
|
6431 |
|
6432 |
|
6433 | if( nbTitles == 0 ) { G.O.thumbnailLabel.display=false; }
|
6434 |
|
6435 | }
|
6436 |
|
6437 |
|
6438 |
|
6439 |
|
6440 | function ElementGetText( element ) {
|
6441 |
|
6442 | var text = '';
|
6443 | if( element.childNodes[0] !== undefined ) {
|
6444 | if( element.childNodes[0].nodeValue !== null && element.childNodes[0].nodeValue !== undefined ) {
|
6445 | text = element.childNodes[0].nodeValue.trim();
|
6446 | }
|
6447 | }
|
6448 | return text;
|
6449 | }
|
6450 |
|
6451 |
|
6452 | function GetContentMarkup( $elements, group ) {
|
6453 | var foundAlbumID = false;
|
6454 | var nbTitles = 0;
|
6455 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
6456 | var GetImageTitleFromURL = NGY2Tools.GetImageTitleFromURL.bind(G);
|
6457 |
|
6458 | G.I[0].contentIsLoaded = true;
|
6459 |
|
6460 | jQuery.each($elements, function(i, item){
|
6461 |
|
6462 |
|
6463 | if( item.dataset.nanogallery2Lgroup != group ) { return; }
|
6464 |
|
6465 |
|
6466 | if( item.nodeName == 'SCRIPT' ) { return; }
|
6467 |
|
6468 |
|
6469 | var data = {
|
6470 |
|
6471 | 'data-ngdesc': '',
|
6472 | 'data-ngid': null,
|
6473 | 'data-ngkind': 'image',
|
6474 | 'data-ngtags': null,
|
6475 | 'data-ngdest': '',
|
6476 | 'data-ngthumbimgwidth': 0,
|
6477 | 'data-ngthumbimgheight': 0,
|
6478 | 'data-ngimagewidth': 0,
|
6479 | 'data-ngimageheight': 0,
|
6480 | 'data-ngimagedominantcolors': null,
|
6481 | 'data-ngimagedominantcolor': null,
|
6482 | 'data-ngexifmodel': '',
|
6483 | 'data-ngexifflash': '',
|
6484 | 'data-ngexiffocallength': '',
|
6485 | 'data-ngexiffstop': '',
|
6486 | 'data-ngexifexposure': '',
|
6487 | 'data-ngexifiso': '',
|
6488 | 'data-ngexiftime': '',
|
6489 | 'data-ngexiflocation': '',
|
6490 | 'data-ngsrc': '',
|
6491 | 'alt': ''
|
6492 | };
|
6493 |
|
6494 |
|
6495 | [].forEach.call( item.attributes, function(attr) {
|
6496 | data[attr.name.toLowerCase()] = attr.value.trim();
|
6497 | });
|
6498 |
|
6499 | var title = ElementGetText(item);
|
6500 | if( title == '' && data.alt != '') {
|
6501 |
|
6502 | title = data['alt'];
|
6503 | }
|
6504 |
|
6505 |
|
6506 | jQuery.each($(item).children(), function(i, sub_item){
|
6507 |
|
6508 |
|
6509 | if( title == '' ) {
|
6510 | title = ElementGetText(sub_item);
|
6511 | }
|
6512 |
|
6513 | [].forEach.call( sub_item.attributes, function(attr) {
|
6514 | data[attr.name.toLowerCase()] = attr.value.trim();
|
6515 | });
|
6516 |
|
6517 | if( title == '' && data.alt != '') {
|
6518 |
|
6519 | title = data['alt'];
|
6520 | }
|
6521 |
|
6522 | });
|
6523 |
|
6524 |
|
6525 |
|
6526 | var src = '',
|
6527 | st = RetrieveCurWidth().toUpperCase();
|
6528 | if( data.hasOwnProperty('data-ngsrc'+st) ) {
|
6529 | src = data['data-ngsrc'+st];
|
6530 | }
|
6531 |
|
6532 |
|
6533 |
|
6534 |
|
6535 |
|
6536 |
|
6537 |
|
6538 |
|
6539 | src = src || data['data-ngsrc'] || data['href'];
|
6540 | if( src !== undefined && !StartsWithProtocol(src) ) {
|
6541 | src = G.O.itemsBaseURL + src;
|
6542 | }
|
6543 |
|
6544 |
|
6545 | var thumbsrc = '';
|
6546 |
|
6547 | if( data.hasOwnProperty('src') ) {
|
6548 | thumbsrc = data['src'];
|
6549 | }
|
6550 |
|
6551 | if( thumbsrc == '' && data.hasOwnProperty('data-ngthumb') ) {
|
6552 | thumbsrc = data['data-ngthumb'];
|
6553 | }
|
6554 | if( thumbsrc == '' ) {
|
6555 | thumbsrc = src;
|
6556 | }
|
6557 | if( thumbsrc !== undefined && !StartsWithProtocol(thumbsrc) ) {
|
6558 | thumbsrc = G.O.itemsBaseURL + thumbsrc;
|
6559 | }
|
6560 |
|
6561 |
|
6562 | if( src === undefined && thumbsrc === undefined ) { return; }
|
6563 |
|
6564 |
|
6565 | var description = data['data-ngdesc'];
|
6566 | var ID = data['id'] || data['data-ngid'];
|
6567 |
|
6568 |
|
6569 |
|
6570 | var kind = data['data-ngkind'];
|
6571 | var tags = data['data-ngtags'];
|
6572 |
|
6573 | var albumID = '0';
|
6574 | if( data.hasOwnProperty('data-ngalbumid') ) {
|
6575 | albumID = data['data-ngalbumid'];
|
6576 | foundAlbumID = true;
|
6577 | }
|
6578 |
|
6579 |
|
6580 | var title_from_url = GetImageTitleFromURL( src );
|
6581 | if( title_from_url != '' ) {
|
6582 | title = title_from_url;
|
6583 | }
|
6584 |
|
6585 | var newItem = NGY2Item.New( G, title, description, ID, albumID, kind, tags );
|
6586 | if( title != '' ) {
|
6587 | nbTitles++;
|
6588 | }
|
6589 |
|
6590 |
|
6591 | newItem.setMediaURL( src, 'img');
|
6592 |
|
6593 |
|
6594 |
|
6595 | jQuery.each(mediaList, function ( n, media ) {
|
6596 | var id = media.getID(src);
|
6597 | if( id != null ) {
|
6598 | if( thumbsrc == src && typeof media.thumbUrl == 'function' ) {
|
6599 | thumbsrc = media.thumbUrl(id);
|
6600 | }
|
6601 | if( typeof media.url == 'function' ) { src = media.url(id); }
|
6602 | newItem.mediaKind = media.kind;
|
6603 | newItem.mediaMarkup = ( media.selfhosted ) ? media.markup( src ) : media.markup(id);
|
6604 | return false;
|
6605 | }
|
6606 | });
|
6607 |
|
6608 |
|
6609 |
|
6610 | newItem.imageWidth = parseInt( data['data-ngimagewidth'] );
|
6611 | newItem.imageHeight = parseInt( data['data-ngimageheight'] );
|
6612 |
|
6613 |
|
6614 | var tw = parseInt(data['data-ngthumbimgwidth']);
|
6615 | var th = parseInt(data['data-ngthumbimgheight']);
|
6616 | newItem.thumbs = {
|
6617 | url: { l1 : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc }, lN : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc } },
|
6618 | width: { l1 : { xs: tw, sm: tw, me: tw, la: tw, xl: tw }, lN : { xs: tw, sm: tw, me: tw, la: tw, xl: tw } },
|
6619 | height: { l1 : { xs: th, sm: th, me: th, la: th, xl: th }, lN : { xs: th, sm: th, me: th, la: th, xl: th } }
|
6620 | };
|
6621 |
|
6622 |
|
6623 | if( newItem.mediaKind == 'img' ) {
|
6624 |
|
6625 |
|
6626 | var lst = ['xs', 'sm', 'me', 'la', 'xl'];
|
6627 | for( var i = 0; i < lst.length; i++ ) {
|
6628 |
|
6629 | if( data.hasOwnProperty('data-ngthumb' + lst[i]) ) {
|
6630 | var turl=data['data-ngthumb' + lst[i]];
|
6631 | if( !StartsWithProtocol(turl) ) {
|
6632 | turl = G.O.itemsBaseURL + turl;
|
6633 | }
|
6634 | newItem.url.l1[lst[i]] = turl;
|
6635 | newItem.url.lN[lst[i]] = turl;
|
6636 | }
|
6637 |
|
6638 |
|
6639 | if( data.hasOwnProperty('data-ngthumb' + lst[i] + 'width') ) {
|
6640 | var tw=parseInt(data['data-ngthumb' + lst[i] + 'width']);
|
6641 | newItem.width.l1[lst[i]] = tw;
|
6642 | newItem.width.lN[lst[i]] = tw;
|
6643 | }
|
6644 |
|
6645 | if( data.hasOwnProperty('data-ngthumb' + lst[i] + 'height') ) {
|
6646 | var th=parseInt('data-ngthumb' + lst[i] + 'height');
|
6647 | newItem.height.l1[lst[i]] = th;
|
6648 | newItem.height.lN[lst[i]] = th;
|
6649 | }
|
6650 | }
|
6651 | }
|
6652 |
|
6653 |
|
6654 |
|
6655 | newItem.imageDominantColors = data['data-ngimagedominantcolors'];
|
6656 |
|
6657 | newItem.imageDominantColor = data['data-ngimagedominantcolors'];
|
6658 |
|
6659 | newItem.destinationURL = data['data-ngdest'];
|
6660 | newItem.downloadURL = data['data-ngdownloadurl'];
|
6661 |
|
6662 |
|
6663 | newItem.exif.model=data['data-ngexifmodel'];
|
6664 |
|
6665 | newItem.exif.flash=data['data-ngexifflash'];
|
6666 |
|
6667 | newItem.exif.focallength=data['data-ngexiffocallength'];
|
6668 |
|
6669 | newItem.exif.fstop=data['data-ngexiffstop'];
|
6670 |
|
6671 | newItem.exif.exposure=data['data-ngexifexposure'];
|
6672 |
|
6673 | newItem.exif.iso=data['data-ngexifiso'];
|
6674 |
|
6675 | newItem.exif.time=data['data-ngexiftime'];
|
6676 |
|
6677 | newItem.exif.location=data['data-ngexiflocation'];
|
6678 |
|
6679 | newItem.contentIsLoaded = true;
|
6680 |
|
6681 |
|
6682 | if( jQuery(item).data('customdata') !== undefined ) {
|
6683 | newItem.customData = cloneJSObject(jQuery(item).data('customdata'));
|
6684 | }
|
6685 |
|
6686 | if( jQuery(item).data('ngcustomdata') !== undefined ) {
|
6687 | newItem.customData = cloneJSObject(jQuery(item).data('ngcustomdata'));
|
6688 | }
|
6689 |
|
6690 | var fu=G.O.fnProcessData;
|
6691 | if( fu !== null ) {
|
6692 | typeof fu == 'function' ? fu(newItem, 'markup', item) : window[fu](newItem, 'markup', item);
|
6693 | }
|
6694 |
|
6695 | AlbumPostProcess(albumID);
|
6696 |
|
6697 | });
|
6698 |
|
6699 |
|
6700 | if( nbTitles == 0 ) { G.O.thumbnailLabel.display = false; }
|
6701 |
|
6702 | }
|
6703 |
|
6704 |
|
6705 |
|
6706 |
|
6707 |
|
6708 |
|
6709 |
|
6710 |
|
6711 | function DefineVariables() {
|
6712 |
|
6713 |
|
6714 | if( G.O.kind.toUpperCase() == 'PICASA' || G.O.kind.toUpperCase() == 'GOOGLE') {
|
6715 | G.O.kind='google2';
|
6716 | }
|
6717 |
|
6718 |
|
6719 | G.GOM.cache.viewport = getViewport();
|
6720 | G.GOM.curWidth = RetrieveCurWidth();
|
6721 |
|
6722 |
|
6723 | jQuery.extend(true, G.tn.toolbar.image, G.O.thumbnailToolbarImage );
|
6724 | jQuery.extend(true, G.tn.toolbar.album, G.O.thumbnailToolbarAlbum );
|
6725 | var t = ['image', 'album'];
|
6726 | var pos= ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']
|
6727 | for( var i=0; i < t.length ; i++ ) {
|
6728 | for( var j=0; j < pos.length ; j++ ) {
|
6729 | G.tn.toolbar[t[i]][pos[j]] = G.tn.toolbar[t[i]][pos[j]].toUpperCase();
|
6730 | }
|
6731 | }
|
6732 |
|
6733 |
|
6734 | if( G.O.thumbnailLabel.position == 'overImageOnBottom' ) {
|
6735 | G.O.thumbnailLabel.valign = 'bottom';
|
6736 | G.O.thumbnailLabel.position = 'overImage';
|
6737 | }
|
6738 | if( G.O.thumbnailLabel.position == 'overImageOnMiddle' ) {
|
6739 | G.O.thumbnailLabel.valign = 'middle';
|
6740 | G.O.thumbnailLabel.position = 'overImage';
|
6741 | }
|
6742 | if( G.O.thumbnailLabel.position == 'overImageOnTop' ) {
|
6743 | G.O.thumbnailLabel.valign = 'top';
|
6744 | G.O.thumbnailLabel.position = 'overImage';
|
6745 | }
|
6746 | if( G.O.thumbnailL1Label !== undefined && G.O.thumbnailL1Label.position !== undefined ) {
|
6747 | if( G.O.thumbnailL1Label.position == 'overImageOnBottom' ) {
|
6748 | G.O.thumbnailL1Label.valign = 'bottom';
|
6749 | G.O.thumbnailL1Label.position = 'overImage';
|
6750 | }
|
6751 | if( G.O.thumbnailL1Label.position == 'overImageOnMiddle' ) {
|
6752 | G.O.thumbnailL1Label.valign = 'middle';
|
6753 | G.O.thumbnailL1Label.position = 'overImage';
|
6754 | }
|
6755 | if( G.O.thumbnailL1Label.position == 'overImageOnTop' ) {
|
6756 | G.O.thumbnailL1Label.valign = 'top';
|
6757 | G.O.thumbnailL1Label.position = 'overImage';
|
6758 | }
|
6759 | }
|
6760 |
|
6761 |
|
6762 | G.O.thumbnailLabel.get = function( opt ) {
|
6763 | if( G.GOM.curNavLevel == 'l1' && G.O.thumbnailL1Label !== undefined && G.O.thumbnailL1Label[opt] !== undefined ) {
|
6764 | return G.O.thumbnailL1Label[opt];
|
6765 | }
|
6766 | else {
|
6767 | return G.O.thumbnailLabel[opt];
|
6768 | }
|
6769 | };
|
6770 | G.O.thumbnailLabel.set = function( opt, value ) {
|
6771 | if( G.GOM.curNavLevel == 'l1' && G.O.thumbnailL1Label !== undefined && G.O.thumbnailL1Label[opt] !== undefined ) {
|
6772 | G.O.thumbnailL1Label[opt]=value;
|
6773 | }
|
6774 | else {
|
6775 | G.O.thumbnailLabel[opt]=value;
|
6776 | }
|
6777 | };
|
6778 |
|
6779 | if( G.O.blockList != '' ) { G.blockList = G.O.blockList.toUpperCase().split('|'); }
|
6780 | if( G.O.allowList != '' ) { G.allowList = G.O.allowList.toUpperCase().split('|'); }
|
6781 |
|
6782 | if( G.O.albumList2 !== undefined && G.O.albumList2 !== null && G.O.albumList2.constructor === Array ) {
|
6783 | var l=G.O.albumList2.length;
|
6784 | for(var i=0; i< l; i++ ) {
|
6785 | G.albumList.push(G.O.albumList2[i]);
|
6786 | }
|
6787 |
|
6788 | }
|
6789 | if( G.O.albumList2 !== undefined && typeof G.O.albumList2 == 'string' ) {
|
6790 | G.albumList.push(G.O.albumList2);
|
6791 | }
|
6792 |
|
6793 |
|
6794 |
|
6795 | G.tn.opt.lN.crop = G.O.thumbnailCrop;
|
6796 | G.tn.opt.l1.crop = G.O.thumbnailL1Crop != null ? G.O.thumbnailL1Crop : G.O.thumbnailCrop;
|
6797 |
|
6798 |
|
6799 | function ThumbnailOpt( lN, l1, opt) {
|
6800 | G.tn.opt.lN[opt] = G.O[lN];
|
6801 | G.tn.opt.l1[opt] = G.O[lN];
|
6802 | if( toType(G.O[l1]) == 'number' ) {
|
6803 | G.tn.opt.l1[opt] = G.O[l1];
|
6804 | }
|
6805 | }
|
6806 |
|
6807 | ThumbnailOpt('thumbnailStacks', 'thumbnailL1Stacks', 'stacks');
|
6808 |
|
6809 | ThumbnailOpt('thumbnailStacksTranslateX', 'thumbnailL1StacksTranslateX', 'stacksTranslateX');
|
6810 |
|
6811 | ThumbnailOpt('thumbnailStacksTranslateY', 'thumbnailL1StacksTranslateY', 'stacksTranslateY');
|
6812 |
|
6813 | ThumbnailOpt('thumbnailStacksTranslateZ', 'thumbnailL1StacksTranslateZ', 'stacksTranslateZ');
|
6814 |
|
6815 | ThumbnailOpt('thumbnailStacksRotateX', 'thumbnailL1StacksRotateX', 'stacksRotateX');
|
6816 |
|
6817 | ThumbnailOpt('thumbnailStacksRotateY', 'thumbnailL1StacksRotateY', 'stacksRotateY');
|
6818 |
|
6819 | ThumbnailOpt('thumbnailStacksRotateZ', 'thumbnailL1StacksRotateZ', 'stacksRotateZ');
|
6820 |
|
6821 | ThumbnailOpt('thumbnailStacksScale', 'thumbnailL1StacksScale', 'stacksScale');
|
6822 |
|
6823 |
|
6824 |
|
6825 |
|
6826 |
|
6827 | ThumbnailOpt('thumbnailBorderHorizontal', 'thumbnailL1BorderHorizontal', 'borderHorizontal');
|
6828 |
|
6829 | ThumbnailOpt('thumbnailBorderVertical', 'thumbnailL1BorderVertical', 'borderVertical');
|
6830 |
|
6831 | ThumbnailOpt('thumbnailBaseGridHeight', 'thumbnailL1BaseGridHeight', 'baseGridHeight');
|
6832 |
|
6833 |
|
6834 |
|
6835 | function ResponsiveSetSize( setting, level, v ) {
|
6836 | G.tn.settings[setting][level]['xs'] = v;
|
6837 | G.tn.settings[setting][level]['sm'] = v;
|
6838 | G.tn.settings[setting][level]['me'] = v;
|
6839 | G.tn.settings[setting][level]['la'] = v;
|
6840 | G.tn.settings[setting][level]['xl'] = v;
|
6841 | }
|
6842 |
|
6843 |
|
6844 |
|
6845 |
|
6846 | function ResponsiveOption( option, setting, level ) {
|
6847 | var v = G.O[option];
|
6848 |
|
6849 | if( v === undefined || v === null ) { return; }
|
6850 |
|
6851 |
|
6852 | if( toType(v) == 'number' || v.indexOf(' ') == -1 ) {
|
6853 |
|
6854 | var vn = 'auto';
|
6855 | if( v != 'auto' ) { vn = parseInt(v); }
|
6856 | ResponsiveSetSize( setting, level, vn );
|
6857 | }
|
6858 | else {
|
6859 | var sp = v.split(' ');
|
6860 | if( sp.length > 0 && +sp[0] === +sp[0] ) {
|
6861 |
|
6862 | var vn = 'auto';
|
6863 | if( sp[0] != 'auto' ) { vn = parseInt(sp[0]); }
|
6864 | ResponsiveSetSize( setting, level, vn );
|
6865 | }
|
6866 | for( var i = 1; i < sp.length; i++ ) {
|
6867 | if( /^xs|sm|me|la|xl/i.test( sp[i] ) ) {
|
6868 | var wi = sp[i].substring(0, 2).toLowerCase();
|
6869 | var va = sp[i].substring(2);
|
6870 | var vn = 'auto';
|
6871 | if( va != 'auto' ) { vn = parseInt(va); }
|
6872 | G.tn.settings[setting][level][wi] = vn;
|
6873 | }
|
6874 | }
|
6875 | }
|
6876 | }
|
6877 |
|
6878 | ResponsiveOption('thumbnailGutterWidth', 'gutterWidth', 'lN');
|
6879 | ResponsiveOption('thumbnailGutterWidth', 'gutterWidth', 'l1');
|
6880 | ResponsiveOption('thumbnailL1GutterWidth', 'gutterWidth', 'l1');
|
6881 | ResponsiveOption('thumbnailGutterHeight', 'gutterHeight', 'lN');
|
6882 | ResponsiveOption('thumbnailGutterHeight', 'gutterHeight', 'l1');
|
6883 | ResponsiveOption('thumbnailL1GutterHeight', 'gutterHeight', 'l1');
|
6884 |
|
6885 |
|
6886 | G.galleryDisplayMode.lN = G.O.galleryDisplayMode.toUpperCase();
|
6887 | G.galleryDisplayMode.l1 = G.O.galleryL1DisplayMode != null ? G.O.galleryL1DisplayMode.toUpperCase() : G.O.galleryDisplayMode.toUpperCase();
|
6888 |
|
6889 |
|
6890 | G.galleryMaxRows.lN = G.O.galleryMaxRows;
|
6891 | G.galleryMaxRows.l1 = toType(G.O.galleryL1MaxRows) == 'number' ? G.O.galleryL1MaxRows : G.O.galleryMaxRows;
|
6892 |
|
6893 |
|
6894 | G.galleryLastRowFull.lN = G.O.galleryLastRowFull;
|
6895 | G.galleryLastRowFull.l1 = G.O.galleryL1LastRowFull != null ? G.O.galleryL1LastRowFull : G.O.galleryLastRowFull;
|
6896 |
|
6897 |
|
6898 | G.gallerySorting.lN = G.O.gallerySorting.toUpperCase();
|
6899 | G.gallerySorting.l1 = G.O.galleryL1Sorting != null ? G.O.galleryL1Sorting.toUpperCase() : G.gallerySorting.lN;
|
6900 |
|
6901 |
|
6902 | G.galleryDisplayTransition.lN = G.O.galleryDisplayTransition.toUpperCase();
|
6903 | G.galleryDisplayTransition.l1 = G.O.galleryL1DisplayTransition != null ? G.O.galleryL1DisplayTransition.toUpperCase() : G.galleryDisplayTransition.lN;
|
6904 |
|
6905 |
|
6906 | G.galleryDisplayTransitionDuration.lN = G.O.galleryDisplayTransitionDuration;
|
6907 | G.galleryDisplayTransitionDuration.l1 = G.O.galleryL1DisplayTransitionDuration != null ? G.O.galleryL1DisplayTransitionDuration : G.galleryDisplayTransitionDuration.lN;
|
6908 |
|
6909 |
|
6910 | G.galleryMaxItems.lN = G.O.galleryMaxItems;
|
6911 | G.galleryMaxItems.l1 = toType(G.O.galleryL1MaxItems) == 'number' ? G.O.galleryL1MaxItems : G.O.galleryMaxItems;
|
6912 |
|
6913 |
|
6914 | G.galleryFilterTags.lN = G.O.galleryFilterTags;
|
6915 | G.galleryFilterTags.l1 = G.O.galleryL1FilterTags != null ? G.O.galleryL1FilterTags : G.O.galleryFilterTags;
|
6916 |
|
6917 |
|
6918 | G.galleryFilterTagsMode.lN = G.O.galleryFilterTagsMode;
|
6919 | G.galleryFilterTagsMode.l1 = G.O.galleryL1FilterTagsMode != null ? G.O.galleryL1FilterTagsMode : G.O.galleryFilterTagsMode;
|
6920 |
|
6921 |
|
6922 | G.O.galleryPaginationMode = G.O.galleryPaginationMode.toUpperCase();
|
6923 |
|
6924 | if( toType(G.O.slideshowDelay) == 'number' && G.O.slideshowDelay >= 2000 ) {
|
6925 | G.VOM.slideshowDelay = G.O.slideshowDelay;
|
6926 | }
|
6927 | else {
|
6928 | NanoConsoleLog(G, 'Parameter "slideshowDelay" must be an integer >= 2000 ms.');
|
6929 | }
|
6930 |
|
6931 |
|
6932 | if( typeof G.O.thumbnailDisplayTransition == 'boolean' ) {
|
6933 | if( G.O.thumbnailDisplayTransition === true ) {
|
6934 | G.tn.opt.lN.displayTransition = 'FADEIN';
|
6935 | G.tn.opt.l1.displayTransition = 'FADEIN';
|
6936 | }
|
6937 | else {
|
6938 | G.tn.opt.lN.displayTransition = 'NONE';
|
6939 | G.tn.opt.l1.displayTransition = 'NONE';
|
6940 | }
|
6941 | }
|
6942 |
|
6943 | if( G.O.fnThumbnailDisplayEffect !== '' ) {
|
6944 | G.tn.opt.lN.displayTransition = 'CUSTOM';
|
6945 | G.tn.opt.l1.displayTransition = 'CUSTOM';
|
6946 | }
|
6947 | if( G.O.fnThumbnailL1DisplayEffect !== '' ) {
|
6948 | G.tn.opt.l1.displayTransition = 'CUSTOM';
|
6949 | }
|
6950 |
|
6951 |
|
6952 |
|
6953 |
|
6954 | ThumbnailOpt('thumbnailDisplayTransitionEasing', 'thumbnailL1DisplayTransitionEasing', 'displayTransitionEasing');
|
6955 |
|
6956 | function thumbnailDisplayTransitionParse( cfg, level ) {
|
6957 | if( typeof cfg == 'string' ) {
|
6958 | var st=cfg.split('_');
|
6959 | if( st.length == 1 ) {
|
6960 | G.tn.opt[level]['displayTransition'] = cfg.toUpperCase();
|
6961 | }
|
6962 | if( st.length == 2 ) {
|
6963 | G.tn.opt[level]['displayTransition'] = st[0].toUpperCase();
|
6964 | G.tn.opt[level]['displayTransitionStartVal'] = Number(st[1]);
|
6965 | }
|
6966 | if( st.length == 3 ) {
|
6967 | G.tn.opt[level]['displayTransition'] = st[0].toUpperCase();
|
6968 | G.tn.opt[level]['displayTransitionStartVal'] = Number(st[1]);
|
6969 | G.tn.opt[level]['displayTransitionEasing'] = st[2];
|
6970 | }
|
6971 | }
|
6972 | }
|
6973 | thumbnailDisplayTransitionParse( G.O.thumbnailDisplayTransition, 'lN');
|
6974 | thumbnailDisplayTransitionParse( G.O.thumbnailDisplayTransition, 'l1');
|
6975 | thumbnailDisplayTransitionParse( G.O.thumbnailL1DisplayTransition, 'l1');
|
6976 |
|
6977 |
|
6978 |
|
6979 | ThumbnailOpt('thumbnailDisplayTransitionDuration', 'thumbnailL1DisplayTransitionDuration', 'displayTransitionDuration');
|
6980 |
|
6981 | ThumbnailOpt('thumbnailDisplayInterval', 'thumbnailL1DisplayInterval', 'displayInterval');
|
6982 |
|
6983 | ThumbnailOpt('thumbnailDisplayOrder', 'thumbnailL1DisplayOrder', 'displayOrder');
|
6984 |
|
6985 |
|
6986 |
|
6987 | if( G.O.thumbnailSizeSM !== undefined ) { G.O.breakpointSizeSM = G.O.thumbnailSizeSM; }
|
6988 | if( G.O.thumbnailSizeME !== undefined ) { G.O.breakpointSizeME = G.O.thumbnailSizeME; }
|
6989 | if( G.O.thumbnailSizeLA !== undefined ) { G.O.breakpointSizeLA = G.O.thumbnailSizeLA; }
|
6990 | if( G.O.thumbnailSizeXL !== undefined ) { G.O.breakpointSizeXL = G.O.thumbnailSizeXL; }
|
6991 |
|
6992 |
|
6993 |
|
6994 | if( G.O.thumbnailL1BuildInit2 !== undefined ) {
|
6995 | var t1 = G.O.thumbnailL1BuildInit2.split('|');
|
6996 | for( var i = 0; i < t1.length; i++ ) {
|
6997 | var o1 = t1[i].trim().split('_');
|
6998 | if( o1.length == 3 ) {
|
6999 | var i1 = NewTBuildInit();
|
7000 | i1.element = ThumbnailOverEffectsGetCSSElement(o1[0], '');
|
7001 | i1.property = o1[1];
|
7002 | i1.value = o1[2];
|
7003 | G.tn.buildInit.level1.push(i1);
|
7004 | }
|
7005 | }
|
7006 | }
|
7007 |
|
7008 | if( G.O.thumbnailBuildInit2 !== undefined ) {
|
7009 | var t1 = G.O.thumbnailBuildInit2.split('|');
|
7010 | for( var i = 0; i < t1.length; i++ ) {
|
7011 | var o1 = t1[i].trim().split('_');
|
7012 | if( o1.length == 3 ) {
|
7013 | var i1 = NewTBuildInit();
|
7014 | i1.element = ThumbnailOverEffectsGetCSSElement(o1[0], '');
|
7015 | i1.property = o1[1];
|
7016 | i1.value = o1[2];
|
7017 | G.tn.buildInit.std.push(i1);
|
7018 | }
|
7019 | }
|
7020 | }
|
7021 |
|
7022 |
|
7023 |
|
7024 |
|
7025 |
|
7026 | var tL1HE = G.O.thumbnailL1HoverEffect2;
|
7027 | if( tL1HE !== undefined ) {
|
7028 | switch( toType(tL1HE) ) {
|
7029 | case 'string': {
|
7030 | let tmp = tL1HE.split('|');
|
7031 | for(var i = 0; i < tmp.length; i++) {
|
7032 | let oDef = NewTHoverEffect();
|
7033 | oDef = ThumbnailHoverEffectExtract( tmp[i].trim(), oDef );
|
7034 | if( oDef != null ) {
|
7035 | G.tn.hoverEffects.level1.push(oDef);
|
7036 | }
|
7037 | }
|
7038 | break;
|
7039 | }
|
7040 | case 'object': {
|
7041 | let oDef = NewTHoverEffect();
|
7042 | oDef = jQuery.extend(oDef,tL1HE);
|
7043 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
7044 | if( oDef != null ) {
|
7045 | G.tn.hoverEffects.level1.push(oDef);
|
7046 | }
|
7047 | break;
|
7048 | }
|
7049 | case 'array': {
|
7050 | for(var i = 0; i < tL1HE.length; i++) {
|
7051 | let oDef = NewTHoverEffect();
|
7052 | oDef = jQuery.extend(oDef,tL1HE[i]);
|
7053 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
7054 | if( oDef != null ) {
|
7055 | G.tn.hoverEffects.level1.push(oDef);
|
7056 | }
|
7057 | }
|
7058 | break;
|
7059 | }
|
7060 | case 'null':
|
7061 | break;
|
7062 | default:
|
7063 | NanoAlert(G, 'incorrect parameter for "thumbnailL1HoverEffect2".');
|
7064 | }
|
7065 | }
|
7066 | G.tn.hoverEffects.level1 = ThumbnailOverEffectsPreset(G.tn.hoverEffects.level1);
|
7067 |
|
7068 |
|
7069 | var tHE = G.O.thumbnailHoverEffect2;
|
7070 | switch( toType(tHE) ) {
|
7071 | case 'string': {
|
7072 | let tmp = tHE.split('|');
|
7073 | for(var i = 0; i < tmp.length; i++) {
|
7074 | let oDef = NewTHoverEffect();
|
7075 | oDef = ThumbnailHoverEffectExtract( tmp[i].trim(), oDef );
|
7076 | if( oDef != null ) {
|
7077 | G.tn.hoverEffects.std.push(oDef);
|
7078 | }
|
7079 | }
|
7080 | break;
|
7081 | }
|
7082 | case 'object': {
|
7083 | let oDef = NewTHoverEffect();
|
7084 | oDef = jQuery.extend(oDef, tHE);
|
7085 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
7086 | if( oDef != null ) {
|
7087 | G.tn.hoverEffects.std.push(oDef);
|
7088 | }
|
7089 | break;
|
7090 | }
|
7091 | case 'array': {
|
7092 | for(var i = 0; i < tHE.length; i++) {
|
7093 | let oDef = NewTHoverEffect();
|
7094 | oDef = jQuery.extend(oDef,tHE[i]);
|
7095 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
7096 | if( oDef!= null ) {
|
7097 | G.tn.hoverEffects.std.push(oDef);
|
7098 | }
|
7099 | }
|
7100 | break;
|
7101 | }
|
7102 | case 'null':
|
7103 | break;
|
7104 | default:
|
7105 | NanoAlert(G, 'incorrect parameter for "thumbnailHoverEffect2".');
|
7106 | }
|
7107 | G.tn.hoverEffects.std = ThumbnailOverEffectsPreset(G.tn.hoverEffects.std);
|
7108 |
|
7109 |
|
7110 | if( G.O.touchAnimationL1 == undefined ) {
|
7111 | G.O.touchAnimationL1 = G.O.touchAnimation;
|
7112 | }
|
7113 |
|
7114 |
|
7115 | if( G.tn.hoverEffects.std.length == 0 ) {
|
7116 | if( G.tn.hoverEffects.level1.length == 0 ) {
|
7117 | G.O.touchAnimationL1 = false;
|
7118 | }
|
7119 | G.O.touchAnimation = false;
|
7120 | }
|
7121 |
|
7122 |
|
7123 |
|
7124 | if( G.O.thumbnailHeight == 0 || G.O.thumbnailHeight == '' ) { G.O.thumbnailHeight = 'auto'; }
|
7125 | if( G.O.thumbnailWidth == 0 || G.O.thumbnailWidth == '' ) { G.O.thumbnailWidth = 'auto'; }
|
7126 | if( G.O.thumbnailL1Height == 0 || G.O.thumbnailL1Height == '' ) { G.O.thumbnailL1Height = 'auto'; }
|
7127 | if( G.O.thumbnailL1Width == 0 || G.O.thumbnailL1Width == '' ) { G.O.thumbnailL1Width = 'auto'; }
|
7128 |
|
7129 |
|
7130 |
|
7131 |
|
7132 |
|
7133 |
|
7134 | ResponsiveOption('thumbnailWidth', 'width', 'lN');
|
7135 | ResponsiveOption('thumbnailWidth', 'width', 'l1');
|
7136 | ResponsiveOption('thumbnailL1Width', 'width', 'l1');
|
7137 | ResponsiveOption('thumbnailHeight', 'height', 'lN');
|
7138 | ResponsiveOption('thumbnailHeight', 'height', 'l1');
|
7139 | ResponsiveOption('thumbnailL1Height', 'height', 'l1');
|
7140 |
|
7141 |
|
7142 | G.O.thumbnailLabelHeight = parseInt(G.O.thumbnailLabelHeight);
|
7143 |
|
7144 |
|
7145 |
|
7146 |
|
7147 | if( G.O.galleryMosaic != undefined ) {
|
7148 |
|
7149 | G.tn.settings.mosaic.l1.xs = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7150 | G.tn.settings.mosaic.l1.sm = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7151 | G.tn.settings.mosaic.l1.me = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7152 | G.tn.settings.mosaic.l1.la = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7153 | G.tn.settings.mosaic.l1.xl = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7154 | G.tn.settings.mosaic.lN.xs = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7155 | G.tn.settings.mosaic.lN.sm = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7156 | G.tn.settings.mosaic.lN.me = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7157 | G.tn.settings.mosaic.lN.la = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7158 | G.tn.settings.mosaic.lN.xl = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7159 | G.tn.settings.mosaicCalcFactor('l1', 'xs');
|
7160 | G.tn.settings.mosaicCalcFactor('l1', 'sm');
|
7161 | G.tn.settings.mosaicCalcFactor('l1', 'me');
|
7162 | G.tn.settings.mosaicCalcFactor('l1', 'la');
|
7163 | G.tn.settings.mosaicCalcFactor('l1', 'xl');
|
7164 | G.tn.settings.mosaicCalcFactor('lN', 'xs');
|
7165 | G.tn.settings.mosaicCalcFactor('lN', 'sm');
|
7166 | G.tn.settings.mosaicCalcFactor('lN', 'me');
|
7167 | G.tn.settings.mosaicCalcFactor('lN', 'la');
|
7168 | G.tn.settings.mosaicCalcFactor('lN', 'xl');
|
7169 | }
|
7170 | if( G.O.galleryL1Mosaic != undefined ) {
|
7171 |
|
7172 | G.tn.settings.mosaic.l1.xs = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
7173 | G.tn.settings.mosaic.l1.sm = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
7174 | G.tn.settings.mosaic.l1.me = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
7175 | G.tn.settings.mosaic.l1.la = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
7176 | G.tn.settings.mosaic.l1.xl = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
7177 | G.tn.settings.mosaicCalcFactor('l1', 'xs');
|
7178 | G.tn.settings.mosaicCalcFactor('l1', 'sm');
|
7179 | G.tn.settings.mosaicCalcFactor('l1', 'me');
|
7180 | G.tn.settings.mosaicCalcFactor('l1', 'la');
|
7181 | G.tn.settings.mosaicCalcFactor('l1', 'xl');
|
7182 | }
|
7183 |
|
7184 | var lst=['xs','sm','me','la','xl'];
|
7185 |
|
7186 | for( var w = 0; w < lst.length; w++ ) {
|
7187 | if( G.O['galleryMosaic' + lst[w].toUpperCase()] != undefined ) {
|
7188 | G.tn.settings.mosaic.lN[lst[w]] = JSON.parse(JSON.stringify( G.O['galleryMosaic' + lst[w].toUpperCase()] ));
|
7189 | G.tn.settings.mosaic.l1[lst[w]] = JSON.parse(JSON.stringify( G.O['galleryMosaic' + lst[w].toUpperCase()] ));
|
7190 | G.tn.settings.mosaicCalcFactor('lN',lst[w]);
|
7191 | G.tn.settings.mosaicCalcFactor('l1', lst[w]);
|
7192 | }
|
7193 | }
|
7194 |
|
7195 | for( var w = 0; w < lst.length; w++ ) {
|
7196 | if( G.O['galleryL1Mosaic' + lst[w].toUpperCase()] != undefined ) {
|
7197 | G.tn.settings.mosaic.l1[lst[w]] = JSON.parse(JSON.stringify( G.O['galleryL1Mosaic' + lst[w].toUpperCase()] ));
|
7198 | G.tn.settings.mosaicCalcFactor('l1', lst[w]);
|
7199 | }
|
7200 | }
|
7201 |
|
7202 | G.O.imageTransition = G.O.imageTransition.toUpperCase();
|
7203 |
|
7204 | G.layout.SetEngine();
|
7205 |
|
7206 |
|
7207 | switch( G.O.kind ) {
|
7208 |
|
7209 | case '':
|
7210 | break;
|
7211 |
|
7212 | default:
|
7213 | jQuery.nanogallery2['data_' + G.O.kind](G, 'Init' );
|
7214 | }
|
7215 |
|
7216 | }
|
7217 |
|
7218 |
|
7219 | function ThumbnailHoverEffectExtract( name, effect) {
|
7220 | var easings = [ 'easeInQuad', 'easeOutQuad', 'easeInOutQuad', 'easeInCubic', 'easeOutCubic', 'easeInOutCubic', 'easeInQuart', 'easeOutQuart', 'easeInOutQuart', 'easeInQuint', 'easeOutQuint', 'easeInOutQuint', 'easeInSine', 'easeOutSine', 'easeInOutSine', 'easeInExpo', 'easeOutExpo', 'easeInOutExpo', 'easeInCirc', 'easeOutCirc', 'easeInOutCirc', 'easeOutBounce', 'easeInBack', 'easeOutBack', 'easeInOutBack', 'elastic', 'bounce'];
|
7221 |
|
7222 | var sp = name.split('_');
|
7223 | if( sp.length >= 4 ) {
|
7224 |
|
7225 | effect.name = '';
|
7226 | effect.type = sp[1];
|
7227 | effect.from = sp[2];
|
7228 | effect.to = sp[3];
|
7229 | if( sp.length >= 5 ) {
|
7230 |
|
7231 |
|
7232 | for( var n = 4; n < sp.length; n++ ) {
|
7233 | var v = sp[n];
|
7234 |
|
7235 |
|
7236 | var foundEasing = false;
|
7237 | for( var e = 0; e < easings.length; e++) {
|
7238 | if( v == easings[e] ) {
|
7239 | foundEasing = true;
|
7240 | effect.easing = v;
|
7241 | break;
|
7242 | }
|
7243 | }
|
7244 | if( foundEasing === true ) {
|
7245 | continue;
|
7246 | }
|
7247 |
|
7248 | v = v.toUpperCase();
|
7249 |
|
7250 | if( v == 'HOVERIN' ) {
|
7251 | effect.hoverout = false;
|
7252 | continue;
|
7253 | }
|
7254 | if( v == 'HOVEROUT' ) {
|
7255 | effect.hoverin = false;
|
7256 | continue;
|
7257 | }
|
7258 |
|
7259 | if( v == 'KEYFRAME' ) {
|
7260 | effect.firstKeyframe = false;
|
7261 | continue;
|
7262 | }
|
7263 |
|
7264 | var num = parseInt(v.replace(/[^0-9\.]/g, ''), 10);
|
7265 |
|
7266 | if( num > 0 ) {
|
7267 |
|
7268 | if( v.indexOf('DURATION') >= 0 ) {
|
7269 | effect.duration = num;
|
7270 | continue;
|
7271 | }
|
7272 | if( v.indexOf('DURATIONBACK') >= 0 ) {
|
7273 | effect.durationBack = num;
|
7274 | continue;
|
7275 | }
|
7276 | if( v.indexOf('DELAY') >= 0 ) {
|
7277 | effect.delay = num;
|
7278 | continue;
|
7279 | }
|
7280 | if( v.indexOf('DELAYBACK') >= 0 ) {
|
7281 | effect.delayBack = num;
|
7282 | continue;
|
7283 | }
|
7284 |
|
7285 |
|
7286 | effect.duration = num;
|
7287 | }
|
7288 | }
|
7289 | }
|
7290 | effect.element = ThumbnailOverEffectsGetCSSElement(sp[0], effect.type);
|
7291 |
|
7292 | }
|
7293 | else {
|
7294 | effect.name = name;
|
7295 |
|
7296 |
|
7297 | }
|
7298 | return effect;
|
7299 | }
|
7300 |
|
7301 |
|
7302 | function ThumbnailOverEffectsGetCSSElement( element, property ) {
|
7303 |
|
7304 | var elts = {
|
7305 | 'image': '.nGY2GThumbnailImage',
|
7306 | 'thumbnail': '.nGY2GThumbnail',
|
7307 | 'label': '.nGY2GThumbnailLabel',
|
7308 | 'title': '.nGY2GThumbnailTitle',
|
7309 | 'description': '.nGY2GThumbnailDescription',
|
7310 | 'tools': '.nGY2GThumbnailIcons',
|
7311 | 'customlayer': '.nGY2GThumbnailCustomLayer',
|
7312 | 'default': 'nGY2GThumbnailImage'
|
7313 | };
|
7314 | return (elts[element] || elts['default']);
|
7315 |
|
7316 |
|
7317 | }
|
7318 |
|
7319 |
|
7320 | function ThumbnailOverEffectsPreset( effects ) {
|
7321 |
|
7322 |
|
7323 |
|
7324 |
|
7325 |
|
7326 |
|
7327 |
|
7328 |
|
7329 |
|
7330 |
|
7331 |
|
7332 |
|
7333 |
|
7334 |
|
7335 |
|
7336 | var newEffects=[];
|
7337 | for( var i=0; i< effects.length; i++ ) {
|
7338 | switch( effects[i].name.toUpperCase() ) {
|
7339 | case 'BORDERLIGHTER': {
|
7340 | let rgb = ColorHelperToRGB(GalleryThemeGetCurrent().thumbnail.borderColor);
|
7341 | let name = 'thumbnail_borderColor_'+rgb+'_'+ShadeBlendConvert(0.5, rgb );
|
7342 | newEffects.push(ThumbnailHoverEffectExtract(name, effects[i]));
|
7343 | break;
|
7344 | }
|
7345 | case 'BORDERDARKER': {
|
7346 | let rgb = ColorHelperToRGB(GalleryThemeGetCurrent().thumbnail.borderColor);
|
7347 | let name = 'thumbnail_borderColor_'+rgb+'_'+ShadeBlendConvert(-0.5, rgb );
|
7348 | newEffects.push(ThumbnailHoverEffectExtract(name, effects[i]));
|
7349 | break;
|
7350 | }
|
7351 | case 'SCALE120':
|
7352 | newEffects.push(ThumbnailHoverEffectExtract('thumbnail_scale_1.00_1.20', effects[i]));
|
7353 | break;
|
7354 | case 'LABELAPPEAR':
|
7355 | case 'LABELAPPEAR75':
|
7356 | newEffects.push(ThumbnailHoverEffectExtract('label_opacity_0.00_1.00', effects[i]));
|
7357 | break;
|
7358 | case 'TOOLSAPPEAR':
|
7359 | newEffects.push(ThumbnailHoverEffectExtract('tools_opacity_0_1', effects[i]));
|
7360 | break;
|
7361 | case 'TOOLSSLIDEDOWN':
|
7362 | newEffects.push(ThumbnailHoverEffectExtract('tools_translateY_-100%_0%', effects[i]));
|
7363 | break;
|
7364 | case 'TOOLSSLIDEUP':
|
7365 | newEffects.push(ThumbnailHoverEffectExtract('tools_translateY_100%_0%', effects[i]));
|
7366 | break;
|
7367 | case 'LABELOPACITY50':
|
7368 | newEffects.push(ThumbnailHoverEffectExtract('label_opacity_1.00_0.50', effects[i]));
|
7369 | break;
|
7370 | case 'LABELSLIDEUPTOP':
|
7371 | case 'LABELSLIDEUP':
|
7372 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_100%_0%', effects[i]));
|
7373 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_100%_0%', effects[i]));
|
7374 | break;
|
7375 | case 'LABELSLIDEDOWN':
|
7376 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_-100%_0%', effects[i]));
|
7377 | break;
|
7378 | case 'SCALELABELOVERIMAGE':
|
7379 | newEffects.push(ThumbnailHoverEffectExtract('label_scale_0.00_1.00', effects[i]));
|
7380 | var n = cloneJSObject(effects[i]);
|
7381 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.00_0.00', n));
|
7382 | break;
|
7383 | case 'OVERSCALE':
|
7384 | case 'OVERSCALEOUTSIDE':
|
7385 |
|
7386 | newEffects.push(ThumbnailHoverEffectExtract('label_scale_2.00_1.00', effects[i]));
|
7387 | var n = cloneJSObject(effects[i]);
|
7388 | newEffects.push(ThumbnailHoverEffectExtract('label_opacity_0.00_1.00', n));
|
7389 | n = cloneJSObject(effects[i]);
|
7390 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.00_0.00', n));
|
7391 | n = cloneJSObject(effects[i]);
|
7392 | newEffects.push(ThumbnailHoverEffectExtract('image_opacity_1.00_0.00', n));
|
7393 | break;
|
7394 | case 'DESCRIPTIONAPPEAR':
|
7395 | newEffects.push(ThumbnailHoverEffectExtract('description_opacity_0_1', effects[i]));
|
7396 | break;
|
7397 | case 'SLIDERIGHT':
|
7398 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_100%', effects[i]));
|
7399 | newEffects.push(ThumbnailHoverEffectExtract('label_translateX_-100%_0%', cloneJSObject(effects[i])));
|
7400 | break;
|
7401 | case 'SLIDELEFT':
|
7402 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_-100%', effects[i]));
|
7403 | newEffects.push(ThumbnailHoverEffectExtract('label_translateX_100%_0%', cloneJSObject(effects[i])));
|
7404 | break;
|
7405 | case 'SLIDEUP':
|
7406 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_-100%', effects[i]));
|
7407 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_100%_0%', cloneJSObject(effects[i])));
|
7408 | break;
|
7409 | case 'SLIDEDOWN':
|
7410 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_100%', effects[i]));
|
7411 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_-100%_0%', cloneJSObject(effects[i])));
|
7412 | break;
|
7413 | case 'IMAGESCALE150':
|
7414 | case 'IMAGESCALE150OUTSIDE':
|
7415 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.00_1.50', effects[i]));
|
7416 | break;
|
7417 | case 'IMAGESCALEIN80':
|
7418 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.20_1.00', effects[i]));
|
7419 | break;
|
7420 | case 'IMAGESLIDERIGHT':
|
7421 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_100%', effects[i]));
|
7422 | break;
|
7423 | case 'IMAGESLIDELEFT':
|
7424 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_-100%', effects[i]));
|
7425 | break;
|
7426 | case 'IMAGESLIDEUP':
|
7427 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_-100%', effects[i]));
|
7428 | break;
|
7429 | case 'IMAGESLIDEDOWN':
|
7430 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_100%', effects[i]));
|
7431 | break;
|
7432 | case 'LABELSLIDEUPDOWN':
|
7433 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_0%_100%', effects[i]));
|
7434 | break;
|
7435 | case 'DESCRIPTIONSLIDEUP':
|
7436 | newEffects.push(ThumbnailHoverEffectExtract('description_translateY_110%_0%', effects[i]));
|
7437 | break;
|
7438 |
|
7439 | case 'IMAGEBLURON':
|
7440 | newEffects.push(ThumbnailHoverEffectExtract('image_blur_2.00px_0.00px', effects[i]));
|
7441 | break;
|
7442 | case 'IMAGEBLUROFF':
|
7443 | newEffects.push(ThumbnailHoverEffectExtract('image_blur_0.00px_2.00px', effects[i]));
|
7444 | break;
|
7445 | case 'IMAGEGRAYON':
|
7446 | newEffects.push(ThumbnailHoverEffectExtract('image_grayscale_0%_100%', effects[i]));
|
7447 | break;
|
7448 | case 'IMAGEGRAYOFF':
|
7449 | newEffects.push(ThumbnailHoverEffectExtract('image_grayscale_100%_0%', effects[i]));
|
7450 | break;
|
7451 | case 'IMAGESEPIAON':
|
7452 | newEffects.push(ThumbnailHoverEffectExtract('image_sepia_100%_1%', effects[i]));
|
7453 | break;
|
7454 | case 'IMAGESEPIAOFF':
|
7455 | newEffects.push(ThumbnailHoverEffectExtract('image_sepia_1%_100%', effects[i]));
|
7456 | break;
|
7457 |
|
7458 | default:
|
7459 | newEffects.push(effects[i]);
|
7460 | break;
|
7461 | }
|
7462 | }
|
7463 |
|
7464 | return newEffects;
|
7465 | }
|
7466 |
|
7467 |
|
7468 |
|
7469 | function NewTHoverEffect() {
|
7470 | var oDef={
|
7471 | name: '',
|
7472 | element: '',
|
7473 | type: '',
|
7474 | from: '',
|
7475 | to: '',
|
7476 | hoverin: true,
|
7477 | hoverout: true,
|
7478 | firstKeyframe: true,
|
7479 | delay: 0,
|
7480 | delayBack: 0,
|
7481 | duration: 400,
|
7482 | durationBack: 300,
|
7483 | easing: 'easeOutQuart',
|
7484 | easingBack: 'easeOutQuart',
|
7485 | animParam: null
|
7486 | };
|
7487 | return oDef;
|
7488 | }
|
7489 |
|
7490 | function NewTBuildInit() {
|
7491 |
|
7492 | var oDef={ element: '', property: '', value: '' };
|
7493 | return oDef;
|
7494 | }
|
7495 |
|
7496 |
|
7497 | function ThumbnailStyle( cfg, level) {
|
7498 |
|
7499 | switch( cfg.position ){
|
7500 | case 'onBottom' :
|
7501 | G.tn.style[level]['label'] = 'bottom:0; ';
|
7502 | break;
|
7503 | case 'right' :
|
7504 | switch( cfg.valign ) {
|
7505 | case 'top':
|
7506 | G.tn.style[level]['label'] = 'top:0; position:absolute; left: 50%;';
|
7507 | break;
|
7508 | case 'middle':
|
7509 | G.tn.style[level]['label'] = 'top:0; bottom:0; left: 50%;';
|
7510 | G.tn.style[level]['title'] = 'position:absolute; bottom:50%;';
|
7511 | G.tn.style[level]['desc'] = 'position:absolute; top:50%;';
|
7512 | break;
|
7513 | case 'bottom':
|
7514 | default:
|
7515 | G.tn.style[level].label = 'bottom:0; position:absolute; left: 50%;';
|
7516 | G.tn.style[level].title = 'position:absolute;bottom:0;';
|
7517 | break;
|
7518 | }
|
7519 | break;
|
7520 | case 'custom':
|
7521 | break;
|
7522 | default:
|
7523 | case 'overImage' :
|
7524 | switch( cfg.valign ) {
|
7525 | case 'top':
|
7526 | G.tn.style[level]['label'] = 'top:0; position:absolute;';
|
7527 | break;
|
7528 | case 'middle':
|
7529 | G.tn.style[level]['label'] = 'top:0; bottom:0;';
|
7530 | G.tn.style[level]['title'] = 'position:absolute; bottom:50%;';
|
7531 | G.tn.style[level]['desc'] = 'position:absolute; top:50%;';
|
7532 | break;
|
7533 | case 'bottom':
|
7534 | default:
|
7535 |
|
7536 | G.tn.style[level].label = 'bottom:0; position:absolute;';
|
7537 | break;
|
7538 | }
|
7539 |
|
7540 |
|
7541 |
|
7542 |
|
7543 |
|
7544 |
|
7545 |
|
7546 |
|
7547 |
|
7548 |
|
7549 |
|
7550 |
|
7551 |
|
7552 |
|
7553 |
|
7554 |
|
7555 |
|
7556 | }
|
7557 |
|
7558 |
|
7559 | if( cfg.position != 'onBottom' ) {
|
7560 |
|
7561 | if( cfg.titleMultiLine ) {
|
7562 | G.tn.style[level]['title'] += 'white-space:normal;';
|
7563 | }
|
7564 | if( cfg.descriptionMultiLine ) {
|
7565 | G.tn.style[level]['desc'] += 'white-space:normal;';
|
7566 | }
|
7567 | }
|
7568 |
|
7569 |
|
7570 | switch( cfg.align ) {
|
7571 | case 'right':
|
7572 | G.tn.style[level].label += 'text-align:right;';
|
7573 | break;
|
7574 | case 'left':
|
7575 | G.tn.style[level].label += 'text-align:left;';
|
7576 | break;
|
7577 | default:
|
7578 | G.tn.style[level].label += 'text-align:center;';
|
7579 | break;
|
7580 | }
|
7581 |
|
7582 |
|
7583 | if( cfg.titleFontSize != undefined && cfg.titleFontSize != '' ) {
|
7584 | G.tn.style[level].title += 'font-size:' + cfg.titleFontSize + ';';
|
7585 | }
|
7586 | if( cfg.descriptionFontSize != undefined && cfg.descriptionFontSize != '' ) {
|
7587 | G.tn.style[level].desc += 'font-size:' + cfg.descriptionFontSize + ';';
|
7588 | }
|
7589 |
|
7590 | if( cfg.displayDescription == false ) {
|
7591 | G.tn.style[level].desc += 'display:none;';
|
7592 | }
|
7593 | }
|
7594 |
|
7595 |
|
7596 |
|
7597 | function ThumbnailDefCaches() {
|
7598 |
|
7599 |
|
7600 |
|
7601 | ThumbnailStyle( G.O.thumbnailLabel, 'lN');
|
7602 | if( G.O.thumbnailL1Label !== undefined ) {
|
7603 | ThumbnailStyle( G.O.thumbnailL1Label, 'l1');
|
7604 | }
|
7605 | else {
|
7606 | ThumbnailStyle( G.O.thumbnailLabel, 'l1');
|
7607 | }
|
7608 |
|
7609 | if( G.O.thumbnailL1Label && G.O.thumbnailL1Label.display ) {
|
7610 |
|
7611 | ThumbnailStyle( G.O.thumbnailL1Label, 'l1');
|
7612 | }
|
7613 |
|
7614 |
|
7615 |
|
7616 | var lst=['xs','sm','me','la','xl'];
|
7617 | for( var i = 0; i < lst.length; i++ ) {
|
7618 | var w = G.tn.settings.width.lN[lst[i]];
|
7619 | if( w != 'auto' ) {
|
7620 | G.tn.defaultSize.width.lN[lst[i]] = w;
|
7621 | G.tn.defaultSize.width.l1[lst[i]] = w;
|
7622 | }
|
7623 | else {
|
7624 | var h = G.tn.settings.height.lN[lst[i]];
|
7625 | G.tn.defaultSize.width.lN[lst[i]] = h;
|
7626 | G.tn.defaultSize.width.l1[lst[i]] = h;
|
7627 | }
|
7628 | }
|
7629 | for( var i = 0; i < lst.length; i++ ) {
|
7630 | var h = G.tn.settings.height.lN[lst[i]];
|
7631 | if( h != 'auto' ) {
|
7632 |
|
7633 | G.tn.defaultSize.height.lN[lst[i]] = h;
|
7634 | G.tn.defaultSize.height.l1[lst[i]] = h;
|
7635 | }
|
7636 | else {
|
7637 | var w = G.tn.settings.width.lN[lst[i]];
|
7638 | G.tn.defaultSize.height.lN[lst[i]] = w;
|
7639 | G.tn.defaultSize.height.l1[lst[i]] = w;
|
7640 | }
|
7641 | }
|
7642 |
|
7643 |
|
7644 | for( var i = 0; i < lst.length; i++ ) {
|
7645 | var w = G.tn.settings.width.l1[lst[i]];
|
7646 | if( w != 'auto' ) {
|
7647 | G.tn.defaultSize.width.l1[lst[i]] = w;
|
7648 | }
|
7649 | else {
|
7650 | var h = G.tn.settings.height.l1[lst[i]];
|
7651 | G.tn.defaultSize.width.l1[lst[i]] = h;
|
7652 | }
|
7653 | }
|
7654 | for( var i = 0; i < lst.length; i++ ) {
|
7655 | var h = G.tn.settings.height.l1[lst[i]];
|
7656 | if( h != 'auto' ) {
|
7657 |
|
7658 | G.tn.defaultSize.height.l1[lst[i]] = h;
|
7659 | }
|
7660 | else {
|
7661 | var w = G.tn.settings.width.l1[lst[i]];
|
7662 | G.tn.defaultSize.height.l1[lst[i]]= w ;
|
7663 | }
|
7664 | }
|
7665 |
|
7666 | }
|
7667 |
|
7668 |
|
7669 |
|
7670 | function GalleryThemeGetCurrent() {
|
7671 |
|
7672 | var cs=null;
|
7673 | switch(toType(G.O.galleryTheme)) {
|
7674 | case 'object':
|
7675 | cs = G.galleryTheme_dark;
|
7676 | jQuery.extend(true,cs,G.O.galleryTheme);
|
7677 | break;
|
7678 | case 'string':
|
7679 | switch( G.O.galleryTheme ) {
|
7680 | case 'light':
|
7681 | cs = G.galleryTheme_light;
|
7682 | break;
|
7683 | case 'default':
|
7684 | case 'dark':
|
7685 | case 'none':
|
7686 | default:
|
7687 | cs = G.galleryTheme_dark;
|
7688 | }
|
7689 | break;
|
7690 | default:
|
7691 | cs = G.galleryTheme_dark;
|
7692 | }
|
7693 | return cs;
|
7694 | }
|
7695 |
|
7696 |
|
7697 | function SetGalleryTheme() {
|
7698 |
|
7699 | if( typeof G.O.colorScheme !== 'undefined' ) {
|
7700 | G.O.galleryTheme = G.O.colorScheme;
|
7701 | }
|
7702 |
|
7703 | var cs = null;
|
7704 | var galleryTheme = '';
|
7705 | switch(toType(G.O.galleryTheme)) {
|
7706 | case 'object':
|
7707 | cs = G.galleryTheme_dark;
|
7708 | jQuery.extend(true,cs,G.O.galleryTheme);
|
7709 | galleryTheme='nanogallery_gallerytheme_custom_' + G.baseEltID;
|
7710 | break;
|
7711 | case 'string':
|
7712 | switch( G.O.galleryTheme ) {
|
7713 | case 'light':
|
7714 | cs = G.galleryTheme_light;
|
7715 | galleryTheme='nanogallery_gallerytheme_light_' + G.baseEltID;
|
7716 | break;
|
7717 | case 'default':
|
7718 | case 'dark':
|
7719 | case 'none':
|
7720 | default:
|
7721 | cs = G.galleryTheme_dark;
|
7722 | galleryTheme='nanogallery_gallerytheme_dark_' + G.baseEltID;
|
7723 | }
|
7724 | break;
|
7725 | default:
|
7726 | NanoAlert(G, 'Error in galleryTheme parameter.');
|
7727 | return;
|
7728 | }
|
7729 |
|
7730 |
|
7731 | var s1='.' + galleryTheme + ' ';
|
7732 |
|
7733 |
|
7734 | var c = cs.navigationBar;
|
7735 | var s=s1+'.nGY2Navigationbar { background:'+c.background+'; }'+'\n';
|
7736 | if( c.border !== undefined && c.border !== '' ) { s+=s1+'.nGY2Navigationbar { border:'+c.border+'; }'+'\n'; }
|
7737 | if( c.borderTop !== undefined && c.borderTop !== '' ) { s+=s1+'.nGY2Navigationbar { border-top:'+c.borderTop+'; }'+'\n'; }
|
7738 | if( c.borderBottom !== undefined && c.borderBottom !== '' ) { s+=s1+'.nGY2Navigationbar { border-bottom:'+c.borderBottom+'; }'+'\n'; }
|
7739 | if( c.borderRight !== undefined && c.borderRight !== '' ) { s+=s1+'.nGY2Navigationbar { border-right:'+c.borderRight+'; }'+'\n'; }
|
7740 | if( c.borderLeft !== undefined && c.borderLeft !== '' ) { s+=s1+'.nGY2Navigationbar { border-left:'+c.borderLeft+'; }'+'\n'; }
|
7741 |
|
7742 |
|
7743 | var c = cs.navigationBreadcrumb;
|
7744 | s+=s1+'.nGY2Breadcrumb { background:'+c.background+'; border-radius:'+c.borderRadius+'; }'+'\n';
|
7745 | s+=s1+'.nGY2Breadcrumb .oneItem { color:'+c.color+'; }'+'\n';
|
7746 | s+=s1+'.nGY2Breadcrumb .oneItem:hover { color:'+c.colorHover+'; }'+'\n';
|
7747 |
|
7748 |
|
7749 | var c = cs.navigationFilter;
|
7750 | s+=s1+'.nGY2NavFilterUnselected { color:'+c.color+'; background:'+c.background+'; border-radius:'+c.borderRadius+'; }'+'\n';
|
7751 | s+=s1+'.nGY2NavFilterSelected { color:'+c.colorSelected+'; background:'+c.backgroundSelected+'; border-radius:'+c.borderRadius+'; }'+'\n';
|
7752 | s+=s1+'.nGY2NavFilterSelectAll { color:'+c.colorSelected+'; background:'+c.background+'; border-radius:'+c.borderRadius+'; }'+'\n';
|
7753 |
|
7754 |
|
7755 | var c = cs.navigationPagination;
|
7756 | s+=s1+'.nGY2NavPagination { color:'+c.color+'; background:'+c.background+'; border-radius:'+c.borderRadius+'; }'+'\n';
|
7757 | s+=s1+'.nGY2NavPagination:hover { color:'+c.colorHover+'; }'+'\n';
|
7758 |
|
7759 |
|
7760 | var c = cs.thumbnail;
|
7761 |
|
7762 | s+=s1+'.nGY2GThumbnail { border-radius: '+c.borderRadius+'; background:'+c.background+'; border-color:'+c.borderColor+'; }'+'\n';
|
7763 | s+=s1+'.nGY2GThumbnail_l1 { border-top-width:'+G.tn.opt.l1.borderVertical+'px; border-right-width:'+G.tn.opt.l1.borderHorizontal+'px; border-bottom-width:'+G.tn.opt.l1.borderVertical+'px; border-left-width:'+G.tn.opt.l1.borderHorizontal+'px;}'+'\n';
|
7764 | s+=s1+'.nGY2GThumbnail_lN { border-top-width:'+G.tn.opt.lN.borderVertical+'px; border-right-width:'+G.tn.opt.lN.borderHorizontal+'px; border-bottom-width:'+G.tn.opt.lN.borderVertical+'px; border-left-width:'+G.tn.opt.lN.borderHorizontal+'px;}'+'\n';
|
7765 | s+=s1+'.nGY2GThumbnailStack { background:'+c.stackBackground+'; }'+'\n';
|
7766 |
|
7767 | s+=s1+'.nGY2TnImgBack { background:'+c.background+'; background-image:'+c.backgroundImage+'; }'+'\n';
|
7768 | s+=s1+'.nGY2GThumbnailAlbumUp { background:'+c.background+'; background-image:'+c.backgroundImage+'; color:'+cs.thumbnail.titleColor+'; }'+'\n';
|
7769 | s+=s1+'.nGY2GThumbnailIconsFullThumbnail { color:'+c.titleColor+'; }\n';
|
7770 | s+=s1+'.nGY2GThumbnailLabel { background:'+c.labelBackground+'; opacity:'+c.labelOpacity+'; }'+'\n';
|
7771 | s+=s1+'.nGY2GThumbnailImageTitle { color:'+c.titleColor+'; background-color:'+c.titleBgColor+'; '+(c.titleShadow =='' ? '': 'Text-Shadow:'+c.titleShadow+';')+' }'+'\n';
|
7772 | s+=s1+'.nGY2GThumbnailAlbumTitle { color:'+c.titleColor+'; background-color:'+c.titleBgColor+'; '+(c.titleShadow =='' ? '': 'Text-Shadow:'+c.titleShadow+';')+' }'+'\n';
|
7773 | s+=s1+'.nGY2GThumbnailDescription { color:'+c.descriptionColor+'; background-color:'+c.descriptionBgColor+'; '+(c.descriptionShadow =='' ? '': 'Text-Shadow:'+c.descriptionShadow+';')+' }'+'\n';
|
7774 |
|
7775 |
|
7776 | var c = cs.thumbnailIcon;
|
7777 | s+=s1+'.nGY2GThumbnailIcons { padding:'+c.padding+'; }\n';
|
7778 | s+=s1+'.nGY2GThumbnailIcon { color:'+c.color+'; '+(c.shadow =='' ? '': 'Text-Shadow:'+c.shadow+';')+' }\n';
|
7779 | s+=s1+'.nGY2GThumbnailIconTextBadge { background-color:'+c.color+'; }\n';
|
7780 |
|
7781 |
|
7782 | var c = cs.pagination;
|
7783 | if( G.O.galleryPaginationMode != 'NUMBERS' ) {
|
7784 | s+=s1+'.nGY2paginationDot { border:'+c.shapeBorder+'; background:'+c.shapeColor+';}\n';
|
7785 | s+=s1+'.nGY2paginationDotCurrentPage { border:'+c.shapeBorder+'; background:'+c.shapeSelectedColor+';}\n';
|
7786 | s+=s1+'.nGY2paginationRectangle { border:'+c.shapeBorder+'; background:'+c.shapeColor+';}\n';
|
7787 | s+=s1+'.nGY2paginationRectangleCurrentPage { border:'+c.shapeBorder+'; background:'+c.shapeSelectedColor+';}\n';
|
7788 | } else {
|
7789 | s+=s1+'.nGY2paginationItem { background:'+c.background+'; color:'+c.color+'; border-radius:'+c.borderRadius+'; }\n';
|
7790 | s+=s1+'.nGY2paginationItemCurrentPage { background:'+c.background+'; color:'+c.color+'; border-radius:'+c.borderRadius+'; }\n';
|
7791 | s+=s1+'.nGY2PaginationPrev { background:'+c.background+'; color:'+c.color+'; border-radius:'+c.borderRadius+'; }\n';
|
7792 | s+=s1+'.nGY2PaginationNext { background:'+c.background+'; color:'+c.color+'; border-radius:'+c.borderRadius+'; }\n';
|
7793 | s+=s1+'.nGY2paginationItemCurrentPage { background:'+c.backgroundSelected+'; }\n';
|
7794 | }
|
7795 |
|
7796 |
|
7797 | var c = cs.thumbnail;
|
7798 |
|
7799 | s+=s1+'.nGY2GalleryMoreButtonAnnotation { background:'+c.background+'; border-color:'+c.borderColor+'; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px;}\n';
|
7800 | s+=s1+'.nGY2GalleryMoreButtonAnnotation { color:'+c.titleColor+'; '+(c.titleShadow =='' ? '': 'Text-Shadow:'+c.titleShadow)+'; }\n';
|
7801 |
|
7802 | jQuery('head').append('<style id="ngycs_'+G.baseEltID+'">'+s+'</style>');
|
7803 | G.$E.base.addClass(galleryTheme);
|
7804 |
|
7805 | };
|
7806 |
|
7807 |
|
7808 | function SetViewerTheme( ) {
|
7809 |
|
7810 | if( G.VOM.viewerTheme != '' ) {
|
7811 | G.VOM.$baseCont.addClass(G.VOM.viewerTheme);
|
7812 | return;
|
7813 | }
|
7814 |
|
7815 | if( typeof G.O.colorSchemeViewer !== 'undefined' ) {
|
7816 | G.O.viewerTheme = G.O.colorSchemeViewer;
|
7817 | }
|
7818 |
|
7819 | var cs=null;
|
7820 | switch(toType(G.O.viewerTheme)) {
|
7821 | case 'object':
|
7822 | cs = G.viewerTheme_dark;
|
7823 | jQuery.extend(true, cs, G.O.viewerTheme);
|
7824 | G.VOM.viewerTheme = 'nanogallery_viewertheme_custom_' + G.baseEltID;
|
7825 | break;
|
7826 | case 'string':
|
7827 | switch( G.O.viewerTheme ) {
|
7828 | case 'none':
|
7829 | return;
|
7830 | break;
|
7831 | case 'light':
|
7832 | cs = G.viewerTheme_light;
|
7833 | G.VOM.viewerTheme = 'nanogallery_viewertheme_light_' + G.baseEltID;
|
7834 | break;
|
7835 | case 'dark':
|
7836 | case 'default':
|
7837 | cs = G.viewerTheme_dark;
|
7838 | G.VOM.viewerTheme = 'nanogallery_viewertheme_dark_' + G.baseEltID;
|
7839 | break;
|
7840 | }
|
7841 | break;
|
7842 | default:
|
7843 | NanoAlert(G, 'Error in viewerTheme parameter.');
|
7844 | return;
|
7845 | }
|
7846 |
|
7847 | var s1 = '.' + G.VOM.viewerTheme + ' ';
|
7848 | var s = s1 + '.nGY2Viewer { background:' + cs.background + '; }'+'\n';
|
7849 | s += s1 + '.nGY2Viewer .toolbarBackground { background:' + cs.barBackground + '; }'+'\n';
|
7850 | s += s1 + '.nGY2Viewer .toolbar { border:' + cs.barBorder + '; color:' + cs.barColor + '; }'+'\n';
|
7851 | s += s1 + '.nGY2Viewer .toolbar .previousButton:after { color:' + cs.barColor + '; }'+'\n';
|
7852 | s += s1 + '.nGY2Viewer .toolbar .nextButton:after { color:' + cs.barColor + '; }'+'\n';
|
7853 | s += s1 + '.nGY2Viewer .toolbar .closeButton:after { color:' + cs.barColor + '; }'+'\n';
|
7854 | s += s1 + '.nGY2Viewer .toolbar .label .title { color:' + cs.barColor + '; }'+'\n';
|
7855 | s += s1 + '.nGY2Viewer .toolbar .label .description { color:' + cs.barDescriptionColor + '; }'+'\n';
|
7856 | jQuery('head').append('<style>' + s + '</style>');
|
7857 | G.VOM.$baseCont.addClass(G.VOM.viewerTheme);
|
7858 | };
|
7859 |
|
7860 |
|
7861 |
|
7862 |
|
7863 | function SetPolyFills() {
|
7864 |
|
7865 |
|
7866 |
|
7867 | if (!Function.prototype.bind) {
|
7868 | Function.prototype.bind = function (oThis) {
|
7869 | if (typeof this !== "function") {
|
7870 |
|
7871 |
|
7872 | throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
7873 | }
|
7874 |
|
7875 | var aArgs = Array.prototype.slice.call(arguments, 1),
|
7876 | fToBind = this,
|
7877 | fNOP = function () {},
|
7878 | fBound = function () {
|
7879 | return fToBind.apply(this instanceof fNOP && oThis
|
7880 | ? this
|
7881 | : oThis,
|
7882 | aArgs.concat(Array.prototype.slice.call(arguments)));
|
7883 | };
|
7884 |
|
7885 | fNOP.prototype = this.prototype;
|
7886 | fBound.prototype = new fNOP();
|
7887 |
|
7888 | return fBound;
|
7889 | };
|
7890 | }
|
7891 |
|
7892 |
|
7893 |
|
7894 |
|
7895 |
|
7896 | (function() {
|
7897 | var lastTime = 0;
|
7898 | var vendors = ['ms', 'moz', 'webkit', 'o'];
|
7899 | for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
7900 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
7901 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
|
7902 | }
|
7903 | if (!window.requestAnimationFrame)
|
7904 | window.requestAnimationFrame = function(callback, element) {
|
7905 | var currTime = new Date().getTime();
|
7906 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
7907 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
|
7908 | lastTime = currTime + timeToCall;
|
7909 | return id;
|
7910 | };
|
7911 |
|
7912 | if (!window.cancelAnimationFrame)
|
7913 | window.cancelAnimationFrame = function(id) {
|
7914 | clearTimeout(id);
|
7915 | };
|
7916 | }());
|
7917 |
|
7918 |
|
7919 | Array.prototype.ngy2removeIf = function(callback) {
|
7920 | var i = this.length;
|
7921 | while (i--) {
|
7922 | if (callback(this[i], i)) {
|
7923 | this.splice(i, 1);
|
7924 | }
|
7925 | }
|
7926 | };
|
7927 |
|
7928 |
|
7929 |
|
7930 | if (!String.prototype.startsWith) {
|
7931 | String.prototype.startsWith = function(searchString, position) {
|
7932 | position = position || 0;
|
7933 | return this.indexOf(searchString, position) === position;
|
7934 | };
|
7935 | }
|
7936 |
|
7937 | }
|
7938 |
|
7939 |
|
7940 |
|
7941 | function GalleryClicked(e) {
|
7942 |
|
7943 | var r = GalleryEventRetrieveElementl(e, false);
|
7944 |
|
7945 | if( r.GOMidx == -1 ) { return 'exit'; }
|
7946 |
|
7947 | var idx = G.GOM.items[r.GOMidx].thumbnailIdx;
|
7948 | if( G.GOM.slider.hostIdx == r.GOMidx ) {
|
7949 | idx = G.GOM.items[G.GOM.slider.currentIdx].thumbnailIdx;
|
7950 | }
|
7951 | switch( r.action ) {
|
7952 | case 'OPEN':
|
7953 | ThumbnailOpen(idx, false);
|
7954 | return 'exit';
|
7955 | break;
|
7956 | case 'DISPLAY':
|
7957 |
|
7958 | ThumbnailOpen(idx, true);
|
7959 | return 'exit';
|
7960 | break;
|
7961 | case 'TOGGLESELECT':
|
7962 | ThumbnailSelectionToggle(idx);
|
7963 | return 'exit';
|
7964 | break;
|
7965 | case 'SHARE':
|
7966 | PopupShare(idx);
|
7967 | return 'exit';
|
7968 | break;
|
7969 | case 'DOWNLOAD':
|
7970 | DownloadImage(idx);
|
7971 | return 'exit';
|
7972 | break;
|
7973 | case 'INFO':
|
7974 | ItemDisplayInfo(G.I[idx]);
|
7975 | return 'exit';
|
7976 | break;
|
7977 | case 'SHOPPINGCART':
|
7978 | AddToCart(idx, 'gallery');
|
7979 | return 'exit';
|
7980 | break;
|
7981 | default:
|
7982 |
|
7983 | var fu = G.O.fnThumbnailToolCustAction;
|
7984 | if( fu !== null ) {
|
7985 | typeof fu == 'function' ? fu(r.action, G.I[idx]) : window[fu](r.action, G.I[idx]);
|
7986 | }
|
7987 | break;
|
7988 | }
|
7989 | }
|
7990 |
|
7991 |
|
7992 | function DownloadImage(idx) {
|
7993 | if( G.I[idx].mediaKind != 'img' ) { return; }
|
7994 |
|
7995 |
|
7996 | var url = G.I[idx].src;
|
7997 |
|
7998 | if( G.I[idx].downloadURL != undefined && G.I[idx].downloadURL != '' ) {
|
7999 | url = G.I[idx].downloadURL;
|
8000 | }
|
8001 |
|
8002 | var a = document.createElement('a');
|
8003 | a.href = url;
|
8004 |
|
8005 | a.download = url.split('/').pop();
|
8006 | a.target = '_blank';
|
8007 | a.style.display = 'none';
|
8008 | document.body.appendChild(a);
|
8009 | a.click();
|
8010 | document.body.removeChild(a);
|
8011 |
|
8012 | }
|
8013 |
|
8014 |
|
8015 | function AddToCart( idx, source ) {
|
8016 |
|
8017 | var found=false;
|
8018 | for( var i=0; i<G.shoppingCart.length; i++ ) {
|
8019 | if( G.shoppingCart[i].idx == idx ) {
|
8020 | G.shoppingCart[i].qty++;
|
8021 | ThumbnailBuildToolbarOneCartUpdate( G.I[idx] );
|
8022 |
|
8023 | var fu = G.O.fnShoppingCartUpdated;
|
8024 | if( fu !== null ) {
|
8025 | typeof fu == 'function' ? fu(G.shoppingCart, G.I[idx], source) : window[fu](G.shoppingCart, G.I[idx], source);
|
8026 | }
|
8027 | TriggerCustomEvent('shoppingCartUpdated');
|
8028 | return;
|
8029 | }
|
8030 | }
|
8031 |
|
8032 |
|
8033 | if( !found) {
|
8034 | G.shoppingCart.push( { idx:idx, ID:G.I[idx].GetID(), qty:1} );
|
8035 | ThumbnailBuildToolbarOneCartUpdate(G.I[idx]);
|
8036 |
|
8037 | var fu=G.O.fnShoppingCartUpdated;
|
8038 | if( fu !== null ) {
|
8039 | typeof fu == 'function' ? fu(G.shoppingCart, G.I[idx], source) : window[fu](G.shoppingCart, G.I[idx], source);
|
8040 | }
|
8041 | TriggerCustomEvent('shoppingCartUpdated');
|
8042 | }
|
8043 | }
|
8044 |
|
8045 |
|
8046 |
|
8047 | function ThumbnailSelectionClear() {
|
8048 | G.GOM.nbSelected = 0;
|
8049 | for( var i = 0, nbTn = G.GOM.items.length; i < nbTn ; i++ ) {
|
8050 | var item = G .I[G.GOM.items[i].thumbnailIdx];
|
8051 | if( item.selected ) {
|
8052 | item.selected = false;
|
8053 | var fu = G.O.fnThumbnailSelection;
|
8054 | if( fu !== null ) {
|
8055 | typeof fu == 'function' ? fu(item.$elt, item, G.I) : window[fu](item.$elt, item, G.I);
|
8056 | }
|
8057 | }
|
8058 | item.selected = false;
|
8059 | }
|
8060 | }
|
8061 |
|
8062 | function ThumbnailSelectionToggle( idx ){
|
8063 | var item = G.I[idx];
|
8064 | if( item.selected === true ) {
|
8065 | ThumbnailSelectionSet(item, false);
|
8066 | G.GOM.nbSelected--;
|
8067 | TriggerCustomEvent('itemUnSelected');
|
8068 | }
|
8069 | else {
|
8070 | ThumbnailSelectionSet(item, true);
|
8071 | G.GOM.nbSelected++;
|
8072 | TriggerCustomEvent('itemSelected');
|
8073 | }
|
8074 | }
|
8075 |
|
8076 |
|
8077 |
|
8078 | function ThumbnailSelectionSet(item, selected ){
|
8079 |
|
8080 | item.selected = selected;
|
8081 |
|
8082 | ThumbnailSelectionSetIcon( item );
|
8083 |
|
8084 |
|
8085 | var fu=G.O.fnThumbnailSelection;
|
8086 | if( fu !== null ) {
|
8087 | typeof fu == 'function' ? fu(item.$elt, item, G.I) : window[fu](item.$elt, item, G.I);
|
8088 | }
|
8089 |
|
8090 | }
|
8091 |
|
8092 | function ThumbnailSelectionSetIcon( item ) {
|
8093 | if( item.$elt == null ) {
|
8094 |
|
8095 | return;
|
8096 | }
|
8097 | var $sub = item.$getElt('.nGY2GThumbnail');
|
8098 | var $icon = item.$getElt('.nGY2GThumbnailIconImageSelect');
|
8099 | if( item.selected === true) {
|
8100 | $sub.addClass('nGY2GThumbnailSubSelected');
|
8101 | $icon.addClass('nGY2ThumbnailSelected');
|
8102 | $icon.removeClass('nGY2ThumbnailUnselected');
|
8103 | $icon.html(G.O.icons.thumbnailSelected);
|
8104 | }
|
8105 | else {
|
8106 | $sub.removeClass('nGY2GThumbnailSubSelected');
|
8107 | $icon.removeClass('nGY2ThumbnailSelected');
|
8108 | $icon.addClass('nGY2ThumbnailUnselected');
|
8109 | $icon.html(G.O.icons.thumbnailUnselected);
|
8110 | }
|
8111 | }
|
8112 |
|
8113 |
|
8114 |
|
8115 | function PopupShare(idx) {
|
8116 |
|
8117 |
|
8118 |
|
8119 |
|
8120 | var item=G.I[idx];
|
8121 |
|
8122 | var currentURL=document.location.protocol + '//' + document.location.hostname + document.location.pathname;
|
8123 | var newLocationHash = '#nanogallery/' + G.baseEltID + '/';
|
8124 | if( item.kind == 'image' ) {
|
8125 | newLocationHash += item.albumID + '/' + item.GetID();
|
8126 | }
|
8127 | else {
|
8128 | newLocationHash += item.GetID();
|
8129 | }
|
8130 |
|
8131 | var content = '<br><br>';
|
8132 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="facebook">' + G.O.icons.shareFacebook + '</div>';
|
8133 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="pinterest">' + G.O.icons.sharePinterest + '</div>';
|
8134 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="tumblr">' + G.O.icons.shareTumblr + '</div>';
|
8135 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="twitter">' + G.O.icons.shareTwitter + '</div>';
|
8136 |
|
8137 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="vk">' + G.O.icons.shareVK + '</div>';
|
8138 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="mail">' + G.O.icons.shareMail + '</div>';
|
8139 | content += '<div class="nGY2PopupOneItem" style="text-align:center;"></div>';
|
8140 | content += '<input class="nGY2PopupOneItemText" readonly type="text" value="' + currentURL+newLocationHash + '" style="width:100%;text-align:center;">';
|
8141 | content += '<br>';
|
8142 |
|
8143 | currentURL = encodeURIComponent(document.location.protocol + '//' + document.location.hostname + document.location.pathname + newLocationHash);
|
8144 |
|
8145 | var currentTitle = item.title;
|
8146 | var currentTn = item.thumbImg().src;
|
8147 |
|
8148 |
|
8149 | Popup('nanogallery2 - share to:', content, 'Center');
|
8150 |
|
8151 | G.popup.$elt.find('.nGY2PopupOneItem').on('click', function(e) {
|
8152 | e.stopPropagation();
|
8153 |
|
8154 | var shareURL = '';
|
8155 | var found = true;
|
8156 | switch(jQuery(this).attr('data-share').toUpperCase()) {
|
8157 | case 'FACEBOOK':
|
8158 |
|
8159 |
|
8160 | shareURL = 'https://www.facebook.com/sharer.php?u=' + currentURL;
|
8161 | break;
|
8162 | case 'VK':
|
8163 | shareURL = 'http://vk.com/share.php?url=' + currentURL;
|
8164 | break;
|
8165 | case 'GOOGLEPLUS':
|
8166 | shareURL = "https://plus.google.com/share?url=" + currentURL;
|
8167 | break;
|
8168 | case 'TWITTER':
|
8169 |
|
8170 | shareURL = 'https://twitter.com/intent/tweet?text=' + currentTitle + 'url=' + currentURL;
|
8171 | break;
|
8172 | case 'PINTEREST':
|
8173 |
|
8174 | shareURL = 'https://pinterest.com/pin/create/button/?media=' + currentTn + '&url=' + currentURL + '&description=' + currentTitle;
|
8175 | break;
|
8176 | case 'TUMBLR':
|
8177 |
|
8178 | shareURL = 'http://www.tumblr.com/share/link?url=' + currentURL + '&name=' + currentTitle;
|
8179 | break;
|
8180 | case 'MAIL':
|
8181 | shareURL = 'mailto:?subject=' + currentTitle + '&body=' + currentURL;
|
8182 | break;
|
8183 | default:
|
8184 | found = false;
|
8185 | break;
|
8186 | }
|
8187 |
|
8188 | if( found ) {
|
8189 | window.open(shareURL, "" , "height=550,width=500,left=100,top=100,menubar=0" );
|
8190 | G.popup.close();
|
8191 |
|
8192 | }
|
8193 |
|
8194 | });
|
8195 | }
|
8196 |
|
8197 |
|
8198 | function Popup(title, content, align) {
|
8199 | var pp = '<div class="nGY2Popup" style="opacity:0;"><div class="nGY2PopupContent' + align + '">';
|
8200 | pp += '<div class="nGY2PopupCloseButton" style="font-size:0.9em;">' + G.O.icons.buttonClose + '</div>';
|
8201 | pp += '<div class="nGY2PopupTitle">' + title + '</div>';
|
8202 | pp += content;
|
8203 | pp += '</div></div>';
|
8204 |
|
8205 | G.popup.$elt = jQuery(pp).appendTo('body');
|
8206 | setElementOnTop( G.VOM.$viewer, G.popup.$elt);
|
8207 |
|
8208 | G.popup.isDisplayed = true;
|
8209 |
|
8210 | var tweenable = new NGTweenable();
|
8211 | tweenable.tween({
|
8212 | from: { o: 0, y: 100 },
|
8213 | to: { o: 1, y: 0 },
|
8214 | easing: 'easeInOutSine',
|
8215 | duration: 250,
|
8216 | step: function (state, att) {
|
8217 | G.popup.$elt[0].style.opacity = state.o;
|
8218 | G.popup.$elt[0].style[G.CSStransformName] = 'translateY(' + (state.y) + 'px)';
|
8219 | }
|
8220 | });
|
8221 |
|
8222 | G.popup.$elt.find('.nGY2PopupCloseButton').on('click', function(e) {
|
8223 | e.stopPropagation();
|
8224 | G.popup.close();
|
8225 | });
|
8226 |
|
8227 | }
|
8228 |
|
8229 |
|
8230 | function GalleryMouseEnter(e) {
|
8231 | if( !G.VOM.viewerDisplayed && G.GOM.albumIdx != -1 ) {
|
8232 | var r = GalleryEventRetrieveElementl(e, true);
|
8233 |
|
8234 | if( r.GOMidx != -1 ) {
|
8235 |
|
8236 |
|
8237 | ThumbnailHover(r.GOMidx);
|
8238 | }
|
8239 | }
|
8240 | }
|
8241 |
|
8242 | function GalleryMouseLeave(e) {
|
8243 | if( !G.VOM.viewerDisplayed && G.GOM.albumIdx != -1 ) {
|
8244 | var r = GalleryEventRetrieveElementl(e, true);
|
8245 | if( r.GOMidx != -1 ) {
|
8246 |
|
8247 |
|
8248 | ThumbnailHoverOut(r.GOMidx);
|
8249 | }
|
8250 | }
|
8251 | }
|
8252 |
|
8253 | function GalleryEventRetrieveElementl( e, ignoreSubItems ) {
|
8254 | var r = { action: 'NONE', GOMidx: -1 };
|
8255 |
|
8256 | if( e == undefined ) {
|
8257 | return r;
|
8258 | }
|
8259 | var target = e.target || e.srcElement;
|
8260 | while( target != G.$E.conTnParent[0] ) {
|
8261 | if( jQuery(target).hasClass('nGY2GThumbnail') ) {
|
8262 | if( r.action == 'NONE' ) {
|
8263 | r.action = 'OPEN';
|
8264 | }
|
8265 | r.GOMidx = jQuery(target).data('index');
|
8266 | return r;
|
8267 | }
|
8268 |
|
8269 | if( !ignoreSubItems ) {
|
8270 | var a = jQuery(target).data('ngy2action');
|
8271 | if( a != '' && a != undefined ) {
|
8272 | r.action = a;
|
8273 | }
|
8274 | }
|
8275 | if( target.parentNode == null ) {
|
8276 | return r;
|
8277 | }
|
8278 | target = target.parentNode;
|
8279 | }
|
8280 | return r;
|
8281 | }
|
8282 |
|
8283 |
|
8284 |
|
8285 | function ThumbnailOpen( idx, ignoreSelected ) {
|
8286 | var item = G.I[idx];
|
8287 |
|
8288 | G.GOM.albumIdxLoading = idx;
|
8289 |
|
8290 | var fu = G.O.fnThumbnailClicked;
|
8291 | if( fu !== null ) {
|
8292 | typeof fu == 'function' ? fu(item.$elt, item) : window[fu](item.$elt, item);
|
8293 | }
|
8294 |
|
8295 |
|
8296 | if( item.destinationURL !== undefined && item.destinationURL.length > 0 ) {
|
8297 | window.location = item.destinationURL;
|
8298 | return;
|
8299 | }
|
8300 |
|
8301 | switch( item.kind ) {
|
8302 | case 'image':
|
8303 | if( ignoreSelected === false && G.GOM.nbSelected > 0 ) {
|
8304 | ThumbnailSelectionToggle(idx);
|
8305 | }
|
8306 | else {
|
8307 |
|
8308 | DisplayPhotoIdx( idx );
|
8309 | }
|
8310 | break;
|
8311 | case 'album':
|
8312 | if( ignoreSelected === false && G.GOM.nbSelected > 0 ) {
|
8313 | ThumbnailSelectionToggle( idx );
|
8314 | }
|
8315 | else {
|
8316 | if( G.O.thumbnailAlbumDisplayImage && idx != 0 ) {
|
8317 |
|
8318 | DisplayFirstMediaInAlbum( idx );
|
8319 | return;
|
8320 | }
|
8321 | else {
|
8322 |
|
8323 | DisplayAlbum('-1', item.GetID());
|
8324 | }
|
8325 | }
|
8326 | break;
|
8327 | case 'albumUp':
|
8328 | var parent = NGY2Item.Get(G, item.albumID);
|
8329 | DisplayAlbum('-1', parent.albumID);
|
8330 | break;
|
8331 | }
|
8332 | }
|
8333 |
|
8334 | function DisplayFirstMediaInAlbum( albumIdx ) {
|
8335 | if( G.O.debugMode ) { console.log('#DisplayFirstPhotoInAlbum : '+ albumIdx); }
|
8336 |
|
8337 | var item = G.I[albumIdx];
|
8338 |
|
8339 | var l = G.I.length;
|
8340 | for( var i = 0; i < l; i++ ) {
|
8341 | if( G.I[i].albumID == item.GetID() ) {
|
8342 | DisplayPhotoIdx( i );
|
8343 | return;
|
8344 | }
|
8345 | }
|
8346 |
|
8347 |
|
8348 | AlbumGetContent( item.GetID(), DisplayFirstMediaInAlbum, albumIdx, null );
|
8349 |
|
8350 | }
|
8351 |
|
8352 |
|
8353 |
|
8354 | function OpenOriginal( item ) {
|
8355 | switch( G.O.kind ) {
|
8356 | case 'flickr':
|
8357 | var sU = 'https://www.flickr.com/photos/' + G.O.userID + '/' + item.GetID();
|
8358 | if( item.albumID != '0' ) {
|
8359 | sU += '/in/album-' + item.albumID + '/';
|
8360 | }
|
8361 | window.open(sU, '_blank');
|
8362 | break;
|
8363 | case 'picasa':
|
8364 | case 'google':
|
8365 | case 'google2':
|
8366 |
|
8367 |
|
8368 |
|
8369 |
|
8370 | default:
|
8371 | var sU = item.responsiveURL();
|
8372 | window.open(sU, '_blank');
|
8373 | break;
|
8374 | }
|
8375 | }
|
8376 |
|
8377 |
|
8378 |
|
8379 |
|
8380 |
|
8381 | function DisplayPhotoIdx( ngy2ItemIdx ) {
|
8382 |
|
8383 | if( !G.O.thumbnailOpenInLightox ) { return; }
|
8384 |
|
8385 | if( G.O.thumbnailOpenOriginal ) {
|
8386 |
|
8387 | OpenOriginal( G.I[ngy2ItemIdx] );
|
8388 | return;
|
8389 | }
|
8390 |
|
8391 | var items = [];
|
8392 |
|
8393 | G.VOM.content.current.vIdx = 0;
|
8394 | G.VOM.items = [];
|
8395 | G.VOM.albumID = G.I[ngy2ItemIdx].albumID;
|
8396 |
|
8397 | var vimg = new VImg(ngy2ItemIdx);
|
8398 | G.VOM.items.push(vimg);
|
8399 | items.push(G.I[ngy2ItemIdx]);
|
8400 |
|
8401 | var l = G.I.length;
|
8402 | for( let idx = ngy2ItemIdx+1; idx < l ; idx++) {
|
8403 | let item = G.I[idx];
|
8404 | if( item.kind == 'image' && item.isToDisplay(G.VOM.albumID) && item.destinationURL == '' ) {
|
8405 | let vimg = new VImg(idx);
|
8406 | G.VOM.items.push(vimg);
|
8407 | items.push(item);
|
8408 | }
|
8409 | }
|
8410 | var last = G.VOM.items.length;
|
8411 | var cnt = 1;
|
8412 | for( let idx = 0; idx < ngy2ItemIdx ; idx++) {
|
8413 | let item = G.I[idx];
|
8414 | if( item.kind == 'image' && item.isToDisplay(G.VOM.albumID) && item.destinationURL == '' ) {
|
8415 | let vimg = new VImg(idx);
|
8416 | vimg.mediaNumber = cnt;
|
8417 | G.VOM.items.push(vimg);
|
8418 | items.push(item);
|
8419 | cnt++;
|
8420 | }
|
8421 | }
|
8422 | for( let i = 0; i < last; i++ ) {
|
8423 | G.VOM.items[i].mediaNumber = cnt;
|
8424 | cnt++;
|
8425 | }
|
8426 |
|
8427 |
|
8428 | var fu = G.O.fnThumbnailOpen;
|
8429 | if( fu !== null ) {
|
8430 | typeof fu == 'function' ? fu(items) : window[fu](items);
|
8431 | return;
|
8432 | }
|
8433 |
|
8434 |
|
8435 | if( !G.VOM.viewerDisplayed ) {
|
8436 |
|
8437 | LightboxOpen();
|
8438 | }
|
8439 | else {
|
8440 |
|
8441 | G.VOM.content.current.$media.empty();
|
8442 | let item = G.VOM.content.current.NGY2Item();
|
8443 | var spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
8444 | if( item.mediaKind == 'img' && item.imageWidth != 0 && item.imageHeight != 0 ) {
|
8445 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
8446 | }
|
8447 | G.VOM.content.current.$media.append( spreloader + item.mediaMarkup);
|
8448 | ViewerSetMediaVisibility(G.VOM.content.next, 0);
|
8449 | ViewerSetMediaVisibility(G.VOM.content.previous, 0);
|
8450 | if( item.mediaKind == 'img' ) {
|
8451 | G.VOM.ImageLoader.loadImage(VieweImgSizeRetrieved, item);
|
8452 | }
|
8453 |
|
8454 |
|
8455 |
|
8456 |
|
8457 | LightboxDisplay('');
|
8458 | }
|
8459 | }
|
8460 |
|
8461 | function ViewerZoomStart() {
|
8462 | if( G.O.viewerZoom && !G.VOM.viewerMediaIsChanged ) {
|
8463 | var item = G.VOM.content.current.NGY2Item();
|
8464 | if( item.mediaKind == 'img' && item.imageHeight > 0 && item.imageWidth > 0 ) {
|
8465 | if( G.VOM.zoom.isZooming === false ) {
|
8466 |
|
8467 | G.VOM.zoom.userFactor = 1;
|
8468 | G.VOM.zoom.isZooming = true;
|
8469 | }
|
8470 | return true;
|
8471 | }
|
8472 | }
|
8473 | return false;
|
8474 | }
|
8475 |
|
8476 | function ViewerZoomIn( zoomIn ) {
|
8477 | if( zoomIn ) {
|
8478 |
|
8479 | G.VOM.zoom.userFactor += 0.1;
|
8480 | ViewerZoomMax();
|
8481 | }
|
8482 | else {
|
8483 |
|
8484 | G.VOM.zoom.userFactor -= 0.1;
|
8485 | ViewerZoomMin();
|
8486 | }
|
8487 | ViewerMediaSetPosAndZoom();
|
8488 | }
|
8489 |
|
8490 | function ViewerZoomMax() {
|
8491 | if( G.VOM.zoom.userFactor > 3 ) {
|
8492 | G.VOM.zoom.userFactor = 3;
|
8493 | }
|
8494 | }
|
8495 | function ViewerZoomMin() {
|
8496 |
|
8497 | if( G.VOM.zoom.userFactor < 0.2 ) {
|
8498 | G.VOM.zoom.userFactor = 0.2;
|
8499 | }
|
8500 | }
|
8501 |
|
8502 |
|
8503 |
|
8504 |
|
8505 | function ViewerMediaSetPosAndZoom() {
|
8506 |
|
8507 | if( !G.VOM.zoom.isZooming ) {
|
8508 | G.VOM.zoom.userFactor = 1;
|
8509 | }
|
8510 |
|
8511 | ViewerMediaSetPosAndZoomOne( G.VOM.content.current, true );
|
8512 | ViewerMediaSetPosAndZoomOne( G.VOM.content.previous, false );
|
8513 | ViewerMediaSetPosAndZoomOne( G.VOM.content.next, false );
|
8514 |
|
8515 | }
|
8516 |
|
8517 |
|
8518 |
|
8519 |
|
8520 | function ViewerMediaCenterNotImg( $mediaContainer ) {
|
8521 | var $media = $mediaContainer.children().eq(1);
|
8522 | var h = 90;
|
8523 | if( G.O.viewerGallery != 'none' ) { h -= 10; }
|
8524 | if( G.O.viewerToolbar.display != 'none' ) { h -= 10; }
|
8525 | $media.css( {'height': h+'%' });
|
8526 | $media.css( {'width': '90%' });
|
8527 | $media[0].style[G.CSStransformName] = 'translate(0px, "50%") ';
|
8528 | }
|
8529 |
|
8530 |
|
8531 | function ViewerMediaSetPosAndZoomOne(content_item, isCurrent ) {
|
8532 |
|
8533 | var item = content_item.NGY2Item();
|
8534 | var $img = content_item.$media;
|
8535 |
|
8536 |
|
8537 | if( item.mediaKind != 'img' ) {
|
8538 | ViewerMediaCenterNotImg( $img );
|
8539 | return;
|
8540 | }
|
8541 |
|
8542 | if( item.imageHeight == 0 || item.imageWidth == 0 ) {
|
8543 |
|
8544 | ViewerSetMediaVisibility( content_item, 0 );
|
8545 | return;
|
8546 | }
|
8547 |
|
8548 |
|
8549 | var zoomUserFactor = isCurrent == true ? G.VOM.zoom.userFactor : 1;
|
8550 |
|
8551 | var dpr = 1;
|
8552 | if( G.O.viewerImageDisplay == 'bestImageQuality' ) {
|
8553 | dpr = window.devicePixelRatio;
|
8554 | }
|
8555 |
|
8556 |
|
8557 | var zoomBaseFactorW = (G.VOM.window.lastWidth - G.VOM.padding.V) / (item.imageWidth / dpr);
|
8558 | var zoomBaseFactorH = (G.VOM.window.lastHeight - G.VOM.padding.H) / (item.imageHeight / dpr);
|
8559 | var zoomBaseFactor = Math.min(zoomBaseFactorW, zoomBaseFactorH);
|
8560 | if( zoomBaseFactor > 1 && G.O.viewerImageDisplay != 'upscale' ) {
|
8561 |
|
8562 | zoomBaseFactor = 1;
|
8563 | }
|
8564 |
|
8565 | var imageCurrentHeight = (item.imageHeight / dpr) * zoomUserFactor * zoomBaseFactor;
|
8566 | var imageCurrentWidth = (item.imageWidth / dpr) * zoomUserFactor * zoomBaseFactor;
|
8567 | $img.children().eq(1).css( {'height': imageCurrentHeight });
|
8568 | $img.children().eq(1).css( {'width': imageCurrentWidth });
|
8569 |
|
8570 |
|
8571 | var posX = 0;
|
8572 | if( imageCurrentWidth > G.VOM.window.lastWidth ) {
|
8573 | posX = -(imageCurrentWidth - G.VOM.window.lastWidth)/2;
|
8574 | }
|
8575 | var posY = 0;
|
8576 |
|
8577 |
|
8578 |
|
8579 |
|
8580 |
|
8581 |
|
8582 | if( isCurrent ) {
|
8583 | if( !G.VOM.zoom.isZooming ) {
|
8584 | G.VOM.panPosX = 0;
|
8585 | G.VOM.panPosY = 0;
|
8586 | }
|
8587 | G.VOM.zoom.posX = posX;
|
8588 | G.VOM.zoom.posY = posY;
|
8589 | ViewerImagePanSetPosition(G.VOM.panPosX, G.VOM.panPosY, $img, false);
|
8590 | }
|
8591 |
|
8592 |
|
8593 |
|
8594 | else {
|
8595 |
|
8596 | ViewerMediaPanX( G.VOM.swipePosX );
|
8597 | $img.children().eq(1)[0].style[G.CSStransformName]= 'translate(0px, 0px) rotate('+ item.rotationAngle +'deg)';
|
8598 | }
|
8599 |
|
8600 | }
|
8601 |
|
8602 |
|
8603 |
|
8604 | function ViewerImagePanSetPosition(posX, posY, imageContainer, savePosition ) {
|
8605 | if( savePosition ) {
|
8606 | G.VOM.panPosX = posX;
|
8607 | G.VOM.panPosY = posY;
|
8608 | }
|
8609 |
|
8610 | posX += G.VOM.zoom.posX;
|
8611 | posY += G.VOM.zoom.posY;
|
8612 |
|
8613 |
|
8614 | imageContainer.children().eq(1)[0].style[G.CSStransformName]= 'translate('+ posX + 'px, '+ posY + 'px) rotate('+ G.VOM.content.current.NGY2Item().rotationAngle +'deg)';
|
8615 |
|
8616 |
|
8617 | }
|
8618 |
|
8619 |
|
8620 |
|
8621 |
|
8622 | function LightboxOpen( idx ) {
|
8623 |
|
8624 |
|
8625 | G.GOM.firstDisplay = false;
|
8626 |
|
8627 |
|
8628 | jQuery('head').append('<style id="nGY2_body_scrollbar_style" type="text/css">.nGY2_body_scrollbar{margin-right: ' + (window.innerWidth - document.documentElement.clientWidth) + 'px;}</style>');
|
8629 | jQuery("body").addClass("nGY2_body_scrollbar");
|
8630 |
|
8631 |
|
8632 | G.VOM.$baseCont = jQuery('<div class="nGY2 nGY2ViewerContainer" style="opacity:1"></div>').appendTo('body');
|
8633 |
|
8634 | SetViewerTheme();
|
8635 |
|
8636 | G.VOM.$viewer = jQuery('<div class="nGY2Viewer" style="opacity:0" itemscope itemtype="http://schema.org/ImageObject"></div>').appendTo( G.VOM.$baseCont );
|
8637 | G.VOM.$viewer.css({ msTouchAction: 'none', touchAction: 'none' });
|
8638 |
|
8639 | if( idx == undefined ) {
|
8640 | G.VOM.content.current.vIdx = 0;
|
8641 | }
|
8642 | else {
|
8643 | G.VOM.content.current.vIdx = idx;
|
8644 | }
|
8645 | G.VOM.content.previous.vIdx = G.VOM.IdxNext();
|
8646 | G.VOM.content.next.vIdx = G.VOM.IdxPrevious();
|
8647 |
|
8648 | var sMedia = '<div class="nGY2ViewerMediaPan"><div class="nGY2ViewerMediaLoaderDisplayed"></div>' + G.VOM.content.previous.NGY2Item().mediaMarkup + '</div>';
|
8649 | sMedia += '<div class="nGY2ViewerMediaPan"><div class="nGY2ViewerMediaLoaderDisplayed"></div>' + G.VOM.content.current.NGY2Item().mediaMarkup + '</div>';
|
8650 | sMedia += '<div class="nGY2ViewerMediaPan"><div class="nGY2ViewerMediaLoaderDisplayed"></div>' + G.VOM.content.next.NGY2Item().mediaMarkup + '</div>';
|
8651 |
|
8652 | var sNav = '';
|
8653 | var iconP = G.O.icons.viewerImgPrevious;
|
8654 | if( iconP != undefined && iconP != '') {
|
8655 | sNav += '<div class="nGY2ViewerAreaPrevious ngy2viewerToolAction" data-ngy2action="previous">' + iconP + '</div>';
|
8656 | }
|
8657 | var iconN = G.O.icons.viewerImgNext;
|
8658 | if( iconN != undefined && iconN != '') {
|
8659 | sNav += '<div class="nGY2ViewerAreaNext ngy2viewerToolAction" data-ngy2action="next">' + iconN + '</div>';
|
8660 | }
|
8661 |
|
8662 | G.VOM.$content = jQuery('<div class="nGY2ViewerContent">' + sMedia + sNav + '</div>').appendTo( G.VOM.$viewer );
|
8663 |
|
8664 | G.VOM.$buttonLeft = G.VOM.$content.find('.nGY2ViewerAreaPrevious');
|
8665 | G.VOM.$buttonRight = G.VOM.$content.find('.nGY2ViewerAreaNext');
|
8666 |
|
8667 | var $mediaPan = G.VOM.$content.find('.nGY2ViewerMediaPan');
|
8668 | G.VOM.content.previous.$media = $mediaPan.eq(0);
|
8669 | G.VOM.content.current.$media = $mediaPan.eq(1);
|
8670 | G.VOM.content.next.$media = $mediaPan.eq(2);
|
8671 |
|
8672 |
|
8673 | var vP = G.GOM.cache.viewport;
|
8674 | G.VOM.content.previous.$media[0].style[G.CSStransformName] = 'translate(-' + vP.w + 'px, 0px)';
|
8675 | G.VOM.content.next.$media[0].style[G.CSStransformName] = 'translate(' + vP.w + 'px, 0px)';
|
8676 |
|
8677 |
|
8678 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, G.VOM.content.current.NGY2Item() );
|
8679 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, G.VOM.content.previous.NGY2Item() );
|
8680 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, G.VOM.content.next.NGY2Item() );
|
8681 |
|
8682 | G.VOM.padding.H = parseInt(G.VOM.$content.css("padding-left")) + parseInt(G.VOM.$content.css("padding-right"));
|
8683 | G.VOM.padding.V = parseInt(G.VOM.$content.css("padding-top")) + parseInt(G.VOM.$content.css("padding-bottom"));
|
8684 |
|
8685 |
|
8686 | var vtbBg1 = '';
|
8687 | var vtbBg2 = ' toolbarBackground';
|
8688 | if( G.O.viewerToolbar.fullWidth ) {
|
8689 | vtbBg1 = ' toolbarBackground';
|
8690 | vtbBg2 = '';
|
8691 | }
|
8692 | var vtbAlign = 'text-align:center;';
|
8693 | switch ( G.O.viewerToolbar.align ) {
|
8694 | case 'left':
|
8695 | vtbAlign = 'text-align:left;';
|
8696 | break;
|
8697 | case 'right':
|
8698 | vtbAlign = 'text-align:right;';
|
8699 | break;
|
8700 | }
|
8701 | var sTB = '<div class="toolbarContainer nGEvent' + vtbBg1 + '" style="visibility:' +(G.O.viewerToolbar.display ? "visible" : "hidden")+';'+vtbAlign+'"><div class="toolbar nGEvent' + vtbBg2 + '"></div></div>';
|
8702 | G.VOM.$toolbar = jQuery(sTB).appendTo(G.VOM.$viewer);
|
8703 |
|
8704 | if( G.VOM.toolbarMode == 'min' || (G.O.viewerToolbar.autoMinimize > 0 && G.O.viewerToolbar.autoMinimize >= G.GOM.cache.viewport.w) ) {
|
8705 | ViewerToolbarForVisibilityMin();
|
8706 | }
|
8707 | else {
|
8708 | ViewerToolbarForVisibilityStd();
|
8709 | }
|
8710 |
|
8711 |
|
8712 | var sTopLeft = '<div class="nGY2ViewerToolsTopLeft nGEvent"><div class="toolbar nGEvent">';
|
8713 | var sTL = G.O.viewerTools.topLeft.split(',');
|
8714 | for( var i = 0, sTLL = sTL.length; i < sTLL; i++) {
|
8715 | sTopLeft += ToolbarAddElt( sTL[i] );
|
8716 | }
|
8717 | sTopLeft += '</div></div>';
|
8718 | G.VOM.$toolbarTL = jQuery(sTopLeft).appendTo(G.VOM.$viewer);
|
8719 |
|
8720 |
|
8721 | var sTopRight = '<div class="nGY2ViewerToolsTopRight nGEvent"><div class="toolbar nGEvent">';
|
8722 | var sTR = G.O.viewerTools.topRight.split(',');
|
8723 | for( var i = 0, sTRL = sTR.length; i < sTRL; i++) {
|
8724 | sTopRight += ToolbarAddElt( sTR[i] );
|
8725 | }
|
8726 | sTopRight += '</div></div>';
|
8727 | G.VOM.$toolbarTR = jQuery(sTopRight).appendTo(G.VOM.$viewer);
|
8728 |
|
8729 |
|
8730 | ViewerToolsOn();
|
8731 |
|
8732 |
|
8733 | if( ngscreenfull.enabled && G.O.viewerFullscreen ) {
|
8734 | ngscreenfull.request();
|
8735 | G.VOM.viewerIsFullscreen=true;
|
8736 | }
|
8737 |
|
8738 |
|
8739 | LightboxGalleryBuild();
|
8740 |
|
8741 | setElementOnTop('', G.VOM.$viewer);
|
8742 | ResizeLightbox(true);
|
8743 | G.VOM.gallery.Resize();
|
8744 | G.VOM.timeImgChanged = new Date().getTime();
|
8745 |
|
8746 |
|
8747 | G.VOM.$toolbarTL.css('opacity', 0);
|
8748 | G.VOM.$toolbarTR.css('opacity', 0);
|
8749 | G.VOM.$buttonLeft.css('opacity', 0);
|
8750 | G.VOM.$buttonRight.css('opacity', 0);
|
8751 | if( G.O.viewerGallery != 'none' ) { G.VOM.gallery.$elt.css('opacity', 0); }
|
8752 | G.VOM.$content.css('opacity', 0);
|
8753 | G.VOM.$toolbarTR[0].style[G.CSStransformName] = 'translateY(-40px) ';
|
8754 | G.VOM.$toolbarTL[0].style[G.CSStransformName] = 'translateY(-40px) ';
|
8755 | G.VOM.$buttonLeft[0].style[G.CSStransformName] = 'translateX(-40px) ';
|
8756 | G.VOM.$buttonRight[0].style[G.CSStransformName] = 'translateX(40px) ';
|
8757 |
|
8758 |
|
8759 | new NGTweenable().tween({
|
8760 | from: { opacity: 0, posY: G.VOM.window.lastHeight*.5 },
|
8761 | to: { opacity: 1, posY: 0 },
|
8762 | delay: 10,
|
8763 | duration: 450,
|
8764 | easing: 'easeInOutQuint',
|
8765 | step: function (state) {
|
8766 |
|
8767 | G.VOM.$viewer.css('opacity', state.opacity);
|
8768 | G.VOM.$viewer[0].style[G.CSStransformName] = 'translateY(' + (state.posY) + 'px) ';
|
8769 |
|
8770 |
|
8771 | G.VOM.$content.css('opacity', state.opacity);
|
8772 | }
|
8773 | });
|
8774 |
|
8775 |
|
8776 |
|
8777 | new NGTweenable().tween({
|
8778 | from: { posY: -40, opacity: 0, scale: 3 },
|
8779 | to: { posY: 0, opacity: 1, scale: 1 },
|
8780 | delay: 300,
|
8781 | duration: 400,
|
8782 | easing: 'easeInOutQuint',
|
8783 | step: function (state) {
|
8784 |
|
8785 |
|
8786 | G.VOM.$toolbarTR[0].style[G.CSStransformName] = 'translateY(' + (state.posY) + 'px) ';
|
8787 | G.VOM.$toolbarTL[0].style[G.CSStransformName] = 'translateY(' + (state.posY) + 'px) ';
|
8788 | G.VOM.$buttonLeft[0].style[G.CSStransformName] = 'translateX(' + (state.posY) + 'px) ';
|
8789 | G.VOM.$buttonRight[0].style[G.CSStransformName] = 'translateX(' + (-state.posY) + 'px) ';
|
8790 |
|
8791 |
|
8792 | if( G.O.viewerGallery != 'none' ) {
|
8793 | G.VOM.gallery.$elt.css({ opacity: state.opacity });
|
8794 | G.VOM.gallery.$elt[0].style[G.CSStransformName] = 'scale('+state.scale+')';
|
8795 | }
|
8796 |
|
8797 | },
|
8798 | finish: function() {
|
8799 | G.VOM.viewerDisplayed = true;
|
8800 | ViewerMediaPanX(0);
|
8801 | ViewerSetEvents();
|
8802 |
|
8803 | LightboxDisplay('');
|
8804 |
|
8805 | if( G.O.slideshowAutoStart ) {
|
8806 | G.VOM.playSlideshow = false;
|
8807 | SlideshowToggle();
|
8808 | }
|
8809 |
|
8810 | ViewerToolsUnHide();
|
8811 | LightboxDisplayFinalize('');
|
8812 | }
|
8813 | });
|
8814 |
|
8815 |
|
8816 |
|
8817 |
|
8818 |
|
8819 |
|
8820 |
|
8821 |
|
8822 |
|
8823 |
|
8824 |
|
8825 |
|
8826 |
|
8827 |
|
8828 |
|
8829 |
|
8830 |
|
8831 |
|
8832 | }
|
8833 |
|
8834 | function ViewerEvents() {
|
8835 | if( !G.VOM.viewerDisplayed || G.VOM.viewerMediaIsChanged ) {
|
8836 |
|
8837 |
|
8838 | return false;
|
8839 | }
|
8840 | return true;
|
8841 | }
|
8842 |
|
8843 |
|
8844 | function LightboxGalleryBuild() {
|
8845 |
|
8846 | G.VOM.gallery.firstDisplay = true;
|
8847 |
|
8848 | if( G.O.viewerGallery != 'none' ) {
|
8849 |
|
8850 | var tw = G.O.viewerGalleryTWidth;
|
8851 | var th = G.O.viewerGalleryTHeight;
|
8852 | var gutter = 2;
|
8853 |
|
8854 | var t = '';
|
8855 | for( var i=0; i< G.VOM.items.length; i++) {
|
8856 | var idx = G.VOM.items[i].ngy2ItemIdx;
|
8857 | var o = G.I[idx];
|
8858 | var src = (o.thumbImg().src).replace(/'/g, "%27");
|
8859 | src = src.replace(/\\/g, '\\\\');
|
8860 | t += '<div class="nGY2VThumbnail" style="width:'+tw+'px;height:'+th+'px;left:'+i*(tw+gutter*2)+'px;background-image: url(''+src+'');" data-ngy2_lightbox_thumbnail="true" data-ngy2_idx="' + idx + '" data-ngy2_vidx="' + i + '" ></div>';
|
8861 | }
|
8862 | G.VOM.gallery.gwidth = (tw+2*gutter) * G.VOM.items.length;
|
8863 | G.VOM.gallery.oneTmbWidth = tw+2*gutter;
|
8864 | var tc = "<div class='nGY2VThumbnailContainer' style='height:"+(th+gutter*2)+"px;left:0;width:"+G.VOM.gallery.gwidth+"px;' data-ngy2_lightbox_gallery='true'>" + t + "</div>";
|
8865 | G.VOM.gallery.$elt = jQuery('<div class="nGY2viewerGallery" style="display: inline-block;height:'+(th+gutter*2)+'px;left:0;right:0;">'+ tc +'</div>').appendTo(G.VOM.$viewer);
|
8866 | G.VOM.gallery.$tmbCont = G.VOM.gallery.$elt.find('.nGY2VThumbnailContainer')
|
8867 |
|
8868 | G.VOM.gallery.Resize();
|
8869 | G.VOM.gallery.SetThumbnailActive();
|
8870 |
|
8871 | }
|
8872 | }
|
8873 |
|
8874 |
|
8875 |
|
8876 | function ViewerSetEvents() {
|
8877 |
|
8878 | if( G.VOM.hammertime == null ) {
|
8879 |
|
8880 | G.VOM.hammertime = new NGHammer.Manager(G.VOM.$baseCont[0], {
|
8881 |
|
8882 | recognizers: [
|
8883 | [NGHammer.Pinch, { enable: true }],
|
8884 | [NGHammer.Pan, { direction: NGHammer.DIRECTION_ALL }]
|
8885 | ]
|
8886 | });
|
8887 |
|
8888 |
|
8889 | G.VOM.hammertime.on('pan', function(ev) {
|
8890 | if( !ViewerEvents() ) { return; }
|
8891 |
|
8892 |
|
8893 | if( G.VOM.panMode == 'off' ) {
|
8894 |
|
8895 | if( ev.target.dataset.ngy2_lightbox_thumbnail != undefined || ev.target.dataset.ngy2_lightbox_gallery != undefined ){
|
8896 | G.VOM.panMode = 'gallery';
|
8897 | }
|
8898 | else {
|
8899 | if( G.VOM.zoom.isZooming ) {
|
8900 | G.VOM.panMode = 'zoom';
|
8901 | }
|
8902 | else {
|
8903 | G.VOM.panMode = 'media';
|
8904 | }
|
8905 | }
|
8906 | }
|
8907 |
|
8908 |
|
8909 | switch( G.VOM.panMode ) {
|
8910 | case 'zoom':
|
8911 |
|
8912 | ViewerImagePanSetPosition(G.VOM.panPosX + ev.deltaX, G.VOM.panPosY + ev.deltaY, G.VOM.content.current.$media, false);
|
8913 | G.VOM.toolsHide();
|
8914 | break;
|
8915 |
|
8916 | case 'media':
|
8917 | if( Math.abs(ev.deltaY) > G.VOM.panThreshold && Math.abs(ev.deltaX) < G.VOM.panThreshold && !G.VOM.panXOnly ) {
|
8918 |
|
8919 | ViewerMediaPanX( 0 );
|
8920 | var dist = 0;
|
8921 | if( ev.deltaY < 0 ) {
|
8922 |
|
8923 | dist = Math.max( ev.deltaY, -200);
|
8924 | }
|
8925 | else {
|
8926 |
|
8927 | dist = Math.min( ev.deltaY, 200);
|
8928 | }
|
8929 | G.VOM.$viewer[0].style[G.CSStransformName] = 'translateY(' + dist + 'px) ';
|
8930 | G.VOM.$viewer.css('opacity', 1-Math.abs(dist)/200/2);
|
8931 | }
|
8932 | else {
|
8933 |
|
8934 | if( Math.abs(ev.deltaX) > G.VOM.panThreshold ) {
|
8935 | G.VOM.panXOnly = true;
|
8936 | }
|
8937 | ViewerMediaPanX( ev.deltaX );
|
8938 | G.VOM.$viewer[0].style[G.CSStransformName] = 'translateY(0px)';
|
8939 | G.VOM.$viewer.css('opacity', 1);
|
8940 | }
|
8941 | break;
|
8942 |
|
8943 | case 'gallery':
|
8944 | G.VOM.gallery.PanGallery( ev.deltaX );
|
8945 | break;
|
8946 | }
|
8947 |
|
8948 | });
|
8949 |
|
8950 |
|
8951 | G.VOM.hammertime.on('panend', function(ev) {
|
8952 | if( !ViewerEvents() ) { return; }
|
8953 |
|
8954 | switch( G.VOM.panMode ) {
|
8955 | case 'zoom':
|
8956 |
|
8957 | G.VOM.timeImgChanged = new Date().getTime();
|
8958 | ViewerImagePanSetPosition( G.VOM.panPosX+ev.deltaX, G.VOM.panPosY+ev.deltaY, G.VOM.content.current.$media, true);
|
8959 | break;
|
8960 | case 'media':
|
8961 | var panY = false;
|
8962 | if( !G.VOM.panXOnly ) {
|
8963 | if( Math.abs(ev.deltaY) > 50 && Math.abs(ev.deltaX) < 50 ) {
|
8964 |
|
8965 | LightboxClose();
|
8966 | panY = true;
|
8967 | }
|
8968 | }
|
8969 | if( !panY ) {
|
8970 | if( Math.abs( ev.deltaX ) < 50 ) {
|
8971 | ViewerMediaPanX(0);
|
8972 | }
|
8973 | else {
|
8974 | ev.deltaX > 50 ? DisplayPreviousMedia( Math.abs(ev.velocityX) ) : DisplayNextMedia( Math.abs(ev.velocityX) );
|
8975 | }
|
8976 | }
|
8977 | G.VOM.panXOnly = false;
|
8978 | break;
|
8979 | case 'gallery':
|
8980 |
|
8981 | G.VOM.gallery.posX += ev.deltaX;
|
8982 | G.VOM.gallery.PanGallery( 0 );
|
8983 | G.VOM.gallery.PanGalleryEnd( ev.velocityX );
|
8984 | break;
|
8985 | }
|
8986 |
|
8987 | G.VOM.panMode = 'off';
|
8988 | });
|
8989 |
|
8990 |
|
8991 |
|
8992 | if( G.O.viewerZoom ) {
|
8993 |
|
8994 | G.VOM.hammertime.add( new NGHammer.Tap({ event: 'doubletap', taps: 2, interval: 250 }) );
|
8995 | G.VOM.hammertime.add( new NGHammer.Tap({ event: 'singletap' }) );
|
8996 | G.VOM.hammertime.get('doubletap').recognizeWith('singletap');
|
8997 | G.VOM.hammertime.get('singletap').requireFailure('doubletap');
|
8998 |
|
8999 |
|
9000 | G.VOM.hammertime.on('singletap', function(ev) {
|
9001 |
|
9002 | if( !ViewerEvents() ) { return; }
|
9003 |
|
9004 |
|
9005 | if( ev.target.dataset.ngy2_lightbox_thumbnail != undefined ){
|
9006 |
|
9007 | var idx = parseInt(ev.target.dataset.ngy2_idx);
|
9008 | var vidx = parseInt(ev.target.dataset.ngy2_vidx);
|
9009 |
|
9010 | if( !isNaN(idx) && vidx != G.VOM.content.current.vIdx ) {
|
9011 |
|
9012 | if( vidx > G.VOM.content.current.vIdx ) {
|
9013 | TriggerCustomEvent('lightboxNextImage');
|
9014 |
|
9015 |
|
9016 | G.VOM.content.next.$media.empty();
|
9017 | var nextItem = G.I[idx];
|
9018 | G.VOM.content.next.vIdx = vidx;
|
9019 | let spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
9020 | if( nextItem.mediaKind == 'img' && nextItem.imageWidth != 0 && nextItem.imageHeight != 0 ) {
|
9021 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
9022 | }
|
9023 | G.VOM.content.next.$media.append( spreloader + nextItem.mediaMarkup );
|
9024 | if( nextItem.mediaKind == 'img' ) {
|
9025 | G.VOM.ImageLoader.loadImage(VieweImgSizeRetrieved, nextItem);
|
9026 | }
|
9027 | else {
|
9028 | ViewerMediaCenterNotImg( G.VOM.content.next.$media );
|
9029 | }
|
9030 | LightboxDisplay('nextImage');
|
9031 |
|
9032 | }
|
9033 | else {
|
9034 | TriggerCustomEvent('lightboxPreviousImage');
|
9035 |
|
9036 |
|
9037 | G.VOM.content.previous.$media.empty();
|
9038 | var previousItem = G.I[idx];
|
9039 | G.VOM.content.previous.vIdx = vidx;
|
9040 | let spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
9041 | if( previousItem.mediaKind == 'img' && previousItem.imageWidth != 0 && previousItem.imageHeight != 0 ) {
|
9042 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
9043 | }
|
9044 | G.VOM.content.previous.$media.append( spreloader + previousItem.mediaMarkup );
|
9045 | if( previousItem.mediaKind == 'img' ) {
|
9046 | G.VOM.ImageLoader.loadImage(VieweImgSizeRetrieved, previousItem);
|
9047 | }
|
9048 | else {
|
9049 | ViewerMediaCenterNotImg( G.VOM.content.previous.$media );
|
9050 | }
|
9051 | LightboxDisplay('previousImage');
|
9052 | }
|
9053 | return;
|
9054 | }
|
9055 | }
|
9056 |
|
9057 |
|
9058 | StopPropagationPreventDefault(ev.srcEvent);
|
9059 | if( G.VOM.toolbarsDisplayed == false ) {
|
9060 | debounce( ViewerToolsUnHide, 100, false)();
|
9061 | G.VOM.singletapTime = new Date().getTime();
|
9062 | }
|
9063 | else {
|
9064 |
|
9065 | if( (new Date().getTime()) - G.VOM.singletapTime < 400 ) { return; }
|
9066 |
|
9067 | if( G.VOM.content.current.NGY2Item().mediaKind == 'img' && ev.target.className.indexOf('nGY2ViewerMedia') !== -1 ) {
|
9068 | var x =0;
|
9069 | if( ev.srcEvent instanceof MouseEvent ) {
|
9070 | x = ev.srcEvent.pageX;
|
9071 | }
|
9072 | else {
|
9073 | x = ev.srcEvent.changedTouches[0].pageX;
|
9074 | }
|
9075 | if( x < (G.GOM.cache.viewport.w/2) ) {
|
9076 | DisplayPreviousMedia();
|
9077 | }
|
9078 | else {
|
9079 | DisplayNextMedia();
|
9080 | }
|
9081 | }
|
9082 | }
|
9083 | });
|
9084 |
|
9085 |
|
9086 | G.VOM.hammertime.on('doubletap', function(ev) {
|
9087 | if( !ViewerEvents() ) { return; }
|
9088 | StopPropagationPreventDefault(ev.srcEvent);
|
9089 |
|
9090 | if( ev.target.className.indexOf('nGY2ViewerMedia') !== -1 ) {
|
9091 |
|
9092 | if( G.VOM.zoom.isZooming ) {
|
9093 | G.VOM.zoom.isZooming = false;
|
9094 |
|
9095 | ResizeLightbox(true);
|
9096 | }
|
9097 | else {
|
9098 | if( ViewerZoomStart() ) {
|
9099 | G.VOM.zoom.userFactor = 1.5;
|
9100 | ViewerMediaSetPosAndZoom();
|
9101 | }
|
9102 | }
|
9103 | }
|
9104 | });
|
9105 |
|
9106 |
|
9107 | G.VOM.hammertime.on('pinchend', function(ev) {
|
9108 | ev.srcEvent.stopPropagation();
|
9109 | ev.srcEvent.preventDefault();
|
9110 | G.VOM.timeImgChanged = new Date().getTime();
|
9111 | });
|
9112 | G.VOM.hammertime.on('pinch', function(ev) {
|
9113 | ev.srcEvent.stopPropagation();
|
9114 | ev.srcEvent.preventDefault();
|
9115 |
|
9116 | if( ViewerZoomStart() ) {
|
9117 | G.VOM.zoom.userFactor = ev.scale;
|
9118 | ViewerZoomMax();
|
9119 | ViewerZoomMin();
|
9120 | ViewerMediaSetPosAndZoom();
|
9121 | }
|
9122 | });
|
9123 | }
|
9124 |
|
9125 |
|
9126 | else {
|
9127 |
|
9128 |
|
9129 | G.VOM.hammertime.add( new NGHammer.Tap({ event: 'singletap' }) );
|
9130 |
|
9131 |
|
9132 |
|
9133 | G.VOM.hammertime.on('singletap', function(ev) {
|
9134 | if( !ViewerEvents() ) { return; }
|
9135 | StopPropagationPreventDefault( ev.srcEvent );
|
9136 | if( G.VOM.toolbarsDisplayed == false ){
|
9137 |
|
9138 | debounce( ViewerToolsUnHide, 100, false)();
|
9139 | G.VOM.singletapTime = new Date().getTime();
|
9140 | }
|
9141 | else {
|
9142 |
|
9143 | if( (new Date().getTime()) - G.VOM.singletapTime < 400 ) { return; }
|
9144 | if( ev.target.className.indexOf('nGY2ViewerMedia') !== -1 ) {
|
9145 | var x = 0;
|
9146 | if( ev.srcEvent instanceof MouseEvent ) {
|
9147 | x = ev.srcEvent.pageX;
|
9148 | }
|
9149 | else {
|
9150 | x = ev.srcEvent.changedTouches[0].pageX;
|
9151 | }
|
9152 | if( x < (G.GOM.cache.viewport.w/2) ) {
|
9153 | DisplayPreviousMedia();
|
9154 | }
|
9155 | else {
|
9156 | DisplayNextMedia();
|
9157 | }
|
9158 | }
|
9159 | }
|
9160 |
|
9161 | });
|
9162 | }
|
9163 | }
|
9164 | }
|
9165 |
|
9166 |
|
9167 | function StopPropagationPreventDefault(e) {
|
9168 | e.stopPropagation();
|
9169 | e.preventDefault();
|
9170 | }
|
9171 |
|
9172 |
|
9173 | function ViewerToolsHide() {
|
9174 | if( G.VOM.viewerDisplayed ) {
|
9175 | G.VOM.toolbarsDisplayed = false;
|
9176 | ViewerToolsOpacity(0);
|
9177 | }
|
9178 | }
|
9179 |
|
9180 | function ViewerToolsUnHide() {
|
9181 | if( G.VOM.viewerDisplayed ) {
|
9182 | G.VOM.toolbarsDisplayed = true;
|
9183 | ViewerToolsOpacity(1);
|
9184 | G.VOM.toolsHide();
|
9185 | }
|
9186 | }
|
9187 |
|
9188 | function ViewerToolsOpacity( op ) {
|
9189 | if( G.VOM.$toolbar != null ) {
|
9190 | G.VOM.$toolbar.css('opacity', op);
|
9191 | }
|
9192 | if( G.VOM.$toolbarTL != null ) {
|
9193 | G.VOM.$toolbarTL.css('opacity', op);
|
9194 | }
|
9195 | if( G.VOM.$toolbarTR != null ) {
|
9196 | G.VOM.$toolbarTR.css('opacity', op);
|
9197 | }
|
9198 |
|
9199 |
|
9200 | G.VOM.$content.find('.nGY2ViewerAreaNext').css('opacity', op);
|
9201 | G.VOM.$content.find('.nGY2ViewerAreaPrevious').css('opacity', op);
|
9202 |
|
9203 |
|
9204 |
|
9205 | }
|
9206 |
|
9207 |
|
9208 |
|
9209 | function ViewerToolsOn() {
|
9210 |
|
9211 | G.VOM.$viewer.off('touchstart click', '.ngy2viewerToolAction', ViewerToolsAction);
|
9212 |
|
9213 |
|
9214 | G.VOM.$viewer.on('touchstart click', '.ngy2viewerToolAction', ViewerToolsAction);
|
9215 | }
|
9216 |
|
9217 |
|
9218 |
|
9219 | function ViewerToolsAction(e) {
|
9220 |
|
9221 | if( (new Date().getTime()) - G.timeLastTouchStart < 300 ) { return; }
|
9222 | G.timeLastTouchStart = new Date().getTime();
|
9223 |
|
9224 | var $this = $(this);
|
9225 | var ngy2action = $this.data('ngy2action');
|
9226 | if( ngy2action == undefined ) { return; }
|
9227 | switch( ngy2action ) {
|
9228 | case 'next':
|
9229 | StopPropagationPreventDefault(e);
|
9230 | DisplayNextMedia();
|
9231 | break;
|
9232 | case 'previous':
|
9233 | StopPropagationPreventDefault(e);
|
9234 | DisplayPreviousMedia();
|
9235 | break;
|
9236 | case 'playPause':
|
9237 | e.stopPropagation();
|
9238 | SlideshowToggle();
|
9239 | break;
|
9240 | case 'zoomIn':
|
9241 | StopPropagationPreventDefault(e);
|
9242 | if( ViewerZoomStart() ) { ViewerZoomIn( true ); }
|
9243 | break;
|
9244 | case 'zoomOut':
|
9245 | StopPropagationPreventDefault(e);
|
9246 | if( ViewerZoomStart() ) { ViewerZoomIn( false ); }
|
9247 | break;
|
9248 | case 'minimize':
|
9249 |
|
9250 | StopPropagationPreventDefault(e);
|
9251 | if( G.VOM.toolbarMode == 'std' ) {
|
9252 | ViewerToolbarForVisibilityMin();
|
9253 | }
|
9254 | else {
|
9255 | ViewerToolbarForVisibilityStd();
|
9256 | }
|
9257 | break;
|
9258 | case 'fullScreen':
|
9259 |
|
9260 | e.stopPropagation();
|
9261 | if( ngscreenfull.enabled ) {
|
9262 | ngscreenfull.toggle();
|
9263 | }
|
9264 | break;
|
9265 | case 'info':
|
9266 | e.stopPropagation();
|
9267 | ItemDisplayInfo( G.VOM.content.current.NGY2Item() );
|
9268 | break;
|
9269 | case 'close':
|
9270 | StopPropagationPreventDefault(e);
|
9271 | if( (new Date().getTime()) - G.VOM.timeImgChanged < 400 ) { return; }
|
9272 | LightboxClose();
|
9273 | break;
|
9274 | case 'download':
|
9275 | StopPropagationPreventDefault(e);
|
9276 | DownloadImage(G.VOM.items[G.VOM.content.current.vIdx].ngy2ItemIdx);
|
9277 | break;
|
9278 | case 'share':
|
9279 | StopPropagationPreventDefault(e);
|
9280 | PopupShare(G.VOM.items[G.VOM.content.current.vIdx].ngy2ItemIdx);
|
9281 | break;
|
9282 | case 'linkOriginal':
|
9283 | StopPropagationPreventDefault(e);
|
9284 | OpenOriginal( G.VOM.content.current.NGY2Item() );
|
9285 | break;
|
9286 | case 'rotateLeft':
|
9287 | StopPropagationPreventDefault(e);
|
9288 | ViewerImageRotate(-90);
|
9289 | break;
|
9290 | case 'rotateRight':
|
9291 | StopPropagationPreventDefault(e);
|
9292 | ViewerImageRotate(90);
|
9293 | break;
|
9294 | case 'shoppingcart':
|
9295 | StopPropagationPreventDefault(e);
|
9296 | AddToCart( G.VOM.items[G.VOM.content.current.vIdx].ngy2ItemIdx, 'lightbox');
|
9297 | break;
|
9298 | }
|
9299 |
|
9300 |
|
9301 | var fu = G.O.fnImgToolbarCustClick;
|
9302 | if( ngy2action.indexOf('custom') == 0 && fu !== null ) {
|
9303 | typeof fu == 'function' ? fu(ngy2action, $this, G.VOM.content.current.NGY2Item() ) : window[fu](ngy2action, $this, G.VOM.content.current.NGY2Item() );
|
9304 | }
|
9305 | }
|
9306 |
|
9307 |
|
9308 | function ViewerImageRotate( angle ) {
|
9309 | var item = G.VOM.content.current.NGY2Item();
|
9310 | if( item.mediaKind == 'img' ) {
|
9311 | item.rotationAngle += angle;
|
9312 | item.rotationAngle = item.rotationAngle % 360;
|
9313 | if( item.rotationAngle < 0 ) {
|
9314 | item.rotationAngle += 360;
|
9315 | }
|
9316 | ViewerMediaPanX( 0 );
|
9317 | ViewerMediaSetPosAndZoomOne( G.VOM.content.current, true );
|
9318 | }
|
9319 | }
|
9320 |
|
9321 |
|
9322 |
|
9323 | function ItemDisplayInfo( ng2item ) {
|
9324 |
|
9325 | var content = '<div class="nGY2PopupOneItem">' + ng2item.title + '</div>';
|
9326 | content += '<div class="nGY2PopupOneItemText">' + ng2item.description + '</div>';
|
9327 | if( ng2item.author != '' ) {
|
9328 | content += '<div class="nGY2PopupOneItemText">' + G.O.icons.user + ' ' + ng2item.author + '</div>';
|
9329 | }
|
9330 | if( ng2item.exif.model != '' ) {
|
9331 | content += '<div class="nGY2PopupOneItemText">' + G.O.icons.config + ' ' + ng2item.exif.model + '</div>';
|
9332 | }
|
9333 | var sexif = G.O.icons.picture + ':';
|
9334 | if( ng2item.exif.flash != '' || ng2item.exif.focallength != '' || ng2item.exif.fstop != '' || ng2item.exif.exposure != '' || ng2item.exif.iso != '' || ng2item.exif.time != '' ) {
|
9335 | sexif += '<br>';
|
9336 | sexif += ng2item.exif.flash == '' ? '' : ' ' + ng2item.exif.flash;
|
9337 | sexif += ng2item.exif.focallength == '' ? '' : ' ' + ng2item.exif.focallength+'mm';
|
9338 | sexif += ng2item.exif.fstop == '' ? '' : ' f' + ng2item.exif.fstop;
|
9339 | sexif += ng2item.exif.exposure == '' ? '' : ' ' + ng2item.exif.exposure+'s';
|
9340 | sexif += ng2item.exif.iso == '' ? '' : ' ' + ng2item.exif.iso+' ISO';
|
9341 | if( ng2item.exif.time != '' ) {
|
9342 |
|
9343 |
|
9344 | sexif += ' ' + ng2item.exif.time;
|
9345 | }
|
9346 | }
|
9347 | else {
|
9348 | sexif += ' n/a';
|
9349 | }
|
9350 | content += '<div class="nGY2PopupOneItemText">' + sexif + '</div>';
|
9351 |
|
9352 | if( ng2item.exif.location != '' ) {
|
9353 | content += '<div class="nGY2PopupOneItemText">'+G.O.icons.location+' <a href="http://maps.google.com/maps?z=12&t=m&q='+encodeURIComponent(ng2item.exif.location)+'" target="_blank">'+ng2item.exif.location+'</a></div>';
|
9354 |
|
9355 | content += '<iframe width="300" height="150" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?&t=m&q='+encodeURIComponent( ng2item.exif.location ) +'&output=embed"></iframe>';
|
9356 | }
|
9357 | else {
|
9358 | content += '<div class="nGY2PopupOneItemText">' + G.O.icons.location + ': n/a</div>';
|
9359 | }
|
9360 |
|
9361 | var r = { title: G.O.icons.viewerInfo, content: content };
|
9362 |
|
9363 |
|
9364 | var fu = G.O.fnPopupMediaInfo;
|
9365 | if( fu !== null ) {
|
9366 | typeof fu == 'function' ? r=fu(ng2item, r.title, r.content) : r=window[fu](ng2item, r.title, r.content);
|
9367 | }
|
9368 |
|
9369 |
|
9370 | Popup( r.title, r.content, 'Left');
|
9371 |
|
9372 | }
|
9373 |
|
9374 |
|
9375 |
|
9376 | function ToolbarAddElt( elt ) {
|
9377 | var r = '<div class="ngbt ngy2viewerToolAction ',
|
9378 | e=elt.replace(/^\s+|\s+$/g, '');
|
9379 | switch( e ) {
|
9380 | case 'minimizeButton':
|
9381 | case 'minimize':
|
9382 | var ic = G.O.icons.viewerToolbarMin;
|
9383 | if( G.VOM.toolbarMode == 'min' ) {
|
9384 | ic = G.O.icons.viewerToolbarStd;
|
9385 | }
|
9386 | r += 'minimizeButton nGEvent" data-ngy2action="minimize">'+ic+'</div>';
|
9387 | break;
|
9388 | case 'previousButton':
|
9389 | case 'previous':
|
9390 | r += 'previousButton nGEvent" data-ngy2action="previous">'+ G.O.icons.viewerPrevious +'</div>';
|
9391 | break;
|
9392 | case 'pageCounter':
|
9393 | r += 'pageCounter nGEvent"></div>';
|
9394 | break;
|
9395 | case 'nextButton':
|
9396 | case 'next':
|
9397 | r += 'nextButton nGEvent" data-ngy2action="next">'+ G.O.icons.viewerNext +'</div>';
|
9398 | break;
|
9399 | case 'playPauseButton':
|
9400 | case 'playPause':
|
9401 | r += 'playButton playPauseButton nGEvent" data-ngy2action="playPause">'+ G.O.icons.viewerPlay +'</div>';
|
9402 | break;
|
9403 | case 'rotateLeft':
|
9404 | r += 'rotateLeftButton nGEvent" data-ngy2action="rotateLeft">'+ G.O.icons.viewerRotateLeft +'</div>';
|
9405 | break;
|
9406 | case 'rotateRight':
|
9407 | r += 'rotateRightButton nGEvent" data-ngy2action="rotateRight">'+ G.O.icons.viewerRotateRight +'</div>';
|
9408 | break;
|
9409 | case 'downloadButton':
|
9410 | case 'download':
|
9411 | r += 'downloadButton nGEvent" data-ngy2action="download">'+ G.O.icons.viewerDownload +'</div>';
|
9412 | break;
|
9413 | case 'zoomButton':
|
9414 | case 'zoom':
|
9415 | r += 'nGEvent" data-ngy2action="zoomIn">'+ G.O.icons.viewerZoomIn +'</div><div class="ngbt ngy2viewerToolAction nGEvent" data-ngy2action="zoomOut">'+ G.O.icons.viewerZoomOut +'</div>';
|
9416 | break;
|
9417 | case 'fullscreenButton':
|
9418 | case 'fullscreen':
|
9419 | var s = G.O.icons.viewerFullscreenOn;
|
9420 | if( ngscreenfull.enabled && G.VOM.viewerIsFullscreen ) {
|
9421 | s = G.O.icons.viewerFullscreenOff;
|
9422 | }
|
9423 | r += 'setFullscreenButton fullscreenButton nGEvent" data-ngy2action="fullScreen">'+s+'</div>';
|
9424 | break;
|
9425 | case 'infoButton':
|
9426 | case 'info':
|
9427 | r += 'infoButton nGEvent" data-ngy2action="info">'+ G.O.icons.viewerInfo +'</div>';
|
9428 | break;
|
9429 | case 'linkOriginalButton':
|
9430 | case 'linkOriginal':
|
9431 | r += 'linkOriginalButton nGEvent" data-ngy2action="linkOriginal">' + G.O.icons.viewerLinkOriginal + '</div>';
|
9432 | break;
|
9433 | case 'closeButton':
|
9434 | case 'close':
|
9435 | r += 'closeButton nGEvent" data-ngy2action="close">'+ G.O.icons.buttonClose +'</div>';
|
9436 | break;
|
9437 | case 'shareButton':
|
9438 | case 'share':
|
9439 | r += 'nGEvent" data-ngy2action="share">'+ G.O.icons.viewerShare +'</div>';
|
9440 | break;
|
9441 | case 'label':
|
9442 | r += '"><div class="label"><div class="title nGEvent" itemprop="name"></div><div class="description nGEvent" itemprop="description"></div></div></div>';
|
9443 | break;
|
9444 | case 'shoppingcart':
|
9445 | r += 'closeButton nGEvent" data-ngy2action="shoppingcart">'+ G.O.icons.viewerShoppingcart +'</div>';
|
9446 | break;
|
9447 | default:
|
9448 |
|
9449 | if( e.indexOf('custom') == 0 ) {
|
9450 | var t = '';
|
9451 |
|
9452 | var fu = G.O.fnImgToolbarCustInit;
|
9453 | if( fu !== null ) {
|
9454 | typeof fu == 'function' ? fu(e) : window[fu](e);
|
9455 | }
|
9456 | if( t == undefined || t == '' ) {
|
9457 |
|
9458 | var n = e.substring(6);
|
9459 | t = G.O.icons['viewerCustomTool'+n];
|
9460 | }
|
9461 | r += 'ngy2CustomBtn ' + e + ' nGEvent" data-ngy2action="' + e + '">' + t + '</div>';
|
9462 | }
|
9463 | else {
|
9464 | r = '';
|
9465 | }
|
9466 | break;
|
9467 | }
|
9468 | return r;
|
9469 | }
|
9470 |
|
9471 |
|
9472 |
|
9473 | function SlideshowToggle(){
|
9474 | if( G.VOM.playSlideshow ) {
|
9475 | window.clearTimeout(G.VOM.playSlideshowTimerID);
|
9476 | G.VOM.playSlideshow = false;
|
9477 | G.VOM.$viewer.find('.playPauseButton').html(G.O.icons.viewerPlay);
|
9478 | }
|
9479 | else {
|
9480 | G.VOM.playSlideshow = true;
|
9481 | DisplayNextMedia();
|
9482 | G.VOM.$viewer.find('.playPauseButton').html(G.O.icons.viewerPause);
|
9483 | }
|
9484 | }
|
9485 |
|
9486 | function ViewerToolbarForVisibilityStd() {
|
9487 | G.VOM.toolbarMode = 'std';
|
9488 |
|
9489 | var sTB = '';
|
9490 | var t = G.O.viewerToolbar.standard.split(',');
|
9491 | for( var i = 0, lt = t.length; i < lt; i++) {
|
9492 | sTB += ToolbarAddElt( t[i] );
|
9493 | }
|
9494 | G.VOM.$toolbar.find('.toolbar').html(sTB);
|
9495 | ViewerToolbarElementContent();
|
9496 | }
|
9497 |
|
9498 | function ViewerToolbarForVisibilityMin() {
|
9499 | if( G.O.viewerToolbar.minimized == undefined || G.O.viewerToolbar.minimized == '' ) {
|
9500 | ViewerToolbarForVisibilityStd();
|
9501 | }
|
9502 | else {
|
9503 | G.VOM.toolbarMode = 'min';
|
9504 | var sTB = '';
|
9505 | var t = G.O.viewerToolbar.minimized.split(',');
|
9506 | for( var i = 0, lt = t.length; i < lt; i++) {
|
9507 | sTB += ToolbarAddElt( t[i] );
|
9508 | }
|
9509 | G.VOM.$toolbar.find('.toolbar').html(sTB);
|
9510 | ViewerToolbarElementContent();
|
9511 | }
|
9512 | }
|
9513 |
|
9514 | function ViewerToolbarElementContent() {
|
9515 |
|
9516 | var vomIdx = G.VOM.content.current.vIdx;
|
9517 | if( vomIdx == null ) { return; }
|
9518 |
|
9519 | var item = G.VOM.content.current.NGY2Item();
|
9520 |
|
9521 |
|
9522 | var setTxt = false;
|
9523 |
|
9524 | if( item.title !== undefined && item.title != '' ) {
|
9525 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.title').html(item.title);
|
9526 | setTxt = true;
|
9527 | }
|
9528 | else {
|
9529 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.title').html('');
|
9530 | }
|
9531 |
|
9532 | if( item.description !== undefined && item.description != '' ) {
|
9533 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.description').html(item.description);
|
9534 | setTxt = true;
|
9535 | }
|
9536 | else {
|
9537 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.description').html('');
|
9538 | }
|
9539 |
|
9540 | if( setTxt ) {
|
9541 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.label').show();
|
9542 | }
|
9543 | else {
|
9544 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.label').hide();
|
9545 | }
|
9546 |
|
9547 |
|
9548 | var viewerMaxImages = G.VOM.items.length;
|
9549 | if( viewerMaxImages > 0 ) {
|
9550 | G.VOM.$viewer.find('.pageCounter').html((G.VOM.items[vomIdx].mediaNumber)+'/'+viewerMaxImages);
|
9551 | }
|
9552 |
|
9553 |
|
9554 | var $cu = G.VOM.$viewer.find('.ngy2CustomBtn');
|
9555 | var fu = G.O.fnImgToolbarCustDisplay;
|
9556 | if( $cu.length > 0 && fu !== null ) {
|
9557 | typeof fu == 'function' ? fu($cu, item) : window[fu]($cu, item);
|
9558 | }
|
9559 |
|
9560 |
|
9561 | ViewerToolsOn();
|
9562 | }
|
9563 |
|
9564 |
|
9565 | function ViewerMediaPanX( posX ) {
|
9566 | G.VOM.swipePosX = posX;
|
9567 | if( G.CSStransformName == null ) {
|
9568 |
|
9569 |
|
9570 | }
|
9571 | else {
|
9572 |
|
9573 |
|
9574 |
|
9575 | G.VOM.content.current.$media[0].style[G.CSStransformName] = 'translate(' + posX + 'px, 0px)';
|
9576 |
|
9577 |
|
9578 | var itemPrevious = G.VOM.content.previous.NGY2Item();
|
9579 | var itemNext = G.VOM.content.next.NGY2Item();
|
9580 |
|
9581 |
|
9582 | if( G.O.imageTransition.startsWith('SWIPE') ) {
|
9583 | if( itemPrevious.mediaTransition() ) {
|
9584 | ViewerSetMediaVisibility(G.VOM.content.previous, 1);
|
9585 | }
|
9586 | if( itemNext.mediaTransition() ) {
|
9587 | ViewerSetMediaVisibility(G.VOM.content.next, 1);
|
9588 | }
|
9589 |
|
9590 | var sc = Math.min( Math.max( Math.abs(posX) / G.VOM.window.lastWidth, .8), 1);
|
9591 | if( G.O.imageTransition == 'SWIPE' ) { sc = 1; }
|
9592 |
|
9593 | if( posX > 0 ) {
|
9594 | let dir = G.VOM.window.lastWidth;
|
9595 | if( itemPrevious.mediaTransition() ) {
|
9596 |
|
9597 | G.VOM.content.previous.$media[0].style[G.CSStransformName] = 'translate(' + (-dir + posX) + 'px, 0px) scale(' + sc + ')';
|
9598 |
|
9599 | }
|
9600 | if( itemNext.mediaTransition() ) {
|
9601 |
|
9602 | G.VOM.content.next.$media[0].style[G.CSStransformName] = 'translate(' + (dir) + 'px, 0px) scale(' + sc + ')';
|
9603 |
|
9604 | }
|
9605 | }
|
9606 | else {
|
9607 | let dir = -G.VOM.window.lastWidth;
|
9608 | if( itemNext.mediaTransition() ) {
|
9609 |
|
9610 | G.VOM.content.next.$media[0].style[G.CSStransformName] = 'translate(' + (-dir + posX) + 'px, 0px) scale(' + sc + ')';
|
9611 |
|
9612 | }
|
9613 | if( itemPrevious.mediaTransition() ) {
|
9614 |
|
9615 | G.VOM.content.previous.$media[0].style[G.CSStransformName] = 'translate(' + (dir) + 'px, 0px) scale(' + sc + ')';
|
9616 |
|
9617 | }
|
9618 | }
|
9619 | }
|
9620 |
|
9621 |
|
9622 | if( G.O.imageTransition == 'SLIDEAPPEAR' ) {
|
9623 | G.VOM.content.previous.$media[0].style[G.CSStransformName] = '';
|
9624 | G.VOM.content.next.$media[0].style[G.CSStransformName] = '';
|
9625 | if( posX < 0 ) {
|
9626 | let o = (-posX) / G.VOM.window.lastWidth;
|
9627 | if( itemNext.mediaTransition() ) {
|
9628 | ViewerSetMediaVisibility(G.VOM.content.next, o);
|
9629 | }
|
9630 | if( itemPrevious.mediaTransition() ) {
|
9631 | ViewerSetMediaVisibility(G.VOM.content.previous, 0);
|
9632 | }
|
9633 | }
|
9634 | else {
|
9635 | let o = posX / G.VOM.window.lastWidth;
|
9636 | if( itemPrevious.mediaTransition() ) {
|
9637 | ViewerSetMediaVisibility(G.VOM.content.previous, o);
|
9638 | }
|
9639 | if( itemNext.mediaTransition() ) {
|
9640 | ViewerSetMediaVisibility(G.VOM.content.next, 0);
|
9641 | }
|
9642 | }
|
9643 | }
|
9644 | }
|
9645 | }
|
9646 |
|
9647 |
|
9648 | function DisplayNextMedia( velocity ) {
|
9649 | velocity = velocity || 0;
|
9650 |
|
9651 | if( G.VOM.viewerMediaIsChanged || ((new Date().getTime()) - G.VOM.timeImgChanged < 300) ) { return; }
|
9652 |
|
9653 | TriggerCustomEvent('lightboxNextImage');
|
9654 | LightboxDisplay('nextImage', velocity);
|
9655 | };
|
9656 |
|
9657 |
|
9658 | function DisplayPreviousMedia( velocity ) {
|
9659 | velocity = velocity || 0;
|
9660 |
|
9661 | if( G.VOM.viewerMediaIsChanged || ((new Date().getTime()) - G.VOM.timeImgChanged < 300) ) { return; }
|
9662 | if( G.VOM.playSlideshow ) {
|
9663 | SlideshowToggle();
|
9664 | }
|
9665 |
|
9666 | TriggerCustomEvent('lightboxPreviousImage');
|
9667 | LightboxDisplay( 'previousImage', velocity);
|
9668 | };
|
9669 |
|
9670 |
|
9671 |
|
9672 |
|
9673 | function LightboxDisplay( displayType, velocity ) {
|
9674 |
|
9675 | velocity = velocity || 0;
|
9676 |
|
9677 | if( G.O.debugMode && console.timeline ) { console.timeline('nanogallery2_viewer'); }
|
9678 |
|
9679 | if( G.VOM.playSlideshow ) { window.clearTimeout( G.VOM.playSlideshowTimerID ); }
|
9680 |
|
9681 | var current_content_item = null;
|
9682 | var new_content_item = null;
|
9683 |
|
9684 | G.VOM.timeImgChanged = new Date().getTime();
|
9685 | G.VOM.viewerMediaIsChanged = true;
|
9686 | G.VOM.zoom.isZooming = false;
|
9687 | ResizeLightbox(true);
|
9688 |
|
9689 | switch( displayType ) {
|
9690 | case '':
|
9691 | current_content_item = G.VOM.content.current;
|
9692 | new_content_item = G.VOM.content.current;
|
9693 | break;
|
9694 | case 'previousImage':
|
9695 | current_content_item = G.VOM.content.current;
|
9696 | new_content_item = G.VOM.content.previous;
|
9697 | break;
|
9698 | default:
|
9699 | current_content_item = G.VOM.content.current;
|
9700 | new_content_item = G.VOM.content.next;
|
9701 | }
|
9702 |
|
9703 |
|
9704 | SetLocationHash( new_content_item.NGY2Item().albumID, new_content_item.NGY2Item().GetID() );
|
9705 |
|
9706 | if( displayType == '' ) {
|
9707 |
|
9708 | return;
|
9709 | }
|
9710 |
|
9711 |
|
9712 | var vP = G.GOM.cache.viewport;
|
9713 | var t_easing = '';
|
9714 | var t_dur = 500 * (vP.w - Math.abs(G.VOM.swipePosX)) / vP.w;
|
9715 | if( velocity > 0 ) {
|
9716 |
|
9717 | t_dur = Math.min( (vP.w - Math.abs(G.VOM.swipePosX)) / velocity, t_dur);
|
9718 | t_easing = 'linear';
|
9719 | }
|
9720 |
|
9721 |
|
9722 |
|
9723 |
|
9724 | if( G.CSStransformName == null ) {
|
9725 |
|
9726 | ViewerSetMediaVisibility(new_content_item, 1);
|
9727 | ViewerSetMediaVisibility(current_content_item, 1);
|
9728 | LightboxDisplayFinalize(displayType);
|
9729 | }
|
9730 | else {
|
9731 | switch( G.O.imageTransition ) {
|
9732 | case 'SWIPE':
|
9733 | case 'SWIPE2':
|
9734 | var dir = ( displayType == 'nextImage' ? - vP.w : vP.w );
|
9735 | new_content_item.$media[0].style[G.CSStransformName] = 'translate(' + (-dir) + 'px, 0px) '
|
9736 |
|
9737 | if( velocity == 0 ) {
|
9738 | t_easing = G.O.imageTransition == 'swipe' ? 'easeInOutSine' : 'easeOutCubic';
|
9739 | }
|
9740 |
|
9741 | ViewerSetMediaVisibility(G.VOM.content.current, 1);
|
9742 | G.VOM.content.current.$media[0].style[G.CSStransformName] = 'translate(0px, 0px)';
|
9743 | ViewerSetMediaVisibility(new_content_item, 1);
|
9744 |
|
9745 | new NGTweenable().tween({
|
9746 | from: { t: G.VOM.swipePosX },
|
9747 | to: { t: (displayType == 'nextImage' ? - vP.w : vP.w) },
|
9748 | attachment: { dT: displayType, new_content_item: new_content_item, dir: dir, media_transition: new_content_item.NGY2Item().mediaTransition()},
|
9749 |
|
9750 | duration: t_dur,
|
9751 | easing: ( t_easing ),
|
9752 | step: function (state, att) {
|
9753 |
|
9754 | G.VOM.content.current.$media[0].style[G.CSStransformName] = 'translate(' + state.t + 'px, 0px)';
|
9755 |
|
9756 |
|
9757 | if( att.media_transition ) {
|
9758 |
|
9759 | var sc = Math.min( Math.max( (Math.abs(state.t)) / G.VOM.window.lastWidth, .8), 1);
|
9760 | if( G.O.imageTransition == 'SWIPE' ) { sc = 1; }
|
9761 | att.new_content_item.$media[0].style[G.CSStransformName] = 'translate(' + (-att.dir+state.t) + 'px, 0px) scale(' + sc + ')';
|
9762 | }
|
9763 | },
|
9764 | finish: function (state, att) {
|
9765 | G.VOM.content.current.$media[0].style[G.CSStransformName] = '';
|
9766 | ViewerSetMediaVisibility(G.VOM.content.current, 0);
|
9767 | att.new_content_item.$media[0].style[G.CSStransformName] = '';
|
9768 | LightboxDisplayFinalize(att.dT);
|
9769 | }
|
9770 | });
|
9771 | break;
|
9772 |
|
9773 | case 'SLIDEAPPEAR':
|
9774 | default:
|
9775 |
|
9776 | var op = (Math.abs(G.VOM.swipePosX)) / G.VOM.window.lastWidth;
|
9777 | new_content_item.$media[0].style[G.CSStransformName] = '';
|
9778 | if( velocity == 0 ) {
|
9779 | t_easing ='easeInOutSine';
|
9780 | }
|
9781 | new NGTweenable().tween({
|
9782 | from: { o: op, t: G.VOM.swipePosX },
|
9783 | to: { o: 1, t: (displayType == 'nextImage' ? - vP.w : vP.w) },
|
9784 | attachment: { dT: displayType, new_content_item:new_content_item, media_transition: new_content_item.NGY2Item().mediaTransition() },
|
9785 | delay: 30,
|
9786 | duration: t_dur,
|
9787 | easing: t_easing,
|
9788 | step: function (state, att) {
|
9789 |
|
9790 | G.VOM.content.current.$media[0].style[G.CSStransformName]= 'translate('+state.t+'px, 0px)';
|
9791 |
|
9792 |
|
9793 | if( att.media_transition ) {
|
9794 |
|
9795 | ViewerSetMediaVisibility(att.new_content_item, state.o);
|
9796 | }
|
9797 | },
|
9798 | finish: function (state, att) {
|
9799 | G.VOM.content.current.$media[0].style[G.CSStransformName]= '';
|
9800 | LightboxDisplayFinalize(att.dT);
|
9801 | }
|
9802 | });
|
9803 | break;
|
9804 | }
|
9805 | }
|
9806 |
|
9807 | }
|
9808 |
|
9809 |
|
9810 | function LightboxDisplayFinalize( displayType ) {
|
9811 |
|
9812 | var newVomIdx = 0;
|
9813 | switch( displayType ) {
|
9814 | case '':
|
9815 |
|
9816 | newVomIdx = G.VOM.content.current.vIdx;
|
9817 | break;
|
9818 | case 'previousImage':
|
9819 |
|
9820 | newVomIdx = G.VOM.content.previous.vIdx;
|
9821 | break;
|
9822 | default:
|
9823 |
|
9824 | newVomIdx = G.VOM.content.next.vIdx;
|
9825 | }
|
9826 |
|
9827 |
|
9828 |
|
9829 | G.VOM.content.current.vIdx = newVomIdx;
|
9830 | G.VOM.content.next.vIdx = G.VOM.IdxNext();
|
9831 | G.VOM.content.previous.vIdx = G.VOM.IdxPrevious();
|
9832 | G.VOM.gallery.Resize();
|
9833 | G.VOM.gallery.SetThumbnailActive();
|
9834 |
|
9835 | var ngy2item = G.VOM.content.current.NGY2Item();
|
9836 |
|
9837 | ViewerToolbarElementContent();
|
9838 | if( G.O.debugMode && console.timeline ) { console.timelineEnd('nanogallery2_viewer'); }
|
9839 |
|
9840 | var fu=G.O.fnImgDisplayed;
|
9841 | if( fu !== null ) {
|
9842 | typeof fu == 'function' ? fu(ngy2item) : window[fu](ngy2item);
|
9843 | }
|
9844 |
|
9845 | G.VOM.swipePosX = 0;
|
9846 | if( displayType != '' ) {
|
9847 |
|
9848 | G.VOM.content.current.$media.removeClass('imgCurrent');
|
9849 |
|
9850 | var $tmp = G.VOM.content.current.$media;
|
9851 | switch( displayType ) {
|
9852 | case 'nextImage':
|
9853 | G.VOM.content.current.$media = G.VOM.content.next.$media;
|
9854 | G.VOM.content.next.$media = $tmp;
|
9855 | break;
|
9856 | case 'previousImage':
|
9857 | G.VOM.content.current.$media = G.VOM.content.previous.$media;
|
9858 | G.VOM.content.previous.$media = $tmp;
|
9859 | break;
|
9860 | }
|
9861 | }
|
9862 |
|
9863 | G.VOM.content.current.$media.addClass('imgCurrent');
|
9864 |
|
9865 |
|
9866 | var $pans = G.VOM.$content.find('.nGY2ViewerMediaPan');
|
9867 | G.VOM.content.current.$media.insertAfter($pans.last());
|
9868 |
|
9869 | if( ngy2item.mediaKind == 'img' && ngy2item.imageWidth == 0 ) {
|
9870 | ViewerSetMediaVisibility(G.VOM.content.current, 0);
|
9871 | }
|
9872 | else {
|
9873 | G.VOM.content.current.$media.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9874 | ViewerSetMediaVisibility(G.VOM.content.current, 1);
|
9875 | }
|
9876 |
|
9877 |
|
9878 |
|
9879 | G.VOM.content.next.$media.empty();
|
9880 | var nextItem = G.VOM.content.next.NGY2Item();
|
9881 | var spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
9882 | if( nextItem.mediaKind == 'img' && nextItem.imageWidth != 0 && nextItem.imageHeight != 0 ) {
|
9883 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
9884 | }
|
9885 | G.VOM.content.next.$media.append( spreloader + nextItem.mediaMarkup );
|
9886 | ViewerSetMediaVisibility(G.VOM.content.next, 0);
|
9887 | ViewerSetMediaVisibility(G.VOM.content.previous, 0);
|
9888 | if( nextItem.mediaKind == 'img' ) {
|
9889 | G.VOM.ImageLoader.loadImage(VieweImgSizeRetrieved, nextItem);
|
9890 | }
|
9891 | else {
|
9892 | ViewerMediaCenterNotImg( G.VOM.content.next.$media );
|
9893 | }
|
9894 |
|
9895 |
|
9896 | G.VOM.content.previous.$media.empty();
|
9897 | var previousItem = G.VOM.content.previous.NGY2Item();
|
9898 | spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
9899 | if( previousItem.mediaKind == 'img' && previousItem.imageWidth != 0 && previousItem.imageHeight != 0 ) {
|
9900 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
9901 | }
|
9902 | G.VOM.content.previous.$media.append( spreloader + previousItem.mediaMarkup );
|
9903 | ViewerSetMediaVisibility(G.VOM.content.previous, 0);
|
9904 | ViewerSetMediaVisibility(G.VOM.content.next, 0);
|
9905 | if( previousItem.mediaKind == 'img' ) {
|
9906 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, previousItem );
|
9907 | }
|
9908 | else {
|
9909 | ViewerMediaCenterNotImg( G.VOM.content.previous.$media );
|
9910 | }
|
9911 |
|
9912 |
|
9913 |
|
9914 | if( G.VOM.playSlideshow ) {
|
9915 | G.VOM.content.current.$media.children().eq(1).ngimagesLoaded().always( function( instance ) {
|
9916 | if( G.VOM.playSlideshow ) {
|
9917 |
|
9918 | G.VOM.playSlideshowTimerID = window.setTimeout( function(){ DisplayNextMedia(); }, G.VOM.slideshowDelay );
|
9919 | }
|
9920 | });
|
9921 | }
|
9922 |
|
9923 |
|
9924 |
|
9925 |
|
9926 |
|
9927 |
|
9928 |
|
9929 |
|
9930 |
|
9931 |
|
9932 | ResizeLightbox();
|
9933 |
|
9934 | G.VOM.viewerMediaIsChanged = false;
|
9935 | TriggerCustomEvent('lightboxImageDisplayed');
|
9936 |
|
9937 | }
|
9938 |
|
9939 |
|
9940 |
|
9941 | function VieweImgSizeRetrieved(w, h, item, n) {
|
9942 |
|
9943 | item.imageWidth = w;
|
9944 | item.imageHeight = h;
|
9945 |
|
9946 |
|
9947 | if( G.VOM.content.current.NGY2Item() == item ) {
|
9948 |
|
9949 | G.VOM.content.current.$media.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9950 | ViewerSetMediaVisibility(G.VOM.content.current, 1);
|
9951 | G.VOM.zoom.userFactor = 1;
|
9952 | }
|
9953 |
|
9954 | if( G.VOM.content.next.NGY2Item() == item ) {
|
9955 | G.VOM.content.next.$media.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9956 | }
|
9957 | if( G.VOM.content.previous.NGY2Item() == item ) {
|
9958 | G.VOM.content.previous.$media.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9959 | }
|
9960 |
|
9961 | ViewerMediaSetPosAndZoom();
|
9962 |
|
9963 | }
|
9964 |
|
9965 |
|
9966 |
|
9967 | function ViewerSetMediaVisibility( content_item, opacity ) {
|
9968 |
|
9969 | var item = content_item.NGY2Item();
|
9970 | var $media = content_item.$media;
|
9971 |
|
9972 | if( item.mediaKind == 'img' && item.imageWidth == 0 ) {
|
9973 |
|
9974 |
|
9975 |
|
9976 | $media.children().eq(1).css({ opacity: 0, visibility: 'hidden' });
|
9977 |
|
9978 | return;
|
9979 | }
|
9980 |
|
9981 | if( opacity == 0 ) {
|
9982 |
|
9983 |
|
9984 | $media.children().css({ opacity: 0, visibility: 'hidden' });
|
9985 | }
|
9986 | else {
|
9987 |
|
9988 | $media.children().css({ opacity: opacity, visibility: 'visible' });
|
9989 | }
|
9990 | }
|
9991 |
|
9992 |
|
9993 |
|
9994 | function LightboxClose( vomIdx ) {
|
9995 |
|
9996 |
|
9997 | if( vomIdx == undefined ) {
|
9998 | vomIdx = G.VOM.content.current.vIdx;
|
9999 | }
|
10000 |
|
10001 | G.VOM.viewerMediaIsChanged = false;
|
10002 |
|
10003 | if( G.VOM.viewerDisplayed ) {
|
10004 |
|
10005 |
|
10006 | jQuery("body").removeClass("nGY2_body_scrollbar");
|
10007 | jQuery("#nGY2_body_scrollbar_style").remove();
|
10008 |
|
10009 | if( G.VOM.playSlideshow ) {
|
10010 | window.clearTimeout( G.VOM.playSlideshowTimerID );
|
10011 | G.VOM.playSlideshow = false;
|
10012 | }
|
10013 |
|
10014 | G.VOM.hammertime.destroy();
|
10015 | G.VOM.hammertime = null;
|
10016 |
|
10017 | if( ngscreenfull.enabled && G.VOM.viewerIsFullscreen ) {
|
10018 | G.VOM.viewerIsFullscreen = false;
|
10019 | ngscreenfull.exit();
|
10020 | }
|
10021 |
|
10022 |
|
10023 |
|
10024 | jQuery('.nGY2ViewerContainer').remove();
|
10025 | G.VOM.$baseCont = null;
|
10026 | G.VOM.viewerDisplayed = false;
|
10027 |
|
10028 | if( G.O.lightboxStandalone ) { return; }
|
10029 |
|
10030 | if( G.O.thumbnailAlbumDisplayImage ) {
|
10031 |
|
10032 | if( vomIdx == null ) {
|
10033 |
|
10034 |
|
10035 | }
|
10036 | else {
|
10037 | var item = G.I[G.VOM.items[vomIdx].ngy2ItemIdx];
|
10038 | var parent = NGY2Item.Get(G, item.albumID);
|
10039 | if( G.GOM.albumIdx != parent.albumID ) {
|
10040 |
|
10041 | DisplayAlbum('-1', parent.albumID);
|
10042 | }
|
10043 | else {
|
10044 | GalleryResize();
|
10045 | SetLocationHash( '', '' );
|
10046 | ThumbnailHoverReInitAll();
|
10047 | }
|
10048 | }
|
10049 |
|
10050 | }
|
10051 | else {
|
10052 | if( vomIdx != null ) {
|
10053 | if( G.GOM.albumIdx == -1 ) {
|
10054 |
|
10055 | DisplayAlbum( '', G.I[G.VOM.items[vomIdx].ngy2ItemIdx].albumID );
|
10056 | }
|
10057 | else {
|
10058 | GalleryResize();
|
10059 | SetLocationHash( G.I[G.VOM.items[vomIdx].ngy2ItemIdx].albumID, '' );
|
10060 | ThumbnailHoverReInitAll();
|
10061 | }
|
10062 | }
|
10063 | }
|
10064 | G.VOM.timeImgChanged = new Date().getTime();
|
10065 | }
|
10066 | }
|
10067 |
|
10068 |
|
10069 |
|
10070 | function ResizeLightbox( forceUpdate ) {
|
10071 | forceUpdate = typeof forceUpdate !== 'undefined' ? forceUpdate : false;
|
10072 |
|
10073 | if( G.VOM.$toolbar === null ) { return; }
|
10074 |
|
10075 |
|
10076 |
|
10077 | var windowsW = G.VOM.$viewer.width();
|
10078 | var windowsH = G.VOM.$viewer.height();
|
10079 | var $elt = G.VOM.content.current.$media.children().eq(1);
|
10080 | if( $elt == null || G.VOM.content.current.vIdx == -1 ) { return; }
|
10081 |
|
10082 | if( !forceUpdate && G.VOM.window.lastWidth == windowsW && G.VOM.window.lastHeight == windowsH ) { return; }
|
10083 |
|
10084 | G.VOM.window.lastWidth = windowsW;
|
10085 | G.VOM.window.lastHeight = windowsH;
|
10086 |
|
10087 |
|
10088 |
|
10089 |
|
10090 |
|
10091 | var galleryHeight = 0;
|
10092 | var cBottom = 0;
|
10093 |
|
10094 | if( G.O.viewerGallery != 'none' ) {
|
10095 | galleryHeight = G.O.viewerGalleryTHeight + 10;
|
10096 | }
|
10097 | if( G.O.viewerGallery == 'bottom' ) {
|
10098 | cBottom = galleryHeight;
|
10099 | }
|
10100 |
|
10101 |
|
10102 | switch( G.O.viewerToolbar.position ) {
|
10103 | case 'top':
|
10104 | case 'topOverImage':
|
10105 | G.VOM.$content.css({height: windowsH, width: windowsW, top: 0 });
|
10106 | G.VOM.$toolbar.css({top: 0, bottom: ''});
|
10107 | break;
|
10108 |
|
10109 |
|
10110 |
|
10111 |
|
10112 |
|
10113 | case 'bottom':
|
10114 | case 'bottomOverImage':
|
10115 | default:
|
10116 | windowsH -= cBottom;
|
10117 | G.VOM.$content.css({height: windowsH, width: windowsW, bottom: -cBottom, top: 0 });
|
10118 | G.VOM.$toolbar.css({bottom: galleryHeight});
|
10119 | break;
|
10120 |
|
10121 |
|
10122 |
|
10123 |
|
10124 |
|
10125 |
|
10126 | }
|
10127 |
|
10128 |
|
10129 | if( !G.VOM.viewerMediaIsChanged && G.VOM.zoom.isZooming ) {
|
10130 | ViewerMediaSetPosAndZoom();
|
10131 | }
|
10132 | else {
|
10133 | if( !G.VOM.zoom.isZooming && ( G.VOM.zoom.userFactor != 0 || G.VOM.panPosX != 0 || G.VOM.panPosY != 0 || G.VOM.zoom.posX != 0 || G.VOM.zoom.posY != 0 )) {
|
10134 |
|
10135 | G.VOM.zoom.isZooming= true;
|
10136 | new NGTweenable().tween({
|
10137 | from: { userFactor: G.VOM.zoom.userFactor, panPosX: G.VOM.panPosX, panPosY: G.VOM.panPosY, zoomPosX: G.VOM.zoom.posX, zoomPosY: G.VOM.zoom.posY },
|
10138 | to: { userFactor: 1, panPosX: 0, panPosY: 0, zoomPosX: 0, zoomPosY: 0 },
|
10139 | easing: 'easeInOutSine',
|
10140 | delay: 0,
|
10141 | duration: 150,
|
10142 | step: function (state) {
|
10143 | G.VOM.zoom.userFactor = state.userFactor;
|
10144 | G.VOM.panPosX = state.panPosX;
|
10145 | G.VOM.panPosY = state.panPosY;
|
10146 | G.VOM.zoom.posX = state.zoomPosX;
|
10147 | G.VOM.zoom.posY = state.zoomPosY;
|
10148 | ViewerMediaSetPosAndZoom();
|
10149 | },
|
10150 | finish: function (state) {
|
10151 | G.VOM.zoom.isZooming=false;
|
10152 | }
|
10153 | });
|
10154 |
|
10155 | }
|
10156 | else {
|
10157 | G.VOM.zoom.userFactor = 1;
|
10158 | G.VOM.zoom.isZooming = false;
|
10159 | G.VOM.panPosX = 0;
|
10160 | G.VOM.panPosY = 0;
|
10161 | G.VOM.zoom.posX = 0;
|
10162 | G.VOM.zoom.posY = 0;
|
10163 | ViewerMediaSetPosAndZoom();
|
10164 | }
|
10165 | }
|
10166 | }
|
10167 |
|
10168 |
|
10169 |
|
10170 |
|
10171 | function getScrollableParent (node) {
|
10172 | const regex = /(auto|scroll)/;
|
10173 | const parents = (_node, ps) => {
|
10174 | if (_node.parentNode === null) { return ps; }
|
10175 | return parents(_node.parentNode, ps.concat([_node]));
|
10176 | };
|
10177 |
|
10178 | const style = (_node, prop) => getComputedStyle(_node, null).getPropertyValue(prop);
|
10179 | const overflow = _node => style(_node, 'overflow') + style(_node, 'overflow-y') + style(_node, 'overflow-x');
|
10180 | const scroll = _node => regex.test(overflow(_node));
|
10181 |
|
10182 | const scrollParent = (_node) => {
|
10183 | if (!(_node instanceof HTMLElement || _node instanceof SVGElement)) {
|
10184 | return undefined;
|
10185 | }
|
10186 |
|
10187 | const ps = parents(_node.parentNode, []);
|
10188 |
|
10189 | for (let i = 0; i < ps.length; i += 1) {
|
10190 | if( ps[i] === document.body ) {
|
10191 | return null;
|
10192 | }
|
10193 | if (scroll(ps[i])) {
|
10194 | return ps[i];
|
10195 | }
|
10196 | }
|
10197 |
|
10198 | return document.scrollingElement || document.documentElement;
|
10199 | };
|
10200 |
|
10201 | return scrollParent(node);
|
10202 | };
|
10203 |
|
10204 |
|
10205 |
|
10206 |
|
10207 |
|
10208 | function BuildSkeleton() {
|
10209 |
|
10210 |
|
10211 |
|
10212 |
|
10213 | var $elements = G.$E.base.children();
|
10214 | if( $elements.length > 0 ) {
|
10215 | G.O.$markup = $elements;
|
10216 | }
|
10217 |
|
10218 | if( !G.O.lightboxStandalone ) {
|
10219 | G.$E.base.text('');
|
10220 | G.$E.base.addClass('ngy2_container');
|
10221 |
|
10222 |
|
10223 |
|
10224 |
|
10225 |
|
10226 |
|
10227 |
|
10228 |
|
10229 | G.$E.base.addClass(G.O.theme)
|
10230 |
|
10231 | SetGalleryTheme();
|
10232 |
|
10233 |
|
10234 | if( G.O.thumbnailLabel.get('hideIcons') ) {
|
10235 | G.O.icons.thumbnailAlbum = '';
|
10236 | G.O.icons.thumbnailImage = '';
|
10237 | }
|
10238 |
|
10239 |
|
10240 | var styleNavigation="";
|
10241 | if( G.O.navigationFontSize != undefined && G.O.navigationFontSize != '' ) {
|
10242 | styleNavigation=' style="font-size:'+G.O.navigationFontSize+';"';
|
10243 | }
|
10244 | G.$E.conNavigationBar = jQuery('<div class="nGY2Navigationbar" '+styleNavigation+'></div>').appendTo(G.$E.base);
|
10245 |
|
10246 |
|
10247 | G.$E.conLoadingB = jQuery('<div class="nanoGalleryLBarOff"><div></div><div></div><div></div><div></div><div></div></div>').appendTo(G.$E.base);
|
10248 |
|
10249 |
|
10250 | G.$E.conTnParent = jQuery('<div class="nGY2Gallery"></div>').appendTo( G.$E.base );
|
10251 | G.$E.conTn = jQuery('<div class="nGY2GallerySub"></div>').appendTo( G.$E.conTnParent );
|
10252 |
|
10253 |
|
10254 | switch( G.O.thumbnailAlignment ) {
|
10255 | case 'left':
|
10256 | G.$E.conTnParent.css({'text-align':'left'});
|
10257 |
|
10258 | break;
|
10259 | case 'right':
|
10260 | G.$E.conTnParent.css({'text-align':'right'});
|
10261 |
|
10262 | break;
|
10263 | }
|
10264 |
|
10265 |
|
10266 | if( G.O.galleryBuildInit2 !== undefined ) {
|
10267 | var t1=G.O.galleryBuildInit2.split('|');
|
10268 | for( var i=0; i<t1.length; i++ ) {
|
10269 | var o1=t1[i].split('_');
|
10270 | if( o1.length == 2 ) {
|
10271 | G.$E.conTn.css(o1[0], o1[1]);
|
10272 | }
|
10273 | }
|
10274 | }
|
10275 |
|
10276 |
|
10277 | var effects=G.tn.hoverEffects.std.concat(G.tn.hoverEffects.level1);
|
10278 | for( var j=0; j<effects.length; j++) {
|
10279 | switch( effects[j].type ) {
|
10280 | case 'scale':
|
10281 | case 'rotateZ':
|
10282 | case 'rotateX':
|
10283 | case 'rotateY':
|
10284 | case 'translateX':
|
10285 | case 'translateY':
|
10286 |
|
10287 | if( effects[j].element == '.nGY2GThumbnail' ) {
|
10288 |
|
10289 | G.$E.base.css('overflow', 'visible');
|
10290 | G.$E.base.find('.nGY2GallerySub').css('overflow', 'visible');
|
10291 | G.$E.conTnParent.css('overflow', 'visible');
|
10292 | }
|
10293 | break;
|
10294 | }
|
10295 | }
|
10296 |
|
10297 |
|
10298 | G.$E.conTnBottom = jQuery('<div class="nGY2GalleryBottom" '+styleNavigation+'></div>').appendTo( G.$E.conTnParent );
|
10299 |
|
10300 |
|
10301 | if( G.O.portable ) {
|
10302 |
|
10303 |
|
10304 |
|
10305 | var logo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAYCAYAAACbU/80AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4QgDBCAWVVC/hwAABRxJREFUSMetll9oVFcexz/nnDvJRBmSzWTrmD9uNGZsHta0/qFIFQTxRcnCBgTFNlX0YR8W+1AK9lGwCBJYgn0KKr5136S4gpUQTR4caJRslcxYWV3iaphQapJJppO5957z60Mmk4mN1q75wg/OPefc+/v9vt/fueenKEFEqICqsNWAVNiCA7XwaS0iZeejo6OIiCltdIBdJXMLOYp5/PjxsoTVS5nr0mYDJIE/lObeBhaYAn4oJbboAwBvBedHJicnPx8YGGh/8eJF1dvKoJSShoYGf//+/Zl4PP4l8M2yIEoSLErx6c2bN6W1tXVRglWzLVu2SCqVEhE5LiI457SIoEREW2udMaZtcnLy+2QyWZ3L5XRHR4f+4MNdoBUahUJhcWilmZ/NE4ZhOQHn3LIi1lqjtS6vjY6O8uTJE9vc3MyDBw+mYrHYn0Uk63me8gCtlHLA7uHh4bW5XC7oePddPTQ8xHffDjM/PYe3thqMws35iAcHPj5ENBp9Yxmy2Sw7d+40z549C+7du9ewb9++D6y13wDaK+kE0DAzMyNKKbXtvfd5EfzM+Ef/4C+8x23+wzPm+IhtfMf3/Ksuyl+7u9FaY63l+vXrpFIpCoUCmzdvpquri9bWVoIgQClFIpFg48aNPH/+XE9NTQkQLTGmvEXKRERprZWIEIYhQRjQbN6hmUb+tCaPNnM055v40f3If7XBGMPT8af0fNLD0NDQsozPnDlDb28vx44dIwxDRARrLSKCKmUbiUQQkWWnoLJ20UpjFYAjVA6rBJTFV5ZIJIIfBBw4eICxsTHq6uo4dOgQ8XicgYEB7t69y/Hjx4nH43R1dVHB8q+w4hlXSmGd5edwmjCco5DLkZ+aJvTnyIdTrFmzhn9+/TVjY2M0NTVx+/Zt+vv7OXfuHKlUip6eHgBOnz6N7/vlYl0JKzIw78/T+sdGbn6yjf5ZS2HtJgIP+mcC5kySI1uSXPjqAlprTp06RWdnJ8ViEaUUVVVVnD9/nqtXr5LJZHj48CFbt279fQEEYUisZi2fXel9bWU750gmkwRBgNYaz/Ow1lJfX088Hmd2dpZcLvdaBl4pgQChH4B1iHU4a8E6Qj9ARGhpaUFrzeDgIJFIBGMM1lqMMWQyGSYmJohEIqxfv/7314CIoADtGTAaZTTaLI2VUhw+fBjnHBcvXuTy5cs45/A8j3Q6zcmTJ/F9n71799LW1rbgSOs3D+B1lBljcM7R3d3N0aNHKRQKnDhxgs7OTnbt2sX27dsZGRkhHo/T19e3+Kt/fQ1YawFwzolSCs/zUEqVtX1VcJcuXSKRSNDf3086nS6v79mzh76+Pjo6OigWi1RXV2OMWZC29PL8/PxSAL7vE41Gf4rFYkpEePToEb7vU1VVxW+ht7eXs2fPcv/+fQqFAps2baKlpaW8Xl1dTS6XY3x8HBFxtbW1BiiW4hAlInp8fNxt2LChPZvN/ru9vT2Sz+e93bt3qx07diwrzJWYcM5RU1NDNBots5bP53HOlS+kO3fuMDIy4hKJhKTT6ena2tqtxWJxoqamRr98HX9x7do1qaurExYaiXCVzK5bt04GBwdFRP728nVcWZAO+Hsmk/nsxo0bTTMzM5FXHZ83hYhQX1/vHzx48H9tbW1ngSsVvpYCmJ2dJRaLKRbapjpgOxB7K+9LmAbuAnOAnpiYcI2NjUsRLlo2myUMQ1M5t5rmnDO3bt1aNlfmd4W2XL/0/H8pUDF2rNCW/wLRuCkxx8V6wgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNy0wOC0wM1QwNDozMjoyMi0wNDowMO7mdkwAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTctMDgtMDNUMDQ6MzI6MjItMDQ6MDCfu87wAAAAAElFTkSuQmCC';
|
10306 | var st = "font-weight:bold !important;color: #FF0075 !important;font-size: 14px !important;text-transform: lowercase !important;cursor:pointer !important;text-align: center !important;Text-Shadow: #000000 1px 0px 0px, #000000 1px 1px 0px, #000000 1px -1px 0px, #000000 -1px 1px 0px, #000000 -1px 0px 0px, #000000 -1px -1px 0px, #000000 0px 1px 0px, #000000 0px -1px 0px !important;";
|
10307 | G.$E.ngy2i=jQuery('<div class="nGY2PortInfo"><a href="http://nano.gallery" target="_blank" title="nanogallery2 | easy photo gallery for your website" style="' + st + '"><img src="' + logo + '" style="height:32px !important;width:initial !important;box-shadow: none !important;vertical-align: middle !important;"/> nanogallery2</a></div>').appendTo(G.$E.base);
|
10308 |
|
10309 | G.$E.ngy2i.find('a').on({
|
10310 | mouseenter: function () {
|
10311 | jQuery(this).attr('style', st);
|
10312 | },
|
10313 | mouseleave: function () {
|
10314 | jQuery(this).attr('style', st);
|
10315 | }
|
10316 | });
|
10317 | }
|
10318 | }
|
10319 |
|
10320 |
|
10321 | G.$E.conConsole = jQuery('<div class="nGY2ConsoleParent"></div>').appendTo(G.$E.base);
|
10322 |
|
10323 |
|
10324 | i18n();
|
10325 |
|
10326 | if( !G.O.lightboxStandalone ) {
|
10327 |
|
10328 | ThumbnailDefCaches();
|
10329 |
|
10330 |
|
10331 |
|
10332 | switch( G.tn.opt.Get('displayTransition') ) {
|
10333 | case 'SCALEDOWN':
|
10334 | case 'RANDOMSCALE':
|
10335 | default:
|
10336 | G.$E.base.css('overflow', 'visible');
|
10337 | G.$E.conTnParent.css('overflow', 'visible');
|
10338 | G.$E.conTn.css('overflow', 'visible');
|
10339 | break;
|
10340 | }
|
10341 | }
|
10342 |
|
10343 | }
|
10344 |
|
10345 | function TriggerCustomEvent ( eventName ) {
|
10346 |
|
10347 | var eN = eventName + '.nanogallery2';
|
10348 | var event=null;
|
10349 | try {
|
10350 | event = new Event( eN );
|
10351 | } catch(e) {
|
10352 | event = document.createEvent('Event');
|
10353 | event.initEvent(eN, false, false);
|
10354 | }
|
10355 | G.$E.base.trigger(eN, event);
|
10356 | }
|
10357 |
|
10358 |
|
10359 |
|
10360 | function SetGlobalEvents() {
|
10361 |
|
10362 |
|
10363 | if( !G.O.lightboxStandalone ) {
|
10364 | G.$E.conTnParent.on({
|
10365 | mouseenter: GalleryMouseEnter,
|
10366 | mouseleave: GalleryMouseLeave
|
10367 | }, ".nGY2GThumbnail");
|
10368 |
|
10369 |
|
10370 | G.GOM.hammertime = new NGHammer( G.$E.conTn[0] );
|
10371 |
|
10372 |
|
10373 |
|
10374 |
|
10375 | G.GOM.hammertime.on('pan', function(ev) {
|
10376 | if( !G.VOM.viewerDisplayed ) {
|
10377 | if( G.O.paginationSwipe && G.layout.support.rows && G.galleryDisplayMode.Get() == 'PAGINATION' ) {
|
10378 | if( Math.abs(ev.deltaY) > G.GOM.panThreshold ) {
|
10379 | G.GOM.panYOnly = true;
|
10380 | }
|
10381 | if( !G.GOM.panYOnly ) {
|
10382 | G.$E.conTn.css( G.CSStransformName , 'translate('+(ev.deltaX)+'px,0px)');
|
10383 | }
|
10384 | }
|
10385 | }
|
10386 | });
|
10387 | G.GOM.hammertime.on('panend', function(ev) {
|
10388 | if( !G.VOM.viewerDisplayed ) {
|
10389 | if( G.O.paginationSwipe && G.layout.support.rows && G.galleryDisplayMode.Get() == 'PAGINATION' ) {
|
10390 | if( !G.GOM.panYOnly ) {
|
10391 | if( ev.deltaX > 50 ) {
|
10392 | paginationPreviousPage();
|
10393 | return;
|
10394 | }
|
10395 | if( ev.deltaX < -50 ) {
|
10396 | paginationNextPage();
|
10397 | return;
|
10398 | }
|
10399 | }
|
10400 | G.GOM.panYOnly = false;
|
10401 | G.$E.conTn.css( G.CSStransformName , 'translate(0px,0px)');
|
10402 |
|
10403 | }
|
10404 | }
|
10405 | });
|
10406 |
|
10407 | G.GOM.hammertime.on('tap', function(ev) {
|
10408 | if( !G.VOM.viewerDisplayed ) {
|
10409 | ev.srcEvent.stopPropagation();
|
10410 | ev.srcEvent.preventDefault();
|
10411 |
|
10412 | if( ev.pointerType == 'mouse') {
|
10413 | if( GalleryClicked(ev.srcEvent) == 'exit' ) { return; }
|
10414 | }
|
10415 | else {
|
10416 | var r = GalleryEventRetrieveElementl(ev.srcEvent, false);
|
10417 | if( r.GOMidx == -1 ) { return; }
|
10418 | if( r.action != 'NONE' && r.action != 'OPEN' ) {
|
10419 |
|
10420 | GalleryClicked(ev.srcEvent);
|
10421 | return;
|
10422 | }
|
10423 |
|
10424 | if( G.GOM.slider.hostIdx == r.GOMidx ) {
|
10425 |
|
10426 | ThumbnailHoverOutAll();
|
10427 | ThumbnailOpen(G.GOM.items[G.GOM.slider.currentIdx].thumbnailIdx, true);
|
10428 | return;
|
10429 | }
|
10430 |
|
10431 | if( (G.GOM.curNavLevel == 'l1' && G.O.touchAnimationL1 == false) || (G.GOM.curNavLevel == 'lN' && G.O.touchAnimation == false) ) {
|
10432 |
|
10433 | ThumbnailOpen(G.GOM.items[r.GOMidx].thumbnailIdx, true);
|
10434 | return;
|
10435 | }
|
10436 |
|
10437 | if( G.O.touchAutoOpenDelay > 0 ) {
|
10438 |
|
10439 | ThumbnailHoverOutAll();
|
10440 | ThumbnailHover( r.GOMidx );
|
10441 | window.clearInterval( G.touchAutoOpenDelayTimerID );
|
10442 | G.touchAutoOpenDelayTimerID = window.setInterval(function(){
|
10443 | window.clearInterval( G.touchAutoOpenDelayTimerID );
|
10444 | ThumbnailOpen( G.GOM.items[r.GOMidx].thumbnailIdx, true );
|
10445 | }, G.O.touchAutoOpenDelay );
|
10446 | }
|
10447 | else {
|
10448 |
|
10449 | if( !G.I[G.GOM.items[r.GOMidx].thumbnailIdx].hovered ) {
|
10450 | ThumbnailHoverOutAll();
|
10451 | ThumbnailHover(r.GOMidx);
|
10452 | }
|
10453 | else {
|
10454 |
|
10455 | ThumbnailOpen(G.GOM.items[r.GOMidx].thumbnailIdx, true);
|
10456 | }
|
10457 | }
|
10458 | }
|
10459 | }
|
10460 | });
|
10461 |
|
10462 |
|
10463 | if( G.O.locationHash ) {
|
10464 |
|
10465 |
|
10466 |
|
10467 | jQuery(window).on('hashchange.nanogallery2.' + G.baseEltID, function() {ProcessLocationHash();} );
|
10468 | }
|
10469 | }
|
10470 |
|
10471 |
|
10472 | jQuery(window).on('resize.nanogallery2.' + G.baseEltID + ' orientationChange.nanogallery2.' + G.baseEltID, debounce( ResizeWindowEvent, G.O.eventsDebounceDelay, false) );
|
10473 |
|
10474 |
|
10475 | jQuery(window).on('scroll.nanogallery2.' + G.baseEltID, debounce( OnScrollEvent, G.O.eventsDebounceDelay, false) );
|
10476 |
|
10477 | if( !G.O.lightboxStandalone ) {
|
10478 |
|
10479 | G.$E.scrollableParent = getScrollableParent( G.$E.base[0] );
|
10480 | var sp = getScrollableParent( G.$E.base[0] );
|
10481 | if( sp !== null ) {
|
10482 | G.$E.scrollableParent = jQuery( sp );
|
10483 | G.$E.scrollableParent.on('scroll.nanogallery2.' + G.baseEltID, debounce( OnScrollEvent, G.O.eventsDebounceDelay, false) );
|
10484 | }
|
10485 | }
|
10486 |
|
10487 |
|
10488 | G.VOM.toolsHide = debounce( ViewerToolsHide, G.O.viewerHideToolsDelay, false );
|
10489 |
|
10490 |
|
10491 | jQuery(document).keyup(function(e) {
|
10492 | if( G.popup.isDisplayed ) {
|
10493 | switch( e.keyCode) {
|
10494 | case 27:
|
10495 | G.popup.close();
|
10496 | break;
|
10497 | }
|
10498 | }
|
10499 | else {
|
10500 | if( G.VOM.viewerDisplayed ) {
|
10501 | ViewerToolsUnHide();
|
10502 | switch( e.keyCode) {
|
10503 | case 27:
|
10504 | case 40:
|
10505 | case 38:
|
10506 | LightboxClose();
|
10507 | break;
|
10508 | case 32:
|
10509 | case 13:
|
10510 | SlideshowToggle();
|
10511 | break;
|
10512 | case 39:
|
10513 | case 33:
|
10514 | DisplayNextMedia();
|
10515 | break;
|
10516 | case 37:
|
10517 | case 34:
|
10518 | DisplayPreviousMedia();
|
10519 | break;
|
10520 | case 35:
|
10521 | case 36:
|
10522 | }
|
10523 | }
|
10524 | }
|
10525 | });
|
10526 |
|
10527 |
|
10528 | jQuery(window).bind('mousewheel wheel', function(e){
|
10529 |
|
10530 | if( G.VOM.viewerDisplayed && G.VOM.content.current.NGY2Item().mediaKind == 'img' ) {
|
10531 |
|
10532 | var deltaY = 0;
|
10533 | e.preventDefault();
|
10534 |
|
10535 | if( ViewerZoomStart() ) {
|
10536 | if (e.originalEvent.deltaY) {
|
10537 | deltaY = e.originalEvent.deltaY;
|
10538 | } else if (e.originalEvent.wheelDelta) {
|
10539 | deltaY = -e.originalEvent.wheelDelta;
|
10540 | }
|
10541 | ViewerZoomIn( deltaY <= 0 ? true : false );
|
10542 | }
|
10543 | }
|
10544 | });
|
10545 |
|
10546 |
|
10547 | jQuery(window).bind('mousemove', function(e){
|
10548 | if( G.VOM.viewerDisplayed ) {
|
10549 | if( G.VOM.toolbarsDisplayed == false ) {
|
10550 | G.VOM.singletapTime = new Date().getTime();
|
10551 | debounce( ViewerToolsUnHide, 100, false )();
|
10552 | }
|
10553 | }
|
10554 | });
|
10555 |
|
10556 |
|
10557 | if( ngscreenfull.enabled ) {
|
10558 |
|
10559 | ngscreenfull.onchange( function() {
|
10560 | if( G.VOM.viewerDisplayed ) {
|
10561 | if( ngscreenfull.isFullscreen ) {
|
10562 | G.VOM.viewerIsFullscreen=true;
|
10563 | G.VOM.$viewer.find('.fullscreenButton').html(G.O.icons.viewerFullscreenOff);
|
10564 | }
|
10565 | else {
|
10566 | G.VOM.viewerIsFullscreen=false;
|
10567 | G.VOM.$viewer.find('.fullscreenButton').html(G.O.icons.viewerFullscreenOn);
|
10568 | }
|
10569 | }
|
10570 | });
|
10571 | }
|
10572 |
|
10573 | }
|
10574 |
|
10575 |
|
10576 |
|
10577 | function ProcessLocationHash() {
|
10578 |
|
10579 |
|
10580 | if( !G.O.locationHash ) { return false; }
|
10581 |
|
10582 | var curGal = '#nanogallery/' + G.baseEltID + '/',
|
10583 | newLocationHash = location.hash;
|
10584 | if( G.O.debugMode ) {
|
10585 | console.log('------------------------ PROCESS LOCATION HASH');
|
10586 | console.log('newLocationHash1: ' +newLocationHash);
|
10587 | console.log('G.locationHashLastUsed: ' +G.locationHashLastUsed);
|
10588 | }
|
10589 |
|
10590 | if( newLocationHash == '' ) {
|
10591 |
|
10592 | if( G.locationHashLastUsed !== '' ) {
|
10593 |
|
10594 | if( G.O.debugMode ) { console.log('display root album' ); }
|
10595 | G.locationHashLastUsed = '';
|
10596 | if( G.O.debugMode ) { console.log('new3 G.locationHashLastUsed: ' + G.locationHashLastUsed); }
|
10597 | DisplayAlbum('', '0');
|
10598 | return true;
|
10599 | }
|
10600 | }
|
10601 |
|
10602 | if( newLocationHash == G.locationHashLastUsed ) { return; }
|
10603 |
|
10604 | if( newLocationHash.indexOf(curGal) == 0 ) {
|
10605 |
|
10606 | var IDs=parseIDs( newLocationHash.substring(curGal.length) );
|
10607 | if( IDs.imageID != '0' ) {
|
10608 | if( G.O.debugMode ) { console.log('display image: ' + IDs.albumID +'-'+ IDs.imageID ); }
|
10609 | DisplayPhoto( IDs.imageID, IDs.albumID );
|
10610 | return true;
|
10611 | }
|
10612 | else {
|
10613 | if( G.O.debugMode ) { console.log('display album: ' + IDs.albumID ); }
|
10614 | DisplayAlbum( '-1', IDs.albumID );
|
10615 | return true;
|
10616 | }
|
10617 | }
|
10618 |
|
10619 | return false;
|
10620 | }
|
10621 |
|
10622 |
|
10623 | function SetLocationHash(albumID, imageID ) {
|
10624 | if( !G.O.locationHash || G.O.lightboxStandalone ) { return false; }
|
10625 |
|
10626 | if( G.O.debugMode ) {
|
10627 | console.log('------------------------ SET LOCATION HASH');
|
10628 | }
|
10629 |
|
10630 | if( imageID == '' && (albumID == '-1' || albumID == '0' || G.O.album == albumID ) ) {
|
10631 |
|
10632 | if( location.hash != '' ) {
|
10633 |
|
10634 | if ("pushState" in history) {
|
10635 | history.pushState("", document.title, window.location.pathname + window.location.search);
|
10636 | }
|
10637 | else {
|
10638 | location.hash='';
|
10639 | }
|
10640 | }
|
10641 | G.locationHashLastUsed='';
|
10642 | if( G.O.debugMode ) { console.log('new2 G.locationHashLastUsed: '+G.locationHashLastUsed); }
|
10643 | return;
|
10644 | }
|
10645 |
|
10646 | var newLocationHash='#'+'nanogallery/'+G.baseEltID+'/'+ albumID;
|
10647 | if( imageID != '' ) {
|
10648 | newLocationHash+='/'+imageID;
|
10649 | }
|
10650 |
|
10651 | var lH=location.hash;
|
10652 | if( G.O.debugMode ) {
|
10653 | console.log('newLocationHash2: '+newLocationHash);
|
10654 | console.log('location.hash: '+lH);
|
10655 | }
|
10656 |
|
10657 | G.locationHashLastUsed=newLocationHash;
|
10658 | if( G.O.debugMode ) { console.log('new G.locationHashLastUsed: '+G.locationHashLastUsed); }
|
10659 |
|
10660 | if( lH == '' || lH != newLocationHash ) {
|
10661 |
|
10662 | try {
|
10663 | top.location.hash=newLocationHash;
|
10664 | }
|
10665 | catch(e) {
|
10666 |
|
10667 | G.O.locationHash=false;
|
10668 | }
|
10669 | }
|
10670 | }
|
10671 |
|
10672 |
|
10673 |
|
10674 | function ResizeWindowEvent() {
|
10675 | CacheViewport();
|
10676 |
|
10677 | var l = G.GOM.curNavLevel;
|
10678 | var w = G.GOM.curWidth;
|
10679 |
|
10680 | if( G.VOM.viewerDisplayed ) {
|
10681 |
|
10682 | ResizeLightbox();
|
10683 | G.VOM.gallery.Resize();
|
10684 | }
|
10685 | else {
|
10686 |
|
10687 | if( G.galleryResizeEventEnabled ) {
|
10688 | var nw = RetrieveCurWidth();
|
10689 |
|
10690 | if( G.GOM.albumIdx != -1 ) {
|
10691 |
|
10692 |
|
10693 |
|
10694 | var s = G.tn.settings;
|
10695 | if( G.layout.engine == "MOSAIC") {
|
10696 |
|
10697 | if( JSON.stringify(s.mosaic[l][w]) !== JSON.stringify(s.mosaic[l][nw]) ) {
|
10698 |
|
10699 | G.GOM.curWidth = nw;
|
10700 | G.GOM.pagination.currentPage = 0;
|
10701 | GalleryRender( G.GOM.albumIdx );
|
10702 | return;
|
10703 | }
|
10704 | }
|
10705 | else {
|
10706 |
|
10707 | if( s.height[l][w] != s.height[l][nw] || s.width[l][w] != s.width[l][nw] || s.gutterHeight[l][w] != s.gutterHeight[l][nw] || s.gutterWidth[l][w] != s.gutterWidth[l][nw] ) {
|
10708 |
|
10709 | G.GOM.curWidth = nw;
|
10710 |
|
10711 | G.GOM.pagination.currentPage = 0;
|
10712 | GalleryRender( G.GOM.albumIdx );
|
10713 | return;
|
10714 | }
|
10715 | }
|
10716 |
|
10717 | }
|
10718 |
|
10719 | GalleryResize();
|
10720 |
|
10721 | }
|
10722 | }
|
10723 | }
|
10724 |
|
10725 |
|
10726 |
|
10727 |
|
10728 | function OnScrollEvent() {
|
10729 | if( !G.VOM.viewerDisplayed ) {
|
10730 | GalleryResizeOnScrollEvent();
|
10731 | }
|
10732 | }
|
10733 |
|
10734 |
|
10735 | function GalleryResizeOnScrollEvent() {
|
10736 | if( G.galleryResizeEventEnabled == false) {
|
10737 | window.setTimeout(GalleryResizeOnScrollEvent, 10);
|
10738 | } else {
|
10739 | GalleryResize();
|
10740 | }
|
10741 | }
|
10742 |
|
10743 |
|
10744 |
|
10745 |
|
10746 | function i18n() {
|
10747 |
|
10748 |
|
10749 | G.i18nLang = (navigator.language || navigator.userLanguage).toUpperCase();
|
10750 | if( G.i18nLang === 'UNDEFINED') { G.i18nLang=''; }
|
10751 |
|
10752 | var llang=-('_'+G.i18nLang).length;
|
10753 |
|
10754 | if( toType(G.O.i18n) == 'object' ){
|
10755 |
|
10756 | for( var key in G.O.i18n ) {
|
10757 |
|
10758 | var s=key.substr(llang);
|
10759 | if( s == ('_'+G.i18nLang) ) {
|
10760 | G.i18nTranslations[key.substr(0,key.length-s.length)]=G.O.i18n[key];
|
10761 | }
|
10762 | else {
|
10763 | G.i18nTranslations[key]=G.O.i18n[key];
|
10764 | }
|
10765 | }
|
10766 | }
|
10767 | }
|
10768 |
|
10769 | function GetI18nItem( item, property ) {
|
10770 | var s='';
|
10771 | if( G.i18nLang != '' ) {
|
10772 | if( item[property+'_'+G.i18nLang] !== undefined && item[property+'_'+G.i18nLang].length>0 ) {
|
10773 | s=item[property+'_'+G.i18nLang];
|
10774 | return s;
|
10775 | }
|
10776 | }
|
10777 | s=item[property];
|
10778 | return s;
|
10779 | }
|
10780 |
|
10781 |
|
10782 | function RetrieveCurWidth() {
|
10783 | var vpW = G.GOM.cache.viewport.w;
|
10784 |
|
10785 | if( G.O.breakpointSizeSM > 0 && vpW < G.O.breakpointSizeSM) { return 'xs'; }
|
10786 | if( G.O.breakpointSizeME > 0 && vpW < G.O.breakpointSizeME) { return 'sm'; }
|
10787 | if( G.O.breakpointSizeLA > 0 && vpW < G.O.breakpointSizeLA) { return 'me'; }
|
10788 | if( G.O.breakpointSizeXL > 0 && vpW < G.O.breakpointSizeXL) { return 'la'; }
|
10789 |
|
10790 | return 'xl';
|
10791 | }
|
10792 |
|
10793 |
|
10794 |
|
10795 | function browserNotification() {
|
10796 | var m = 'Your browser version is not supported anymore. The image gallery cannot be displayed. <br><br>Please update to a more recent one. Download:<br>';
|
10797 | m += ' <a href="http://www.google.com/chrome/?hl=en-US)">Chrome</a><br>';
|
10798 | m += ' <a href="http://www.mozilla.com/firefox/)">Firefox</a><br>';
|
10799 | m += ' <a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">Internet Explorer</a><br>';
|
10800 | m += ' <a href="http://www.apple.com/safari/download/">Safari</a>';
|
10801 | NanoAlert(G, m, false);
|
10802 | }
|
10803 |
|
10804 |
|
10805 | function FirstSupportedPropertyName(prefixedPropertyNames) {
|
10806 | var tempDiv = document.createElement("div");
|
10807 | for (var i = 0; i < prefixedPropertyNames.length; ++i) {
|
10808 | if (typeof tempDiv.style[prefixedPropertyNames[i]] != 'undefined')
|
10809 | return prefixedPropertyNames[i];
|
10810 | }
|
10811 | return null;
|
10812 | }
|
10813 |
|
10814 |
|
10815 |
|
10816 |
|
10817 | }
|
10818 |
|
10819 |
|
10820 |
|
10821 |
|
10822 |
|
10823 |
|
10824 |
|
10825 |
|
10826 |
|
10827 |
|
10828 |
|
10829 |
|
10830 |
|
10831 |
|
10832 |
|
10833 |
|
10834 |
|
10835 |
|
10836 |
|
10837 |
|
10838 |
|
10839 |
|
10840 |
|
10841 |
|
10842 |
|
10843 |
|
10844 |
|
10845 |
|
10846 |
|
10847 |
|
10848 |
|
10849 |
|
10850 | ( function( global, factory ) {
|
10851 |
|
10852 |
|
10853 |
|
10854 |
|
10855 |
|
10856 |
|
10857 |
|
10858 |
|
10859 |
|
10860 |
|
10861 | global.ngEvEmitter = factory();
|
10862 |
|
10863 |
|
10864 | }( typeof window != 'undefined' ? window : this, function() {
|
10865 |
|
10866 |
|
10867 |
|
10868 | function ngEvEmitter() {}
|
10869 |
|
10870 | var proto = ngEvEmitter.prototype;
|
10871 |
|
10872 | proto.on = function( eventName, listener ) {
|
10873 | if ( !eventName || !listener ) {
|
10874 | return;
|
10875 | }
|
10876 |
|
10877 | var events = this._events = this._events || {};
|
10878 |
|
10879 | var listeners = events[ eventName ] = events[ eventName ] || [];
|
10880 |
|
10881 | if ( listeners.indexOf( listener ) == -1 ) {
|
10882 | listeners.push( listener );
|
10883 | }
|
10884 |
|
10885 | return this;
|
10886 | };
|
10887 |
|
10888 | proto.once = function( eventName, listener ) {
|
10889 | if ( !eventName || !listener ) {
|
10890 | return;
|
10891 | }
|
10892 |
|
10893 | this.on( eventName, listener );
|
10894 |
|
10895 |
|
10896 | var onceEvents = this._onceEvents = this._onceEvents || {};
|
10897 |
|
10898 | var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
|
10899 |
|
10900 | onceListeners[ listener ] = true;
|
10901 |
|
10902 | return this;
|
10903 | };
|
10904 |
|
10905 | proto.off = function( eventName, listener ) {
|
10906 | var listeners = this._events && this._events[ eventName ];
|
10907 | if ( !listeners || !listeners.length ) {
|
10908 | return;
|
10909 | }
|
10910 | var index = listeners.indexOf( listener );
|
10911 | if ( index != -1 ) {
|
10912 | listeners.splice( index, 1 );
|
10913 | }
|
10914 |
|
10915 | return this;
|
10916 | };
|
10917 |
|
10918 | proto.emitEvent = function( eventName, args ) {
|
10919 | var listeners = this._events && this._events[ eventName ];
|
10920 | if ( !listeners || !listeners.length ) {
|
10921 | return;
|
10922 | }
|
10923 | var i = 0;
|
10924 | var listener = listeners[i];
|
10925 | args = args || [];
|
10926 |
|
10927 | var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
|
10928 |
|
10929 | while ( listener ) {
|
10930 | var isOnce = onceListeners && onceListeners[ listener ];
|
10931 | if ( isOnce ) {
|
10932 |
|
10933 |
|
10934 | this.off( eventName, listener );
|
10935 |
|
10936 | delete onceListeners[ listener ];
|
10937 | }
|
10938 |
|
10939 | listener.apply( this, args );
|
10940 |
|
10941 | i += isOnce ? 0 : 1;
|
10942 | listener = listeners[i];
|
10943 | }
|
10944 |
|
10945 | return this;
|
10946 | };
|
10947 |
|
10948 | return ngEvEmitter;
|
10949 |
|
10950 | }));
|
10951 |
|
10952 |
|
10953 |
|
10954 |
|
10955 |
|
10956 |
|
10957 |
|
10958 | ( function( window, factory ) { 'use strict';
|
10959 |
|
10960 |
|
10961 |
|
10962 |
|
10963 |
|
10964 |
|
10965 |
|
10966 |
|
10967 |
|
10968 |
|
10969 |
|
10970 |
|
10971 |
|
10972 |
|
10973 |
|
10974 |
|
10975 |
|
10976 |
|
10977 |
|
10978 | window.ngimagesLoaded = factory(
|
10979 | window,
|
10980 | window.ngEvEmitter
|
10981 | );
|
10982 |
|
10983 |
|
10984 | })( window,
|
10985 |
|
10986 |
|
10987 |
|
10988 | function factory( window, ngEvEmitter ) {
|
10989 |
|
10990 |
|
10991 |
|
10992 |
|
10993 | var $ = jQuery;
|
10994 | var console = window.console;
|
10995 |
|
10996 |
|
10997 |
|
10998 |
|
10999 | function extend( a, b ) {
|
11000 | for ( var prop in b ) {
|
11001 | a[ prop ] = b[ prop ];
|
11002 | }
|
11003 | return a;
|
11004 | }
|
11005 |
|
11006 |
|
11007 | function makeArray( obj ) {
|
11008 | var ary = [];
|
11009 | if ( Array.isArray( obj ) ) {
|
11010 |
|
11011 | ary = obj;
|
11012 | } else if ( typeof obj.length == 'number' ) {
|
11013 |
|
11014 | for ( var i=0; i < obj.length; i++ ) {
|
11015 | ary.push( obj[i] );
|
11016 | }
|
11017 | } else {
|
11018 |
|
11019 | ary.push( obj );
|
11020 | }
|
11021 | return ary;
|
11022 | }
|
11023 |
|
11024 |
|
11025 |
|
11026 |
|
11027 |
|
11028 |
|
11029 |
|
11030 |
|
11031 | function ngImagesLoaded( elem, options, onAlways ) {
|
11032 |
|
11033 | if ( !( this instanceof ngImagesLoaded ) ) {
|
11034 | return new ngImagesLoaded( elem, options, onAlways );
|
11035 | }
|
11036 |
|
11037 | if ( typeof elem == 'string' ) {
|
11038 | elem = document.querySelectorAll( elem );
|
11039 | }
|
11040 |
|
11041 | this.elements = makeArray( elem );
|
11042 | this.options = extend( {}, this.options );
|
11043 |
|
11044 | if ( typeof options == 'function' ) {
|
11045 | onAlways = options;
|
11046 | } else {
|
11047 | extend( this.options, options );
|
11048 | }
|
11049 |
|
11050 | if ( onAlways ) {
|
11051 | this.on( 'always', onAlways );
|
11052 | }
|
11053 |
|
11054 | this.getImages();
|
11055 |
|
11056 | if ( $ ) {
|
11057 |
|
11058 | this.jqDeferred = new $.Deferred();
|
11059 | }
|
11060 |
|
11061 |
|
11062 | setTimeout( function() {
|
11063 | this.check();
|
11064 | }.bind( this ));
|
11065 | }
|
11066 |
|
11067 | ngImagesLoaded.prototype = Object.create( ngEvEmitter.prototype );
|
11068 |
|
11069 | ngImagesLoaded.prototype.options = {};
|
11070 |
|
11071 | ngImagesLoaded.prototype.getImages = function() {
|
11072 | this.images = [];
|
11073 |
|
11074 |
|
11075 | this.elements.forEach( this.addElementImages, this );
|
11076 | };
|
11077 |
|
11078 |
|
11079 |
|
11080 |
|
11081 | ngImagesLoaded.prototype.addElementImages = function( elem ) {
|
11082 |
|
11083 | if ( elem.nodeName == 'IMG' ) {
|
11084 | this.addImage( elem );
|
11085 | }
|
11086 |
|
11087 | if ( this.options.background === true ) {
|
11088 | this.addElementBackgroundImages( elem );
|
11089 | }
|
11090 |
|
11091 |
|
11092 |
|
11093 | var nodeType = elem.nodeType;
|
11094 | if ( !nodeType || !elementNodeTypes[ nodeType ] ) {
|
11095 | return;
|
11096 | }
|
11097 | var childImgs = elem.querySelectorAll('img');
|
11098 |
|
11099 | for ( var i=0; i < childImgs.length; i++ ) {
|
11100 | var img = childImgs[i];
|
11101 | this.addImage( img );
|
11102 | }
|
11103 |
|
11104 |
|
11105 | if ( typeof this.options.background == 'string' ) {
|
11106 | var children = elem.querySelectorAll( this.options.background );
|
11107 | for ( i=0; i < children.length; i++ ) {
|
11108 | var child = children[i];
|
11109 | this.addElementBackgroundImages( child );
|
11110 | }
|
11111 | }
|
11112 | };
|
11113 |
|
11114 | var elementNodeTypes = {
|
11115 | 1: true,
|
11116 | 9: true,
|
11117 | 11: true
|
11118 | };
|
11119 |
|
11120 | ngImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
|
11121 | var style = getComputedStyle( elem );
|
11122 | if ( !style ) {
|
11123 |
|
11124 | return;
|
11125 | }
|
11126 |
|
11127 | var reURL = /url\((['"])?(.*?)\1\)/gi;
|
11128 | var matches = reURL.exec( style.backgroundImage );
|
11129 | while ( matches !== null ) {
|
11130 | var url = matches && matches[2];
|
11131 | if ( url ) {
|
11132 | this.addBackground( url, elem );
|
11133 | }
|
11134 | matches = reURL.exec( style.backgroundImage );
|
11135 | }
|
11136 | };
|
11137 |
|
11138 |
|
11139 |
|
11140 |
|
11141 | ngImagesLoaded.prototype.addImage = function( img ) {
|
11142 | var loadingImage = new LoadingImage( img );
|
11143 | this.images.push( loadingImage );
|
11144 | };
|
11145 |
|
11146 | ngImagesLoaded.prototype.addBackground = function( url, elem ) {
|
11147 | var background = new Background( url, elem );
|
11148 | this.images.push( background );
|
11149 | };
|
11150 |
|
11151 | ngImagesLoaded.prototype.check = function() {
|
11152 | var _this = this;
|
11153 | this.progressedCount = 0;
|
11154 | this.hasAnyBroken = false;
|
11155 |
|
11156 | if ( !this.images.length ) {
|
11157 | this.complete();
|
11158 | return;
|
11159 | }
|
11160 |
|
11161 | function onProgress( image, elem, message ) {
|
11162 |
|
11163 | setTimeout( function() {
|
11164 | _this.progress( image, elem, message );
|
11165 | });
|
11166 | }
|
11167 |
|
11168 | this.images.forEach( function( loadingImage ) {
|
11169 | loadingImage.once( 'progress', onProgress );
|
11170 | loadingImage.check();
|
11171 | });
|
11172 | };
|
11173 |
|
11174 | ngImagesLoaded.prototype.progress = function( image, elem, message ) {
|
11175 | this.progressedCount++;
|
11176 | this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
|
11177 |
|
11178 | this.emitEvent( 'progress', [ this, image, elem ] );
|
11179 | if ( this.jqDeferred && this.jqDeferred.notify ) {
|
11180 | this.jqDeferred.notify( this, image );
|
11181 | }
|
11182 |
|
11183 | if ( this.progressedCount == this.images.length ) {
|
11184 | this.complete();
|
11185 | }
|
11186 |
|
11187 | if ( this.options.debug && console ) {
|
11188 | console.log( 'progress: ' + message, image, elem );
|
11189 | }
|
11190 | };
|
11191 |
|
11192 | ngImagesLoaded.prototype.complete = function() {
|
11193 | var eventName = this.hasAnyBroken ? 'fail' : 'done';
|
11194 | this.isComplete = true;
|
11195 | this.emitEvent( eventName, [ this ] );
|
11196 | this.emitEvent( 'always', [ this ] );
|
11197 | if ( this.jqDeferred ) {
|
11198 | var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
|
11199 | this.jqDeferred[ jqMethod ]( this );
|
11200 | }
|
11201 | };
|
11202 |
|
11203 |
|
11204 |
|
11205 | function LoadingImage( img ) {
|
11206 | this.img = img;
|
11207 | }
|
11208 |
|
11209 | LoadingImage.prototype = Object.create( ngEvEmitter.prototype );
|
11210 |
|
11211 | LoadingImage.prototype.check = function() {
|
11212 |
|
11213 |
|
11214 | var isComplete = this.getIsImageComplete();
|
11215 | if ( isComplete ) {
|
11216 |
|
11217 | this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
|
11218 | return;
|
11219 | }
|
11220 |
|
11221 |
|
11222 | this.proxyImage = new Image();
|
11223 | this.proxyImage.addEventListener( 'load', this );
|
11224 | this.proxyImage.addEventListener( 'error', this );
|
11225 |
|
11226 | this.img.addEventListener( 'load', this );
|
11227 | this.img.addEventListener( 'error', this );
|
11228 | this.proxyImage.src = this.img.src;
|
11229 | };
|
11230 |
|
11231 | LoadingImage.prototype.getIsImageComplete = function() {
|
11232 | return this.img.complete && this.img.naturalWidth !== undefined;
|
11233 | };
|
11234 |
|
11235 | LoadingImage.prototype.confirm = function( isLoaded, message ) {
|
11236 | this.isLoaded = isLoaded;
|
11237 | this.emitEvent( 'progress', [ this, this.img, message ] );
|
11238 | };
|
11239 |
|
11240 |
|
11241 |
|
11242 |
|
11243 | LoadingImage.prototype.handleEvent = function( event ) {
|
11244 | var method = 'on' + event.type;
|
11245 | if ( this[ method ] ) {
|
11246 | this[ method ]( event );
|
11247 | }
|
11248 | };
|
11249 |
|
11250 | LoadingImage.prototype.onload = function() {
|
11251 | this.confirm( true, 'onload' );
|
11252 | this.unbindEvents();
|
11253 | };
|
11254 |
|
11255 | LoadingImage.prototype.onerror = function() {
|
11256 | this.confirm( false, 'onerror' );
|
11257 | this.unbindEvents();
|
11258 | };
|
11259 |
|
11260 | LoadingImage.prototype.unbindEvents = function() {
|
11261 | this.proxyImage.removeEventListener( 'load', this );
|
11262 | this.proxyImage.removeEventListener( 'error', this );
|
11263 | this.img.removeEventListener( 'load', this );
|
11264 | this.img.removeEventListener( 'error', this );
|
11265 | };
|
11266 |
|
11267 |
|
11268 |
|
11269 | function Background( url, element ) {
|
11270 | this.url = url;
|
11271 | this.element = element;
|
11272 | this.img = new Image();
|
11273 | }
|
11274 |
|
11275 |
|
11276 | Background.prototype = Object.create( LoadingImage.prototype );
|
11277 |
|
11278 | Background.prototype.check = function() {
|
11279 | this.img.addEventListener( 'load', this );
|
11280 | this.img.addEventListener( 'error', this );
|
11281 | this.img.src = this.url;
|
11282 |
|
11283 | var isComplete = this.getIsImageComplete();
|
11284 | if ( isComplete ) {
|
11285 | this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
|
11286 | this.unbindEvents();
|
11287 | }
|
11288 | };
|
11289 |
|
11290 | Background.prototype.unbindEvents = function() {
|
11291 | this.img.removeEventListener( 'load', this );
|
11292 | this.img.removeEventListener( 'error', this );
|
11293 | };
|
11294 |
|
11295 | Background.prototype.confirm = function( isLoaded, message ) {
|
11296 | this.isLoaded = isLoaded;
|
11297 | this.emitEvent( 'progress', [ this, this.element, message ] );
|
11298 | };
|
11299 |
|
11300 |
|
11301 |
|
11302 | ngImagesLoaded.makeJQueryPlugin = function( jQuery ) {
|
11303 | jQuery = jQuery || window.jQuery;
|
11304 | if ( !jQuery ) {
|
11305 | return;
|
11306 | }
|
11307 |
|
11308 | $ = jQuery;
|
11309 |
|
11310 | $.fn.ngimagesLoaded = function( options, callback ) {
|
11311 | var instance = new ngImagesLoaded( this, options, callback );
|
11312 | return instance.jqDeferred.promise( $(this) );
|
11313 | };
|
11314 | };
|
11315 |
|
11316 | ngImagesLoaded.makeJQueryPlugin();
|
11317 |
|
11318 |
|
11319 |
|
11320 | return ngImagesLoaded;
|
11321 |
|
11322 | });
|
11323 |
|
11324 |
|
11325 |
|
11326 |
|
11327 |
|
11328 |
|
11329 |
|
11330 |
|
11331 |
|
11332 |
|
11333 |
|
11334 |
|
11335 |
|
11336 |
|
11337 |
|
11338 |
|
11339 |
|
11340 | (function () {
|
11341 | 'use strict';
|
11342 |
|
11343 | var document = typeof window !== 'undefined' && typeof window.document !== 'undefined' ? window.document : {};
|
11344 | var isCommonjs = typeof module !== 'undefined' && module.exports;
|
11345 | var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element;
|
11346 |
|
11347 | var fn = (function () {
|
11348 | var val;
|
11349 |
|
11350 | var fnMap = [
|
11351 | [
|
11352 | 'requestFullscreen',
|
11353 | 'exitFullscreen',
|
11354 | 'fullscreenElement',
|
11355 | 'fullscreenEnabled',
|
11356 | 'fullscreenchange',
|
11357 | 'fullscreenerror'
|
11358 | ],
|
11359 |
|
11360 | [
|
11361 | 'webkitRequestFullscreen',
|
11362 | 'webkitExitFullscreen',
|
11363 | 'webkitFullscreenElement',
|
11364 | 'webkitFullscreenEnabled',
|
11365 | 'webkitfullscreenchange',
|
11366 | 'webkitfullscreenerror'
|
11367 |
|
11368 | ],
|
11369 |
|
11370 | [
|
11371 | 'webkitRequestFullScreen',
|
11372 | 'webkitCancelFullScreen',
|
11373 | 'webkitCurrentFullScreenElement',
|
11374 | 'webkitCancelFullScreen',
|
11375 | 'webkitfullscreenchange',
|
11376 | 'webkitfullscreenerror'
|
11377 |
|
11378 | ],
|
11379 | [
|
11380 | 'mozRequestFullScreen',
|
11381 | 'mozCancelFullScreen',
|
11382 | 'mozFullScreenElement',
|
11383 | 'mozFullScreenEnabled',
|
11384 | 'mozfullscreenchange',
|
11385 | 'mozfullscreenerror'
|
11386 | ],
|
11387 | [
|
11388 | 'msRequestFullscreen',
|
11389 | 'msExitFullscreen',
|
11390 | 'msFullscreenElement',
|
11391 | 'msFullscreenEnabled',
|
11392 | 'MSFullscreenChange',
|
11393 | 'MSFullscreenError'
|
11394 | ]
|
11395 | ];
|
11396 |
|
11397 | var i = 0;
|
11398 | var l = fnMap.length;
|
11399 | var ret = {};
|
11400 |
|
11401 | for (; i < l; i++) {
|
11402 | val = fnMap[i];
|
11403 | if (val && val[1] in document) {
|
11404 | for (i = 0; i < val.length; i++) {
|
11405 | ret[fnMap[0][i]] = val[i];
|
11406 | }
|
11407 | return ret;
|
11408 | }
|
11409 | }
|
11410 |
|
11411 | return false;
|
11412 | })();
|
11413 |
|
11414 | var eventNameMap = {
|
11415 | change: fn.fullscreenchange,
|
11416 | error: fn.fullscreenerror
|
11417 | };
|
11418 |
|
11419 | var ngscreenfull = {
|
11420 | request: function (elem) {
|
11421 | return new Promise(function (resolve) {
|
11422 | var request = fn.requestFullscreen;
|
11423 |
|
11424 | var onFullScreenEntered = function () {
|
11425 | this.off('change', onFullScreenEntered);
|
11426 | resolve();
|
11427 | }.bind(this);
|
11428 |
|
11429 | elem = elem || document.documentElement;
|
11430 |
|
11431 |
|
11432 |
|
11433 |
|
11434 |
|
11435 | if (/ Version\/5\.1(?:\.\d+)? Safari\//.test(navigator.userAgent)) {
|
11436 | elem[request]();
|
11437 | } else {
|
11438 | elem[request](keyboardAllowed ? Element.ALLOW_KEYBOARD_INPUT : {});
|
11439 | }
|
11440 |
|
11441 | this.on('change', onFullScreenEntered);
|
11442 | }.bind(this));
|
11443 | },
|
11444 | exit: function () {
|
11445 | return new Promise(function (resolve) {
|
11446 | if (!this.isFullscreen) {
|
11447 | resolve();
|
11448 | return;
|
11449 | }
|
11450 |
|
11451 | var onFullScreenExit = function () {
|
11452 | this.off('change', onFullScreenExit);
|
11453 | resolve();
|
11454 | }.bind(this);
|
11455 |
|
11456 | document[fn.exitFullscreen]();
|
11457 |
|
11458 | this.on('change', onFullScreenExit);
|
11459 | }.bind(this));
|
11460 | },
|
11461 | toggle: function (elem) {
|
11462 | return this.isFullscreen ? this.exit() : this.request(elem);
|
11463 | },
|
11464 | onchange: function (callback) {
|
11465 | this.on('change', callback);
|
11466 | },
|
11467 | onerror: function (callback) {
|
11468 | this.on('error', callback);
|
11469 | },
|
11470 | on: function (event, callback) {
|
11471 | var eventName = eventNameMap[event];
|
11472 | if (eventName) {
|
11473 | document.addEventListener(eventName, callback, false);
|
11474 | }
|
11475 | },
|
11476 | off: function (event, callback) {
|
11477 | var eventName = eventNameMap[event];
|
11478 | if (eventName) {
|
11479 | document.removeEventListener(eventName, callback, false);
|
11480 | }
|
11481 | },
|
11482 | raw: fn
|
11483 | };
|
11484 |
|
11485 | if (!fn) {
|
11486 | if (isCommonjs) {
|
11487 | module.exports = false;
|
11488 | } else {
|
11489 | window.ngscreenfull = false;
|
11490 | }
|
11491 |
|
11492 | return;
|
11493 | }
|
11494 |
|
11495 | Object.defineProperties(ngscreenfull, {
|
11496 | isFullscreen: {
|
11497 | get: function () {
|
11498 | return Boolean(document[fn.fullscreenElement]);
|
11499 | }
|
11500 | },
|
11501 | element: {
|
11502 | enumerable: true,
|
11503 | get: function () {
|
11504 | return document[fn.fullscreenElement];
|
11505 | }
|
11506 | },
|
11507 | enabled: {
|
11508 | enumerable: true,
|
11509 | get: function () {
|
11510 |
|
11511 | return Boolean(document[fn.fullscreenEnabled]);
|
11512 | }
|
11513 | }
|
11514 | });
|
11515 |
|
11516 | if (isCommonjs) {
|
11517 | module.exports = ngscreenfull;
|
11518 | } else {
|
11519 | window.ngscreenfull = ngscreenfull;
|
11520 | }
|
11521 | })();
|
11522 |
|
11523 |
|
11524 |
|
11525 |
|
11526 |
|
11527 |
|
11528 |
|
11529 | |
11530 |
|
11531 |
|
11532 |
|
11533 |
|
11534 |
|
11535 |
|
11536 |
|
11537 |
|
11538 |
|
11539 |
|
11540 |
|
11541 |
|
11542 | ;(function () {
|
11543 | const root = typeof window !== 'undefined' ? window : global
|
11544 |
|
11545 |
|
11546 |
|
11547 |
|
11548 |
|
11549 |
|
11550 | var NGTweenable = (function () {
|
11551 |
|
11552 | 'use strict';
|
11553 |
|
11554 |
|
11555 | var formula;
|
11556 |
|
11557 |
|
11558 | var DEFAULT_SCHEDULE_FUNCTION;
|
11559 | var DEFAULT_EASING = 'linear';
|
11560 | var DEFAULT_DURATION = 500;
|
11561 | var UPDATE_TIME = 1000 / 60;
|
11562 |
|
11563 | var _now = Date.now
|
11564 | ? Date.now
|
11565 | : function () {return +new Date();};
|
11566 |
|
11567 | var now = typeof SHIFTY_DEBUG_NOW !== 'undefined' ? SHIFTY_DEBUG_NOW : _now;
|
11568 |
|
11569 | if (typeof window !== 'undefined') {
|
11570 |
|
11571 |
|
11572 | DEFAULT_SCHEDULE_FUNCTION = window.requestAnimationFrame
|
11573 | || window.webkitRequestAnimationFrame
|
11574 | || window.oRequestAnimationFrame
|
11575 | || window.msRequestAnimationFrame
|
11576 | || (window.mozCancelRequestAnimationFrame
|
11577 | && window.mozRequestAnimationFrame)
|
11578 | || setTimeout;
|
11579 | } else {
|
11580 | DEFAULT_SCHEDULE_FUNCTION = setTimeout;
|
11581 | }
|
11582 |
|
11583 | function noop () {
|
11584 |
|
11585 | }
|
11586 |
|
11587 | |
11588 |
|
11589 |
|
11590 |
|
11591 |
|
11592 |
|
11593 |
|
11594 |
|
11595 | function each (obj, fn) {
|
11596 | var key;
|
11597 | for (key in obj) {
|
11598 | if (Object.hasOwnProperty.call(obj, key)) {
|
11599 | fn(key);
|
11600 | }
|
11601 | }
|
11602 | }
|
11603 |
|
11604 | |
11605 |
|
11606 |
|
11607 |
|
11608 |
|
11609 |
|
11610 |
|
11611 | function shallowCopy (targetObj, srcObj) {
|
11612 | each(srcObj, function (prop) {
|
11613 | targetObj[prop] = srcObj[prop];
|
11614 | });
|
11615 |
|
11616 | return targetObj;
|
11617 | }
|
11618 |
|
11619 | |
11620 |
|
11621 |
|
11622 |
|
11623 |
|
11624 |
|
11625 |
|
11626 | function defaults (target, src) {
|
11627 | each(src, function (prop) {
|
11628 | if (typeof target[prop] === 'undefined') {
|
11629 | target[prop] = src[prop];
|
11630 | }
|
11631 | });
|
11632 | }
|
11633 |
|
11634 | |
11635 |
|
11636 |
|
11637 |
|
11638 |
|
11639 |
|
11640 |
|
11641 |
|
11642 |
|
11643 |
|
11644 |
|
11645 |
|
11646 |
|
11647 |
|
11648 |
|
11649 | function tweenProps (forPosition, currentState, originalState, targetState,
|
11650 | duration, timestamp, easing) {
|
11651 | var normalizedPosition =
|
11652 | forPosition < timestamp ? 0 : (forPosition - timestamp) / duration;
|
11653 |
|
11654 |
|
11655 | var prop;
|
11656 | var easingObjectProp;
|
11657 | var easingFn;
|
11658 | for (prop in currentState) {
|
11659 | if (currentState.hasOwnProperty(prop)) {
|
11660 | easingObjectProp = easing[prop];
|
11661 | easingFn = typeof easingObjectProp === 'function'
|
11662 | ? easingObjectProp
|
11663 | : formula[easingObjectProp];
|
11664 |
|
11665 | currentState[prop] = tweenProp(
|
11666 | originalState[prop],
|
11667 | targetState[prop],
|
11668 | easingFn,
|
11669 | normalizedPosition
|
11670 | );
|
11671 | }
|
11672 | }
|
11673 |
|
11674 | return currentState;
|
11675 | }
|
11676 |
|
11677 | |
11678 |
|
11679 |
|
11680 |
|
11681 |
|
11682 |
|
11683 |
|
11684 |
|
11685 |
|
11686 |
|
11687 | function tweenProp (start, end, easingFunc, position) {
|
11688 | return start + (end - start) * easingFunc(position);
|
11689 | }
|
11690 |
|
11691 | |
11692 |
|
11693 |
|
11694 |
|
11695 |
|
11696 |
|
11697 |
|
11698 | function applyFilter (tweenable, filterName) {
|
11699 | var filters = NGTweenable.prototype.filter;
|
11700 | var args = tweenable._filterArgs;
|
11701 |
|
11702 | each(filters, function (name) {
|
11703 | if (typeof filters[name][filterName] !== 'undefined') {
|
11704 | filters[name][filterName].apply(tweenable, args);
|
11705 | }
|
11706 | });
|
11707 | }
|
11708 |
|
11709 | var timeoutHandler_endTime;
|
11710 | var timeoutHandler_currentTime;
|
11711 | var timeoutHandler_isEnded;
|
11712 | var timeoutHandler_offset;
|
11713 | |
11714 |
|
11715 |
|
11716 |
|
11717 |
|
11718 |
|
11719 |
|
11720 |
|
11721 |
|
11722 |
|
11723 |
|
11724 |
|
11725 |
|
11726 |
|
11727 |
|
11728 |
|
11729 | function timeoutHandler (tweenable, timestamp, delay, duration, currentState,
|
11730 | originalState, targetState, easing, step, schedule,
|
11731 | opt_currentTimeOverride) {
|
11732 |
|
11733 | timeoutHandler_endTime = timestamp + delay + duration;
|
11734 |
|
11735 | timeoutHandler_currentTime =
|
11736 | Math.min(opt_currentTimeOverride || now(), timeoutHandler_endTime);
|
11737 |
|
11738 | timeoutHandler_isEnded =
|
11739 | timeoutHandler_currentTime >= timeoutHandler_endTime;
|
11740 |
|
11741 | timeoutHandler_offset = duration - (
|
11742 | timeoutHandler_endTime - timeoutHandler_currentTime);
|
11743 |
|
11744 | if (tweenable.isPlaying()) {
|
11745 | if (timeoutHandler_isEnded) {
|
11746 | step(targetState, tweenable._attachment, timeoutHandler_offset);
|
11747 | tweenable.stop(true);
|
11748 | } else {
|
11749 | tweenable._scheduleId =
|
11750 | schedule(tweenable._timeoutHandler, UPDATE_TIME);
|
11751 |
|
11752 | applyFilter(tweenable, 'beforeTween');
|
11753 |
|
11754 |
|
11755 |
|
11756 |
|
11757 | if (timeoutHandler_currentTime < (timestamp + delay)) {
|
11758 | tweenProps(1, currentState, originalState, targetState, 1, 1, easing);
|
11759 | } else {
|
11760 | tweenProps(timeoutHandler_currentTime, currentState, originalState,
|
11761 | targetState, duration, timestamp + delay, easing);
|
11762 | }
|
11763 |
|
11764 | applyFilter(tweenable, 'afterTween');
|
11765 |
|
11766 | step(currentState, tweenable._attachment, timeoutHandler_offset);
|
11767 | }
|
11768 | }
|
11769 | }
|
11770 |
|
11771 |
|
11772 | |
11773 |
|
11774 |
|
11775 |
|
11776 |
|
11777 |
|
11778 |
|
11779 |
|
11780 |
|
11781 | function composeEasingObject (fromTweenParams, easing) {
|
11782 | var composedEasing = {};
|
11783 | var typeofEasing = typeof easing;
|
11784 |
|
11785 | if (typeofEasing === 'string' || typeofEasing === 'function') {
|
11786 | each(fromTweenParams, function (prop) {
|
11787 | composedEasing[prop] = easing;
|
11788 | });
|
11789 | } else {
|
11790 | each(fromTweenParams, function (prop) {
|
11791 | if (!composedEasing[prop]) {
|
11792 | composedEasing[prop] = easing[prop] || DEFAULT_EASING;
|
11793 | }
|
11794 | });
|
11795 | }
|
11796 |
|
11797 | return composedEasing;
|
11798 | }
|
11799 |
|
11800 | |
11801 |
|
11802 |
|
11803 |
|
11804 |
|
11805 |
|
11806 |
|
11807 |
|
11808 |
|
11809 |
|
11810 |
|
11811 |
|
11812 | function NGTweenable (opt_initialState, opt_config) {
|
11813 | this._currentState = opt_initialState || {};
|
11814 | this._configured = false;
|
11815 | this._scheduleFunction = DEFAULT_SCHEDULE_FUNCTION;
|
11816 |
|
11817 |
|
11818 |
|
11819 |
|
11820 | if (typeof opt_config !== 'undefined') {
|
11821 | this.setConfig(opt_config);
|
11822 | }
|
11823 | }
|
11824 |
|
11825 | |
11826 |
|
11827 |
|
11828 |
|
11829 |
|
11830 |
|
11831 |
|
11832 | NGTweenable.prototype.tween = function (opt_config) {
|
11833 | if (this._isTweening) {
|
11834 | return this;
|
11835 | }
|
11836 |
|
11837 |
|
11838 |
|
11839 | if (opt_config !== undefined || !this._configured) {
|
11840 | this.setConfig(opt_config);
|
11841 | }
|
11842 |
|
11843 | this._timestamp = now();
|
11844 | this._start(this.get(), this._attachment);
|
11845 | return this.resume();
|
11846 | };
|
11847 |
|
11848 | |
11849 |
|
11850 |
|
11851 |
|
11852 |
|
11853 |
|
11854 |
|
11855 |
|
11856 |
|
11857 |
|
11858 |
|
11859 |
|
11860 |
|
11861 |
|
11862 |
|
11863 |
|
11864 |
|
11865 |
|
11866 |
|
11867 |
|
11868 |
|
11869 |
|
11870 |
|
11871 |
|
11872 |
|
11873 |
|
11874 |
|
11875 |
|
11876 |
|
11877 | NGTweenable.prototype.setConfig = function (config) {
|
11878 | config = config || {};
|
11879 | this._configured = true;
|
11880 |
|
11881 |
|
11882 |
|
11883 | this._attachment = config.attachment;
|
11884 |
|
11885 |
|
11886 | this._pausedAtTime = null;
|
11887 | this._scheduleId = null;
|
11888 | this._delay = config.delay || 0;
|
11889 | this._start = config.start || noop;
|
11890 | this._step = config.step || noop;
|
11891 | this._finish = config.finish || noop;
|
11892 | this._duration = config.duration || DEFAULT_DURATION;
|
11893 | this._currentState = shallowCopy({}, config.from || this.get());
|
11894 | this._originalState = this.get();
|
11895 | this._targetState = shallowCopy({}, config.to || this.get());
|
11896 |
|
11897 | var self = this;
|
11898 | this._timeoutHandler = function () {
|
11899 | timeoutHandler(self,
|
11900 | self._timestamp,
|
11901 | self._delay,
|
11902 | self._duration,
|
11903 | self._currentState,
|
11904 | self._originalState,
|
11905 | self._targetState,
|
11906 | self._easing,
|
11907 | self._step,
|
11908 | self._scheduleFunction
|
11909 | );
|
11910 | };
|
11911 |
|
11912 |
|
11913 | var currentState = this._currentState;
|
11914 | var targetState = this._targetState;
|
11915 |
|
11916 |
|
11917 | defaults(targetState, currentState);
|
11918 |
|
11919 | this._easing = composeEasingObject(
|
11920 | currentState, config.easing || DEFAULT_EASING);
|
11921 |
|
11922 | this._filterArgs =
|
11923 | [currentState, this._originalState, targetState, this._easing];
|
11924 |
|
11925 | applyFilter(this, 'tweenCreated');
|
11926 | return this;
|
11927 | };
|
11928 |
|
11929 | |
11930 |
|
11931 |
|
11932 |
|
11933 | NGTweenable.prototype.get = function () {
|
11934 | return shallowCopy({}, this._currentState);
|
11935 | };
|
11936 |
|
11937 | |
11938 |
|
11939 |
|
11940 |
|
11941 | NGTweenable.prototype.set = function (state) {
|
11942 | this._currentState = state;
|
11943 | };
|
11944 |
|
11945 | |
11946 |
|
11947 |
|
11948 |
|
11949 |
|
11950 |
|
11951 |
|
11952 |
|
11953 | NGTweenable.prototype.pause = function () {
|
11954 | this._pausedAtTime = now();
|
11955 | this._isPaused = true;
|
11956 | return this;
|
11957 | };
|
11958 |
|
11959 | |
11960 |
|
11961 |
|
11962 |
|
11963 |
|
11964 | NGTweenable.prototype.resume = function () {
|
11965 | if (this._isPaused) {
|
11966 | this._timestamp += now() - this._pausedAtTime;
|
11967 | }
|
11968 |
|
11969 | this._isPaused = false;
|
11970 | this._isTweening = true;
|
11971 |
|
11972 | this._timeoutHandler();
|
11973 |
|
11974 | return this;
|
11975 | };
|
11976 |
|
11977 | |
11978 |
|
11979 |
|
11980 |
|
11981 |
|
11982 |
|
11983 |
|
11984 |
|
11985 |
|
11986 | NGTweenable.prototype.seek = function (millisecond) {
|
11987 | millisecond = Math.max(millisecond, 0);
|
11988 | var currentTime = now();
|
11989 |
|
11990 | if ((this._timestamp + millisecond) === 0) {
|
11991 | return this;
|
11992 | }
|
11993 |
|
11994 | this._timestamp = currentTime - millisecond;
|
11995 |
|
11996 | if (!this.isPlaying()) {
|
11997 | this._isTweening = true;
|
11998 | this._isPaused = false;
|
11999 |
|
12000 |
|
12001 |
|
12002 | timeoutHandler(this,
|
12003 | this._timestamp,
|
12004 | this._delay,
|
12005 | this._duration,
|
12006 | this._currentState,
|
12007 | this._originalState,
|
12008 | this._targetState,
|
12009 | this._easing,
|
12010 | this._step,
|
12011 | this._scheduleFunction,
|
12012 | currentTime
|
12013 | );
|
12014 |
|
12015 | this.pause();
|
12016 | }
|
12017 |
|
12018 | return this;
|
12019 | };
|
12020 |
|
12021 | |
12022 |
|
12023 |
|
12024 |
|
12025 |
|
12026 |
|
12027 |
|
12028 |
|
12029 |
|
12030 | NGTweenable.prototype.stop = function (gotoEnd) {
|
12031 | this._isTweening = false;
|
12032 | this._isPaused = false;
|
12033 | this._timeoutHandler = noop;
|
12034 |
|
12035 | (root.cancelAnimationFrame ||
|
12036 | root.webkitCancelAnimationFrame ||
|
12037 | root.oCancelAnimationFrame ||
|
12038 | root.msCancelAnimationFrame ||
|
12039 | root.mozCancelRequestAnimationFrame ||
|
12040 | root.clearTimeout)(this._scheduleId);
|
12041 |
|
12042 | if (gotoEnd) {
|
12043 | applyFilter(this, 'beforeTween');
|
12044 | tweenProps(
|
12045 | 1,
|
12046 | this._currentState,
|
12047 | this._originalState,
|
12048 | this._targetState,
|
12049 | 1,
|
12050 | 0,
|
12051 | this._easing
|
12052 | );
|
12053 | applyFilter(this, 'afterTween');
|
12054 | applyFilter(this, 'afterTweenEnd');
|
12055 | this._finish.call(this, this._currentState, this._attachment);
|
12056 | }
|
12057 |
|
12058 | return this;
|
12059 | };
|
12060 |
|
12061 | |
12062 |
|
12063 |
|
12064 |
|
12065 | NGTweenable.prototype.isPlaying = function () {
|
12066 | return this._isTweening && !this._isPaused;
|
12067 | };
|
12068 |
|
12069 | |
12070 |
|
12071 |
|
12072 |
|
12073 |
|
12074 |
|
12075 |
|
12076 |
|
12077 |
|
12078 |
|
12079 |
|
12080 |
|
12081 | NGTweenable.prototype.setScheduleFunction = function (scheduleFunction) {
|
12082 | this._scheduleFunction = scheduleFunction;
|
12083 | };
|
12084 |
|
12085 | |
12086 |
|
12087 |
|
12088 |
|
12089 |
|
12090 | NGTweenable.prototype.dispose = function () {
|
12091 | var prop;
|
12092 | for (prop in this) {
|
12093 | if (this.hasOwnProperty(prop)) {
|
12094 | delete this[prop];
|
12095 | }
|
12096 | }
|
12097 | };
|
12098 |
|
12099 | |
12100 |
|
12101 |
|
12102 |
|
12103 |
|
12104 | NGTweenable.prototype.filter = {};
|
12105 |
|
12106 | |
12107 |
|
12108 |
|
12109 |
|
12110 |
|
12111 |
|
12112 |
|
12113 |
|
12114 |
|
12115 | NGTweenable.prototype.formula = {
|
12116 | linear: function (pos) {
|
12117 | return pos;
|
12118 | }
|
12119 | };
|
12120 |
|
12121 | formula = NGTweenable.prototype.formula;
|
12122 |
|
12123 | shallowCopy(NGTweenable, {
|
12124 | 'now': now
|
12125 | ,'each': each
|
12126 | ,'tweenProps': tweenProps
|
12127 | ,'tweenProp': tweenProp
|
12128 | ,'applyFilter': applyFilter
|
12129 | ,'shallowCopy': shallowCopy
|
12130 | ,'defaults': defaults
|
12131 | ,'composeEasingObject': composeEasingObject
|
12132 | });
|
12133 |
|
12134 |
|
12135 |
|
12136 |
|
12137 | if (typeof SHIFTY_DEBUG_NOW === 'function') {
|
12138 | root.timeoutHandler = timeoutHandler;
|
12139 | }
|
12140 |
|
12141 |
|
12142 | if (typeof exports === 'object') {
|
12143 |
|
12144 | module.exports = NGTweenable;
|
12145 | } else if (typeof define === 'function' && define.amdDISABLED) {
|
12146 |
|
12147 | define(function () {return NGTweenable;});
|
12148 | } else if (typeof root.NGTweenable === 'undefined') {
|
12149 |
|
12150 | root.NGTweenable = NGTweenable;
|
12151 | }
|
12152 |
|
12153 | return NGTweenable;
|
12154 |
|
12155 | } ());
|
12156 |
|
12157 |
|
12158 |
|
12159 |
|
12160 |
|
12161 |
|
12162 |
|
12163 |
|
12164 |
|
12165 |
|
12166 |
|
12167 |
|
12168 |
|
12169 |
|
12170 |
|
12171 |
|
12172 | ;(function () {
|
12173 |
|
12174 | NGTweenable.shallowCopy(NGTweenable.prototype.formula, {
|
12175 | easeInQuad: function (pos) {
|
12176 | return Math.pow(pos, 2);
|
12177 | },
|
12178 |
|
12179 | easeOutQuad: function (pos) {
|
12180 | return -(Math.pow((pos - 1), 2) - 1);
|
12181 | },
|
12182 |
|
12183 | easeInOutQuad: function (pos) {
|
12184 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,2);}
|
12185 | return -0.5 * ((pos -= 2) * pos - 2);
|
12186 | },
|
12187 |
|
12188 | easeInCubic: function (pos) {
|
12189 | return Math.pow(pos, 3);
|
12190 | },
|
12191 |
|
12192 | easeOutCubic: function (pos) {
|
12193 | return (Math.pow((pos - 1), 3) + 1);
|
12194 | },
|
12195 |
|
12196 | easeInOutCubic: function (pos) {
|
12197 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,3);}
|
12198 | return 0.5 * (Math.pow((pos - 2),3) + 2);
|
12199 | },
|
12200 |
|
12201 | easeInQuart: function (pos) {
|
12202 | return Math.pow(pos, 4);
|
12203 | },
|
12204 |
|
12205 | easeOutQuart: function (pos) {
|
12206 | return -(Math.pow((pos - 1), 4) - 1);
|
12207 | },
|
12208 |
|
12209 | easeInOutQuart: function (pos) {
|
12210 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,4);}
|
12211 | return -0.5 * ((pos -= 2) * Math.pow(pos,3) - 2);
|
12212 | },
|
12213 |
|
12214 | easeInQuint: function (pos) {
|
12215 | return Math.pow(pos, 5);
|
12216 | },
|
12217 |
|
12218 | easeOutQuint: function (pos) {
|
12219 | return (Math.pow((pos - 1), 5) + 1);
|
12220 | },
|
12221 |
|
12222 | easeInOutQuint: function (pos) {
|
12223 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,5);}
|
12224 | return 0.5 * (Math.pow((pos - 2),5) + 2);
|
12225 | },
|
12226 |
|
12227 | easeInSine: function (pos) {
|
12228 | return -Math.cos(pos * (Math.PI / 2)) + 1;
|
12229 | },
|
12230 |
|
12231 | easeOutSine: function (pos) {
|
12232 | return Math.sin(pos * (Math.PI / 2));
|
12233 | },
|
12234 |
|
12235 | easeInOutSine: function (pos) {
|
12236 | return (-0.5 * (Math.cos(Math.PI * pos) - 1));
|
12237 | },
|
12238 |
|
12239 | easeInExpo: function (pos) {
|
12240 | return (pos === 0) ? 0 : Math.pow(2, 10 * (pos - 1));
|
12241 | },
|
12242 |
|
12243 | easeOutExpo: function (pos) {
|
12244 | return (pos === 1) ? 1 : -Math.pow(2, -10 * pos) + 1;
|
12245 | },
|
12246 |
|
12247 | easeInOutExpo: function (pos) {
|
12248 | if (pos === 0) {return 0;}
|
12249 | if (pos === 1) {return 1;}
|
12250 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(2,10 * (pos - 1));}
|
12251 | return 0.5 * (-Math.pow(2, -10 * --pos) + 2);
|
12252 | },
|
12253 |
|
12254 | easeInCirc: function (pos) {
|
12255 | return -(Math.sqrt(1 - (pos * pos)) - 1);
|
12256 | },
|
12257 |
|
12258 | easeOutCirc: function (pos) {
|
12259 | return Math.sqrt(1 - Math.pow((pos - 1), 2));
|
12260 | },
|
12261 |
|
12262 | easeInOutCirc: function (pos) {
|
12263 | if ((pos /= 0.5) < 1) {return -0.5 * (Math.sqrt(1 - pos * pos) - 1);}
|
12264 | return 0.5 * (Math.sqrt(1 - (pos -= 2) * pos) + 1);
|
12265 | },
|
12266 |
|
12267 | easeOutBounce: function (pos) {
|
12268 | if ((pos) < (1 / 2.75)) {
|
12269 | return (7.5625 * pos * pos);
|
12270 | } else if (pos < (2 / 2.75)) {
|
12271 | return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
|
12272 | } else if (pos < (2.5 / 2.75)) {
|
12273 | return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
|
12274 | } else {
|
12275 | return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
|
12276 | }
|
12277 | },
|
12278 |
|
12279 | easeInBack: function (pos) {
|
12280 | var s = 1.70158;
|
12281 | return (pos) * pos * ((s + 1) * pos - s);
|
12282 | },
|
12283 |
|
12284 | easeOutBack: function (pos) {
|
12285 | var s = 1.70158;
|
12286 | return (pos = pos - 1) * pos * ((s + 1) * pos + s) + 1;
|
12287 | },
|
12288 |
|
12289 | easeInOutBack: function (pos) {
|
12290 | var s = 1.70158;
|
12291 | if ((pos /= 0.5) < 1) {
|
12292 | return 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s));
|
12293 | }
|
12294 | return 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
|
12295 | },
|
12296 |
|
12297 | elastic: function (pos) {
|
12298 |
|
12299 | return -1 * Math.pow(4,-8 * pos) * Math.sin((pos * 6 - 1) * (2 * Math.PI) / 2) + 1;
|
12300 | },
|
12301 |
|
12302 | swingFromTo: function (pos) {
|
12303 | var s = 1.70158;
|
12304 | return ((pos /= 0.5) < 1) ?
|
12305 | 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s)) :
|
12306 | 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
|
12307 | },
|
12308 |
|
12309 | swingFrom: function (pos) {
|
12310 | var s = 1.70158;
|
12311 | return pos * pos * ((s + 1) * pos - s);
|
12312 | },
|
12313 |
|
12314 | swingTo: function (pos) {
|
12315 | var s = 1.70158;
|
12316 | return (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
|
12317 | },
|
12318 |
|
12319 | bounce: function (pos) {
|
12320 | if (pos < (1 / 2.75)) {
|
12321 | return (7.5625 * pos * pos);
|
12322 | } else if (pos < (2 / 2.75)) {
|
12323 | return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
|
12324 | } else if (pos < (2.5 / 2.75)) {
|
12325 | return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
|
12326 | } else {
|
12327 | return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
|
12328 | }
|
12329 | },
|
12330 |
|
12331 | bouncePast: function (pos) {
|
12332 | if (pos < (1 / 2.75)) {
|
12333 | return (7.5625 * pos * pos);
|
12334 | } else if (pos < (2 / 2.75)) {
|
12335 | return 2 - (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
|
12336 | } else if (pos < (2.5 / 2.75)) {
|
12337 | return 2 - (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
|
12338 | } else {
|
12339 | return 2 - (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
|
12340 | }
|
12341 | },
|
12342 |
|
12343 | easeFromTo: function (pos) {
|
12344 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,4);}
|
12345 | return -0.5 * ((pos -= 2) * Math.pow(pos,3) - 2);
|
12346 | },
|
12347 |
|
12348 | easeFrom: function (pos) {
|
12349 | return Math.pow(pos,4);
|
12350 | },
|
12351 |
|
12352 | easeTo: function (pos) {
|
12353 | return Math.pow(pos,0.25);
|
12354 | }
|
12355 | });
|
12356 |
|
12357 | }());
|
12358 |
|
12359 |
|
12360 |
|
12361 |
|
12362 |
|
12363 |
|
12364 |
|
12365 |
|
12366 |
|
12367 |
|
12368 |
|
12369 |
|
12370 |
|
12371 |
|
12372 |
|
12373 |
|
12374 |
|
12375 |
|
12376 |
|
12377 |
|
12378 |
|
12379 |
|
12380 |
|
12381 |
|
12382 |
|
12383 |
|
12384 |
|
12385 |
|
12386 |
|
12387 |
|
12388 |
|
12389 |
|
12390 |
|
12391 |
|
12392 |
|
12393 |
|
12394 |
|
12395 |
|
12396 |
|
12397 | ;(function () {
|
12398 |
|
12399 | function cubicBezierAtTime(t,p1x,p1y,p2x,p2y,duration) {
|
12400 | var ax = 0,bx = 0,cx = 0,ay = 0,by = 0,cy = 0;
|
12401 | function sampleCurveX(t) {
|
12402 | return ((ax * t + bx) * t + cx) * t;
|
12403 | }
|
12404 | function sampleCurveY(t) {
|
12405 | return ((ay * t + by) * t + cy) * t;
|
12406 | }
|
12407 | function sampleCurveDerivativeX(t) {
|
12408 | return (3.0 * ax * t + 2.0 * bx) * t + cx;
|
12409 | }
|
12410 | function solveEpsilon(duration) {
|
12411 | return 1.0 / (200.0 * duration);
|
12412 | }
|
12413 | function solve(x,epsilon) {
|
12414 | return sampleCurveY(solveCurveX(x, epsilon));
|
12415 | }
|
12416 | function fabs(n) {
|
12417 | if (n >= 0) {
|
12418 | return n;
|
12419 | } else {
|
12420 | return 0 - n;
|
12421 | }
|
12422 | }
|
12423 | function solveCurveX(x, epsilon) {
|
12424 | var t0,t1,t2,x2,d2,i;
|
12425 | for (t2 = x, i = 0; i < 8; i++) {
|
12426 | x2 = sampleCurveX(t2) - x;
|
12427 | if (fabs(x2) < epsilon) {
|
12428 | return t2;
|
12429 | }
|
12430 | d2 = sampleCurveDerivativeX(t2);
|
12431 | if (fabs(d2) < 1e-6) {
|
12432 | break;
|
12433 | }
|
12434 | t2 = t2 - x2 / d2;
|
12435 | }
|
12436 | t0 = 0.0;
|
12437 | t1 = 1.0;
|
12438 | t2 = x;
|
12439 | if (t2 < t0) {
|
12440 | return t0;
|
12441 | }
|
12442 | if (t2 > t1) {
|
12443 | return t1;
|
12444 | }
|
12445 | while (t0 < t1) {
|
12446 | x2 = sampleCurveX(t2);
|
12447 | if (fabs(x2 - x) < epsilon) {
|
12448 | return t2;
|
12449 | }
|
12450 | if (x > x2) {
|
12451 | t0 = t2;
|
12452 | }else {
|
12453 | t1 = t2;
|
12454 | }
|
12455 | t2 = (t1 - t0) * 0.5 + t0;
|
12456 | }
|
12457 | return t2;
|
12458 | }
|
12459 | cx = 3.0 * p1x;
|
12460 | bx = 3.0 * (p2x - p1x) - cx;
|
12461 | ax = 1.0 - cx - bx;
|
12462 | cy = 3.0 * p1y;
|
12463 | by = 3.0 * (p2y - p1y) - cy;
|
12464 | ay = 1.0 - cy - by;
|
12465 | return solve(t, solveEpsilon(duration));
|
12466 | }
|
12467 | |
12468 |
|
12469 |
|
12470 |
|
12471 |
|
12472 |
|
12473 |
|
12474 |
|
12475 |
|
12476 |
|
12477 |
|
12478 |
|
12479 |
|
12480 |
|
12481 |
|
12482 |
|
12483 |
|
12484 | function getCubicBezierTransition (x1, y1, x2, y2) {
|
12485 | return function (pos) {
|
12486 | return cubicBezierAtTime(pos,x1,y1,x2,y2,1);
|
12487 | };
|
12488 | }
|
12489 |
|
12490 |
|
12491 | |
12492 |
|
12493 |
|
12494 |
|
12495 |
|
12496 |
|
12497 |
|
12498 |
|
12499 |
|
12500 |
|
12501 |
|
12502 |
|
12503 |
|
12504 |
|
12505 |
|
12506 |
|
12507 |
|
12508 |
|
12509 | NGTweenable.setBezierFunction = function (name, x1, y1, x2, y2) {
|
12510 | var cubicBezierTransition = getCubicBezierTransition(x1, y1, x2, y2);
|
12511 | cubicBezierTransition.displayName = name;
|
12512 | cubicBezierTransition.x1 = x1;
|
12513 | cubicBezierTransition.y1 = y1;
|
12514 | cubicBezierTransition.x2 = x2;
|
12515 | cubicBezierTransition.y2 = y2;
|
12516 |
|
12517 | return NGTweenable.prototype.formula[name] = cubicBezierTransition;
|
12518 | };
|
12519 |
|
12520 |
|
12521 | |
12522 |
|
12523 |
|
12524 |
|
12525 |
|
12526 |
|
12527 |
|
12528 |
|
12529 |
|
12530 | NGTweenable.unsetBezierFunction = function (name) {
|
12531 | delete NGTweenable.prototype.formula[name];
|
12532 | };
|
12533 |
|
12534 | })();
|
12535 |
|
12536 | ;(function () {
|
12537 |
|
12538 | function getInterpolatedValues (
|
12539 | from, current, targetState, position, easing, delay) {
|
12540 | return NGTweenable.tweenProps(
|
12541 | position, current, from, targetState, 1, delay, easing);
|
12542 | }
|
12543 |
|
12544 |
|
12545 |
|
12546 |
|
12547 | var mockNGTweenable = new NGTweenable();
|
12548 | mockNGTweenable._filterArgs = [];
|
12549 |
|
12550 | |
12551 |
|
12552 |
|
12553 |
|
12554 |
|
12555 |
|
12556 |
|
12557 |
|
12558 |
|
12559 |
|
12560 |
|
12561 |
|
12562 |
|
12563 |
|
12564 |
|
12565 |
|
12566 |
|
12567 |
|
12568 |
|
12569 |
|
12570 |
|
12571 |
|
12572 |
|
12573 |
|
12574 |
|
12575 |
|
12576 |
|
12577 |
|
12578 |
|
12579 |
|
12580 |
|
12581 |
|
12582 |
|
12583 |
|
12584 |
|
12585 |
|
12586 | NGTweenable.interpolate = function (
|
12587 | from, targetState, position, easing, opt_delay) {
|
12588 |
|
12589 | var current = NGTweenable.shallowCopy({}, from);
|
12590 | var delay = opt_delay || 0;
|
12591 | var easingObject = NGTweenable.composeEasingObject(
|
12592 | from, easing || 'linear');
|
12593 |
|
12594 | mockNGTweenable.set({});
|
12595 |
|
12596 |
|
12597 | var filterArgs = mockNGTweenable._filterArgs;
|
12598 | filterArgs.length = 0;
|
12599 | filterArgs[0] = current;
|
12600 | filterArgs[1] = from;
|
12601 | filterArgs[2] = targetState;
|
12602 | filterArgs[3] = easingObject;
|
12603 |
|
12604 |
|
12605 | NGTweenable.applyFilter(mockNGTweenable, 'tweenCreated');
|
12606 | NGTweenable.applyFilter(mockNGTweenable, 'beforeTween');
|
12607 |
|
12608 | var interpolatedValues = getInterpolatedValues(
|
12609 | from, current, targetState, position, easingObject, delay);
|
12610 |
|
12611 |
|
12612 | NGTweenable.applyFilter(mockNGTweenable, 'afterTween');
|
12613 |
|
12614 | return interpolatedValues;
|
12615 | };
|
12616 |
|
12617 | }());
|
12618 |
|
12619 |
|
12620 |
|
12621 |
|
12622 |
|
12623 |
|
12624 |
|
12625 |
|
12626 |
|
12627 |
|
12628 |
|
12629 |
|
12630 |
|
12631 |
|
12632 |
|
12633 |
|
12634 |
|
12635 |
|
12636 |
|
12637 |
|
12638 |
|
12639 |
|
12640 |
|
12641 |
|
12642 |
|
12643 |
|
12644 |
|
12645 |
|
12646 |
|
12647 |
|
12648 |
|
12649 |
|
12650 |
|
12651 |
|
12652 |
|
12653 |
|
12654 |
|
12655 |
|
12656 |
|
12657 |
|
12658 |
|
12659 |
|
12660 |
|
12661 |
|
12662 |
|
12663 |
|
12664 |
|
12665 |
|
12666 |
|
12667 |
|
12668 |
|
12669 |
|
12670 |
|
12671 |
|
12672 |
|
12673 |
|
12674 |
|
12675 |
|
12676 |
|
12677 |
|
12678 |
|
12679 |
|
12680 |
|
12681 |
|
12682 |
|
12683 |
|
12684 |
|
12685 |
|
12686 |
|
12687 |
|
12688 |
|
12689 |
|
12690 |
|
12691 |
|
12692 |
|
12693 |
|
12694 |
|
12695 |
|
12696 |
|
12697 |
|
12698 |
|
12699 |
|
12700 |
|
12701 |
|
12702 |
|
12703 |
|
12704 |
|
12705 |
|
12706 |
|
12707 |
|
12708 |
|
12709 |
|
12710 |
|
12711 |
|
12712 |
|
12713 |
|
12714 |
|
12715 |
|
12716 |
|
12717 |
|
12718 |
|
12719 |
|
12720 |
|
12721 |
|
12722 |
|
12723 |
|
12724 |
|
12725 |
|
12726 |
|
12727 |
|
12728 |
|
12729 |
|
12730 |
|
12731 |
|
12732 |
|
12733 |
|
12734 |
|
12735 |
|
12736 |
|
12737 |
|
12738 |
|
12739 |
|
12740 |
|
12741 |
|
12742 |
|
12743 |
|
12744 |
|
12745 |
|
12746 |
|
12747 |
|
12748 |
|
12749 |
|
12750 |
|
12751 |
|
12752 |
|
12753 |
|
12754 |
|
12755 | ;(function (NGTweenable) {
|
12756 |
|
12757 | |
12758 |
|
12759 |
|
12760 |
|
12761 |
|
12762 |
|
12763 |
|
12764 | var formatManifest;
|
12765 |
|
12766 |
|
12767 |
|
12768 | var R_NUMBER_COMPONENT = /(\d|\-|\.)/;
|
12769 | var R_FORMAT_CHUNKS = /([^\-0-9\.]+)/g;
|
12770 | var R_UNFORMATTED_VALUES = /[0-9.\-]+/g;
|
12771 | var R_RGB = new RegExp(
|
12772 | 'rgb\\(' + R_UNFORMATTED_VALUES.source +
|
12773 | (/,\s*/.source) + R_UNFORMATTED_VALUES.source +
|
12774 | (/,\s*/.source) + R_UNFORMATTED_VALUES.source + '\\)', 'g');
|
12775 | var R_RGB_PREFIX = /^.*\(/;
|
12776 | var R_HEX = /#([0-9]|[a-f]){3,6}/gi;
|
12777 | var VALUE_PLACEHOLDER = 'VAL';
|
12778 |
|
12779 |
|
12780 |
|
12781 | |
12782 |
|
12783 |
|
12784 |
|
12785 |
|
12786 |
|
12787 |
|
12788 | function getFormatChunksFrom (rawValues, prefix) {
|
12789 | var accumulator = [];
|
12790 |
|
12791 | var rawValuesLength = rawValues.length;
|
12792 | var i;
|
12793 |
|
12794 | for (i = 0; i < rawValuesLength; i++) {
|
12795 | accumulator.push('_' + prefix + '_' + i);
|
12796 | }
|
12797 |
|
12798 | return accumulator;
|
12799 | }
|
12800 |
|
12801 | |
12802 |
|
12803 |
|
12804 |
|
12805 |
|
12806 |
|
12807 | function getFormatStringFrom (formattedString) {
|
12808 | var chunks = formattedString.match(R_FORMAT_CHUNKS);
|
12809 |
|
12810 | if (!chunks) {
|
12811 |
|
12812 |
|
12813 |
|
12814 | chunks = ['', ''];
|
12815 |
|
12816 |
|
12817 |
|
12818 |
|
12819 | } else if (chunks.length === 1 ||
|
12820 |
|
12821 |
|
12822 | formattedString.charAt(0).match(R_NUMBER_COMPONENT)) {
|
12823 |
|
12824 |
|
12825 | chunks.unshift('');
|
12826 | }
|
12827 |
|
12828 | return chunks.join(VALUE_PLACEHOLDER);
|
12829 | }
|
12830 |
|
12831 | |
12832 |
|
12833 |
|
12834 |
|
12835 |
|
12836 |
|
12837 |
|
12838 |
|
12839 | function sanitizeObjectForHexProps (stateObject) {
|
12840 | NGTweenable.each(stateObject, function (prop) {
|
12841 | var currentProp = stateObject[prop];
|
12842 |
|
12843 | if (typeof currentProp === 'string' && currentProp.match(R_HEX)) {
|
12844 | stateObject[prop] = sanitizeHexChunksToRGB(currentProp);
|
12845 | }
|
12846 | });
|
12847 | }
|
12848 |
|
12849 | |
12850 |
|
12851 |
|
12852 |
|
12853 |
|
12854 |
|
12855 | function sanitizeHexChunksToRGB (str) {
|
12856 | return filterStringChunks(R_HEX, str, convertHexToRGB);
|
12857 | }
|
12858 |
|
12859 | |
12860 |
|
12861 |
|
12862 |
|
12863 |
|
12864 |
|
12865 | function convertHexToRGB (hexString) {
|
12866 | var rgbArr = hexToRGBArray(hexString);
|
12867 | return 'rgb(' + rgbArr[0] + ',' + rgbArr[1] + ',' + rgbArr[2] + ')';
|
12868 | }
|
12869 |
|
12870 | var hexToRGBArray_returnArray = [];
|
12871 | |
12872 |
|
12873 |
|
12874 |
|
12875 |
|
12876 |
|
12877 |
|
12878 |
|
12879 |
|
12880 |
|
12881 | function hexToRGBArray (hex) {
|
12882 |
|
12883 | hex = hex.replace(/#/, '');
|
12884 |
|
12885 |
|
12886 |
|
12887 | if (hex.length === 3) {
|
12888 | hex = hex.split('');
|
12889 | hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
12890 | }
|
12891 |
|
12892 | hexToRGBArray_returnArray[0] = hexToDec(hex.substr(0, 2));
|
12893 | hexToRGBArray_returnArray[1] = hexToDec(hex.substr(2, 2));
|
12894 | hexToRGBArray_returnArray[2] = hexToDec(hex.substr(4, 2));
|
12895 |
|
12896 | return hexToRGBArray_returnArray;
|
12897 | }
|
12898 |
|
12899 | |
12900 |
|
12901 |
|
12902 |
|
12903 |
|
12904 |
|
12905 |
|
12906 |
|
12907 | function hexToDec (hex) {
|
12908 | return parseInt(hex, 16);
|
12909 | }
|
12910 |
|
12911 | |
12912 |
|
12913 |
|
12914 |
|
12915 |
|
12916 |
|
12917 |
|
12918 |
|
12919 |
|
12920 |
|
12921 | function filterStringChunks (pattern, unfilteredString, filter) {
|
12922 | var pattenMatches = unfilteredString.match(pattern);
|
12923 | var filteredString = unfilteredString.replace(pattern, VALUE_PLACEHOLDER);
|
12924 |
|
12925 | if (pattenMatches) {
|
12926 | var pattenMatchesLength = pattenMatches.length;
|
12927 | var currentChunk;
|
12928 |
|
12929 | for (var i = 0; i < pattenMatchesLength; i++) {
|
12930 | currentChunk = pattenMatches.shift();
|
12931 | filteredString = filteredString.replace(
|
12932 | VALUE_PLACEHOLDER, filter(currentChunk));
|
12933 | }
|
12934 | }
|
12935 |
|
12936 | return filteredString;
|
12937 | }
|
12938 |
|
12939 | |
12940 |
|
12941 |
|
12942 |
|
12943 |
|
12944 |
|
12945 |
|
12946 |
|
12947 | function sanitizeRGBChunks (formattedString) {
|
12948 | return filterStringChunks(R_RGB, formattedString, sanitizeRGBChunk);
|
12949 | }
|
12950 |
|
12951 | |
12952 |
|
12953 |
|
12954 |
|
12955 |
|
12956 |
|
12957 | function sanitizeRGBChunk (rgbChunk) {
|
12958 | var numbers = rgbChunk.match(R_UNFORMATTED_VALUES);
|
12959 | var numbersLength = numbers.length;
|
12960 | var sanitizedString = rgbChunk.match(R_RGB_PREFIX)[0];
|
12961 |
|
12962 | for (var i = 0; i < numbersLength; i++) {
|
12963 | sanitizedString += parseInt(numbers[i], 10) + ',';
|
12964 | }
|
12965 |
|
12966 | sanitizedString = sanitizedString.slice(0, -1) + ')';
|
12967 |
|
12968 | return sanitizedString;
|
12969 | }
|
12970 |
|
12971 | |
12972 |
|
12973 |
|
12974 |
|
12975 |
|
12976 |
|
12977 |
|
12978 | function getFormatManifests (stateObject) {
|
12979 | var manifestAccumulator = {};
|
12980 |
|
12981 | NGTweenable.each(stateObject, function (prop) {
|
12982 | var currentProp = stateObject[prop];
|
12983 |
|
12984 | if (typeof currentProp === 'string') {
|
12985 | var rawValues = getValuesFrom(currentProp);
|
12986 |
|
12987 | manifestAccumulator[prop] = {
|
12988 | 'formatString': getFormatStringFrom(currentProp)
|
12989 | ,'chunkNames': getFormatChunksFrom(rawValues, prop)
|
12990 | };
|
12991 | }
|
12992 | });
|
12993 |
|
12994 | return manifestAccumulator;
|
12995 | }
|
12996 |
|
12997 | |
12998 |
|
12999 |
|
13000 |
|
13001 |
|
13002 | function expandFormattedProperties (stateObject, formatManifests) {
|
13003 | NGTweenable.each(formatManifests, function (prop) {
|
13004 | var currentProp = stateObject[prop];
|
13005 | var rawValues = getValuesFrom(currentProp);
|
13006 | var rawValuesLength = rawValues.length;
|
13007 |
|
13008 | for (var i = 0; i < rawValuesLength; i++) {
|
13009 | stateObject[formatManifests[prop].chunkNames[i]] = +rawValues[i];
|
13010 | }
|
13011 |
|
13012 | delete stateObject[prop];
|
13013 | });
|
13014 | }
|
13015 |
|
13016 | |
13017 |
|
13018 |
|
13019 |
|
13020 |
|
13021 | function collapseFormattedProperties (stateObject, formatManifests) {
|
13022 | NGTweenable.each(formatManifests, function (prop) {
|
13023 | var currentProp = stateObject[prop];
|
13024 | var formatChunks = extractPropertyChunks(
|
13025 | stateObject, formatManifests[prop].chunkNames);
|
13026 | var valuesList = getValuesList(
|
13027 | formatChunks, formatManifests[prop].chunkNames);
|
13028 | currentProp = getFormattedValues(
|
13029 | formatManifests[prop].formatString, valuesList);
|
13030 | stateObject[prop] = sanitizeRGBChunks(currentProp);
|
13031 | });
|
13032 | }
|
13033 |
|
13034 | |
13035 |
|
13036 |
|
13037 |
|
13038 |
|
13039 |
|
13040 |
|
13041 | function extractPropertyChunks (stateObject, chunkNames) {
|
13042 | var extractedValues = {};
|
13043 | var currentChunkName, chunkNamesLength = chunkNames.length;
|
13044 |
|
13045 | for (var i = 0; i < chunkNamesLength; i++) {
|
13046 | currentChunkName = chunkNames[i];
|
13047 | extractedValues[currentChunkName] = stateObject[currentChunkName];
|
13048 | delete stateObject[currentChunkName];
|
13049 | }
|
13050 |
|
13051 | return extractedValues;
|
13052 | }
|
13053 |
|
13054 | var getValuesList_accumulator = [];
|
13055 | |
13056 |
|
13057 |
|
13058 |
|
13059 |
|
13060 |
|
13061 |
|
13062 | function getValuesList (stateObject, chunkNames) {
|
13063 | getValuesList_accumulator.length = 0;
|
13064 | var chunkNamesLength = chunkNames.length;
|
13065 |
|
13066 | for (var i = 0; i < chunkNamesLength; i++) {
|
13067 | getValuesList_accumulator.push(stateObject[chunkNames[i]]);
|
13068 | }
|
13069 |
|
13070 | return getValuesList_accumulator;
|
13071 | }
|
13072 |
|
13073 | |
13074 |
|
13075 |
|
13076 |
|
13077 |
|
13078 |
|
13079 |
|
13080 | function getFormattedValues (formatString, rawValues) {
|
13081 | var formattedValueString = formatString;
|
13082 | var rawValuesLength = rawValues.length;
|
13083 |
|
13084 | for (var i = 0; i < rawValuesLength; i++) {
|
13085 | formattedValueString = formattedValueString.replace(
|
13086 | VALUE_PLACEHOLDER, +rawValues[i].toFixed(4));
|
13087 | }
|
13088 |
|
13089 | return formattedValueString;
|
13090 | }
|
13091 |
|
13092 | |
13093 |
|
13094 |
|
13095 |
|
13096 |
|
13097 |
|
13098 |
|
13099 |
|
13100 |
|
13101 | function getValuesFrom (formattedString) {
|
13102 | return formattedString.match(R_UNFORMATTED_VALUES);
|
13103 | }
|
13104 |
|
13105 | |
13106 |
|
13107 |
|
13108 |
|
13109 |
|
13110 | function expandEasingObject (easingObject, tokenData) {
|
13111 | NGTweenable.each(tokenData, function (prop) {
|
13112 | var currentProp = tokenData[prop];
|
13113 | var chunkNames = currentProp.chunkNames;
|
13114 | var chunkLength = chunkNames.length;
|
13115 |
|
13116 | var easing = easingObject[prop];
|
13117 | var i;
|
13118 |
|
13119 | if (typeof easing === 'string') {
|
13120 | var easingChunks = easing.split(' ');
|
13121 | var lastEasingChunk = easingChunks[easingChunks.length - 1];
|
13122 |
|
13123 | for (i = 0; i < chunkLength; i++) {
|
13124 | easingObject[chunkNames[i]] = easingChunks[i] || lastEasingChunk;
|
13125 | }
|
13126 |
|
13127 | } else {
|
13128 | for (i = 0; i < chunkLength; i++) {
|
13129 | easingObject[chunkNames[i]] = easing;
|
13130 | }
|
13131 | }
|
13132 |
|
13133 | delete easingObject[prop];
|
13134 | });
|
13135 | }
|
13136 |
|
13137 | |
13138 |
|
13139 |
|
13140 |
|
13141 |
|
13142 | function collapseEasingObject (easingObject, tokenData) {
|
13143 | NGTweenable.each(tokenData, function (prop) {
|
13144 | var currentProp = tokenData[prop];
|
13145 | var chunkNames = currentProp.chunkNames;
|
13146 | var chunkLength = chunkNames.length;
|
13147 |
|
13148 | var firstEasing = easingObject[chunkNames[0]];
|
13149 | var typeofEasings = typeof firstEasing;
|
13150 |
|
13151 | if (typeofEasings === 'string') {
|
13152 | var composedEasingString = '';
|
13153 |
|
13154 | for (var i = 0; i < chunkLength; i++) {
|
13155 | composedEasingString += ' ' + easingObject[chunkNames[i]];
|
13156 | delete easingObject[chunkNames[i]];
|
13157 | }
|
13158 |
|
13159 | easingObject[prop] = composedEasingString.substr(1);
|
13160 | } else {
|
13161 | easingObject[prop] = firstEasing;
|
13162 | }
|
13163 | });
|
13164 | }
|
13165 |
|
13166 | NGTweenable.prototype.filter.token = {
|
13167 | 'tweenCreated': function (currentState, fromState, toState, easingObject) {
|
13168 | sanitizeObjectForHexProps(currentState);
|
13169 | sanitizeObjectForHexProps(fromState);
|
13170 | sanitizeObjectForHexProps(toState);
|
13171 | this._tokenData = getFormatManifests(currentState);
|
13172 | },
|
13173 |
|
13174 | 'beforeTween': function (currentState, fromState, toState, easingObject) {
|
13175 | expandEasingObject(easingObject, this._tokenData);
|
13176 | expandFormattedProperties(currentState, this._tokenData);
|
13177 | expandFormattedProperties(fromState, this._tokenData);
|
13178 | expandFormattedProperties(toState, this._tokenData);
|
13179 | },
|
13180 |
|
13181 | 'afterTween': function (currentState, fromState, toState, easingObject) {
|
13182 | collapseFormattedProperties(currentState, this._tokenData);
|
13183 | collapseFormattedProperties(fromState, this._tokenData);
|
13184 | collapseFormattedProperties(toState, this._tokenData);
|
13185 | collapseEasingObject(easingObject, this._tokenData);
|
13186 | }
|
13187 | };
|
13188 |
|
13189 | } (NGTweenable));
|
13190 |
|
13191 | }).call(null);
|
13192 |
|
13193 |
|
13194 |
|
13195 |
|
13196 |
|
13197 |
|
13198 |
|
13199 |
|
13200 |
|
13201 |
|
13202 |
|
13203 |
|
13204 |
|
13205 |
|
13206 |
|
13207 |
|
13208 |
|
13209 |
|
13210 |
|
13211 |
|
13212 |
|
13213 |
|
13214 |
|
13215 | (function(window, document, exportName, undefined) {
|
13216 | 'use strict';
|
13217 |
|
13218 | var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
|
13219 | var TEST_ELEMENT = document.createElement('div');
|
13220 |
|
13221 | var TYPE_FUNCTION = 'function';
|
13222 |
|
13223 | var round = Math.round;
|
13224 | var abs = Math.abs;
|
13225 | var now = Date.now;
|
13226 |
|
13227 |
|
13228 |
|
13229 |
|
13230 |
|
13231 |
|
13232 |
|
13233 |
|
13234 | function setTimeoutContext(fn, timeout, context) {
|
13235 | return setTimeout(bindFn(fn, context), timeout);
|
13236 | }
|
13237 |
|
13238 |
|
13239 |
|
13240 |
|
13241 |
|
13242 |
|
13243 |
|
13244 |
|
13245 |
|
13246 |
|
13247 | function invokeArrayArg(arg, fn, context) {
|
13248 | if (Array.isArray(arg)) {
|
13249 | each(arg, context[fn], context);
|
13250 | return true;
|
13251 | }
|
13252 | return false;
|
13253 | }
|
13254 |
|
13255 |
|
13256 |
|
13257 |
|
13258 |
|
13259 |
|
13260 |
|
13261 | function each(obj, iterator, context) {
|
13262 | var i;
|
13263 |
|
13264 | if (!obj) {
|
13265 | return;
|
13266 | }
|
13267 |
|
13268 | if (obj.forEach) {
|
13269 | obj.forEach(iterator, context);
|
13270 | } else if (obj.length !== undefined) {
|
13271 | i = 0;
|
13272 | while (i < obj.length) {
|
13273 | iterator.call(context, obj[i], i, obj);
|
13274 | i++;
|
13275 | }
|
13276 | } else {
|
13277 | for (i in obj) {
|
13278 | obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
|
13279 | }
|
13280 | }
|
13281 | }
|
13282 |
|
13283 |
|
13284 |
|
13285 |
|
13286 |
|
13287 |
|
13288 |
|
13289 |
|
13290 | function deprecate(method, name, message) {
|
13291 | var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
|
13292 | return function() {
|
13293 | var e = new Error('get-stack-trace');
|
13294 | var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '')
|
13295 | .replace(/^\s+at\s+/gm, '')
|
13296 | .replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';
|
13297 |
|
13298 | var log = window.console && (window.console.warn || window.console.log);
|
13299 | if (log) {
|
13300 | log.call(window.console, deprecationMessage, stack);
|
13301 | }
|
13302 | return method.apply(this, arguments);
|
13303 | };
|
13304 | }
|
13305 |
|
13306 |
|
13307 |
|
13308 |
|
13309 |
|
13310 |
|
13311 |
|
13312 |
|
13313 | var assign;
|
13314 | if (typeof Object.assign !== 'function') {
|
13315 | assign = function assign(target) {
|
13316 | if (target === undefined || target === null) {
|
13317 | throw new TypeError('Cannot convert undefined or null to object');
|
13318 | }
|
13319 |
|
13320 | var output = Object(target);
|
13321 | for (var index = 1; index < arguments.length; index++) {
|
13322 | var source = arguments[index];
|
13323 | if (source !== undefined && source !== null) {
|
13324 | for (var nextKey in source) {
|
13325 | if (source.hasOwnProperty(nextKey)) {
|
13326 | output[nextKey] = source[nextKey];
|
13327 | }
|
13328 | }
|
13329 | }
|
13330 | }
|
13331 | return output;
|
13332 | };
|
13333 | } else {
|
13334 | assign = Object.assign;
|
13335 | }
|
13336 |
|
13337 |
|
13338 |
|
13339 |
|
13340 |
|
13341 |
|
13342 |
|
13343 |
|
13344 |
|
13345 | var extend = deprecate(function extend(dest, src, merge) {
|
13346 | var keys = Object.keys(src);
|
13347 | var i = 0;
|
13348 | while (i < keys.length) {
|
13349 | if (!merge || (merge && dest[keys[i]] === undefined)) {
|
13350 | dest[keys[i]] = src[keys[i]];
|
13351 | }
|
13352 | i++;
|
13353 | }
|
13354 | return dest;
|
13355 | }, 'extend', 'Use `assign`.');
|
13356 |
|
13357 |
|
13358 |
|
13359 |
|
13360 |
|
13361 |
|
13362 |
|
13363 |
|
13364 | var merge = deprecate(function merge(dest, src) {
|
13365 | return extend(dest, src, true);
|
13366 | }, 'merge', 'Use `assign`.');
|
13367 |
|
13368 |
|
13369 |
|
13370 |
|
13371 |
|
13372 |
|
13373 |
|
13374 | function inherit(child, base, properties) {
|
13375 | var baseP = base.prototype,
|
13376 | childP;
|
13377 |
|
13378 | childP = child.prototype = Object.create(baseP);
|
13379 | childP.constructor = child;
|
13380 | childP._super = baseP;
|
13381 |
|
13382 | if (properties) {
|
13383 | assign(childP, properties);
|
13384 | }
|
13385 | }
|
13386 |
|
13387 |
|
13388 |
|
13389 |
|
13390 |
|
13391 |
|
13392 |
|
13393 | function bindFn(fn, context) {
|
13394 | return function boundFn() {
|
13395 | return fn.apply(context, arguments);
|
13396 | };
|
13397 | }
|
13398 |
|
13399 |
|
13400 |
|
13401 |
|
13402 |
|
13403 |
|
13404 |
|
13405 |
|
13406 | function boolOrFn(val, args) {
|
13407 | if (typeof val == TYPE_FUNCTION) {
|
13408 | return val.apply(args ? args[0] || undefined : undefined, args);
|
13409 | }
|
13410 | return val;
|
13411 | }
|
13412 |
|
13413 |
|
13414 |
|
13415 |
|
13416 |
|
13417 |
|
13418 |
|
13419 | function ifUndefined(val1, val2) {
|
13420 | return (val1 === undefined) ? val2 : val1;
|
13421 | }
|
13422 |
|
13423 |
|
13424 |
|
13425 |
|
13426 |
|
13427 |
|
13428 |
|
13429 | function addEventListeners(target, types, handler) {
|
13430 | each(splitStr(types), function(type) {
|
13431 | target.addEventListener(type, handler, false);
|
13432 | });
|
13433 | }
|
13434 |
|
13435 |
|
13436 |
|
13437 |
|
13438 |
|
13439 |
|
13440 |
|
13441 | function removeEventListeners(target, types, handler) {
|
13442 | each(splitStr(types), function(type) {
|
13443 | target.removeEventListener(type, handler, false);
|
13444 | });
|
13445 | }
|
13446 |
|
13447 |
|
13448 |
|
13449 |
|
13450 |
|
13451 |
|
13452 |
|
13453 |
|
13454 | function hasParent(node, parent) {
|
13455 | while (node) {
|
13456 | if (node == parent) {
|
13457 | return true;
|
13458 | }
|
13459 | node = node.parentNode;
|
13460 | }
|
13461 | return false;
|
13462 | }
|
13463 |
|
13464 |
|
13465 |
|
13466 |
|
13467 |
|
13468 |
|
13469 |
|
13470 | function inStr(str, find) {
|
13471 | return str.indexOf(find) > -1;
|
13472 | }
|
13473 |
|
13474 |
|
13475 |
|
13476 |
|
13477 |
|
13478 |
|
13479 | function splitStr(str) {
|
13480 | return str.trim().split(/\s+/g);
|
13481 | }
|
13482 |
|
13483 |
|
13484 |
|
13485 |
|
13486 |
|
13487 |
|
13488 |
|
13489 |
|
13490 | function inArray(src, find, findByKey) {
|
13491 | if (src.indexOf && !findByKey) {
|
13492 | return src.indexOf(find);
|
13493 | } else {
|
13494 | var i = 0;
|
13495 | while (i < src.length) {
|
13496 | if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
|
13497 | return i;
|
13498 | }
|
13499 | i++;
|
13500 | }
|
13501 | return -1;
|
13502 | }
|
13503 | }
|
13504 |
|
13505 |
|
13506 |
|
13507 |
|
13508 |
|
13509 |
|
13510 | function toArray(obj) {
|
13511 | return Array.prototype.slice.call(obj, 0);
|
13512 | }
|
13513 |
|
13514 |
|
13515 |
|
13516 |
|
13517 |
|
13518 |
|
13519 |
|
13520 |
|
13521 | function uniqueArray(src, key, sort) {
|
13522 | var results = [];
|
13523 | var values = [];
|
13524 | var i = 0;
|
13525 |
|
13526 | while (i < src.length) {
|
13527 | var val = key ? src[i][key] : src[i];
|
13528 | if (inArray(values, val) < 0) {
|
13529 | results.push(src[i]);
|
13530 | }
|
13531 | values[i] = val;
|
13532 | i++;
|
13533 | }
|
13534 |
|
13535 | if (sort) {
|
13536 | if (!key) {
|
13537 | results = results.sort();
|
13538 | } else {
|
13539 | results = results.sort(function sortUniqueArray(a, b) {
|
13540 | return a[key] > b[key];
|
13541 | });
|
13542 | }
|
13543 | }
|
13544 |
|
13545 | return results;
|
13546 | }
|
13547 |
|
13548 |
|
13549 |
|
13550 |
|
13551 |
|
13552 |
|
13553 |
|
13554 | function prefixed(obj, property) {
|
13555 | var prefix, prop;
|
13556 | var camelProp = property[0].toUpperCase() + property.slice(1);
|
13557 |
|
13558 | var i = 0;
|
13559 | while (i < VENDOR_PREFIXES.length) {
|
13560 | prefix = VENDOR_PREFIXES[i];
|
13561 | prop = (prefix) ? prefix + camelProp : property;
|
13562 |
|
13563 | if (prop in obj) {
|
13564 | return prop;
|
13565 | }
|
13566 | i++;
|
13567 | }
|
13568 | return undefined;
|
13569 | }
|
13570 |
|
13571 |
|
13572 |
|
13573 |
|
13574 |
|
13575 | var _uniqueId = 1;
|
13576 | function uniqueId() {
|
13577 | return _uniqueId++;
|
13578 | }
|
13579 |
|
13580 |
|
13581 |
|
13582 |
|
13583 |
|
13584 |
|
13585 | function getWindowForElement(element) {
|
13586 | var doc = element.ownerDocument || element;
|
13587 | return (doc.defaultView || doc.parentWindow || window);
|
13588 | }
|
13589 |
|
13590 | var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
13591 |
|
13592 | var SUPPORT_TOUCH = ('ontouchstart' in window);
|
13593 |
|
13594 | var SUPPORT_POINTER_EVENTS = false;
|
13595 | var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
13596 |
|
13597 | var INPUT_TYPE_TOUCH = 'touch';
|
13598 | var INPUT_TYPE_PEN = 'pen';
|
13599 | var INPUT_TYPE_MOUSE = 'mouse';
|
13600 | var INPUT_TYPE_KINECT = 'kinect';
|
13601 |
|
13602 | var COMPUTE_INTERVAL = 25;
|
13603 |
|
13604 | var INPUT_START = 1;
|
13605 | var INPUT_MOVE = 2;
|
13606 | var INPUT_END = 4;
|
13607 | var INPUT_CANCEL = 8;
|
13608 |
|
13609 | var DIRECTION_NONE = 1;
|
13610 | var DIRECTION_LEFT = 2;
|
13611 | var DIRECTION_RIGHT = 4;
|
13612 | var DIRECTION_UP = 8;
|
13613 | var DIRECTION_DOWN = 16;
|
13614 |
|
13615 | var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
13616 | var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
13617 | var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
13618 |
|
13619 | var PROPS_XY = ['x', 'y'];
|
13620 | var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
13621 |
|
13622 |
|
13623 |
|
13624 |
|
13625 |
|
13626 |
|
13627 |
|
13628 |
|
13629 | function Input(manager, callback) {
|
13630 | var self = this;
|
13631 | this.manager = manager;
|
13632 | this.callback = callback;
|
13633 | this.element = manager.element;
|
13634 | this.target = manager.options.inputTarget;
|
13635 |
|
13636 |
|
13637 |
|
13638 | this.domHandler = function(ev) {
|
13639 | if (boolOrFn(manager.options.enable, [manager])) {
|
13640 | self.handler(ev);
|
13641 | }
|
13642 | };
|
13643 |
|
13644 | this.init();
|
13645 |
|
13646 | }
|
13647 |
|
13648 | Input.prototype = {
|
13649 | |
13650 |
|
13651 |
|
13652 |
|
13653 | handler: function() { },
|
13654 |
|
13655 | |
13656 |
|
13657 |
|
13658 | init: function() {
|
13659 | this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
|
13660 | this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
|
13661 | this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
13662 | },
|
13663 |
|
13664 | |
13665 |
|
13666 |
|
13667 | destroy: function() {
|
13668 | this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
|
13669 | this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
13670 | this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
13671 | }
|
13672 | };
|
13673 |
|
13674 |
|
13675 |
|
13676 |
|
13677 |
|
13678 |
|
13679 |
|
13680 | function createInputInstance(manager) {
|
13681 | var Type;
|
13682 | var inputClass = manager.options.inputClass;
|
13683 |
|
13684 | if (inputClass) {
|
13685 | Type = inputClass;
|
13686 | } else if (SUPPORT_POINTER_EVENTS) {
|
13687 | Type = PointerEventInput;
|
13688 | } else if (SUPPORT_ONLY_TOUCH) {
|
13689 | Type = TouchInput;
|
13690 | } else if (!SUPPORT_TOUCH) {
|
13691 | Type = MouseInput;
|
13692 | } else {
|
13693 | Type = TouchMouseInput;
|
13694 | }
|
13695 | return new (Type)(manager, inputHandler);
|
13696 | }
|
13697 |
|
13698 |
|
13699 |
|
13700 |
|
13701 |
|
13702 |
|
13703 |
|
13704 | function inputHandler(manager, eventType, input) {
|
13705 | var pointersLen = input.pointers.length;
|
13706 | var changedPointersLen = input.changedPointers.length;
|
13707 | var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
|
13708 | var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - changedPointersLen === 0));
|
13709 |
|
13710 | input.isFirst = !!isFirst;
|
13711 | input.isFinal = !!isFinal;
|
13712 |
|
13713 | if (isFirst) {
|
13714 | manager.session = {};
|
13715 | }
|
13716 |
|
13717 |
|
13718 |
|
13719 | input.eventType = eventType;
|
13720 |
|
13721 |
|
13722 | computeInputData(manager, input);
|
13723 |
|
13724 |
|
13725 | manager.emit('hammer.input', input);
|
13726 |
|
13727 | manager.recognize(input);
|
13728 | manager.session.prevInput = input;
|
13729 | }
|
13730 |
|
13731 |
|
13732 |
|
13733 |
|
13734 |
|
13735 |
|
13736 | function computeInputData(manager, input) {
|
13737 | var session = manager.session;
|
13738 | var pointers = input.pointers;
|
13739 | var pointersLength = pointers.length;
|
13740 |
|
13741 |
|
13742 | if (!session.firstInput) {
|
13743 | session.firstInput = simpleCloneInputData(input);
|
13744 | }
|
13745 |
|
13746 |
|
13747 | if (pointersLength > 1 && !session.firstMultiple) {
|
13748 | session.firstMultiple = simpleCloneInputData(input);
|
13749 | } else if (pointersLength === 1) {
|
13750 | session.firstMultiple = false;
|
13751 | }
|
13752 |
|
13753 | var firstInput = session.firstInput;
|
13754 | var firstMultiple = session.firstMultiple;
|
13755 | var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
|
13756 |
|
13757 | var center = input.center = getCenter(pointers);
|
13758 | input.timeStamp = now();
|
13759 | input.deltaTime = input.timeStamp - firstInput.timeStamp;
|
13760 |
|
13761 | input.angle = getAngle(offsetCenter, center);
|
13762 | input.distance = getDistance(offsetCenter, center);
|
13763 |
|
13764 | computeDeltaXY(session, input);
|
13765 | input.offsetDirection = getDirection(input.deltaX, input.deltaY);
|
13766 |
|
13767 | var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
|
13768 | input.overallVelocityX = overallVelocity.x;
|
13769 | input.overallVelocityY = overallVelocity.y;
|
13770 | input.overallVelocity = (abs(overallVelocity.x) > abs(overallVelocity.y)) ? overallVelocity.x : overallVelocity.y;
|
13771 |
|
13772 | input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
|
13773 | input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
|
13774 |
|
13775 | input.maxPointers = !session.prevInput ? input.pointers.length : ((input.pointers.length >
|
13776 | session.prevInput.maxPointers) ? input.pointers.length : session.prevInput.maxPointers);
|
13777 |
|
13778 | computeIntervalInputData(session, input);
|
13779 |
|
13780 |
|
13781 | var target = manager.element;
|
13782 | if (hasParent(input.srcEvent.target, target)) {
|
13783 | target = input.srcEvent.target;
|
13784 | }
|
13785 | input.target = target;
|
13786 | }
|
13787 |
|
13788 | function computeDeltaXY(session, input) {
|
13789 | var center = input.center;
|
13790 | var offset = session.offsetDelta || {};
|
13791 | var prevDelta = session.prevDelta || {};
|
13792 | var prevInput = session.prevInput || {};
|
13793 |
|
13794 | if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
|
13795 | prevDelta = session.prevDelta = {
|
13796 | x: prevInput.deltaX || 0,
|
13797 | y: prevInput.deltaY || 0
|
13798 | };
|
13799 |
|
13800 | offset = session.offsetDelta = {
|
13801 | x: center.x,
|
13802 | y: center.y
|
13803 | };
|
13804 | }
|
13805 |
|
13806 | input.deltaX = prevDelta.x + (center.x - offset.x);
|
13807 | input.deltaY = prevDelta.y + (center.y - offset.y);
|
13808 | }
|
13809 |
|
13810 |
|
13811 |
|
13812 |
|
13813 |
|
13814 |
|
13815 | function computeIntervalInputData(session, input) {
|
13816 | var last = session.lastInterval || input,
|
13817 | deltaTime = input.timeStamp - last.timeStamp,
|
13818 | velocity, velocityX, velocityY, direction;
|
13819 |
|
13820 | if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
|
13821 | var deltaX = input.deltaX - last.deltaX;
|
13822 | var deltaY = input.deltaY - last.deltaY;
|
13823 |
|
13824 | var v = getVelocity(deltaTime, deltaX, deltaY);
|
13825 | velocityX = v.x;
|
13826 | velocityY = v.y;
|
13827 | velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
|
13828 | direction = getDirection(deltaX, deltaY);
|
13829 |
|
13830 | session.lastInterval = input;
|
13831 | } else {
|
13832 |
|
13833 | velocity = last.velocity;
|
13834 | velocityX = last.velocityX;
|
13835 | velocityY = last.velocityY;
|
13836 | direction = last.direction;
|
13837 | }
|
13838 |
|
13839 | input.velocity = velocity;
|
13840 | input.velocityX = velocityX;
|
13841 | input.velocityY = velocityY;
|
13842 | input.direction = direction;
|
13843 | }
|
13844 |
|
13845 |
|
13846 |
|
13847 |
|
13848 |
|
13849 |
|
13850 | function simpleCloneInputData(input) {
|
13851 |
|
13852 |
|
13853 | var pointers = [];
|
13854 | var i = 0;
|
13855 | while (i < input.pointers.length) {
|
13856 | pointers[i] = {
|
13857 | clientX: round(input.pointers[i].clientX),
|
13858 | clientY: round(input.pointers[i].clientY)
|
13859 | };
|
13860 | i++;
|
13861 | }
|
13862 |
|
13863 | return {
|
13864 | timeStamp: now(),
|
13865 | pointers: pointers,
|
13866 | center: getCenter(pointers),
|
13867 | deltaX: input.deltaX,
|
13868 | deltaY: input.deltaY
|
13869 | };
|
13870 | }
|
13871 |
|
13872 |
|
13873 |
|
13874 |
|
13875 |
|
13876 |
|
13877 | function getCenter(pointers) {
|
13878 | var pointersLength = pointers.length;
|
13879 |
|
13880 |
|
13881 | if (pointersLength === 1) {
|
13882 | return {
|
13883 | x: round(pointers[0].clientX),
|
13884 | y: round(pointers[0].clientY)
|
13885 | };
|
13886 | }
|
13887 |
|
13888 | var x = 0, y = 0, i = 0;
|
13889 | while (i < pointersLength) {
|
13890 | x += pointers[i].clientX;
|
13891 | y += pointers[i].clientY;
|
13892 | i++;
|
13893 | }
|
13894 |
|
13895 | return {
|
13896 | x: round(x / pointersLength),
|
13897 | y: round(y / pointersLength)
|
13898 | };
|
13899 | }
|
13900 |
|
13901 |
|
13902 |
|
13903 |
|
13904 |
|
13905 |
|
13906 |
|
13907 |
|
13908 | function getVelocity(deltaTime, x, y) {
|
13909 | return {
|
13910 | x: x / deltaTime || 0,
|
13911 | y: y / deltaTime || 0
|
13912 | };
|
13913 | }
|
13914 |
|
13915 |
|
13916 |
|
13917 |
|
13918 |
|
13919 |
|
13920 |
|
13921 | function getDirection(x, y) {
|
13922 | if (x === y) {
|
13923 | return DIRECTION_NONE;
|
13924 | }
|
13925 |
|
13926 | if (abs(x) >= abs(y)) {
|
13927 | return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
13928 | }
|
13929 | return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
13930 | }
|
13931 |
|
13932 |
|
13933 |
|
13934 |
|
13935 |
|
13936 |
|
13937 |
|
13938 |
|
13939 | function getDistance(p1, p2, props) {
|
13940 | if (!props) {
|
13941 | props = PROPS_XY;
|
13942 | }
|
13943 | var x = p2[props[0]] - p1[props[0]],
|
13944 | y = p2[props[1]] - p1[props[1]];
|
13945 |
|
13946 | return Math.sqrt((x * x) + (y * y));
|
13947 | }
|
13948 |
|
13949 |
|
13950 |
|
13951 |
|
13952 |
|
13953 |
|
13954 |
|
13955 |
|
13956 | function getAngle(p1, p2, props) {
|
13957 | if (!props) {
|
13958 | props = PROPS_XY;
|
13959 | }
|
13960 | var x = p2[props[0]] - p1[props[0]],
|
13961 | y = p2[props[1]] - p1[props[1]];
|
13962 | return Math.atan2(y, x) * 180 / Math.PI;
|
13963 | }
|
13964 |
|
13965 |
|
13966 |
|
13967 |
|
13968 |
|
13969 |
|
13970 |
|
13971 | function getRotation(start, end) {
|
13972 | return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
13973 | }
|
13974 |
|
13975 |
|
13976 |
|
13977 |
|
13978 |
|
13979 |
|
13980 |
|
13981 |
|
13982 | function getScale(start, end) {
|
13983 | return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
13984 | }
|
13985 |
|
13986 | var MOUSE_INPUT_MAP = {
|
13987 | mousedown: INPUT_START,
|
13988 | mousemove: INPUT_MOVE,
|
13989 | mouseup: INPUT_END
|
13990 | };
|
13991 |
|
13992 | var MOUSE_ELEMENT_EVENTS = 'mousedown';
|
13993 | var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
|
13994 |
|
13995 |
|
13996 |
|
13997 |
|
13998 |
|
13999 |
|
14000 | function MouseInput() {
|
14001 | this.evEl = MOUSE_ELEMENT_EVENTS;
|
14002 | this.evWin = MOUSE_WINDOW_EVENTS;
|
14003 |
|
14004 | this.pressed = false;
|
14005 |
|
14006 | Input.apply(this, arguments);
|
14007 | }
|
14008 |
|
14009 | inherit(MouseInput, Input, {
|
14010 | |
14011 |
|
14012 |
|
14013 |
|
14014 | handler: function MEhandler(ev) {
|
14015 | var eventType = MOUSE_INPUT_MAP[ev.type];
|
14016 |
|
14017 |
|
14018 | if (eventType & INPUT_START && ev.button === 0) {
|
14019 | this.pressed = true;
|
14020 | }
|
14021 |
|
14022 | if (eventType & INPUT_MOVE && ev.which !== 1) {
|
14023 | eventType = INPUT_END;
|
14024 | }
|
14025 |
|
14026 |
|
14027 | if (!this.pressed) {
|
14028 | return;
|
14029 | }
|
14030 |
|
14031 | if (eventType & INPUT_END) {
|
14032 | this.pressed = false;
|
14033 | }
|
14034 |
|
14035 | this.callback(this.manager, eventType, {
|
14036 | pointers: [ev],
|
14037 | changedPointers: [ev],
|
14038 | pointerType: INPUT_TYPE_MOUSE,
|
14039 | srcEvent: ev
|
14040 | });
|
14041 | }
|
14042 | });
|
14043 |
|
14044 | var POINTER_INPUT_MAP = {
|
14045 | pointerdown: INPUT_START,
|
14046 | pointermove: INPUT_MOVE,
|
14047 | pointerup: INPUT_END,
|
14048 | pointercancel: INPUT_CANCEL,
|
14049 | pointerout: INPUT_CANCEL
|
14050 | };
|
14051 |
|
14052 |
|
14053 | var IE10_POINTER_TYPE_ENUM = {
|
14054 | 2: INPUT_TYPE_TOUCH,
|
14055 | 3: INPUT_TYPE_PEN,
|
14056 | 4: INPUT_TYPE_MOUSE,
|
14057 | 5: INPUT_TYPE_KINECT
|
14058 | };
|
14059 |
|
14060 | var POINTER_ELEMENT_EVENTS = 'pointerdown';
|
14061 | var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
|
14062 |
|
14063 |
|
14064 | if (window.MSPointerEvent && !window.PointerEvent) {
|
14065 | POINTER_ELEMENT_EVENTS = 'MSPointerDown';
|
14066 | POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
|
14067 | }
|
14068 |
|
14069 |
|
14070 |
|
14071 |
|
14072 |
|
14073 |
|
14074 | function PointerEventInput() {
|
14075 | this.evEl = POINTER_ELEMENT_EVENTS;
|
14076 | this.evWin = POINTER_WINDOW_EVENTS;
|
14077 |
|
14078 | Input.apply(this, arguments);
|
14079 |
|
14080 | this.store = (this.manager.session.pointerEvents = []);
|
14081 | }
|
14082 |
|
14083 | inherit(PointerEventInput, Input, {
|
14084 | |
14085 |
|
14086 |
|
14087 |
|
14088 | handler: function PEhandler(ev) {
|
14089 | var store = this.store;
|
14090 | var removePointer = false;
|
14091 |
|
14092 | var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
|
14093 | var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
|
14094 | var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
|
14095 |
|
14096 | var isTouch = (pointerType == INPUT_TYPE_TOUCH);
|
14097 |
|
14098 |
|
14099 | var storeIndex = inArray(store, ev.pointerId, 'pointerId');
|
14100 |
|
14101 |
|
14102 | if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
|
14103 | if (storeIndex < 0) {
|
14104 | store.push(ev);
|
14105 | storeIndex = store.length - 1;
|
14106 | }
|
14107 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
14108 | removePointer = true;
|
14109 | }
|
14110 |
|
14111 |
|
14112 | if (storeIndex < 0) {
|
14113 | return;
|
14114 | }
|
14115 |
|
14116 |
|
14117 | store[storeIndex] = ev;
|
14118 |
|
14119 | this.callback(this.manager, eventType, {
|
14120 | pointers: store,
|
14121 | changedPointers: [ev],
|
14122 | pointerType: pointerType,
|
14123 | srcEvent: ev
|
14124 | });
|
14125 |
|
14126 | if (removePointer) {
|
14127 |
|
14128 | store.splice(storeIndex, 1);
|
14129 | }
|
14130 | }
|
14131 | });
|
14132 |
|
14133 | var SINGLE_TOUCH_INPUT_MAP = {
|
14134 | touchstart: INPUT_START,
|
14135 | touchmove: INPUT_MOVE,
|
14136 | touchend: INPUT_END,
|
14137 | touchcancel: INPUT_CANCEL
|
14138 | };
|
14139 |
|
14140 | var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
|
14141 | var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
|
14142 |
|
14143 |
|
14144 |
|
14145 |
|
14146 |
|
14147 |
|
14148 | function SingleTouchInput() {
|
14149 | this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
14150 | this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
14151 | this.started = false;
|
14152 |
|
14153 | Input.apply(this, arguments);
|
14154 | }
|
14155 |
|
14156 | inherit(SingleTouchInput, Input, {
|
14157 | handler: function TEhandler(ev) {
|
14158 | var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
14159 |
|
14160 |
|
14161 | if (type === INPUT_START) {
|
14162 | this.started = true;
|
14163 | }
|
14164 |
|
14165 | if (!this.started) {
|
14166 | return;
|
14167 | }
|
14168 |
|
14169 | var touches = normalizeSingleTouches.call(this, ev, type);
|
14170 |
|
14171 |
|
14172 | if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
|
14173 | this.started = false;
|
14174 | }
|
14175 |
|
14176 | this.callback(this.manager, type, {
|
14177 | pointers: touches[0],
|
14178 | changedPointers: touches[1],
|
14179 | pointerType: INPUT_TYPE_TOUCH,
|
14180 | srcEvent: ev
|
14181 | });
|
14182 | }
|
14183 | });
|
14184 |
|
14185 |
|
14186 |
|
14187 |
|
14188 |
|
14189 |
|
14190 |
|
14191 | function normalizeSingleTouches(ev, type) {
|
14192 | var all = toArray(ev.touches);
|
14193 | var changed = toArray(ev.changedTouches);
|
14194 |
|
14195 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
14196 | all = uniqueArray(all.concat(changed), 'identifier', true);
|
14197 | }
|
14198 |
|
14199 | return [all, changed];
|
14200 | }
|
14201 |
|
14202 | var TOUCH_INPUT_MAP = {
|
14203 | touchstart: INPUT_START,
|
14204 | touchmove: INPUT_MOVE,
|
14205 | touchend: INPUT_END,
|
14206 | touchcancel: INPUT_CANCEL
|
14207 | };
|
14208 |
|
14209 | var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
14210 |
|
14211 |
|
14212 |
|
14213 |
|
14214 |
|
14215 |
|
14216 | function TouchInput() {
|
14217 | this.evTarget = TOUCH_TARGET_EVENTS;
|
14218 | this.targetIds = {};
|
14219 |
|
14220 | Input.apply(this, arguments);
|
14221 | }
|
14222 |
|
14223 | inherit(TouchInput, Input, {
|
14224 | handler: function MTEhandler(ev) {
|
14225 | var type = TOUCH_INPUT_MAP[ev.type];
|
14226 | var touches = getTouches.call(this, ev, type);
|
14227 | if (!touches) {
|
14228 | return;
|
14229 | }
|
14230 |
|
14231 | this.callback(this.manager, type, {
|
14232 | pointers: touches[0],
|
14233 | changedPointers: touches[1],
|
14234 | pointerType: INPUT_TYPE_TOUCH,
|
14235 | srcEvent: ev
|
14236 | });
|
14237 | }
|
14238 | });
|
14239 |
|
14240 |
|
14241 |
|
14242 |
|
14243 |
|
14244 |
|
14245 |
|
14246 | function getTouches(ev, type) {
|
14247 | var allTouches = toArray(ev.touches);
|
14248 | var targetIds = this.targetIds;
|
14249 |
|
14250 |
|
14251 | if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
|
14252 | targetIds[allTouches[0].identifier] = true;
|
14253 | return [allTouches, allTouches];
|
14254 | }
|
14255 |
|
14256 | var i,
|
14257 | targetTouches,
|
14258 | changedTouches = toArray(ev.changedTouches),
|
14259 | changedTargetTouches = [],
|
14260 | target = this.target;
|
14261 |
|
14262 |
|
14263 | targetTouches = allTouches.filter(function(touch) {
|
14264 | return hasParent(touch.target, target);
|
14265 | });
|
14266 |
|
14267 |
|
14268 | if (type === INPUT_START) {
|
14269 | i = 0;
|
14270 | while (i < targetTouches.length) {
|
14271 | targetIds[targetTouches[i].identifier] = true;
|
14272 | i++;
|
14273 | }
|
14274 | }
|
14275 |
|
14276 |
|
14277 | i = 0;
|
14278 | while (i < changedTouches.length) {
|
14279 | if (targetIds[changedTouches[i].identifier]) {
|
14280 | changedTargetTouches.push(changedTouches[i]);
|
14281 | }
|
14282 |
|
14283 |
|
14284 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
14285 | delete targetIds[changedTouches[i].identifier];
|
14286 | }
|
14287 | i++;
|
14288 | }
|
14289 |
|
14290 | if (!changedTargetTouches.length) {
|
14291 | return;
|
14292 | }
|
14293 |
|
14294 | return [
|
14295 |
|
14296 | uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
|
14297 | changedTargetTouches
|
14298 | ];
|
14299 | }
|
14300 |
|
14301 |
|
14302 |
|
14303 |
|
14304 |
|
14305 |
|
14306 |
|
14307 |
|
14308 |
|
14309 |
|
14310 |
|
14311 | var DEDUP_TIMEOUT = 2500;
|
14312 | var DEDUP_DISTANCE = 25;
|
14313 |
|
14314 | function TouchMouseInput() {
|
14315 | Input.apply(this, arguments);
|
14316 |
|
14317 | var handler = bindFn(this.handler, this);
|
14318 | this.touch = new TouchInput(this.manager, handler);
|
14319 | this.mouse = new MouseInput(this.manager, handler);
|
14320 |
|
14321 | this.primaryTouch = null;
|
14322 | this.lastTouches = [];
|
14323 | }
|
14324 |
|
14325 | inherit(TouchMouseInput, Input, {
|
14326 | |
14327 |
|
14328 |
|
14329 |
|
14330 |
|
14331 |
|
14332 | handler: function TMEhandler(manager, inputEvent, inputData) {
|
14333 | var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
|
14334 | isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
|
14335 |
|
14336 | if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
|
14337 | return;
|
14338 | }
|
14339 |
|
14340 |
|
14341 | if (isTouch) {
|
14342 | recordTouches.call(this, inputEvent, inputData);
|
14343 | } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
|
14344 | return;
|
14345 | }
|
14346 |
|
14347 | this.callback(manager, inputEvent, inputData);
|
14348 | },
|
14349 |
|
14350 | |
14351 |
|
14352 |
|
14353 | destroy: function destroy() {
|
14354 | this.touch.destroy();
|
14355 | this.mouse.destroy();
|
14356 | }
|
14357 | });
|
14358 |
|
14359 | function recordTouches(eventType, eventData) {
|
14360 | if (eventType & INPUT_START) {
|
14361 | this.primaryTouch = eventData.changedPointers[0].identifier;
|
14362 | setLastTouch.call(this, eventData);
|
14363 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
14364 | setLastTouch.call(this, eventData);
|
14365 | }
|
14366 | }
|
14367 |
|
14368 | function setLastTouch(eventData) {
|
14369 | var touch = eventData.changedPointers[0];
|
14370 |
|
14371 | if (touch.identifier === this.primaryTouch) {
|
14372 | var lastTouch = {x: touch.clientX, y: touch.clientY};
|
14373 | this.lastTouches.push(lastTouch);
|
14374 | var lts = this.lastTouches;
|
14375 | var removeLastTouch = function() {
|
14376 | var i = lts.indexOf(lastTouch);
|
14377 | if (i > -1) {
|
14378 | lts.splice(i, 1);
|
14379 | }
|
14380 | };
|
14381 | setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
14382 | }
|
14383 | }
|
14384 |
|
14385 | function isSyntheticEvent(eventData) {
|
14386 | var x = eventData.srcEvent.clientX, y = eventData.srcEvent.clientY;
|
14387 | for (var i = 0; i < this.lastTouches.length; i++) {
|
14388 | var t = this.lastTouches[i];
|
14389 | var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y);
|
14390 | if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
|
14391 | return true;
|
14392 | }
|
14393 | }
|
14394 | return false;
|
14395 | }
|
14396 |
|
14397 | var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
|
14398 | var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
|
14399 |
|
14400 |
|
14401 | var TOUCH_ACTION_COMPUTE = 'compute';
|
14402 | var TOUCH_ACTION_AUTO = 'auto';
|
14403 | var TOUCH_ACTION_MANIPULATION = 'manipulation';
|
14404 | var TOUCH_ACTION_NONE = 'none';
|
14405 | var TOUCH_ACTION_PAN_X = 'pan-x';
|
14406 | var TOUCH_ACTION_PAN_Y = 'pan-y';
|
14407 | var TOUCH_ACTION_MAP = getTouchActionProps();
|
14408 |
|
14409 |
|
14410 |
|
14411 |
|
14412 |
|
14413 |
|
14414 |
|
14415 |
|
14416 | function TouchAction(manager, value) {
|
14417 | this.manager = manager;
|
14418 | this.set(value);
|
14419 | }
|
14420 |
|
14421 | TouchAction.prototype = {
|
14422 | |
14423 |
|
14424 |
|
14425 |
|
14426 | set: function(value) {
|
14427 |
|
14428 | if (value == TOUCH_ACTION_COMPUTE) {
|
14429 | value = this.compute();
|
14430 | }
|
14431 |
|
14432 | if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
|
14433 | this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
|
14434 | }
|
14435 | this.actions = value.toLowerCase().trim();
|
14436 | },
|
14437 |
|
14438 | |
14439 |
|
14440 |
|
14441 | update: function() {
|
14442 | this.set(this.manager.options.touchAction);
|
14443 | },
|
14444 |
|
14445 | |
14446 |
|
14447 |
|
14448 |
|
14449 | compute: function() {
|
14450 | var actions = [];
|
14451 | each(this.manager.recognizers, function(recognizer) {
|
14452 | if (boolOrFn(recognizer.options.enable, [recognizer])) {
|
14453 | actions = actions.concat(recognizer.getTouchAction());
|
14454 | }
|
14455 | });
|
14456 | return cleanTouchActions(actions.join(' '));
|
14457 | },
|
14458 |
|
14459 | |
14460 |
|
14461 |
|
14462 |
|
14463 | preventDefaults: function(input) {
|
14464 | var srcEvent = input.srcEvent;
|
14465 | var direction = input.offsetDirection;
|
14466 |
|
14467 |
|
14468 | if (this.manager.session.prevented) {
|
14469 | srcEvent.preventDefault();
|
14470 | return;
|
14471 | }
|
14472 |
|
14473 | var actions = this.actions;
|
14474 | var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
|
14475 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
|
14476 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
|
14477 |
|
14478 | if (hasNone) {
|
14479 |
|
14480 |
|
14481 | var isTapPointer = input.pointers.length === 1;
|
14482 | var isTapMovement = input.distance < 2;
|
14483 | var isTapTouchTime = input.deltaTime < 250;
|
14484 |
|
14485 | if (isTapPointer && isTapMovement && isTapTouchTime) {
|
14486 | return;
|
14487 | }
|
14488 | }
|
14489 |
|
14490 | if (hasPanX && hasPanY) {
|
14491 |
|
14492 | return;
|
14493 | }
|
14494 |
|
14495 | if (hasNone ||
|
14496 | (hasPanY && direction & DIRECTION_HORIZONTAL) ||
|
14497 | (hasPanX && direction & DIRECTION_VERTICAL)) {
|
14498 | return this.preventSrc(srcEvent);
|
14499 | }
|
14500 | },
|
14501 |
|
14502 | |
14503 |
|
14504 |
|
14505 |
|
14506 | preventSrc: function(srcEvent) {
|
14507 | this.manager.session.prevented = true;
|
14508 | srcEvent.preventDefault();
|
14509 | }
|
14510 | };
|
14511 |
|
14512 |
|
14513 |
|
14514 |
|
14515 |
|
14516 |
|
14517 | function cleanTouchActions(actions) {
|
14518 |
|
14519 | if (inStr(actions, TOUCH_ACTION_NONE)) {
|
14520 | return TOUCH_ACTION_NONE;
|
14521 | }
|
14522 |
|
14523 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
|
14524 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
|
14525 |
|
14526 |
|
14527 |
|
14528 |
|
14529 |
|
14530 | if (hasPanX && hasPanY) {
|
14531 | return TOUCH_ACTION_NONE;
|
14532 | }
|
14533 |
|
14534 |
|
14535 | if (hasPanX || hasPanY) {
|
14536 | return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
|
14537 | }
|
14538 |
|
14539 |
|
14540 | if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
|
14541 | return TOUCH_ACTION_MANIPULATION;
|
14542 | }
|
14543 |
|
14544 | return TOUCH_ACTION_AUTO;
|
14545 | }
|
14546 |
|
14547 | function getTouchActionProps() {
|
14548 | if (!NATIVE_TOUCH_ACTION) {
|
14549 | return false;
|
14550 | }
|
14551 | var touchMap = {};
|
14552 | var cssSupports = window.CSS && window.CSS.supports;
|
14553 | ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function(val) {
|
14554 |
|
14555 |
|
14556 |
|
14557 | touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
|
14558 | });
|
14559 | return touchMap;
|
14560 | }
|
14561 |
|
14562 |
|
14563 |
|
14564 |
|
14565 |
|
14566 |
|
14567 |
|
14568 |
|
14569 |
|
14570 |
|
14571 |
|
14572 |
|
14573 |
|
14574 |
|
14575 |
|
14576 |
|
14577 |
|
14578 |
|
14579 |
|
14580 |
|
14581 |
|
14582 |
|
14583 |
|
14584 |
|
14585 |
|
14586 |
|
14587 |
|
14588 |
|
14589 | var STATE_POSSIBLE = 1;
|
14590 | var STATE_BEGAN = 2;
|
14591 | var STATE_CHANGED = 4;
|
14592 | var STATE_ENDED = 8;
|
14593 | var STATE_RECOGNIZED = STATE_ENDED;
|
14594 | var STATE_CANCELLED = 16;
|
14595 | var STATE_FAILED = 32;
|
14596 |
|
14597 |
|
14598 |
|
14599 |
|
14600 |
|
14601 |
|
14602 |
|
14603 | function Recognizer(options) {
|
14604 | this.options = assign({}, this.defaults, options || {});
|
14605 |
|
14606 | this.id = uniqueId();
|
14607 |
|
14608 | this.manager = null;
|
14609 |
|
14610 |
|
14611 | this.options.enable = ifUndefined(this.options.enable, true);
|
14612 |
|
14613 | this.state = STATE_POSSIBLE;
|
14614 |
|
14615 | this.simultaneous = {};
|
14616 | this.requireFail = [];
|
14617 | }
|
14618 |
|
14619 | Recognizer.prototype = {
|
14620 | |
14621 |
|
14622 |
|
14623 |
|
14624 | defaults: {},
|
14625 |
|
14626 | |
14627 |
|
14628 |
|
14629 |
|
14630 |
|
14631 | set: function(options) {
|
14632 | assign(this.options, options);
|
14633 |
|
14634 |
|
14635 | this.manager && this.manager.touchAction.update();
|
14636 | return this;
|
14637 | },
|
14638 |
|
14639 | |
14640 |
|
14641 |
|
14642 |
|
14643 |
|
14644 | recognizeWith: function(otherRecognizer) {
|
14645 | if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
|
14646 | return this;
|
14647 | }
|
14648 |
|
14649 | var simultaneous = this.simultaneous;
|
14650 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
14651 | if (!simultaneous[otherRecognizer.id]) {
|
14652 | simultaneous[otherRecognizer.id] = otherRecognizer;
|
14653 | otherRecognizer.recognizeWith(this);
|
14654 | }
|
14655 | return this;
|
14656 | },
|
14657 |
|
14658 | |
14659 |
|
14660 |
|
14661 |
|
14662 |
|
14663 | dropRecognizeWith: function(otherRecognizer) {
|
14664 | if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
|
14665 | return this;
|
14666 | }
|
14667 |
|
14668 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
14669 | delete this.simultaneous[otherRecognizer.id];
|
14670 | return this;
|
14671 | },
|
14672 |
|
14673 | |
14674 |
|
14675 |
|
14676 |
|
14677 |
|
14678 | requireFailure: function(otherRecognizer) {
|
14679 | if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
|
14680 | return this;
|
14681 | }
|
14682 |
|
14683 | var requireFail = this.requireFail;
|
14684 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
14685 | if (inArray(requireFail, otherRecognizer) === -1) {
|
14686 | requireFail.push(otherRecognizer);
|
14687 | otherRecognizer.requireFailure(this);
|
14688 | }
|
14689 | return this;
|
14690 | },
|
14691 |
|
14692 | |
14693 |
|
14694 |
|
14695 |
|
14696 |
|
14697 | dropRequireFailure: function(otherRecognizer) {
|
14698 | if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
|
14699 | return this;
|
14700 | }
|
14701 |
|
14702 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
14703 | var index = inArray(this.requireFail, otherRecognizer);
|
14704 | if (index > -1) {
|
14705 | this.requireFail.splice(index, 1);
|
14706 | }
|
14707 | return this;
|
14708 | },
|
14709 |
|
14710 | |
14711 |
|
14712 |
|
14713 |
|
14714 | hasRequireFailures: function() {
|
14715 | return this.requireFail.length > 0;
|
14716 | },
|
14717 |
|
14718 | |
14719 |
|
14720 |
|
14721 |
|
14722 |
|
14723 | canRecognizeWith: function(otherRecognizer) {
|
14724 | return !!this.simultaneous[otherRecognizer.id];
|
14725 | },
|
14726 |
|
14727 | |
14728 |
|
14729 |
|
14730 |
|
14731 |
|
14732 | emit: function(input) {
|
14733 | var self = this;
|
14734 | var state = this.state;
|
14735 |
|
14736 | function emit(event) {
|
14737 | self.manager.emit(event, input);
|
14738 | }
|
14739 |
|
14740 |
|
14741 | if (state < STATE_ENDED) {
|
14742 | emit(self.options.event + stateStr(state));
|
14743 | }
|
14744 |
|
14745 | emit(self.options.event);
|
14746 |
|
14747 | if (input.additionalEvent) {
|
14748 | emit(input.additionalEvent);
|
14749 | }
|
14750 |
|
14751 |
|
14752 | if (state >= STATE_ENDED) {
|
14753 | emit(self.options.event + stateStr(state));
|
14754 | }
|
14755 | },
|
14756 |
|
14757 | |
14758 |
|
14759 |
|
14760 |
|
14761 |
|
14762 |
|
14763 | tryEmit: function(input) {
|
14764 | if (this.canEmit()) {
|
14765 | return this.emit(input);
|
14766 | }
|
14767 |
|
14768 | this.state = STATE_FAILED;
|
14769 | },
|
14770 |
|
14771 | |
14772 |
|
14773 |
|
14774 |
|
14775 | canEmit: function() {
|
14776 | var i = 0;
|
14777 | while (i < this.requireFail.length) {
|
14778 | if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
|
14779 | return false;
|
14780 | }
|
14781 | i++;
|
14782 | }
|
14783 | return true;
|
14784 | },
|
14785 |
|
14786 | |
14787 |
|
14788 |
|
14789 |
|
14790 | recognize: function(inputData) {
|
14791 |
|
14792 |
|
14793 | var inputDataClone = assign({}, inputData);
|
14794 |
|
14795 |
|
14796 | if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
|
14797 | this.reset();
|
14798 | this.state = STATE_FAILED;
|
14799 | return;
|
14800 | }
|
14801 |
|
14802 |
|
14803 | if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
|
14804 | this.state = STATE_POSSIBLE;
|
14805 | }
|
14806 |
|
14807 | this.state = this.process(inputDataClone);
|
14808 |
|
14809 |
|
14810 |
|
14811 | if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
|
14812 | this.tryEmit(inputDataClone);
|
14813 | }
|
14814 | },
|
14815 |
|
14816 | |
14817 |
|
14818 |
|
14819 |
|
14820 |
|
14821 |
|
14822 |
|
14823 | process: function(inputData) { },
|
14824 |
|
14825 | |
14826 |
|
14827 |
|
14828 |
|
14829 |
|
14830 | getTouchAction: function() { },
|
14831 |
|
14832 | |
14833 |
|
14834 |
|
14835 |
|
14836 |
|
14837 | reset: function() { }
|
14838 | };
|
14839 |
|
14840 |
|
14841 |
|
14842 |
|
14843 |
|
14844 |
|
14845 | function stateStr(state) {
|
14846 | if (state & STATE_CANCELLED) {
|
14847 | return 'cancel';
|
14848 | } else if (state & STATE_ENDED) {
|
14849 | return 'end';
|
14850 | } else if (state & STATE_CHANGED) {
|
14851 | return 'move';
|
14852 | } else if (state & STATE_BEGAN) {
|
14853 | return 'start';
|
14854 | }
|
14855 | return '';
|
14856 | }
|
14857 |
|
14858 |
|
14859 |
|
14860 |
|
14861 |
|
14862 |
|
14863 | function directionStr(direction) {
|
14864 | if (direction == DIRECTION_DOWN) {
|
14865 | return 'down';
|
14866 | } else if (direction == DIRECTION_UP) {
|
14867 | return 'up';
|
14868 | } else if (direction == DIRECTION_LEFT) {
|
14869 | return 'left';
|
14870 | } else if (direction == DIRECTION_RIGHT) {
|
14871 | return 'right';
|
14872 | }
|
14873 | return '';
|
14874 | }
|
14875 |
|
14876 |
|
14877 |
|
14878 |
|
14879 |
|
14880 |
|
14881 |
|
14882 | function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
14883 | var manager = recognizer.manager;
|
14884 | if (manager) {
|
14885 | return manager.get(otherRecognizer);
|
14886 | }
|
14887 | return otherRecognizer;
|
14888 | }
|
14889 |
|
14890 |
|
14891 |
|
14892 |
|
14893 |
|
14894 |
|
14895 | function AttrRecognizer() {
|
14896 | Recognizer.apply(this, arguments);
|
14897 | }
|
14898 |
|
14899 | inherit(AttrRecognizer, Recognizer, {
|
14900 | |
14901 |
|
14902 |
|
14903 |
|
14904 | defaults: {
|
14905 | |
14906 |
|
14907 |
|
14908 |
|
14909 | pointers: 1
|
14910 | },
|
14911 |
|
14912 | |
14913 |
|
14914 |
|
14915 |
|
14916 |
|
14917 |
|
14918 | attrTest: function(input) {
|
14919 | var optionPointers = this.options.pointers;
|
14920 | return optionPointers === 0 || input.pointers.length === optionPointers;
|
14921 | },
|
14922 |
|
14923 | |
14924 |
|
14925 |
|
14926 |
|
14927 |
|
14928 |
|
14929 | process: function(input) {
|
14930 | var state = this.state;
|
14931 | var eventType = input.eventType;
|
14932 |
|
14933 | var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
|
14934 | var isValid = this.attrTest(input);
|
14935 |
|
14936 |
|
14937 | if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
|
14938 | return state | STATE_CANCELLED;
|
14939 | } else if (isRecognized || isValid) {
|
14940 | if (eventType & INPUT_END) {
|
14941 | return state | STATE_ENDED;
|
14942 | } else if (!(state & STATE_BEGAN)) {
|
14943 | return STATE_BEGAN;
|
14944 | }
|
14945 | return state | STATE_CHANGED;
|
14946 | }
|
14947 | return STATE_FAILED;
|
14948 | }
|
14949 | });
|
14950 |
|
14951 |
|
14952 |
|
14953 |
|
14954 |
|
14955 |
|
14956 |
|
14957 | function PanRecognizer() {
|
14958 | AttrRecognizer.apply(this, arguments);
|
14959 |
|
14960 | this.pX = null;
|
14961 | this.pY = null;
|
14962 | }
|
14963 |
|
14964 | inherit(PanRecognizer, AttrRecognizer, {
|
14965 | |
14966 |
|
14967 |
|
14968 |
|
14969 | defaults: {
|
14970 | event: 'pan',
|
14971 | threshold: 10,
|
14972 | pointers: 1,
|
14973 | direction: DIRECTION_ALL
|
14974 | },
|
14975 |
|
14976 | getTouchAction: function() {
|
14977 | var direction = this.options.direction;
|
14978 | var actions = [];
|
14979 | if (direction & DIRECTION_HORIZONTAL) {
|
14980 | actions.push(TOUCH_ACTION_PAN_Y);
|
14981 | }
|
14982 | if (direction & DIRECTION_VERTICAL) {
|
14983 | actions.push(TOUCH_ACTION_PAN_X);
|
14984 | }
|
14985 | return actions;
|
14986 | },
|
14987 |
|
14988 | directionTest: function(input) {
|
14989 | var options = this.options;
|
14990 | var hasMoved = true;
|
14991 | var distance = input.distance;
|
14992 | var direction = input.direction;
|
14993 | var x = input.deltaX;
|
14994 | var y = input.deltaY;
|
14995 |
|
14996 |
|
14997 | if (!(direction & options.direction)) {
|
14998 | if (options.direction & DIRECTION_HORIZONTAL) {
|
14999 | direction = (x === 0) ? DIRECTION_NONE : (x < 0) ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
15000 | hasMoved = x != this.pX;
|
15001 | distance = Math.abs(input.deltaX);
|
15002 | } else {
|
15003 | direction = (y === 0) ? DIRECTION_NONE : (y < 0) ? DIRECTION_UP : DIRECTION_DOWN;
|
15004 | hasMoved = y != this.pY;
|
15005 | distance = Math.abs(input.deltaY);
|
15006 | }
|
15007 | }
|
15008 | input.direction = direction;
|
15009 | return hasMoved && distance > options.threshold && direction & options.direction;
|
15010 | },
|
15011 |
|
15012 | attrTest: function(input) {
|
15013 | return AttrRecognizer.prototype.attrTest.call(this, input) &&
|
15014 | (this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input)));
|
15015 | },
|
15016 |
|
15017 | emit: function(input) {
|
15018 |
|
15019 | this.pX = input.deltaX;
|
15020 | this.pY = input.deltaY;
|
15021 |
|
15022 | var direction = directionStr(input.direction);
|
15023 |
|
15024 | if (direction) {
|
15025 | input.additionalEvent = this.options.event + direction;
|
15026 | }
|
15027 | this._super.emit.call(this, input);
|
15028 | }
|
15029 | });
|
15030 |
|
15031 |
|
15032 |
|
15033 |
|
15034 |
|
15035 |
|
15036 |
|
15037 | function PinchRecognizer() {
|
15038 | AttrRecognizer.apply(this, arguments);
|
15039 | }
|
15040 |
|
15041 | inherit(PinchRecognizer, AttrRecognizer, {
|
15042 | |
15043 |
|
15044 |
|
15045 |
|
15046 | defaults: {
|
15047 | event: 'pinch',
|
15048 | threshold: 0,
|
15049 | pointers: 2
|
15050 | },
|
15051 |
|
15052 | getTouchAction: function() {
|
15053 | return [TOUCH_ACTION_NONE];
|
15054 | },
|
15055 |
|
15056 | attrTest: function(input) {
|
15057 | return this._super.attrTest.call(this, input) &&
|
15058 | (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
|
15059 | },
|
15060 |
|
15061 | emit: function(input) {
|
15062 | if (input.scale !== 1) {
|
15063 | var inOut = input.scale < 1 ? 'in' : 'out';
|
15064 | input.additionalEvent = this.options.event + inOut;
|
15065 | }
|
15066 | this._super.emit.call(this, input);
|
15067 | }
|
15068 | });
|
15069 |
|
15070 |
|
15071 |
|
15072 |
|
15073 |
|
15074 |
|
15075 |
|
15076 | function PressRecognizer() {
|
15077 | Recognizer.apply(this, arguments);
|
15078 |
|
15079 | this._timer = null;
|
15080 | this._input = null;
|
15081 | }
|
15082 |
|
15083 | inherit(PressRecognizer, Recognizer, {
|
15084 | |
15085 |
|
15086 |
|
15087 |
|
15088 | defaults: {
|
15089 | event: 'press',
|
15090 | pointers: 1,
|
15091 | time: 251,
|
15092 | threshold: 9
|
15093 | },
|
15094 |
|
15095 | getTouchAction: function() {
|
15096 | return [TOUCH_ACTION_AUTO];
|
15097 | },
|
15098 |
|
15099 | process: function(input) {
|
15100 | var options = this.options;
|
15101 | var validPointers = input.pointers.length === options.pointers;
|
15102 | var validMovement = input.distance < options.threshold;
|
15103 | var validTime = input.deltaTime > options.time;
|
15104 |
|
15105 | this._input = input;
|
15106 |
|
15107 |
|
15108 |
|
15109 | if (!validMovement || !validPointers || (input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime)) {
|
15110 | this.reset();
|
15111 | } else if (input.eventType & INPUT_START) {
|
15112 | this.reset();
|
15113 | this._timer = setTimeoutContext(function() {
|
15114 | this.state = STATE_RECOGNIZED;
|
15115 | this.tryEmit();
|
15116 | }, options.time, this);
|
15117 | } else if (input.eventType & INPUT_END) {
|
15118 | return STATE_RECOGNIZED;
|
15119 | }
|
15120 | return STATE_FAILED;
|
15121 | },
|
15122 |
|
15123 | reset: function() {
|
15124 | clearTimeout(this._timer);
|
15125 | },
|
15126 |
|
15127 | emit: function(input) {
|
15128 | if (this.state !== STATE_RECOGNIZED) {
|
15129 | return;
|
15130 | }
|
15131 |
|
15132 | if (input && (input.eventType & INPUT_END)) {
|
15133 | this.manager.emit(this.options.event + 'up', input);
|
15134 | } else {
|
15135 | this._input.timeStamp = now();
|
15136 | this.manager.emit(this.options.event, this._input);
|
15137 | }
|
15138 | }
|
15139 | });
|
15140 |
|
15141 |
|
15142 |
|
15143 |
|
15144 |
|
15145 |
|
15146 |
|
15147 | function RotateRecognizer() {
|
15148 | AttrRecognizer.apply(this, arguments);
|
15149 | }
|
15150 |
|
15151 | inherit(RotateRecognizer, AttrRecognizer, {
|
15152 | |
15153 |
|
15154 |
|
15155 |
|
15156 | defaults: {
|
15157 | event: 'rotate',
|
15158 | threshold: 0,
|
15159 | pointers: 2
|
15160 | },
|
15161 |
|
15162 | getTouchAction: function() {
|
15163 | return [TOUCH_ACTION_NONE];
|
15164 | },
|
15165 |
|
15166 | attrTest: function(input) {
|
15167 | return this._super.attrTest.call(this, input) &&
|
15168 | (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
15169 | }
|
15170 | });
|
15171 |
|
15172 |
|
15173 |
|
15174 |
|
15175 |
|
15176 |
|
15177 |
|
15178 | function SwipeRecognizer() {
|
15179 | AttrRecognizer.apply(this, arguments);
|
15180 | }
|
15181 |
|
15182 | inherit(SwipeRecognizer, AttrRecognizer, {
|
15183 | |
15184 |
|
15185 |
|
15186 |
|
15187 | defaults: {
|
15188 | event: 'swipe',
|
15189 | threshold: 10,
|
15190 | velocity: 0.3,
|
15191 | direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
|
15192 | pointers: 1
|
15193 | },
|
15194 |
|
15195 | getTouchAction: function() {
|
15196 | return PanRecognizer.prototype.getTouchAction.call(this);
|
15197 | },
|
15198 |
|
15199 | attrTest: function(input) {
|
15200 | var direction = this.options.direction;
|
15201 | var velocity;
|
15202 |
|
15203 | if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
15204 | velocity = input.overallVelocity;
|
15205 | } else if (direction & DIRECTION_HORIZONTAL) {
|
15206 | velocity = input.overallVelocityX;
|
15207 | } else if (direction & DIRECTION_VERTICAL) {
|
15208 | velocity = input.overallVelocityY;
|
15209 | }
|
15210 |
|
15211 | return this._super.attrTest.call(this, input) &&
|
15212 | direction & input.offsetDirection &&
|
15213 | input.distance > this.options.threshold &&
|
15214 | input.maxPointers == this.options.pointers &&
|
15215 | abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
|
15216 | },
|
15217 |
|
15218 | emit: function(input) {
|
15219 | var direction = directionStr(input.offsetDirection);
|
15220 | if (direction) {
|
15221 | this.manager.emit(this.options.event + direction, input);
|
15222 | }
|
15223 |
|
15224 | this.manager.emit(this.options.event, input);
|
15225 | }
|
15226 | });
|
15227 |
|
15228 |
|
15229 |
|
15230 |
|
15231 |
|
15232 |
|
15233 |
|
15234 |
|
15235 |
|
15236 |
|
15237 |
|
15238 | function TapRecognizer() {
|
15239 | Recognizer.apply(this, arguments);
|
15240 |
|
15241 |
|
15242 |
|
15243 | this.pTime = false;
|
15244 | this.pCenter = false;
|
15245 |
|
15246 | this._timer = null;
|
15247 | this._input = null;
|
15248 | this.count = 0;
|
15249 | }
|
15250 |
|
15251 | inherit(TapRecognizer, Recognizer, {
|
15252 | |
15253 |
|
15254 |
|
15255 |
|
15256 | defaults: {
|
15257 | event: 'tap',
|
15258 | pointers: 1,
|
15259 | taps: 1,
|
15260 | interval: 300,
|
15261 | time: 250,
|
15262 | threshold: 9,
|
15263 | posThreshold: 10
|
15264 | },
|
15265 |
|
15266 | getTouchAction: function() {
|
15267 | return [TOUCH_ACTION_MANIPULATION];
|
15268 | },
|
15269 |
|
15270 | process: function(input) {
|
15271 | var options = this.options;
|
15272 |
|
15273 | var validPointers = input.pointers.length === options.pointers;
|
15274 | var validMovement = input.distance < options.threshold;
|
15275 | var validTouchTime = input.deltaTime < options.time;
|
15276 |
|
15277 | this.reset();
|
15278 |
|
15279 | if ((input.eventType & INPUT_START) && (this.count === 0)) {
|
15280 | return this.failTimeout();
|
15281 | }
|
15282 |
|
15283 |
|
15284 |
|
15285 | if (validMovement && validTouchTime && validPointers) {
|
15286 | if (input.eventType != INPUT_END) {
|
15287 | return this.failTimeout();
|
15288 | }
|
15289 |
|
15290 | var validInterval = this.pTime ? (input.timeStamp - this.pTime < options.interval) : true;
|
15291 | var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
|
15292 |
|
15293 | this.pTime = input.timeStamp;
|
15294 | this.pCenter = input.center;
|
15295 |
|
15296 | if (!validMultiTap || !validInterval) {
|
15297 | this.count = 1;
|
15298 | } else {
|
15299 | this.count += 1;
|
15300 | }
|
15301 |
|
15302 | this._input = input;
|
15303 |
|
15304 |
|
15305 |
|
15306 | var tapCount = this.count % options.taps;
|
15307 | if (tapCount === 0) {
|
15308 |
|
15309 |
|
15310 | if (!this.hasRequireFailures()) {
|
15311 | return STATE_RECOGNIZED;
|
15312 | } else {
|
15313 | this._timer = setTimeoutContext(function() {
|
15314 | this.state = STATE_RECOGNIZED;
|
15315 | this.tryEmit();
|
15316 | }, options.interval, this);
|
15317 | return STATE_BEGAN;
|
15318 | }
|
15319 | }
|
15320 | }
|
15321 | return STATE_FAILED;
|
15322 | },
|
15323 |
|
15324 | failTimeout: function() {
|
15325 | this._timer = setTimeoutContext(function() {
|
15326 | this.state = STATE_FAILED;
|
15327 | }, this.options.interval, this);
|
15328 | return STATE_FAILED;
|
15329 | },
|
15330 |
|
15331 | reset: function() {
|
15332 | clearTimeout(this._timer);
|
15333 | },
|
15334 |
|
15335 | emit: function() {
|
15336 | if (this.state == STATE_RECOGNIZED) {
|
15337 | this._input.tapCount = this.count;
|
15338 | this.manager.emit(this.options.event, this._input);
|
15339 | }
|
15340 | }
|
15341 | });
|
15342 |
|
15343 |
|
15344 |
|
15345 |
|
15346 |
|
15347 |
|
15348 |
|
15349 | function NGHammer(element, options) {
|
15350 | options = options || {};
|
15351 | options.recognizers = ifUndefined(options.recognizers, NGHammer.defaults.preset);
|
15352 | return new Manager(element, options);
|
15353 | }
|
15354 |
|
15355 |
|
15356 |
|
15357 |
|
15358 | NGHammer.VERSION = '2.0.7';
|
15359 |
|
15360 |
|
15361 |
|
15362 |
|
15363 |
|
15364 | NGHammer.defaults = {
|
15365 | |
15366 |
|
15367 |
|
15368 |
|
15369 |
|
15370 |
|
15371 | domEvents: false,
|
15372 |
|
15373 | |
15374 |
|
15375 |
|
15376 |
|
15377 |
|
15378 |
|
15379 | touchAction: TOUCH_ACTION_COMPUTE,
|
15380 |
|
15381 | |
15382 |
|
15383 |
|
15384 |
|
15385 | enable: true,
|
15386 |
|
15387 | |
15388 |
|
15389 |
|
15390 |
|
15391 |
|
15392 |
|
15393 |
|
15394 | inputTarget: null,
|
15395 |
|
15396 | |
15397 |
|
15398 |
|
15399 |
|
15400 |
|
15401 | inputClass: null,
|
15402 |
|
15403 | |
15404 |
|
15405 |
|
15406 |
|
15407 |
|
15408 | preset: [
|
15409 |
|
15410 | [RotateRecognizer, {enable: false}],
|
15411 | [PinchRecognizer, {enable: false}, ['rotate']],
|
15412 | [SwipeRecognizer, {direction: DIRECTION_HORIZONTAL}],
|
15413 | [PanRecognizer, {direction: DIRECTION_HORIZONTAL}, ['swipe']],
|
15414 | [TapRecognizer],
|
15415 | [TapRecognizer, {event: 'doubletap', taps: 2}, ['tap']],
|
15416 | [PressRecognizer]
|
15417 | ],
|
15418 |
|
15419 | |
15420 |
|
15421 |
|
15422 |
|
15423 |
|
15424 | cssProps: {
|
15425 | |
15426 |
|
15427 |
|
15428 |
|
15429 |
|
15430 | userSelect: 'none',
|
15431 |
|
15432 | |
15433 |
|
15434 |
|
15435 |
|
15436 |
|
15437 | touchSelect: 'none',
|
15438 |
|
15439 | |
15440 |
|
15441 |
|
15442 |
|
15443 |
|
15444 |
|
15445 |
|
15446 | touchCallout: 'none',
|
15447 |
|
15448 | |
15449 |
|
15450 |
|
15451 |
|
15452 |
|
15453 | contentZooming: 'none',
|
15454 |
|
15455 | |
15456 |
|
15457 |
|
15458 |
|
15459 |
|
15460 | userDrag: 'none',
|
15461 |
|
15462 | |
15463 |
|
15464 |
|
15465 |
|
15466 |
|
15467 |
|
15468 | tapHighlightColor: 'rgba(0,0,0,0)'
|
15469 | }
|
15470 | };
|
15471 |
|
15472 | var STOP = 1;
|
15473 | var FORCED_STOP = 2;
|
15474 |
|
15475 |
|
15476 |
|
15477 |
|
15478 |
|
15479 |
|
15480 |
|
15481 | function Manager(element, options) {
|
15482 | this.options = assign({}, NGHammer.defaults, options || {});
|
15483 |
|
15484 | this.options.inputTarget = this.options.inputTarget || element;
|
15485 |
|
15486 | this.handlers = {};
|
15487 | this.session = {};
|
15488 | this.recognizers = [];
|
15489 | this.oldCssProps = {};
|
15490 |
|
15491 | this.element = element;
|
15492 | this.input = createInputInstance(this);
|
15493 | this.touchAction = new TouchAction(this, this.options.touchAction);
|
15494 |
|
15495 | toggleCssProps(this, true);
|
15496 |
|
15497 | each(this.options.recognizers, function(item) {
|
15498 | var recognizer = this.add(new (item[0])(item[1]));
|
15499 | item[2] && recognizer.recognizeWith(item[2]);
|
15500 | item[3] && recognizer.requireFailure(item[3]);
|
15501 | }, this);
|
15502 | }
|
15503 |
|
15504 | Manager.prototype = {
|
15505 | |
15506 |
|
15507 |
|
15508 |
|
15509 |
|
15510 | set: function(options) {
|
15511 | assign(this.options, options);
|
15512 |
|
15513 |
|
15514 | if (options.touchAction) {
|
15515 | this.touchAction.update();
|
15516 | }
|
15517 | if (options.inputTarget) {
|
15518 |
|
15519 | this.input.destroy();
|
15520 | this.input.target = options.inputTarget;
|
15521 | this.input.init();
|
15522 | }
|
15523 | return this;
|
15524 | },
|
15525 |
|
15526 | |
15527 |
|
15528 |
|
15529 |
|
15530 |
|
15531 |
|
15532 | stop: function(force) {
|
15533 | this.session.stopped = force ? FORCED_STOP : STOP;
|
15534 | },
|
15535 |
|
15536 | |
15537 |
|
15538 |
|
15539 |
|
15540 |
|
15541 |
|
15542 | recognize: function(inputData) {
|
15543 | var session = this.session;
|
15544 | if (session.stopped) {
|
15545 | return;
|
15546 | }
|
15547 |
|
15548 |
|
15549 | this.touchAction.preventDefaults(inputData);
|
15550 |
|
15551 | var recognizer;
|
15552 | var recognizers = this.recognizers;
|
15553 |
|
15554 |
|
15555 |
|
15556 |
|
15557 | var curRecognizer = session.curRecognizer;
|
15558 |
|
15559 |
|
15560 |
|
15561 | if (!curRecognizer || (curRecognizer && curRecognizer.state & STATE_RECOGNIZED)) {
|
15562 | curRecognizer = session.curRecognizer = null;
|
15563 | }
|
15564 |
|
15565 | var i = 0;
|
15566 | while (i < recognizers.length) {
|
15567 | recognizer = recognizers[i];
|
15568 |
|
15569 |
|
15570 |
|
15571 |
|
15572 |
|
15573 |
|
15574 |
|
15575 | if (session.stopped !== FORCED_STOP && (
|
15576 | !curRecognizer || recognizer == curRecognizer ||
|
15577 | recognizer.canRecognizeWith(curRecognizer))) {
|
15578 | recognizer.recognize(inputData);
|
15579 | } else {
|
15580 | recognizer.reset();
|
15581 | }
|
15582 |
|
15583 |
|
15584 |
|
15585 | if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
|
15586 | curRecognizer = session.curRecognizer = recognizer;
|
15587 | }
|
15588 | i++;
|
15589 | }
|
15590 | },
|
15591 |
|
15592 | |
15593 |
|
15594 |
|
15595 |
|
15596 |
|
15597 | get: function(recognizer) {
|
15598 | if (recognizer instanceof Recognizer) {
|
15599 | return recognizer;
|
15600 | }
|
15601 |
|
15602 | var recognizers = this.recognizers;
|
15603 | for (var i = 0; i < recognizers.length; i++) {
|
15604 | if (recognizers[i].options.event == recognizer) {
|
15605 | return recognizers[i];
|
15606 | }
|
15607 | }
|
15608 | return null;
|
15609 | },
|
15610 |
|
15611 | |
15612 |
|
15613 |
|
15614 |
|
15615 |
|
15616 |
|
15617 | add: function(recognizer) {
|
15618 | if (invokeArrayArg(recognizer, 'add', this)) {
|
15619 | return this;
|
15620 | }
|
15621 |
|
15622 |
|
15623 | var existing = this.get(recognizer.options.event);
|
15624 | if (existing) {
|
15625 | this.remove(existing);
|
15626 | }
|
15627 |
|
15628 | this.recognizers.push(recognizer);
|
15629 | recognizer.manager = this;
|
15630 |
|
15631 | this.touchAction.update();
|
15632 | return recognizer;
|
15633 | },
|
15634 |
|
15635 | |
15636 |
|
15637 |
|
15638 |
|
15639 |
|
15640 | remove: function(recognizer) {
|
15641 | if (invokeArrayArg(recognizer, 'remove', this)) {
|
15642 | return this;
|
15643 | }
|
15644 |
|
15645 | recognizer = this.get(recognizer);
|
15646 |
|
15647 |
|
15648 | if (recognizer) {
|
15649 | var recognizers = this.recognizers;
|
15650 | var index = inArray(recognizers, recognizer);
|
15651 |
|
15652 | if (index !== -1) {
|
15653 | recognizers.splice(index, 1);
|
15654 | this.touchAction.update();
|
15655 | }
|
15656 | }
|
15657 |
|
15658 | return this;
|
15659 | },
|
15660 |
|
15661 | |
15662 |
|
15663 |
|
15664 |
|
15665 |
|
15666 |
|
15667 | on: function(events, handler) {
|
15668 | if (events === undefined) {
|
15669 | return;
|
15670 | }
|
15671 | if (handler === undefined) {
|
15672 | return;
|
15673 | }
|
15674 |
|
15675 | var handlers = this.handlers;
|
15676 | each(splitStr(events), function(event) {
|
15677 | handlers[event] = handlers[event] || [];
|
15678 | handlers[event].push(handler);
|
15679 | });
|
15680 | return this;
|
15681 | },
|
15682 |
|
15683 | |
15684 |
|
15685 |
|
15686 |
|
15687 |
|
15688 |
|
15689 | off: function(events, handler) {
|
15690 | if (events === undefined) {
|
15691 | return;
|
15692 | }
|
15693 |
|
15694 | var handlers = this.handlers;
|
15695 | each(splitStr(events), function(event) {
|
15696 | if (!handler) {
|
15697 | delete handlers[event];
|
15698 | } else {
|
15699 | handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
|
15700 | }
|
15701 | });
|
15702 | return this;
|
15703 | },
|
15704 |
|
15705 | |
15706 |
|
15707 |
|
15708 |
|
15709 |
|
15710 | emit: function(event, data) {
|
15711 |
|
15712 | if (this.options.domEvents) {
|
15713 | triggerDomEvent(event, data);
|
15714 | }
|
15715 |
|
15716 |
|
15717 | var handlers = this.handlers[event] && this.handlers[event].slice();
|
15718 | if (!handlers || !handlers.length) {
|
15719 | return;
|
15720 | }
|
15721 |
|
15722 | data.type = event;
|
15723 | data.preventDefault = function() {
|
15724 | data.srcEvent.preventDefault();
|
15725 | };
|
15726 |
|
15727 | var i = 0;
|
15728 | while (i < handlers.length) {
|
15729 | handlers[i](data);
|
15730 | i++;
|
15731 | }
|
15732 | },
|
15733 |
|
15734 | |
15735 |
|
15736 |
|
15737 |
|
15738 | destroy: function() {
|
15739 | this.element && toggleCssProps(this, false);
|
15740 |
|
15741 | this.handlers = {};
|
15742 | this.session = {};
|
15743 | this.input.destroy();
|
15744 | this.element = null;
|
15745 | }
|
15746 | };
|
15747 |
|
15748 |
|
15749 |
|
15750 |
|
15751 |
|
15752 |
|
15753 | function toggleCssProps(manager, add) {
|
15754 | var element = manager.element;
|
15755 | if (!element.style) {
|
15756 | return;
|
15757 | }
|
15758 | var prop;
|
15759 | each(manager.options.cssProps, function(value, name) {
|
15760 | prop = prefixed(element.style, name);
|
15761 | if (add) {
|
15762 | manager.oldCssProps[prop] = element.style[prop];
|
15763 | element.style[prop] = value;
|
15764 | } else {
|
15765 | element.style[prop] = manager.oldCssProps[prop] || '';
|
15766 | }
|
15767 | });
|
15768 | if (!add) {
|
15769 | manager.oldCssProps = {};
|
15770 | }
|
15771 | }
|
15772 |
|
15773 |
|
15774 |
|
15775 |
|
15776 |
|
15777 |
|
15778 | function triggerDomEvent(event, data) {
|
15779 | var gestureEvent = document.createEvent('Event');
|
15780 | gestureEvent.initEvent(event, true, true);
|
15781 | gestureEvent.gesture = data;
|
15782 | data.target.dispatchEvent(gestureEvent);
|
15783 | }
|
15784 |
|
15785 | assign(NGHammer, {
|
15786 | INPUT_START: INPUT_START,
|
15787 | INPUT_MOVE: INPUT_MOVE,
|
15788 | INPUT_END: INPUT_END,
|
15789 | INPUT_CANCEL: INPUT_CANCEL,
|
15790 |
|
15791 | STATE_POSSIBLE: STATE_POSSIBLE,
|
15792 | STATE_BEGAN: STATE_BEGAN,
|
15793 | STATE_CHANGED: STATE_CHANGED,
|
15794 | STATE_ENDED: STATE_ENDED,
|
15795 | STATE_RECOGNIZED: STATE_RECOGNIZED,
|
15796 | STATE_CANCELLED: STATE_CANCELLED,
|
15797 | STATE_FAILED: STATE_FAILED,
|
15798 |
|
15799 | DIRECTION_NONE: DIRECTION_NONE,
|
15800 | DIRECTION_LEFT: DIRECTION_LEFT,
|
15801 | DIRECTION_RIGHT: DIRECTION_RIGHT,
|
15802 | DIRECTION_UP: DIRECTION_UP,
|
15803 | DIRECTION_DOWN: DIRECTION_DOWN,
|
15804 | DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
|
15805 | DIRECTION_VERTICAL: DIRECTION_VERTICAL,
|
15806 | DIRECTION_ALL: DIRECTION_ALL,
|
15807 |
|
15808 | Manager: Manager,
|
15809 | Input: Input,
|
15810 | TouchAction: TouchAction,
|
15811 |
|
15812 | TouchInput: TouchInput,
|
15813 | MouseInput: MouseInput,
|
15814 | PointerEventInput: PointerEventInput,
|
15815 | TouchMouseInput: TouchMouseInput,
|
15816 | SingleTouchInput: SingleTouchInput,
|
15817 |
|
15818 | Recognizer: Recognizer,
|
15819 | AttrRecognizer: AttrRecognizer,
|
15820 | Tap: TapRecognizer,
|
15821 | Pan: PanRecognizer,
|
15822 | Swipe: SwipeRecognizer,
|
15823 | Pinch: PinchRecognizer,
|
15824 | Rotate: RotateRecognizer,
|
15825 | Press: PressRecognizer,
|
15826 |
|
15827 | on: addEventListeners,
|
15828 | off: removeEventListeners,
|
15829 | each: each,
|
15830 | merge: merge,
|
15831 | extend: extend,
|
15832 | assign: assign,
|
15833 | inherit: inherit,
|
15834 | bindFn: bindFn,
|
15835 | prefixed: prefixed
|
15836 | });
|
15837 |
|
15838 |
|
15839 |
|
15840 | var freeGlobal = (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}));
|
15841 | freeGlobal.NGHammer = NGHammer;
|
15842 |
|
15843 | if (typeof define === 'function' && define.amdDISABLED) {
|
15844 | define(function() {
|
15845 | return NGHammer;
|
15846 | });
|
15847 | } else if (typeof module != 'undefined' && module.exports) {
|
15848 | module.exports = NGHammer;
|
15849 | } else {
|
15850 | window[exportName] = NGHammer;
|
15851 | }
|
15852 |
|
15853 | })(window, document, 'NGHammer');
|
15854 |
|
15855 |
|
15856 |
|
15857 |
|
15858 |
|
15859 |
|
15860 |
|
15861 |
|
15862 | }));
|
15863 |
|
15864 |
|
15865 |
|
15866 |
|
15867 |
|
15868 |
|
15869 |
|
15870 |
|
15871 |
|
15872 | (function(){
|
15873 | 'use strict';
|
15874 |
|
15875 | function document_ready(callback){
|
15876 |
|
15877 | if (document.readyState!='loading') callback();
|
15878 |
|
15879 | else if (document.addEventListener) document.addEventListener('DOMContentLoaded', callback);
|
15880 |
|
15881 | else document.attachEvent('onreadystatechange', function(){
|
15882 | if (document.readyState=='complete') callback();
|
15883 | });
|
15884 | }
|
15885 |
|
15886 | document_ready(function(){
|
15887 |
|
15888 |
|
15889 | var t=document.querySelectorAll('[data-nanogallery2]');
|
15890 | for( var i=0; i < t.length; i++ ) {
|
15891 | jQuery( t[i] ).nanogallery2( jQuery(t[i]).data('nanogallery2') );
|
15892 | }
|
15893 |
|
15894 |
|
15895 | var t = document.querySelectorAll('[data-nanogallery2-lightbox]');
|
15896 | for( var i=0; i < t.length; i++ ) {
|
15897 |
|
15898 |
|
15899 | t[i].classList.add('NGY2ThumbnailLightbox');
|
15900 |
|
15901 |
|
15902 | t[i].addEventListener('click', function(e) {
|
15903 |
|
15904 | e.preventDefault();
|
15905 |
|
15906 |
|
15907 | var options = {
|
15908 | lightboxStandalone: true,
|
15909 | viewerToolbar: { display: false }
|
15910 | };
|
15911 |
|
15912 |
|
15913 | var g = this.dataset.nanogallery2Lgroup;
|
15914 |
|
15915 |
|
15916 |
|
15917 | var t = document.querySelectorAll('[data-nanogallery2-lightbox]');
|
15918 | for( var i=0; i < t.length; i++ ) {
|
15919 | if( t[i].dataset.nanogallery2Lgroup == g ) {
|
15920 | if( t[i].dataset.nanogallery2Lightbox !== "" ) {
|
15921 | options = jQuery.extend(true, {}, options, jQuery(t[i]).data('nanogallery2Lightbox'));
|
15922 | break;
|
15923 | }
|
15924 | }
|
15925 | }
|
15926 | jQuery( this ).nanogallery2( options );
|
15927 |
|
15928 | });
|
15929 |
|
15930 | }
|
15931 | });
|
15932 |
|
15933 |
|
15934 |
|
15935 |
|
15936 |
|
15937 |
|
15938 |
|
15939 |
|
15940 |
|
15941 |
|
15942 |
|
15943 |
|
15944 |
|
15945 |
|
15946 |
|
15947 |
|
15948 |
|
15949 |
|
15950 |
|
15951 |
|
15952 |
|
15953 |
|
15954 |
|
15955 |
|
15956 |
|
15957 |
|
15958 |
|
15959 |
|
15960 |
|
15961 |
|
15962 |
|
15963 |
|
15964 | }).call(null);
|
15965 |
|
15966 |
|
15967 |
|
15968 |
|
15969 |
|
15970 |
|
15971 |
|
15972 |
|
15973 |
|
15974 |
|
15975 |
|
15976 |
|
15977 |
|
15978 |
|
15979 |
|
15980 |
|
15981 | (function (factory) {
|
15982 | "use strict";
|
15983 | if (typeof define === 'function' && define.amd) {
|
15984 |
|
15985 | define(['jquery', 'nanogallery2'], factory);
|
15986 | } else if (typeof exports === 'object' && typeof require === 'function') {
|
15987 |
|
15988 | factory(require(['jquery', 'nanogallery2']));
|
15989 | } else {
|
15990 |
|
15991 | factory(jQuery);
|
15992 | }
|
15993 | }(function ($) {
|
15994 |
|
15995 |
|
15996 | jQuery.nanogallery2.data_nano_photos_provider2 = function (instance, fnName){
|
15997 | var G = instance;
|
15998 |
|
15999 |
|
16000 | var AlbumGetContent = function(albumID, fnToCall, fnParam1, fnParam2) {
|
16001 |
|
16002 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
16003 |
|
16004 |
|
16005 | if( instance.I[albumIdx].title == '' ) {
|
16006 | instance.I[albumIdx].title = JsonConvertCharset(albumID);
|
16007 | }
|
16008 |
|
16009 |
|
16010 | var url = G.O.dataProvider + '?albumID='+albumID;
|
16011 |
|
16012 |
|
16013 | url += '&hxs=' + G.tn.settings.getH(G.GOM.curNavLevel, 'xs');
|
16014 | url += '&wxs=' + G.tn.settings.getW(G.GOM.curNavLevel, 'xs');
|
16015 | url += '&hsm=' + G.tn.settings.getH(G.GOM.curNavLevel, 'sm');
|
16016 | url += '&wsm=' + G.tn.settings.getW(G.GOM.curNavLevel, 'sm');
|
16017 | url += '&hme=' + G.tn.settings.getH(G.GOM.curNavLevel, 'me');
|
16018 | url += '&wme=' + G.tn.settings.getW(G.GOM.curNavLevel, 'me');
|
16019 | url += '&hla=' + G.tn.settings.getH(G.GOM.curNavLevel, 'la');
|
16020 | url += '&wla=' + G.tn.settings.getW(G.GOM.curNavLevel, 'la');
|
16021 | url += '&hxl=' + G.tn.settings.getH(G.GOM.curNavLevel, 'xl');
|
16022 | url += '&wxl=' + G.tn.settings.getW(G.GOM.curNavLevel, 'xl');
|
16023 |
|
16024 |
|
16025 |
|
16026 |
|
16027 |
|
16028 |
|
16029 |
|
16030 |
|
16031 |
|
16032 |
|
16033 |
|
16034 | PreloaderDisplay( true );
|
16035 |
|
16036 | jQuery.ajaxSetup({ cache: false });
|
16037 | jQuery.support.cors = true;
|
16038 | try {
|
16039 |
|
16040 | var tId = setTimeout( function() {
|
16041 |
|
16042 | PreloaderDisplay(false);
|
16043 | NanoAlert(G, 'Could not retrieve nanoPhotosProvider2 data (timeout).');
|
16044 | }, 60000 );
|
16045 |
|
16046 | if( G.O.debugMode ) { console.log('nanoPhotosProvider2 URL: ' + url); }
|
16047 |
|
16048 | jQuery.getJSON(url, function(data, status, xhr) {
|
16049 | clearTimeout( tId );
|
16050 | PreloaderDisplay( false );
|
16051 | JsonParseData(albumIdx, data);
|
16052 |
|
16053 | if( data.nano_status == 'ok' ) {
|
16054 | AlbumPostProcess( albumID );
|
16055 | if( fnToCall !== null && fnToCall !== undefined) {
|
16056 | fnToCall( fnParam1, fnParam2, null );
|
16057 | }
|
16058 | }
|
16059 | else {
|
16060 | NanoAlert(G, 'Could not retrieve nanoPhotosProvider2 data. Error: ' + data.nano_status + ' - ' + data.nano_message);
|
16061 | }
|
16062 | })
|
16063 | .fail( function(jqxhr, textStatus, error) {
|
16064 | clearTimeout( tId );
|
16065 | PreloaderDisplay( false );
|
16066 |
|
16067 | var k=''
|
16068 | for(var key in jqxhr) {
|
16069 | k+= key + '=' + jqxhr[key] +'<br>';
|
16070 | }
|
16071 | var err = textStatus + ', ' + error + ' ' + k + '<br><br>URL:'+url;
|
16072 | NanoAlert(G, 'Could not retrieve nanoPhotosProvider2 data. Error: ' + err);
|
16073 |
|
16074 | });
|
16075 |
|
16076 | }
|
16077 | catch(e) {
|
16078 | NanoAlert(G, 'Could not retrieve nanoPhotosProvider2 data. Error: ' + e);
|
16079 | }
|
16080 | }
|
16081 |
|
16082 |
|
16083 | function JsonConvertCharset( str ) {
|
16084 |
|
16085 | return decodeURIComponent(str);
|
16086 |
|
16087 |
|
16088 |
|
16089 |
|
16090 |
|
16091 |
|
16092 |
|
16093 |
|
16094 |
|
16095 |
|
16096 |
|
16097 |
|
16098 |
|
16099 | }
|
16100 |
|
16101 | function JsonParseData(albumIdx, data) {
|
16102 | if( G.O.debugMode ) {
|
16103 | console.log('nanoPhotosProvider2 parse data:');
|
16104 | console.dir(data);
|
16105 | }
|
16106 |
|
16107 |
|
16108 | var foundAlbumID = false;
|
16109 | var nb = 0;
|
16110 |
|
16111 |
|
16112 | jQuery.each( data.album_content, function( i, item ){
|
16113 |
|
16114 |
|
16115 | var baseURL = G.O.dataProvider.substring(0, G.O.dataProvider.indexOf('nano_photos_provider2.php'));
|
16116 |
|
16117 |
|
16118 | var src = baseURL + JsonConvertCharset( item.src );
|
16119 |
|
16120 |
|
16121 | var title = item.title;
|
16122 |
|
16123 |
|
16124 | var description = item.description.split('_').join(' ');
|
16125 |
|
16126 |
|
16127 | var kind = 'image';
|
16128 | if( item.kind !== undefined && item.kind.length > 0 ) {
|
16129 | kind = item.kind;
|
16130 | }
|
16131 |
|
16132 |
|
16133 | var ID=item.ID;
|
16134 |
|
16135 | var filterAlbum = false;
|
16136 | if( kind == 'album' ) {
|
16137 |
|
16138 | if( !FilterAlbumName(title, ID) ) { filterAlbum = true; }
|
16139 |
|
16140 | if( G.O.album != '' || G.O.photoset != '' ) { filterAlbum = true; }
|
16141 | }
|
16142 |
|
16143 |
|
16144 | if( kind == 'image' || !filterAlbum ) {
|
16145 |
|
16146 | var albumID = 0;
|
16147 | if( item.albumID !== undefined ) {
|
16148 | albumID = item.albumID;
|
16149 | foundAlbumID = true;
|
16150 | }
|
16151 |
|
16152 | var tags = (item.tags === undefined) ? '' : item.tags;
|
16153 | var newItem = NGY2Item.New( G, title.split('_').join(' ') , description, ID, albumID, kind, tags );
|
16154 | newItem.setMediaURL( src, 'img');
|
16155 |
|
16156 |
|
16157 | if( item.dcGIF !== undefined ) {
|
16158 | newItem.imageDominantColors = 'data:image/gif;base64,' + item.dcGIF;
|
16159 | }
|
16160 |
|
16161 | if( item.dc !== undefined && item.dc !== '' ) {
|
16162 | newItem.imageDominantColor = item.dc;
|
16163 | }
|
16164 |
|
16165 | if( kind == 'album' ) {
|
16166 |
|
16167 | newItem.numberItems = item.cnt;
|
16168 | }
|
16169 | else {
|
16170 |
|
16171 | newItem.imageWidth = item.imgWidth;
|
16172 | newItem.imageHeight = item.imgHeight;
|
16173 | }
|
16174 |
|
16175 |
|
16176 | if( item.originalURL != '' ) {
|
16177 | newItem.downloadURL = baseURL+JsonConvertCharset(item.originalURL);
|
16178 | }
|
16179 |
|
16180 |
|
16181 | var cnl = G.GOM.curNavLevel;
|
16182 | var l=['xs', 'sm', 'me', 'la', 'xl'];
|
16183 | for( var n = 0; n < l.length; n++ ) {
|
16184 | newItem.thumbs.url[cnl][l[n]] = baseURL + JsonConvertCharset(item.t_url[n]);
|
16185 | newItem.thumbs.width[cnl][l[n]] = parseInt(item.t_width[n]);
|
16186 | newItem.thumbs.height[cnl][l[n]] = parseInt(item.t_height[n]);
|
16187 | }
|
16188 |
|
16189 |
|
16190 | var fu = G.O.fnProcessData;
|
16191 | if( fu !== null ) {
|
16192 | typeof fu == 'function' ? fu(newItem, G.O.dataProvider, data) : window[fu](newItem, G.O.dataProvider, data);
|
16193 | }
|
16194 |
|
16195 | }
|
16196 | });
|
16197 |
|
16198 | G.I[albumIdx].contentIsLoaded = true;
|
16199 | }
|
16200 |
|
16201 |
|
16202 |
|
16203 |
|
16204 | function Init() {
|
16205 |
|
16206 | }
|
16207 |
|
16208 |
|
16209 |
|
16210 | var PreloaderDisplay = NGY2Tools.PreloaderDisplay.bind(G);
|
16211 |
|
16212 | var NanoAlert = NGY2Tools.NanoAlert;
|
16213 |
|
16214 | var FilterAlbumName = NGY2Tools.FilterAlbumName.bind(G);
|
16215 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
16216 |
|
16217 | switch( fnName ){
|
16218 | case 'GetHiddenAlbums':
|
16219 | break;
|
16220 | case 'AlbumGetContent':
|
16221 | var albumID = arguments[2],
|
16222 | callback = arguments[3],
|
16223 | cbParam1 = arguments[4],
|
16224 | cbParam2 = arguments[5];
|
16225 | AlbumGetContent(albumID, callback, cbParam1, cbParam2);
|
16226 | break;
|
16227 | case 'Init':
|
16228 | Init();
|
16229 | break;
|
16230 | case '':
|
16231 | break;
|
16232 | }
|
16233 |
|
16234 | };
|
16235 |
|
16236 |
|
16237 |
|
16238 | }));
|
16239 |
|
16240 |
|
16241 |
|
16242 |
|
16243 |
|
16244 |
|
16245 |
|
16246 |
|
16247 |
|
16248 |
|
16249 |
|
16250 |
|
16251 |
|
16252 |
|
16253 |
|
16254 |
|
16255 |
|
16256 |
|
16257 |
|
16258 | (function (factory) {
|
16259 | "use strict";
|
16260 | if (typeof define === 'function' && define.amd) {
|
16261 |
|
16262 | define(['jquery', 'nanogallery2'], factory);
|
16263 | } else if (typeof exports === 'object' && typeof require === 'function') {
|
16264 |
|
16265 | factory(require(['jquery', 'nanogallery2']));
|
16266 | } else {
|
16267 |
|
16268 | factory(jQuery);
|
16269 | }
|
16270 | }(function ($) {
|
16271 |
|
16272 |
|
16273 | jQuery.nanogallery2.data_google2 = function (instance, fnName){
|
16274 | var G=instance;
|
16275 |
|
16276 |
|
16277 |
|
16278 | var AlbumGetContent = function(albumID, fnToCall, fnParam1, fnParam2) {
|
16279 |
|
16280 | var url = '';
|
16281 | var kind = 'image';
|
16282 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
16283 |
|
16284 | var maxResults='';
|
16285 | if( G.galleryMaxItems.Get() > 0 ) {
|
16286 | maxResults = '&max-results=' + G.galleryMaxItems.Get();
|
16287 | }
|
16288 |
|
16289 | var gat='';
|
16290 | if( typeof ngy2_pwa_at !== 'undefined' ) {
|
16291 | gat=ngy2_pwa_at;
|
16292 | }
|
16293 |
|
16294 | if( albumID == 0 ) {
|
16295 |
|
16296 | if( gat != '' ) {
|
16297 |
|
16298 |
|
16299 | url = 'https://photoslibrary.googleapis.com/v1/albums';
|
16300 | }
|
16301 | else {
|
16302 |
|
16303 |
|
16304 | url = G.O.google2URL + '?nguserid=' + G.O.userID + '&alt=json&v=3&kind=album' + maxResults + '&rnd=' + (new Date().getTime());
|
16305 | }
|
16306 | kind='album';
|
16307 |
|
16308 | }
|
16309 | else {
|
16310 |
|
16311 | if( gat != '' ) {
|
16312 |
|
16313 |
|
16314 |
|
16315 | url = 'https://photoslibrary.googleapis.com/v1/mediaItems:search';
|
16316 | }
|
16317 | else {
|
16318 |
|
16319 |
|
16320 | url = G.O.google2URL + '?nguserid=' + G.O.userID + '&ngalbumid=' + albumID + '&alt=json&v=3&kind=photo&' + maxResults;
|
16321 | }
|
16322 | }
|
16323 |
|
16324 | if( G.O.debugMode ) { console.log('Google Photos URL: ' + url); }
|
16325 |
|
16326 | PreloaderDisplay(true);
|
16327 | jQuery.ajaxSetup({ cache: false });
|
16328 | jQuery.support.cors = true;
|
16329 | try {
|
16330 | var tId = setTimeout( function() {
|
16331 |
|
16332 | PreloaderDisplay(false);
|
16333 | NanoAlert('Could not retrieve AJAX data...');
|
16334 | }, 60000 );
|
16335 |
|
16336 | jQuery.getJSON( url + '&callback=?', function(data) {
|
16337 |
|
16338 | if( data.nano_status == 'error' ) {
|
16339 | clearTimeout(tId);
|
16340 | PreloaderDisplay(false);
|
16341 | NanoAlert(G, "Could not retrieve Google data. Error: " + data.nano_message);
|
16342 | return;
|
16343 | }
|
16344 | clearTimeout(tId);
|
16345 | PreloaderDisplay(false);
|
16346 | GoogleParseData( albumIdx, kind, data );
|
16347 | AlbumPostProcess(albumID);
|
16348 | if( fnToCall !== null && fnToCall !== undefined) {
|
16349 | fnToCall( fnParam1, fnParam2, null );
|
16350 | }
|
16351 |
|
16352 | })
|
16353 | .fail( function(jqxhr, textStatus, error) {
|
16354 | clearTimeout(tId);
|
16355 | PreloaderDisplay(false);
|
16356 |
|
16357 | var k=''
|
16358 | for(var key in jqxhr) {
|
16359 | k+= key + '=' + jqxhr[key] +'<br>';
|
16360 | }
|
16361 | var err = textStatus + ', ' + error + ' ' + k + '<br><br>URL:'+url;
|
16362 | NanoAlert(G, "Could not retrieve Google data. Error: " + err);
|
16363 | });
|
16364 | }
|
16365 | catch(e) {
|
16366 | NanoAlert(G, "Could not retrieve Google data. Error: " + e);
|
16367 | }
|
16368 | }
|
16369 |
|
16370 |
|
16371 |
|
16372 |
|
16373 |
|
16374 | function GoogleParseData(albumIdx, kind, data) {
|
16375 |
|
16376 | if( G.O.debugMode ) {
|
16377 | console.log('Google Photos data:');
|
16378 | console.dir(data);
|
16379 | }
|
16380 | var albumID = G.I[albumIdx].GetID();
|
16381 |
|
16382 |
|
16383 | jQuery.each(data, function(i,data){
|
16384 |
|
16385 | if( typeof data === 'object' && data !== null ) {
|
16386 |
|
16387 | var itemDescription = '';
|
16388 | var itemTitle = '';
|
16389 | if( kind == 'image') {
|
16390 | if (data.description !== undefined ){
|
16391 | itemDescription = data.description
|
16392 | }
|
16393 | if( G.O.thumbnailLabel.get('title') != '' ) {
|
16394 | itemTitle = GetImageTitleFromURL( data.filename );
|
16395 | }
|
16396 | }
|
16397 | else {
|
16398 | itemTitle = data.title;
|
16399 | }
|
16400 | if( itemTitle == undefined ) {
|
16401 |
|
16402 | itemTitle = '';
|
16403 | }
|
16404 |
|
16405 | var itemID = data.id;
|
16406 | if( kind == 'album' ) {
|
16407 | if( !FilterAlbumName(itemTitle, itemID) || data.coverPhotoBaseUrl == undefined ) {
|
16408 | return true;
|
16409 | }
|
16410 | }
|
16411 |
|
16412 |
|
16413 | var newItem = NGY2Item.New( G, itemTitle, itemDescription, itemID, albumID, kind, '' );
|
16414 |
|
16415 | var width = 0;
|
16416 | var height = 0;
|
16417 |
|
16418 |
|
16419 | var src = '';
|
16420 | if( kind == 'image' ) {
|
16421 | src = data.baseUrl;
|
16422 | if( !G.O.viewerZoom && G.O.viewerZoom != undefined ) {
|
16423 | if( window.screen.width > window.screen.height ) {
|
16424 | src += '=w' + window.screen.width;
|
16425 | }
|
16426 | else {
|
16427 | src = s + '=h' + window.screen.height;
|
16428 | }
|
16429 | }
|
16430 | else {
|
16431 |
|
16432 | src += '=h' + data.mediaMetadata.height + '-w' + data.mediaMetadata.width;
|
16433 |
|
16434 |
|
16435 |
|
16436 | }
|
16437 |
|
16438 |
|
16439 | newItem.setMediaURL( src, 'img');
|
16440 |
|
16441 |
|
16442 | if( data.mediaMetadata.width !== undefined ) {
|
16443 | newItem.imageWidth = parseInt(data.mediaMetadata.width);
|
16444 | width = newItem.imageWidth;
|
16445 | }
|
16446 | if( data.mediaMetadata.height !== undefined ) {
|
16447 | newItem.imageHeight=parseInt(data.mediaMetadata.height);
|
16448 | height = newItem.imageHeight;
|
16449 | }
|
16450 |
|
16451 |
|
16452 |
|
16453 |
|
16454 |
|
16455 |
|
16456 | if( data.mediaMetadata.photo !== undefined ) {
|
16457 |
|
16458 | if( data.mediaMetadata.photo.exposureTime != undefined ) {
|
16459 | newItem.exif.exposure = data.mediaMetadata.photo.exposureTime;
|
16460 | }
|
16461 | if( data.mediaMetadata.photo.focalLength != undefined ) {
|
16462 | newItem.exif.focallength = data.mediaMetadata.photo.focalLength;
|
16463 | }
|
16464 | if( data.mediaMetadata.photo.apertureFNumber != undefined ) {
|
16465 | newItem.exif.fstop = data.mediaMetadata.photo.apertureFNumber;
|
16466 | }
|
16467 | if( data.mediaMetadata.photo.isoEquivalent != undefined ) {
|
16468 | newItem.exif.iso = data.mediaMetadata.photo.isoEquivalent;
|
16469 | }
|
16470 | if( data.mediaMetadata.photo.cameraModel != undefined ) {
|
16471 | newItem.exif.model = data.mediaMetadata.photo.cameraModel;
|
16472 | }
|
16473 | }
|
16474 |
|
16475 |
|
16476 | if( data.mediaMetadata.video !== undefined ) {
|
16477 | if( data.mediaMetadata.video.cameraModel != undefined ) {
|
16478 | newItem.exif.model = data.mediaMetadata.video.cameraModel;
|
16479 | }
|
16480 |
|
16481 | newItem.downloadURL = data.baseUrl + '=dv';
|
16482 |
|
16483 |
|
16484 |
|
16485 | }
|
16486 |
|
16487 | }
|
16488 | else {
|
16489 |
|
16490 | newItem.numberItems = data.mediaItemsCount;
|
16491 | }
|
16492 |
|
16493 |
|
16494 | newItem.thumbs=GoogleThumbSetSizes2('l1', newItem.thumbs, data, kind, height, width );
|
16495 | newItem.thumbs=GoogleThumbSetSizes2('lN', newItem.thumbs, data, kind,height ,width );
|
16496 |
|
16497 |
|
16498 | var fu = G.O.fnProcessData;
|
16499 | if( fu !== null ) {
|
16500 | typeof fu == 'function' ? fu(newItem, 'google2', data) : window[fu](newItem, 'google2', data);
|
16501 | }
|
16502 |
|
16503 | }
|
16504 | });
|
16505 |
|
16506 | G.I[albumIdx].contentIsLoaded = true;
|
16507 | }
|
16508 |
|
16509 |
|
16510 |
|
16511 | function GoogleThumbSetSizes2(level, tn, data, kind, height, width ) {
|
16512 | var sizes=['xs','sm','me','la','xl'];
|
16513 |
|
16514 | for(var i=0; i<sizes.length; i++ ) {
|
16515 |
|
16516 |
|
16517 | if( kind == 'image' ) {
|
16518 | if( G.tn.settings.width[level][sizes[i]] == 'auto' ) {
|
16519 | let ratio1 = width / height;
|
16520 | tn.height[level][sizes[i]] = G.tn.settings.getH(level, sizes[i]);
|
16521 | tn.width[level][sizes[i]] = G.tn.settings.getH(level, sizes[i]) * ratio1;
|
16522 | tn.url[level][sizes[i]] = data.baseUrl + '=h' + G.tn.settings.getH(level, sizes[i]);
|
16523 | continue;
|
16524 | }
|
16525 | if( G.tn.settings.height[level][sizes[i]] == 'auto' ) {
|
16526 | let ratio1 = height / width;
|
16527 | tn.width[level][sizes[i]] = G.tn.settings.getW(level, sizes[i]);
|
16528 | tn.height[level][sizes[i]] = G.tn.settings.getW(level, sizes[i]) * ratio1;
|
16529 | tn.url[level][sizes[i]] = data.baseUrl + '=w' + G.tn.settings.getW(level, sizes[i]);
|
16530 | continue;
|
16531 | }
|
16532 |
|
16533 | tn.height[level][sizes[i]] = G.tn.settings.getH(level, sizes[i]);
|
16534 | tn.width[level][sizes[i]] = G.tn.settings.getW(level, sizes[i]);
|
16535 | tn.url[level][sizes[i]] = data.baseUrl + '=w' + G.tn.settings.getW(level, sizes[i]);
|
16536 |
|
16537 | }
|
16538 |
|
16539 |
|
16540 | if( kind == 'album' ) {
|
16541 | if( G.tn.settings.width[level][sizes[i]] == 'auto' ) {
|
16542 | tn.url[level][sizes[i]]= data.coverPhotoBaseUrl + '=h' + G.tn.settings.getH(level, sizes[i]);
|
16543 | continue;
|
16544 | }
|
16545 | if( G.tn.settings.height[level][sizes[i]] == 'auto' ) {
|
16546 | tn.url[level][sizes[i]]= data.coverPhotoBaseUrl + '=w' + G.tn.settings.getW(level, sizes[i]);
|
16547 | continue;
|
16548 | }
|
16549 |
|
16550 | tn.url[level][sizes[i]]= data.coverPhotoBaseUrl + '=h' + G.tn.settings.getH(level, sizes[i]) + '-w' + G.tn.settings.getW(level, sizes[i]);
|
16551 |
|
16552 | }
|
16553 | }
|
16554 |
|
16555 | return tn;
|
16556 | }
|
16557 |
|
16558 |
|
16559 |
|
16560 |
|
16561 |
|
16562 | function Init() {
|
16563 | }
|
16564 |
|
16565 |
|
16566 |
|
16567 | var PreloaderDisplay = NGY2Tools.PreloaderDisplay.bind(G);
|
16568 |
|
16569 | var NanoAlert = NGY2Tools.NanoAlert;
|
16570 | var GetImageTitleFromURL = NGY2Tools.GetImageTitleFromURL.bind(G);
|
16571 | var FilterAlbumName = NGY2Tools.FilterAlbumName.bind(G);
|
16572 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
16573 |
|
16574 | switch( fnName ){
|
16575 | case 'AlbumGetContent':
|
16576 | var albumID = arguments[2],
|
16577 | callback2 = arguments[3],
|
16578 | cbParam1 = arguments[4],
|
16579 | cbParam2 = arguments[5];
|
16580 | AlbumGetContent(albumID, callback2, cbParam1, cbParam2);
|
16581 | break;
|
16582 | case 'Init':
|
16583 | Init();
|
16584 | break;
|
16585 | case '':
|
16586 | break;
|
16587 | }
|
16588 |
|
16589 | };
|
16590 |
|
16591 |
|
16592 |
|
16593 | }));
|
16594 |
|
16595 |
|
16596 |
|
16597 |
|
16598 |
|
16599 |
|
16600 |
|
16601 |
|
16602 |
|
16603 |
|
16604 |
|
16605 |
|
16606 |
|
16607 |
|
16608 |
|
16609 |
|
16610 |
|
16611 |
|
16612 | (function (factory) {
|
16613 | "use strict";
|
16614 | if (typeof define === 'function' && define.amd) {
|
16615 |
|
16616 | define(['jquery', 'nanogallery2'], factory);
|
16617 | } else if (typeof exports === 'object' && typeof require === 'function') {
|
16618 |
|
16619 | factory(require(['jquery', 'nanogallery2']));
|
16620 | } else {
|
16621 |
|
16622 | factory(jQuery);
|
16623 | }
|
16624 | }(function ($) {
|
16625 |
|
16626 |
|
16627 | jQuery.nanogallery2.data_flickr = function (instance, fnName){
|
16628 | var G = instance;
|
16629 |
|
16630 |
|
16631 |
|
16632 | var Flickr = {
|
16633 | url: function() {
|
16634 |
|
16635 | return 'https://api.flickr.com/services/rest/';
|
16636 | },
|
16637 | thumbSize:' sq',
|
16638 | thumbAvailableSizes : new Array(75, 100, 150, 240, 500, 640),
|
16639 | thumbAvailableSizesStr : new Array('sq', 't', 'q', 's', 'm', 'z'),
|
16640 | photoSize : '0',
|
16641 | photoAvailableSizes : new Array(75, 100, 150, 240, 500, 640, 1024, 1024, 1600, 2048, 10000),
|
16642 | photoAvailableSizesStr : new Array('sq', 't', 'q', 's', 'm', 'z', 'b', 'l', 'h', 'k', 'o')
|
16643 | };
|
16644 |
|
16645 |
|
16646 |
|
16647 | var AlbumGetContent = function(albumID, fnToCall, fnParam1, fnParam2) {
|
16648 | if( G.O.flickrAPIKey == '' ) {
|
16649 | NanoAlert(G, 'Please set your Flickr API Key (option flickrAPIKey)');
|
16650 | }
|
16651 |
|
16652 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
16653 | var url = '';
|
16654 | var kind = 'image';
|
16655 |
|
16656 | if( G.O.photoset.toUpperCase() == 'NONE' || G.O.album.toUpperCase() == 'NONE' ) {
|
16657 |
|
16658 | url = Flickr.url() + "?&method=flickr.people.getPublicPhotos&api_key=" + G.O.flickrAPIKey + "&user_id="+G.O.userID+"&extras=description,views,tags,url_o,url_sq,url_t,url_q,url_s,url_m,url_z,url_b,url_h,url_k&per_page=500&format=json";
|
16659 | }
|
16660 | else
|
16661 | if( G.I[albumIdx].GetID() == 0 ) {
|
16662 |
|
16663 | url = Flickr.url() + "?&method=flickr.photosets.getList&api_key=" + G.O.flickrAPIKey + "&user_id="+G.O.userID+"&per_page=500&primary_photo_extras=tags,url_o,url_sq,url_t,url_q,url_s,url_m,url_l,url_z,url_b,url_h,url_k&format=json";
|
16664 | kind='album';
|
16665 | }
|
16666 | else {
|
16667 |
|
16668 | url = Flickr.url() + "?&method=flickr.photosets.getPhotos&api_key=" + G.O.flickrAPIKey + "&photoset_id="+G.I[albumIdx].GetID()+"&extras=description,views,tags,url_o,url_sq,url_t,url_q,url_s,url_m,url_l,url_z,url_b,url_h,url_k&format=json";
|
16669 | }
|
16670 |
|
16671 | if( G.O.debugMode ) { console.log('Flickr URL: ' + url); }
|
16672 |
|
16673 | PreloaderDisplay(true);
|
16674 | jQuery.ajaxSetup({ cache: false });
|
16675 | jQuery.support.cors = true;
|
16676 |
|
16677 | var tId = setTimeout( function() {
|
16678 |
|
16679 | PreloaderDisplay(false);
|
16680 | NanoAlert(G, 'Could not retrieve AJAX data...');
|
16681 | }, 60000 );
|
16682 |
|
16683 | var sourceData=[];
|
16684 |
|
16685 |
|
16686 | var FlickrGetDone = function() {
|
16687 | clearTimeout(tId);
|
16688 | PreloaderDisplay(false);
|
16689 |
|
16690 |
|
16691 | sourceData = FilterByTags(sourceData, G.O.tagBlockList);
|
16692 |
|
16693 | if( kind == 'album' ) {
|
16694 | FlickrParsePhotoSets(albumIdx, albumID, sourceData);
|
16695 | }
|
16696 | else {
|
16697 | FlickrParsePhotos(albumIdx, albumID, sourceData);
|
16698 | }
|
16699 |
|
16700 | AlbumPostProcess( albumID );
|
16701 |
|
16702 | if( fnToCall !== null && fnToCall !== undefined) {
|
16703 | fnToCall( fnParam1, fnParam2, null );
|
16704 | }
|
16705 | }
|
16706 |
|
16707 |
|
16708 | var FlickrGetOnePage = function( url, page ) {
|
16709 | jQuery.getJSON( url + '&page=' + page + '&jsoncallback=?', function(data, status, xhr) {
|
16710 |
|
16711 | var pages=0;
|
16712 | if( kind == 'album' ) {
|
16713 | if( data.stat !== undefined && data.stat === 'fail' ) {
|
16714 | NanoAlert(G, "Could not retrieve Flickr album list: " + data.message + " (code: "+data.code+").");
|
16715 | return false;
|
16716 | }
|
16717 | sourceData=sourceData.concat(data.photosets.photoset);
|
16718 | pages=data.photosets.pages;
|
16719 | }
|
16720 | else {
|
16721 | if( G.O.photoset.toUpperCase() == 'NONE' || G.O.album.toUpperCase() == 'NONE' ) {
|
16722 |
|
16723 | sourceData=sourceData.concat(data.photos.photo);
|
16724 | pages=data.photos.pages;
|
16725 | }
|
16726 | else {
|
16727 |
|
16728 | if( data.stat !== undefined && data.stat === 'fail' ) {
|
16729 | NanoAlert(G, "Could not retrieve Flickr album: " + data.message + " (code: "+data.code+").");
|
16730 | return false;
|
16731 | }
|
16732 | if( G.I[albumIdx].title == '' ) {
|
16733 | G.I[albumIdx].title=data.photoset.title;
|
16734 | }
|
16735 | sourceData=sourceData.concat(data.photoset.photo);
|
16736 | pages=data.photoset.pages;
|
16737 | }
|
16738 |
|
16739 | }
|
16740 |
|
16741 | if( pages > page ) {
|
16742 | FlickrGetOnePage(url, page+1);
|
16743 | }
|
16744 | else {
|
16745 | FlickrGetDone();
|
16746 | }
|
16747 | })
|
16748 | .fail( function(jqxhr, textStatus, error) {
|
16749 | clearTimeout(tId);
|
16750 | PreloaderDisplay(false);
|
16751 | NanoAlert(G, "Could not retrieve Flickr ajax data: " + textStatus + ', ' + error);
|
16752 | });
|
16753 |
|
16754 | }
|
16755 |
|
16756 | FlickrGetOnePage(url, 1);
|
16757 |
|
16758 | }
|
16759 |
|
16760 |
|
16761 |
|
16762 |
|
16763 |
|
16764 | function FlickrParsePhotos( albumIdx, albumID, source ) {
|
16765 |
|
16766 | if( G.O.debugMode ) {
|
16767 | console.log('Flickr parse photos:');
|
16768 | console.dir(source);
|
16769 | }
|
16770 |
|
16771 | jQuery.each(source, function(i,item){
|
16772 |
|
16773 | var itemID = item.id;
|
16774 |
|
16775 | var imgUrl=item.url_sq;
|
16776 |
|
16777 |
|
16778 | var itemTitle = item.title;
|
16779 | if( G.O.thumbnailLabel.get('title') != '' ) {
|
16780 | itemTitle=GetImageTitleFromURL(imgUrl);
|
16781 | }
|
16782 |
|
16783 |
|
16784 | var itemDescription=item.description._content;
|
16785 |
|
16786 |
|
16787 | var imgW=75, imgH=75;
|
16788 | var start=Flickr.photoAvailableSizesStr.length-1;
|
16789 | if( G.O.flickrSkipOriginal ) { start--; }
|
16790 | for( var i = start; i>=0 ; i-- ) {
|
16791 | if( item['url_'+Flickr.photoAvailableSizesStr[i]] != undefined ) {
|
16792 | imgUrl=item['url_'+Flickr.photoAvailableSizesStr[i]];
|
16793 | imgW=parseInt(item['width_'+Flickr.photoAvailableSizesStr[i]]);
|
16794 | imgH=parseInt(item['height_'+Flickr.photoAvailableSizesStr[i]]);
|
16795 | break;
|
16796 | }
|
16797 | }
|
16798 |
|
16799 | var sizes = {};
|
16800 | for( var p in item ) {
|
16801 | if( p.indexOf('height_') == 0 || p.indexOf('width_') == 0 || p.indexOf('url_') == 0 ) {
|
16802 | sizes[p]=item[p];
|
16803 | }
|
16804 | }
|
16805 |
|
16806 |
|
16807 | var tags = item.tags !== undefined ? item.tags : '';
|
16808 |
|
16809 |
|
16810 | var newItem = NGY2Item.New( G, itemTitle, itemDescription, itemID, albumID, 'image', tags );
|
16811 |
|
16812 |
|
16813 | newItem.setMediaURL( imgUrl, 'img');
|
16814 | newItem.imageWidth = imgW;
|
16815 | newItem.imageHeight = imgH;
|
16816 |
|
16817 |
|
16818 |
|
16819 | var tn = {
|
16820 | url: { l1 : { xs:'', sm:'', me:'', la:'', xl:'' }, lN : { xs:'', sm:'', me:'', la:'', xl:'' } },
|
16821 | width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
16822 | height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } }
|
16823 | };
|
16824 | tn = FlickrRetrieveImages(tn, item, 'l1' );
|
16825 | tn = FlickrRetrieveImages(tn, item, 'lN' );
|
16826 | newItem.thumbs=tn;
|
16827 |
|
16828 |
|
16829 | var fu = G.O.fnProcessData;
|
16830 | if( fu !== null ) {
|
16831 | typeof fu == 'function' ? fu(newItem, 'flickr', item) : window[fu](newItem, 'flickr', item);
|
16832 | }
|
16833 |
|
16834 |
|
16835 | });
|
16836 | G.I[albumIdx].contentIsLoaded=true;
|
16837 |
|
16838 | }
|
16839 |
|
16840 |
|
16841 |
|
16842 |
|
16843 |
|
16844 | function FlickrParsePhotoSets( albumIdx, albumID, source ) {
|
16845 |
|
16846 | if( G.O.debugMode ) {
|
16847 | console.log('Flickr parse list of albums:');
|
16848 | console.dir(source);
|
16849 | }
|
16850 |
|
16851 | jQuery.each(source, function(i,item){
|
16852 |
|
16853 | var itemTitle = item.title._content;
|
16854 |
|
16855 | if( item.visibility_can_see_set == 0 ) { return true; }
|
16856 |
|
16857 | if( FilterAlbumName(itemTitle, item.id) ) {
|
16858 | var itemID=item.id;
|
16859 |
|
16860 | var itemDescription = item.description._content != undefined ? item.description._content : '';
|
16861 |
|
16862 | var sizes = {};
|
16863 | for( var p in item.primary_photo_extras) {
|
16864 | sizes[p] = item.primary_photo_extras[p];
|
16865 | }
|
16866 | var tags='';
|
16867 | if( item.primary_photo_extras !== undefined ) {
|
16868 | if( item.primary_photo_extras.tags !== undefined ) {
|
16869 | tags = item.primary_photo_extras.tags;
|
16870 | }
|
16871 | }
|
16872 |
|
16873 | var newItem = NGY2Item.New( G, itemTitle, itemDescription, itemID, albumID, 'album', tags );
|
16874 | newItem.numberItems = item.photos;
|
16875 | newItem.thumbSizes = sizes;
|
16876 |
|
16877 | var tn = {
|
16878 | url: { l1 : { xs:'', sm:'', me:'', la:'', xl:'' }, lN : { xs:'', sm:'', me:'', la:'', xl:'' } },
|
16879 | width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
16880 | height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } }
|
16881 | };
|
16882 | tn = FlickrRetrieveImages(tn, item.primary_photo_extras, 'l1' );
|
16883 | tn = FlickrRetrieveImages(tn, item.primary_photo_extras, 'lN' );
|
16884 | newItem.thumbs = tn;
|
16885 |
|
16886 |
|
16887 | var fu = G.O.fnProcessData;
|
16888 | if( fu !== null ) {
|
16889 | typeof fu == 'function' ? fu(newItem, 'flickr', item) : window[fu](newItem, 'flickr', item);
|
16890 | }
|
16891 |
|
16892 | }
|
16893 | });
|
16894 |
|
16895 | G.I[albumIdx].contentIsLoaded=true;
|
16896 | }
|
16897 |
|
16898 | function FlickrRetrieveImages(tn, item, level ) {
|
16899 |
|
16900 | var sf=1;
|
16901 | if( G.tn.opt[level].crop === true ) {
|
16902 | sf=G.O.thumbnailCropScaleFactor;
|
16903 | }
|
16904 |
|
16905 |
|
16906 | var sizes=['xs','sm','me','la','xl'];
|
16907 | for( var i=0; i<sizes.length; i++ ) {
|
16908 | if( G.tn.settings.width[level][sizes[i]] == 'auto' || G.tn.settings.width[level][sizes[i]] == '' ) {
|
16909 | let sdir='height_';
|
16910 | let tsize=Math.ceil( G.tn.settings.height[level][sizes[i]] * G.tn.scale * sf * G.tn.settings.mosaic[level+'Factor']['h'][sizes[i]] );
|
16911 | let one=FlickrRetrieveOneImage(sdir, tsize, item );
|
16912 | tn.url[level][sizes[i]]=one.url;
|
16913 | tn.width[level][sizes[i]]=one.width;
|
16914 | tn.height[level][sizes[i]]=one.height;
|
16915 | }
|
16916 | else
|
16917 | if( G.tn.settings.height[level][sizes[i]] == 'auto' || G.tn.settings.height[level][sizes[i]] == '' ) {
|
16918 | let sdir='width_';
|
16919 | let tsize=Math.ceil( G.tn.settings.width[level][sizes[i]] * G.tn.scale * sf * G.tn.settings.mosaic[level+'Factor']['w'][sizes[i]] );
|
16920 | let one=FlickrRetrieveOneImage(sdir, tsize, item );
|
16921 | tn.url[level][sizes[i]]=one.url;
|
16922 | tn.width[level][sizes[i]]=one.width;
|
16923 | tn.height[level][sizes[i]]=one.height;
|
16924 | }
|
16925 | else {
|
16926 | let sdir='height_';
|
16927 | let tsize=Math.ceil( G.tn.settings.height[level][sizes[i]] * G.tn.scale * sf * G.tn.settings.mosaic[level+'Factor']['h'][sizes[i]] );
|
16928 | if( G.tn.settings.width[level][sizes[i]] > G.tn.settings.height[level][sizes[i]] ) {
|
16929 | sdir='width_';
|
16930 | tsize=Math.ceil( G.tn.settings.width[level][sizes[i]] * G.tn.scale * sf * G.tn.settings.mosaic[level+'Factor']['w'][sizes[i]] );
|
16931 | }
|
16932 | let one=FlickrRetrieveOneImage(sdir, tsize, item );
|
16933 | tn.url[level][sizes[i]]=one.url;
|
16934 | tn.width[level][sizes[i]]=one.width;
|
16935 | tn.height[level][sizes[i]]=one.height;
|
16936 | }
|
16937 | }
|
16938 | return tn;
|
16939 | }
|
16940 |
|
16941 | function FlickrRetrieveOneImage(sdir, tsize, item ) {
|
16942 | var one={ url: '', width: 0, height: 0 };
|
16943 | var tnIndex=0;
|
16944 | for( var j=0; j < Flickr.thumbAvailableSizes.length; j++ ) {
|
16945 | var size=item[sdir+Flickr.photoAvailableSizesStr[j]];
|
16946 | if( size != undefined ) {
|
16947 | tnIndex=j;
|
16948 | if( size >= tsize ) {
|
16949 | break;
|
16950 | }
|
16951 | }
|
16952 | }
|
16953 | var fSize=Flickr.photoAvailableSizesStr[tnIndex];
|
16954 | one.url = item['url_'+fSize];
|
16955 | one.width = parseInt(item['width_'+fSize]);
|
16956 | one.height = parseInt(item['height_'+fSize]);
|
16957 | return one;
|
16958 | }
|
16959 |
|
16960 | var FilterByTags = function(data, tagBlockList) {
|
16961 | if( tagBlockList!= '' && data != undefined) {
|
16962 | data = data.filter(function (item) {
|
16963 | var regex = new RegExp( tagBlockList, "i");
|
16964 | var tagsToTest = [item.tags];
|
16965 | if ( Array.isArray(item.tags) ) {
|
16966 | tagsToTest = item.tags;
|
16967 | }
|
16968 | return ! tagsToTest.some( function (x) { return regex.test(x); } );
|
16969 | });
|
16970 | }
|
16971 | return data;
|
16972 | };
|
16973 |
|
16974 |
|
16975 |
|
16976 |
|
16977 |
|
16978 |
|
16979 |
|
16980 |
|
16981 |
|
16982 | function Init() {
|
16983 | return;
|
16984 | }
|
16985 |
|
16986 |
|
16987 |
|
16988 | var PreloaderDisplay = NGY2Tools.PreloaderDisplay.bind(G);
|
16989 | var NanoAlert = NGY2Tools.NanoAlert;
|
16990 | var GetImageTitleFromURL = NGY2Tools.GetImageTitleFromURL.bind(G);
|
16991 | var FilterAlbumName = NGY2Tools.FilterAlbumName.bind(G);
|
16992 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
16993 |
|
16994 | switch( fnName ){
|
16995 |
|
16996 |
|
16997 |
|
16998 |
|
16999 |
|
17000 | case 'AlbumGetContent':
|
17001 | var albumID = arguments[2],
|
17002 | callback = arguments[3],
|
17003 | cbParam1 = arguments[4],
|
17004 | cbParam2 = arguments[5];
|
17005 | AlbumGetContent(albumID, callback, cbParam1, cbParam2);
|
17006 | break;
|
17007 | case 'Init':
|
17008 | Init();
|
17009 | break;
|
17010 | case '':
|
17011 | break;
|
17012 | }
|
17013 |
|
17014 | };
|
17015 |
|
17016 |
|
17017 |
|
17018 | }));
|
17019 |
|
17020 |
|
17021 |
|