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 | (function (factory) {
|
30 | "use strict";
|
31 | if (typeof define === 'function' && define.amd) {
|
32 |
|
33 |
|
34 | define(['jquery'], factory);
|
35 | } else if (typeof exports === 'object' && typeof require === 'function') {
|
36 |
|
37 | factory(require('jquery'));
|
38 | } else {
|
39 |
|
40 | factory(jQuery);
|
41 | }
|
42 | }(function ($) {
|
43 |
|
44 | "use strict";
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | function ColorHelperToRGB( color ) {
|
50 | var obj = document.getElementById('ngyColorHelperToRGB');
|
51 | if (obj === null) {
|
52 | obj = document.createElement('div');
|
53 | obj.id = "ngyColorHelperToRGB";
|
54 | obj.style.cssText = 'display: none; color:' + color + ';';
|
55 | document.body.appendChild(obj);
|
56 | }
|
57 |
|
58 | var rgb = getComputedStyle(obj).color;
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | return rgb;
|
68 | }
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | function ShadeBlendConvert (p, from, to) {
|
78 | var rgba='';
|
79 | if( from.toUpperCase().substring(0,5) == 'RGBA(' ) {
|
80 | rgba='a';
|
81 | from='rgb('+from.substring(5);
|
82 | }
|
83 |
|
84 | if(typeof(p)!="number"||p<-1||p>1||typeof(from)!="string"||(from[0]!='r'&&from[0]!='#')||(typeof(to)!="string"&&typeof(to)!="undefined"))return null;
|
85 |
|
86 | function sbcRip(d){
|
87 | var l=d.length,RGB=new Object();
|
88 | if(l>9){
|
89 | d=d.split(",");
|
90 | if(d.length<3||d.length>4)return null;
|
91 | 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;
|
92 | }else{
|
93 | if(l==8||l==6||l<4)return null;
|
94 | if(l<6)d="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]+(l>4?d[4]+""+d[4]:"");
|
95 | 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;
|
96 | }
|
97 | return RGB;
|
98 | }
|
99 | 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);
|
100 | if(!f||!t)return null;
|
101 | 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])+")");
|
102 | 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);
|
103 | }
|
104 |
|
105 |
|
106 |
|
107 | function cloneJSObject( obj ) {
|
108 | if (obj === null || typeof obj !== 'object') {
|
109 | return obj;
|
110 | }
|
111 |
|
112 | var temp = obj.constructor();
|
113 | for (var key in obj) {
|
114 | temp[key] = cloneJSObject(obj[key]);
|
115 | }
|
116 | return temp;
|
117 | }
|
118 |
|
119 |
|
120 | function getViewport() {
|
121 | var $win = jQuery(window);
|
122 | return {
|
123 | l: $win.scrollLeft(),
|
124 | t: $win.scrollTop(),
|
125 | w: $win.width(),
|
126 | h: $win.height()
|
127 | }
|
128 | }
|
129 |
|
130 |
|
131 |
|
132 |
|
133 | |
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 | function inViewportVert( $elt, threshold ) {
|
155 | var wp = getViewport(),
|
156 | eltOS = $elt.offset(),
|
157 | th = $elt.outerHeight(true);
|
158 |
|
159 |
|
160 | if( wp.t == 0 && (eltOS.top) <= (wp.t + wp.h ) ) { return true; }
|
161 |
|
162 | if( eltOS.top >= wp.t && (eltOS.top + th) <= (wp.t + wp.h - threshold) ) {
|
163 | return true;
|
164 | }
|
165 | else {
|
166 | return false;
|
167 | }
|
168 | }
|
169 |
|
170 | function topInViewportVert( $elt, threshold ) {
|
171 | var wp = getViewport(),
|
172 | eltOS = $elt.offset();
|
173 |
|
174 | if( eltOS.top >= wp.t && eltOS.top <= (wp.t + wp.h - threshold) ) {
|
175 | return true;
|
176 | }
|
177 | else {
|
178 | return false;
|
179 | }
|
180 | }
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 | function setElementOnTop( start, elt ) {
|
198 | var highest_index = 0;
|
199 | if( start == '' ) { start = '*'; }
|
200 | jQuery(start).each(function() {
|
201 | var cur = parseInt(jQuery(this).css('z-index'));
|
202 | highest_index = cur > highest_index ? cur : highest_index;
|
203 | });
|
204 | highest_index++;
|
205 | jQuery(elt).css('z-index',highest_index);
|
206 | }
|
207 |
|
208 |
|
209 | var toType = function( obj ) {
|
210 |
|
211 | return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
|
212 | };
|
213 |
|
214 |
|
215 | $.nanogallery2 = function (elt, options) {
|
216 |
|
217 |
|
218 | var _this = this;
|
219 |
|
220 |
|
221 | _this.$e = jQuery(elt);
|
222 | _this.e = elt;
|
223 |
|
224 |
|
225 | _this.$e.data('nanogallery2data', _this);
|
226 |
|
227 | _this.init = function () {
|
228 |
|
229 |
|
230 | if (typeof window.NGY2Item === 'undefined') {
|
231 |
|
232 | window.NGY2Tools = (function () {
|
233 |
|
234 | function NGY2Tools() {
|
235 | var nextId = 1;
|
236 | }
|
237 |
|
238 |
|
239 | NGY2Tools.FilterAlbumName = function( title, ID ) {
|
240 | var s = title.toUpperCase();
|
241 | if( this.albumList.length > 0 ) {
|
242 | for( var j=0; j < this.albumList.length; j++) {
|
243 | if( s === this.albumList[j].toUpperCase() || ID === this.albumList[j] ) {
|
244 | return true;
|
245 | }
|
246 | }
|
247 | }
|
248 | else {
|
249 | var found = false;
|
250 | if( this.allowList !== null ) {
|
251 |
|
252 | for( var j = 0; j < this.allowList.length; j++) {
|
253 | if( s.indexOf(this.allowList[j]) !== -1 ) {
|
254 | found = true;
|
255 | }
|
256 | }
|
257 | if( !found ) { return false; }
|
258 | }
|
259 |
|
260 |
|
261 | if( this.blockList !== null ) {
|
262 |
|
263 | for( var j = 0; j < this.blockList.length; j++) {
|
264 | if( s.indexOf(this.blockList[j]) !== -1 ) {
|
265 | return false;
|
266 | }
|
267 | }
|
268 | }
|
269 | return true;
|
270 | }
|
271 | };
|
272 |
|
273 |
|
274 |
|
275 |
|
276 | NGY2Tools.NanoAlert = function(context, msg, verbose) {
|
277 | NGY2Tools.NanoConsoleLog.call(context, msg);
|
278 | if( context.$E.conConsole != null ) {
|
279 | context.$E.conConsole.css({visibility: 'visible', minHeight: '100px'});
|
280 | if( verbose == false ) {
|
281 | context.$E.conConsole.append('<p>' + msg + '</p>');
|
282 | }
|
283 | else {
|
284 | context.$E.conConsole.append('<p>nanogallery2: '+ msg + ' [' + context.baseEltID + ']</p>');
|
285 | }
|
286 | }
|
287 | };
|
288 |
|
289 |
|
290 |
|
291 |
|
292 | NGY2Tools.NanoConsoleLog = function(context, msg) {
|
293 | if (window.console) { console.log('nanogallery2: ' + msg + ' [' + context.baseEltID + ']'); }
|
294 |
|
295 | };
|
296 |
|
297 |
|
298 |
|
299 |
|
300 | NGY2Tools.PreloaderDisplay = function(display) {
|
301 | if( display === true ) {
|
302 |
|
303 | this.$E.conLoadingB.removeClass('nanoGalleryLBarOff').addClass('nanoGalleryLBar');
|
304 |
|
305 | if( this.GOM.albumIdxLoading != undefined && this.GOM.albumIdxLoading != -1 ) {
|
306 | let item = this.I[this.GOM.albumIdxLoading];
|
307 | item.$Elts['.nGY2TnImg'].addClass('nGY2GThumbnailLoaderDisplayed');
|
308 | }
|
309 | }
|
310 | else {
|
311 |
|
312 | this.$E.conLoadingB.removeClass('nanoGalleryLBar').addClass('nanoGalleryLBarOff');
|
313 |
|
314 | if( this.GOM.albumIdxLoading != undefined && this.GOM.albumIdxLoading != -1 ) {
|
315 | let item = this.I[this.GOM.albumIdxLoading];
|
316 | item.$Elts['.nGY2TnImg'].removeClass('nGY2GThumbnailLoaderDisplayed');
|
317 | }
|
318 | }
|
319 | };
|
320 |
|
321 |
|
322 |
|
323 |
|
324 | NGY2Tools.AreaShuffle = function (o) {
|
325 | for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
|
326 | return o;
|
327 | };
|
328 |
|
329 |
|
330 |
|
331 | NGY2Tools.GetImageTitleFromURL = function( imageURL ) {
|
332 | if( this.O.thumbnailLabel.get('title') == '%filename' ) {
|
333 | return (imageURL.split('/').pop()).replace('_',' ');
|
334 | }
|
335 |
|
336 | if( this.O.thumbnailLabel.get('title') == '%filenameNoExt' ) {
|
337 | var s=imageURL.split('/').pop();
|
338 | return (s.split('.').shift()).replace('_',' ');
|
339 | }
|
340 |
|
341 | return '';
|
342 | };
|
343 |
|
344 |
|
345 |
|
346 |
|
347 | NGY2Tools.AlbumPostProcess = function(albumID) {
|
348 |
|
349 |
|
350 |
|
351 | var sortOrder = this.gallerySorting[this.GOM.curNavLevel];
|
352 | var maxItems = this.galleryMaxItems[this.GOM.curNavLevel];
|
353 |
|
354 | if( sortOrder != '' || maxItems > 0 ) {
|
355 |
|
356 |
|
357 | var currentAlbum = this.I.filter( function( obj ) {
|
358 | return( obj.albumID == albumID && obj.kind != 'albumUp' );
|
359 | });
|
360 |
|
361 |
|
362 | switch( sortOrder ) {
|
363 | case 'RANDOM':
|
364 | currentAlbum = NGY2Tools.AreaShuffle(currentAlbum);
|
365 | break;
|
366 | case 'REVERSED':
|
367 | currentAlbum = currentAlbum.reverse();
|
368 | break;
|
369 | case 'TITLEASC':
|
370 | currentAlbum.sort(function (a, b) {
|
371 | return( (a.title.toUpperCase() < b.title.toUpperCase()) ? -1 : ((a.title.toUpperCase() > b.title.toUpperCase()) ? 1 : 0) );
|
372 | });
|
373 | break;
|
374 | case 'TITLEDESC':
|
375 | currentAlbum.sort(function (a, b) {
|
376 | return( (a.title.toUpperCase() > b.title.toUpperCase()) ? -1 : ((a.title.toUpperCase() < b.title.toUpperCase()) ? 1 : 0) );
|
377 | });
|
378 | break;
|
379 | }
|
380 |
|
381 |
|
382 | if( maxItems > 0 && currentAlbum.length > maxItems ) {
|
383 | currentAlbum.splice(maxItems - 1, currentAlbum.length-maxItems );
|
384 | }
|
385 |
|
386 |
|
387 | this.I.ngy2removeIf( function( obj ) {
|
388 | return( obj.albumID == albumID && obj.kind != 'albumUp' );
|
389 | });
|
390 |
|
391 |
|
392 | this.I.push.apply(this.I, currentAlbum);
|
393 |
|
394 | }
|
395 | };
|
396 |
|
397 | return NGY2Tools;
|
398 | })();
|
399 |
|
400 |
|
401 |
|
402 |
|
403 | window.NGY2Item = (function() {
|
404 | var nextId = 1;
|
405 |
|
406 |
|
407 | function NGY2Item( itemID ) {
|
408 |
|
409 | var ID = 0;
|
410 |
|
411 |
|
412 | if( itemID === undefined || itemID === null ) {
|
413 | ID = nextId++;
|
414 | }
|
415 | else {
|
416 | ID = itemID;
|
417 | }
|
418 | this.GetID = function () { return ID; };
|
419 |
|
420 |
|
421 | this.kind = '';
|
422 | this.mediaKind = 'img';
|
423 | this.mediaMarkup = '';
|
424 | this.G = null;
|
425 | this.title = '';
|
426 | this.description = '';
|
427 | this.albumID = 0;
|
428 | this.src = '';
|
429 | this.width = 0;
|
430 | this.height = 0;
|
431 | this.destinationURL = '';
|
432 | this.downloadURL = '';
|
433 | this.author = '';
|
434 | this.left = 0;
|
435 | this.top = 0;
|
436 | this.width = 0;
|
437 | this.height = 0;
|
438 | this.resizedContentWidth= 0;
|
439 | this.resizedContentHeight= 0;
|
440 | this.thumbs = {
|
441 | url: { l1: { xs: '', sm:'', me: '', la: '', xl: '' }, lN: { xs: '', sm: '', me: '', la:'', xl: '' } },
|
442 | width: { l1: { xs: 0, sm: 0, me: 0, la: 0 , xl: 0 }, lN: { xs: 0 , sm: 0, me: 0, la: 0, xl: 0 } },
|
443 | height: { l1: { xs: 0, sm: 0, me: 0, la: 0 , xl: 0 }, lN: { xs: 0, sm: 0, me: 0, la: 0, xl: 0 } }
|
444 | };
|
445 | this.thumbnailImgRevealed = false;
|
446 | this.imageDominantColors = null;
|
447 | this.imageDominantColor = null;
|
448 | this.featured = false;
|
449 | this.flickrThumbSizes = {};
|
450 | this.picasaThumbs = null;
|
451 | this.hovered = false;
|
452 | this.hoverInitDone = false;
|
453 | this.contentIsLoaded = false;
|
454 | this.contentLength = 0;
|
455 | this.numberItems = 0;
|
456 | this.mediaNumber = 0;
|
457 | this.mediaCounter = 0;
|
458 | this.eltTransform = [];
|
459 | this.eltFilter = [];
|
460 | this.eltEffect = [];
|
461 | this.paginationLastPage = 0;
|
462 | this.paginationLastWidth = 0;
|
463 | this.customData = {};
|
464 | this.selected = false;
|
465 | this.imageWidth = 0;
|
466 | this.imageHeight = 0;
|
467 | this.$elt = null;
|
468 | this.$Elts = [];
|
469 | this.tags = [];
|
470 | this.albumTagList = [];
|
471 | this.albumTagListSel = [];
|
472 | this.exif = { exposure: '', flash: '', focallength: '', fstop: '', iso: '', model: '', time: '', location: ''};
|
473 | this.deleted = false;
|
474 | this.rotationAngle = 0;
|
475 | }
|
476 |
|
477 |
|
478 |
|
479 | NGY2Item.Get = function( instance, ID ) {
|
480 | var l = instance.I.length;
|
481 | for( var i = 0; i < l; i++ ) {
|
482 | if( instance.I[i].GetID() == ID ) {
|
483 | return instance.I[i];
|
484 | }
|
485 | }
|
486 | return null;
|
487 | };
|
488 |
|
489 | NGY2Item.GetIdx = function( instance, ID ) {
|
490 | var l = instance.I.length;
|
491 | for( var i = 0; i < l; i++ ) {
|
492 | if( instance.I[i].GetID() == ID ) {
|
493 | return i;
|
494 | }
|
495 | }
|
496 | return -1;
|
497 | };
|
498 |
|
499 |
|
500 | NGY2Item.New = function( instance, title, description, ID, albumID, kind, tags ) {
|
501 | var album = NGY2Item.Get( instance, albumID );
|
502 |
|
503 |
|
504 | if( instance.O.titleTranslationMap !== null ) {
|
505 | let obj = instance.O.titleTranslationMap.find(o => o.title === title);
|
506 | if( obj !== undefined ) {
|
507 | title = obj.replace;
|
508 | }
|
509 | }
|
510 |
|
511 |
|
512 | if( albumID != -1 && albumID != 0 && title !='image gallery by nanogallery2 [build]' ) {
|
513 | if( instance.O.thumbnailLevelUp && album.getContentLength(false) == 0 && instance.O.album == '' ) {
|
514 |
|
515 | let item = new NGY2Item('0');
|
516 | instance.I.push( item );
|
517 | album.contentLength += 1;
|
518 | item.title = 'UP';
|
519 | item.albumID = albumID;
|
520 | item.kind = 'albumUp';
|
521 | item.G = instance;
|
522 |
|
523 | jQuery.extend( true, item.thumbs.width, instance.tn.defaultSize.width);
|
524 | jQuery.extend( true, item.thumbs.height, instance.tn.defaultSize.height);
|
525 | }
|
526 | }
|
527 |
|
528 | var item = NGY2Item.Get(instance, ID);
|
529 | if( item === null ){
|
530 |
|
531 | item = new NGY2Item(ID);
|
532 | instance.I.push(item);
|
533 | if( albumID != -1 && title !='image gallery by nanogallery2 [build]' ) {
|
534 | album.contentLength+=1;
|
535 | }
|
536 | }
|
537 | item.G = instance;
|
538 |
|
539 | item.albumID = albumID;
|
540 | item.kind = kind;
|
541 | if( kind == 'image' ) {
|
542 | album.mediaCounter += 1;
|
543 | item.mediaNumber = album.mediaCounter;
|
544 | }
|
545 |
|
546 |
|
547 | var kw = instance.O.thumbnailFeaturedKeyword;
|
548 | if( kw != '' ) {
|
549 |
|
550 | kw = kw.toUpperCase();
|
551 | var p = title.toUpperCase().indexOf(kw);
|
552 | if( p > -1) {
|
553 | item.featured = true;
|
554 |
|
555 | title = title.substring(0, p) + title.substring(p+kw.length, title.length);
|
556 | }
|
557 | p = description.toUpperCase().indexOf(kw);
|
558 | if( p > -1) {
|
559 | item.featured=true;
|
560 |
|
561 | description=description.substring(0, p) + description.substring(p + kw.length, description.length);
|
562 | }
|
563 | }
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 | if( typeof instance.galleryFilterTags.Get() == 'string' ) {
|
576 | switch( instance.galleryFilterTags.Get().toUpperCase() ) {
|
577 | case 'TITLE': {
|
578 | let re = /(?:^|\W)#(\w+)(?!\w)/g, match, matches = [];
|
579 |
|
580 | while (match = re.exec(title)) {
|
581 | matches.push(match[1].replace(/^\s*|\s*$/, ''));
|
582 | }
|
583 | item.setTags(matches);
|
584 | title = title.split('#').join('');
|
585 | break;
|
586 | }
|
587 | case 'DESCRIPTION': {
|
588 | let re = /(?:^|\W)#(\w+)(?!\w)/g, match2, matches2 = [];
|
589 |
|
590 | while (match2 = re.exec(description)) {
|
591 | matches2.push(match2[1].replace(/^\s*|\s*$/, ''));
|
592 | }
|
593 | item.setTags(matches2);
|
594 | description = description.split('#').join('');
|
595 | break;
|
596 | }
|
597 | }
|
598 | }
|
599 | else {
|
600 | if( tags != '' && tags != undefined ) {
|
601 |
|
602 | item.setTags(tags.split(' '));
|
603 | }
|
604 | }
|
605 |
|
606 |
|
607 |
|
608 |
|
609 | item.title = escapeHtml(instance, title);
|
610 | item.description = escapeHtml(instance, description);
|
611 | return item;
|
612 | };
|
613 |
|
614 |
|
615 |
|
616 | NGY2Item.prototype.delete = function( ) {
|
617 | this.deleted = true;
|
618 |
|
619 |
|
620 | this.G.I[NGY2Item.GetIdx(this.G, this.albumID)].contentLength--;
|
621 | this.G.I[NGY2Item.GetIdx(this.G, this.albumID)].numberItems--;
|
622 |
|
623 |
|
624 | var nbTn = this.G.GOM.items.length;
|
625 | var ID = this.GetID();
|
626 | var foundIdx = -1;
|
627 | var foundGOMidx = -1;
|
628 | for( var i = 0; i < nbTn ; i++ ) {
|
629 | var curTn = this.G.GOM.items[i];
|
630 | var item=this.G.I[curTn.thumbnailIdx];
|
631 | if( item.GetID() == ID ) {
|
632 |
|
633 | if( !curTn.neverDisplayed ) {
|
634 | foundIdx = curTn.thumbnailIdx;
|
635 | foundGOMidx = i;
|
636 | }
|
637 | }
|
638 | else {
|
639 | if( foundIdx != -1 ) {
|
640 | if( !curTn.neverDisplayed ) {
|
641 |
|
642 | item.$getElt('.nGY2GThumbnail').data('index', i-1);
|
643 | item.$getElt('.nGY2GThumbnailImg').data('index', i-1);
|
644 | }
|
645 | }
|
646 | }
|
647 | }
|
648 | if( foundIdx != -1 ) {
|
649 |
|
650 | var G = this.G;
|
651 | if( this.selected == true ) {
|
652 | this.selected = false;
|
653 | G.GOM.nbSelected--;
|
654 | }
|
655 | if( G.I[foundIdx].$elt !== null ) {
|
656 | G.I[foundIdx].$elt.remove();
|
657 | }
|
658 | G.GOM.items.splice(foundGOMidx, 1);
|
659 | if( G.GOM.lastDisplayedIdx != -1 ) {
|
660 | G.GOM.lastDisplayedIdx -= 1;
|
661 | }
|
662 | }
|
663 |
|
664 |
|
665 | }
|
666 |
|
667 | NGY2Item.prototype.addToGOM = function( ) {
|
668 |
|
669 | var ID = this.GetID();
|
670 | var l = this.G.I.length;
|
671 | for( var idx = 0; idx < l; idx++ ) {
|
672 | var item = this.G.I[idx];
|
673 | if( item.GetID() == ID ) {
|
674 | var w = item.thumbImg().width;
|
675 | var h = item.thumbImg().height;
|
676 |
|
677 | if( h == 0 ) {
|
678 | h = this.G.tn.defaultSize.getHeight();
|
679 | }
|
680 | if( w == 0 ) {
|
681 | w = this.G.tn.defaultSize.getWidth();
|
682 | }
|
683 |
|
684 | var tn = new this.G.GOM.GTn(idx, w, h);
|
685 | this.G.GOM.items.push(tn);
|
686 | break;
|
687 | }
|
688 | }
|
689 |
|
690 | }
|
691 |
|
692 |
|
693 |
|
694 |
|
695 | var entityMap = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '/': '/', '`': '`', '=': '=' };
|
696 | function escapeHtml (instance, string) {
|
697 | if( instance.O.allowHTMLinData == true ) {
|
698 | return string;
|
699 | }
|
700 | else {
|
701 | return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
|
702 | return entityMap[s];
|
703 | });
|
704 | }
|
705 | }
|
706 |
|
707 |
|
708 | NGY2Item.get_nextId = function () {
|
709 | return nextId;
|
710 | };
|
711 |
|
712 |
|
713 |
|
714 |
|
715 | NGY2Item.prototype.$getElt = function( elt, forceRefresh ) {
|
716 | if( this.$elt == null ) { return null; }
|
717 | if( this.$Elts[elt] !== undefined && !forceRefresh == true ) {
|
718 | return this.$Elts[elt];
|
719 | }
|
720 | else {
|
721 | if( elt == '.nGY2GThumbnail' ) {
|
722 | this.$Elts[elt]=this.$elt;
|
723 | }
|
724 | else {
|
725 | this.$Elts[elt]=this.$elt.find(elt);
|
726 | }
|
727 | return this.$Elts[elt];
|
728 | }
|
729 | };
|
730 |
|
731 |
|
732 | NGY2Item.prototype.removeElt = function( elt ) {
|
733 | if( this.$elt == null ) { return; }
|
734 | if( this.$Elts[elt] == undefined) { return; }
|
735 | this.$Elts[elt].remove();
|
736 | var index = this.$Elts.indexOf(elt);
|
737 | this.$Elts.splice(index, 1);
|
738 | };
|
739 |
|
740 |
|
741 | NGY2Item.prototype.album = function() {
|
742 | return this.G.I[NGY2Item.GetIdx(this.G, this.albumID)];
|
743 | };
|
744 |
|
745 |
|
746 | NGY2Item.prototype.mediaTransition = function( ) {
|
747 | if( this.G.O.viewerTransitionMediaKind.indexOf( this.mediaKind ) > -1 ) {
|
748 | return true;
|
749 | }
|
750 | return false;
|
751 | };
|
752 |
|
753 |
|
754 | NGY2Item.prototype.imageSet = function( src, w, h ) {
|
755 | this.src = src;
|
756 | this.width = w;
|
757 | this.height = h;
|
758 | };
|
759 |
|
760 |
|
761 | NGY2Item.prototype.thumbSet = function( src, w, h, screenSize, level ) {
|
762 | var lst=['xs','sm','me','la','xl'];
|
763 | if( typeof screenSize === 'undefined' || screenSize == '' || screenSize == null ) {
|
764 | for( var i=0; i< lst.length; i++ ) {
|
765 | if( typeof level === 'undefined' || level == '' ) {
|
766 | this.thumbs.url.l1[lst[i]]=src;
|
767 | this.thumbs.height.l1[lst[i]]=h;
|
768 | this.thumbs.width.l1[lst[i]]=w;
|
769 | this.thumbs.url.lN[lst[i]]=src;
|
770 | this.thumbs.height.lN[lst[i]]=h;
|
771 | this.thumbs.width.lN[lst[i]]=w;
|
772 | }
|
773 | else {
|
774 | this.thumbs.url[level][lst[i]]=src;
|
775 | this.thumbs.height[level][lst[i]]=h;
|
776 | this.thumbs.width[level][lst[i]]=w;
|
777 | }
|
778 | }
|
779 | }
|
780 | else {
|
781 | if( typeof level === 'undefined' || level == '' || level == null ) {
|
782 | this.thumbs.url.l1[screenSize]=src;
|
783 | this.thumbs.height.l1[screenSize]=h;
|
784 | this.thumbs.width.l1[screenSize]=w;
|
785 | this.thumbs.url.lN[screenSize]=src;
|
786 | this.thumbs.height.lN[screenSize]=h;
|
787 | this.thumbs.width.lN[screenSize]=w;
|
788 | }
|
789 | else {
|
790 | this.thumbs.url[level][screenSize]=src;
|
791 | this.thumbs.height[level][screenSize]=h;
|
792 | this.thumbs.width[level][screenSize]=w;
|
793 | }
|
794 | }
|
795 |
|
796 | for( var i=0; i< lst.length; i++ ) {
|
797 | this.thumbs.height.l1[lst[i]]=h;
|
798 | }
|
799 | for( var i=0; i< lst.length; i++ ) {
|
800 | 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() ) {
|
801 | this.thumbs.height.lN[lst[i]]=h;
|
802 | }
|
803 | }
|
804 | };
|
805 |
|
806 |
|
807 | NGY2Item.prototype.thumbSetImgHeight = function( h ) {
|
808 | var lst=['xs','sm','me','la','xl'];
|
809 | for( var i=0; i< lst.length; i++ ) {
|
810 | 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() ) {
|
811 | this.thumbs.height.l1[lst[i]]=h;
|
812 | }
|
813 | }
|
814 | for( var i=0; i< lst.length; i++ ) {
|
815 | 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() ) {
|
816 | this.thumbs.height.lN[lst[i]]=h;
|
817 | }
|
818 | }
|
819 | };
|
820 |
|
821 |
|
822 | NGY2Item.prototype.thumbSetImgWidth = function( w ) {
|
823 | var lst=['xs','sm','me','la','xl'];
|
824 | for( var i=0; i< lst.length; i++ ) {
|
825 | 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() ) {
|
826 | this.thumbs.width.l1[lst[i]]=w;
|
827 | }
|
828 | }
|
829 | for( var i=0; i< lst.length; i++ ) {
|
830 | 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() ) {
|
831 | this.thumbs.width.lN[lst[i]]=w;
|
832 | }
|
833 | }
|
834 | };
|
835 |
|
836 |
|
837 | NGY2Item.prototype.thumbImg = function () {
|
838 | var tnImg = { src: '', width: 0, height: 0 };
|
839 |
|
840 | if( this.title == 'image gallery by nanogallery2 [build]' ) {
|
841 | tnImg.src = this.G.emptyGif;
|
842 | tnImg.url = this.G.emptyGif;
|
843 | return tnImg;
|
844 | }
|
845 | tnImg.src = this.thumbs.url[this.G.GOM.curNavLevel][this.G.GOM.curWidth];
|
846 | tnImg.width = this.thumbs.width[this.G.GOM.curNavLevel][this.G.GOM.curWidth];
|
847 | tnImg.height = this.thumbs.height[this.G.GOM.curNavLevel][this.G.GOM.curWidth];
|
848 | return tnImg;
|
849 | };
|
850 |
|
851 |
|
852 | NGY2Item.prototype.setTags = function( tags ) {
|
853 | if( tags.length > 0 ) {
|
854 | this.tags = tags;
|
855 | var lstTags = this.album().albumTagList;
|
856 | for( var i = 0; i < tags.length; i++ ) {
|
857 | var tfound = false;
|
858 | for( var j = 0; j < lstTags.length; j++ ) {
|
859 | if( tags[i].toUpperCase() == lstTags[j].toUpperCase() ) {
|
860 | tfound = true;
|
861 | }
|
862 | }
|
863 | if( tfound == false) {
|
864 | this.album().albumTagList.push(tags[i])
|
865 |
|
866 | }
|
867 | }
|
868 | }
|
869 | };
|
870 |
|
871 |
|
872 | NGY2Item.prototype.checkTagFilter = function() {
|
873 | if( this.G.galleryFilterTags.Get() != false && this.album().albumTagList.length > 0 ) {
|
874 | if( this.G.O.thumbnailLevelUp && this.kind == 'albumUp' ) {
|
875 | return true;
|
876 | }
|
877 | var found = false;
|
878 | var lstTags = this.album().albumTagListSel;
|
879 | if( lstTags.length == 0 ) {
|
880 |
|
881 | return true;
|
882 | }
|
883 | for( var i = 0; i < this.tags.length; i++ ) {
|
884 | for( var j = 0; j < lstTags.length; j++ ) {
|
885 | if( this.tags[i].toUpperCase() == lstTags[j].toUpperCase() ) {
|
886 | found = true;
|
887 | break;
|
888 | }
|
889 | }
|
890 | }
|
891 | return found;
|
892 | }
|
893 | else
|
894 | return true;
|
895 | };
|
896 |
|
897 |
|
898 | NGY2Item.prototype.isSearchTagFound = function() {
|
899 | if( this.G.GOM.albumSearchTags == '' ) { return true; }
|
900 | if( this.G.O.thumbnailLevelUp && this.kind == 'albumUp' ) { return true; }
|
901 |
|
902 |
|
903 | for( var i = 0; i < this.tags.length; i++ ) {
|
904 | if( this.tags[i].toUpperCase().indexOf( this.G.GOM.albumSearchTags ) >= 0 ) {
|
905 | return true;
|
906 | }
|
907 | }
|
908 | return false;
|
909 | };
|
910 |
|
911 |
|
912 |
|
913 | NGY2Item.prototype.setMediaURL = function( url, mediaKind ) {
|
914 | this.src = url;
|
915 | this.mediaKind = mediaKind;
|
916 | if( mediaKind == 'img' ) {
|
917 | this.mediaMarkup = '<img class="nGY2ViewerMedia" src="' + url + '" alt=" " itemprop="contentURL" draggable="false">';
|
918 | }
|
919 | };
|
920 |
|
921 |
|
922 |
|
923 | NGY2Item.prototype.isToDisplay = function( albumID ) {
|
924 | return this.albumID == albumID && this.checkTagFilter() && this.isSearchFound() && this.isSearchTagFound() && this.deleted == false;
|
925 | };
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 | NGY2Item.prototype.getContentLength = function( filterTags ) {
|
932 | if( filterTags == false || this.albumTagList.length == 0 || this.G.galleryFilterTags.Get() == false ) {
|
933 | return this.contentLength;
|
934 | }
|
935 | else {
|
936 | var l = this.G.I.length;
|
937 | var cnt = 0;
|
938 | var albumID = this.GetID();
|
939 | for( var idx = 0; idx < l; idx++ ) {
|
940 | var item = this.G.I[idx];
|
941 | if( item.isToDisplay(albumID) ) {
|
942 | cnt++;
|
943 | }
|
944 | }
|
945 | return cnt;
|
946 | }
|
947 | };
|
948 |
|
949 | NGY2Item.prototype.isSearchFound = function() {
|
950 | if( this.G.GOM.albumSearch != '' ) {
|
951 | if( this.title.toUpperCase().indexOf( this.G.GOM.albumSearch ) == -1 ) {
|
952 | return false;
|
953 | }
|
954 | }
|
955 | return true;
|
956 | }
|
957 |
|
958 |
|
959 |
|
960 | NGY2Item.prototype.responsiveURL = function () {
|
961 | var url = '';
|
962 | switch(this.G.O.kind) {
|
963 | case '':
|
964 | url = this.src;
|
965 | break;
|
966 | case 'flickr':
|
967 | url = this.src;
|
968 | break;
|
969 | case 'picasa':
|
970 | case 'google':
|
971 | case 'google2':
|
972 | default:
|
973 | url = this.src;
|
974 | break;
|
975 | }
|
976 | return url;
|
977 | };
|
978 |
|
979 |
|
980 |
|
981 | NGY2Item.prototype.ThumbnailImageReveal = function () {
|
982 |
|
983 | if( this.thumbnailImgRevealed == false ) {
|
984 | this.thumbnailImgRevealed = true;
|
985 | new NGTweenable().tween({
|
986 | from: { opacity: 0 },
|
987 | to: { opacity: 1 },
|
988 | attachment: { item: this },
|
989 | delay: 30,
|
990 | duration: 400,
|
991 | easing: 'easeOutQuart',
|
992 | step: function (state, att) {
|
993 | var $e=att.item.$getElt('.nGY2TnImg');
|
994 | if( $e != null ) {
|
995 | $e.css( state );
|
996 | }
|
997 | }
|
998 | });
|
999 | }
|
1000 | };
|
1001 |
|
1002 |
|
1003 |
|
1004 | function ValueApplyPercent( str, percent ) {
|
1005 | str=String(str);
|
1006 | if( str === '0' || percent == 1 ) { return str; }
|
1007 | var n = Number(str.replace(/[a-zA-Z]/g, ''));
|
1008 | var ar = str.match(/([^\-0-9\.]+)/g);
|
1009 | var a = '';
|
1010 | if( ar != null && ar.length > 0 ) {
|
1011 | a = ar.join();
|
1012 | }
|
1013 |
|
1014 | if( isNaN(n) || n == 0 ) {
|
1015 | return str;
|
1016 | }
|
1017 |
|
1018 | n = n * percent;
|
1019 | return n + a;
|
1020 | }
|
1021 |
|
1022 |
|
1023 | NGY2Item.prototype.CSSTransformApply = function ( eltClass ) {
|
1024 | var obj = this.eltTransform[eltClass];
|
1025 |
|
1026 | if( eltClass == '.nGY2GThumbnail' ) {
|
1027 |
|
1028 | var nbStacks = obj.$elt.length-1;
|
1029 | var pTranslateX = 1;
|
1030 | var pTranslateY = 1;
|
1031 | var pTranslateZ = 1;
|
1032 | var pTranslate = 1;
|
1033 | var pRotateX = 1;
|
1034 | var pRotateY = 1;
|
1035 | var pRotateZ = 1;
|
1036 | var pRotate = 1;
|
1037 | var pScale = 1;
|
1038 | for( var n = nbStacks; n >= 0; n-- ) {
|
1039 |
|
1040 | 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) + ')';
|
1041 | if( !(this.G.IE <= 9) && !this.G.isGingerbread ) {
|
1042 | v += ' rotateX(' + ValueApplyPercent(obj.rotateX,pRotateX) + ') rotateY(' + ValueApplyPercent(obj.rotateY,pRotateY) + ') rotateZ(' + ValueApplyPercent(obj.rotateZ,pRotateZ) + ') rotate(' + ValueApplyPercent(obj.rotate,pRotate) + ')';
|
1043 | }
|
1044 | else {
|
1045 | v += ' rotate(' + ValueApplyPercent(obj.rotateZ,pRotateZ) + ')';
|
1046 | }
|
1047 | obj.$elt[n].style[this.G.CSStransformName] = v;
|
1048 |
|
1049 | if( nbStacks > 0 ) {
|
1050 |
|
1051 | pTranslateX -= this.G.tn.opt.Get('stacksTranslateX');
|
1052 | pTranslateY -= this.G.tn.opt.Get('stacksTranslateY');
|
1053 | pTranslateZ -= this.G.tn.opt.Get('stacksTranslateZ');
|
1054 | pRotateX -= this.G.tn.opt.Get('stacksRotateX');
|
1055 | pRotateY -= this.G.tn.opt.Get('stacksRotateY');
|
1056 | pRotateZ -= this.G.tn.opt.Get('stacksRotateZ');
|
1057 | pScale -= this.G.tn.opt.Get('stacksScale');
|
1058 | }
|
1059 | }
|
1060 | }
|
1061 | else {
|
1062 |
|
1063 | if( obj.$elt != null ) {
|
1064 | for( var n = 0; n < obj.$elt.length; n++ ) {
|
1065 | if( obj.$elt[n] != undefined ) {
|
1066 |
|
1067 | var v = 'translateX(' + obj.translateX + ') translateY(' + obj.translateY + ') translateZ(' + obj.translateZ + ') scale(' + obj.scale + ') translate(' + obj.translate + ')';
|
1068 | if( !(this.G.IE <= 9) && !this.G.isGingerbread ) {
|
1069 | v += ' rotateX(' + obj.rotateX + ') rotateY(' + obj.rotateY + ') rotateZ(' + obj.rotateZ + ') rotate(' + obj.rotate + ')';
|
1070 | }
|
1071 | else {
|
1072 | v += ' rotate(' + obj.rotateZ + ')';
|
1073 | }
|
1074 | obj.$elt[n].style[this.G.CSStransformName] = v;
|
1075 | }
|
1076 | }
|
1077 | }
|
1078 | }
|
1079 | };
|
1080 |
|
1081 |
|
1082 | NGY2Item.prototype.CSSTransformSet = function ( eltClass, transform, value, forceRefresh ) {
|
1083 | if( this.eltTransform[eltClass] == undefined ) {
|
1084 | this.eltTransform[eltClass] = { translateX: 0, translateY: 0, translateZ: 0, rotateX: 0, rotateY: 0, rotateZ: 0, scale: 1, translate: '0px,0px', rotate: 0 };
|
1085 | this.eltTransform[eltClass].$elt = this.$getElt(eltClass);
|
1086 | }
|
1087 | this.eltTransform[eltClass][transform] = value;
|
1088 | if( forceRefresh === true ) {
|
1089 | this.eltTransform[eltClass].$elt = this.$getElt(eltClass, true);
|
1090 | }
|
1091 | };
|
1092 |
|
1093 |
|
1094 | NGY2Item.prototype.CSSFilterApply = function ( eltClass ) {
|
1095 | var obj = this.eltFilter[eltClass];
|
1096 | var v = 'blur(' + obj.blur + ') brightness(' + obj.brightness + ') grayscale(' + obj.grayscale + ') sepia(' + obj.sepia + ') contrast(' + obj.contrast + ') opacity(' + obj.opacity + ') saturate(' + obj.saturate + ')';
|
1097 | if( obj.$elt != null ) {
|
1098 | for( var n = 0; n < obj.$elt.length; n++ ) {
|
1099 | if( obj.$elt[n] != undefined ) {
|
1100 | obj.$elt[n].style.WebkitFilter = v;
|
1101 | obj.$elt[n].style.filter = v;
|
1102 | }
|
1103 | }
|
1104 | }
|
1105 | };
|
1106 |
|
1107 |
|
1108 | NGY2Item.prototype.CSSFilterSet = function ( eltClass, filter, value, forceRefresh ) {
|
1109 | if( this.eltFilter[eltClass] == undefined ) {
|
1110 | this.eltFilter[eltClass] = { blur: 0, brightness: '100%', grayscale: '0%', sepia: '0%', contrast: '100%', opacity: '100%', saturate: '100%' };
|
1111 | this.eltFilter[eltClass].$elt = this.$getElt(eltClass);
|
1112 | }
|
1113 | this.eltFilter[eltClass][filter] = value;
|
1114 | if( forceRefresh === true ) {
|
1115 | this.eltTransform[eltClass].$elt = this.$getElt(eltClass, true);
|
1116 | }
|
1117 | };
|
1118 |
|
1119 |
|
1120 | NGY2Item.prototype.animate = function ( effect, delay, hoverIn ) {
|
1121 | if( this.$getElt() == null ) { return; }
|
1122 |
|
1123 | var context = {};
|
1124 | context.G = this.G;
|
1125 | context.item = this;
|
1126 | context.effect = effect;
|
1127 | context.hoverIn = hoverIn;
|
1128 | context.cssKind = '';
|
1129 | if( hoverIn ) {
|
1130 |
|
1131 |
|
1132 | if( this.eltEffect[effect.element] == undefined ) {
|
1133 | this.eltEffect[effect.element] = [];
|
1134 | }
|
1135 | if( this.eltEffect[effect.element][effect.type] == undefined ) {
|
1136 | this.eltEffect[effect.element][effect.type] = { initialValue: 0, lastValue: 0 };
|
1137 | }
|
1138 | if( effect.firstKeyframe ) {
|
1139 |
|
1140 | this.eltEffect[effect.element][effect.type] = { initialValue: effect.from, lastValue: effect.from};
|
1141 | }
|
1142 |
|
1143 | context.animeFrom = effect.from;
|
1144 | context.animeTo = effect.to;
|
1145 | context.animeDuration = parseInt(effect.duration);
|
1146 | context.animeDelay = 30 + parseInt(effect.delay + delay);
|
1147 | context.animeEasing = effect.easing;
|
1148 | }
|
1149 | else {
|
1150 |
|
1151 |
|
1152 | context.animeFrom = this.eltEffect[effect.element][effect.type].lastValue;
|
1153 | context.animeTo = this.eltEffect[effect.element][effect.type].initialValue;
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 | context.animeDuration = parseInt(effect.durationBack);
|
1165 | context.animeDelay = 30 + parseInt(effect.delayBack + delay);
|
1166 | context.animeEasing = effect.easingBack;
|
1167 | }
|
1168 |
|
1169 |
|
1170 |
|
1171 | var transform=['translateX', 'translateY', 'translateZ', 'scale', 'rotateX', 'rotateY', 'rotateZ'];
|
1172 | for( var i = 0; i < transform.length; i++ ) {
|
1173 | if( effect.type == transform[i] ) {
|
1174 | context.cssKind = 'transform';
|
1175 | break;
|
1176 | }
|
1177 | }
|
1178 |
|
1179 |
|
1180 | var filter=['blur', 'brightness', 'grayscale', 'sepia', 'contrast', 'opacity', 'saturate'];
|
1181 | for( var i = 0; i < filter.length; i++ ) {
|
1182 | if( effect.type == filter[i] ) {
|
1183 | context.cssKind = 'filter';
|
1184 | break;
|
1185 | }
|
1186 | }
|
1187 |
|
1188 | if( hoverIn && effect.element == '.nGY2GThumbnail' && ( effect.type == 'scale' || effect.type == 'rotateX') ) {
|
1189 | this.G.GOM.lastZIndex++;
|
1190 | this.$getElt(effect.element).css('z-index', this.G.GOM.lastZIndex);
|
1191 |
|
1192 | }
|
1193 |
|
1194 |
|
1195 | var tweenable = new NGTweenable();
|
1196 | context.tweenable=tweenable;
|
1197 | tweenable.tween({
|
1198 | attachment: context,
|
1199 | from: { 'v': context.animeFrom },
|
1200 | to: { 'v': context.animeTo },
|
1201 | duration: context.animeDuration,
|
1202 | delay: context.animeDelay,
|
1203 | easing: context.animeEasing,
|
1204 |
|
1205 | step: function (state, att) {
|
1206 | if( att.item.$getElt() == null ) {
|
1207 |
|
1208 | att.tweenable.stop(false);
|
1209 |
|
1210 | return;
|
1211 | }
|
1212 | if( att.hoverIn && !att.item.hovered ) {
|
1213 |
|
1214 | att.tweenable.stop(false);
|
1215 |
|
1216 | return;
|
1217 | }
|
1218 |
|
1219 | if( att.G.VOM.viewerDisplayed ) {
|
1220 | att.tweenable.stop(false);
|
1221 |
|
1222 | return;
|
1223 | }
|
1224 |
|
1225 |
|
1226 | if( state.v == att.animeFrom ) { return; }
|
1227 |
|
1228 | switch( att.cssKind ) {
|
1229 | case 'transform':
|
1230 |
|
1231 | att.item.CSSTransformSet(att.effect.element, att.effect.type, state.v);
|
1232 | att.item.CSSTransformApply( att.effect.element );
|
1233 |
|
1234 | break;
|
1235 | case 'filter':
|
1236 |
|
1237 | att.item.CSSFilterSet(att.effect.element, att.effect.type, state.v);
|
1238 | att.item.CSSFilterApply( att.effect.element );
|
1239 |
|
1240 | break;
|
1241 | default:
|
1242 | var v=state.v;
|
1243 | if( state.v.substring(0,4) == 'rgb(' || state.v.substring(0,5) == 'rgba(' ) {
|
1244 |
|
1245 |
|
1246 | v = ShadeBlendConvert(0, v);
|
1247 | }
|
1248 |
|
1249 | att.item.$getElt( att.effect.element ).css( att.effect.type, v );
|
1250 |
|
1251 | break;
|
1252 | }
|
1253 | if( hoverIn ) {
|
1254 |
|
1255 | att.item.eltEffect[att.effect.element][att.effect.type].lastValue = state.v;
|
1256 | }
|
1257 | },
|
1258 |
|
1259 | finish: function (state, att) {
|
1260 | if( hoverIn ) {
|
1261 |
|
1262 | att.item.eltEffect[att.effect.element][att.effect.type].lastValue = state.v;
|
1263 | }
|
1264 |
|
1265 | if( att.item.$getElt() == null ) {
|
1266 |
|
1267 | return;
|
1268 | }
|
1269 | if( att.hoverIn && !att.item.hovered ) {
|
1270 |
|
1271 | return;
|
1272 | }
|
1273 |
|
1274 | if( att.G.VOM.viewerDisplayed ) {
|
1275 | return;
|
1276 | }
|
1277 |
|
1278 |
|
1279 | switch( att.cssKind ) {
|
1280 | case 'transform':
|
1281 | att.item.CSSTransformSet(att.effect.element, att.effect.type, att.animeTo);
|
1282 | att.item.CSSTransformApply(att.effect.element);
|
1283 | break;
|
1284 | case 'filter':
|
1285 | att.item.CSSFilterSet(att.effect.element, att.effect.type, att.animeTo);
|
1286 | att.item.CSSFilterApply(att.effect.element);
|
1287 | break;
|
1288 | default:
|
1289 | att.item.$getElt(att.effect.element).css(att.effect.type, att.animeTo);
|
1290 | break;
|
1291 | }
|
1292 |
|
1293 | }
|
1294 | });
|
1295 | };
|
1296 |
|
1297 | return NGY2Item;
|
1298 | })();
|
1299 |
|
1300 | }
|
1301 |
|
1302 | _this.options = jQuery.extend(true, {}, jQuery.nanogallery2.defaultOptions, options);
|
1303 |
|
1304 | _this.nG2 = null;
|
1305 | _this.nG2 = new nanoGALLERY2();
|
1306 | _this.nG2.initiateGallery2(_this.e, _this.options );
|
1307 |
|
1308 | };
|
1309 |
|
1310 |
|
1311 | _this.test = function() {
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 | }
|
1318 |
|
1319 |
|
1320 |
|
1321 | _this.init();
|
1322 | };
|
1323 |
|
1324 | jQuery.nanogallery2.defaultOptions = {
|
1325 | kind : '',
|
1326 | userID : '',
|
1327 | photoset : '',
|
1328 | album: '',
|
1329 | blockList : 'scrapbook|profil|auto backup',
|
1330 | tagBlockList: '',
|
1331 | allowList : '',
|
1332 | albumList : '',
|
1333 | albumList2 : null,
|
1334 | RTL : false,
|
1335 | flickrSkipOriginal : true,
|
1336 | flickrAPIKey: '',
|
1337 | breadcrumbAutoHideTopLevel : true,
|
1338 | displayBreadcrumb : true,
|
1339 | breadcrumbOnlyCurrentLevel : true,
|
1340 | breadcrumbHideIcons : true,
|
1341 | theme : 'nGY2',
|
1342 | galleryTheme : 'dark',
|
1343 | viewerTheme : 'dark',
|
1344 | items : null,
|
1345 | itemsBaseURL : '',
|
1346 | thumbnailSelectable : false,
|
1347 | dataProvider: '',
|
1348 | allowHTMLinData: false,
|
1349 | locationHash : true,
|
1350 | slideshowDelay : 3000,
|
1351 | slideshowAutoStart : false,
|
1352 |
|
1353 | debugMode: false,
|
1354 |
|
1355 | titleTranslationMap: null,
|
1356 | galleryDisplayMoreStep : 2,
|
1357 | galleryDisplayMode : 'fullContent',
|
1358 | galleryL1DisplayMode : null,
|
1359 | galleryPaginationMode : 'rectangles',
|
1360 | galleryPaginationTopButtons : true,
|
1361 | galleryMaxRows : 2,
|
1362 | galleryL1MaxRows : null,
|
1363 | galleryLastRowFull: false,
|
1364 | galleryL1LastRowFull: null,
|
1365 | galleryLayoutEngine : 'default',
|
1366 | paginationSwipe: true,
|
1367 | paginationVisiblePages : 10,
|
1368 | galleryFilterTags : false,
|
1369 | galleryL1FilterTags : null,
|
1370 | galleryFilterTagsMode : 'single',
|
1371 | galleryL1FilterTagsMode : null,
|
1372 | galleryMaxItems : 0,
|
1373 | galleryL1MaxItems : null,
|
1374 | gallerySorting : '',
|
1375 | galleryL1Sorting : null,
|
1376 | galleryDisplayTransition : 'none',
|
1377 | galleryL1DisplayTransition : null,
|
1378 | galleryDisplayTransitionDuration : 1000,
|
1379 | galleryL1DisplayTransitionDuration : null,
|
1380 | galleryResizeAnimation : false,
|
1381 | galleryRenderDelay : 10,
|
1382 |
|
1383 | thumbnailCrop : true,
|
1384 | thumbnailL1Crop : null,
|
1385 | thumbnailCropScaleFactor : 1.5,
|
1386 | thumbnailLevelUp : false,
|
1387 | thumbnailAlignment : 'fillWidth',
|
1388 | thumbnailWidth : 300,
|
1389 | thumbnailL1Width : null,
|
1390 | thumbnailHeight : 200,
|
1391 | thumbnailL1Height : null,
|
1392 | thumbnailBaseGridHeight : 0,
|
1393 | thumbnailL1BaseGridHeight : null,
|
1394 | thumbnailGutterWidth : 2,
|
1395 | thumbnailL1GutterWidth : null,
|
1396 | thumbnailGutterHeight : 2,
|
1397 | thumbnailL1GutterHeight : null,
|
1398 | thumbnailBorderVertical : 2,
|
1399 | thumbnailL1BorderVertical : null,
|
1400 | thumbnailBorderHorizontal : 2,
|
1401 | thumbnailL1BorderHorizontal : null,
|
1402 | thumbnailFeaturedKeyword : '*featured',
|
1403 | thumbnailAlbumDisplayImage : false,
|
1404 | thumbnailHoverEffect2 : 'toolsAppear',
|
1405 | thumbnailBuildInit2 : '',
|
1406 | thumbnailStacks : 0,
|
1407 | thumbnailL1Stacks : null,
|
1408 | thumbnailStacksTranslateX : 0,
|
1409 | thumbnailL1StacksTranslateX : null,
|
1410 | thumbnailStacksTranslateY : 0,
|
1411 | thumbnailL1StacksTranslateY : null,
|
1412 | thumbnailStacksTranslateZ : 0,
|
1413 | thumbnailL1StacksTranslateZ : null,
|
1414 | thumbnailStacksRotateX : 0,
|
1415 | thumbnailL1StacksRotateX : null,
|
1416 | thumbnailStacksRotateY : 0,
|
1417 | thumbnailL1StacksRotateY : null,
|
1418 | thumbnailStacksRotateZ : 0,
|
1419 | thumbnailL1StacksRotateZ : null,
|
1420 | thumbnailStacksScale : 0,
|
1421 | thumbnailL1StacksScale : null,
|
1422 | thumbnailDisplayOutsideScreen: true,
|
1423 | thumbnailWaitImageLoaded: true,
|
1424 | thumbnailSliderDelay: 2000,
|
1425 | galleryBuildInit2 : '',
|
1426 | portable : false,
|
1427 | eventsDebounceDelay: 10,
|
1428 |
|
1429 | touchAnimation : false,
|
1430 | touchAnimationL1 : undefined,
|
1431 | touchAutoOpenDelay : 0,
|
1432 |
|
1433 | thumbnailLabel : {
|
1434 | position : 'overImage',
|
1435 | align: 'center',
|
1436 | valign: 'bottom',
|
1437 | display : true,
|
1438 | displayDescription : false,
|
1439 | titleMaxLength : 0,
|
1440 | titleMultiLine : false,
|
1441 | descriptionMaxLength : 0,
|
1442 | descriptionMultiLine : false,
|
1443 | hideIcons : true,
|
1444 | title : ''
|
1445 | },
|
1446 |
|
1447 | thumbnailToolbarImage : { topLeft: 'select', topRight : 'featured' },
|
1448 | thumbnailToolbarAlbum : { topLeft: 'select', topRight : 'counter' },
|
1449 | thumbnailDisplayOrder : '',
|
1450 | thumbnailL1DisplayOrder : null,
|
1451 | thumbnailDisplayInterval : 15,
|
1452 | thumbnailL1DisplayInterval : null,
|
1453 | thumbnailDisplayTransition : 'fadeIn',
|
1454 | thumbnailL1DisplayTransition : null,
|
1455 | thumbnailDisplayTransitionEasing : 'easeOutQuart',
|
1456 | thumbnailL1DisplayTransitionEasing : null,
|
1457 | thumbnailDisplayTransitionDuration: 240,
|
1458 | thumbnailL1DisplayTransitionDuration: null,
|
1459 | thumbnailOpenInLightox : true,
|
1460 | thumbnailOpenOriginal : false,
|
1461 |
|
1462 | lightboxStandalone: false,
|
1463 | viewer : 'internal',
|
1464 | viewerFullscreen: false,
|
1465 | imageTransition : 'swipe2',
|
1466 | viewerTransitionMediaKind : 'img',
|
1467 | viewerZoom : true,
|
1468 | viewerImageDisplay : '',
|
1469 | openOnStart : '',
|
1470 | viewerHideToolsDelay : 4000,
|
1471 | viewerToolbar : {
|
1472 | display : false,
|
1473 | position : 'bottom',
|
1474 | fullWidth : false,
|
1475 | align : 'center',
|
1476 | autoMinimize : 0,
|
1477 | standard : 'minimizeButton,label',
|
1478 | minimized : 'minimizeButton,label,infoButton,shareButton,fullscreenButton'
|
1479 | },
|
1480 | viewerTools : {
|
1481 | topLeft : 'pageCounter,playPauseButton',
|
1482 | topRight : 'rotateLeft,rotateRight,fullscreenButton,closeButton'
|
1483 | },
|
1484 | viewerGallery: 'bottomOverMedia',
|
1485 | viewerGalleryTWidth: 40,
|
1486 | viewerGalleryTHeight: 40,
|
1487 |
|
1488 | breakpointSizeSM : 480,
|
1489 | breakpointSizeME : 992,
|
1490 | breakpointSizeLA : 1200,
|
1491 | breakpointSizeXL : 1800,
|
1492 |
|
1493 | fnThumbnailInit : null,
|
1494 | fnThumbnailHoverInit : null,
|
1495 | fnThumbnailHover : null,
|
1496 | fnThumbnailHoverOut : null,
|
1497 | fnThumbnailDisplayEffect : null,
|
1498 | fnViewerInfo : null,
|
1499 | fnImgToolbarCustInit : null,
|
1500 | fnImgToolbarCustDisplay : null,
|
1501 | fnImgToolbarCustClick : null,
|
1502 | fnProcessData : null,
|
1503 | fnThumbnailSelection : null,
|
1504 | fnGalleryRenderStart : null,
|
1505 | fnGalleryRenderEnd : null,
|
1506 | fnGalleryObjectModelBuilt : null,
|
1507 | fnGalleryLayoutApplied : null,
|
1508 | fnThumbnailClicked : null,
|
1509 | fnShoppingCartUpdated : null,
|
1510 | fnThumbnailToolCustAction : null,
|
1511 | fnThumbnailOpen : null,
|
1512 | fnImgDisplayed : null,
|
1513 | fnPopupMediaInfo : null,
|
1514 |
|
1515 | i18n : {
|
1516 | 'breadcrumbHome' : 'Galleries', 'breadcrumbHome_FR' : 'Galeries',
|
1517 | 'thumbnailImageTitle' : '', 'thumbnailAlbumTitle' : '',
|
1518 | 'thumbnailImageDescription' : '', 'thumbnailAlbumDescription' : '',
|
1519 | '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'
|
1520 | },
|
1521 | icons : {
|
1522 |
|
1523 | thumbnailAlbum: '<i class="nGY2Icon-folder-empty"></i>',
|
1524 | thumbnailImage: '<i class="nGY2Icon-picture"></i>',
|
1525 | breadcrumbAlbum: '<i class="nGY2Icon-folder-empty"></i>',
|
1526 | breadcrumbHome: '<i class="nGY2Icon-home"></i>',
|
1527 | breadcrumbSeparator: '<i class="nGY2Icon-left-open"></i>',
|
1528 | breadcrumbSeparatorRtl: '<i class="nGY2Icon-right-open"></i>',
|
1529 | navigationFilterSelected: '<i style="color:#fff;" class="nGY2Icon-ok"></i>',
|
1530 | navigationFilterUnselected: '<i style="color:#ddd;opacity:0.3;" class="nGY2Icon-circle-empty"></i>',
|
1531 | navigationFilterSelectedAll: '<i class="nGY2Icon-ccw"></i>',
|
1532 | navigationPaginationPrevious: '<i class="nGY2Icon-ngy2_chevron-left"></i>',
|
1533 | navigationPaginationNext: '<i class="nGY2Icon-ngy2_chevron-right"></i>',
|
1534 | thumbnailSelected: '<i style="color:#bff;" class="nGY2Icon-ok-circled"></i>',
|
1535 | thumbnailUnselected: '<i style="color:#bff;" class="nGY2Icon-circle-empty"></i>',
|
1536 | thumbnailFeatured: '<i style="color:#dd5;" class="nGY2Icon-star"></i>',
|
1537 | thumbnailCounter: '<i class="nGY2Icon-picture"></i>',
|
1538 | thumbnailShare: '<i class="nGY2Icon-ngy2_share2"></i>',
|
1539 | thumbnailDownload: '<i class="nGY2Icon-ngy2_download2"></i>',
|
1540 | thumbnailInfo: '<i class="nGY2Icon-ngy2_info2"></i>',
|
1541 | thumbnailShoppingcart: '<i class="nGY2Icon-basket"></i>',
|
1542 | thumbnailDisplay: '<i class="nGY2Icon-resize-full"></i>',
|
1543 | thumbnailCustomTool1: 'T1',
|
1544 | thumbnailCustomTool2: 'T2',
|
1545 | thumbnailCustomTool3: 'T3',
|
1546 | thumbnailCustomTool4: 'T4',
|
1547 | thumbnailCustomTool5: 'T5',
|
1548 | thumbnailCustomTool6: 'T6',
|
1549 | thumbnailCustomTool7: 'T7',
|
1550 | thumbnailCustomTool8: 'T8',
|
1551 | thumbnailCustomTool9: 'T9',
|
1552 | thumbnailCustomTool10: 'T10',
|
1553 | thumbnailAlbumUp: '<i style="font-size: 3em;" class="nGY2Icon-ngy2_chevron_up2"></i>',
|
1554 | paginationNext: '<i class="nGY2Icon-right-open"></i>',
|
1555 | paginationPrevious: '<i class="nGY2Icon-left-open"></i>',
|
1556 | galleryMoreButton: '<i class="nGY2Icon-picture"></i> <i class="nGY2Icon-right-open"></i>',
|
1557 | buttonClose: '<i class="nGY2Icon-ngy2_close2"></i>',
|
1558 | viewerPrevious: '<i class="nGY2Icon-ngy2_chevron-left"></i>',
|
1559 | viewerNext: '<i class="nGY2Icon-ngy2_chevron-right"></i>',
|
1560 | viewerImgPrevious: '<i class="nGY2Icon-ngy2_chevron_left3"></i>',
|
1561 | viewerImgNext: '<i class="nGY2Icon-ngy2_chevron_right3"></i>',
|
1562 | viewerDownload: '<i class="nGY2Icon-ngy2_download2"></i>',
|
1563 | viewerToolbarMin: '<i class="nGY2Icon-ellipsis-vert"></i>',
|
1564 | viewerToolbarStd: '<i class="nGY2Icon-menu"></i>',
|
1565 | viewerPlay: '<i class="nGY2Icon-play"></i>',
|
1566 | viewerPause: '<i class="nGY2Icon-pause"></i>',
|
1567 | viewerFullscreenOn: '<i class="nGY2Icon-resize-full"></i>',
|
1568 | viewerFullscreenOff: '<i class="nGY2Icon-resize-small"></i>',
|
1569 | viewerZoomIn: '<i class="nGY2Icon-ngy2_zoom_in2"></i>',
|
1570 | viewerZoomOut: '<i class="nGY2Icon-ngy2_zoom_out2"></i>',
|
1571 | viewerLinkOriginal: '<i class="nGY2Icon-ngy2_external2"></i>',
|
1572 | viewerInfo: '<i class="nGY2Icon-ngy2_info2"></i>',
|
1573 | viewerShare: '<i class="nGY2Icon-ngy2_share2"></i>',
|
1574 | viewerRotateLeft: '<i class="nGY2Icon-ccw"></i>',
|
1575 | viewerRotateRight: '<i class="nGY2Icon-cw"></i>',
|
1576 | viewerShoppingcart: '<i class="nGY2Icon-basket"></i>',
|
1577 | user: '<i class="nGY2Icon-user"></i>',
|
1578 | location: '<i class="nGY2Icon-location"></i>',
|
1579 | picture: '<i class="nGY2Icon-picture"></i>',
|
1580 | config: '<i class="nGY2Icon-wrench"></i>',
|
1581 | shareFacebook: '<i style="color:#3b5998;" class="nGY2Icon-facebook-squared"></i>',
|
1582 | shareTwitter: '<i style="color:#00aced;" class="nGY2Icon-twitter-squared"></i>',
|
1583 |
|
1584 | shareTumblr: '<i style="color:#32506d;" class="nGY2Icon-tumblr-squared"></i>',
|
1585 | sharePinterest: '<i style="color:#cb2027;" class="nGY2Icon-pinterest-squared"></i>',
|
1586 | shareVK: '<i style="color:#3b5998;" class="nGY2Icon-vkontakte"></i>',
|
1587 | shareMail: '<i style="color:#555;" class="nGY2Icon-mail-alt"></i>',
|
1588 | viewerCustomTool1: 'T1',
|
1589 | viewerCustomTool2: 'T2',
|
1590 | viewerCustomTool3: 'T3',
|
1591 | viewerCustomTool4: 'T4',
|
1592 | viewerCustomTool5: 'T5',
|
1593 | viewerCustomTool6: 'T6',
|
1594 | viewerCustomTool7: 'T7',
|
1595 | viewerCustomTool8: 'T8',
|
1596 | viewerCustomTool9: 'T9',
|
1597 | viewerCustomTool10: 'T10'
|
1598 | }
|
1599 | };
|
1600 |
|
1601 | jQuery.fn.nanogallery2 = function (args, option, value) {
|
1602 |
|
1603 | if( typeof jQuery(this).data('nanogallery2data') === 'undefined'){
|
1604 | if( args == 'destroy' ) {
|
1605 |
|
1606 | return;
|
1607 | }
|
1608 |
|
1609 | return this.each( function(){
|
1610 | (new jQuery.nanogallery2(this, args));
|
1611 | });
|
1612 | }
|
1613 | else {
|
1614 |
|
1615 |
|
1616 | var nG2 = $(this).data('nanogallery2data').nG2;
|
1617 |
|
1618 |
|
1619 |
|
1620 | if( args !== undefined && args.lightboxStandalone === true ) {
|
1621 |
|
1622 | nG2.LightboxReOpen();
|
1623 | return;
|
1624 | }
|
1625 |
|
1626 | switch(args){
|
1627 | case 'displayItem':
|
1628 | nG2.DisplayItem(option);
|
1629 | break;
|
1630 |
|
1631 | case 'search':
|
1632 | return( nG2.Search(option));
|
1633 | break;
|
1634 |
|
1635 | case 'search2':
|
1636 | return nG2.Search2(option, value);
|
1637 | break;
|
1638 |
|
1639 | case 'search2Execute':
|
1640 | return nG2.Search2Execute();
|
1641 | break;
|
1642 |
|
1643 | case 'refresh':
|
1644 | nG2.Refresh();
|
1645 | break;
|
1646 |
|
1647 | case 'resize':
|
1648 | nG2.Resize();
|
1649 | break;
|
1650 |
|
1651 | case 'instance':
|
1652 | return nG2;
|
1653 | break;
|
1654 |
|
1655 | case 'data':
|
1656 | nG2.data= {
|
1657 | items: nG2.I,
|
1658 | gallery: nG2.GOM,
|
1659 | lightbox: nG2.VOM,
|
1660 | shoppingcart: nG2.shoppingCart
|
1661 | };
|
1662 | return nG2.data;
|
1663 | break;
|
1664 |
|
1665 | case 'reload':
|
1666 | nG2.ReloadAlbum();
|
1667 | return $(this);
|
1668 | break;
|
1669 |
|
1670 | case 'itemsSelectedGet':
|
1671 | return nG2.ItemsSelectedGet();
|
1672 | break;
|
1673 |
|
1674 | case 'itemsSetSelectedValue':
|
1675 | nG2.ItemsSetSelectedValue(option, value);
|
1676 | break;
|
1677 |
|
1678 | case 'option':
|
1679 | if(typeof value === 'undefined'){
|
1680 | return nG2.Get(option);
|
1681 | }else{
|
1682 | nG2.Set(option,value);
|
1683 | if( option == 'demoViewportWidth' ) {
|
1684 |
|
1685 | $(window).trigger('resize');
|
1686 | }
|
1687 | }
|
1688 | break;
|
1689 |
|
1690 | case 'destroy':
|
1691 | nG2.Destroy();
|
1692 | $(this).removeData('nanogallery2data');
|
1693 | break;
|
1694 |
|
1695 | case 'shoppingCartGet':
|
1696 |
|
1697 | return nG2.shoppingCart;
|
1698 | break;
|
1699 |
|
1700 | case 'shoppingCartUpdate':
|
1701 |
|
1702 |
|
1703 |
|
1704 |
|
1705 | if( typeof value === 'undefined' || typeof option === 'undefined' ){
|
1706 | return false;
|
1707 | }
|
1708 |
|
1709 | var item_ID = option;
|
1710 | var new_qty = value;
|
1711 |
|
1712 | for( var i=0; i < nG2.shoppingCart.length; i++) {
|
1713 | if( nG2.shoppingCart[i].ID == item_ID ) {
|
1714 |
|
1715 |
|
1716 | nG2.shoppingCart[i].qty = new_qty;
|
1717 |
|
1718 | let item = nG2.I[nG2.shoppingCart[i].idx];
|
1719 |
|
1720 |
|
1721 | nG2.ThumbnailToolbarOneCartUpdate( item );
|
1722 |
|
1723 | if( new_qty == 0 ) {
|
1724 |
|
1725 | nG2.shoppingCart.splice(i, 1);
|
1726 | }
|
1727 |
|
1728 | var fu = nG2.O.fnShoppingCartUpdated;
|
1729 | if( fu !== null ) {
|
1730 | typeof fu == 'function' ? fu(nG2.shoppingCart, item, 'api') : window[fu](nG2.shoppingCart, item, 'api');
|
1731 | }
|
1732 |
|
1733 | break;
|
1734 | }
|
1735 | }
|
1736 |
|
1737 | return nG2.shoppingCart;
|
1738 | break;
|
1739 |
|
1740 | case 'shoppingCartRemove':
|
1741 |
|
1742 |
|
1743 | if( typeof option === 'undefined' ){
|
1744 | return false;
|
1745 | }
|
1746 | var ID = option;
|
1747 | for( var i=0; i < nG2.shoppingCart.length; i++) {
|
1748 | if( nG2.shoppingCart[i].ID == ID ) {
|
1749 |
|
1750 | var item = nG2.I[nG2.shoppingCart[i].idx];
|
1751 |
|
1752 |
|
1753 | nG2.shoppingCart[i].qty = 0;
|
1754 | nG2.ThumbnailToolbarOneCartUpdate( item );
|
1755 |
|
1756 |
|
1757 | nG2.shoppingCart.splice(i, 1);
|
1758 |
|
1759 |
|
1760 | var fu = nG2.O.fnShoppingCartUpdated;
|
1761 | if( fu !== null ) {
|
1762 | typeof fu == 'function' ? fu(nG2.shoppingCart, item, 'api') : window[fu](nG2.shoppingCart, item, 'api');
|
1763 | }
|
1764 |
|
1765 | break;
|
1766 | }
|
1767 | }
|
1768 |
|
1769 | return nG2.shoppingCart;
|
1770 | break;
|
1771 |
|
1772 | case 'closeViewer':
|
1773 | nG2.CloseViewer();
|
1774 | break;
|
1775 | case 'minimizeToolbar':
|
1776 | nG2.MinimizeToolbar();
|
1777 | break;
|
1778 | case 'maximizeToolbar':
|
1779 | nG2.MaximizeToolbar();
|
1780 | break;
|
1781 | case 'paginationPreviousPage':
|
1782 | nG2.PaginationPreviousPage();
|
1783 | break;
|
1784 | case 'paginationNextPage':
|
1785 | nG2.paginationNextPage();
|
1786 | break;
|
1787 | case 'paginationGotoPage':
|
1788 | nG2.PaginationGotoPage( option );
|
1789 | break;
|
1790 | case 'paginationCountPages':
|
1791 | nG2.PaginationCountPages();
|
1792 | break;
|
1793 |
|
1794 | }
|
1795 | return $(this);
|
1796 |
|
1797 | }
|
1798 | };
|
1799 |
|
1800 |
|
1801 |
|
1802 |
|
1803 |
|
1804 |
|
1805 |
|
1806 | function nanoGALLERY2() {
|
1807 | "use strict";
|
1808 |
|
1809 | |
1810 |
|
1811 |
|
1812 | this.LightboxReOpen = function(){
|
1813 | LightboxStandaloneDisplay();
|
1814 | }
|
1815 |
|
1816 | |
1817 |
|
1818 |
|
1819 | this.ReloadAlbum = function(){
|
1820 | if( G.O.kind === '' ) {
|
1821 | throw 'Not supported for this content source:' + G.O.kind;
|
1822 | }
|
1823 |
|
1824 | var albumIdx = G.GOM.albumIdx;
|
1825 | if( albumIdx == -1 ) {
|
1826 | throw ('Current album not found.');
|
1827 | }
|
1828 |
|
1829 | var albumID = G.I[albumIdx].GetID();
|
1830 |
|
1831 |
|
1832 | var l = G.I.length;
|
1833 | for( var i = 0; i < l ; i++ ) {
|
1834 | var item = G.I[i];
|
1835 | if( item.albumID == albumID ) {
|
1836 | item.selected = false;
|
1837 | }
|
1838 | }
|
1839 |
|
1840 | G.I[albumIdx].contentIsLoaded = false;
|
1841 |
|
1842 | DisplayAlbum('-1', albumID);
|
1843 | };
|
1844 |
|
1845 | |
1846 |
|
1847 |
|
1848 |
|
1849 | this.ItemsSetSelectedValue = function(items, value){
|
1850 | var l = items.length;
|
1851 | for( var j = 0; j < l ; j++) {
|
1852 | ThumbnailSelectionSet(items[j], value);
|
1853 | }
|
1854 | };
|
1855 |
|
1856 | |
1857 |
|
1858 |
|
1859 |
|
1860 | this.ItemsSelectedGet = function(){
|
1861 | var selectedItems = [];
|
1862 | var l = G.I.length;
|
1863 | for( var i = 0; i < l ; i++ ) {
|
1864 | if( G.I[i].selected == true ) {
|
1865 | selectedItems.push(G.I[i]);
|
1866 | }
|
1867 | }
|
1868 | return selectedItems;
|
1869 | };
|
1870 |
|
1871 | |
1872 |
|
1873 |
|
1874 |
|
1875 |
|
1876 | this.Get = function(option){
|
1877 | return G.O[option];
|
1878 | };
|
1879 |
|
1880 | |
1881 |
|
1882 |
|
1883 |
|
1884 | this.Set = function(option, value){
|
1885 | G.O[option] = value;
|
1886 | switch( option ) {
|
1887 | case 'thumbnailSelectable':
|
1888 | ThumbnailSelectionClear();
|
1889 |
|
1890 | GalleryRender( G.GOM.albumIdx );
|
1891 | break;
|
1892 | }
|
1893 | };
|
1894 |
|
1895 | |
1896 |
|
1897 |
|
1898 | this.Refresh = function() {
|
1899 |
|
1900 | GalleryRender( G.GOM.albumIdx );
|
1901 | };
|
1902 | |
1903 |
|
1904 |
|
1905 | this.Resize = function() {
|
1906 |
|
1907 | GalleryResize();
|
1908 | };
|
1909 |
|
1910 | |
1911 |
|
1912 |
|
1913 |
|
1914 |
|
1915 |
|
1916 | this.DisplayItem = function( itemID ) {
|
1917 | var IDs=parseIDs( itemID );
|
1918 | if( IDs.imageID != '0' ) {
|
1919 | DisplayPhoto( IDs.imageID, IDs.albumID );
|
1920 | }
|
1921 | else {
|
1922 | DisplayAlbum( '-1', IDs.albumID );
|
1923 | }
|
1924 | };
|
1925 |
|
1926 | this.ThumbnailToolbarOneCartUpdate = function ( item ) {
|
1927 | ThumbnailBuildToolbarOneCartUpdate( item );
|
1928 | }
|
1929 |
|
1930 |
|
1931 |
|
1932 | var CountItemsToDisplay = function( gIdx ) {
|
1933 | if( G.I[gIdx] == undefined ) { return 0; }
|
1934 | var albumID = G.I[gIdx].GetID();
|
1935 | var l = G.I.length;
|
1936 | var cnt = 0;
|
1937 | for( var idx = 0; idx < l; idx++ ) {
|
1938 | var item = G.I[idx];
|
1939 | if( item.isToDisplay(albumID) ) {
|
1940 | cnt++;
|
1941 | }
|
1942 | }
|
1943 | return cnt;
|
1944 | }
|
1945 | |
1946 |
|
1947 |
|
1948 | this.Search = function( search ) {
|
1949 | G.GOM.albumSearch = search.toUpperCase();
|
1950 | var gIdx = G.GOM.albumIdx;
|
1951 | GalleryRender( G.GOM.albumIdx );
|
1952 | return CountItemsToDisplay( gIdx );
|
1953 | };
|
1954 |
|
1955 | |
1956 |
|
1957 |
|
1958 | this.Search2 = function( searchTitle, searchTags ) {
|
1959 | if( searchTitle != undefined && searchTitle != null ) {
|
1960 | G.GOM.albumSearch = searchTitle.toUpperCase().trim();
|
1961 | }
|
1962 | else {
|
1963 | G.GOM.albumSearch = '';
|
1964 | }
|
1965 |
|
1966 | if( searchTags != null && searchTags != undefined ) {
|
1967 | G.GOM.albumSearchTags = searchTags.toUpperCase().trim();
|
1968 | }
|
1969 | else {
|
1970 | G.GOM.albumSearchTags = '';
|
1971 | }
|
1972 | return CountItemsToDisplay( G.GOM.albumIdx );
|
1973 | };
|
1974 |
|
1975 | |
1976 |
|
1977 |
|
1978 | this.Search2Execute = function() {
|
1979 | var gIdx = G.GOM.albumIdx;
|
1980 | GalleryRender( G.GOM.albumIdx );
|
1981 | return CountItemsToDisplay( gIdx );
|
1982 | };
|
1983 |
|
1984 |
|
1985 | |
1986 |
|
1987 |
|
1988 | this.Destroy = function(){
|
1989 |
|
1990 | if( G.GOM.hammertime != null ) {
|
1991 | G.GOM.hammertime.destroy();
|
1992 | G.GOM.hammertime = null;
|
1993 | }
|
1994 |
|
1995 | if( G.VOM.hammertime != null ) {
|
1996 | G.VOM.hammertime.destroy();
|
1997 | G.VOM.hammertime = null;
|
1998 | }
|
1999 |
|
2000 |
|
2001 | $('#ngycs_' + G.baseEltID).remove()
|
2002 |
|
2003 | G.GOM.items = [];
|
2004 | NGY2Item.New( G, G.i18nTranslations.breadcrumbHome, '', '0', '-1', 'album' );
|
2005 | G.GOM.navigationBar.$newContent = null;
|
2006 | G.$E.base.empty();
|
2007 | G.$E.base.removeData();
|
2008 | if( G.O.locationHash ) {
|
2009 | jQuery(window).off('hashchange.nanogallery2.' + G.baseEltID);
|
2010 | }
|
2011 |
|
2012 | jQuery(window).off('resize.nanogallery2.' + G.baseEltID);
|
2013 | jQuery(window).off('orientationChange.nanogallery2.' + G.baseEltID);
|
2014 | jQuery(window).off('scroll.nanogallery2.' + G.baseEltID);
|
2015 | if( G.$E.scrollableParent !== null ) {
|
2016 | G.$E.scrollableParent.off('scroll.nanogallery2.' + G.baseEltID);
|
2017 | }
|
2018 | G.GOM.firstDisplay = true;
|
2019 | };
|
2020 |
|
2021 | |
2022 |
|
2023 |
|
2024 | this.CloseViewer = function() {
|
2025 | LightboxClose(null);
|
2026 | return false;
|
2027 | };
|
2028 |
|
2029 | |
2030 |
|
2031 |
|
2032 | this.MinimizeToolbar = function() {
|
2033 | ViewerToolbarForVisibilityMin();
|
2034 | return false;
|
2035 | };
|
2036 |
|
2037 | |
2038 |
|
2039 |
|
2040 | this.MaximizeToolbar = function() {
|
2041 | ViewerToolbarForVisibilityStd();
|
2042 | return false;
|
2043 | };
|
2044 |
|
2045 | |
2046 |
|
2047 |
|
2048 | this.PaginationPreviousPage = function() {
|
2049 | paginationPreviousPage();
|
2050 | return false;
|
2051 | };
|
2052 |
|
2053 |
|
2054 | |
2055 |
|
2056 |
|
2057 | this.PaginationNextPage = function() {
|
2058 | paginationNextPage();
|
2059 | return false;
|
2060 | };
|
2061 |
|
2062 |
|
2063 | |
2064 |
|
2065 |
|
2066 | this.PaginationGotoPage = function( page ) {
|
2067 |
|
2068 | if( page > 1 ) { page--; }
|
2069 | G.GOM.pagination.currentPage = page;
|
2070 |
|
2071 |
|
2072 | G.GOM.ScrollToTop();
|
2073 |
|
2074 | GalleryDisplayPart1();
|
2075 | GalleryDisplayPart2( true );
|
2076 | return false;
|
2077 | };
|
2078 |
|
2079 | |
2080 |
|
2081 |
|
2082 | this.PaginationCountPages = function() {
|
2083 | if( G.GOM.items.length == 0 ) { return 0; }
|
2084 |
|
2085 | var nbPages = Math.ceil((G.GOM.items[G.GOM.items.length - 1].row + 1) / G.galleryMaxRows.Get());
|
2086 | return nbPages;
|
2087 | };
|
2088 |
|
2089 | |
2090 |
|
2091 |
|
2092 |
|
2093 |
|
2094 |
|
2095 |
|
2096 |
|
2097 |
|
2098 |
|
2099 |
|
2100 |
|
2101 | var throttle = function(func, wait, options) {
|
2102 | var context, args, result;
|
2103 | var timeout = null;
|
2104 | var previous = 0;
|
2105 | if (!options) options = {};
|
2106 | var later = function() {
|
2107 | previous = options.leading === false ? 0 : new Date().getTime();
|
2108 | timeout = null;
|
2109 | result = func.apply(context, args);
|
2110 | if (!timeout) context = args = null;
|
2111 | };
|
2112 | return function() {
|
2113 | var now = new Date().getTime();
|
2114 | if (!previous && options.leading === false) previous = now;
|
2115 | var remaining = wait - (now - previous);
|
2116 | context = this;
|
2117 | args = arguments;
|
2118 | if (remaining <= 0 || remaining > wait) {
|
2119 | if (timeout) {
|
2120 | clearTimeout(timeout);
|
2121 | timeout = null;
|
2122 | }
|
2123 | previous = now;
|
2124 | result = func.apply(context, args);
|
2125 | if (!timeout) context = args = null;
|
2126 | } else if (!timeout && options.trailing !== false) {
|
2127 | timeout = setTimeout(later, remaining);
|
2128 | }
|
2129 | return result;
|
2130 | };
|
2131 | };
|
2132 |
|
2133 |
|
2134 |
|
2135 |
|
2136 |
|
2137 | var debounce = function (func, threshold, execAsap) {
|
2138 | var timeout;
|
2139 | return function debounced () {
|
2140 | var obj = this, args = arguments;
|
2141 | function delayed () {
|
2142 | if (!execAsap)
|
2143 | func.apply(obj, args);
|
2144 | timeout = null;
|
2145 | };
|
2146 |
|
2147 | if (timeout)
|
2148 | clearTimeout(timeout);
|
2149 |
|
2150 | else if (execAsap)
|
2151 | func.apply(obj, args);
|
2152 | timeout = setTimeout(delayed, threshold || 100);
|
2153 |
|
2154 | };
|
2155 | }
|
2156 |
|
2157 |
|
2158 |
|
2159 | window.ng_draf = function (cb) {
|
2160 | return requestAnimationFrame(function() {
|
2161 | window.requestAnimationFrame(cb)
|
2162 | })
|
2163 | }
|
2164 |
|
2165 |
|
2166 | |
2167 |
|
2168 |
|
2169 |
|
2170 |
|
2171 |
|
2172 | window.requestTimeout = function(fn, delay) {
|
2173 | if( !window.requestAnimationFrame &&
|
2174 | !window.webkitRequestAnimationFrame &&
|
2175 | !(window.mozRequestAnimationFrame && window.mozCancelRequestAnimationFrame) &&
|
2176 | !window.oRequestAnimationFrame &&
|
2177 | !window.msRequestAnimationFrame)
|
2178 | return window.setTimeout(fn, delay);
|
2179 |
|
2180 | var start = new Date().getTime(),
|
2181 | handle = new Object();
|
2182 |
|
2183 | function loop(){
|
2184 | var current = new Date().getTime(),
|
2185 | delta = current - start;
|
2186 |
|
2187 |
|
2188 | delta >= delay ? fn.call() : handle.value = requestAnimFrame(loop);
|
2189 | };
|
2190 |
|
2191 | handle.value = requestAnimFrame(loop);
|
2192 | return handle;
|
2193 | };
|
2194 |
|
2195 |
|
2196 |
|
2197 |
|
2198 | window.requestAnimFrame = (function() {
|
2199 | return window.requestAnimationFrame ||
|
2200 | window.webkitRequestAnimationFrame ||
|
2201 | window.mozRequestAnimationFrame ||
|
2202 | window.oRequestAnimationFrame ||
|
2203 | window.msRequestAnimationFrame ||
|
2204 | function(/* function */ callback, /* DOMElement */ element){
|
2205 | window.setTimeout(callback, 1000 / 60);
|
2206 | };
|
2207 | })();
|
2208 |
|
2209 |
|
2210 |
|
2211 | |
2212 |
|
2213 |
|
2214 |
|
2215 | window.clearRequestTimeout = function(handle) {
|
2216 | window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) :
|
2217 | window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) :
|
2218 | window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) :
|
2219 | window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) :
|
2220 | window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) :
|
2221 | window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) :
|
2222 | clearTimeout(handle);
|
2223 | };
|
2224 |
|
2225 |
|
2226 |
|
2227 | |
2228 |
|
2229 |
|
2230 | var G=this;
|
2231 | G.I = [];
|
2232 | G.Id = [];
|
2233 | G.O = null;
|
2234 | G.baseEltID = null;
|
2235 | G.$E = {
|
2236 | base: null,
|
2237 | conTnParent: null,
|
2238 | conLoadingB: null,
|
2239 | conConsole: null,
|
2240 | conNavigationBar: null,
|
2241 | conTnBottom: null,
|
2242 | scrollableParent: null
|
2243 | };
|
2244 | G.shoppingCart = [];
|
2245 | G.layout = {
|
2246 | internal : true,
|
2247 | engine : '',
|
2248 | support : { rows: false },
|
2249 | prerequisite : { imageSize: false },
|
2250 | SetEngine: function() {
|
2251 |
|
2252 | if( G.layout.internal ) {
|
2253 | if( G.tn.settings.width[G.GOM.curNavLevel][G.GOM.curWidth] == 'auto' || G.tn.settings.width[G.GOM.curNavLevel][G.GOM.curWidth] == '' ) {
|
2254 |
|
2255 | G.layout.engine = 'JUSTIFIED';
|
2256 | G.layout.support.rows = true;
|
2257 | G.layout.prerequisite.imageSize = true;
|
2258 | return;
|
2259 | }
|
2260 | if( G.tn.settings.height[G.GOM.curNavLevel][G.GOM.curWidth] == 'auto' || G.tn.settings.height[G.GOM.curNavLevel][G.GOM.curWidth] == '' ) {
|
2261 |
|
2262 | G.layout.engine = 'CASCADING';
|
2263 | G.layout.support.rows = false;
|
2264 | G.layout.prerequisite.imageSize = true;
|
2265 | return;
|
2266 | }
|
2267 |
|
2268 | if( G.tn.settings.getMosaic() != null ) {
|
2269 | G.layout.engine = 'MOSAIC';
|
2270 | G.layout.support.rows = true;
|
2271 | G.layout.prerequisite.imageSize = false;
|
2272 | return;
|
2273 | }
|
2274 |
|
2275 | G.layout.engine = 'GRID';
|
2276 | G.layout.support.rows=true;
|
2277 |
|
2278 |
|
2279 |
|
2280 |
|
2281 | G.layout.prerequisite.imageSize = false;
|
2282 |
|
2283 | }
|
2284 | }
|
2285 | };
|
2286 | G.galleryResizeEventEnabled = false;
|
2287 | G.galleryMaxRows = { l1: 0, lN: 0,
|
2288 | Get: function() {
|
2289 | return G.galleryMaxRows[G.GOM.curNavLevel];
|
2290 | }
|
2291 | };
|
2292 | G.galleryMaxItems = { l1: 0, lN: 0,
|
2293 | Get: function() {
|
2294 | return G.galleryMaxItems[G.GOM.curNavLevel];
|
2295 | }
|
2296 | };
|
2297 | G.galleryFilterTags = { l1: 0, lN: 0,
|
2298 | Get: function() {
|
2299 | return G.galleryFilterTags[G.GOM.curNavLevel];
|
2300 | }
|
2301 | };
|
2302 | G.galleryFilterTagsMode = { l1: 0, lN: 0,
|
2303 | Get: function() {
|
2304 | return G.galleryFilterTagsMode[G.GOM.curNavLevel];
|
2305 | }
|
2306 | };
|
2307 | G.galleryDisplayMode = { l1: 'FULLCONTENT', lN: 'FULLCONTENT',
|
2308 | Get: function() {
|
2309 | return G.galleryDisplayMode[G.GOM.curNavLevel];
|
2310 | }
|
2311 | };
|
2312 | G.galleryLastRowFull = { l1: false, lN: false,
|
2313 | Get: function() {
|
2314 | return G.galleryLastRowFull[G.GOM.curNavLevel];
|
2315 | }
|
2316 | };
|
2317 | G.gallerySorting = { l1: '', lN: '',
|
2318 | Get: function() {
|
2319 | return G.gallerySorting[G.GOM.curNavLevel];
|
2320 | }
|
2321 | };
|
2322 | G.galleryDisplayTransition = { l1: 'none', lN: 'none',
|
2323 | Get: function() {
|
2324 | return G.galleryDisplayTransition[G.GOM.curNavLevel];
|
2325 | }
|
2326 | };
|
2327 | G.galleryDisplayTransitionDuration = { l1: 500, lN: 500,
|
2328 | Get: function() {
|
2329 | return G.galleryDisplayTransitionDuration[G.GOM.curNavLevel];
|
2330 | }
|
2331 | };
|
2332 | G.$currentTouchedThumbnail = null;
|
2333 |
|
2334 |
|
2335 |
|
2336 |
|
2337 |
|
2338 | G.tn = {
|
2339 |
|
2340 | opt: {
|
2341 | 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 },
|
2342 | 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 },
|
2343 | Get: function(opt) {
|
2344 | return G.tn.opt[G.GOM.curNavLevel][opt];
|
2345 | }
|
2346 | },
|
2347 | scale: 1,
|
2348 | labelHeight: {
|
2349 | l1: 0, lN: 0,
|
2350 | get: function() {
|
2351 | return G.tn.labelHeight[G.GOM.curNavLevel];
|
2352 | }
|
2353 | },
|
2354 | defaultSize: {
|
2355 |
|
2356 | width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
2357 | height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
2358 | getWidth: function() {
|
2359 | return G.tn.defaultSize.width[G.GOM.curNavLevel][G.GOM.curWidth];
|
2360 | },
|
2361 | getOuterWidth: function() {
|
2362 | G.tn.borderWidth = G.tn.opt.Get('borderHorizontal');
|
2363 | G.tn.borderHeight = G.tn.opt.Get('borderVertical');
|
2364 | var w = G.tn.defaultSize.width[G.GOM.curNavLevel][G.GOM.curWidth] + G.tn.opt.Get('borderHorizontal') * 2;
|
2365 | if( G.O.thumbnailLabel.get('position') == 'right' || G.O.thumbnailLabel.get('position') == 'left' ) {
|
2366 | w += G.tn.defaultSize.width[G.GOM.curNavLevel][G.GOM.curWidth];
|
2367 | }
|
2368 | return w;
|
2369 | },
|
2370 | getHeight: function() {
|
2371 | return G.tn.defaultSize.height[G.GOM.curNavLevel][G.GOM.curWidth];
|
2372 | },
|
2373 | getOuterHeight: function() {
|
2374 | return G.tn.defaultSize.height[G.GOM.curNavLevel][G.GOM.curWidth]+G.tn.opt.Get('borderVertical')*2;
|
2375 | }
|
2376 | },
|
2377 | settings: {
|
2378 | width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0, xsc:'u', smc:'u', mec:'u', lac:'u', xlc:'u' },
|
2379 | lN : { xs:0, sm:0, me:0, la:0, xl:0, xsc:'u', smc:'u', mec:'u', lac:'u', xlc:'u' } },
|
2380 | height: { 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 | getH: function(l, w) {
|
2383 | var cl = (l == undefined ? G.GOM.curNavLevel : l);
|
2384 | var cw = (w == undefined ? G.GOM.curWidth : w);
|
2385 | if( G.layout.engine == 'MOSAIC' ) {
|
2386 | return this.height[cl][cw] * this.mosaic[cl+'Factor']['h'][cw];
|
2387 | }
|
2388 | else {
|
2389 | return this.height[cl][cw];
|
2390 | }
|
2391 | },
|
2392 | getW: function(l, w) {
|
2393 | var cl = (l == undefined ? G.GOM.curNavLevel : l);
|
2394 | var cw = (w == undefined ? G.GOM.curWidth : w);
|
2395 | if( G.layout.engine == 'MOSAIC' ) {
|
2396 | return this.width[cl][cw] * this.mosaic[cl+'Factor']['w'][cw];
|
2397 | }
|
2398 | else {
|
2399 | return this.width[cl][cw];
|
2400 |
|
2401 | }
|
2402 | },
|
2403 | mosaic: { l1 : { xs: null, sm: null, me: null, la: null, xl: null },
|
2404 | lN : { xs: null, sm: null, me: null, la: null, xl: null },
|
2405 | l1Factor : { h :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }, w :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }},
|
2406 | lNFactor : { h :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }, w :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }}
|
2407 | },
|
2408 | getMosaic: function() {
|
2409 | return this.mosaic[G.GOM.curNavLevel][G.GOM.curWidth];
|
2410 | },
|
2411 | mosaicCalcFactor: function(l, w) {
|
2412 |
|
2413 | var maxW = 1;
|
2414 | var maxH = 1;
|
2415 | for( var n = 0; n < G.tn.settings.mosaic[l][w].length; n++ ) {
|
2416 | maxW = Math.max(maxW, this.mosaic[l][w][n]['w']);
|
2417 | maxH = Math.max(maxH, this.mosaic[l][w][n]['h']);
|
2418 | }
|
2419 | this.mosaic[l + 'Factor']['h'][w] = maxH;
|
2420 | this.mosaic[l + 'Factor']['w'][w] = maxW;
|
2421 | },
|
2422 | gutterHeight: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
2423 | gutterWidth: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
2424 | GetResponsive: function( setting ) {
|
2425 | return this[setting][G.GOM.curNavLevel][G.GOM.curWidth];
|
2426 | }
|
2427 | },
|
2428 |
|
2429 | hoverEffects : {
|
2430 | std : [],
|
2431 | level1: [],
|
2432 | get: function() {
|
2433 | if( G.GOM.curNavLevel == 'l1' && this.level1.length !== 0 ) {
|
2434 | return this.level1;
|
2435 | }
|
2436 | else {
|
2437 | return this.std;
|
2438 | }
|
2439 | }
|
2440 | },
|
2441 |
|
2442 | buildInit : {
|
2443 | std : [],
|
2444 | level1: [],
|
2445 | get: function() {
|
2446 | if( G.GOM.curNavLevel == 'l1' && this.level1.length !== 0 ) {
|
2447 | return this.level1;
|
2448 | }
|
2449 | else {
|
2450 | return this.std;
|
2451 | }
|
2452 | }
|
2453 | },
|
2454 |
|
2455 | toolbar: {
|
2456 | album : { topLeft : '', topRight: '', bottomLeft: '', bottomRight: '' },
|
2457 | image : { topLeft : '', topRight: '', bottomLeft: '', bottomRight: '' },
|
2458 | albumUp : { topLeft : '', topRight: '', bottomLeft: '', bottomRight: '' },
|
2459 | get: function( item ) {
|
2460 | return this[item.kind];
|
2461 | },
|
2462 | },
|
2463 | style: {
|
2464 |
|
2465 | l1 : { label: '', title: '', desc: '' },
|
2466 | lN : { label: '', title: '', desc: '' },
|
2467 | getTitle : function() {
|
2468 | return ('style="' + this[G.GOM.curNavLevel].title + '"');
|
2469 | },
|
2470 | getDesc : function() {
|
2471 | return ('style="' + this[G.GOM.curNavLevel].desc + '"');
|
2472 | },
|
2473 | getLabel: function() {
|
2474 | var s='style="'+ this[G.GOM.curNavLevel].label;
|
2475 | s+= (G.O.RTL ? '"direction:RTL;"' :'');
|
2476 | s+='"';
|
2477 | return s;
|
2478 | }
|
2479 | }
|
2480 | };
|
2481 | G.scrollTimeOut = 0;
|
2482 | G.i18nTranslations = {'paginationPrevious':'Previous', 'paginationNext':'Next', 'breadcrumbHome':'List of Albums', 'thumbnailImageTitle':'', 'thumbnailAlbumTitle':'', 'thumbnailImageDescription':'', 'thumbnailAlbumDescription':'' };
|
2483 | G.emptyGif = 'data:image/gif;base64,R0lGODlhEAAQAIAAAP///////yH5BAEKAAEALAAAAAAQABAAAAIOjI+py+0Po5y02ouzPgUAOw==';
|
2484 | G.CSStransformName = FirstSupportedPropertyName(["transform", "msTransform", "MozTransform", "WebkitTransform", "OTransform"]);
|
2485 |
|
2486 | G.CSStransformStyle = FirstSupportedPropertyName(["transformStyle", "msTransformStyle", "MozTransformStyle", "WebkitTransformStyle", "OTransformStyle"]);
|
2487 | G.CSSperspective = FirstSupportedPropertyName(["perspective", "msPerspective", "MozPerspective", "WebkitPerspective", "OPerspective"]);
|
2488 | G.CSSbackfaceVisibilityName = FirstSupportedPropertyName(["backfaceVisibility", "msBackfaceVisibility", "MozBackfaceVisibility", "WebkitBackfaceVisibility", "OBackfaceVisibility"]);
|
2489 | G.CSStransitionName = FirstSupportedPropertyName(["transition", "msTransition", "MozTransition", "WebkitTransition", "OTransition"]);
|
2490 | G.CSSanimationName = FirstSupportedPropertyName(["animation", "msAnimation", "MozAnimation", "WebkitAnimation", "OAnimation"]);
|
2491 | G.GalleryResizeThrottled = throttle(GalleryResize, 15, {leading: false});
|
2492 |
|
2493 | G.blockList = null;
|
2494 | G.allowList = null;
|
2495 | G.albumList = [];
|
2496 | G.locationHashLastUsed = '';
|
2497 | G.custGlobals = {};
|
2498 | G.touchAutoOpenDelayTimerID = 0;
|
2499 | G.i18nLang = '';
|
2500 | G.timeLastTouchStart = 0;
|
2501 | G.custGlobals = {};
|
2502 | G.markupOrApiProcessed = false;
|
2503 |
|
2504 |
|
2505 |
|
2506 | G.GOM = {
|
2507 | albumIdx : -1,
|
2508 | clipArea : { top: 0, height: 0 },
|
2509 | displayArea : { width: 0 , height: 0 },
|
2510 | displayAreaLast : { width: 0 , height: 0 },
|
2511 | displayedMoreSteps : 0,
|
2512 | items: [],
|
2513 | $imgPreloader: [],
|
2514 | thumbnails2Display: [],
|
2515 | itemsDisplayed : 0,
|
2516 | firstDisplay : true,
|
2517 | firstDisplayTime : 0,
|
2518 | navigationBar : {
|
2519 | displayed: false,
|
2520 | $newContent: ''
|
2521 | },
|
2522 | cache : {
|
2523 | viewport: null,
|
2524 | containerOffset: null,
|
2525 | areaWidth: 100
|
2526 | },
|
2527 | nbSelected : 0,
|
2528 | pagination : { currentPage: 0 },
|
2529 | panThreshold: 60,
|
2530 | panYOnly: false,
|
2531 | lastFullRow : -1,
|
2532 | lastDisplayedIdx: -1,
|
2533 | displayInterval : { from: 0, len: 0 },
|
2534 | hammertime: null,
|
2535 | curNavLevel: 'l1',
|
2536 | curWidth: 'me',
|
2537 | albumSearch: '',
|
2538 | albumSearchTags: '',
|
2539 | lastZIndex: 0,
|
2540 | lastRandomValue: 0,
|
2541 | slider : {
|
2542 | hostIdx: -1,
|
2543 | hostItem: null,
|
2544 | currentIdx: 0,
|
2545 | nextIdx: 0,
|
2546 | timerID: 0,
|
2547 | tween: null
|
2548 | },
|
2549 | NGY2Item: function( idx ) {
|
2550 | if( G.GOM.items[idx] == undefined || G.GOM.items[idx] == null ) { return null; }
|
2551 | var i = G.GOM.items[idx].thumbnailIdx;
|
2552 | return G.I[i];
|
2553 | },
|
2554 |
|
2555 |
|
2556 | GTn: function(index, width, height) {
|
2557 | this.thumbnailIdx = index;
|
2558 | this.width = 0;
|
2559 | this.height = 0;
|
2560 | this.top = 0;
|
2561 | this.left = 0;
|
2562 | this.row = 0;
|
2563 | this.imageWidth = width;
|
2564 | this.imageHeight = height;
|
2565 | this.resizedContentWidth = 0;
|
2566 | this.resizedContentHeight = 0;
|
2567 | this.displayed = false;
|
2568 | this.neverDisplayed = true;
|
2569 | this.inDisplayArea = false;
|
2570 | },
|
2571 |
|
2572 | ScrollToTop: function() {
|
2573 |
|
2574 | if( G.GOM.firstDisplay ) {
|
2575 |
|
2576 | return;
|
2577 | }
|
2578 |
|
2579 | if( G.$E.scrollableParent === null && !topInViewportVert(G.$E.base, 20) ) {
|
2580 |
|
2581 | G.$E.base.get(0).scrollIntoView();
|
2582 | }
|
2583 |
|
2584 | if( G.$E.scrollableParent !== null ) {
|
2585 |
|
2586 |
|
2587 | var scrollTop = G.$E.scrollableParent.scrollTop();
|
2588 |
|
2589 | var dist = Math.abs(G.$E.scrollableParent.offset().top - G.$E.base.offset().top - scrollTop);
|
2590 | if( scrollTop > dist ) {
|
2591 | window.ng_draf( function() {
|
2592 |
|
2593 | G.$E.scrollableParent.scrollTop(dist);
|
2594 | });
|
2595 | }
|
2596 | }
|
2597 | }
|
2598 | };
|
2599 |
|
2600 |
|
2601 |
|
2602 |
|
2603 |
|
2604 | G.VOM = {
|
2605 | viewerDisplayed: false,
|
2606 | viewerIsFullscreen: false,
|
2607 | infoDisplayed: false,
|
2608 | toolbarsDisplayed: true,
|
2609 | toolsHide: null,
|
2610 | zoom : {
|
2611 | posX: 0,
|
2612 | posY: 0,
|
2613 | userFactor: 1,
|
2614 | isZooming: false
|
2615 | },
|
2616 | padding: { H: 0, V: 0 },
|
2617 | window: { lastWidth: 0, lastHeight: 0 },
|
2618 | $viewer: null,
|
2619 | $toolbar: null,
|
2620 | $toolbarTL: null,
|
2621 | $toolbarTR: null,
|
2622 |
|
2623 | toolbarMode: 'std',
|
2624 | playSlideshow : false,
|
2625 | playSlideshowTimerID: 0,
|
2626 | slideshowDelay: 3000,
|
2627 | albumID: -1,
|
2628 | viewerMediaIsChanged: false,
|
2629 | items: [],
|
2630 |
|
2631 | panMode: 'off',
|
2632 |
|
2633 | $baseCont: null,
|
2634 | $content: null,
|
2635 | content: {
|
2636 | previous : {
|
2637 | vIdx: -1,
|
2638 | $media: null,
|
2639 | NGY2Item: function() {
|
2640 | return G.I[ G.VOM.items[G.VOM.content.previous.vIdx].ngy2ItemIdx ];
|
2641 | }
|
2642 | },
|
2643 | current : {
|
2644 | vIdx: -1,
|
2645 | $media: null,
|
2646 | NGY2Item: function() {
|
2647 | return G.I[ G.VOM.items[G.VOM.content.current.vIdx].ngy2ItemIdx ];
|
2648 | }
|
2649 | },
|
2650 | next : {
|
2651 | vIdx: -1,
|
2652 | $media: null,
|
2653 | NGY2Item: function() {
|
2654 | return G.I[ G.VOM.items[G.VOM.content.next.vIdx].ngy2ItemIdx ];
|
2655 | }
|
2656 | }
|
2657 | },
|
2658 | IdxNext: function() {
|
2659 | var n = 0;
|
2660 |
|
2661 | if( G.VOM.content.current.vIdx < (G.VOM.items.length-1) ) {
|
2662 | n = G.VOM.content.current.vIdx + 1;
|
2663 | }
|
2664 | return n;
|
2665 | },
|
2666 | IdxPrevious: function() {
|
2667 | var n = G.VOM.content.current.vIdx - 1;
|
2668 | if( G.VOM.content.current.vIdx == 0 ) {
|
2669 | n = G.VOM.items.length - 1;
|
2670 | }
|
2671 | return n;
|
2672 | },
|
2673 |
|
2674 | gallery: {
|
2675 | $elt: null,
|
2676 | $tmbCont: null,
|
2677 | gwidth: 0,
|
2678 | vwidth: 0,
|
2679 | oneTmbWidth: 0,
|
2680 | firstDisplay: true,
|
2681 | posX: 0,
|
2682 | SetThumbnailActive() {
|
2683 | if( G.O.viewerGallery == 'none' ) { return; }
|
2684 | this.$tmbCont.children().removeClass('activeVThumbnail');
|
2685 | this.$tmbCont.children().eq( G.VOM.content.current.vIdx ).addClass('activeVThumbnail');
|
2686 | this.firstDisplay = false;
|
2687 | },
|
2688 | Resize: function() {
|
2689 | if( G.O.viewerGallery == 'none' ) { return; }
|
2690 |
|
2691 | if( !this.firstDisplay ) {
|
2692 | var viewerW = G.VOM.$viewer.width();
|
2693 |
|
2694 |
|
2695 | var maxTmb = Math.trunc(viewerW / this.oneTmbWidth);
|
2696 | this.vwidth = maxTmb * this.oneTmbWidth;
|
2697 | this.$elt.css({ width: this.vwidth, left: (viewerW - this.vwidth)/2 });
|
2698 |
|
2699 |
|
2700 | if( G.VOM.items.length >= maxTmb ) {
|
2701 | var tmbPos = this.oneTmbWidth * G.VOM.content.current.vIdx;
|
2702 |
|
2703 | if( (tmbPos + this.posX) < this.vwidth ) {
|
2704 | if( tmbPos + this.posX < 0 ) {
|
2705 | this.posX = -tmbPos;
|
2706 | }
|
2707 | }
|
2708 | else {
|
2709 | if( tmbPos + this.posX >= this.vwidth ) {
|
2710 | this.posX = this.vwidth - (tmbPos + this.oneTmbWidth)
|
2711 | }
|
2712 | }
|
2713 | }
|
2714 |
|
2715 | this.PanGallery(0);
|
2716 | }
|
2717 | else {
|
2718 |
|
2719 | new NGTweenable().tween({
|
2720 | from: { opacity: 0 },
|
2721 | to: { opacity: 1 },
|
2722 | easing: 'easeInOutSine',
|
2723 | duration: 1000,
|
2724 | step: function (state) {
|
2725 |
|
2726 | },
|
2727 | finish: function (state) {
|
2728 |
|
2729 | }
|
2730 | });
|
2731 |
|
2732 | }
|
2733 | },
|
2734 | PanGallery: function( panX ){
|
2735 |
|
2736 |
|
2737 | if( this.gwidth < G.VOM.$viewer.width() ) {
|
2738 | this.posX = (G.VOM.$viewer.width() - this.gwidth) / 2;
|
2739 | panX = 0;
|
2740 | }
|
2741 |
|
2742 |
|
2743 | if( this.posX > (this.vwidth - this.oneTmbWidth) ) {
|
2744 |
|
2745 | this.posX = this.vwidth - this.oneTmbWidth;
|
2746 | }
|
2747 | if( (this.posX+this.gwidth) < this.oneTmbWidth ) {
|
2748 |
|
2749 | this.posX = -this.gwidth + this.oneTmbWidth;
|
2750 | }
|
2751 |
|
2752 | this.$tmbCont.css( G.CSStransformName , 'translateX(' + (this.posX + panX) + 'px)');
|
2753 | },
|
2754 | PanGalleryEnd: function( velocity ) {
|
2755 |
|
2756 | var d = velocity * 100;
|
2757 | new NGTweenable().tween({
|
2758 | from: { pan: G.VOM.gallery.posX },
|
2759 | to: { pan: G.VOM.gallery.posX + d },
|
2760 | easing: 'easeOutQuad',
|
2761 | duration: 500,
|
2762 | step: function (state) {
|
2763 | G.VOM.gallery.posX = state.pan;
|
2764 | G.VOM.gallery.PanGallery( 0 );
|
2765 | }
|
2766 | });
|
2767 | }
|
2768 |
|
2769 | },
|
2770 | hammertime: null,
|
2771 | swipePosX: 0,
|
2772 | panPosX: 0,
|
2773 | panPosY: 0,
|
2774 | panThreshold: 60,
|
2775 | panXOnly: false,
|
2776 | singletapTime: 0,
|
2777 | viewerTheme: '',
|
2778 | timeImgChanged: 0,
|
2779 | ImageLoader: {
|
2780 |
|
2781 |
|
2782 | maxChecks: 1000,
|
2783 | list: [],
|
2784 | intervalHandle : null,
|
2785 |
|
2786 | loadImage : function (callback, ngitem) {
|
2787 | if( ngitem.mediaKind != 'img' ) { return; }
|
2788 | var img = new Image ();
|
2789 | img.src = ngitem.responsiveURL();
|
2790 | if (img.width && img.height) {
|
2791 | callback (img.width, img.height, ngitem, 0);
|
2792 | }
|
2793 | else {
|
2794 | var obj = {image: img, url: ngitem.responsiveURL(), ngitem: ngitem, callback: callback, checks: 1};
|
2795 | var i;
|
2796 | for (i=0; i < this.list.length; i++) {
|
2797 | if (this.list[i] == null)
|
2798 | break;
|
2799 | }
|
2800 | this.list[i] = obj;
|
2801 | if (!this.intervalHandle)
|
2802 | this.intervalHandle = setInterval(this.interval, 50);
|
2803 | }
|
2804 | },
|
2805 |
|
2806 |
|
2807 | interval : function () {
|
2808 | var count = 0;
|
2809 | var list = G.VOM.ImageLoader.list, item;
|
2810 | for (var i=0; i<list.length; i++) {
|
2811 | item = list[i];
|
2812 | if (item != null) {
|
2813 | if (item.image.width && item.image.height) {
|
2814 | G.VOM.ImageLoader.list[i] = null;
|
2815 | item.callback (item.image.width, item.image.height, item.ngitem, item.checks);
|
2816 | }
|
2817 | else if (item.checks > G.VOM.ImageLoader.maxChecks) {
|
2818 | G.VOM.ImageLoader.list[i] = null;
|
2819 | item.callback (0, 0, item.ngitem, item.checks);
|
2820 | }
|
2821 | else {
|
2822 | count++;
|
2823 | item.checks++;
|
2824 | }
|
2825 | }
|
2826 | }
|
2827 | if (count == 0) {
|
2828 | G.VOM.ImageLoader.list = [];
|
2829 | clearInterval (G.VOM.ImageLoader.intervalHandle);
|
2830 | delete G.VOM.ImageLoader.intervalHandle;
|
2831 | }
|
2832 | }
|
2833 | }
|
2834 | }
|
2835 |
|
2836 | function VImg( index ) {
|
2837 | this.$e = null;
|
2838 | this.ngy2ItemIdx = index;
|
2839 | this.mediaNumber = G.VOM.items.length + 1;
|
2840 | this.posX = 0;
|
2841 | this.posY = 0;
|
2842 | }
|
2843 |
|
2844 |
|
2845 |
|
2846 |
|
2847 | G.popup = {
|
2848 | isDisplayed: false,
|
2849 | $elt: null,
|
2850 | close: function() {
|
2851 | if( this.$elt != null ) {
|
2852 | var tweenable = new NGTweenable();
|
2853 | tweenable.tween({
|
2854 | from: { opacity:1 },
|
2855 | to: { opacity:0 },
|
2856 | attachment: { t: this },
|
2857 | easing: 'easeInOutSine',
|
2858 | duration: 100,
|
2859 | step: function (state, att) {
|
2860 | if( att.t.$elt != null ) {
|
2861 | att.t.$elt.css('opacity',state.opacity);
|
2862 | }
|
2863 | },
|
2864 | finish: function (state, att) {
|
2865 | if( att.t.$elt != null ) {
|
2866 | att.t.$elt.remove();
|
2867 | att.t.$elt=null;
|
2868 | }
|
2869 | att.t.isDisplayed=false;
|
2870 | }
|
2871 | });
|
2872 | }
|
2873 | }
|
2874 | }
|
2875 |
|
2876 |
|
2877 |
|
2878 |
|
2879 | G.galleryTheme_dark = {
|
2880 | navigationBar : { background: 'none', borderTop: '', borderBottom: '', borderRight: '', borderLeft: '' },
|
2881 | navigationBreadcrumb : { background: '#111', color: '#fff', colorHover: '#ccc', borderRadius: '4px' },
|
2882 | navigationFilter : { color: '#ddd', background: '#111', colorSelected: '#fff', backgroundSelected: '#111', borderRadius: '4px' },
|
2883 | navigationPagination : { background: '#111', color: '#fff', colorHover: '#ccc', borderRadius: '4px' },
|
2884 | 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' },
|
2885 | thumbnailIcon : { padding: '5px', color: '#fff', shadow:'' },
|
2886 | pagination : { background: '#181818', backgroundSelected: '#666', color: '#fff', borderRadius: '2px', shapeBorder: '3px solid #666', shapeColor: '#444', shapeSelectedColor: '#aaa'}
|
2887 | };
|
2888 |
|
2889 | G.galleryTheme_light = {
|
2890 | navigationBar : { background: 'none', borderTop: '', borderBottom: '', borderRight: '', borderLeft: '' },
|
2891 | navigationBreadcrumb : { background: '#eee', color: '#000', colorHover: '#333', borderRadius: '4px' },
|
2892 | navigationFilter : { background: '#eee', color: '#222', colorSelected: '#000', backgroundSelected: '#eee', borderRadius: '4px' },
|
2893 | navigationPagination : { background: '#eee', color: '#000', colorHover: '#333', borderRadius: '4px' },
|
2894 | 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' },
|
2895 | thumbnailIcon : { padding: '5px', color: '#fff' },
|
2896 | pagination : { background: '#eee', backgroundSelected: '#aaa', color: '#000', borderRadius: '2px', shapeBorder: '3px solid #666', shapeColor: '#444', shapeSelectedColor: '#aaa'}
|
2897 | };
|
2898 |
|
2899 |
|
2900 | G.viewerTheme_dark = {
|
2901 | background: '#000',
|
2902 | barBackground: 'rgba(4, 4, 4, 0.2)',
|
2903 | barBorder: '0px solid #111',
|
2904 | barColor: '#fff',
|
2905 | barDescriptionColor: '#ccc'
|
2906 | };
|
2907 | G.viewerTheme_light = {
|
2908 | background: '#f8f8f8',
|
2909 | barBackground: 'rgba(4, 4, 4, 0.7)',
|
2910 | barBorder: '0px solid #111',
|
2911 | barColor: '#fff',
|
2912 | barDescriptionColor: '#ccc'
|
2913 | };
|
2914 |
|
2915 |
|
2916 |
|
2917 |
|
2918 |
|
2919 |
|
2920 | var NanoAlert = NGY2Tools.NanoAlert;
|
2921 | var NanoConsoleLog = NGY2Tools.NanoConsoleLog;
|
2922 |
|
2923 |
|
2924 |
|
2925 | this.initiateGallery2 = function( element, params ) {
|
2926 |
|
2927 |
|
2928 | G.O = params;
|
2929 |
|
2930 | G.$E.base = jQuery(element);
|
2931 | G.baseEltID = G.$E.base.attr('id');
|
2932 | if( G.baseEltID == undefined ) {
|
2933 |
|
2934 | var base_id = 'my_nanogallery';
|
2935 | var c = '';
|
2936 | var f = true;
|
2937 | while( f ) {
|
2938 | if (document.getElementById(base_id + c)) {
|
2939 |
|
2940 | if( c == '' ) {
|
2941 | c = 1;
|
2942 | }
|
2943 | else {
|
2944 | c++;
|
2945 | }
|
2946 | }
|
2947 | else {
|
2948 | f = false;
|
2949 | G.baseEltID = 'my_nanogallery' + c;
|
2950 | }
|
2951 | }
|
2952 | G.$E.base.attr('id', G.baseEltID)
|
2953 | }
|
2954 | G.O.$markup = [];
|
2955 |
|
2956 | DefineVariables();
|
2957 | SetPolyFills();
|
2958 | BuildSkeleton();
|
2959 | G.GOM.firstDisplayTime = Date.now();
|
2960 |
|
2961 | SetGlobalEvents();
|
2962 |
|
2963 |
|
2964 | if( !G.O.lightboxStandalone ) {
|
2965 | var albumToDisplay = G.O.album;
|
2966 | if( albumToDisplay == '' && G.O.photoset != '' ) {
|
2967 | albumToDisplay = G.O.photoset;
|
2968 | G.O.album = G.O.photoset;
|
2969 | }
|
2970 | if( albumToDisplay != '' ) {
|
2971 | G.O.displayBreadcrumb = false;
|
2972 | if( albumToDisplay.toUpperCase() != 'NONE' ) {
|
2973 |
|
2974 | if( G.O.kind == "nano_photos_provider2") {
|
2975 | if( albumToDisplay == decodeURIComponent(albumToDisplay)) {
|
2976 |
|
2977 | albumToDisplay = encodeURIComponent(albumToDisplay);
|
2978 | G.O.album = albumToDisplay;
|
2979 | }
|
2980 | }
|
2981 | NGY2Item.New( G, '', '', albumToDisplay, '-1', 'album' );
|
2982 | if( !ProcessLocationHash() ) {
|
2983 | DisplayAlbum('-1', albumToDisplay);
|
2984 | }
|
2985 | return;
|
2986 | }
|
2987 | }
|
2988 | }
|
2989 |
|
2990 |
|
2991 |
|
2992 | NGY2Item.New( G, G.i18nTranslations.breadcrumbHome, '', '0', '-1', 'album' );
|
2993 |
|
2994 | processStartOptions();
|
2995 |
|
2996 | }
|
2997 |
|
2998 |
|
2999 |
|
3000 | function processStartOptions() {
|
3001 |
|
3002 |
|
3003 |
|
3004 |
|
3005 |
|
3006 |
|
3007 |
|
3008 |
|
3009 |
|
3010 |
|
3011 |
|
3012 |
|
3013 | if( !ProcessLocationHash() ) {
|
3014 | processStartOptionsPart2();
|
3015 | }
|
3016 | }
|
3017 |
|
3018 |
|
3019 | function processStartOptionsPart2() {
|
3020 |
|
3021 |
|
3022 | if( G.O.lightboxStandalone ) {
|
3023 | LightboxStandaloneFindContent();
|
3024 | }
|
3025 | else {
|
3026 |
|
3027 | if( G.O.openOnStart != '' ) {
|
3028 | var IDs = parseIDs(G.O.openOnStart);
|
3029 | if( IDs.imageID != '0' ) {
|
3030 | DisplayPhoto(IDs.imageID, IDs.albumID);
|
3031 | }
|
3032 | else {
|
3033 | DisplayAlbum('-1', IDs.albumID);
|
3034 | }
|
3035 | }
|
3036 | else {
|
3037 |
|
3038 | DisplayAlbum('-1', 0);
|
3039 | }
|
3040 | }
|
3041 | }
|
3042 |
|
3043 |
|
3044 |
|
3045 |
|
3046 |
|
3047 | function LightboxStandaloneFindContent() {
|
3048 |
|
3049 | G.GOM.curNavLevel = 'l1';
|
3050 |
|
3051 | if( G.O.items == null ) {
|
3052 |
|
3053 | var elts = jQuery('[data-nanogallery2-Lightbox');
|
3054 |
|
3055 | var g = G.$E.base[0].dataset.nanogallery2Lgroup;
|
3056 |
|
3057 | GetContentMarkup( elts, g );
|
3058 | }
|
3059 | else {
|
3060 |
|
3061 | GetContentApiObject();
|
3062 | }
|
3063 |
|
3064 | LightboxStandaloneDisplay();
|
3065 |
|
3066 | }
|
3067 |
|
3068 |
|
3069 |
|
3070 | function LightboxStandaloneDisplay() {
|
3071 |
|
3072 | G.VOM.items = [];
|
3073 | G.VOM.albumID = '0';
|
3074 | G.GOM.curNavLevel = 'l1';
|
3075 | var vcnt = 0;
|
3076 |
|
3077 | var srct = G.$E.base[0].src;
|
3078 | var displayIdx = undefined;
|
3079 | for( var idx = 0; idx < G.I.length; idx++ ) {
|
3080 | if( G.I[idx].kind == 'image' ) {
|
3081 | var vimg = new VImg(idx);
|
3082 | G.VOM.items.push(vimg);
|
3083 |
|
3084 | if( G.I[idx].thumbImg().src == srct ) {
|
3085 |
|
3086 | displayIdx = vcnt;
|
3087 | }
|
3088 | vcnt++;
|
3089 | }
|
3090 |
|
3091 | }
|
3092 | if( G.VOM.items.length > 0 ) {
|
3093 | LightboxOpen( displayIdx );
|
3094 | }
|
3095 | else {
|
3096 | NanoConsoleLog(G, 'No content for Lightbox standalone.');
|
3097 | }
|
3098 | }
|
3099 |
|
3100 |
|
3101 |
|
3102 |
|
3103 | function parseIDs( IDs ) {
|
3104 | var r = { albumID: '0', imageID: '0' };
|
3105 |
|
3106 | var t = IDs.split('/');
|
3107 | if( t.length > 0 ) {
|
3108 | r.albumID = t[0];
|
3109 | if( t.length > 1 ) {
|
3110 | r.imageID = t[1];
|
3111 | }
|
3112 | }
|
3113 | return r;
|
3114 | }
|
3115 |
|
3116 |
|
3117 |
|
3118 | function DisplayAlbum( imageID, albumID ) {
|
3119 |
|
3120 | if( G.VOM.viewerDisplayed ) {
|
3121 | LightboxClose(null);
|
3122 | }
|
3123 |
|
3124 |
|
3125 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
3126 | G.GOM.curNavLevel = 'lN';
|
3127 | if( albumIdx == 0 ) {
|
3128 | G.GOM.curNavLevel = 'l1';
|
3129 | }
|
3130 | G.layout.SetEngine();
|
3131 | G.galleryResizeEventEnabled = false;
|
3132 |
|
3133 | if( albumIdx == -1 ) {
|
3134 | NGY2Item.New( G, '', '', albumID, '0', 'album' );
|
3135 | albumIdx = G.I.length - 1;
|
3136 | }
|
3137 |
|
3138 | if( !G.I[albumIdx].contentIsLoaded ) {
|
3139 |
|
3140 | AlbumGetContent( albumID, DisplayAlbum, imageID, albumID );
|
3141 | return;
|
3142 | }
|
3143 |
|
3144 | ThumbnailSelectionClear();
|
3145 |
|
3146 | G.GOM.pagination.currentPage = 0;
|
3147 | SetLocationHash( albumID, '' );
|
3148 | GalleryRender( albumIdx );
|
3149 |
|
3150 | }
|
3151 |
|
3152 |
|
3153 |
|
3154 | function GalleryBottomManage() {
|
3155 |
|
3156 | switch( G.galleryDisplayMode.Get() ) {
|
3157 | case 'PAGINATION':
|
3158 | if( G.layout.support.rows && G.galleryMaxRows.Get() > 0 ) {
|
3159 | ManagePagination();
|
3160 | }
|
3161 | break;
|
3162 | case 'MOREBUTTON':
|
3163 | G.$E.conTnBottom.off('click');
|
3164 | var nb = G.GOM.items.length-G.GOM.itemsDisplayed;
|
3165 | if( nb == 0 ) {
|
3166 | G.$E.conTnBottom.empty();
|
3167 | }
|
3168 | else {
|
3169 | G.$E.conTnBottom.html('<div class="nGY2GalleryMoreButton"><div class="nGY2GalleryMoreButtonAnnotation">+'+nb+' ' + G.O.icons.galleryMoreButton +'</div></div>');
|
3170 | G.$E.conTnBottom.on('click', function(e) {
|
3171 | G.GOM.displayedMoreSteps++;
|
3172 | GalleryResize();
|
3173 | });
|
3174 | }
|
3175 | break;
|
3176 | case 'FULLCONTENT':
|
3177 | default:
|
3178 | break;
|
3179 | }
|
3180 | }
|
3181 |
|
3182 |
|
3183 |
|
3184 | function breadcrumbAdd( albumIdx ) {
|
3185 |
|
3186 | var ic='';
|
3187 | if( !G.O.breadcrumbHideIcons ) {
|
3188 | ic=G.O.icons.breadcrumbAlbum;
|
3189 | if( albumIdx == 0 ) {
|
3190 | ic=G.O.icons.breadcrumbHome;
|
3191 | }
|
3192 | }
|
3193 | var $newDiv =jQuery('<div class="oneItem">'+ic + G.I[albumIdx].title+'</div>').appendTo(G.GOM.navigationBar.$newContent.find('.nGY2Breadcrumb'));
|
3194 | if( G.O.breadcrumbOnlyCurrentLevel ) {
|
3195 |
|
3196 | if( albumIdx == 0 ) {
|
3197 |
|
3198 | jQuery($newDiv).data('albumID','0');
|
3199 | }
|
3200 | else {
|
3201 | jQuery($newDiv).data('albumID',G.I[albumIdx].albumID);
|
3202 | }
|
3203 | }
|
3204 | else {
|
3205 |
|
3206 | jQuery($newDiv).data('albumID',G.I[albumIdx].GetID());
|
3207 | }
|
3208 | $newDiv.click(function() {
|
3209 | var cAlbumID = jQuery(this).data('albumID');
|
3210 | DisplayAlbum('-1', cAlbumID);
|
3211 | return;
|
3212 | });
|
3213 | }
|
3214 |
|
3215 |
|
3216 | function breadcrumbAddSeparator( lastAlbumID ) {
|
3217 | 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'));
|
3218 | jQuery($newSep).data('albumIdx',lastAlbumID);
|
3219 | $newSep.click(function() {
|
3220 | var sepAlbumIdx=jQuery(this).data('albumIdx');
|
3221 | DisplayAlbum('-1', G.I[sepAlbumIdx].GetID());
|
3222 | return;
|
3223 | });
|
3224 | }
|
3225 |
|
3226 |
|
3227 |
|
3228 |
|
3229 | function GalleryNavigationBar( albumIdx ) {
|
3230 |
|
3231 |
|
3232 |
|
3233 |
|
3234 |
|
3235 |
|
3236 |
|
3237 |
|
3238 |
|
3239 |
|
3240 |
|
3241 |
|
3242 |
|
3243 |
|
3244 |
|
3245 |
|
3246 | G.GOM.navigationBar.$newContent=jQuery('<div class="nGY2Navigationbar"></div>');
|
3247 |
|
3248 |
|
3249 |
|
3250 |
|
3251 | if( G.O.displayBreadcrumb == true && !G.O.thumbnailAlbumDisplayImage) {
|
3252 |
|
3253 | var newLevel = 0,
|
3254 | lstItems=[];
|
3255 | if( albumIdx != 0 ) {
|
3256 | var l=G.I.length,
|
3257 | parentID=0;
|
3258 |
|
3259 | lstItems.push(albumIdx);
|
3260 | var curIdx=albumIdx;
|
3261 | newLevel++;
|
3262 |
|
3263 | while( G.I[curIdx].albumID != 0 && G.I[curIdx].albumID != -1) {
|
3264 | for(var i=1; i < l; i++ ) {
|
3265 | if( G.I[i].GetID() == G.I[curIdx].albumID ) {
|
3266 | curIdx=i;
|
3267 | lstItems.push(curIdx);
|
3268 | newLevel++;
|
3269 | break;
|
3270 | }
|
3271 | }
|
3272 | }
|
3273 | }
|
3274 |
|
3275 |
|
3276 | if( !(G.O.breadcrumbAutoHideTopLevel && newLevel == 0) ) {
|
3277 | BreadcrumbBuild( lstItems );
|
3278 | }
|
3279 | }
|
3280 |
|
3281 |
|
3282 |
|
3283 | if( G.galleryFilterTags.Get() != false ) {
|
3284 | var nTags = G.I[albumIdx].albumTagList.length;
|
3285 | if( nTags > 0 ) {
|
3286 | for(var i = 0; i < nTags; i++ ) {
|
3287 | var s = G.I[albumIdx].albumTagList[i];
|
3288 | var ic = G.O.icons.navigationFilterUnselected;
|
3289 | var tagClass = 'Unselected';
|
3290 | if( jQuery.inArray(s, G.I[albumIdx].albumTagListSel) >= 0 ) {
|
3291 | tagClass = 'Selected';
|
3292 | ic = G.O.icons.navigationFilterSelected;
|
3293 | }
|
3294 |
|
3295 | var $newTag = jQuery('<div class="nGY2NavigationbarItem nGY2NavFilter' + tagClass + '">'+ ic +' '+ s +'</div>').appendTo(G.GOM.navigationBar.$newContent);
|
3296 |
|
3297 | $newTag.click(function() {
|
3298 |
|
3299 | var $this = jQuery(this);
|
3300 | var tag = $this.text().replace(/^\s*|\s*$/, '');
|
3301 |
|
3302 | if( G.galleryFilterTagsMode.Get() == 'single' ) {
|
3303 |
|
3304 | G.I[albumIdx].albumTagListSel = [];
|
3305 | G.I[albumIdx].albumTagListSel.push(tag);
|
3306 | }
|
3307 | else {
|
3308 |
|
3309 |
|
3310 | if( $this.hasClass('nGY2NavFilterUnselected') ){
|
3311 | G.I[albumIdx].albumTagListSel.push(tag);
|
3312 | }
|
3313 | else {
|
3314 | var tidx=jQuery.inArray(tag,G.I[albumIdx].albumTagListSel);
|
3315 | if( tidx != -1 ) {
|
3316 | G.I[albumIdx].albumTagListSel.splice(tidx,1);
|
3317 | }
|
3318 | }
|
3319 | $this.toggleClass('nGY2NavFilters-oneTagUnselected nGY2NavFilters-oneTagSelected');
|
3320 | }
|
3321 |
|
3322 | DisplayAlbum('-1', G.I[albumIdx].GetID());
|
3323 | });
|
3324 | }
|
3325 |
|
3326 |
|
3327 | var $newClearFilter=jQuery('<div class="nGY2NavigationbarItem nGY2NavFilterSelectAll">'+ G.O.icons.navigationFilterSelectedAll +'</div>').appendTo(G.GOM.navigationBar.$newContent);
|
3328 | $newClearFilter.click(function() {
|
3329 |
|
3330 | G.I[albumIdx].albumTagListSel = [];
|
3331 |
|
3332 |
|
3333 |
|
3334 |
|
3335 | DisplayAlbum('-1', G.I[albumIdx].GetID());
|
3336 | });
|
3337 | }
|
3338 | }
|
3339 |
|
3340 |
|
3341 | if( G.galleryDisplayMode.Get() == "PAGINATION" && G.O.galleryPaginationTopButtons ) {
|
3342 | if( G.layout.support.rows && G.galleryMaxRows.Get() > 0 ) {
|
3343 |
|
3344 | var $newTagPrev = jQuery('<div class="nGY2NavigationbarItem nGY2NavPagination">'+G.O.icons.navigationPaginationPrevious+'</div>').appendTo(G.GOM.navigationBar.$newContent);
|
3345 | $newTagPrev.click(function() {
|
3346 | paginationPreviousPage();
|
3347 | });
|
3348 | var $newTagNext = jQuery('<div class="nGY2NavigationbarItem nGY2NavPagination">'+G.O.icons.navigationPaginationNext+'</div>').appendTo(G.GOM.navigationBar.$newContent);
|
3349 | $newTagNext.click(function() {
|
3350 | paginationNextPage();
|
3351 | });
|
3352 | }
|
3353 | }
|
3354 |
|
3355 | }
|
3356 |
|
3357 | function BreadcrumbBuild(lstItems) {
|
3358 |
|
3359 |
|
3360 | jQuery('<div class="nGY2NavigationbarItem nGY2Breadcrumb"></div>').appendTo(G.GOM.navigationBar.$newContent);
|
3361 |
|
3362 |
|
3363 | if( G.O.breadcrumbOnlyCurrentLevel ) {
|
3364 |
|
3365 | if( lstItems.length == 0 ) {
|
3366 | breadcrumbAdd(0);
|
3367 | }
|
3368 | else {
|
3369 |
|
3370 | if( lstItems.length == 1 ) {
|
3371 | breadcrumbAddSeparator(0);
|
3372 | }
|
3373 | else {
|
3374 | breadcrumbAddSeparator(lstItems[0]);
|
3375 | }
|
3376 | breadcrumbAdd(lstItems[0]);
|
3377 | }
|
3378 | }
|
3379 | else {
|
3380 |
|
3381 | breadcrumbAdd(0);
|
3382 | if( lstItems.length > 0 ) {
|
3383 | breadcrumbAddSeparator(0);
|
3384 | for(var i=lstItems.length-1; i>=0 ; i-- ) {
|
3385 | breadcrumbAdd(lstItems[i]);
|
3386 | if( i > 0 ) {
|
3387 | breadcrumbAddSeparator(lstItems[i-1]);
|
3388 | }
|
3389 | }
|
3390 | }
|
3391 | }
|
3392 |
|
3393 | }
|
3394 |
|
3395 |
|
3396 |
|
3397 | function ManagePagination() {
|
3398 |
|
3399 | G.$E.conTnBottom.css('opacity', 0);
|
3400 | G.$E.conTnBottom.children().remove();
|
3401 |
|
3402 | if( G.GOM.items.length == 0 ) { return; }
|
3403 |
|
3404 |
|
3405 | var nbPages = Math.ceil((G.GOM.items[G.GOM.items.length - 1].row + 1)/G.galleryMaxRows.Get());
|
3406 |
|
3407 |
|
3408 | if( nbPages == 1 ) { return; }
|
3409 |
|
3410 |
|
3411 | if( G.GOM.pagination.currentPage > (nbPages-1) ) {
|
3412 | G.GOM.pagination.currentPage = nbPages-1;
|
3413 | }
|
3414 |
|
3415 | GalleryRenderGetInterval();
|
3416 |
|
3417 | if( G.GOM.displayInterval.len == 0 ) { return; }
|
3418 |
|
3419 |
|
3420 | if( G.O.galleryPaginationMode == 'NUMBERS' && G.GOM.pagination.currentPage > 0 ) {
|
3421 | var $eltPrev = jQuery('<div class="nGY2PaginationPrev">'+G.O.icons.paginationPrevious+'</div>').appendTo(G.$E.conTnBottom);
|
3422 | $eltPrev.click(function(e) {
|
3423 | paginationPreviousPage();
|
3424 | });
|
3425 | }
|
3426 |
|
3427 | var firstPage = 0;
|
3428 | var lastPage = nbPages;
|
3429 | if( G.O.galleryPaginationMode != 'NUMBERS' ) {
|
3430 |
|
3431 | firstPage = 0;
|
3432 | }
|
3433 | else {
|
3434 |
|
3435 |
|
3436 | var numberOfPagesToDisplay = G.O.paginationVisiblePages;
|
3437 | if( numberOfPagesToDisplay >= nbPages ) {
|
3438 | firstPage = 0;
|
3439 | }
|
3440 | else {
|
3441 |
|
3442 | var nbBeforeAfter = 0;
|
3443 | if( isOdd(numberOfPagesToDisplay) ) {
|
3444 | nbBeforeAfter = (numberOfPagesToDisplay + 1) / 2;
|
3445 | }
|
3446 | else {
|
3447 | nbBeforeAfter = numberOfPagesToDisplay / 2;
|
3448 | }
|
3449 |
|
3450 | if( G.GOM.pagination.currentPage < nbBeforeAfter ) {
|
3451 | firstPage = 0;
|
3452 | lastPage = numberOfPagesToDisplay - 1;
|
3453 | if( lastPage > nbPages ) {
|
3454 | lastPage = nbPages - 1;
|
3455 | }
|
3456 | }
|
3457 | else {
|
3458 | firstPage = G.GOM.pagination.currentPage - nbBeforeAfter;
|
3459 | lastPage = firstPage + numberOfPagesToDisplay;
|
3460 | if( lastPage > nbPages ) {
|
3461 | lastPage = nbPages - 1;
|
3462 | }
|
3463 | }
|
3464 |
|
3465 | if( (lastPage - firstPage) < numberOfPagesToDisplay ) {
|
3466 | firstPage = lastPage - numberOfPagesToDisplay;
|
3467 | if( firstPage < 0 ) {
|
3468 | firstPage = 0;
|
3469 | }
|
3470 | }
|
3471 |
|
3472 | }
|
3473 | }
|
3474 |
|
3475 |
|
3476 | for(var i = firstPage; i < lastPage; i++ ) {
|
3477 | var c = '';
|
3478 | var p = '';
|
3479 |
|
3480 | switch( G.O.galleryPaginationMode ) {
|
3481 | case 'NUMBERS':
|
3482 | c = 'nGY2paginationItem';
|
3483 | p = i + 1;
|
3484 | break;
|
3485 | case 'DOTS':
|
3486 | c = 'nGY2paginationDot';
|
3487 | break;
|
3488 | case 'RECTANGLES':
|
3489 | c = 'nGY2paginationRectangle';
|
3490 | break;
|
3491 | }
|
3492 | if( i == G.GOM.pagination.currentPage ) {
|
3493 | c += 'CurrentPage';
|
3494 | }
|
3495 |
|
3496 | var elt$ = jQuery('<div class="' + c + '">' + p + '</div>').appendTo(G.$E.conTnBottom);
|
3497 | elt$.data('pageNumber', i );
|
3498 | elt$.click( function(e) {
|
3499 | G.GOM.pagination.currentPage = jQuery(this).data('pageNumber');
|
3500 | TriggerCustomEvent('pageChanged');
|
3501 |
|
3502 |
|
3503 | G.GOM.ScrollToTop();
|
3504 |
|
3505 | GalleryDisplayPart1();
|
3506 | GalleryDisplayPart2( true );
|
3507 | });
|
3508 |
|
3509 | }
|
3510 |
|
3511 |
|
3512 | if( G.O.galleryPaginationMode == 'NUMBERS' && (G.GOM.pagination.currentPage + 1) < nbPages ) {
|
3513 | var $eltNext = jQuery('<div class="nGY2PaginationNext">' + G.O.icons.paginationNext + '</div>').appendTo(G.$E.conTnBottom);
|
3514 | $eltNext.click( function(e) {
|
3515 | paginationNextPage();
|
3516 | });
|
3517 | }
|
3518 |
|
3519 | G.$E.conTnBottom.css('opacity', 1);
|
3520 |
|
3521 | }
|
3522 | function isOdd(num) { return (num % 2) == 1;}
|
3523 |
|
3524 |
|
3525 | function paginationNextPage() {
|
3526 |
|
3527 | var n1 = 0;
|
3528 | ThumbnailHoverOutAll();
|
3529 |
|
3530 |
|
3531 | if( G.galleryMaxRows.Get() > 0 ) {
|
3532 |
|
3533 | n1 = (G.GOM.items[G.GOM.items.length - 1].row + 1) / G.galleryMaxRows.Get();
|
3534 | }
|
3535 | var n2 = Math.ceil(n1);
|
3536 | var pn = G.GOM.pagination.currentPage;
|
3537 | if( pn < (n2-1) ) {
|
3538 | pn++;
|
3539 | }
|
3540 | else {
|
3541 | pn = 0;
|
3542 | }
|
3543 |
|
3544 | G.GOM.pagination.currentPage = pn;
|
3545 | TriggerCustomEvent('pageChanged');
|
3546 |
|
3547 |
|
3548 | G.GOM.ScrollToTop();
|
3549 |
|
3550 | GalleryDisplayPart1();
|
3551 | GalleryDisplayPart2( true );
|
3552 | }
|
3553 |
|
3554 |
|
3555 | function paginationPreviousPage() {
|
3556 |
|
3557 |
|
3558 | var n1 = 0;
|
3559 |
|
3560 | ThumbnailHoverOutAll();
|
3561 |
|
3562 |
|
3563 | if( G.galleryMaxRows.Get() > 0 ) {
|
3564 |
|
3565 | n1 = (G.GOM.items[G.GOM.items.length - 1].row + 1) / G.galleryMaxRows.Get();
|
3566 | }
|
3567 | var n2 = Math.ceil(n1);
|
3568 |
|
3569 |
|
3570 | var pn = G.GOM.pagination.currentPage;
|
3571 | if( pn > 0 ) {
|
3572 | pn--;
|
3573 | }
|
3574 | else {
|
3575 | pn = n2 - 1;
|
3576 | }
|
3577 |
|
3578 | G.GOM.pagination.currentPage = pn;
|
3579 | TriggerCustomEvent('pageChanged');
|
3580 |
|
3581 |
|
3582 | G.GOM.ScrollToTop();
|
3583 |
|
3584 | GalleryDisplayPart1();
|
3585 | GalleryDisplayPart2( true );
|
3586 | }
|
3587 |
|
3588 |
|
3589 | function GalleryRenderGetInterval() {
|
3590 | G.GOM.displayInterval.from = 0;
|
3591 | G.GOM.displayInterval.len = G.I.length;
|
3592 |
|
3593 | switch( G.galleryDisplayMode.Get() ) {
|
3594 | case 'PAGINATION':
|
3595 | if( G.layout.support.rows ) {
|
3596 | let nbTn = G.GOM.items.length;
|
3597 | var firstRow = G.GOM.pagination.currentPage * G.galleryMaxRows.Get();
|
3598 | var lastRow = firstRow + G.galleryMaxRows.Get();
|
3599 | var firstTn = -1;
|
3600 | G.GOM.displayInterval.len = 0;
|
3601 | for( var i = 0; i < nbTn ; i++ ) {
|
3602 | let curTn = G.GOM.items[i];
|
3603 | if( curTn.row >= firstRow && curTn.row < lastRow ) {
|
3604 | if( firstTn == -1 ) {
|
3605 | G.GOM.displayInterval.from = i;
|
3606 | firstTn = i;
|
3607 | }
|
3608 | G.GOM.displayInterval.len++;
|
3609 | }
|
3610 | }
|
3611 | }
|
3612 | break;
|
3613 | case 'MOREBUTTON':
|
3614 | if( G.layout.support.rows ) {
|
3615 | let nbTn = G.GOM.items.length;
|
3616 | let lastRow = G.O.galleryDisplayMoreStep * (G.GOM.displayedMoreSteps+1);
|
3617 | G.GOM.displayInterval.len = 0;
|
3618 | for( var i = 0; i < nbTn ; i++ ) {
|
3619 | let curTn = G.GOM.items[i];
|
3620 | if( curTn.row < lastRow ) {
|
3621 | G.GOM.displayInterval.len++;
|
3622 | }
|
3623 | }
|
3624 | }
|
3625 | break;
|
3626 | case 'ROWS':
|
3627 | if( G.layout.support.rows ) {
|
3628 | let nbTn = G.GOM.items.length;
|
3629 | let lastRow = G.galleryMaxRows.Get();
|
3630 | if( G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1 ) {
|
3631 | if( lastRow > (G.GOM.lastFullRow + 1) ) {
|
3632 | lastRow = G.GOM.lastFullRow + 1;
|
3633 | }
|
3634 | }
|
3635 | G.GOM.displayInterval.len = 0;
|
3636 | for( var i = 0; i < nbTn ; i++ ) {
|
3637 | let curTn = G.GOM.items[i];
|
3638 | if( curTn.row < lastRow ) {
|
3639 | G.GOM.displayInterval.len++;
|
3640 | }
|
3641 | }
|
3642 | }
|
3643 | break;
|
3644 | default:
|
3645 | case 'FULLCONTENT':
|
3646 | if( G.layout.support.rows && G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1 ) {
|
3647 | let nbTn = G.GOM.items.length;
|
3648 | let lastRow = G.GOM.lastFullRow + 1;
|
3649 | G.GOM.displayInterval.len = 0;
|
3650 | for( var i = 0; i < nbTn ; i++ ) {
|
3651 | let curTn = G.GOM.items[i];
|
3652 | if( curTn.row < lastRow ) {
|
3653 | G.GOM.displayInterval.len++;
|
3654 | }
|
3655 | }
|
3656 | }
|
3657 | break;
|
3658 | }
|
3659 | }
|
3660 |
|
3661 |
|
3662 |
|
3663 | function GalleryRender( albumIdx ) {
|
3664 | TriggerCustomEvent('galleryRenderStart');
|
3665 | clearTimeout(G.GOM.slider.timerID);
|
3666 | G.GOM.slider.hostIdx = -1;
|
3667 |
|
3668 | var fu=G.O.fnGalleryRenderStart;
|
3669 | if( fu !== null ) {
|
3670 |
|
3671 | typeof fu == 'function' ? fu( G.I[G.GOM.albumIdx] ) : window[fu]( G.I[G.GOM.albumIdx] );
|
3672 | }
|
3673 |
|
3674 | G.layout.SetEngine();
|
3675 | G.galleryResizeEventEnabled = false;
|
3676 | G.GOM.albumIdx = -1;
|
3677 | G.GOM.lastDisplayedIdx = -1;
|
3678 |
|
3679 |
|
3680 | if( G.$E.conTnBottom !== undefined ) {
|
3681 |
|
3682 | G.$E.conTnBottom.empty();
|
3683 | }
|
3684 |
|
3685 |
|
3686 | GalleryNavigationBar(albumIdx);
|
3687 |
|
3688 | if( G.GOM.firstDisplay ) {
|
3689 |
|
3690 | G.GOM.firstDisplay = false;
|
3691 | var d = Date.now()-G.GOM.firstDisplayTime;
|
3692 | if( d < G.O.galleryRenderDelay ) {
|
3693 |
|
3694 |
|
3695 | requestTimeout( function() { GalleryRenderPart1( albumIdx )}, G.O.galleryRenderDelay-d );
|
3696 | }
|
3697 | else {
|
3698 | GalleryRenderPart1( albumIdx );
|
3699 | }
|
3700 | G.O.galleryRenderDelay = 0;
|
3701 |
|
3702 | }
|
3703 | else {
|
3704 | var hideNavigationBar = false;
|
3705 | if( G.GOM.navigationBar.$newContent.children().length == 0 ) {
|
3706 | hideNavigationBar = true;
|
3707 | }
|
3708 |
|
3709 |
|
3710 | var tweenable = new NGTweenable();
|
3711 | tweenable.tween({
|
3712 | from: { 'opacity': 1 },
|
3713 | to: { 'opacity': 0 },
|
3714 | duration: 300,
|
3715 | easing: 'easeInQuart',
|
3716 | attachment: { h: hideNavigationBar },
|
3717 | step: function (state, att) {
|
3718 | G.$E.conTnParent.css({'opacity': state.opacity });
|
3719 | if( att.h ) {
|
3720 | G.$E.conNavigationBar.css({ 'opacity': state.opacity });
|
3721 | }
|
3722 | },
|
3723 | finish: function (state, att) {
|
3724 | if( att.h ) {
|
3725 | G.$E.conNavigationBar.css({ 'opacity': 0, 'display': 'none' });
|
3726 | }
|
3727 |
|
3728 |
|
3729 | G.GOM.ScrollToTop();
|
3730 |
|
3731 | GalleryRenderPart1( albumIdx );
|
3732 | }
|
3733 | });
|
3734 | }
|
3735 | }
|
3736 |
|
3737 |
|
3738 | function GalleryRenderPart1( albumIdx ) {
|
3739 |
|
3740 | var oldN = G.$E.conNavigationBar.children().length;
|
3741 | G.$E.conNavigationBar.empty();
|
3742 | G.GOM.navigationBar.$newContent.children().clone(true,true).appendTo(G.$E.conNavigationBar);
|
3743 |
|
3744 | if( G.$E.conNavigationBar.children().length > 0 && oldN == 0 ) {
|
3745 | G.$E.conNavigationBar.css({ 'opacity': 0, 'display': 'block' });
|
3746 | var tweenable = new NGTweenable();
|
3747 | tweenable.tween({
|
3748 | from: { opacity: 0 },
|
3749 | to: { opacity: 1 },
|
3750 | duration: 200,
|
3751 | easing: 'easeInQuart',
|
3752 | step: function (state) {
|
3753 |
|
3754 | G.$E.conNavigationBar.css( state );
|
3755 |
|
3756 | },
|
3757 | finish: function (state) {
|
3758 |
|
3759 | G.$E.conNavigationBar.css({ 'opacity': 1 });
|
3760 |
|
3761 |
|
3762 |
|
3763 | requestTimeout(function(){ GalleryRenderPart2(albumIdx) }, 20);
|
3764 |
|
3765 | }
|
3766 | });
|
3767 | }
|
3768 | else {
|
3769 | requestTimeout(function(){ GalleryRenderPart2(albumIdx) }, 20);
|
3770 | }
|
3771 |
|
3772 | }
|
3773 |
|
3774 |
|
3775 | function GalleryRenderPart2(albumIdx) {
|
3776 |
|
3777 | G.GOM.lastZIndex = parseInt(G.$E.base.css('z-index'));
|
3778 | if( isNaN(G.GOM.lastZIndex) ) {
|
3779 | G.GOM.lastZIndex=0;
|
3780 | }
|
3781 | G.$E.conTnParent.css({ 'opacity': 0 });
|
3782 | G.$E.conTn.off().empty();
|
3783 | var l = G.I.length;
|
3784 | for( var i = 0; i < l ; i++ ) {
|
3785 |
|
3786 | var item = G.I[i];
|
3787 | item.hovered = false;
|
3788 | item.$elt = null;
|
3789 | item.$Elts = [];
|
3790 | item.eltTransform = [];
|
3791 | item.eltFilter = [];
|
3792 | item.width = 0;
|
3793 | item.height = 0;
|
3794 | item.left = 0;
|
3795 | item.top = 0;
|
3796 | item.resizedContentWidth = 0;
|
3797 | item.resizedContentHeight = 0;
|
3798 | item.thumbnailImgRevealed = false;
|
3799 | }
|
3800 |
|
3801 | if( G.CSStransformName == null ) {
|
3802 | G.$E.conTn.css('left', '0px');
|
3803 | }
|
3804 | else {
|
3805 |
|
3806 | G.$E.conTn.css( G.CSStransformName, 'none');
|
3807 | }
|
3808 |
|
3809 |
|
3810 | requestTimeout(function(){ GalleryRenderPart3(albumIdx) }, 20);
|
3811 |
|
3812 |
|
3813 | }
|
3814 |
|
3815 |
|
3816 | function GalleryRenderPart3(albumIdx) {
|
3817 | var d = new Date();
|
3818 |
|
3819 | G.$E.conTnParent.css( 'opacity', 1);
|
3820 |
|
3821 | G.GOM.items = [];
|
3822 | G.GOM.displayedMoreSteps = 0;
|
3823 |
|
3824 | if( G.O.thumbnailLabel.get('position') == 'onBottom' ) {
|
3825 |
|
3826 | G.tn.labelHeight[G.GOM.curNavLevel] = ThumbnailGetLabelHeight();
|
3827 | }
|
3828 | else {
|
3829 | G.tn.labelHeight[G.GOM.curNavLevel] = 0;
|
3830 | }
|
3831 | G.GOM.albumIdx=albumIdx;
|
3832 |
|
3833 | TriggerCustomEvent('galleryRenderEnd');
|
3834 | var fu=G.O.fnGalleryRenderEnd;
|
3835 | if( fu !== null ) {
|
3836 |
|
3837 | typeof fu == 'function' ? fu(G.I[G.GOM.albumIdx] ) : window[fu](G.I[G.GOM.albumIdx] );
|
3838 | }
|
3839 |
|
3840 |
|
3841 | if( GalleryPopulateGOM() ) {
|
3842 |
|
3843 | GallerySetLayout();
|
3844 |
|
3845 |
|
3846 | GalleryAppear();
|
3847 |
|
3848 |
|
3849 | GalleryDisplayPart1();
|
3850 | requestTimeout(function(){ GalleryDisplayPart2( false ) }, 20);
|
3851 | }
|
3852 | else {
|
3853 |
|
3854 | G.galleryResizeEventEnabled = true;
|
3855 | }
|
3856 |
|
3857 | if( G.O.debugMode ) { console.log('GalleryRenderPart3: '+ (new Date()-d)); }
|
3858 |
|
3859 | }
|
3860 |
|
3861 |
|
3862 |
|
3863 | function GalleryResize() {
|
3864 | var d = new Date();
|
3865 | G.galleryResizeEventEnabled = false;
|
3866 |
|
3867 | if( GallerySetLayout() == false ) {
|
3868 | G.galleryResizeEventEnabled = true;
|
3869 | if( G.O.debugMode ) { console.log('GalleryResize1: '+ (new Date()-d)); }
|
3870 | return;
|
3871 | }
|
3872 | if( G.O.debugMode ) { console.log('GalleryResizeSetLayout: '+ (new Date()-d)); }
|
3873 |
|
3874 | GalleryDisplayPart1();
|
3875 | GalleryDisplayPart2( false );
|
3876 |
|
3877 | if( G.O.debugMode ) { console.log('GalleryResizeFull: '+ (new Date()-d)); }
|
3878 | }
|
3879 |
|
3880 |
|
3881 |
|
3882 |
|
3883 |
|
3884 |
|
3885 | function GalleryPopulateGOM() {
|
3886 |
|
3887 | var preloadImages = '';
|
3888 | var albumID = G.I[G.GOM.albumIdx].GetID();
|
3889 | var l = G.I.length;
|
3890 | var cnt = 0;
|
3891 |
|
3892 | for( var idx = 0; idx < l; idx++ ) {
|
3893 | var item = G.I[idx];
|
3894 |
|
3895 | if( item.isToDisplay(albumID) ) {
|
3896 | var w = item.thumbImg().width;
|
3897 | var h = item.thumbImg().height;
|
3898 |
|
3899 | if( G.layout.prerequisite.imageSize && ( w == 0 || h == 0) ) {
|
3900 |
|
3901 | preloadImages += '<img src="'+item.thumbImg().src+'" data-idx="'+cnt+'" data-albumidx="'+G.GOM.albumIdx+'">';
|
3902 | }
|
3903 |
|
3904 |
|
3905 | if( h == 0 ) {
|
3906 | h = G.tn.defaultSize.getHeight();
|
3907 | }
|
3908 | if( w == 0 ) {
|
3909 | w = G.tn.defaultSize.getWidth();
|
3910 | }
|
3911 | var tn = new G.GOM.GTn(idx, w, h);
|
3912 | G.GOM.items.push(tn);
|
3913 | cnt++;
|
3914 | }
|
3915 | }
|
3916 |
|
3917 | TriggerCustomEvent('galleryObjectModelBuilt');
|
3918 | var fu = G.O.fnGalleryObjectModelBuilt;
|
3919 | if( fu !== null ) {
|
3920 | typeof fu == 'function' ? fu() : window[fu]();
|
3921 | }
|
3922 |
|
3923 | if( preloadImages != '' ) {
|
3924 |
|
3925 | var $newImg = jQuery(preloadImages);
|
3926 | var gi_imgLoad = ngimagesLoaded( $newImg );
|
3927 | $newImg = null;
|
3928 | gi_imgLoad.on( 'progress', function( instance, image ) {
|
3929 |
|
3930 | if( image.isLoaded ) {
|
3931 | var idx = image.img.getAttribute('data-idx');
|
3932 | var albumIdx = image.img.getAttribute('data-albumidx');
|
3933 | if( albumIdx == G.GOM.albumIdx ) {
|
3934 |
|
3935 | var curTn = G.GOM.items[idx];
|
3936 | curTn.imageWidth = image.img.naturalWidth;
|
3937 | curTn.imageHeight = image.img.naturalHeight;
|
3938 | var item = G.I[curTn.thumbnailIdx];
|
3939 | item.thumbs.width[G.GOM.curNavLevel][G.GOM.curWidth] = curTn.imageWidth;
|
3940 | item.thumbs.height[G.GOM.curNavLevel][G.GOM.curWidth] = curTn.imageHeight;
|
3941 |
|
3942 |
|
3943 | G.GalleryResizeThrottled();
|
3944 |
|
3945 |
|
3946 | var object = item.thumbs.width.l1;
|
3947 | for (let property in object) {
|
3948 | if (object.hasOwnProperty(property)) {
|
3949 | if( property != G.GOM.curWidth ) {
|
3950 | if( G.tn.settings.width.l1[property] == G.tn.settings.getW() && G.tn.settings.height.l1[property] == G.tn.settings.getH() ) {
|
3951 | item.thumbs.width.l1[property] = curTn.imageWidth;
|
3952 | item.thumbs.height.l1[property] = curTn.imageHeight;
|
3953 | }
|
3954 | }
|
3955 | }
|
3956 | }
|
3957 | object = item.thumbs.width.lN;
|
3958 | for (let property in object) {
|
3959 | if (object.hasOwnProperty(property)) {
|
3960 | if( property != G.GOM.curWidth ) {
|
3961 | if( G.tn.settings.width.lN[property] == G.tn.settings.getW() && G.tn.settings.height.lN[property] == G.tn.settings.getH() ) {
|
3962 | item.thumbs.width.lN[property] = curTn.imageWidth;
|
3963 | item.thumbs.height.lN[property] = curTn.imageHeight;
|
3964 | }
|
3965 | }
|
3966 | }
|
3967 | }
|
3968 | }
|
3969 | }
|
3970 | });
|
3971 | G.galleryResizeEventEnabled = true;
|
3972 | return false;
|
3973 | }
|
3974 | else {
|
3975 | return true;
|
3976 | }
|
3977 |
|
3978 | }
|
3979 |
|
3980 |
|
3981 | function GallerySetLayout() {
|
3982 | var r = true;
|
3983 |
|
3984 | G.GOM.cache.areaWidth = G.$E.conTnParent.width();
|
3985 | G.GOM.displayArea = { width:0, height:0 };
|
3986 |
|
3987 | switch( G.layout.engine ) {
|
3988 | case 'JUSTIFIED':
|
3989 | r = GallerySetLayoutWidthtAuto();
|
3990 | break;
|
3991 | case 'CASCADING':
|
3992 | r = GallerySetLayoutHeightAuto();
|
3993 | break;
|
3994 | case 'MOSAIC':
|
3995 | r = GallerySetLayoutMosaic();
|
3996 | break;
|
3997 | case 'GRID':
|
3998 | default:
|
3999 | r = GallerySetLayoutGrid();
|
4000 | break;
|
4001 | }
|
4002 |
|
4003 | TriggerCustomEvent('galleryLayoutApplied');
|
4004 | var fu = G.O.fnGalleryLayoutApplied;
|
4005 | if( fu !== null ) {
|
4006 | typeof fu == 'function' ? fu() : window[fu]();
|
4007 | }
|
4008 | return r;
|
4009 |
|
4010 | }
|
4011 |
|
4012 |
|
4013 |
|
4014 | function GallerySetLayoutHeightAuto() {
|
4015 | var curCol = 0,
|
4016 | areaWidth = G.GOM.cache.areaWidth,
|
4017 | curRow = 0,
|
4018 | colHeight = [],
|
4019 | maxCol = NbThumbnailsPerRow(areaWidth),
|
4020 | gutterWidth = 0,
|
4021 | gutterHeight = G.tn.settings.GetResponsive('gutterHeight');
|
4022 | var w = 0;
|
4023 | var scaleFactor = 1;
|
4024 | var tnWidth = G.tn.defaultSize.getOuterWidth();
|
4025 | var nbTn = G.GOM.items.length;
|
4026 | var curPosY = 0;
|
4027 |
|
4028 | if( G.O.thumbnailAlignment == 'justified' ) {
|
4029 | maxCol = Math.min(maxCol, nbTn);
|
4030 | gutterWidth = ( maxCol == 1 ? 0 : (areaWidth - (maxCol * tnWidth) ) / (maxCol - 1) );
|
4031 | }
|
4032 | else {
|
4033 | gutterWidth = G.tn.settings.GetResponsive('gutterWidth');
|
4034 | }
|
4035 |
|
4036 |
|
4037 | var borderWidth = G.tn.opt.Get('borderHorizontal') * 2;
|
4038 | var borderHeight = G.tn.opt.Get('borderVertical') * 2;
|
4039 |
|
4040 | G.GOM.lastFullRow=-1;
|
4041 |
|
4042 |
|
4043 | if( G.O.thumbnailAlignment == 'fillWidth' ) {
|
4044 |
|
4045 | var totalGutterWidth = (maxCol - 1) * gutterWidth;
|
4046 | scaleFactor = (areaWidth - totalGutterWidth) / (maxCol * tnWidth);
|
4047 | if( scaleFactor > 1 ) {
|
4048 | maxCol++;
|
4049 | }
|
4050 | totalGutterWidth = (maxCol - 1) * gutterWidth;
|
4051 | scaleFactor = Math.min( (areaWidth - totalGutterWidth) / (maxCol*tnWidth), 1);
|
4052 | }
|
4053 |
|
4054 |
|
4055 | tnWidth = Math.round( tnWidth * scaleFactor);
|
4056 | var contentWidth = tnWidth - borderWidth;
|
4057 |
|
4058 |
|
4059 | var baseHeight = Math.round( G.tn.opt.Get('baseGridHeight') * scaleFactor );
|
4060 | for( var i = 0; i < nbTn ; i++ ) {
|
4061 | var curTn = G.GOM.items[i];
|
4062 | if( curTn.deleted == true ) { break; }
|
4063 | if( curTn.imageHeight > 0 && curTn.imageWidth > 0 ) {
|
4064 | var curPosX = 0,
|
4065 | curPosY = 0;
|
4066 | var imageRatio = curTn.imageHeight / curTn.imageWidth;
|
4067 |
|
4068 | curTn.resizedContentWidth = contentWidth;
|
4069 | curTn.resizedContentHeight = curTn.resizedContentWidth * imageRatio;
|
4070 | if( baseHeight > 0 ) {
|
4071 |
|
4072 | var t = Math.max( Math.trunc(curTn.resizedContentHeight/baseHeight), 1) ;
|
4073 | curTn.resizedContentHeight = baseHeight * t + ((t-1)*(borderHeight+gutterHeight));
|
4074 | }
|
4075 |
|
4076 | curTn.height = curTn.resizedContentHeight + borderHeight + G.tn.labelHeight.get();
|
4077 | curTn.width = tnWidth;
|
4078 | curTn.row = 0;
|
4079 |
|
4080 | if( curRow == 0 ) {
|
4081 |
|
4082 | curPosX = curCol * (tnWidth + gutterWidth);
|
4083 | colHeight[curCol] = curTn.height + gutterHeight;
|
4084 |
|
4085 | curCol++;
|
4086 | if( curCol >= maxCol ) {
|
4087 | curCol = 0;
|
4088 | curRow++;
|
4089 | }
|
4090 | }
|
4091 | else {
|
4092 | var c=0,
|
4093 | minColHeight=colHeight[0];
|
4094 | for( var j = 1; j < maxCol; j++) {
|
4095 | if( (colHeight[j] + 5) < minColHeight ) {
|
4096 | minColHeight = colHeight[j];
|
4097 | c = j;
|
4098 |
|
4099 | }
|
4100 | }
|
4101 | curPosY = colHeight[c];
|
4102 | curPosX = c * (tnWidth + gutterWidth);
|
4103 | colHeight[c] = curPosY + curTn.height + gutterHeight;
|
4104 | }
|
4105 |
|
4106 | var x = curPosX;
|
4107 | if( G.O.RTL) {
|
4108 | x= w - curPosX - tnWidth;
|
4109 | }
|
4110 |
|
4111 | curTn.left = x;
|
4112 | curTn.top = curPosY;
|
4113 | }
|
4114 | }
|
4115 |
|
4116 | G.GOM.displayArea.width= maxCol * (tnWidth + gutterWidth) - gutterWidth;
|
4117 | return true;
|
4118 | }
|
4119 |
|
4120 |
|
4121 |
|
4122 | function GallerySetLayoutWidthtAuto() {
|
4123 | var curWidth = 0,
|
4124 | areaWidth = G.GOM.cache.areaWidth,
|
4125 | lastPosX = 0,
|
4126 | curPosY = 0,
|
4127 | rowLastItem = [],
|
4128 | rowNum = 0,
|
4129 | rowHeight = [],
|
4130 | bNewRow = false,
|
4131 | cnt = 0,
|
4132 | gutterWidth = G.tn.settings.GetResponsive('gutterWidth'),
|
4133 | gutterHeight = G.tn.settings.GetResponsive('gutterHeight');
|
4134 |
|
4135 | var maxRowHeightVertical = 0;
|
4136 | var maxRowHeightHorizontal = 0;
|
4137 | var rowHasVertical = false;
|
4138 | var rowHasHorizontal = false;
|
4139 |
|
4140 | var tnHeight = G.tn.defaultSize.getOuterHeight();
|
4141 | var borderWidth = G.tn.opt.Get('borderHorizontal') * 2;
|
4142 | var borderHeight = G.tn.opt.Get('borderVertical') * 2;
|
4143 | var nbTnInCurrRow = 1;
|
4144 | var nbTn = G.GOM.items.length;
|
4145 |
|
4146 |
|
4147 | for( var i = 0; i < nbTn ; i++ ) {
|
4148 | let curTn = G.GOM.items[i];
|
4149 | if( curTn.deleted == true ) { break; }
|
4150 | if( curTn.imageWidth > 0 ) {
|
4151 | let imageRatio = curTn.imageWidth / curTn.imageHeight;
|
4152 | let imageWidth = Math.floor( tnHeight * imageRatio );
|
4153 |
|
4154 | if( bNewRow ) {
|
4155 | bNewRow = false;
|
4156 | rowNum++;
|
4157 | curWidth = 0;
|
4158 | rowHasVertical = false;
|
4159 | rowHasHorizontal = false;
|
4160 | nbTnInCurrRow = 1;
|
4161 | }
|
4162 |
|
4163 | if( curTn.imageHeight > curTn.imageWidth ) {
|
4164 | rowHasVertical = true;
|
4165 | }
|
4166 | else {
|
4167 | rowHasHorizontal = true;
|
4168 | }
|
4169 |
|
4170 | if( (curWidth + gutterWidth + imageWidth) < (areaWidth - (nbTnInCurrRow * borderWidth)) ) {
|
4171 |
|
4172 | curWidth += imageWidth + gutterWidth;
|
4173 | rowHeight[rowNum] = tnHeight;
|
4174 |
|
4175 |
|
4176 |
|
4177 | var rowHeightLimit = Math.max(rowHasVertical ? maxRowHeightVertical : 0, rowHasHorizontal ? maxRowHeightHorizontal : 0);
|
4178 | if( rowHeightLimit > 0 ) {
|
4179 | rowHeight[rowNum] = Math.min(rowHeight[rowNum], rowHeightLimit);
|
4180 | }
|
4181 |
|
4182 | rowLastItem[rowNum] = i;
|
4183 | }
|
4184 | else {
|
4185 |
|
4186 | curWidth += gutterWidth+imageWidth;
|
4187 | let ratio = (areaWidth - nbTnInCurrRow * borderWidth) / curWidth;
|
4188 | let rH = Math.floor(tnHeight * ratio);
|
4189 | rowHeight[rowNum] = rH;
|
4190 |
|
4191 |
|
4192 |
|
4193 | if( rowHasVertical ) {
|
4194 | maxRowHeightVertical = Math.max( maxRowHeightVertical, rH );
|
4195 | }
|
4196 | if( rowHasHorizontal ) {
|
4197 | maxRowHeightHorizontal = Math.max( maxRowHeightHorizontal, rH );
|
4198 | }
|
4199 |
|
4200 | rowLastItem[rowNum] = i;
|
4201 | bNewRow = true;
|
4202 | }
|
4203 | cnt++;
|
4204 | nbTnInCurrRow++;
|
4205 | }
|
4206 | }
|
4207 |
|
4208 | rowNum = 0;
|
4209 | curPosY = 0;
|
4210 | lastPosX = 0;
|
4211 | cnt = 0;
|
4212 |
|
4213 | G.GOM.lastFullRow = 0;
|
4214 |
|
4215 |
|
4216 | for( var i = 0; i < nbTn ; i++ ) {
|
4217 | let curTn = G.GOM.items[i];
|
4218 | if( curTn.imageWidth > 0 ) {
|
4219 | let imageRatio = curTn.imageWidth / curTn.imageHeight;
|
4220 | let imageWidth = Math.floor( imageRatio * rowHeight[rowNum] );
|
4221 |
|
4222 | if( i == rowLastItem[rowNum] ) {
|
4223 |
|
4224 | if( rowLastItem.length != (rowNum+1) ) {
|
4225 |
|
4226 | imageWidth = areaWidth - lastPosX - borderWidth;
|
4227 | }
|
4228 | else {
|
4229 |
|
4230 | if( (lastPosX + gutterWidth + imageWidth + borderWidth ) > areaWidth ) {
|
4231 |
|
4232 | imageWidth = areaWidth - lastPosX - borderWidth;
|
4233 | }
|
4234 | }
|
4235 | }
|
4236 |
|
4237 | let rh = parseInt( rowHeight[rowNum] );
|
4238 | imageWidth = parseInt( imageWidth );
|
4239 |
|
4240 |
|
4241 | curTn.resizedContentWidth = imageWidth;
|
4242 | curTn.resizedContentHeight = rh;
|
4243 |
|
4244 | curTn.width = imageWidth + borderWidth;
|
4245 | curTn.height= rh + G.tn.labelHeight.get() + borderHeight;
|
4246 | curTn.row = rowNum;
|
4247 |
|
4248 | curTn.top = curPosY;
|
4249 | let x = lastPosX;
|
4250 | if( G.O.RTL) {
|
4251 | x = areaWidth - lastPosX - curTn.width ;
|
4252 | }
|
4253 | curTn.left = x;
|
4254 |
|
4255 | lastPosX += curTn.width + gutterWidth;
|
4256 |
|
4257 | if( i == rowLastItem[rowNum] ) {
|
4258 |
|
4259 | curPosY += curTn.height + gutterHeight;
|
4260 | G.GOM.lastFullRow = rowNum - 1;
|
4261 | rowNum++;
|
4262 | lastPosX = 0;
|
4263 | }
|
4264 | cnt++;
|
4265 | }
|
4266 | else {
|
4267 | return false;
|
4268 | }
|
4269 | }
|
4270 |
|
4271 |
|
4272 | if( false ) {
|
4273 | var newTop = 0;
|
4274 | if( typeof GOMidx !== 'undefined' ) {
|
4275 | if( G.GOM.albumIdx != -1 ) {
|
4276 | var hoveredTn = G.GOM.items[GOMidx];
|
4277 |
|
4278 |
|
4279 | hoveredTn.width += 40;
|
4280 | hoveredTn.height += 40;
|
4281 |
|
4282 | for( var i = 0; i < nbTn ; i++ ) {
|
4283 | var curTn = G.GOM.items[i];
|
4284 | if( curTn.imageWidth > 0 ) {
|
4285 | if( curTn.row == hoveredTn.row ) {
|
4286 |
|
4287 | newTop = 40;
|
4288 | if( hoveredTn.thumbnailIdx != curTn.thumbnailIdx ) {
|
4289 |
|
4290 | curTn.top += 30;
|
4291 | curTn.width -= 20;
|
4292 | curTn.height -= 20;
|
4293 | }
|
4294 | }
|
4295 | else {
|
4296 |
|
4297 | if( curTn.row == 0 ) {
|
4298 |
|
4299 | }
|
4300 | else {
|
4301 | curTn.top += newTop;
|
4302 | }
|
4303 | }
|
4304 | }
|
4305 | }
|
4306 | }
|
4307 | }
|
4308 | }
|
4309 |
|
4310 | G.GOM.displayArea.width = areaWidth;
|
4311 | return true;
|
4312 | }
|
4313 |
|
4314 |
|
4315 |
|
4316 |
|
4317 |
|
4318 | function GallerySetLayoutMosaic() {
|
4319 | var areaWidth = G.GOM.cache.areaWidth;
|
4320 | var gutterHeight = G.tn.settings.GetResponsive('gutterHeight');
|
4321 | var gutterWidth = G.tn.settings.GetResponsive('gutterWidth');
|
4322 | var borderWidth = G.tn.opt.Get('borderHorizontal') * 2;
|
4323 | var borderHeight = G.tn.opt.Get('borderVertical') * 2;
|
4324 |
|
4325 | var nbTn = G.GOM.items.length;
|
4326 | var row = 0;
|
4327 | var h = 0;
|
4328 | var n = 0;
|
4329 |
|
4330 |
|
4331 |
|
4332 | var nbCols = 0;
|
4333 | var maxW = 0;
|
4334 | let mosaicPattern = G.tn.settings.getMosaic();
|
4335 | for( var i = 0; i < nbTn ; i++ ) {
|
4336 | let curPatternElt = mosaicPattern[n];
|
4337 |
|
4338 | var cLeft = (curPatternElt.c - 1) * G.tn.defaultSize.getOuterWidth() + (curPatternElt.c - 1) * gutterWidth;
|
4339 | var cWidth = curPatternElt.w * G.tn.defaultSize.getOuterWidth() + (curPatternElt.w - 1) * gutterWidth;
|
4340 |
|
4341 | maxW = Math.max(maxW, cLeft + cWidth );
|
4342 |
|
4343 | nbCols = Math.max(nbCols, (curPatternElt.c - 1) + curPatternElt.w );
|
4344 |
|
4345 | n++;
|
4346 | if( n >= mosaicPattern.length ) {
|
4347 |
|
4348 | break;
|
4349 | }
|
4350 | }
|
4351 | var totalGutterWidth = (nbCols - 1) * gutterWidth;
|
4352 | var scaleFactor = Math.min( (areaWidth - totalGutterWidth ) / ( maxW - totalGutterWidth ), 1);
|
4353 |
|
4354 |
|
4355 | row = 0;
|
4356 | n = 0;
|
4357 |
|
4358 | for( var i = 0; i < nbTn ; i++ ) {
|
4359 | let curTn = G.GOM.items[i];
|
4360 | let curPatternElt = mosaicPattern[n];
|
4361 |
|
4362 | 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)) ;
|
4363 | if( row > 0 ) {
|
4364 | curTn.top += gutterHeight;
|
4365 | }
|
4366 |
|
4367 | curTn.left = (curPatternElt.c - 1) * Math.round(G.tn.defaultSize.getOuterWidth()*scaleFactor) + (curPatternElt.c - 1) * gutterWidth;
|
4368 |
|
4369 | curTn.height = Math.round(curPatternElt.h * G.tn.defaultSize.getOuterHeight() * scaleFactor) + (curPatternElt.h - 1) * gutterHeight + (G.tn.labelHeight.get() * curPatternElt.h);
|
4370 | curTn.resizedContentHeight = curTn.height - G.tn.labelHeight.get() - borderHeight;
|
4371 |
|
4372 | curTn.width = Math.round(curPatternElt.w * G.tn.defaultSize.getOuterWidth()*scaleFactor) + (curPatternElt.w - 1) * gutterWidth;
|
4373 | curTn.resizedContentWidth = curTn.width - borderWidth ;
|
4374 |
|
4375 | curTn.row = row;
|
4376 | if( row == 0 ) {
|
4377 | h=Math.max(h, curTn.top + curTn.height);
|
4378 | }
|
4379 |
|
4380 | n++;
|
4381 | if( n >= mosaicPattern.length ) {
|
4382 |
|
4383 | n = 0;
|
4384 | row++;
|
4385 | }
|
4386 | }
|
4387 |
|
4388 | G.GOM.displayArea.width = (maxW - totalGutterWidth) * scaleFactor + totalGutterWidth;
|
4389 | return true;
|
4390 | }
|
4391 |
|
4392 |
|
4393 |
|
4394 |
|
4395 | function GallerySetLayoutGrid() {
|
4396 | var curPosX= 0,
|
4397 | curPosY= 0,
|
4398 | areaWidth= G.GOM.cache.areaWidth,
|
4399 | gutterWidth= 0,
|
4400 | gutterHeight= G.tn.settings.GetResponsive('gutterHeight'),
|
4401 | maxCol= NbThumbnailsPerRow(areaWidth),
|
4402 | w= 0,
|
4403 | cols= [],
|
4404 | curCol= 0,
|
4405 | newAreaWidth = areaWidth,
|
4406 | tnWidth= G.tn.defaultSize.getOuterWidth();
|
4407 | var scaleFactor = 1;
|
4408 | var nbTn= G.GOM.items.length;
|
4409 | var borderWidth = G.tn.opt.Get('borderHorizontal') * 2;
|
4410 | var borderHeight = G.tn.opt.Get('borderVertical') * 2;
|
4411 |
|
4412 |
|
4413 | if( G.O.thumbnailAlignment == 'justified' ) {
|
4414 | maxCol = Math.min( maxCol, nbTn);
|
4415 | gutterWidth = (maxCol==1 ? 0 : (areaWidth-(maxCol*tnWidth))/(maxCol-1));
|
4416 | }
|
4417 | else {
|
4418 | gutterWidth = G.tn.settings.GetResponsive('gutterWidth');
|
4419 | }
|
4420 |
|
4421 |
|
4422 |
|
4423 | if( G.O.RTL || G.O.thumbnailAlignment == 'fillWidth' ) {
|
4424 |
|
4425 | var totalGutterWidth = (maxCol-1) * gutterWidth;
|
4426 | scaleFactor = (areaWidth - totalGutterWidth) / (maxCol*tnWidth);
|
4427 | if( scaleFactor > 1 ) {
|
4428 | maxCol++;
|
4429 | }
|
4430 | totalGutterWidth = (maxCol-1) * gutterWidth;
|
4431 | scaleFactor = Math.min( (areaWidth - totalGutterWidth) / (maxCol*tnWidth), 1);
|
4432 | newAreaWidth = (maxCol*tnWidth) + totalGutterWidth;
|
4433 | }
|
4434 |
|
4435 |
|
4436 | G.GOM.lastFullRow = 0 ;
|
4437 |
|
4438 | var row = 0;
|
4439 |
|
4440 | tnWidth = Math.round(tnWidth * scaleFactor);
|
4441 | var contentWidth = tnWidth - borderWidth;
|
4442 | var tnHeight = Math.round(G.tn.defaultSize.getOuterHeight() * scaleFactor) + G.tn.labelHeight.get();
|
4443 | var contentHeight = Math.round( G.tn.defaultSize.getOuterHeight() * scaleFactor) - borderHeight;
|
4444 |
|
4445 |
|
4446 | for( var i = 0; i < nbTn ; i++ ) {
|
4447 | if( curPosY == 0 ) {
|
4448 | curPosX = curCol * (tnWidth + gutterWidth)
|
4449 | cols[curCol] = curPosX;
|
4450 | w = curPosX + tnWidth;
|
4451 | }
|
4452 | else {
|
4453 | curPosX = cols[curCol];
|
4454 | }
|
4455 |
|
4456 | var x = curPosX;
|
4457 | if( G.O.RTL ) {
|
4458 | x = parseInt(newAreaWidth) - curPosX - tnWidth;
|
4459 | }
|
4460 |
|
4461 |
|
4462 | var curTn=G.GOM.items[i];
|
4463 | curTn.top = curPosY;
|
4464 | curTn.left = x;
|
4465 | curTn.height = tnHeight;
|
4466 | curTn.width = tnWidth;
|
4467 |
|
4468 | if( G.O.thumbnailAlignment == 'fillWidth' ) {
|
4469 | curTn.resizedContentWidth = contentWidth;
|
4470 | curTn.resizedContentHeight = contentHeight;
|
4471 | }
|
4472 | curTn.row = row;
|
4473 |
|
4474 |
|
4475 | curCol++;
|
4476 | if( curCol >= maxCol ){
|
4477 |
|
4478 | curCol = 0;
|
4479 | curPosY += tnHeight + gutterHeight;
|
4480 | G.GOM.lastFullRow = row;
|
4481 | row++;
|
4482 | }
|
4483 | }
|
4484 | G.GOM.displayArea.width = w;
|
4485 |
|
4486 | return true;
|
4487 | }
|
4488 |
|
4489 |
|
4490 |
|
4491 |
|
4492 |
|
4493 | function GalleryDisplayPart1() {
|
4494 | if( G.CSStransformName == null ) {
|
4495 | G.$E.conTn.css( 'left' , '0px');
|
4496 | }
|
4497 | else {
|
4498 | G.$E.conTn.css( G.CSStransformName , 'none');
|
4499 | }
|
4500 |
|
4501 | }
|
4502 |
|
4503 | function CacheViewport() {
|
4504 | G.GOM.cache.viewport = getViewport();
|
4505 |
|
4506 | G.GOM.cache.areaWidth = G.$E.base.width();
|
4507 |
|
4508 |
|
4509 |
|
4510 |
|
4511 |
|
4512 |
|
4513 | if( !G.O.lightboxStandalone ) {
|
4514 | G.GOM.cache.containerOffset = G.$E.conLoadingB.offset();
|
4515 | }
|
4516 | }
|
4517 |
|
4518 |
|
4519 |
|
4520 | function GalleryDisplayPart2( forceTransition ) {
|
4521 | CacheViewport();
|
4522 |
|
4523 | var nbTn = G.GOM.items.length;
|
4524 | G.GOM.itemsDisplayed = 0;
|
4525 | var threshold = 50;
|
4526 | var cnt = 0;
|
4527 |
|
4528 |
|
4529 | GalleryRenderGetInterval();
|
4530 |
|
4531 | for( var i = 0; i < nbTn ; i++ ) {
|
4532 | let curTn = G.GOM.items[i];
|
4533 | if( i >= G.GOM.displayInterval.from && cnt < G.GOM.displayInterval.len ) {
|
4534 | curTn.inDisplayArea = true;
|
4535 | if( forceTransition ) {
|
4536 | curTn.neverDisplayed = true;
|
4537 | }
|
4538 | G.GOM.itemsDisplayed++;
|
4539 | cnt++;
|
4540 | }
|
4541 | else{
|
4542 | curTn.inDisplayArea = false;
|
4543 | }
|
4544 | }
|
4545 |
|
4546 |
|
4547 | GalleryBottomManage();
|
4548 |
|
4549 | var tnToDisplay = [];
|
4550 | var tnToReDisplay = [];
|
4551 |
|
4552 | CacheViewport();
|
4553 | G.GOM.clipArea.top = -1;
|
4554 | cnt = 0 ;
|
4555 | var lastTnIdx = -1;
|
4556 | G.GOM.clipArea.height = 0;
|
4557 |
|
4558 | for( var i = 0; i < nbTn ; i++ ) {
|
4559 | let curTn = G.GOM.items[i];
|
4560 | if( curTn.inDisplayArea ) {
|
4561 | if( G.GOM.clipArea.top == -1 ) {
|
4562 | G.GOM.clipArea.top = curTn.top;
|
4563 | }
|
4564 | if( (curTn.top - G.GOM.clipArea.top) <= -1 ) {
|
4565 |
|
4566 | G.GOM.clipArea.top = curTn.top;
|
4567 | }
|
4568 |
|
4569 | G.GOM.clipArea.height = Math.max( G.GOM.clipArea.height, curTn.top-G.GOM.clipArea.top + curTn.height);
|
4570 |
|
4571 | if( curTn.neverDisplayed ) {
|
4572 |
|
4573 | var top = G.GOM.cache.containerOffset.top + (curTn.top - G.GOM.clipArea.top);
|
4574 |
|
4575 | if( (top + curTn.height) >= (G.GOM.cache.viewport.t - threshold) && top <= (G.GOM.cache.viewport.t + G.GOM.cache.viewport.h + threshold) ) {
|
4576 |
|
4577 | let item = G.I[curTn.thumbnailIdx];
|
4578 | if( item.$elt == null ) {
|
4579 |
|
4580 | ThumbnailBuild( item, curTn.thumbnailIdx, i );
|
4581 | }
|
4582 | tnToDisplay.push({idx:i, delay:cnt, top: curTn.top, left: curTn.left});
|
4583 | cnt++;
|
4584 | }
|
4585 | }
|
4586 | else {
|
4587 | tnToReDisplay.push({idx: i, delay: 0, top: curTn.top, left: curTn.left});
|
4588 | }
|
4589 |
|
4590 | lastTnIdx = i;
|
4591 | }
|
4592 | else {
|
4593 | curTn.displayed = false;
|
4594 | let item = G.I[curTn.thumbnailIdx];
|
4595 | if( item.$elt != null ){
|
4596 | item.$elt.css({ opacity: 0, display: 'none' });
|
4597 | }
|
4598 | }
|
4599 | }
|
4600 |
|
4601 | var areaWidth = G.$E.conTnParent.width();
|
4602 |
|
4603 |
|
4604 |
|
4605 | if( G.GOM.displayArea.width != G.GOM.displayAreaLast.width || G.GOM.clipArea.height != G.GOM.displayAreaLast.height ) {
|
4606 | G.$E.conTn.width( G.GOM.displayArea.width ).height( G.GOM.clipArea.height );
|
4607 | G.GOM.displayAreaLast.width = G.GOM.displayArea.width;
|
4608 | G.GOM.displayAreaLast.height = G.GOM.clipArea.height;
|
4609 |
|
4610 | }
|
4611 |
|
4612 | if( areaWidth != G.$E.conTnParent.width() ) {
|
4613 |
|
4614 |
|
4615 | G.GOM.cache.areaWidth = G.$E.conTnParent.width();
|
4616 | GallerySetLayout();
|
4617 | GalleryDisplayPart1();
|
4618 | GalleryDisplayPart2( forceTransition );
|
4619 | return;
|
4620 | }
|
4621 |
|
4622 |
|
4623 | if( G.layout.support.rows ) {
|
4624 | if( G.galleryDisplayMode.Get() == 'ROWS' || (G.galleryDisplayMode.Get() == 'FULLCONTENT' && G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1) ){
|
4625 | if( lastTnIdx < (nbTn - 1) ) {
|
4626 | G.GOM.lastDisplayedIdxNew = lastTnIdx;
|
4627 | }
|
4628 | else {
|
4629 | G.GOM.lastDisplayedIdxNew =- 1;
|
4630 | }
|
4631 |
|
4632 | if( G.GOM.lastDisplayedIdx != -1 ) {
|
4633 | let item = G.I[G.GOM.items[G.GOM.lastDisplayedIdx].thumbnailIdx];
|
4634 | item.$getElt('.nGY2GThumbnailIconsFullThumbnail').html('');
|
4635 | }
|
4636 | }
|
4637 | }
|
4638 |
|
4639 |
|
4640 |
|
4641 |
|
4642 |
|
4643 | G.GOM.thumbnails2Display=[];
|
4644 |
|
4645 | var duration = ThumbnailPreparePosition( tnToDisplay );
|
4646 | ThumbnailPreparePosition( tnToReDisplay );
|
4647 |
|
4648 | ThumbnailDisplayAnimBatch();
|
4649 |
|
4650 | if( G.tn.opt.Get('displayTransition') == 'NONE' ) {
|
4651 | G.galleryResizeEventEnabled = true;
|
4652 |
|
4653 | TriggerCustomEvent('galleryDisplayed');
|
4654 | }
|
4655 | else {
|
4656 |
|
4657 | requestTimeout( function() {
|
4658 |
|
4659 | G.galleryResizeEventEnabled = true;
|
4660 |
|
4661 | TriggerCustomEvent('galleryDisplayed');
|
4662 |
|
4663 | }, duration * G.tn.opt.Get('displayInterval'));
|
4664 | }
|
4665 |
|
4666 | }
|
4667 |
|
4668 |
|
4669 | function ThumbnailPreparePosition( lstThumb ) {
|
4670 |
|
4671 | var nbBuild = lstThumb.length;
|
4672 | if( nbBuild == 0 ) { return 0; }
|
4673 |
|
4674 |
|
4675 | var displayOrder = G.tn.opt.Get('displayOrder');
|
4676 |
|
4677 | if( displayOrder == 'random' ) {
|
4678 | NGY2Tools.AreaShuffle( lstThumb );
|
4679 | }
|
4680 | else {
|
4681 | if( displayOrder == 'rowByRow' && !( G.layout.engine == 'JUSTIFIED' || G.layout.engine == 'GRID' )) {
|
4682 | displayOrder = '';
|
4683 | }
|
4684 | if( (displayOrder == 'colFromRight' || displayOrder == 'colFromLeft' ) && !(G.layout.engine == 'CASCADING' || G.layout.engine == 'GRID' )) {
|
4685 | displayOrder = '';
|
4686 | }
|
4687 | }
|
4688 |
|
4689 |
|
4690 |
|
4691 | if( displayOrder == 'colFromRight' || displayOrder == 'colFromLeft' ) {
|
4692 | var tab = [];
|
4693 | var cols = [];
|
4694 | for( var i = 0; i < nbBuild ; i++ ) {
|
4695 | if( tab[lstThumb[i].left] == undefined ) {
|
4696 | tab[lstThumb[i].left] = [];
|
4697 | cols.push( lstThumb[i].left );
|
4698 | }
|
4699 | tab[lstThumb[i].left].push( lstThumb[i].idx )
|
4700 | }
|
4701 | if( displayOrder == 'colFromRight' ) {
|
4702 | cols = cols.reverse();
|
4703 | }
|
4704 | for( var i = 0; i < cols.length; i++ ) {
|
4705 | var col = cols[i];
|
4706 | for( var j = 0; j < tab[col].length; j++ ) {
|
4707 | ThumbnailSetPosition( tab[col][j], i);
|
4708 | }
|
4709 | }
|
4710 | return(i);
|
4711 | }
|
4712 |
|
4713 |
|
4714 |
|
4715 | var d = 0;
|
4716 | var top = lstThumb[0].top;
|
4717 | for( var i = 0; i < nbBuild ; i++ ) {
|
4718 |
|
4719 |
|
4720 |
|
4721 | if( displayOrder == 'rowByRow' ) {
|
4722 |
|
4723 | if( lstThumb[i].top > top ) {
|
4724 | d++;
|
4725 | top = lstThumb[i].top;
|
4726 | }
|
4727 | }
|
4728 | else {
|
4729 | d++;
|
4730 | }
|
4731 | ThumbnailSetPosition(lstThumb[i].idx, d);
|
4732 | }
|
4733 | return(d);
|
4734 |
|
4735 | }
|
4736 |
|
4737 |
|
4738 | function ThumbnailSetPosition( GOMidx, cnt ) {
|
4739 | var newTop= 0;
|
4740 | var curTn= G.GOM.items[GOMidx];
|
4741 | var idx= G.GOM.items[GOMidx].thumbnailIdx;
|
4742 | var item= G.I[idx];
|
4743 |
|
4744 | if( curTn.neverDisplayed ) {
|
4745 |
|
4746 | var top = curTn.top - G.GOM.clipArea.top;
|
4747 | if( G.tn.opt.Get('stacks') > 0 ) {
|
4748 |
|
4749 | item.$elt.last().css({ display: 'block'});
|
4750 | item.$elt.css({ top: top , left: curTn.left });
|
4751 | }
|
4752 | else {
|
4753 | item.$elt.css({ display: 'block', top: top , left: curTn.left });
|
4754 | }
|
4755 | newTop=top;
|
4756 |
|
4757 |
|
4758 | if( G.O.thumbnailWaitImageLoaded === true ) {
|
4759 | var gi_imgLoad = ngimagesLoaded( item.$getElt('.nGY2TnImg2') );
|
4760 | gi_imgLoad.on( 'progress', function( instance, image ) {
|
4761 | if( image.isLoaded ) {
|
4762 | var albumIdx = image.img.getAttribute('data-albumidx');
|
4763 | if( albumIdx == G.GOM.albumIdx ) {
|
4764 |
|
4765 | var idx = image.img.getAttribute('data-idx');
|
4766 | G.I[idx].ThumbnailImageReveal();
|
4767 | }
|
4768 | }
|
4769 | });
|
4770 | }
|
4771 |
|
4772 | ThumbnailAppear(GOMidx, cnt);
|
4773 |
|
4774 | curTn.displayed = true;
|
4775 | curTn.neverDisplayed = false;
|
4776 | }
|
4777 | else {
|
4778 | var topOld = G.GOM.cache.containerOffset.top + item.top;
|
4779 | var top = G.GOM.cache.containerOffset.top + (curTn.top - G.GOM.clipArea.top);
|
4780 | newTop = curTn.top - G.GOM.clipArea.top;
|
4781 | var vp = G.GOM.cache.viewport;
|
4782 | if( G.O.thumbnailDisplayOutsideScreen || ( ( (topOld + curTn.height) >= (vp.t - vp.h) && topOld <= (vp.t + vp.h * 4) ) ||
|
4783 | ( (top + curTn.height) >= (vp.t - vp.h) && top <= (vp.t + vp.h * 4) ) ) ) {
|
4784 |
|
4785 | if( curTn.displayed ) {
|
4786 |
|
4787 | if( item.top != curTn.top || item.left != curTn.left ) {
|
4788 |
|
4789 | if( G.O.galleryResizeAnimation == true ) {
|
4790 |
|
4791 | var tweenable = new NGTweenable();
|
4792 | tweenable.tween({
|
4793 | from: { top: item.top, left: item.left, height: item.height, width: item.width },
|
4794 | to: { top: newTop, left: curTn.left, height: curTn.height, width: curTn.width },
|
4795 | attachment: { $e: item.$elt },
|
4796 | duration: 100,
|
4797 | delay: cnt * G.tn.opt.Get('displayInterval') / 5,
|
4798 |
|
4799 | easing: 'easeOutQuart',
|
4800 | step: function (state, att) {
|
4801 |
|
4802 | att.$e.css(state);
|
4803 |
|
4804 | },
|
4805 | finish: function (state, att) {
|
4806 | var _this=this;
|
4807 |
|
4808 | _this.dispose();
|
4809 |
|
4810 | }
|
4811 | });
|
4812 | }
|
4813 | else {
|
4814 |
|
4815 |
|
4816 | item.$elt.css({ top: newTop , left: curTn.left });
|
4817 | }
|
4818 | }
|
4819 | }
|
4820 | else {
|
4821 |
|
4822 | curTn.displayed = true;
|
4823 |
|
4824 | item.$elt.css({ display: 'block', top: newTop, left: curTn.left, opacity: 1 });
|
4825 | ThumbnailAppearFinish(item);
|
4826 | }
|
4827 | }
|
4828 | else {
|
4829 |
|
4830 | curTn.displayed = false;
|
4831 | item.$elt.css({ display: 'none'});
|
4832 | }
|
4833 | }
|
4834 | item.left = curTn.left;
|
4835 | item.top = newTop;
|
4836 |
|
4837 |
|
4838 | if( item.width != curTn.width || item.height != curTn.height ) {
|
4839 | item.$elt.css({ width: curTn.width , height: curTn.height });
|
4840 | item.width = curTn.width;
|
4841 | item.height = curTn.height;
|
4842 |
|
4843 |
|
4844 |
|
4845 | if( item.resizedContentWidth != curTn.resizedContentWidth || item.resizedContentHeight != curTn.resizedContentHeight ) {
|
4846 | if( item.kind == 'albumUp' ) {
|
4847 |
|
4848 | }
|
4849 | else {
|
4850 | item.$getElt('.nGY2GThumbnailImage').css({'height': curTn.resizedContentHeight, 'width': curTn.resizedContentWidth});
|
4851 |
|
4852 | if( G.layout.engine == 'JUSTIFIED' ) {
|
4853 | item.$getElt('.nGY2GThumbnailImg').css({'height': curTn.resizedContentHeight, 'width': curTn.resizedContentWidth});
|
4854 | }
|
4855 | }
|
4856 | item.resizedContentWidth = curTn.resizedContentWidth;
|
4857 | item.resizedContentHeight = curTn.resizedContentHeight;
|
4858 | }
|
4859 | }
|
4860 |
|
4861 |
|
4862 |
|
4863 | if( G.GOM.lastDisplayedIdxNew == GOMidx && G.layout.support.rows ) {
|
4864 | if( (G.galleryDisplayMode.Get() == 'ROWS' && G.galleryMaxRows.Get() > 0) || (G.galleryDisplayMode.Get() == 'FULLCONTENT' && G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1) ){
|
4865 |
|
4866 | var nb = G.GOM.items.length - GOMidx - 1;
|
4867 | if( item.albumID != '0' && G.O.thumbnailLevelUp ) {
|
4868 | nb--;
|
4869 | }
|
4870 |
|
4871 | if( nb > 0 ) {
|
4872 |
|
4873 | if( G.O.thumbnailOpenInLightox || G.O.thumbnailSliderDelay > 0 ) {
|
4874 | item.$getElt('.nGY2GThumbnailIconsFullThumbnail').html( '+' + nb);
|
4875 | }
|
4876 |
|
4877 |
|
4878 |
|
4879 | if( G.O.thumbnailLabel.get('position') != 'right' && G.O.thumbnailLabel.get('position') != 'left' ) {
|
4880 | if( G.GOM.slider.hostItem != G.GOM.NGY2Item(GOMidx) ) {
|
4881 |
|
4882 |
|
4883 | GalleryThumbnailSliderSetContent( G.GOM.slider.hostItem );
|
4884 |
|
4885 | G.GOM.slider.hostIdx = GOMidx;
|
4886 | G.GOM.slider.hostItem = G.GOM.NGY2Item(GOMidx);
|
4887 | G.GOM.slider.nextIdx = GOMidx;
|
4888 | G.GOM.slider.currentIdx = GOMidx;
|
4889 | GalleryThumbnailSliderBuildAndStart();
|
4890 |
|
4891 | }
|
4892 | }
|
4893 | }
|
4894 | else {
|
4895 |
|
4896 | GalleryThumbnailSliderSetContent( G.GOM.slider.hostItem );
|
4897 | G.GOM.slider.hostIdx = -1;
|
4898 | }
|
4899 |
|
4900 | G.GOM.lastDisplayedIdx = GOMidx;
|
4901 | }
|
4902 | }
|
4903 |
|
4904 | }
|
4905 |
|
4906 |
|
4907 |
|
4908 |
|
4909 | function GalleryThumbnailSliderBuildAndStart() {
|
4910 |
|
4911 | if( G.O.thumbnailSliderDelay == 0 || G.GOM.slider.hostIdx == -1 ) {
|
4912 | return;
|
4913 | }
|
4914 | clearTimeout(G.GOM.slider.timerID);
|
4915 |
|
4916 | var item = G.GOM.slider.hostItem;
|
4917 |
|
4918 |
|
4919 | if( item.$getElt('.nGY2TnImgNext').length == 0 ) {
|
4920 | item.$getElt('.nGY2TnImg').clone().removeClass('nGY2TnImg').addClass('nGY2TnImgNext').insertAfter(item.$getElt('.nGY2TnImg'));
|
4921 | item.$getElt('.nGY2TnImgBack').clone().removeClass('nGY2TnImgBack').addClass('nGY2TnImgBackNext').insertAfter(item.$getElt('.nGY2TnImg', true));
|
4922 | item.$getElt('.nGY2GThumbnailImage', true);
|
4923 | item.$getElt('.nGY2GThumbnailImg', true);
|
4924 | }
|
4925 |
|
4926 | item.CSSTransformSet('.nGY2TnImgNext', 'translateX', '100%', true);
|
4927 | item.CSSTransformApply( '.nGY2TnImgNext' );
|
4928 | item.CSSTransformSet('.nGY2TnImgBackNext', 'translateX', '100%', true);
|
4929 | item.CSSTransformApply( '.nGY2TnImgBackNext' );
|
4930 |
|
4931 | GalleryThumbnailSliderSetNextContent();
|
4932 |
|
4933 |
|
4934 |
|
4935 | G.GOM.slider.timerID = requestTimeout(function(){ GalleryThumbnailSliderStartTransition() }, G.O.thumbnailSliderDelay);
|
4936 | }
|
4937 |
|
4938 |
|
4939 | function GalleryThumbnailSliderSetNextContent() {
|
4940 |
|
4941 | G.GOM.slider.nextIdx++;
|
4942 | if( G.GOM.slider.nextIdx >= G.GOM.items.length ) {
|
4943 | G.GOM.slider.nextIdx = G.GOM.slider.hostIdx;
|
4944 | }
|
4945 |
|
4946 |
|
4947 | var newItem = G.GOM.NGY2Item(G.GOM.slider.nextIdx);
|
4948 |
|
4949 | var bgImg = "url('" + G.emptyGif + "')";
|
4950 | if( newItem.imageDominantColors != null ) {
|
4951 |
|
4952 | bgImg = "url('" + newItem.imageDominantColors + "')";
|
4953 | }
|
4954 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgBackNext', true).css({'background-image': bgImg, opacity: 1 });
|
4955 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgNext', true).css({ 'background-image': "url('" + newItem.thumbImg().src + "')", opacity: 1 });
|
4956 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgNext .nGY2GThumbnailImg', true).attr('src', newItem.thumbImg().src );
|
4957 |
|
4958 |
|
4959 | }
|
4960 |
|
4961 |
|
4962 | function GalleryThumbnailSliderStartTransition() {
|
4963 |
|
4964 | if( G.GOM.slider.hostItem.$getElt() != null ) {
|
4965 |
|
4966 |
|
4967 | var tweenable = new NGTweenable();
|
4968 | G.GOM.slider.tween = tweenable;
|
4969 | tweenable.tween({
|
4970 | from: { 'left': 100 },
|
4971 | to: { 'left': 0 },
|
4972 | duration: 800,
|
4973 | delay: 0,
|
4974 |
|
4975 | easing: 'easeOutQuart',
|
4976 |
|
4977 | step: function (state) {
|
4978 | if( G.GOM.slider.hostItem.$getElt() == null ) {
|
4979 |
|
4980 | G.GOM.slider.tween.stop(false);
|
4981 | return;
|
4982 | }
|
4983 |
|
4984 |
|
4985 |
|
4986 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBack', 'translateX', -(100 - state.left) + '%');
|
4987 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBack' );
|
4988 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImg', 'translateX', -(100 - state.left) + '%');
|
4989 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImg' );
|
4990 |
|
4991 |
|
4992 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBackNext', 'translateX', state.left + '%');
|
4993 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBackNext' );
|
4994 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgNext', 'translateX', state.left + '%');
|
4995 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgNext' );
|
4996 |
|
4997 |
|
4998 |
|
4999 | },
|
5000 | finish: function (state) {
|
5001 | if( G.GOM.slider.hostItem.$getElt() == null ) {
|
5002 |
|
5003 | return;
|
5004 | }
|
5005 |
|
5006 | if( G.GOM.NGY2Item(G.GOM.slider.nextIdx) == null ) { return; }
|
5007 |
|
5008 |
|
5009 |
|
5010 | GalleryThumbnailSliderSetContent( G.GOM.NGY2Item(G.GOM.slider.nextIdx) );
|
5011 | G.GOM.slider.currentIdx = G.GOM.slider.nextIdx;
|
5012 | GalleryThumbnailSliderSetNextContent();
|
5013 |
|
5014 | clearTimeout(G.GOM.slider.timerID);
|
5015 |
|
5016 | G.GOM.slider.timerID = requestTimeout(function(){ GalleryThumbnailSliderStartTransition() }, G.O.thumbnailSliderDelay);
|
5017 |
|
5018 | }
|
5019 | });
|
5020 | }
|
5021 | }
|
5022 |
|
5023 |
|
5024 |
|
5025 | function GalleryThumbnailSliderSetContent( ngy2itemContent ) {
|
5026 | if( G.GOM.slider.hostIdx == -1 ) { return; }
|
5027 |
|
5028 | if( G.GOM.slider.tween != null ) {
|
5029 | if( G.GOM.slider.tween._isTweening == true ) {
|
5030 | G.GOM.slider.tween.stop(false);
|
5031 | }
|
5032 | }
|
5033 |
|
5034 | var bgImg = "url('" + G.emptyGif + "')";
|
5035 | if( ngy2itemContent.imageDominantColors != null ) {
|
5036 | bgImg = "url('" + ngy2itemContent.imageDominantColors + "')";
|
5037 | }
|
5038 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgBack').css('background-image', bgImg);
|
5039 | G.GOM.slider.hostItem.$getElt('.nGY2TnImg').css('background-image', "url('" + ngy2itemContent.thumbImg().src + "')" );
|
5040 | G.GOM.slider.hostItem.$getElt('.nGY2TnImg .nGY2GThumbnailImg').attr('src', ngy2itemContent.thumbImg().src );
|
5041 |
|
5042 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBack', 'translateX', '0');
|
5043 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBack' );
|
5044 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImg', 'translateX', '0');
|
5045 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImg' );
|
5046 |
|
5047 |
|
5048 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBackNext', 'translateX', '100%', true);
|
5049 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBackNext' );
|
5050 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgNext', 'translateX', '100%', true);
|
5051 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgNext' );
|
5052 |
|
5053 |
|
5054 | if( G.O.thumbnailLabel.get('display') == true ) {
|
5055 | var icons = G.O.icons.thumbnailAlbum;
|
5056 | if( ngy2itemContent.kind != 'album' ) {
|
5057 | icons = G.O.icons.thumbnailImage;
|
5058 | }
|
5059 | G.GOM.slider.hostItem.$getElt('.nGY2GThumbnailTitle').html(icons + getThumbnailTitle(ngy2itemContent));
|
5060 | G.GOM.slider.hostItem.$getElt('.nGY2GThumbnailDescription').html(icons + getTumbnailDescription(ngy2itemContent));
|
5061 | }
|
5062 | }
|
5063 |
|
5064 |
|
5065 |
|
5066 |
|
5067 | function ThumbnailGetLabelHeight() {
|
5068 | var newElt = [],
|
5069 | newEltIdx = 0;
|
5070 |
|
5071 |
|
5072 | if( G.O.thumbnailLabel.get('display') == false ) {
|
5073 | return 0;
|
5074 | }
|
5075 |
|
5076 |
|
5077 |
|
5078 |
|
5079 |
|
5080 |
|
5081 |
|
5082 | newElt[newEltIdx++] = '<div class="nGY2GThumbnail ' + G.O.theme + '" style="display:block;visibility:hidden;position:absolute;top:-9999px;left:-9999px;" ><div class="nGY2GThumbnailSub">';
|
5083 | if( G.O.thumbnailLabel.get('display') == true ) {
|
5084 |
|
5085 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailLabel" '+ G.tn.style.getLabel() +'>';
|
5086 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailAlbumTitle" '+G.tn.style.getTitle()+'>aAzZjJ</div>';
|
5087 | if( G.O.thumbnailLabel.get('displayDescription') == true ) {
|
5088 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailDescription" '+G.tn.style.getDesc()+'>'+'aAzZjJ'+'</div>';
|
5089 | }
|
5090 | newElt[newEltIdx++] = ' </div>';
|
5091 | }
|
5092 |
|
5093 | newElt[newEltIdx++] = '</div></div>';
|
5094 |
|
5095 | var $newDiv = jQuery(newElt.join('')).appendTo(G.$E.conTn);
|
5096 | var h = $newDiv.find('.nGY2GThumbnailLabel').outerHeight(true);
|
5097 | $newDiv.remove();
|
5098 |
|
5099 | return h;
|
5100 | }
|
5101 |
|
5102 | function ThumbnailBuildStacks( bgColor ) {
|
5103 | var ns=G.tn.opt.Get('stacks');
|
5104 | if( ns == 0 ) { return ''; }
|
5105 |
|
5106 | var s='';
|
5107 | for( var i=0; i<ns; i++ ) {
|
5108 | s='<div class="nGY2GThumbnailStack " style="display:none;'+bgColor+'"></div>'+s;
|
5109 | }
|
5110 | return s;
|
5111 | }
|
5112 |
|
5113 |
|
5114 | function ThumbnailBuildAlbumpUp( item, GOMidx ) {
|
5115 |
|
5116 | var newElt = [],
|
5117 | newEltIdx = 0;
|
5118 |
|
5119 | var mp = '';
|
5120 | if( G.O.thumbnailOpenInLightox === false ) {
|
5121 | mp = 'cursor:default;'
|
5122 | }
|
5123 |
|
5124 | newElt[newEltIdx++] = ThumbnailBuildStacks('') + '<div class="nGY2GThumbnail" style="display:none;opacity:0;' + mp + '" >';
|
5125 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailSub">';
|
5126 |
|
5127 | var h=G.tn.defaultSize.getHeight(),
|
5128 | w=G.tn.defaultSize.getWidth();
|
5129 |
|
5130 | 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>';
|
5131 |
|
5132 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailAlbumUp" >'+G.O.icons.thumbnailAlbumUp+'</div>';
|
5133 | newElt[newEltIdx++] = ' </div>';
|
5134 | newElt[newEltIdx++] = '</div>';
|
5135 |
|
5136 | var $newDiv = jQuery(newElt.join('')).appendTo(G.$E.conTn);
|
5137 |
|
5138 | item.$elt = $newDiv;
|
5139 | $newDiv.data('index', GOMidx);
|
5140 | item.$getElt('.nGY2GThumbnailImg').data('index', GOMidx);
|
5141 |
|
5142 | return;
|
5143 | }
|
5144 |
|
5145 |
|
5146 |
|
5147 | function ThumbnailBuild( item, idx, GOMidx ) {
|
5148 |
|
5149 | item.eltTransform = [];
|
5150 | item.eltFilter = [];
|
5151 | item.hoverInitDone = false;
|
5152 | item.$Elts = [];
|
5153 |
|
5154 | if( item.kind == 'albumUp' ) {
|
5155 | ThumbnailBuildAlbumpUp( item, GOMidx);
|
5156 | return;
|
5157 | }
|
5158 |
|
5159 | var newElt = [],
|
5160 | newEltIdx = 0;
|
5161 |
|
5162 | var mp = '';
|
5163 | if( G.O.thumbnailOpenInLightox === false ) {
|
5164 | mp = 'cursor:default;'
|
5165 | }
|
5166 |
|
5167 |
|
5168 | var src = (item.thumbImg().src).replace(/'/g, "%27"),
|
5169 | sTitle = getThumbnailTitle(item);
|
5170 |
|
5171 |
|
5172 | var bg = '';
|
5173 | var bgImg = "background-image: url('" + G.emptyGif + "');";
|
5174 | if( item.imageDominantColors != null ) {
|
5175 |
|
5176 | bgImg = "background-image: url('" + item.imageDominantColors + "');";
|
5177 | }
|
5178 | else {
|
5179 |
|
5180 | if( item.imageDominantColor != null ) {
|
5181 | bg = 'background-color:' + item.imageDominantColor + ';';
|
5182 | }
|
5183 | else {
|
5184 | bgImg = '';
|
5185 | }
|
5186 | }
|
5187 |
|
5188 | var op = 'opacity:1;';
|
5189 | if( G.O.thumbnailWaitImageLoaded == true ) {
|
5190 | op = 'opacity:0;';
|
5191 | }
|
5192 |
|
5193 |
|
5194 | 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" : "" ) + '">';
|
5195 |
|
5196 |
|
5197 |
|
5198 | var w = G.tn.settings.getW();
|
5199 | var h = G.tn.settings.getH();
|
5200 | if( G.tn.settings.getMosaic() !== null ) {
|
5201 |
|
5202 | w = G.GOM.items[GOMidx].width;
|
5203 | h = G.GOM.items[GOMidx].height;
|
5204 | }
|
5205 |
|
5206 | var bgSize = 'contain';
|
5207 | if( G.tn.opt.Get('crop') ) {
|
5208 | bgSize = 'cover';
|
5209 | }
|
5210 |
|
5211 |
|
5212 | 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;";
|
5213 | newElt[newEltIdx++]='<div class="nGY2GThumbnailImage nGY2TnImgBack" style="' + s1 + '"></div>';
|
5214 |
|
5215 |
|
5216 | var s2 = op + "position: absolute; top: 0px; left: 0px; width:" + w + "px; height:" + h + "px; background-image: url('" + src + "'); background-position: center center; background-repeat: no-repeat; background-size:" + bgSize + "; overflow: hidden;";
|
5217 | newElt[newEltIdx++]='<div class="nGY2GThumbnailImage nGY2TnImg" style="' + s2 + '">';
|
5218 | newElt[newEltIdx++]=' <img class="nGY2GThumbnailImg nGY2TnImg2" src="' + src + '" alt="' + sTitle + '" style="opacity:0;" data-idx="' + idx + '" data-albumidx="' + G.GOM.albumIdx + '" >';
|
5219 | newElt[newEltIdx++]='</div>';
|
5220 |
|
5221 |
|
5222 | newElt[newEltIdx++]='<div class="nGY2GThumbnailCustomLayer"></div>';
|
5223 |
|
5224 |
|
5225 | if( G.O.thumbnailLabel.get('display') == true ) {
|
5226 |
|
5227 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailLabel" '+ G.tn.style.getLabel(item) + '>';
|
5228 | if( item.kind == 'album' ) {
|
5229 |
|
5230 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailTitle nGY2GThumbnailAlbumTitle" ' + G.tn.style.getTitle() + '>' + G.O.icons.thumbnailAlbum + sTitle + '</div>';
|
5231 | }
|
5232 | else {
|
5233 |
|
5234 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailTitle nGY2GThumbnailImageTitle" ' + G.tn.style.getTitle() + '>' + G.O.icons.thumbnailImage + sTitle + '</div>';
|
5235 | }
|
5236 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailDescription" ' + G.tn.style.getDesc() + '>' + getTumbnailDescription(item) + '</div>';
|
5237 | newElt[newEltIdx++]= ' </div>';
|
5238 | }
|
5239 |
|
5240 |
|
5241 |
|
5242 | newElt[newEltIdx++] = ThumbnailBuildTools(item);
|
5243 |
|
5244 |
|
5245 | newElt[newEltIdx++]='</div></div>';
|
5246 |
|
5247 | var $newDiv =jQuery(newElt.join('')).appendTo(G.$E.conTn);
|
5248 |
|
5249 | item.$elt=$newDiv;
|
5250 | $newDiv.data('index',GOMidx);
|
5251 | item.$getElt('.nGY2GThumbnailImg').data('index',GOMidx);
|
5252 |
|
5253 |
|
5254 | var fu=G.O.fnThumbnailInit;
|
5255 | if( fu !== null ) {
|
5256 | typeof fu == 'function' ? fu($newDiv, item, GOMidx) : window[fu]($newDiv, item, GOMidx);
|
5257 | }
|
5258 |
|
5259 | if( item.title != 'image gallery by nanogallery2 [build]' ) {
|
5260 | ThumbnailOverInit(GOMidx);
|
5261 | }
|
5262 |
|
5263 | return ;
|
5264 | }
|
5265 |
|
5266 |
|
5267 |
|
5268 | function ThumbnailBuildTools( item ) {
|
5269 |
|
5270 |
|
5271 | var tb = ThumbnailBuildToolbarOne(item, 'topLeft') + ThumbnailBuildToolbarOne(item, 'topRight') + ThumbnailBuildToolbarOne(item, 'bottomLeft') + ThumbnailBuildToolbarOne(item, 'bottomRight');
|
5272 |
|
5273 |
|
5274 | tb += '<div class="nGY2GThumbnailIconsFullThumbnail"></div>';
|
5275 |
|
5276 | return tb;
|
5277 | }
|
5278 |
|
5279 | function ThumbnailBuildToolbarOne( item, position ) {
|
5280 | var toolbar = '';
|
5281 | var tb = G.tn.toolbar.get(item);
|
5282 | var width = { xs:0, sm:1, me:2, la:3, xl:4 };
|
5283 | var cnt = 0;
|
5284 |
|
5285 | if( tb[position] != '' ) {
|
5286 | var pos='top: 0; right: 0; text-align: right;';
|
5287 | switch( position ) {
|
5288 | case 'topLeft':
|
5289 | pos = 'top: 0; left: 0; text-align: left;';
|
5290 | break;
|
5291 | case 'bottomRight':
|
5292 | pos = 'bottom: 0; right: 0; text-align: right;';
|
5293 | break;
|
5294 | case 'bottomLeft':
|
5295 | pos = 'bottom: 0; left: 0; text-align: left;';
|
5296 | break;
|
5297 | }
|
5298 |
|
5299 | toolbar += ' <ul class="nGY2GThumbnailIcons" style="' + pos + '">';
|
5300 |
|
5301 | var icons = tb[position].split(',');
|
5302 | var nb = icons.length;
|
5303 | for( var i = 0; i < nb; i++ ) {
|
5304 | var icon = icons[i].replace(/^\s*|\s*$/, '');
|
5305 |
|
5306 | var minWidth = icon.substring(0,2).toLowerCase();
|
5307 | var tIcon = icon;
|
5308 | var display = true;
|
5309 | if( /xs|sm|me|la|xl/i.test(minWidth) ) {
|
5310 |
|
5311 | if( width[minWidth] > width[G.GOM.curWidth] ) {
|
5312 | display = false;
|
5313 | }
|
5314 | tIcon = icon.substring(2);
|
5315 | }
|
5316 |
|
5317 | if( display ) {
|
5318 | var sp=(i+1<nb ? ' ' :'');
|
5319 | switch( tIcon ) {
|
5320 | case 'COUNTER':
|
5321 | if( item.kind == 'album' ) {
|
5322 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="">';
|
5323 | toolbar += ' <div class="nGY2GThumbnailIconImageCounter"></div>';
|
5324 | toolbar += ' <div class="nGY2GThumbnailIconText">' + G.O.icons.thumbnailCounter+Math.max((item.getContentLength(false)),item.numberItems) + sp + '</div>';
|
5325 | toolbar += ' </li>';
|
5326 | cnt++;
|
5327 | }
|
5328 | break;
|
5329 | case 'COUNTER2':
|
5330 | if( item.kind == 'album' ) {
|
5331 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="">';
|
5332 | toolbar += ' <div class="nGY2GThumbnailIconTextBadge">' + G.O.icons.thumbnailCounter+Math.max((item.getContentLength(false)),item.numberItems) + sp + '</div>';
|
5333 | toolbar += ' </li>';
|
5334 | cnt++;
|
5335 | }
|
5336 | break;
|
5337 | case 'SHARE':
|
5338 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
5339 | toolbar += ' <div>' + G.O.icons.thumbnailShare + '</div>';
|
5340 | toolbar += ' </li>';
|
5341 | cnt++;
|
5342 | break;
|
5343 | case 'DOWNLOAD':
|
5344 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
5345 | toolbar += ' <div>' + G.O.icons.thumbnailDownload + '</div>';
|
5346 | toolbar += ' </li>';
|
5347 | cnt++;
|
5348 | break;
|
5349 | case 'INFO':
|
5350 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
5351 | toolbar += ' <div>' + G.O.icons.thumbnailInfo + '</div>';
|
5352 | toolbar += ' </li>';
|
5353 | cnt++;
|
5354 | break;
|
5355 | case 'SHOPPINGCART':
|
5356 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
5357 |
|
5358 | toolbar += ThumbnailBuildToolbarOneCart( item );
|
5359 |
|
5360 | toolbar += ' </li>';
|
5361 | cnt++;
|
5362 | break;
|
5363 | case 'DISPLAY':
|
5364 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="DISPLAY">';
|
5365 | toolbar += ' <div class="nGY2GThumbnailIconImageShare">' + G.O.icons.thumbnailDisplay + '</div>';
|
5366 | toolbar += ' </li>';
|
5367 | cnt++;
|
5368 | break;
|
5369 | case 'CUSTOM1':
|
5370 | case 'CUSTOM2':
|
5371 | case 'CUSTOM3':
|
5372 | case 'CUSTOM4':
|
5373 | case 'CUSTOM5':
|
5374 | case 'CUSTOM6':
|
5375 | case 'CUSTOM7':
|
5376 | case 'CUSTOM8':
|
5377 | case 'CUSTOM9':
|
5378 | case 'CUSTOM10':
|
5379 | var cust = tIcon.replace('CUSTOM', '');
|
5380 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon.toLowerCase() + '">';
|
5381 | toolbar += ' <div class="nGY2GThumbnailIconImageShare">' + G.O.icons['thumbnailCustomTool' + cust] + '</div>';
|
5382 | toolbar += ' </li>';
|
5383 | cnt++;
|
5384 | break;
|
5385 | case 'FEATURED':
|
5386 | if( item.featured === true ) {
|
5387 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="">';
|
5388 | toolbar += ' <div class="nGY2GThumbnailIconImageFeatured">' + G.O.icons.thumbnailFeatured + '</div>';
|
5389 | toolbar += ' </li>';
|
5390 | cnt++;
|
5391 | }
|
5392 | break;
|
5393 | case 'SELECT':
|
5394 | if( G.O.thumbnailSelectable == true ) {
|
5395 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="TOGGLESELECT">';
|
5396 | if( item.selected === true ) {
|
5397 | toolbar += ' <div class="nGY2GThumbnailIconImageSelect nGY2ThumbnailSelected">' + G.O.icons.thumbnailSelected + '</div>';
|
5398 | }
|
5399 | else {
|
5400 | toolbar += ' <div class="nGY2GThumbnailIconImageSelect nGY2ThumbnailUnselected">' + G.O.icons.thumbnailUnselected + '</div>';
|
5401 | }
|
5402 | toolbar += ' </li>';
|
5403 | cnt++;
|
5404 | }
|
5405 | break;
|
5406 | }
|
5407 | }
|
5408 | }
|
5409 | toolbar += ' </ul>';
|
5410 | }
|
5411 |
|
5412 | if( cnt > 0 ) {
|
5413 | return toolbar;
|
5414 | }
|
5415 | else {
|
5416 | return '';
|
5417 | }
|
5418 | }
|
5419 |
|
5420 |
|
5421 | function ThumbnailBuildToolbarOneCart( item ) {
|
5422 | var q = 0;
|
5423 |
|
5424 | var id = item.GetID()
|
5425 | for( var i=0; i<G.shoppingCart.length; i++ ) {
|
5426 | if( G.I[G.shoppingCart[i].idx].GetID() == id ) {
|
5427 | q = G.shoppingCart[i].qty;
|
5428 | }
|
5429 | }
|
5430 | if( q == 0 ) {
|
5431 | q = '';
|
5432 | }
|
5433 |
|
5434 | return ' <div>' + G.O.icons.thumbnailShoppingcart + q + '</div>';
|
5435 | }
|
5436 | function ThumbnailBuildToolbarOneCartUpdate( item ) {
|
5437 | var $e = item.$elt;
|
5438 |
|
5439 | if( $e != null ) {
|
5440 | var $q = $e.find('*[data-ngy2action="SHOPPINGCART"]');
|
5441 | if( $q !== undefined ) {
|
5442 | $q.html( ThumbnailBuildToolbarOneCart( item ) );
|
5443 | }
|
5444 | }
|
5445 | }
|
5446 |
|
5447 | function getThumbnailTitle( item ) {
|
5448 |
|
5449 | var sTitle = item.title;
|
5450 | if( G.O.thumbnailLabel.get('display') == true ) {
|
5451 | if( sTitle === undefined || sTitle.length == 0 ) { sTitle = ' '; }
|
5452 |
|
5453 | if( G.i18nTranslations.thumbnailImageTitle != '' ) {
|
5454 | sTitle = G.i18nTranslations.thumbnailImageTitle;
|
5455 | }
|
5456 | var ml = G.O.thumbnailLabel.get('titleMaxLength');
|
5457 | if( ml > 3 && sTitle.length > ml ){
|
5458 | sTitle = sTitle.substring(0, ml) + '...';
|
5459 | }
|
5460 | }
|
5461 |
|
5462 | return sTitle;
|
5463 | }
|
5464 |
|
5465 | function getTumbnailDescription( item ) {
|
5466 | var sDesc = '';
|
5467 | if( G.O.thumbnailLabel.get('displayDescription') == true ) {
|
5468 | if( item.kind == 'album' ) {
|
5469 | if( G.i18nTranslations.thumbnailImageDescription != '' ) {
|
5470 | sDesc = G.i18nTranslations.thumbnailAlbumDescription;
|
5471 | }
|
5472 | else {
|
5473 | sDesc = item.description;
|
5474 | }
|
5475 | }
|
5476 | else {
|
5477 | if( G.i18nTranslations.thumbnailImageDescription != '' ) {
|
5478 | sDesc = G.i18nTranslations.thumbnailImageDescription;
|
5479 | }
|
5480 | else {
|
5481 | sDesc = item.description;
|
5482 | }
|
5483 | }
|
5484 | var ml = G.O.thumbnailLabel.get('descriptionMaxLength');
|
5485 | if( ml > 3 && sDesc.length > ml ){
|
5486 | sDesc = sDesc.substring(0, ml) + '...';
|
5487 | }
|
5488 | if( sDesc.length == 0 ) {
|
5489 | sDesc = ' ';
|
5490 | }
|
5491 | }
|
5492 |
|
5493 | return sDesc;
|
5494 | }
|
5495 |
|
5496 |
|
5497 |
|
5498 |
|
5499 | function NbThumbnailsPerRow( areaWidth ) {
|
5500 | var tnW = G.tn.defaultSize.getOuterWidth();
|
5501 |
|
5502 | var nbMaxTn = 0;
|
5503 | if( G.O.thumbnailAlignment == 'justified' ) {
|
5504 | nbMaxTn = Math.floor((areaWidth)/(tnW));
|
5505 | }
|
5506 | else {
|
5507 | nbMaxTn = Math.floor((areaWidth + G.tn.settings.GetResponsive('gutterWidth'))/(tnW + G.tn.settings.GetResponsive('gutterWidth')));
|
5508 | }
|
5509 |
|
5510 | if( G.O.maxItemsPerLine >0 && nbMaxTn > G.O.maxItemsPerLine ) {
|
5511 | nbMaxTn = G.O.maxItemsPerLine;
|
5512 | }
|
5513 |
|
5514 | if( nbMaxTn < 1 ) { nbMaxTn = 1; }
|
5515 |
|
5516 | return nbMaxTn
|
5517 | }
|
5518 |
|
5519 |
|
5520 | function ThumbnailAppear( n, cnt ) {
|
5521 | var curTn = G.GOM.items[n];
|
5522 | var item = G.I[curTn.thumbnailIdx];
|
5523 |
|
5524 |
|
5525 | if( G.tn.opt.Get('displayTransition') == 'NONE' ) {
|
5526 | item.$elt.css({ opacity: 1 });
|
5527 | ThumbnailAppearFinish( item );
|
5528 | }
|
5529 | else {
|
5530 | if( item.$elt == null ) { return; }
|
5531 | var top = G.GOM.cache.containerOffset.top + ( curTn.top - G.GOM.clipArea.top );
|
5532 | var vp = G.GOM.cache.viewport;
|
5533 | if( (top + (curTn.top - G.GOM.clipArea.top)) >= (vp.t - 50) && top <= (vp.t + vp.h + 50) ) {
|
5534 |
|
5535 | var delay = cnt * G.tn.opt.Get('displayInterval');
|
5536 | if( G.tn.opt.Get('displayTransition') == 'CUSTOM' ) {
|
5537 | if( G.GOM.curNavLevel == 'lN' ) {
|
5538 | G.O.fnThumbnailDisplayEffect(item.$elt, item, n, delay);
|
5539 | }
|
5540 | else {
|
5541 | G.O.fnThumbnailL1DisplayEffect(item.$elt, item, n, delay);
|
5542 | }
|
5543 | }
|
5544 | else {
|
5545 | G.GOM.thumbnails2Display.push({itm: item, d: delay});
|
5546 |
|
5547 | }
|
5548 | return;
|
5549 | }
|
5550 | else {
|
5551 | item.$elt.css({ opacity: 1 });
|
5552 | ThumbnailAppearFinish(item);
|
5553 | }
|
5554 | }
|
5555 | }
|
5556 |
|
5557 |
|
5558 |
|
5559 | function ThumbnailAppearFinish( item ) {
|
5560 |
|
5561 |
|
5562 | var ns = G.tn.opt.Get('stacks');
|
5563 | if( ns > 0 ) {
|
5564 |
|
5565 | item.$elt.css({ display: 'block'});
|
5566 | var o = 0.9;
|
5567 |
|
5568 | for( var i = ns-1; i>=0; i-- ) {
|
5569 | item.$elt.eq(i).css('opacity', o);
|
5570 | o = o - 0.2;
|
5571 | }
|
5572 |
|
5573 | }
|
5574 | }
|
5575 |
|
5576 |
|
5577 | function ThumbnailDisplayAnim2( item, delay ) {
|
5578 | function randomIntFromInterval(min,max) {
|
5579 | return Math.floor(Math.random()*(max-min+1)+min);
|
5580 | }
|
5581 | var oFrom = {};
|
5582 | var oTo = {};
|
5583 |
|
5584 | switch (G.tn.opt.Get('displayTransition')) {
|
5585 | case 'RANDOMSCALE': {
|
5586 | var scales = [0.95, 1, 1.05, 1.1];
|
5587 | var zi = [1, 2, 3, 4];
|
5588 |
|
5589 | var r = randomIntFromInterval(0,3);
|
5590 | while( r == G.GOM.lastRandomValue ) {
|
5591 | r = randomIntFromInterval(0,3);
|
5592 | }
|
5593 | G.GOM.lastRandomValue = r;
|
5594 | let f = scales[r];
|
5595 |
|
5596 | item.$elt.css({ 'z-index': G.GOM.lastZIndex+zi[r], 'box-shadow': '0px 0px 5px 3px rgba(0,0,0,0.74)' });
|
5597 |
|
5598 | oFrom = { scale: 0.5, opacity:0 };
|
5599 | oTo = { scale: f, opacity:1 };
|
5600 | break;
|
5601 | }
|
5602 |
|
5603 | case 'SCALEUP': {
|
5604 | let f = G.tn.opt.Get('displayTransitionStartVal');
|
5605 | if( f == 0 ) { f = 0.6; }
|
5606 | oFrom = { scale: f, opacity: 0 };
|
5607 | oTo = { scale: 1, opacity: 1 };
|
5608 | break;
|
5609 | }
|
5610 |
|
5611 | case 'SCALEDOWN': {
|
5612 | let f = G.tn.opt.Get('displayTransitionStartVal');
|
5613 | if( f == 0 ) { f=1.3; }
|
5614 | oFrom = { scale: f, opacity: 0 };
|
5615 | oTo = { scale: 1, opacity: 1 };
|
5616 | break;
|
5617 | }
|
5618 | case 'SLIDEUP': {
|
5619 | let f = G.tn.opt.Get('displayTransitionStartVal');
|
5620 | if( f == 0 ) { f=50; }
|
5621 | oFrom = { opacity: 0, translateY: f };
|
5622 | oTo = { opacity: 1, translateY: 0 };
|
5623 | break;
|
5624 | }
|
5625 | case 'SLIDEDOWN': {
|
5626 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5627 | if( f == 0 ) { f=-50; }
|
5628 | oFrom = { opacity: 0, translateY: f };
|
5629 | oTo = { opacity: 1, translateY: 0 };
|
5630 | break;
|
5631 | }
|
5632 | case 'FLIPUP': {
|
5633 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5634 | if( f == 0 ) { f=100; }
|
5635 | oFrom = { opacity: 0, translateY: f, rotateX: 45 };
|
5636 | oTo = { opacity: 1, translateY: 0, rotateX: 0 };
|
5637 | break;
|
5638 | }
|
5639 | case 'FLIPDOWN': {
|
5640 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5641 | if( f == 0 ) { f=-100; }
|
5642 | oFrom = { opacity: 0, translateY: f, rotateX: -45 };
|
5643 | oTo = { opacity: 1, translateY: 0, rotateX: 0 };
|
5644 | break;
|
5645 | }
|
5646 | case 'SLIDEUP2': {
|
5647 | let f = G.tn.opt.Get('displayTransitionStartVal');
|
5648 | if( f == 0 ) { f=100; }
|
5649 | oFrom = { opacity: 0, translateY: f, rotateY: 40 };
|
5650 | oTo = { opacity: 1, translateY: 0, rotateY: 0 };
|
5651 | break;
|
5652 | }
|
5653 | case 'IMAGESLIDEUP': {
|
5654 |
|
5655 |
|
5656 | oFrom = { opacity: 0, top: '100%' };
|
5657 | oTo = { opacity: 1, top: '0%' };
|
5658 | break;
|
5659 | }
|
5660 | case 'SLIDEDOWN2': {
|
5661 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5662 | if( f == 0 ) { f=-100; }
|
5663 | oFrom = { opacity: 0, translateY: f, rotateY: 40 };
|
5664 | oTo = { opacity: 1, translateY: 0, rotateY: 0 };
|
5665 | break;
|
5666 | }
|
5667 | case 'SLIDERIGHT': {
|
5668 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5669 | if( f == 0 ) { f=-150; }
|
5670 | oFrom = { opacity: 0, translateX: f };
|
5671 | oTo = { opacity: 1, translateX: 0 };
|
5672 | break;
|
5673 | }
|
5674 | case 'SLIDELEFT': {
|
5675 | let f=G.tn.opt.Get('displayTransitionStartVal');
|
5676 | if( f == 0 ) { f=150; }
|
5677 | oFrom = { opacity: 0, translateX: f };
|
5678 | oTo = { opacity: 1, translateX: 0 };
|
5679 | break;
|
5680 | }
|
5681 | case 'FADEIN':
|
5682 | oFrom = { opacity: 0 };
|
5683 | oTo = { opacity: 1 };
|
5684 | break;
|
5685 |
|
5686 |
|
5687 | }
|
5688 |
|
5689 | var tweenable = new NGTweenable();
|
5690 | tweenable.tween({
|
5691 | from: oFrom,
|
5692 | to: oTo,
|
5693 | attachment: { $e:item.$elt, item: item, tw: tweenable },
|
5694 | delay: delay,
|
5695 | duration: G.tn.opt.Get('displayTransitionDuration'),
|
5696 | easing: G.tn.opt.Get('displayTransitionEasing'),
|
5697 | step: function (state, att) {
|
5698 | window.requestAnimationFrame( function() {
|
5699 | if( att.item.$elt === null ) {
|
5700 | att.tw.stop(false);
|
5701 | return;
|
5702 | }
|
5703 | switch (G.tn.opt.Get('displayTransition')) {
|
5704 | case 'RANDOMSCALE':
|
5705 | att.$e.css( G.CSStransformName , 'scale(' + state.scale + ')').css('opacity', state.opacity);
|
5706 | break;
|
5707 | case 'SCALEUP':
|
5708 | att.$e.css( G.CSStransformName , 'scale('+state.scale+')').css('opacity',state.opacity);
|
5709 | break;
|
5710 | case 'SCALEDOWN':
|
5711 | att.item.$elt.last().css('opacity', state.opacity);
|
5712 | att.item.CSSTransformSet('.nGY2GThumbnail', 'scale', state.scale);
|
5713 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5714 | break;
|
5715 | case 'SLIDEUP':
|
5716 | att.item.$elt.css('opacity', state.opacity);
|
5717 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px, '+state.translateY + 'px');
|
5718 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5719 | break;
|
5720 | case 'SLIDEDOWN':
|
5721 | att.item.$elt.css('opacity', state.opacity);
|
5722 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,'+state.translateY+'px');
|
5723 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5724 | break;
|
5725 | case 'FLIPUP':
|
5726 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,'+state.translateY+'px');
|
5727 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateX', state.rotateX+'deg');
|
5728 | att.item.$elt.css('opacity', state.opacity);
|
5729 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5730 | break;
|
5731 | case 'FLIPDOWN':
|
5732 | att.item.$elt.css('opacity', state.opacity);
|
5733 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,' + state.translateY + 'px');
|
5734 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateX', state.rotateX + 'deg');
|
5735 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5736 | break;
|
5737 | case 'SLIDEUP2':
|
5738 | att.item.$elt.css('opacity', state.opacity);
|
5739 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,' + state.translateY + 'px');
|
5740 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateY', state.rotateY + 'deg');
|
5741 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5742 | break;
|
5743 | case 'IMAGESLIDEUP':
|
5744 | att.item.$elt.css('opacity', state.opacity);
|
5745 | att.item.$Elts['.nGY2GThumbnailImage'].css('top', state.top);
|
5746 | break;
|
5747 | case 'SLIDEDOWN2':
|
5748 | att.item.$elt.css('opacity', state.opacity);
|
5749 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px, ' + state.translateY + 'px');
|
5750 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateY', state.rotateY + 'deg');
|
5751 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5752 | break;
|
5753 | case 'SLIDERIGHT':
|
5754 | att.item.$elt.css('opacity', state.opacity);
|
5755 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', state.translateX + 'px, 0px');
|
5756 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5757 | break;
|
5758 | case 'SLIDELEFT':
|
5759 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', state.translateX + 'px, 0px');
|
5760 | att.item.$elt.css('opacity', state.opacity);
|
5761 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5762 | break;
|
5763 | case 'FADEIN':
|
5764 | att.$e.css(state);
|
5765 | break;
|
5766 | }
|
5767 | });
|
5768 |
|
5769 | },
|
5770 | finish: function (state, att) {
|
5771 | window.requestAnimationFrame( function() {
|
5772 | if( att.item.$elt === null ) { return; }
|
5773 |
|
5774 | switch (G.tn.opt.Get('displayTransition')) {
|
5775 | case 'RANDOMSCALE':
|
5776 | att.$e.css( G.CSStransformName , 'scale('+state.scale+')').css('opacity', '');
|
5777 | break;
|
5778 | case 'SCALEUP':
|
5779 | att.$e.css( G.CSStransformName , '').css('opacity', '');
|
5780 | break;
|
5781 | case 'SCALEDOWN':
|
5782 | att.item.$elt.last().css('opacity', '');
|
5783 | att.item.CSSTransformSet('.nGY2GThumbnail', 'scale', state.scale);
|
5784 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5785 | break;
|
5786 | case 'IMAGESLIDEUP':
|
5787 | att.item.$elt.css('opacity', '');
|
5788 | att.item.$Elts['.nGY2GThumbnailImage'].css('top', 0);
|
5789 | break;
|
5790 | case 'SLIDEDOWN2':
|
5791 | att.item.$elt.css('opacity', '');
|
5792 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5793 | break;
|
5794 | default :
|
5795 |
|
5796 |
|
5797 |
|
5798 |
|
5799 |
|
5800 |
|
5801 |
|
5802 |
|
5803 | att.item.$elt.css('opacity', '');
|
5804 | }
|
5805 | ThumbnailAppearFinish(att.item);
|
5806 | });
|
5807 |
|
5808 | }
|
5809 | });
|
5810 |
|
5811 | }
|
5812 |
|
5813 |
|
5814 | function ThumbnailDisplayAnimBatch() {
|
5815 |
|
5816 | G.GOM.thumbnails2Display.forEach( function(one) {
|
5817 | ThumbnailDisplayAnim2(one.itm, one.d);
|
5818 | });
|
5819 | G.GOM.thumbnails2Display=[];
|
5820 | }
|
5821 |
|
5822 |
|
5823 |
|
5824 |
|
5825 |
|
5826 | function GalleryAppear() {
|
5827 |
|
5828 | var d=G.galleryDisplayTransitionDuration.Get();
|
5829 | switch( G.galleryDisplayTransition.Get() ){
|
5830 | case 'ROTATEX':
|
5831 | G.$E.base.css({ perspective: '1000px', 'perspective-origin': '50% 0%' });
|
5832 | new NGTweenable().tween({
|
5833 | from: { r: 50 },
|
5834 | to: { r: 0 },
|
5835 | attachment: { orgIdx: G.GOM.albumIdx },
|
5836 | duration: d,
|
5837 | easing: 'easeOutCirc',
|
5838 | step: function (state, att) {
|
5839 | if( att.orgIdx == G.GOM.albumIdx ) {
|
5840 |
|
5841 | G.$E.conTnParent.css( G.CSStransformName , 'rotateX(' + state.r + 'deg)');
|
5842 |
|
5843 | }
|
5844 | }
|
5845 | });
|
5846 | break;
|
5847 | case 'SLIDEUP':
|
5848 | G.$E.conTnParent.css({ opacity: 0 });
|
5849 | new NGTweenable().tween({
|
5850 | from: { y: 200, o: 0 },
|
5851 | to: { y: 0, o: 1 },
|
5852 | attachment: { orgIdx: G.GOM.albumIdx },
|
5853 | duration: d,
|
5854 | easing: 'easeOutCirc',
|
5855 | step: function (state, att) {
|
5856 | if( att.orgIdx == G.GOM.albumIdx ) {
|
5857 |
|
5858 | G.$E.conTnParent.css( G.CSStransformName , 'translate( 0px, '+state.y + 'px)').css('opacity', state.o);
|
5859 |
|
5860 | }
|
5861 | }
|
5862 | });
|
5863 | break;
|
5864 | case 'NONE':
|
5865 | default:
|
5866 | break;
|
5867 | }
|
5868 |
|
5869 |
|
5870 | }
|
5871 |
|
5872 |
|
5873 |
|
5874 |
|
5875 |
|
5876 | function ThumbnailOverInit( GOMidx ) {
|
5877 |
|
5878 |
|
5879 |
|
5880 |
|
5881 |
|
5882 | var curTn = G.GOM.items[GOMidx];
|
5883 | var item = G.I[curTn.thumbnailIdx];
|
5884 |
|
5885 | if( item.$elt == null ) { return; }
|
5886 |
|
5887 | var fu = G.O.fnThumbnailHoverInit;
|
5888 | if( fu !== null ) {
|
5889 | typeof fu == 'function' ? fu($e, item, GOMidx) : window[fu]($e, item, GOMidx);
|
5890 | }
|
5891 |
|
5892 |
|
5893 | var inits = G.tn.buildInit.get();
|
5894 | for( var j = 0; j < inits.length; j++) {
|
5895 | switch( inits[j].property ) {
|
5896 |
|
5897 | case 'scale':
|
5898 | case 'rotateX':
|
5899 | case 'rotateY':
|
5900 | case 'rotateZ':
|
5901 | case 'translateX':
|
5902 | case 'translateY':
|
5903 | case 'translateZ':
|
5904 | item.CSSTransformSet(inits[j].element, inits[j].property, inits[j].value);
|
5905 | item.CSSTransformApply(inits[j].element);
|
5906 | break;
|
5907 |
|
5908 | case 'blur':
|
5909 | case 'brightness':
|
5910 | case 'grayscale':
|
5911 | case 'sepia':
|
5912 | case 'contrast':
|
5913 | case 'opacity':
|
5914 | case 'saturate':
|
5915 | item.CSSFilterSet(inits[j].element, inits[j].property, inits[j].value);
|
5916 | item.CSSFilterApply(inits[j].element);
|
5917 | break;
|
5918 | default:
|
5919 | var $t=item.$getElt(inits[j].element);
|
5920 | $t.css( inits[j].property, inits[j].value );
|
5921 | break;
|
5922 | }
|
5923 | }
|
5924 |
|
5925 |
|
5926 | var effects = G.tn.hoverEffects.get();
|
5927 | for( var j = 0; j < effects.length; j++) {
|
5928 | if( effects[j].firstKeyframe === true ) {
|
5929 | switch( effects[j].type ) {
|
5930 | case 'scale':
|
5931 | case 'rotateX':
|
5932 | case 'rotateY':
|
5933 | case 'rotateZ':
|
5934 | case 'translateX':
|
5935 | case 'translateY':
|
5936 | case 'translateZ':
|
5937 | item.CSSTransformSet(effects[j].element, effects[j].type, effects[j].from);
|
5938 | item.CSSTransformApply(effects[j].element);
|
5939 | break;
|
5940 | case 'blur':
|
5941 | case 'brightness':
|
5942 | case 'grayscale':
|
5943 | case 'sepia':
|
5944 | case 'contrast':
|
5945 | case 'opacity':
|
5946 | case 'saturate':
|
5947 | item.CSSFilterSet(effects[j].element, effects[j].type, effects[j].from);
|
5948 | item.CSSFilterApply(effects[j].element);
|
5949 | break;
|
5950 | default:
|
5951 | var $t = item.$getElt(effects[j].element);
|
5952 | $t.css( effects[j].type, effects[j].from );
|
5953 | break;
|
5954 |
|
5955 | }
|
5956 | }
|
5957 | }
|
5958 | item.hoverInitDone=true;
|
5959 | }
|
5960 |
|
5961 | function ThumbnailHoverReInitAll() {
|
5962 | if( G.GOM.albumIdx == -1 ) { return; };
|
5963 | var l = G.GOM.items.length;
|
5964 | for( var i = 0; i < l ; i++ ) {
|
5965 | ThumbnailOverInit(i);
|
5966 |
|
5967 | G.I[G.GOM.items[i].thumbnailIdx].hovered = false;
|
5968 | }
|
5969 | }
|
5970 |
|
5971 |
|
5972 | function ThumbnailHover( GOMidx ) {
|
5973 | if( G.GOM.albumIdx == -1 || !G.galleryResizeEventEnabled ) { return; };
|
5974 | if( G.GOM.slider.hostIdx == GOMidx ) {
|
5975 |
|
5976 | return;
|
5977 | }
|
5978 | var curTn = G.GOM.items[GOMidx];
|
5979 | var item = G.I[curTn.thumbnailIdx];
|
5980 | if( item.kind == 'albumUp' || item.$elt == null ) { return; }
|
5981 |
|
5982 | item.hovered = true;
|
5983 |
|
5984 | var fu = G.O.fnThumbnailHover;
|
5985 | if( fu !== null ) {
|
5986 | typeof fu == 'function' ? fu(item.$elt, item, GOMidx) : window[fu](item.$elt, item, GOMidx);
|
5987 | }
|
5988 | var effects = G.tn.hoverEffects.get();
|
5989 |
|
5990 | try {
|
5991 | for( var j = 0; j < effects.length; j++) {
|
5992 | if( effects[j].hoverin === true ) {
|
5993 |
|
5994 | item.animate( effects[j], 0, true );
|
5995 | }
|
5996 | }
|
5997 |
|
5998 |
|
5999 | }
|
6000 | catch (e) {
|
6001 | NanoAlert(G, 'error on hover: ' + e.message );
|
6002 | }
|
6003 |
|
6004 | }
|
6005 |
|
6006 | function ThumbnailHoverOutAll() {
|
6007 | if( G.GOM.albumIdx == -1 ) { return; };
|
6008 | var l = G.GOM.items.length;
|
6009 | for( var i = 0; i < l ; i++ ) {
|
6010 | if( G.GOM.items[i].inDisplayArea ) {
|
6011 | ThumbnailHoverOut(i);
|
6012 | }
|
6013 | else {
|
6014 | G.I[G.GOM.items[i].thumbnailIdx].hovered = false;
|
6015 | }
|
6016 | }
|
6017 | }
|
6018 |
|
6019 |
|
6020 | function ThumbnailHoverOut( GOMidx ) {
|
6021 | if( G.GOM.albumIdx == -1 || !G.galleryResizeEventEnabled ) { return; }
|
6022 |
|
6023 | if( G.GOM.slider.hostIdx == GOMidx ) {
|
6024 |
|
6025 | return;
|
6026 | }
|
6027 |
|
6028 | var curTn = G.GOM.items[GOMidx];
|
6029 | var item = G.I[curTn.thumbnailIdx];
|
6030 | if( item.kind == 'albumUp' || !item.hovered ) { return; }
|
6031 | item.hovered = false;
|
6032 | if( item.$elt == null ) { return; }
|
6033 |
|
6034 | var fu = G.O.fnThumbnailHoverOut;
|
6035 | if( fu !== null ) {
|
6036 | typeof fu == 'function' ? fu(item.$elt, item, GOMidx) : window[fu](item.$elt, item, GOMidx);
|
6037 | }
|
6038 |
|
6039 | var effects = G.tn.hoverEffects.get();
|
6040 | try {
|
6041 | for( var j = 0; j < effects.length; j++) {
|
6042 | if( effects[j].hoverout === true ) {
|
6043 |
|
6044 | item.animate( effects[j], 0, false );
|
6045 | }
|
6046 | }
|
6047 |
|
6048 |
|
6049 | }
|
6050 | catch (e) {
|
6051 | NanoAlert(G, 'error on hoverOut: ' + e.message );
|
6052 | }
|
6053 |
|
6054 | }
|
6055 |
|
6056 |
|
6057 |
|
6058 | function DisplayPhoto( imageID, albumID ) {
|
6059 |
|
6060 | if( G.O.debugMode ) { console.log('#DisplayPhoto : '+ albumID +'-'+ imageID); }
|
6061 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
6062 | if( albumIdx == 0 ) {
|
6063 | G.GOM.curNavLevel = 'l1';
|
6064 | }
|
6065 | else {
|
6066 | G.GOM.curNavLevel = 'lN';
|
6067 | }
|
6068 |
|
6069 | if( albumIdx == -1 ) {
|
6070 |
|
6071 | if( G.O.kind != '' ) {
|
6072 |
|
6073 | NGY2Item.New( G, '', '', albumID, '0', 'album' );
|
6074 |
|
6075 | }
|
6076 | }
|
6077 |
|
6078 | var ngy2ItemIdx = NGY2Item.GetIdx(G, imageID);
|
6079 | if( ngy2ItemIdx == -1 ) {
|
6080 |
|
6081 | AlbumGetContent( albumID, DisplayPhoto, imageID, albumID );
|
6082 | return;
|
6083 | }
|
6084 |
|
6085 | if( G.O.debugMode ) { console.log('#DisplayPhoto : '+ ngy2ItemIdx); }
|
6086 |
|
6087 | DisplayPhotoIdx(ngy2ItemIdx);
|
6088 |
|
6089 | }
|
6090 |
|
6091 |
|
6092 | function AlbumGetContent( albumID, fnToCall, fnParam1, fnParam2 ) {
|
6093 |
|
6094 |
|
6095 |
|
6096 |
|
6097 |
|
6098 | switch( G.O.kind ) {
|
6099 |
|
6100 | case '':
|
6101 | AlbumGetMarkupOrApi(fnToCall, fnParam1, fnParam2);
|
6102 | break;
|
6103 |
|
6104 | default:
|
6105 | jQuery.nanogallery2['data_'+G.O.kind](G, 'AlbumGetContent', albumID, fnToCall, fnParam1, fnParam2 );
|
6106 | }
|
6107 |
|
6108 | }
|
6109 |
|
6110 | var mediaList = {
|
6111 | youtube : {
|
6112 | getID: function( url ) {
|
6113 |
|
6114 | var s = url.match( /(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/ );
|
6115 | return s != null ? s[1] : null;
|
6116 | },
|
6117 | thumbUrl: function( id ) {
|
6118 | return 'https://img.youtube.com/vi/' + id + '/hqdefault.jpg';
|
6119 | },
|
6120 | url: function( id ) {
|
6121 | return 'https://www.youtube.com/embed/' + id;
|
6122 | },
|
6123 | markup: function( id ) {
|
6124 |
|
6125 | return '<iframe class="nGY2ViewerMedia" src="https://www.youtube.com/embed/' + id + '?rel=0" frameborder="0" allow="autoplay" allowfullscreen></iframe>';
|
6126 | },
|
6127 | kind: 'iframe'
|
6128 | },
|
6129 | vimeo : {
|
6130 | getID: function( url ) {
|
6131 |
|
6132 |
|
6133 | var s = url.match( /(http|https)?:\/\/(www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|)(\d+)(?:|\/\?)/ );
|
6134 | return s != null ? s[4] : null;
|
6135 | },
|
6136 | url: function( id ) {
|
6137 | return 'https://player.vimeo.com/video/' + id;
|
6138 | },
|
6139 | markup: function( id ) {
|
6140 |
|
6141 |
|
6142 | return '<iframe class="nGY2ViewerMedia" src="https://player.vimeo.com/video/' + id + '" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>';
|
6143 | },
|
6144 | kind: 'iframe'
|
6145 | },
|
6146 | dailymotion : {
|
6147 | getID: function( url ) {
|
6148 |
|
6149 | var m = url.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);
|
6150 | if (m !== null) {
|
6151 | if(m[4] !== undefined) {
|
6152 | return m[4];
|
6153 | }
|
6154 | return m[2];
|
6155 | }
|
6156 | return null;
|
6157 | },
|
6158 | thumbUrl: function( id ) {
|
6159 | return 'https://www.dailymotion.com/thumbnail/video/' + id;
|
6160 | },
|
6161 | url: function( id ) {
|
6162 | return 'https://www.dailymotion.com/embed/video/' + id;
|
6163 | },
|
6164 | markup: function( id ) {
|
6165 |
|
6166 | return '<iframe class="nGY2ViewerMedia" src="https://www.dailymotion.com/embed/video/' + id + '?rel=0" frameborder="0" allow="autoplay" allowfullscreen></iframe>';
|
6167 | },
|
6168 | kind: 'iframe'
|
6169 | },
|
6170 | selfhosted : {
|
6171 |
|
6172 | getID: function( url ) {
|
6173 |
|
6174 |
|
6175 |
|
6176 | var extension = url.split('.').pop();
|
6177 |
|
6178 |
|
6179 | var s = ( extension === 'mp4' || extension === 'webm' || extension === 'ogv' || extension === '3gp' ) ? extension : null ;
|
6180 | return s;
|
6181 | },
|
6182 | markup: function( url ) {
|
6183 |
|
6184 | var extension = url.split('.').pop();
|
6185 | return '<video controls class="nGY2ViewerMedia"><source src="'+ url +'" type="video/'+ extension +'" preload="auto">Your browser does not support the video tag (HTML 5).</video>';
|
6186 | },
|
6187 | kind: 'video',
|
6188 | selfhosted : true
|
6189 | }
|
6190 | };
|
6191 |
|
6192 | function AlbumGetMarkupOrApi ( fnToCall, fnParam1, fnParam2 ) {
|
6193 |
|
6194 | if( G.markupOrApiProcessed === true ) {
|
6195 |
|
6196 | DisplayAlbum('-1', 0);
|
6197 | return;
|
6198 | }
|
6199 |
|
6200 | if( G.O.items !== undefined && G.O.items !== null ) {
|
6201 |
|
6202 | GetContentApiObject();
|
6203 | }
|
6204 | else {
|
6205 | if( G.O.$markup.length > 0 ) {
|
6206 |
|
6207 | GetContentMarkup( G.O.$markup );
|
6208 | G.O.$markup=[] ;
|
6209 | }
|
6210 | else {
|
6211 | NanoConsoleLog(G, 'error: no media to process.');
|
6212 | return;
|
6213 | }
|
6214 | }
|
6215 |
|
6216 | G.markupOrApiProcessed = true;
|
6217 | if( fnToCall !== null && fnToCall !== undefined) {
|
6218 | fnToCall( fnParam1, fnParam2, null );
|
6219 | }
|
6220 | }
|
6221 |
|
6222 | function StartsWithProtocol ( path ) {
|
6223 | if( path == undefined ) { return false; }
|
6224 |
|
6225 |
|
6226 | var pattern = /^((http|https|ftp|ftps|file):\/\/)/;
|
6227 | if( !pattern.test(path) ) {
|
6228 |
|
6229 | return false;
|
6230 | }
|
6231 | return true;
|
6232 | }
|
6233 |
|
6234 | function GetContentApiObject() {
|
6235 | var foundAlbumID=false;
|
6236 | var nbTitles = 0;
|
6237 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
6238 |
|
6239 | G.I[0].contentIsLoaded = true;
|
6240 |
|
6241 | jQuery.each(G.O.items, function(i,item){
|
6242 |
|
6243 | var title = '';
|
6244 | title = GetI18nItem(item, 'title');
|
6245 | if( title === undefined ) { title=''; }
|
6246 |
|
6247 | var src='';
|
6248 | if( item['src'+RetrieveCurWidth().toUpperCase()] !== undefined ) {
|
6249 | src = item['src'+RetrieveCurWidth().toUpperCase()];
|
6250 | }
|
6251 | else {
|
6252 | src = item.src;
|
6253 | }
|
6254 | if( !StartsWithProtocol(src) ) {
|
6255 | src = G.O.itemsBaseURL + src;
|
6256 | }
|
6257 |
|
6258 | var thumbsrc = '';
|
6259 | if( item.srct !== undefined && item.srct.length > 0 ) {
|
6260 | thumbsrc = item.srct;
|
6261 | if( !StartsWithProtocol(thumbsrc) ) {
|
6262 | thumbsrc = G.O.itemsBaseURL + thumbsrc;
|
6263 | }
|
6264 | }
|
6265 | else {
|
6266 | thumbsrc = src;
|
6267 | }
|
6268 |
|
6269 | if( G.O.thumbnailLabel.get('title') != '' ) {
|
6270 | title = GetImageTitle(src);
|
6271 | }
|
6272 |
|
6273 | var description='';
|
6274 | description=GetI18nItem(item,'description');
|
6275 | if( description === undefined ) { description=''; }
|
6276 |
|
6277 |
|
6278 |
|
6279 |
|
6280 | var tags = GetI18nItem(item, 'tags');
|
6281 | if( tags === undefined ) { tags=''; }
|
6282 |
|
6283 | var albumID = 0;
|
6284 | if( item.albumID !== undefined ) {
|
6285 | albumID=item.albumID;
|
6286 | foundAlbumID = true;
|
6287 | }
|
6288 | var ID = null;
|
6289 | if( item.ID !== undefined ) {
|
6290 | ID = item.ID;
|
6291 | }
|
6292 | var kind = 'image';
|
6293 | if( item.kind !== undefined && item.kind.length > 0 ) {
|
6294 | kind = item.kind;
|
6295 | }
|
6296 |
|
6297 | var newItem=NGY2Item.New( G, title, description, ID, albumID, kind, tags );
|
6298 | if( title != '' ) {
|
6299 | nbTitles++;
|
6300 | }
|
6301 |
|
6302 |
|
6303 | newItem.setMediaURL( src, 'img');
|
6304 | debugger;
|
6305 |
|
6306 | jQuery.each(mediaList, function ( n, media ) {
|
6307 | var id = media.getID(src);
|
6308 | if( id != null ) {
|
6309 | if( typeof media.url == 'function' ) { src = media.url(id); }
|
6310 | if( typeof media.thumbUrl == 'function' ) { thumbsrc = media.thumbUrl(id); }
|
6311 | newItem.mediaKind = media.kind;
|
6312 | newItem.mediaMarkup = ( media.selfhosted ) ? media.markup( src ) : media.markup(id);
|
6313 | return false;
|
6314 | }
|
6315 | });
|
6316 |
|
6317 |
|
6318 | if( item.imageWidth !== undefined ) { newItem.imageWidth = item.width; }
|
6319 | if( item.imageHeight !== undefined ) { newItem.imageHeight = item.height; }
|
6320 |
|
6321 |
|
6322 |
|
6323 |
|
6324 | var tw = item.imgtWidth !== undefined ? item.imgtWidth : 0;
|
6325 | var th = item.imgtHeight !== undefined ? item.imgtHeight : 0;
|
6326 |
|
6327 |
|
6328 | newItem.thumbs = {
|
6329 | url: { l1 : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc }, lN : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc } },
|
6330 | width: { l1 : { xs: tw, sm: tw, me: tw, la: tw, xl: tw }, lN : { xs: tw, sm: tw, me: tw, la: tw, xl: tw } },
|
6331 | height: { l1 : { xs: th, sm: th, me: th, la: th, xl: th }, lN : { xs: th, sm: th, me: th, la: th, xl: th } }
|
6332 | };
|
6333 |
|
6334 |
|
6335 | if( newItem.mediaKind == 'img' ) {
|
6336 |
|
6337 |
|
6338 | var lst=['xs', 'sm', 'me', 'la', 'xl'];
|
6339 | for( var i=0; i< lst.length; i++ ) {
|
6340 |
|
6341 | var turl = item['srct' + lst[i].toUpperCase()];
|
6342 | if( turl !== undefined ) {
|
6343 | if( !StartsWithProtocol(turl) ) {
|
6344 | turl = G.O.itemsBaseURL + turl;
|
6345 | }
|
6346 | newItem.url.l1[lst[i]] = turl;
|
6347 | newItem.url.lN[lst[i]] = turl;
|
6348 | }
|
6349 |
|
6350 | var tw = item['imgt' + lst[i].toUpperCase() + 'Width'];
|
6351 | if( tw != undefined ) {
|
6352 | newItem.width.l1[lst[i]] = parseInt(tw);
|
6353 | newItem.width.lN[lst[i]] = parseInt(tw);
|
6354 | }
|
6355 |
|
6356 | var th = item['imgt' + lst[i].toUpperCase() + 'Height'];
|
6357 | if( th != undefined ) {
|
6358 | newItem.height.l1[lst[i]] = parseInt(th);
|
6359 | newItem.height.lN[lst[i]] = parseInt(th);
|
6360 | }
|
6361 | }
|
6362 | }
|
6363 |
|
6364 |
|
6365 | if( item.imageDominantColors !== undefined ) {
|
6366 | newItem.imageDominantColors = item.imageDominantColors;
|
6367 | }
|
6368 |
|
6369 | if( item.imageDominantColor !== undefined ) {
|
6370 | newItem.imageDominantColor = item.imageDominantColor;
|
6371 | }
|
6372 |
|
6373 |
|
6374 | if( item.destURL !== undefined && item.destURL.length>0 ) {
|
6375 | newItem.destinationURL = item.destURL;
|
6376 | }
|
6377 |
|
6378 |
|
6379 | if( item.downloadURL !== undefined && item.downloadURL.length>0 ) {
|
6380 | newItem.downloadURL = item.downloadURL;
|
6381 | }
|
6382 |
|
6383 |
|
6384 |
|
6385 | if( item.exifModel !== undefined ) { newItem.exif.model = item.exifModel; }
|
6386 |
|
6387 | if( item.exifFlash !== undefined ) { newItem.exif.flash = item.exifFlash; }
|
6388 |
|
6389 | if( item.exifFocalLength !== undefined ) { newItem.exif.focallength = item.exifFocalLength; }
|
6390 |
|
6391 | if( item.exifFStop !== undefined ) { newItem.exif.fstop = item.exifFStop; }
|
6392 |
|
6393 | if( item.exifExposure !== undefined ) { newItem.exif.exposure = item.exifExposure; }
|
6394 |
|
6395 | if( item.exifIso !== undefined ) { newItem.exif.iso = item.exifIso; }
|
6396 |
|
6397 | if( item.exifTime !== undefined ) { newItem.exif.time = item.exifTime; }
|
6398 |
|
6399 | if( item.exifLocation !== undefined ) { newItem.exif.location = item.exifLocation; }
|
6400 |
|
6401 |
|
6402 |
|
6403 | if( item.customData !== null ) {
|
6404 | newItem.customData = cloneJSObject( item.customData );
|
6405 | }
|
6406 |
|
6407 | newItem.contentIsLoaded = true;
|
6408 |
|
6409 | var fu = G.O.fnProcessData;
|
6410 | if( fu !== null ) {
|
6411 | typeof fu == 'function' ? fu(newItem, 'api', item) : window[fu](newItem, 'api', item);
|
6412 | }
|
6413 |
|
6414 | AlbumPostProcess(albumID);
|
6415 | });
|
6416 |
|
6417 |
|
6418 | if( nbTitles == 0 ) { G.O.thumbnailLabel.display=false; }
|
6419 |
|
6420 | }
|
6421 |
|
6422 |
|
6423 |
|
6424 |
|
6425 | function ElementGetText( element ) {
|
6426 |
|
6427 | var text = '';
|
6428 | if( element.childNodes[0] !== undefined ) {
|
6429 | if( element.childNodes[0].nodeValue !== null && element.childNodes[0].nodeValue !== undefined ) {
|
6430 | text = element.childNodes[0].nodeValue.trim();
|
6431 | }
|
6432 | }
|
6433 | return text;
|
6434 | }
|
6435 |
|
6436 |
|
6437 | function GetContentMarkup( $elements, group ) {
|
6438 | var foundAlbumID = false;
|
6439 | var nbTitles = 0;
|
6440 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
6441 | var GetImageTitleFromURL = NGY2Tools.GetImageTitleFromURL.bind(G);
|
6442 |
|
6443 | G.I[0].contentIsLoaded = true;
|
6444 |
|
6445 | jQuery.each($elements, function(i, item){
|
6446 |
|
6447 |
|
6448 | if( item.dataset.nanogallery2Lgroup != group ) { return; }
|
6449 |
|
6450 |
|
6451 | if( item.nodeName == 'SCRIPT' ) { return; }
|
6452 |
|
6453 |
|
6454 | var data = {
|
6455 |
|
6456 | 'data-ngdesc': '',
|
6457 | 'data-ngid': null,
|
6458 | 'data-ngkind': 'image',
|
6459 | 'data-ngtags': null,
|
6460 | 'data-ngdest': '',
|
6461 | 'data-ngthumbimgwidth': 0,
|
6462 | 'data-ngthumbimgheight': 0,
|
6463 | 'data-ngimagewidth': 0,
|
6464 | 'data-ngimageheight': 0,
|
6465 | 'data-ngimagedominantcolors': null,
|
6466 | 'data-ngimagedominantcolor': null,
|
6467 | 'data-ngexifmodel': '',
|
6468 | 'data-ngexifflash': '',
|
6469 | 'data-ngexiffocallength': '',
|
6470 | 'data-ngexiffstop': '',
|
6471 | 'data-ngexifexposure': '',
|
6472 | 'data-ngexifiso': '',
|
6473 | 'data-ngexiftime': '',
|
6474 | 'data-ngexiflocation': '',
|
6475 | 'data-ngsrc': '',
|
6476 | 'alt': ''
|
6477 | };
|
6478 |
|
6479 |
|
6480 | [].forEach.call( item.attributes, function(attr) {
|
6481 | data[attr.name.toLowerCase()] = attr.value.trim();
|
6482 | });
|
6483 |
|
6484 | var title = ElementGetText(item);
|
6485 | if( title == '' && data.alt != '') {
|
6486 |
|
6487 | title = data['alt'];
|
6488 | }
|
6489 |
|
6490 |
|
6491 | jQuery.each($(item).children(), function(i, sub_item){
|
6492 |
|
6493 |
|
6494 | if( title == '' ) {
|
6495 | title = ElementGetText(sub_item);
|
6496 | }
|
6497 |
|
6498 | [].forEach.call( sub_item.attributes, function(attr) {
|
6499 | data[attr.name.toLowerCase()] = attr.value.trim();
|
6500 | });
|
6501 |
|
6502 | if( title == '' && data.alt != '') {
|
6503 |
|
6504 | title = data['alt'];
|
6505 | }
|
6506 |
|
6507 | });
|
6508 |
|
6509 |
|
6510 |
|
6511 | var src = '',
|
6512 | st = RetrieveCurWidth().toUpperCase();
|
6513 | if( data.hasOwnProperty('data-ngsrc'+st) ) {
|
6514 | src = data['data-ngsrc'+st];
|
6515 | }
|
6516 |
|
6517 |
|
6518 |
|
6519 |
|
6520 |
|
6521 |
|
6522 |
|
6523 |
|
6524 | src = src || data['data-ngsrc'] || data['href'];
|
6525 | if( src !== undefined && !StartsWithProtocol(src) ) {
|
6526 | src = G.O.itemsBaseURL + src;
|
6527 | }
|
6528 |
|
6529 |
|
6530 |
|
6531 | var thumbsrc = '';
|
6532 |
|
6533 | if( data.hasOwnProperty('src') ) {
|
6534 | thumbsrc = data['src'];
|
6535 | }
|
6536 |
|
6537 | if( thumbsrc == '' && data.hasOwnProperty('data-ngthumb') ) {
|
6538 | thumbsrc = data['data-ngthumb'];
|
6539 | }
|
6540 | if( thumbsrc == '' ) {
|
6541 | thumbsrc = src;
|
6542 | }
|
6543 | if( thumbsrc !== undefined && !StartsWithProtocol(thumbsrc) ) {
|
6544 | thumbsrc = G.O.itemsBaseURL + thumbsrc;
|
6545 | }
|
6546 |
|
6547 |
|
6548 | if( src === undefined && thumbsrc === undefined ) { return; }
|
6549 |
|
6550 |
|
6551 |
|
6552 | var description = data['data-ngdesc'];
|
6553 | var ID = data['id'] || data['data-ngid'];
|
6554 |
|
6555 |
|
6556 |
|
6557 | var kind = data['data-ngkind'];
|
6558 | var tags = data['data-ngtags'];
|
6559 |
|
6560 | var albumID = '0';
|
6561 | if( data.hasOwnProperty('data-ngalbumid') ) {
|
6562 | albumID = data['data-ngalbumid'];
|
6563 | foundAlbumID = true;
|
6564 | }
|
6565 |
|
6566 |
|
6567 | var title_from_url = GetImageTitleFromURL( src );
|
6568 | if( title_from_url != '' ) {
|
6569 | title = title_from_url;
|
6570 | }
|
6571 |
|
6572 | var newItem = NGY2Item.New( G, title, description, ID, albumID, kind, tags );
|
6573 | if( title != '' ) {
|
6574 | nbTitles++;
|
6575 | }
|
6576 |
|
6577 |
|
6578 | newItem.setMediaURL( src, 'img');
|
6579 |
|
6580 |
|
6581 |
|
6582 | jQuery.each(mediaList, function ( n, media ) {
|
6583 | var id = media.getID(src);
|
6584 | if( id != null ) {
|
6585 | if( typeof media.url == 'function' ) { src = media.url(id); }
|
6586 | if( typeof media.thumbUrl == 'function' ) { thumbsrc = media.thumbUrl(id); }
|
6587 | newItem.mediaKind = media.kind;
|
6588 | newItem.mediaMarkup = ( media.selfhosted ) ? media.markup( src ) : media.markup(id);
|
6589 | return false;
|
6590 | }
|
6591 | });
|
6592 |
|
6593 |
|
6594 |
|
6595 | newItem.imageWidth = parseInt( data['data-ngimagewidth'] );
|
6596 | newItem.imageHeight = parseInt( data['data-ngimageheight'] );
|
6597 |
|
6598 |
|
6599 | var tw = parseInt(data['data-ngthumbimgwidth']);
|
6600 | var th = parseInt(data['data-ngthumbimgheight']);
|
6601 | newItem.thumbs = {
|
6602 | url: { l1 : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc }, lN : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc } },
|
6603 | width: { l1 : { xs: tw, sm: tw, me: tw, la: tw, xl: tw }, lN : { xs: tw, sm: tw, me: tw, la: tw, xl: tw } },
|
6604 | height: { l1 : { xs: th, sm: th, me: th, la: th, xl: th }, lN : { xs: th, sm: th, me: th, la: th, xl: th } }
|
6605 | };
|
6606 |
|
6607 |
|
6608 | if( newItem.mediaKind == 'img' ) {
|
6609 |
|
6610 |
|
6611 | var lst = ['xs', 'sm', 'me', 'la', 'xl'];
|
6612 | for( var i = 0; i < lst.length; i++ ) {
|
6613 |
|
6614 | if( data.hasOwnProperty('data-ngthumb' + lst[i]) ) {
|
6615 | var turl=data['data-ngthumb' + lst[i]];
|
6616 | if( !StartsWithProtocol(turl) ) {
|
6617 | turl = G.O.itemsBaseURL + turl;
|
6618 | }
|
6619 | newItem.url.l1[lst[i]] = turl;
|
6620 | newItem.url.lN[lst[i]] = turl;
|
6621 | }
|
6622 |
|
6623 |
|
6624 | if( data.hasOwnProperty('data-ngthumb' + lst[i] + 'width') ) {
|
6625 | var tw=parseInt(data['data-ngthumb' + lst[i] + 'width']);
|
6626 | newItem.width.l1[lst[i]] = tw;
|
6627 | newItem.width.lN[lst[i]] = tw;
|
6628 | }
|
6629 |
|
6630 | if( data.hasOwnProperty('data-ngthumb' + lst[i] + 'height') ) {
|
6631 | var th=parseInt('data-ngthumb' + lst[i] + 'height');
|
6632 | newItem.height.l1[lst[i]] = th;
|
6633 | newItem.height.lN[lst[i]] = th;
|
6634 | }
|
6635 | }
|
6636 | }
|
6637 |
|
6638 |
|
6639 |
|
6640 | newItem.imageDominantColors = data['data-ngimagedominantcolors'];
|
6641 |
|
6642 | newItem.imageDominantColor = data['data-ngimagedominantcolors'];
|
6643 |
|
6644 | newItem.destinationURL = data['data-ngdest'];
|
6645 | newItem.downloadURL = data['data-ngdownloadurl'];
|
6646 |
|
6647 |
|
6648 | newItem.exif.model=data['data-ngexifmodel'];
|
6649 |
|
6650 | newItem.exif.flash=data['data-ngexifflash'];
|
6651 |
|
6652 | newItem.exif.focallength=data['data-ngexiffocallength'];
|
6653 |
|
6654 | newItem.exif.fstop=data['data-ngexiffstop'];
|
6655 |
|
6656 | newItem.exif.exposure=data['data-ngexifexposure'];
|
6657 |
|
6658 | newItem.exif.iso=data['data-ngexifiso'];
|
6659 |
|
6660 | newItem.exif.time=data['data-ngexiftime'];
|
6661 |
|
6662 | newItem.exif.location=data['data-ngexiflocation'];
|
6663 |
|
6664 | newItem.contentIsLoaded = true;
|
6665 |
|
6666 |
|
6667 | if( jQuery(item).data('customdata') !== undefined ) {
|
6668 | newItem.customData = cloneJSObject(jQuery(item).data('customdata'));
|
6669 | }
|
6670 |
|
6671 | if( jQuery(item).data('ngcustomdata') !== undefined ) {
|
6672 | newItem.customData = cloneJSObject(jQuery(item).data('ngcustomdata'));
|
6673 | }
|
6674 |
|
6675 | var fu=G.O.fnProcessData;
|
6676 | if( fu !== null ) {
|
6677 | typeof fu == 'function' ? fu(newItem, 'markup', item) : window[fu](newItem, 'markup', item);
|
6678 | }
|
6679 |
|
6680 | AlbumPostProcess(albumID);
|
6681 |
|
6682 | });
|
6683 |
|
6684 |
|
6685 | if( nbTitles == 0 ) { G.O.thumbnailLabel.display = false; }
|
6686 |
|
6687 | }
|
6688 |
|
6689 |
|
6690 |
|
6691 |
|
6692 |
|
6693 |
|
6694 |
|
6695 |
|
6696 | function DefineVariables() {
|
6697 |
|
6698 |
|
6699 | if( G.O.kind.toUpperCase() == 'PICASA' || G.O.kind.toUpperCase() == 'GOOGLE') {
|
6700 | G.O.kind='google2';
|
6701 | }
|
6702 |
|
6703 |
|
6704 | G.GOM.cache.viewport = getViewport();
|
6705 | G.GOM.curWidth = RetrieveCurWidth();
|
6706 |
|
6707 |
|
6708 | jQuery.extend(true, G.tn.toolbar.image, G.O.thumbnailToolbarImage );
|
6709 | jQuery.extend(true, G.tn.toolbar.album, G.O.thumbnailToolbarAlbum );
|
6710 | var t = ['image', 'album'];
|
6711 | var pos= ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']
|
6712 | for( var i=0; i < t.length ; i++ ) {
|
6713 | for( var j=0; j < pos.length ; j++ ) {
|
6714 | G.tn.toolbar[t[i]][pos[j]] = G.tn.toolbar[t[i]][pos[j]].toUpperCase();
|
6715 | }
|
6716 | }
|
6717 |
|
6718 |
|
6719 | if( G.O.thumbnailLabel.position == 'overImageOnBottom' ) {
|
6720 | G.O.thumbnailLabel.valign = 'bottom';
|
6721 | G.O.thumbnailLabel.position = 'overImage';
|
6722 | }
|
6723 | if( G.O.thumbnailLabel.position == 'overImageOnMiddle' ) {
|
6724 | G.O.thumbnailLabel.valign = 'middle';
|
6725 | G.O.thumbnailLabel.position = 'overImage';
|
6726 | }
|
6727 | if( G.O.thumbnailLabel.position == 'overImageOnTop' ) {
|
6728 | G.O.thumbnailLabel.valign = 'top';
|
6729 | G.O.thumbnailLabel.position = 'overImage';
|
6730 | }
|
6731 | if( G.O.thumbnailL1Label !== undefined && G.O.thumbnailL1Label.position !== undefined ) {
|
6732 | if( G.O.thumbnailL1Label.position == 'overImageOnBottom' ) {
|
6733 | G.O.thumbnailL1Label.valign = 'bottom';
|
6734 | G.O.thumbnailL1Label.position = 'overImage';
|
6735 | }
|
6736 | if( G.O.thumbnailL1Label.position == 'overImageOnMiddle' ) {
|
6737 | G.O.thumbnailL1Label.valign = 'middle';
|
6738 | G.O.thumbnailL1Label.position = 'overImage';
|
6739 | }
|
6740 | if( G.O.thumbnailL1Label.position == 'overImageOnTop' ) {
|
6741 | G.O.thumbnailL1Label.valign = 'top';
|
6742 | G.O.thumbnailL1Label.position = 'overImage';
|
6743 | }
|
6744 | }
|
6745 |
|
6746 |
|
6747 | G.O.thumbnailLabel.get = function( opt ) {
|
6748 | if( G.GOM.curNavLevel == 'l1' && G.O.thumbnailL1Label !== undefined && G.O.thumbnailL1Label[opt] !== undefined ) {
|
6749 | return G.O.thumbnailL1Label[opt];
|
6750 | }
|
6751 | else {
|
6752 | return G.O.thumbnailLabel[opt];
|
6753 | }
|
6754 | };
|
6755 | G.O.thumbnailLabel.set = function( opt, value ) {
|
6756 | if( G.GOM.curNavLevel == 'l1' && G.O.thumbnailL1Label !== undefined && G.O.thumbnailL1Label[opt] !== undefined ) {
|
6757 | G.O.thumbnailL1Label[opt]=value;
|
6758 | }
|
6759 | else {
|
6760 | G.O.thumbnailLabel[opt]=value;
|
6761 | }
|
6762 | };
|
6763 |
|
6764 | if( G.O.blockList != '' ) { G.blockList = G.O.blockList.toUpperCase().split('|'); }
|
6765 | if( G.O.allowList != '' ) { G.allowList = G.O.allowList.toUpperCase().split('|'); }
|
6766 |
|
6767 | if( G.O.albumList2 !== undefined && G.O.albumList2 !== null && G.O.albumList2.constructor === Array ) {
|
6768 | var l=G.O.albumList2.length;
|
6769 | for(var i=0; i< l; i++ ) {
|
6770 | G.albumList.push(G.O.albumList2[i]);
|
6771 | }
|
6772 |
|
6773 | }
|
6774 | if( G.O.albumList2 !== undefined && typeof G.O.albumList2 == 'string' ) {
|
6775 | G.albumList.push(G.O.albumList2);
|
6776 | }
|
6777 |
|
6778 |
|
6779 |
|
6780 | G.tn.opt.lN.crop = G.O.thumbnailCrop;
|
6781 | G.tn.opt.l1.crop = G.O.thumbnailL1Crop != null ? G.O.thumbnailL1Crop : G.O.thumbnailCrop;
|
6782 |
|
6783 |
|
6784 | function ThumbnailOpt( lN, l1, opt) {
|
6785 | G.tn.opt.lN[opt] = G.O[lN];
|
6786 | G.tn.opt.l1[opt] = G.O[lN];
|
6787 | if( toType(G.O[l1]) == 'number' ) {
|
6788 | G.tn.opt.l1[opt] = G.O[l1];
|
6789 | }
|
6790 | }
|
6791 |
|
6792 | ThumbnailOpt('thumbnailStacks', 'thumbnailL1Stacks', 'stacks');
|
6793 |
|
6794 | ThumbnailOpt('thumbnailStacksTranslateX', 'thumbnailL1StacksTranslateX', 'stacksTranslateX');
|
6795 |
|
6796 | ThumbnailOpt('thumbnailStacksTranslateY', 'thumbnailL1StacksTranslateY', 'stacksTranslateY');
|
6797 |
|
6798 | ThumbnailOpt('thumbnailStacksTranslateZ', 'thumbnailL1StacksTranslateZ', 'stacksTranslateZ');
|
6799 |
|
6800 | ThumbnailOpt('thumbnailStacksRotateX', 'thumbnailL1StacksRotateX', 'stacksRotateX');
|
6801 |
|
6802 | ThumbnailOpt('thumbnailStacksRotateY', 'thumbnailL1StacksRotateY', 'stacksRotateY');
|
6803 |
|
6804 | ThumbnailOpt('thumbnailStacksRotateZ', 'thumbnailL1StacksRotateZ', 'stacksRotateZ');
|
6805 |
|
6806 | ThumbnailOpt('thumbnailStacksScale', 'thumbnailL1StacksScale', 'stacksScale');
|
6807 |
|
6808 |
|
6809 |
|
6810 |
|
6811 |
|
6812 | ThumbnailOpt('thumbnailBorderHorizontal', 'thumbnailL1BorderHorizontal', 'borderHorizontal');
|
6813 |
|
6814 | ThumbnailOpt('thumbnailBorderVertical', 'thumbnailL1BorderVertical', 'borderVertical');
|
6815 |
|
6816 | ThumbnailOpt('thumbnailBaseGridHeight', 'thumbnailL1BaseGridHeight', 'baseGridHeight');
|
6817 |
|
6818 |
|
6819 |
|
6820 | function ResponsiveSetSize( setting, level, v ) {
|
6821 | G.tn.settings[setting][level]['xs'] = v;
|
6822 | G.tn.settings[setting][level]['sm'] = v;
|
6823 | G.tn.settings[setting][level]['me'] = v;
|
6824 | G.tn.settings[setting][level]['la'] = v;
|
6825 | G.tn.settings[setting][level]['xl'] = v;
|
6826 | }
|
6827 |
|
6828 |
|
6829 |
|
6830 |
|
6831 | function ResponsiveOption( option, setting, level ) {
|
6832 | var v = G.O[option];
|
6833 |
|
6834 | if( v === undefined || v === null ) { return; }
|
6835 |
|
6836 |
|
6837 | if( toType(v) == 'number' || v.indexOf(' ') == -1 ) {
|
6838 |
|
6839 | var vn = 'auto';
|
6840 | if( v != 'auto' ) { vn = parseInt(v); }
|
6841 | ResponsiveSetSize( setting, level, vn );
|
6842 | }
|
6843 | else {
|
6844 | var sp = v.split(' ');
|
6845 | if( sp.length > 0 && +sp[0] === +sp[0] ) {
|
6846 |
|
6847 | var vn = 'auto';
|
6848 | if( sp[0] != 'auto' ) { vn = parseInt(sp[0]); }
|
6849 | ResponsiveSetSize( setting, level, vn );
|
6850 | }
|
6851 | for( var i = 1; i < sp.length; i++ ) {
|
6852 | if( /^xs|sm|me|la|xl/i.test( sp[i] ) ) {
|
6853 | var wi = sp[i].substring(0, 2).toLowerCase();
|
6854 | var va = sp[i].substring(2);
|
6855 | var vn = 'auto';
|
6856 | if( va != 'auto' ) { vn = parseInt(va); }
|
6857 | G.tn.settings[setting][level][wi] = vn;
|
6858 | }
|
6859 | }
|
6860 | }
|
6861 | }
|
6862 |
|
6863 | ResponsiveOption('thumbnailGutterWidth', 'gutterWidth', 'lN');
|
6864 | ResponsiveOption('thumbnailGutterWidth', 'gutterWidth', 'l1');
|
6865 | ResponsiveOption('thumbnailL1GutterWidth', 'gutterWidth', 'l1');
|
6866 | ResponsiveOption('thumbnailGutterHeight', 'gutterHeight', 'lN');
|
6867 | ResponsiveOption('thumbnailGutterHeight', 'gutterHeight', 'l1');
|
6868 | ResponsiveOption('thumbnailL1GutterHeight', 'gutterHeight', 'l1');
|
6869 |
|
6870 |
|
6871 | G.galleryDisplayMode.lN = G.O.galleryDisplayMode.toUpperCase();
|
6872 | G.galleryDisplayMode.l1 = G.O.galleryL1DisplayMode != null ? G.O.galleryL1DisplayMode.toUpperCase() : G.O.galleryDisplayMode.toUpperCase();
|
6873 |
|
6874 |
|
6875 | G.galleryMaxRows.lN = G.O.galleryMaxRows;
|
6876 | G.galleryMaxRows.l1 = toType(G.O.galleryL1MaxRows) == 'number' ? G.O.galleryL1MaxRows : G.O.galleryMaxRows;
|
6877 |
|
6878 |
|
6879 | G.galleryLastRowFull.lN = G.O.galleryLastRowFull;
|
6880 | G.galleryLastRowFull.l1 = G.O.galleryL1LastRowFull != null ? G.O.galleryL1LastRowFull : G.O.galleryLastRowFull;
|
6881 |
|
6882 |
|
6883 | G.gallerySorting.lN = G.O.gallerySorting.toUpperCase();
|
6884 | G.gallerySorting.l1 = G.O.galleryL1Sorting != null ? G.O.galleryL1Sorting.toUpperCase() : G.gallerySorting.lN;
|
6885 |
|
6886 |
|
6887 | G.galleryDisplayTransition.lN = G.O.galleryDisplayTransition.toUpperCase();
|
6888 | G.galleryDisplayTransition.l1 = G.O.galleryL1DisplayTransition != null ? G.O.galleryL1DisplayTransition.toUpperCase() : G.galleryDisplayTransition.lN;
|
6889 |
|
6890 |
|
6891 | G.galleryDisplayTransitionDuration.lN = G.O.galleryDisplayTransitionDuration;
|
6892 | G.galleryDisplayTransitionDuration.l1 = G.O.galleryL1DisplayTransitionDuration != null ? G.O.galleryL1DisplayTransitionDuration : G.galleryDisplayTransitionDuration.lN;
|
6893 |
|
6894 |
|
6895 | G.galleryMaxItems.lN = G.O.galleryMaxItems;
|
6896 | G.galleryMaxItems.l1 = toType(G.O.galleryL1MaxItems) == 'number' ? G.O.galleryL1MaxItems : G.O.galleryMaxItems;
|
6897 |
|
6898 |
|
6899 | G.galleryFilterTags.lN = G.O.galleryFilterTags;
|
6900 | G.galleryFilterTags.l1 = G.O.galleryL1FilterTags != null ? G.O.galleryL1FilterTags : G.O.galleryFilterTags;
|
6901 |
|
6902 |
|
6903 | G.galleryFilterTagsMode.lN = G.O.galleryFilterTagsMode;
|
6904 | G.galleryFilterTagsMode.l1 = G.O.galleryL1FilterTagsMode != null ? G.O.galleryL1FilterTagsMode : G.O.galleryFilterTagsMode;
|
6905 |
|
6906 |
|
6907 | G.O.galleryPaginationMode = G.O.galleryPaginationMode.toUpperCase();
|
6908 |
|
6909 | if( toType(G.O.slideshowDelay) == 'number' && G.O.slideshowDelay >= 2000 ) {
|
6910 | G.VOM.slideshowDelay = G.O.slideshowDelay;
|
6911 | }
|
6912 | else {
|
6913 | NanoConsoleLog(G, 'Parameter "slideshowDelay" must be an integer >= 2000 ms.');
|
6914 | }
|
6915 |
|
6916 |
|
6917 | if( typeof G.O.thumbnailDisplayTransition == 'boolean' ) {
|
6918 | if( G.O.thumbnailDisplayTransition === true ) {
|
6919 | G.tn.opt.lN.displayTransition = 'FADEIN';
|
6920 | G.tn.opt.l1.displayTransition = 'FADEIN';
|
6921 | }
|
6922 | else {
|
6923 | G.tn.opt.lN.displayTransition = 'NONE';
|
6924 | G.tn.opt.l1.displayTransition = 'NONE';
|
6925 | }
|
6926 | }
|
6927 |
|
6928 | if( G.O.fnThumbnailDisplayEffect !== '' ) {
|
6929 | G.tn.opt.lN.displayTransition = 'CUSTOM';
|
6930 | G.tn.opt.l1.displayTransition = 'CUSTOM';
|
6931 | }
|
6932 | if( G.O.fnThumbnailL1DisplayEffect !== '' ) {
|
6933 | G.tn.opt.l1.displayTransition = 'CUSTOM';
|
6934 | }
|
6935 |
|
6936 |
|
6937 |
|
6938 |
|
6939 | ThumbnailOpt('thumbnailDisplayTransitionEasing', 'thumbnailL1DisplayTransitionEasing', 'displayTransitionEasing');
|
6940 |
|
6941 | function thumbnailDisplayTransitionParse( cfg, level ) {
|
6942 | if( typeof cfg == 'string' ) {
|
6943 | var st=cfg.split('_');
|
6944 | if( st.length == 1 ) {
|
6945 | G.tn.opt[level]['displayTransition'] = cfg.toUpperCase();
|
6946 | }
|
6947 | if( st.length == 2 ) {
|
6948 | G.tn.opt[level]['displayTransition'] = st[0].toUpperCase();
|
6949 | G.tn.opt[level]['displayTransitionStartVal'] = Number(st[1]);
|
6950 | }
|
6951 | if( st.length == 3 ) {
|
6952 | G.tn.opt[level]['displayTransition'] = st[0].toUpperCase();
|
6953 | G.tn.opt[level]['displayTransitionStartVal'] = Number(st[1]);
|
6954 | G.tn.opt[level]['displayTransitionEasing'] = st[2];
|
6955 | }
|
6956 | }
|
6957 | }
|
6958 | thumbnailDisplayTransitionParse( G.O.thumbnailDisplayTransition, 'lN');
|
6959 | thumbnailDisplayTransitionParse( G.O.thumbnailDisplayTransition, 'l1');
|
6960 | thumbnailDisplayTransitionParse( G.O.thumbnailL1DisplayTransition, 'l1');
|
6961 |
|
6962 |
|
6963 |
|
6964 | ThumbnailOpt('thumbnailDisplayTransitionDuration', 'thumbnailL1DisplayTransitionDuration', 'displayTransitionDuration');
|
6965 |
|
6966 | ThumbnailOpt('thumbnailDisplayInterval', 'thumbnailL1DisplayInterval', 'displayInterval');
|
6967 |
|
6968 | ThumbnailOpt('thumbnailDisplayOrder', 'thumbnailL1DisplayOrder', 'displayOrder');
|
6969 |
|
6970 |
|
6971 |
|
6972 | if( G.O.thumbnailSizeSM !== undefined ) { G.O.breakpointSizeSM = G.O.thumbnailSizeSM; }
|
6973 | if( G.O.thumbnailSizeME !== undefined ) { G.O.breakpointSizeME = G.O.thumbnailSizeME; }
|
6974 | if( G.O.thumbnailSizeLA !== undefined ) { G.O.breakpointSizeLA = G.O.thumbnailSizeLA; }
|
6975 | if( G.O.thumbnailSizeXL !== undefined ) { G.O.breakpointSizeXL = G.O.thumbnailSizeXL; }
|
6976 |
|
6977 |
|
6978 |
|
6979 | if( G.O.thumbnailL1BuildInit2 !== undefined ) {
|
6980 | var t1 = G.O.thumbnailL1BuildInit2.split('|');
|
6981 | for( var i = 0; i < t1.length; i++ ) {
|
6982 | var o1 = t1[i].trim().split('_');
|
6983 | if( o1.length == 3 ) {
|
6984 | var i1 = NewTBuildInit();
|
6985 | i1.element = ThumbnailOverEffectsGetCSSElement(o1[0], '');
|
6986 | i1.property = o1[1];
|
6987 | i1.value = o1[2];
|
6988 | G.tn.buildInit.level1.push(i1);
|
6989 | }
|
6990 | }
|
6991 | }
|
6992 |
|
6993 | if( G.O.thumbnailBuildInit2 !== undefined ) {
|
6994 | var t1 = G.O.thumbnailBuildInit2.split('|');
|
6995 | for( var i = 0; i < t1.length; i++ ) {
|
6996 | var o1 = t1[i].trim().split('_');
|
6997 | if( o1.length == 3 ) {
|
6998 | var i1 = NewTBuildInit();
|
6999 | i1.element = ThumbnailOverEffectsGetCSSElement(o1[0], '');
|
7000 | i1.property = o1[1];
|
7001 | i1.value = o1[2];
|
7002 | G.tn.buildInit.std.push(i1);
|
7003 | }
|
7004 | }
|
7005 | }
|
7006 |
|
7007 |
|
7008 |
|
7009 |
|
7010 |
|
7011 | var tL1HE = G.O.thumbnailL1HoverEffect2;
|
7012 | if( tL1HE !== undefined ) {
|
7013 | switch( toType(tL1HE) ) {
|
7014 | case 'string': {
|
7015 | let tmp = tL1HE.split('|');
|
7016 | for(var i = 0; i < tmp.length; i++) {
|
7017 | let oDef = NewTHoverEffect();
|
7018 | oDef = ThumbnailHoverEffectExtract( tmp[i].trim(), oDef );
|
7019 | if( oDef != null ) {
|
7020 | G.tn.hoverEffects.level1.push(oDef);
|
7021 | }
|
7022 | }
|
7023 | break;
|
7024 | }
|
7025 | case 'object': {
|
7026 | let oDef = NewTHoverEffect();
|
7027 | oDef = jQuery.extend(oDef,tL1HE);
|
7028 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
7029 | if( oDef != null ) {
|
7030 | G.tn.hoverEffects.level1.push(oDef);
|
7031 | }
|
7032 | break;
|
7033 | }
|
7034 | case 'array': {
|
7035 | for(var i = 0; i < tL1HE.length; i++) {
|
7036 | let oDef = NewTHoverEffect();
|
7037 | oDef = jQuery.extend(oDef,tL1HE[i]);
|
7038 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
7039 | if( oDef != null ) {
|
7040 | G.tn.hoverEffects.level1.push(oDef);
|
7041 | }
|
7042 | }
|
7043 | break;
|
7044 | }
|
7045 | case 'null':
|
7046 | break;
|
7047 | default:
|
7048 | NanoAlert(G, 'incorrect parameter for "thumbnailL1HoverEffect2".');
|
7049 | }
|
7050 | }
|
7051 | G.tn.hoverEffects.level1 = ThumbnailOverEffectsPreset(G.tn.hoverEffects.level1);
|
7052 |
|
7053 |
|
7054 | var tHE = G.O.thumbnailHoverEffect2;
|
7055 | switch( toType(tHE) ) {
|
7056 | case 'string': {
|
7057 | let tmp = tHE.split('|');
|
7058 | for(var i = 0; i < tmp.length; i++) {
|
7059 | let oDef = NewTHoverEffect();
|
7060 | oDef = ThumbnailHoverEffectExtract( tmp[i].trim(), oDef );
|
7061 | if( oDef != null ) {
|
7062 | G.tn.hoverEffects.std.push(oDef);
|
7063 | }
|
7064 | }
|
7065 | break;
|
7066 | }
|
7067 | case 'object': {
|
7068 | let oDef = NewTHoverEffect();
|
7069 | oDef = jQuery.extend(oDef, tHE);
|
7070 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
7071 | if( oDef != null ) {
|
7072 | G.tn.hoverEffects.std.push(oDef);
|
7073 | }
|
7074 | break;
|
7075 | }
|
7076 | case 'array': {
|
7077 | for(var i = 0; i < tHE.length; i++) {
|
7078 | let oDef = NewTHoverEffect();
|
7079 | oDef = jQuery.extend(oDef,tHE[i]);
|
7080 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
7081 | if( oDef!= null ) {
|
7082 | G.tn.hoverEffects.std.push(oDef);
|
7083 | }
|
7084 | }
|
7085 | break;
|
7086 | }
|
7087 | case 'null':
|
7088 | break;
|
7089 | default:
|
7090 | NanoAlert(G, 'incorrect parameter for "thumbnailHoverEffect2".');
|
7091 | }
|
7092 | G.tn.hoverEffects.std = ThumbnailOverEffectsPreset(G.tn.hoverEffects.std);
|
7093 |
|
7094 |
|
7095 | if( G.O.touchAnimationL1 == undefined ) {
|
7096 | G.O.touchAnimationL1 = G.O.touchAnimation;
|
7097 | }
|
7098 |
|
7099 |
|
7100 | if( G.tn.hoverEffects.std.length == 0 ) {
|
7101 | if( G.tn.hoverEffects.level1.length == 0 ) {
|
7102 | G.O.touchAnimationL1 = false;
|
7103 | }
|
7104 | G.O.touchAnimation = false;
|
7105 | }
|
7106 |
|
7107 |
|
7108 |
|
7109 | if( G.O.thumbnailHeight == 0 || G.O.thumbnailHeight == '' ) { G.O.thumbnailHeight = 'auto'; }
|
7110 | if( G.O.thumbnailWidth == 0 || G.O.thumbnailWidth == '' ) { G.O.thumbnailWidth = 'auto'; }
|
7111 | if( G.O.thumbnailL1Height == 0 || G.O.thumbnailL1Height == '' ) { G.O.thumbnailL1Height = 'auto'; }
|
7112 | if( G.O.thumbnailL1Width == 0 || G.O.thumbnailL1Width == '' ) { G.O.thumbnailL1Width = 'auto'; }
|
7113 |
|
7114 |
|
7115 |
|
7116 |
|
7117 |
|
7118 |
|
7119 | ResponsiveOption('thumbnailWidth', 'width', 'lN');
|
7120 | ResponsiveOption('thumbnailWidth', 'width', 'l1');
|
7121 | ResponsiveOption('thumbnailL1Width', 'width', 'l1');
|
7122 | ResponsiveOption('thumbnailHeight', 'height', 'lN');
|
7123 | ResponsiveOption('thumbnailHeight', 'height', 'l1');
|
7124 | ResponsiveOption('thumbnailL1Height', 'height', 'l1');
|
7125 |
|
7126 |
|
7127 | G.O.thumbnailLabelHeight = parseInt(G.O.thumbnailLabelHeight);
|
7128 |
|
7129 |
|
7130 |
|
7131 |
|
7132 | if( G.O.galleryMosaic != undefined ) {
|
7133 |
|
7134 | G.tn.settings.mosaic.l1.xs = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7135 | G.tn.settings.mosaic.l1.sm = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7136 | G.tn.settings.mosaic.l1.me = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7137 | G.tn.settings.mosaic.l1.la = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7138 | G.tn.settings.mosaic.l1.xl = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7139 | G.tn.settings.mosaic.lN.xs = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7140 | G.tn.settings.mosaic.lN.sm = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7141 | G.tn.settings.mosaic.lN.me = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7142 | G.tn.settings.mosaic.lN.la = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7143 | G.tn.settings.mosaic.lN.xl = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
7144 | G.tn.settings.mosaicCalcFactor('l1', 'xs');
|
7145 | G.tn.settings.mosaicCalcFactor('l1', 'sm');
|
7146 | G.tn.settings.mosaicCalcFactor('l1', 'me');
|
7147 | G.tn.settings.mosaicCalcFactor('l1', 'la');
|
7148 | G.tn.settings.mosaicCalcFactor('l1', 'xl');
|
7149 | G.tn.settings.mosaicCalcFactor('lN', 'xs');
|
7150 | G.tn.settings.mosaicCalcFactor('lN', 'sm');
|
7151 | G.tn.settings.mosaicCalcFactor('lN', 'me');
|
7152 | G.tn.settings.mosaicCalcFactor('lN', 'la');
|
7153 | G.tn.settings.mosaicCalcFactor('lN', 'xl');
|
7154 | }
|
7155 | if( G.O.galleryL1Mosaic != undefined ) {
|
7156 |
|
7157 | G.tn.settings.mosaic.l1.xs = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
7158 | G.tn.settings.mosaic.l1.sm = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
7159 | G.tn.settings.mosaic.l1.me = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
7160 | G.tn.settings.mosaic.l1.la = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
7161 | G.tn.settings.mosaic.l1.xl = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
7162 | G.tn.settings.mosaicCalcFactor('l1', 'xs');
|
7163 | G.tn.settings.mosaicCalcFactor('l1', 'sm');
|
7164 | G.tn.settings.mosaicCalcFactor('l1', 'me');
|
7165 | G.tn.settings.mosaicCalcFactor('l1', 'la');
|
7166 | G.tn.settings.mosaicCalcFactor('l1', 'xl');
|
7167 | }
|
7168 |
|
7169 | var lst=['xs','sm','me','la','xl'];
|
7170 |
|
7171 | for( var w = 0; w < lst.length; w++ ) {
|
7172 | if( G.O['galleryMosaic' + lst[w].toUpperCase()] != undefined ) {
|
7173 | G.tn.settings.mosaic.lN[lst[w]] = JSON.parse(JSON.stringify( G.O['galleryMosaic' + lst[w].toUpperCase()] ));
|
7174 | G.tn.settings.mosaic.l1[lst[w]] = JSON.parse(JSON.stringify( G.O['galleryMosaic' + lst[w].toUpperCase()] ));
|
7175 | G.tn.settings.mosaicCalcFactor('lN',lst[w]);
|
7176 | G.tn.settings.mosaicCalcFactor('l1', lst[w]);
|
7177 | }
|
7178 | }
|
7179 |
|
7180 | for( var w = 0; w < lst.length; w++ ) {
|
7181 | if( G.O['galleryL1Mosaic' + lst[w].toUpperCase()] != undefined ) {
|
7182 | G.tn.settings.mosaic.l1[lst[w]] = JSON.parse(JSON.stringify( G.O['galleryL1Mosaic' + lst[w].toUpperCase()] ));
|
7183 | G.tn.settings.mosaicCalcFactor('l1', lst[w]);
|
7184 | }
|
7185 | }
|
7186 |
|
7187 | G.O.imageTransition = G.O.imageTransition.toUpperCase();
|
7188 |
|
7189 | G.layout.SetEngine();
|
7190 |
|
7191 |
|
7192 | switch( G.O.kind ) {
|
7193 |
|
7194 | case '':
|
7195 | break;
|
7196 |
|
7197 | default:
|
7198 | jQuery.nanogallery2['data_' + G.O.kind](G, 'Init' );
|
7199 | }
|
7200 |
|
7201 | }
|
7202 |
|
7203 |
|
7204 | function ThumbnailHoverEffectExtract( name, effect) {
|
7205 | 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'];
|
7206 |
|
7207 | var sp = name.split('_');
|
7208 | if( sp.length >= 4 ) {
|
7209 |
|
7210 | effect.name = '';
|
7211 | effect.type = sp[1];
|
7212 | effect.from = sp[2];
|
7213 | effect.to = sp[3];
|
7214 | if( sp.length >= 5 ) {
|
7215 |
|
7216 |
|
7217 | for( var n = 4; n < sp.length; n++ ) {
|
7218 | var v = sp[n];
|
7219 |
|
7220 |
|
7221 | var foundEasing = false;
|
7222 | for( var e = 0; e < easings.length; e++) {
|
7223 | if( v == easings[e] ) {
|
7224 | foundEasing = true;
|
7225 | effect.easing = v;
|
7226 | break;
|
7227 | }
|
7228 | }
|
7229 | if( foundEasing === true ) {
|
7230 | continue;
|
7231 | }
|
7232 |
|
7233 | v = v.toUpperCase();
|
7234 |
|
7235 | if( v == 'HOVERIN' ) {
|
7236 | effect.hoverout = false;
|
7237 | continue;
|
7238 | }
|
7239 | if( v == 'HOVEROUT' ) {
|
7240 | effect.hoverin = false;
|
7241 | continue;
|
7242 | }
|
7243 |
|
7244 | if( v == 'KEYFRAME' ) {
|
7245 | effect.firstKeyframe = false;
|
7246 | continue;
|
7247 | }
|
7248 |
|
7249 | var num = parseInt(v.replace(/[^0-9\.]/g, ''), 10);
|
7250 |
|
7251 | if( num > 0 ) {
|
7252 |
|
7253 | if( v.indexOf('DURATION') >= 0 ) {
|
7254 | effect.duration = num;
|
7255 | continue;
|
7256 | }
|
7257 | if( v.indexOf('DURATIONBACK') >= 0 ) {
|
7258 | effect.durationBack = num;
|
7259 | continue;
|
7260 | }
|
7261 | if( v.indexOf('DELAY') >= 0 ) {
|
7262 | effect.delay = num;
|
7263 | continue;
|
7264 | }
|
7265 | if( v.indexOf('DELAYBACK') >= 0 ) {
|
7266 | effect.delayBack = num;
|
7267 | continue;
|
7268 | }
|
7269 |
|
7270 |
|
7271 | effect.duration = num;
|
7272 | }
|
7273 | }
|
7274 | }
|
7275 | effect.element = ThumbnailOverEffectsGetCSSElement(sp[0], effect.type);
|
7276 |
|
7277 | }
|
7278 | else {
|
7279 | effect.name = name;
|
7280 |
|
7281 |
|
7282 | }
|
7283 | return effect;
|
7284 | }
|
7285 |
|
7286 |
|
7287 | function ThumbnailOverEffectsGetCSSElement( element, property ) {
|
7288 |
|
7289 | var elts = {
|
7290 | 'image': '.nGY2GThumbnailImage',
|
7291 | 'thumbnail': '.nGY2GThumbnail',
|
7292 | 'label': '.nGY2GThumbnailLabel',
|
7293 | 'title': '.nGY2GThumbnailTitle',
|
7294 | 'description': '.nGY2GThumbnailDescription',
|
7295 | 'tools': '.nGY2GThumbnailIcons',
|
7296 | 'customlayer': '.nGY2GThumbnailCustomLayer',
|
7297 | 'default': 'nGY2GThumbnailImage'
|
7298 | };
|
7299 | return (elts[element] || elts['default']);
|
7300 |
|
7301 |
|
7302 | }
|
7303 |
|
7304 |
|
7305 | function ThumbnailOverEffectsPreset( effects ) {
|
7306 |
|
7307 |
|
7308 |
|
7309 |
|
7310 |
|
7311 |
|
7312 |
|
7313 |
|
7314 |
|
7315 |
|
7316 |
|
7317 |
|
7318 |
|
7319 |
|
7320 |
|
7321 | var newEffects=[];
|
7322 | for( var i=0; i< effects.length; i++ ) {
|
7323 | switch( effects[i].name.toUpperCase() ) {
|
7324 | case 'BORDERLIGHTER': {
|
7325 | let rgb = ColorHelperToRGB(GalleryThemeGetCurrent().thumbnail.borderColor);
|
7326 | let name = 'thumbnail_borderColor_'+rgb+'_'+ShadeBlendConvert(0.5, rgb );
|
7327 | newEffects.push(ThumbnailHoverEffectExtract(name, effects[i]));
|
7328 | break;
|
7329 | }
|
7330 | case 'BORDERDARKER': {
|
7331 | let rgb = ColorHelperToRGB(GalleryThemeGetCurrent().thumbnail.borderColor);
|
7332 | let name = 'thumbnail_borderColor_'+rgb+'_'+ShadeBlendConvert(-0.5, rgb );
|
7333 | newEffects.push(ThumbnailHoverEffectExtract(name, effects[i]));
|
7334 | break;
|
7335 | }
|
7336 | case 'SCALE120':
|
7337 | newEffects.push(ThumbnailHoverEffectExtract('thumbnail_scale_1.00_1.20', effects[i]));
|
7338 | break;
|
7339 | case 'LABELAPPEAR':
|
7340 | case 'LABELAPPEAR75':
|
7341 | newEffects.push(ThumbnailHoverEffectExtract('label_opacity_0.00_1.00', effects[i]));
|
7342 | break;
|
7343 | case 'TOOLSAPPEAR':
|
7344 | newEffects.push(ThumbnailHoverEffectExtract('tools_opacity_0_1', effects[i]));
|
7345 | break;
|
7346 | case 'TOOLSSLIDEDOWN':
|
7347 | newEffects.push(ThumbnailHoverEffectExtract('tools_translateY_-100%_0%', effects[i]));
|
7348 | break;
|
7349 | case 'TOOLSSLIDEUP':
|
7350 | newEffects.push(ThumbnailHoverEffectExtract('tools_translateY_100%_0%', effects[i]));
|
7351 | break;
|
7352 | case 'LABELOPACITY50':
|
7353 | newEffects.push(ThumbnailHoverEffectExtract('label_opacity_1.00_0.50', effects[i]));
|
7354 | break;
|
7355 | case 'LABELSLIDEUPTOP':
|
7356 | case 'LABELSLIDEUP':
|
7357 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_100%_0%', effects[i]));
|
7358 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_100%_0%', effects[i]));
|
7359 | break;
|
7360 | case 'LABELSLIDEDOWN':
|
7361 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_-100%_0%', effects[i]));
|
7362 | break;
|
7363 | case 'SCALELABELOVERIMAGE':
|
7364 | newEffects.push(ThumbnailHoverEffectExtract('label_scale_0.00_1.00', effects[i]));
|
7365 | var n = cloneJSObject(effects[i]);
|
7366 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.00_0.00', n));
|
7367 | break;
|
7368 | case 'OVERSCALE':
|
7369 | case 'OVERSCALEOUTSIDE':
|
7370 |
|
7371 | newEffects.push(ThumbnailHoverEffectExtract('label_scale_2.00_1.00', effects[i]));
|
7372 | var n = cloneJSObject(effects[i]);
|
7373 | newEffects.push(ThumbnailHoverEffectExtract('label_opacity_0.00_1.00', n));
|
7374 | n = cloneJSObject(effects[i]);
|
7375 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.00_0.00', n));
|
7376 | n = cloneJSObject(effects[i]);
|
7377 | newEffects.push(ThumbnailHoverEffectExtract('image_opacity_1.00_0.00', n));
|
7378 | break;
|
7379 | case 'DESCRIPTIONAPPEAR':
|
7380 | newEffects.push(ThumbnailHoverEffectExtract('description_opacity_0_1', effects[i]));
|
7381 | break;
|
7382 | case 'SLIDERIGHT':
|
7383 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_100%', effects[i]));
|
7384 | newEffects.push(ThumbnailHoverEffectExtract('label_translateX_-100%_0%', cloneJSObject(effects[i])));
|
7385 | break;
|
7386 | case 'SLIDELEFT':
|
7387 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_-100%', effects[i]));
|
7388 | newEffects.push(ThumbnailHoverEffectExtract('label_translateX_100%_0%', cloneJSObject(effects[i])));
|
7389 | break;
|
7390 | case 'SLIDEUP':
|
7391 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_-100%', effects[i]));
|
7392 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_100%_0%', cloneJSObject(effects[i])));
|
7393 | break;
|
7394 | case 'SLIDEDOWN':
|
7395 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_100%', effects[i]));
|
7396 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_-100%_0%', cloneJSObject(effects[i])));
|
7397 | break;
|
7398 | case 'IMAGESCALE150':
|
7399 | case 'IMAGESCALE150OUTSIDE':
|
7400 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.00_1.50', effects[i]));
|
7401 | break;
|
7402 | case 'IMAGESCALEIN80':
|
7403 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.20_1.00', effects[i]));
|
7404 | break;
|
7405 | case 'IMAGESLIDERIGHT':
|
7406 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_100%', effects[i]));
|
7407 | break;
|
7408 | case 'IMAGESLIDELEFT':
|
7409 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_-100%', effects[i]));
|
7410 | break;
|
7411 | case 'IMAGESLIDEUP':
|
7412 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_-100%', effects[i]));
|
7413 | break;
|
7414 | case 'IMAGESLIDEDOWN':
|
7415 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_100%', effects[i]));
|
7416 | break;
|
7417 | case 'LABELSLIDEUPDOWN':
|
7418 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_0%_100%', effects[i]));
|
7419 | break;
|
7420 | case 'DESCRIPTIONSLIDEUP':
|
7421 | newEffects.push(ThumbnailHoverEffectExtract('description_translateY_110%_0%', effects[i]));
|
7422 | break;
|
7423 |
|
7424 | case 'IMAGEBLURON':
|
7425 | newEffects.push(ThumbnailHoverEffectExtract('image_blur_2.00px_0.00px', effects[i]));
|
7426 | break;
|
7427 | case 'IMAGEBLUROFF':
|
7428 | newEffects.push(ThumbnailHoverEffectExtract('image_blur_0.00px_2.00px', effects[i]));
|
7429 | break;
|
7430 | case 'IMAGEGRAYON':
|
7431 | newEffects.push(ThumbnailHoverEffectExtract('image_grayscale_0%_100%', effects[i]));
|
7432 | break;
|
7433 | case 'IMAGEGRAYOFF':
|
7434 | newEffects.push(ThumbnailHoverEffectExtract('image_grayscale_100%_0%', effects[i]));
|
7435 | break;
|
7436 | case 'IMAGESEPIAON':
|
7437 | newEffects.push(ThumbnailHoverEffectExtract('image_sepia_100%_1%', effects[i]));
|
7438 | break;
|
7439 | case 'IMAGESEPIAOFF':
|
7440 | newEffects.push(ThumbnailHoverEffectExtract('image_sepia_1%_100%', effects[i]));
|
7441 | break;
|
7442 |
|
7443 | default:
|
7444 | newEffects.push(effects[i]);
|
7445 | break;
|
7446 | }
|
7447 | }
|
7448 |
|
7449 | return newEffects;
|
7450 | }
|
7451 |
|
7452 |
|
7453 |
|
7454 | function NewTHoverEffect() {
|
7455 | var oDef={
|
7456 | name: '',
|
7457 | element: '',
|
7458 | type: '',
|
7459 | from: '',
|
7460 | to: '',
|
7461 | hoverin: true,
|
7462 | hoverout: true,
|
7463 | firstKeyframe: true,
|
7464 | delay: 0,
|
7465 | delayBack: 0,
|
7466 | duration: 400,
|
7467 | durationBack: 300,
|
7468 | easing: 'easeOutQuart',
|
7469 | easingBack: 'easeOutQuart',
|
7470 | animParam: null
|
7471 | };
|
7472 | return oDef;
|
7473 | }
|
7474 |
|
7475 | function NewTBuildInit() {
|
7476 |
|
7477 | var oDef={ element: '', property: '', value: '' };
|
7478 | return oDef;
|
7479 | }
|
7480 |
|
7481 |
|
7482 | function ThumbnailStyle( cfg, level) {
|
7483 |
|
7484 | switch( cfg.position ){
|
7485 | case 'onBottom' :
|
7486 | G.tn.style[level]['label'] = 'bottom:0; ';
|
7487 | break;
|
7488 | case 'right' :
|
7489 | switch( cfg.valign ) {
|
7490 | case 'top':
|
7491 | G.tn.style[level]['label'] = 'top:0; position:absolute; left: 50%;';
|
7492 | break;
|
7493 | case 'middle':
|
7494 | G.tn.style[level]['label'] = 'top:0; bottom:0; left: 50%;';
|
7495 | G.tn.style[level]['title'] = 'position:absolute; bottom:50%;';
|
7496 | G.tn.style[level]['desc'] = 'position:absolute; top:50%;';
|
7497 | break;
|
7498 | case 'bottom':
|
7499 | default:
|
7500 | G.tn.style[level].label = 'bottom:0; position:absolute; left: 50%;';
|
7501 | G.tn.style[level].title = 'position:absolute;bottom:0;';
|
7502 | break;
|
7503 | }
|
7504 | break;
|
7505 | case 'custom':
|
7506 | break;
|
7507 | default:
|
7508 | case 'overImage' :
|
7509 | switch( cfg.valign ) {
|
7510 | case 'top':
|
7511 | G.tn.style[level]['label'] = 'top:0; position:absolute;';
|
7512 | break;
|
7513 | case 'middle':
|
7514 | G.tn.style[level]['label'] = 'top:0; bottom:0;';
|
7515 | G.tn.style[level]['title'] = 'position:absolute; bottom:50%;';
|
7516 | G.tn.style[level]['desc'] = 'position:absolute; top:50%;';
|
7517 | break;
|
7518 | case 'bottom':
|
7519 | default:
|
7520 |
|
7521 | G.tn.style[level].label = 'bottom:0; position:absolute;';
|
7522 | break;
|
7523 | }
|
7524 |
|
7525 |
|
7526 |
|
7527 |
|
7528 |
|
7529 |
|
7530 |
|
7531 |
|
7532 |
|
7533 |
|
7534 |
|
7535 |
|
7536 |
|
7537 |
|
7538 |
|
7539 |
|
7540 |
|
7541 | }
|
7542 |
|
7543 |
|
7544 | if( cfg.position != 'onBottom' ) {
|
7545 |
|
7546 | if( cfg.titleMultiLine ) {
|
7547 | G.tn.style[level]['title'] += 'white-space:normal;';
|
7548 | }
|
7549 | if( cfg.descriptionMultiLine ) {
|
7550 | G.tn.style[level]['desc'] += 'white-space:normal;';
|
7551 | }
|
7552 | }
|
7553 |
|
7554 |
|
7555 | switch( cfg.align ) {
|
7556 | case 'right':
|
7557 | G.tn.style[level].label += 'text-align:right;';
|
7558 | break;
|
7559 | case 'left':
|
7560 | G.tn.style[level].label += 'text-align:left;';
|
7561 | break;
|
7562 | default:
|
7563 | G.tn.style[level].label += 'text-align:center;';
|
7564 | break;
|
7565 | }
|
7566 |
|
7567 |
|
7568 | if( cfg.titleFontSize != undefined && cfg.titleFontSize != '' ) {
|
7569 | G.tn.style[level].title += 'font-size:' + cfg.titleFontSize + ';';
|
7570 | }
|
7571 | if( cfg.descriptionFontSize != undefined && cfg.descriptionFontSize != '' ) {
|
7572 | G.tn.style[level].desc += 'font-size:' + cfg.descriptionFontSize + ';';
|
7573 | }
|
7574 |
|
7575 | if( cfg.displayDescription == false ) {
|
7576 | G.tn.style[level].desc += 'display:none;';
|
7577 | }
|
7578 | }
|
7579 |
|
7580 |
|
7581 |
|
7582 | function ThumbnailDefCaches() {
|
7583 |
|
7584 |
|
7585 |
|
7586 | ThumbnailStyle( G.O.thumbnailLabel, 'lN');
|
7587 | if( G.O.thumbnailL1Label !== undefined ) {
|
7588 | ThumbnailStyle( G.O.thumbnailL1Label, 'l1');
|
7589 | }
|
7590 | else {
|
7591 | ThumbnailStyle( G.O.thumbnailLabel, 'l1');
|
7592 | }
|
7593 |
|
7594 | if( G.O.thumbnailL1Label && G.O.thumbnailL1Label.display ) {
|
7595 |
|
7596 | ThumbnailStyle( G.O.thumbnailL1Label, 'l1');
|
7597 | }
|
7598 |
|
7599 |
|
7600 |
|
7601 | var lst=['xs','sm','me','la','xl'];
|
7602 | for( var i = 0; i < lst.length; i++ ) {
|
7603 | var w = G.tn.settings.width.lN[lst[i]];
|
7604 | if( w != 'auto' ) {
|
7605 | G.tn.defaultSize.width.lN[lst[i]] = w;
|
7606 | G.tn.defaultSize.width.l1[lst[i]] = w;
|
7607 | }
|
7608 | else {
|
7609 | var h = G.tn.settings.height.lN[lst[i]];
|
7610 | G.tn.defaultSize.width.lN[lst[i]] = h;
|
7611 | G.tn.defaultSize.width.l1[lst[i]] = h;
|
7612 | }
|
7613 | }
|
7614 | for( var i = 0; i < lst.length; i++ ) {
|
7615 | var h = G.tn.settings.height.lN[lst[i]];
|
7616 | if( h != 'auto' ) {
|
7617 |
|
7618 | G.tn.defaultSize.height.lN[lst[i]] = h;
|
7619 | G.tn.defaultSize.height.l1[lst[i]] = h;
|
7620 | }
|
7621 | else {
|
7622 | var w = G.tn.settings.width.lN[lst[i]];
|
7623 | G.tn.defaultSize.height.lN[lst[i]] = w;
|
7624 | G.tn.defaultSize.height.l1[lst[i]] = w;
|
7625 | }
|
7626 | }
|
7627 |
|
7628 |
|
7629 | for( var i = 0; i < lst.length; i++ ) {
|
7630 | var w = G.tn.settings.width.l1[lst[i]];
|
7631 | if( w != 'auto' ) {
|
7632 | G.tn.defaultSize.width.l1[lst[i]] = w;
|
7633 | }
|
7634 | else {
|
7635 | var h = G.tn.settings.height.l1[lst[i]];
|
7636 | G.tn.defaultSize.width.l1[lst[i]] = h;
|
7637 | }
|
7638 | }
|
7639 | for( var i = 0; i < lst.length; i++ ) {
|
7640 | var h = G.tn.settings.height.l1[lst[i]];
|
7641 | if( h != 'auto' ) {
|
7642 |
|
7643 | G.tn.defaultSize.height.l1[lst[i]] = h;
|
7644 | }
|
7645 | else {
|
7646 | var w = G.tn.settings.width.l1[lst[i]];
|
7647 | G.tn.defaultSize.height.l1[lst[i]]= w ;
|
7648 | }
|
7649 | }
|
7650 |
|
7651 | }
|
7652 |
|
7653 |
|
7654 |
|
7655 | function GalleryThemeGetCurrent() {
|
7656 |
|
7657 | var cs=null;
|
7658 | switch(toType(G.O.galleryTheme)) {
|
7659 | case 'object':
|
7660 | cs = G.galleryTheme_dark;
|
7661 | jQuery.extend(true,cs,G.O.galleryTheme);
|
7662 | break;
|
7663 | case 'string':
|
7664 | switch( G.O.galleryTheme ) {
|
7665 | case 'light':
|
7666 | cs = G.galleryTheme_light;
|
7667 | break;
|
7668 | case 'default':
|
7669 | case 'dark':
|
7670 | case 'none':
|
7671 | default:
|
7672 | cs = G.galleryTheme_dark;
|
7673 | }
|
7674 | break;
|
7675 | default:
|
7676 | cs = G.galleryTheme_dark;
|
7677 | }
|
7678 | return cs;
|
7679 | }
|
7680 |
|
7681 |
|
7682 | function SetGalleryTheme() {
|
7683 |
|
7684 | if( typeof G.O.colorScheme !== 'undefined' ) {
|
7685 | G.O.galleryTheme = G.O.colorScheme;
|
7686 | }
|
7687 |
|
7688 | var cs = null;
|
7689 | var galleryTheme = '';
|
7690 | switch(toType(G.O.galleryTheme)) {
|
7691 | case 'object':
|
7692 | cs = G.galleryTheme_dark;
|
7693 | jQuery.extend(true,cs,G.O.galleryTheme);
|
7694 | galleryTheme='nanogallery_gallerytheme_custom_' + G.baseEltID;
|
7695 | break;
|
7696 | case 'string':
|
7697 | switch( G.O.galleryTheme ) {
|
7698 | case 'light':
|
7699 | cs = G.galleryTheme_light;
|
7700 | galleryTheme='nanogallery_gallerytheme_light_' + G.baseEltID;
|
7701 | break;
|
7702 | case 'default':
|
7703 | case 'dark':
|
7704 | case 'none':
|
7705 | default:
|
7706 | cs = G.galleryTheme_dark;
|
7707 | galleryTheme='nanogallery_gallerytheme_dark_' + G.baseEltID;
|
7708 | }
|
7709 | break;
|
7710 | default:
|
7711 | NanoAlert(G, 'Error in galleryTheme parameter.');
|
7712 | return;
|
7713 | }
|
7714 |
|
7715 |
|
7716 | var s1='.' + galleryTheme + ' ';
|
7717 |
|
7718 |
|
7719 | var c = cs.navigationBar;
|
7720 | var s=s1+'.nGY2Navigationbar { background:'+c.background+'; }'+'\n';
|
7721 | if( c.border !== undefined && c.border !== '' ) { s+=s1+'.nGY2Navigationbar { border:'+c.border+'; }'+'\n'; }
|
7722 | if( c.borderTop !== undefined && c.borderTop !== '' ) { s+=s1+'.nGY2Navigationbar { border-top:'+c.borderTop+'; }'+'\n'; }
|
7723 | if( c.borderBottom !== undefined && c.borderBottom !== '' ) { s+=s1+'.nGY2Navigationbar { border-bottom:'+c.borderBottom+'; }'+'\n'; }
|
7724 | if( c.borderRight !== undefined && c.borderRight !== '' ) { s+=s1+'.nGY2Navigationbar { border-right:'+c.borderRight+'; }'+'\n'; }
|
7725 | if( c.borderLeft !== undefined && c.borderLeft !== '' ) { s+=s1+'.nGY2Navigationbar { border-left:'+c.borderLeft+'; }'+'\n'; }
|
7726 |
|
7727 |
|
7728 | var c = cs.navigationBreadcrumb;
|
7729 | s+=s1+'.nGY2Breadcrumb { background:'+c.background+'; border-radius:'+c.borderRadius+'; }'+'\n';
|
7730 | s+=s1+'.nGY2Breadcrumb .oneItem { color:'+c.color+'; }'+'\n';
|
7731 | s+=s1+'.nGY2Breadcrumb .oneItem:hover { color:'+c.colorHover+'; }'+'\n';
|
7732 |
|
7733 |
|
7734 | var c = cs.navigationFilter;
|
7735 | s+=s1+'.nGY2NavFilterUnselected { color:'+c.color+'; background:'+c.background+'; border-radius:'+c.borderRadius+'; }'+'\n';
|
7736 | s+=s1+'.nGY2NavFilterSelected { color:'+c.colorSelected+'; background:'+c.backgroundSelected+'; border-radius:'+c.borderRadius+'; }'+'\n';
|
7737 | s+=s1+'.nGY2NavFilterSelectAll { color:'+c.colorSelected+'; background:'+c.background+'; border-radius:'+c.borderRadius+'; }'+'\n';
|
7738 |
|
7739 |
|
7740 | var c = cs.navigationPagination;
|
7741 | s+=s1+'.nGY2NavPagination { color:'+c.color+'; background:'+c.background+'; border-radius:'+c.borderRadius+'; }'+'\n';
|
7742 | s+=s1+'.nGY2NavPagination:hover { color:'+c.colorHover+'; }'+'\n';
|
7743 |
|
7744 |
|
7745 | var c = cs.thumbnail;
|
7746 |
|
7747 | s+=s1+'.nGY2GThumbnail { border-radius: '+c.borderRadius+'; background:'+c.background+'; border-color:'+c.borderColor+'; }'+'\n';
|
7748 | 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';
|
7749 | 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';
|
7750 | s+=s1+'.nGY2GThumbnailStack { background:'+c.stackBackground+'; }'+'\n';
|
7751 |
|
7752 | s+=s1+'.nGY2TnImgBack { background:'+c.background+'; background-image:'+c.backgroundImage+'; }'+'\n';
|
7753 | s+=s1+'.nGY2GThumbnailAlbumUp { background:'+c.background+'; background-image:'+c.backgroundImage+'; color:'+cs.thumbnail.titleColor+'; }'+'\n';
|
7754 | s+=s1+'.nGY2GThumbnailIconsFullThumbnail { color:'+c.titleColor+'; }\n';
|
7755 | s+=s1+'.nGY2GThumbnailLabel { background:'+c.labelBackground+'; opacity:'+c.labelOpacity+'; }'+'\n';
|
7756 | s+=s1+'.nGY2GThumbnailImageTitle { color:'+c.titleColor+'; background-color:'+c.titleBgColor+'; '+(c.titleShadow =='' ? '': 'Text-Shadow:'+c.titleShadow+';')+' }'+'\n';
|
7757 | s+=s1+'.nGY2GThumbnailAlbumTitle { color:'+c.titleColor+'; background-color:'+c.titleBgColor+'; '+(c.titleShadow =='' ? '': 'Text-Shadow:'+c.titleShadow+';')+' }'+'\n';
|
7758 | s+=s1+'.nGY2GThumbnailDescription { color:'+c.descriptionColor+'; background-color:'+c.descriptionBgColor+'; '+(c.descriptionShadow =='' ? '': 'Text-Shadow:'+c.descriptionShadow+';')+' }'+'\n';
|
7759 |
|
7760 |
|
7761 | var c = cs.thumbnailIcon;
|
7762 | s+=s1+'.nGY2GThumbnailIcons { padding:'+c.padding+'; }\n';
|
7763 | s+=s1+'.nGY2GThumbnailIcon { color:'+c.color+'; '+(c.shadow =='' ? '': 'Text-Shadow:'+c.shadow+';')+' }\n';
|
7764 | s+=s1+'.nGY2GThumbnailIconTextBadge { background-color:'+c.color+'; }\n';
|
7765 |
|
7766 |
|
7767 | var c = cs.pagination;
|
7768 | if( G.O.galleryPaginationMode != 'NUMBERS' ) {
|
7769 | s+=s1+'.nGY2paginationDot { border:'+c.shapeBorder+'; background:'+c.shapeColor+';}\n';
|
7770 | s+=s1+'.nGY2paginationDotCurrentPage { border:'+c.shapeBorder+'; background:'+c.shapeSelectedColor+';}\n';
|
7771 | s+=s1+'.nGY2paginationRectangle { border:'+c.shapeBorder+'; background:'+c.shapeColor+';}\n';
|
7772 | s+=s1+'.nGY2paginationRectangleCurrentPage { border:'+c.shapeBorder+'; background:'+c.shapeSelectedColor+';}\n';
|
7773 | } else {
|
7774 | s+=s1+'.nGY2paginationItem { background:'+c.background+'; color:'+c.color+'; border-radius:'+c.borderRadius+'; }\n';
|
7775 | s+=s1+'.nGY2paginationItemCurrentPage { background:'+c.background+'; color:'+c.color+'; border-radius:'+c.borderRadius+'; }\n';
|
7776 | s+=s1+'.nGY2PaginationPrev { background:'+c.background+'; color:'+c.color+'; border-radius:'+c.borderRadius+'; }\n';
|
7777 | s+=s1+'.nGY2PaginationNext { background:'+c.background+'; color:'+c.color+'; border-radius:'+c.borderRadius+'; }\n';
|
7778 | s+=s1+'.nGY2paginationItemCurrentPage { background:'+c.backgroundSelected+'; }\n';
|
7779 | }
|
7780 |
|
7781 |
|
7782 | var c = cs.thumbnail;
|
7783 |
|
7784 | 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';
|
7785 | s+=s1+'.nGY2GalleryMoreButtonAnnotation { color:'+c.titleColor+'; '+(c.titleShadow =='' ? '': 'Text-Shadow:'+c.titleShadow)+'; }\n';
|
7786 |
|
7787 | jQuery('head').append('<style id="ngycs_'+G.baseEltID+'">'+s+'</style>');
|
7788 | G.$E.base.addClass(galleryTheme);
|
7789 |
|
7790 | };
|
7791 |
|
7792 |
|
7793 | function SetViewerTheme( ) {
|
7794 |
|
7795 | if( G.VOM.viewerTheme != '' ) {
|
7796 | G.VOM.$baseCont.addClass(G.VOM.viewerTheme);
|
7797 | return;
|
7798 | }
|
7799 |
|
7800 | if( typeof G.O.colorSchemeViewer !== 'undefined' ) {
|
7801 | G.O.viewerTheme = G.O.colorSchemeViewer;
|
7802 | }
|
7803 |
|
7804 | var cs=null;
|
7805 | switch(toType(G.O.viewerTheme)) {
|
7806 | case 'object':
|
7807 | cs = G.viewerTheme_dark;
|
7808 | jQuery.extend(true, cs, G.O.viewerTheme);
|
7809 | G.VOM.viewerTheme = 'nanogallery_viewertheme_custom_' + G.baseEltID;
|
7810 | break;
|
7811 | case 'string':
|
7812 | switch( G.O.viewerTheme ) {
|
7813 | case 'none':
|
7814 | return;
|
7815 | break;
|
7816 | case 'light':
|
7817 | cs = G.viewerTheme_light;
|
7818 | G.VOM.viewerTheme = 'nanogallery_viewertheme_light_' + G.baseEltID;
|
7819 | break;
|
7820 | case 'dark':
|
7821 | case 'default':
|
7822 | cs = G.viewerTheme_dark;
|
7823 | G.VOM.viewerTheme = 'nanogallery_viewertheme_dark_' + G.baseEltID;
|
7824 | break;
|
7825 | }
|
7826 | break;
|
7827 | default:
|
7828 | NanoAlert(G, 'Error in viewerTheme parameter.');
|
7829 | return;
|
7830 | }
|
7831 |
|
7832 | var s1 = '.' + G.VOM.viewerTheme + ' ';
|
7833 | var s = s1 + '.nGY2Viewer { background:' + cs.background + '; }'+'\n';
|
7834 | s += s1 + '.nGY2Viewer .toolbarBackground { background:' + cs.barBackground + '; }'+'\n';
|
7835 | s += s1 + '.nGY2Viewer .toolbar { border:' + cs.barBorder + '; color:' + cs.barColor + '; }'+'\n';
|
7836 | s += s1 + '.nGY2Viewer .toolbar .previousButton:after { color:' + cs.barColor + '; }'+'\n';
|
7837 | s += s1 + '.nGY2Viewer .toolbar .nextButton:after { color:' + cs.barColor + '; }'+'\n';
|
7838 | s += s1 + '.nGY2Viewer .toolbar .closeButton:after { color:' + cs.barColor + '; }'+'\n';
|
7839 | s += s1 + '.nGY2Viewer .toolbar .label .title { color:' + cs.barColor + '; }'+'\n';
|
7840 | s += s1 + '.nGY2Viewer .toolbar .label .description { color:' + cs.barDescriptionColor + '; }'+'\n';
|
7841 | jQuery('head').append('<style>' + s + '</style>');
|
7842 | G.VOM.$baseCont.addClass(G.VOM.viewerTheme);
|
7843 | };
|
7844 |
|
7845 |
|
7846 |
|
7847 |
|
7848 | function SetPolyFills() {
|
7849 |
|
7850 |
|
7851 |
|
7852 | if (!Function.prototype.bind) {
|
7853 | Function.prototype.bind = function (oThis) {
|
7854 | if (typeof this !== "function") {
|
7855 |
|
7856 |
|
7857 | throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
7858 | }
|
7859 |
|
7860 | var aArgs = Array.prototype.slice.call(arguments, 1),
|
7861 | fToBind = this,
|
7862 | fNOP = function () {},
|
7863 | fBound = function () {
|
7864 | return fToBind.apply(this instanceof fNOP && oThis
|
7865 | ? this
|
7866 | : oThis,
|
7867 | aArgs.concat(Array.prototype.slice.call(arguments)));
|
7868 | };
|
7869 |
|
7870 | fNOP.prototype = this.prototype;
|
7871 | fBound.prototype = new fNOP();
|
7872 |
|
7873 | return fBound;
|
7874 | };
|
7875 | }
|
7876 |
|
7877 |
|
7878 |
|
7879 |
|
7880 |
|
7881 | (function() {
|
7882 | var lastTime = 0;
|
7883 | var vendors = ['ms', 'moz', 'webkit', 'o'];
|
7884 | for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
7885 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
7886 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
|
7887 | }
|
7888 | if (!window.requestAnimationFrame)
|
7889 | window.requestAnimationFrame = function(callback, element) {
|
7890 | var currTime = new Date().getTime();
|
7891 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
7892 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
|
7893 | lastTime = currTime + timeToCall;
|
7894 | return id;
|
7895 | };
|
7896 |
|
7897 | if (!window.cancelAnimationFrame)
|
7898 | window.cancelAnimationFrame = function(id) {
|
7899 | clearTimeout(id);
|
7900 | };
|
7901 | }());
|
7902 |
|
7903 |
|
7904 | Array.prototype.ngy2removeIf = function(callback) {
|
7905 | var i = this.length;
|
7906 | while (i--) {
|
7907 | if (callback(this[i], i)) {
|
7908 | this.splice(i, 1);
|
7909 | }
|
7910 | }
|
7911 | };
|
7912 |
|
7913 |
|
7914 |
|
7915 | if (!String.prototype.startsWith) {
|
7916 | String.prototype.startsWith = function(searchString, position) {
|
7917 | position = position || 0;
|
7918 | return this.indexOf(searchString, position) === position;
|
7919 | };
|
7920 | }
|
7921 |
|
7922 | }
|
7923 |
|
7924 |
|
7925 |
|
7926 | function GalleryClicked(e) {
|
7927 |
|
7928 | var r = GalleryEventRetrieveElementl(e, false);
|
7929 |
|
7930 | if( r.GOMidx == -1 ) { return 'exit'; }
|
7931 |
|
7932 | var idx = G.GOM.items[r.GOMidx].thumbnailIdx;
|
7933 | if( G.GOM.slider.hostIdx == r.GOMidx ) {
|
7934 | idx = G.GOM.items[G.GOM.slider.currentIdx].thumbnailIdx;
|
7935 | }
|
7936 | switch( r.action ) {
|
7937 | case 'OPEN':
|
7938 | ThumbnailOpen(idx, false);
|
7939 | return 'exit';
|
7940 | break;
|
7941 | case 'DISPLAY':
|
7942 |
|
7943 | ThumbnailOpen(idx, true);
|
7944 | return 'exit';
|
7945 | break;
|
7946 | case 'TOGGLESELECT':
|
7947 | ThumbnailSelectionToggle(idx);
|
7948 | return 'exit';
|
7949 | break;
|
7950 | case 'SHARE':
|
7951 | PopupShare(idx);
|
7952 | return 'exit';
|
7953 | break;
|
7954 | case 'DOWNLOAD':
|
7955 | DownloadImage(idx);
|
7956 | return 'exit';
|
7957 | break;
|
7958 | case 'INFO':
|
7959 | ItemDisplayInfo(G.I[idx]);
|
7960 | return 'exit';
|
7961 | break;
|
7962 | case 'SHOPPINGCART':
|
7963 | AddToCart(idx, 'gallery');
|
7964 | return 'exit';
|
7965 | break;
|
7966 | default:
|
7967 |
|
7968 | var fu = G.O.fnThumbnailToolCustAction;
|
7969 | if( fu !== null ) {
|
7970 | typeof fu == 'function' ? fu(r.action, G.I[idx]) : window[fu](r.action, G.I[idx]);
|
7971 | }
|
7972 | break;
|
7973 | }
|
7974 | }
|
7975 |
|
7976 |
|
7977 | function DownloadImage(idx) {
|
7978 | if( G.I[idx].mediaKind != 'img' ) { return; }
|
7979 |
|
7980 |
|
7981 | var url = G.I[idx].src;
|
7982 |
|
7983 | if( G.I[idx].downloadURL != undefined && G.I[idx].downloadURL != '' ) {
|
7984 | url = G.I[idx].downloadURL;
|
7985 | }
|
7986 |
|
7987 | var a = document.createElement('a');
|
7988 | a.href = url;
|
7989 |
|
7990 | a.download = url.split('/').pop();
|
7991 | a.target = '_blank';
|
7992 | a.style.display = 'none';
|
7993 | document.body.appendChild(a);
|
7994 | a.click();
|
7995 | document.body.removeChild(a);
|
7996 |
|
7997 | }
|
7998 |
|
7999 |
|
8000 | function AddToCart( idx, source ) {
|
8001 |
|
8002 | var found=false;
|
8003 | for( var i=0; i<G.shoppingCart.length; i++ ) {
|
8004 | if( G.shoppingCart[i].idx == idx ) {
|
8005 | G.shoppingCart[i].qty++;
|
8006 | ThumbnailBuildToolbarOneCartUpdate( G.I[idx] );
|
8007 |
|
8008 | var fu = G.O.fnShoppingCartUpdated;
|
8009 | if( fu !== null ) {
|
8010 | typeof fu == 'function' ? fu(G.shoppingCart, G.I[idx], source) : window[fu](G.shoppingCart, G.I[idx], source);
|
8011 | }
|
8012 | TriggerCustomEvent('shoppingCartUpdated');
|
8013 | return;
|
8014 | }
|
8015 | }
|
8016 |
|
8017 |
|
8018 | if( !found) {
|
8019 | G.shoppingCart.push( { idx:idx, ID:G.I[idx].GetID(), qty:1} );
|
8020 | ThumbnailBuildToolbarOneCartUpdate(G.I[idx]);
|
8021 |
|
8022 | var fu=G.O.fnShoppingCartUpdated;
|
8023 | if( fu !== null ) {
|
8024 | typeof fu == 'function' ? fu(G.shoppingCart, G.I[idx], source) : window[fu](G.shoppingCart, G.I[idx], source);
|
8025 | }
|
8026 | TriggerCustomEvent('shoppingCartUpdated');
|
8027 | }
|
8028 | }
|
8029 |
|
8030 |
|
8031 |
|
8032 | function ThumbnailSelectionClear() {
|
8033 | G.GOM.nbSelected = 0;
|
8034 | for( var i = 0, nbTn = G.GOM.items.length; i < nbTn ; i++ ) {
|
8035 | var item = G .I[G.GOM.items[i].thumbnailIdx];
|
8036 | if( item.selected ) {
|
8037 | item.selected = false;
|
8038 | var fu = G.O.fnThumbnailSelection;
|
8039 | if( fu !== null ) {
|
8040 | typeof fu == 'function' ? fu(item.$elt, item, G.I) : window[fu](item.$elt, item, G.I);
|
8041 | }
|
8042 | }
|
8043 | item.selected = false;
|
8044 | }
|
8045 | }
|
8046 |
|
8047 | function ThumbnailSelectionToggle( idx ){
|
8048 | var item = G.I[idx];
|
8049 | if( item.selected === true ) {
|
8050 | ThumbnailSelectionSet(item, false);
|
8051 | G.GOM.nbSelected--;
|
8052 | TriggerCustomEvent('itemUnSelected');
|
8053 | }
|
8054 | else {
|
8055 | ThumbnailSelectionSet(item, true);
|
8056 | G.GOM.nbSelected++;
|
8057 | TriggerCustomEvent('itemSelected');
|
8058 | }
|
8059 | }
|
8060 |
|
8061 |
|
8062 |
|
8063 | function ThumbnailSelectionSet(item, selected ){
|
8064 |
|
8065 | item.selected = selected;
|
8066 |
|
8067 | ThumbnailSelectionSetIcon( item );
|
8068 |
|
8069 |
|
8070 | var fu=G.O.fnThumbnailSelection;
|
8071 | if( fu !== null ) {
|
8072 | typeof fu == 'function' ? fu(item.$elt, item, G.I) : window[fu](item.$elt, item, G.I);
|
8073 | }
|
8074 |
|
8075 | }
|
8076 |
|
8077 | function ThumbnailSelectionSetIcon( item ) {
|
8078 | if( item.$elt == null ) {
|
8079 |
|
8080 | return;
|
8081 | }
|
8082 | var $sub = item.$getElt('.nGY2GThumbnail');
|
8083 | var $icon = item.$getElt('.nGY2GThumbnailIconImageSelect');
|
8084 | if( item.selected === true) {
|
8085 | $sub.addClass('nGY2GThumbnailSubSelected');
|
8086 | $icon.addClass('nGY2ThumbnailSelected');
|
8087 | $icon.removeClass('nGY2ThumbnailUnselected');
|
8088 | $icon.html(G.O.icons.thumbnailSelected);
|
8089 | }
|
8090 | else {
|
8091 | $sub.removeClass('nGY2GThumbnailSubSelected');
|
8092 | $icon.removeClass('nGY2ThumbnailSelected');
|
8093 | $icon.addClass('nGY2ThumbnailUnselected');
|
8094 | $icon.html(G.O.icons.thumbnailUnselected);
|
8095 | }
|
8096 | }
|
8097 |
|
8098 |
|
8099 |
|
8100 | function PopupShare(idx) {
|
8101 |
|
8102 |
|
8103 |
|
8104 |
|
8105 | var item=G.I[idx];
|
8106 |
|
8107 | var currentURL=document.location.protocol + '//' + document.location.hostname + document.location.pathname;
|
8108 | var newLocationHash = '#nanogallery/' + G.baseEltID + '/';
|
8109 | if( item.kind == 'image' ) {
|
8110 | newLocationHash += item.albumID + '/' + item.GetID();
|
8111 | }
|
8112 | else {
|
8113 | newLocationHash += item.GetID();
|
8114 | }
|
8115 |
|
8116 | var content = '<br><br>';
|
8117 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="facebook">' + G.O.icons.shareFacebook + '</div>';
|
8118 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="pinterest">' + G.O.icons.sharePinterest + '</div>';
|
8119 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="tumblr">' + G.O.icons.shareTumblr + '</div>';
|
8120 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="twitter">' + G.O.icons.shareTwitter + '</div>';
|
8121 |
|
8122 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="vk">' + G.O.icons.shareVK + '</div>';
|
8123 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="mail">' + G.O.icons.shareMail + '</div>';
|
8124 | content += '<div class="nGY2PopupOneItem" style="text-align:center;"></div>';
|
8125 | content += '<input class="nGY2PopupOneItemText" readonly type="text" value="' + currentURL+newLocationHash + '" style="width:100%;text-align:center;">';
|
8126 | content += '<br>';
|
8127 |
|
8128 | currentURL = encodeURIComponent(document.location.protocol + '//' + document.location.hostname + document.location.pathname + newLocationHash);
|
8129 |
|
8130 | var currentTitle = item.title;
|
8131 | var currentTn = item.thumbImg().src;
|
8132 |
|
8133 |
|
8134 | Popup('nanogallery2 - share to:', content, 'Center');
|
8135 |
|
8136 | G.popup.$elt.find('.nGY2PopupOneItem').on('click', function(e) {
|
8137 | e.stopPropagation();
|
8138 |
|
8139 | var shareURL = '';
|
8140 | var found = true;
|
8141 | switch(jQuery(this).attr('data-share').toUpperCase()) {
|
8142 | case 'FACEBOOK':
|
8143 |
|
8144 |
|
8145 | shareURL = 'https://www.facebook.com/sharer.php?u=' + currentURL;
|
8146 | break;
|
8147 | case 'VK':
|
8148 | shareURL = 'http://vk.com/share.php?url=' + currentURL;
|
8149 | break;
|
8150 | case 'GOOGLEPLUS':
|
8151 | shareURL = "https://plus.google.com/share?url=" + currentURL;
|
8152 | break;
|
8153 | case 'TWITTER':
|
8154 |
|
8155 | shareURL = 'https://twitter.com/intent/tweet?text=' + currentTitle + 'url=' + currentURL;
|
8156 | break;
|
8157 | case 'PINTEREST':
|
8158 |
|
8159 | shareURL = 'https://pinterest.com/pin/create/button/?media=' + currentTn + '&url=' + currentURL + '&description=' + currentTitle;
|
8160 | break;
|
8161 | case 'TUMBLR':
|
8162 |
|
8163 | shareURL = 'http://www.tumblr.com/share/link?url=' + currentURL + '&name=' + currentTitle;
|
8164 | break;
|
8165 | case 'MAIL':
|
8166 | shareURL = 'mailto:?subject=' + currentTitle + '&body=' + currentURL;
|
8167 | break;
|
8168 | default:
|
8169 | found = false;
|
8170 | break;
|
8171 | }
|
8172 |
|
8173 | if( found ) {
|
8174 | window.open(shareURL, "" , "height=550,width=500,left=100,top=100,menubar=0" );
|
8175 | G.popup.close();
|
8176 |
|
8177 | }
|
8178 |
|
8179 | });
|
8180 | }
|
8181 |
|
8182 |
|
8183 | function Popup(title, content, align) {
|
8184 | var pp = '<div class="nGY2Popup" style="opacity:0;"><div class="nGY2PopupContent' + align + '">';
|
8185 | pp += '<div class="nGY2PopupCloseButton" style="font-size:0.9em;">' + G.O.icons.buttonClose + '</div>';
|
8186 | pp += '<div class="nGY2PopupTitle">' + title + '</div>';
|
8187 | pp += content;
|
8188 | pp += '</div></div>';
|
8189 |
|
8190 | G.popup.$elt = jQuery(pp).appendTo('body');
|
8191 | setElementOnTop( G.VOM.$viewer, G.popup.$elt);
|
8192 |
|
8193 | G.popup.isDisplayed = true;
|
8194 |
|
8195 | var tweenable = new NGTweenable();
|
8196 | tweenable.tween({
|
8197 | from: { o: 0, y: 100 },
|
8198 | to: { o: 1, y: 0 },
|
8199 | easing: 'easeInOutSine',
|
8200 | duration: 250,
|
8201 | step: function (state, att) {
|
8202 | G.popup.$elt[0].style.opacity = state.o;
|
8203 | G.popup.$elt[0].style[G.CSStransformName] = 'translateY(' + (state.y) + 'px)';
|
8204 | }
|
8205 | });
|
8206 |
|
8207 | G.popup.$elt.find('.nGY2PopupCloseButton').on('click', function(e) {
|
8208 | e.stopPropagation();
|
8209 | G.popup.close();
|
8210 | });
|
8211 |
|
8212 | }
|
8213 |
|
8214 |
|
8215 | function GalleryMouseEnter(e) {
|
8216 | if( !G.VOM.viewerDisplayed && G.GOM.albumIdx != -1 ) {
|
8217 | var r = GalleryEventRetrieveElementl(e, true);
|
8218 |
|
8219 | if( r.GOMidx != -1 ) {
|
8220 |
|
8221 |
|
8222 | ThumbnailHover(r.GOMidx);
|
8223 | }
|
8224 | }
|
8225 | }
|
8226 |
|
8227 | function GalleryMouseLeave(e) {
|
8228 | if( !G.VOM.viewerDisplayed && G.GOM.albumIdx != -1 ) {
|
8229 | var r = GalleryEventRetrieveElementl(e, true);
|
8230 | if( r.GOMidx != -1 ) {
|
8231 |
|
8232 |
|
8233 | ThumbnailHoverOut(r.GOMidx);
|
8234 | }
|
8235 | }
|
8236 | }
|
8237 |
|
8238 | function GalleryEventRetrieveElementl( e, ignoreSubItems ) {
|
8239 | var r = { action: 'NONE', GOMidx: -1 };
|
8240 |
|
8241 | if( e == undefined ) {
|
8242 | return r;
|
8243 | }
|
8244 | var target = e.target || e.srcElement;
|
8245 | while( target != G.$E.conTnParent[0] ) {
|
8246 | if( jQuery(target).hasClass('nGY2GThumbnail') ) {
|
8247 | if( r.action == 'NONE' ) {
|
8248 | r.action = 'OPEN';
|
8249 | }
|
8250 | r.GOMidx = jQuery(target).data('index');
|
8251 | return r;
|
8252 | }
|
8253 |
|
8254 | if( !ignoreSubItems ) {
|
8255 | var a = jQuery(target).data('ngy2action');
|
8256 | if( a != '' && a != undefined ) {
|
8257 | r.action = a;
|
8258 | }
|
8259 | }
|
8260 | if( target.parentNode == null ) {
|
8261 | return r;
|
8262 | }
|
8263 | target = target.parentNode;
|
8264 | }
|
8265 | return r;
|
8266 | }
|
8267 |
|
8268 |
|
8269 |
|
8270 | function ThumbnailOpen( idx, ignoreSelected ) {
|
8271 | var item = G.I[idx];
|
8272 |
|
8273 | G.GOM.albumIdxLoading = idx;
|
8274 |
|
8275 | var fu = G.O.fnThumbnailClicked;
|
8276 | if( fu !== null ) {
|
8277 | typeof fu == 'function' ? fu(item.$elt, item) : window[fu](item.$elt, item);
|
8278 | }
|
8279 |
|
8280 |
|
8281 | if( item.destinationURL !== undefined && item.destinationURL.length > 0 ) {
|
8282 | window.location = item.destinationURL;
|
8283 | return;
|
8284 | }
|
8285 |
|
8286 | switch( item.kind ) {
|
8287 | case 'image':
|
8288 | if( ignoreSelected === false && G.GOM.nbSelected > 0 ) {
|
8289 | ThumbnailSelectionToggle(idx);
|
8290 | }
|
8291 | else {
|
8292 |
|
8293 | DisplayPhotoIdx( idx );
|
8294 | }
|
8295 | break;
|
8296 | case 'album':
|
8297 | if( ignoreSelected === false && G.GOM.nbSelected > 0 ) {
|
8298 | ThumbnailSelectionToggle( idx );
|
8299 | }
|
8300 | else {
|
8301 | if( G.O.thumbnailAlbumDisplayImage && idx != 0 ) {
|
8302 |
|
8303 | DisplayFirstMediaInAlbum( idx );
|
8304 | return;
|
8305 | }
|
8306 | else {
|
8307 |
|
8308 | DisplayAlbum('-1', item.GetID());
|
8309 | }
|
8310 | }
|
8311 | break;
|
8312 | case 'albumUp':
|
8313 | var parent = NGY2Item.Get(G, item.albumID);
|
8314 | DisplayAlbum('-1', parent.albumID);
|
8315 | break;
|
8316 | }
|
8317 | }
|
8318 |
|
8319 | function DisplayFirstMediaInAlbum( albumIdx ) {
|
8320 | if( G.O.debugMode ) { console.log('#DisplayFirstPhotoInAlbum : '+ albumIdx); }
|
8321 |
|
8322 | var item = G.I[albumIdx];
|
8323 |
|
8324 | var l = G.I.length;
|
8325 | for( var i = 0; i < l; i++ ) {
|
8326 | if( G.I[i].albumID == item.GetID() ) {
|
8327 | DisplayPhotoIdx( i );
|
8328 | return;
|
8329 | }
|
8330 | }
|
8331 |
|
8332 |
|
8333 | AlbumGetContent( item.GetID(), DisplayFirstMediaInAlbum, albumIdx, null );
|
8334 |
|
8335 | }
|
8336 |
|
8337 |
|
8338 |
|
8339 | function OpenOriginal( item ) {
|
8340 | switch( G.O.kind ) {
|
8341 | case 'flickr':
|
8342 | var sU = 'https://www.flickr.com/photos/' + G.O.userID + '/' + item.GetID();
|
8343 | if( item.albumID != '0' ) {
|
8344 | sU += '/in/album-' + item.albumID + '/';
|
8345 | }
|
8346 | window.open(sU, '_blank');
|
8347 | break;
|
8348 | case 'picasa':
|
8349 | case 'google':
|
8350 | case 'google2':
|
8351 |
|
8352 |
|
8353 |
|
8354 |
|
8355 | default:
|
8356 | var sU = item.responsiveURL();
|
8357 | window.open(sU, '_blank');
|
8358 | break;
|
8359 | }
|
8360 | }
|
8361 |
|
8362 |
|
8363 |
|
8364 |
|
8365 |
|
8366 | function DisplayPhotoIdx( ngy2ItemIdx ) {
|
8367 |
|
8368 | if( !G.O.thumbnailOpenInLightox ) { return; }
|
8369 |
|
8370 | if( G.O.thumbnailOpenOriginal ) {
|
8371 |
|
8372 | OpenOriginal( G.I[ngy2ItemIdx] );
|
8373 | return;
|
8374 | }
|
8375 |
|
8376 | var items = [];
|
8377 |
|
8378 | G.VOM.content.current.vIdx = 0;
|
8379 | G.VOM.items = [];
|
8380 | G.VOM.albumID = G.I[ngy2ItemIdx].albumID;
|
8381 |
|
8382 | var vimg = new VImg(ngy2ItemIdx);
|
8383 | G.VOM.items.push(vimg);
|
8384 | items.push(G.I[ngy2ItemIdx]);
|
8385 |
|
8386 | var l = G.I.length;
|
8387 | for( let idx = ngy2ItemIdx+1; idx < l ; idx++) {
|
8388 | let item = G.I[idx];
|
8389 | if( item.kind == 'image' && item.isToDisplay(G.VOM.albumID) && item.destinationURL == '' ) {
|
8390 | let vimg = new VImg(idx);
|
8391 | G.VOM.items.push(vimg);
|
8392 | items.push(item);
|
8393 | }
|
8394 | }
|
8395 | var last = G.VOM.items.length;
|
8396 | var cnt = 1;
|
8397 | for( let idx = 0; idx < ngy2ItemIdx ; idx++) {
|
8398 | let item = G.I[idx];
|
8399 | if( item.kind == 'image' && item.isToDisplay(G.VOM.albumID) && item.destinationURL == '' ) {
|
8400 | let vimg = new VImg(idx);
|
8401 | vimg.mediaNumber = cnt;
|
8402 | G.VOM.items.push(vimg);
|
8403 | items.push(item);
|
8404 | cnt++;
|
8405 | }
|
8406 | }
|
8407 | for( let i = 0; i < last; i++ ) {
|
8408 | G.VOM.items[i].mediaNumber = cnt;
|
8409 | cnt++;
|
8410 | }
|
8411 |
|
8412 |
|
8413 | var fu = G.O.fnThumbnailOpen;
|
8414 | if( fu !== null ) {
|
8415 | typeof fu == 'function' ? fu(items) : window[fu](items);
|
8416 | return;
|
8417 | }
|
8418 |
|
8419 |
|
8420 | if( !G.VOM.viewerDisplayed ) {
|
8421 |
|
8422 | LightboxOpen();
|
8423 | }
|
8424 | else {
|
8425 |
|
8426 | G.VOM.content.current.$media.empty();
|
8427 | let item = G.VOM.content.current.NGY2Item();
|
8428 | var spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
8429 | if( item.mediaKind == 'img' && item.imageWidth != 0 && item.imageHeight != 0 ) {
|
8430 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
8431 | }
|
8432 | G.VOM.content.current.$media.append( spreloader + item.mediaMarkup);
|
8433 | ViewerSetMediaVisibility(G.VOM.content.next, 0);
|
8434 | ViewerSetMediaVisibility(G.VOM.content.previous, 0);
|
8435 | if( item.mediaKind == 'img' ) {
|
8436 | G.VOM.ImageLoader.loadImage(VieweImgSizeRetrieved, item);
|
8437 | }
|
8438 |
|
8439 |
|
8440 |
|
8441 |
|
8442 | LightboxDisplay('');
|
8443 | }
|
8444 | }
|
8445 |
|
8446 | function ViewerZoomStart() {
|
8447 | if( G.O.viewerZoom && !G.VOM.viewerMediaIsChanged ) {
|
8448 | var item = G.VOM.content.current.NGY2Item();
|
8449 | if( item.mediaKind == 'img' && item.imageHeight > 0 && item.imageWidth > 0 ) {
|
8450 | if( G.VOM.zoom.isZooming === false ) {
|
8451 |
|
8452 | G.VOM.zoom.userFactor = 1;
|
8453 | G.VOM.zoom.isZooming = true;
|
8454 | }
|
8455 | return true;
|
8456 | }
|
8457 | }
|
8458 | return false;
|
8459 | }
|
8460 |
|
8461 | function ViewerZoomIn( zoomIn ) {
|
8462 | if( zoomIn ) {
|
8463 |
|
8464 | G.VOM.zoom.userFactor += 0.1;
|
8465 | ViewerZoomMax();
|
8466 | }
|
8467 | else {
|
8468 |
|
8469 | G.VOM.zoom.userFactor -= 0.1;
|
8470 | ViewerZoomMin();
|
8471 | }
|
8472 | ViewerMediaSetPosAndZoom();
|
8473 | }
|
8474 |
|
8475 | function ViewerZoomMax() {
|
8476 | if( G.VOM.zoom.userFactor > 3 ) {
|
8477 | G.VOM.zoom.userFactor = 3;
|
8478 | }
|
8479 | }
|
8480 | function ViewerZoomMin() {
|
8481 |
|
8482 | if( G.VOM.zoom.userFactor < 0.2 ) {
|
8483 | G.VOM.zoom.userFactor = 0.2;
|
8484 | }
|
8485 | }
|
8486 |
|
8487 |
|
8488 |
|
8489 |
|
8490 | function ViewerMediaSetPosAndZoom() {
|
8491 |
|
8492 | if( !G.VOM.zoom.isZooming ) {
|
8493 | G.VOM.zoom.userFactor = 1;
|
8494 | }
|
8495 |
|
8496 | ViewerMediaSetPosAndZoomOne( G.VOM.content.current, true );
|
8497 | ViewerMediaSetPosAndZoomOne( G.VOM.content.previous, false );
|
8498 | ViewerMediaSetPosAndZoomOne( G.VOM.content.next, false );
|
8499 |
|
8500 | }
|
8501 |
|
8502 |
|
8503 |
|
8504 |
|
8505 | function ViewerMediaCenterNotImg( $mediaContainer ) {
|
8506 | var $media = $mediaContainer.children().eq(1);
|
8507 | var h = 90;
|
8508 | if( G.O.viewerGallery != 'none' ) { h -= 10; }
|
8509 | if( G.O.viewerToolbar.display != 'none' ) { h -= 10; }
|
8510 | $media.css( {'height': h+'%' });
|
8511 | $media.css( {'width': '90%' });
|
8512 | $media[0].style[G.CSStransformName] = 'translate(0px, "50%") ';
|
8513 | }
|
8514 |
|
8515 |
|
8516 | function ViewerMediaSetPosAndZoomOne(content_item, isCurrent ) {
|
8517 |
|
8518 | var item = content_item.NGY2Item();
|
8519 | var $img = content_item.$media;
|
8520 |
|
8521 |
|
8522 | if( item.mediaKind != 'img' ) {
|
8523 | ViewerMediaCenterNotImg( $img );
|
8524 | return;
|
8525 | }
|
8526 |
|
8527 | if( item.imageHeight == 0 || item.imageWidth == 0 ) {
|
8528 |
|
8529 | ViewerSetMediaVisibility( content_item, 0 );
|
8530 | return;
|
8531 | }
|
8532 |
|
8533 |
|
8534 | var zoomUserFactor = isCurrent == true ? G.VOM.zoom.userFactor : 1;
|
8535 |
|
8536 | var dpr = 1;
|
8537 | if( G.O.viewerImageDisplay == 'bestImageQuality' ) {
|
8538 | dpr = window.devicePixelRatio;
|
8539 | }
|
8540 |
|
8541 |
|
8542 | var zoomBaseFactorW = (G.VOM.window.lastWidth - G.VOM.padding.V) / (item.imageWidth / dpr);
|
8543 | var zoomBaseFactorH = (G.VOM.window.lastHeight - G.VOM.padding.H) / (item.imageHeight / dpr);
|
8544 | var zoomBaseFactor = Math.min(zoomBaseFactorW, zoomBaseFactorH);
|
8545 | if( zoomBaseFactor > 1 && G.O.viewerImageDisplay != 'upscale' ) {
|
8546 |
|
8547 | zoomBaseFactor = 1;
|
8548 | }
|
8549 |
|
8550 | var imageCurrentHeight = (item.imageHeight / dpr) * zoomUserFactor * zoomBaseFactor;
|
8551 | var imageCurrentWidth = (item.imageWidth / dpr) * zoomUserFactor * zoomBaseFactor;
|
8552 | $img.children().eq(1).css( {'height': imageCurrentHeight });
|
8553 | $img.children().eq(1).css( {'width': imageCurrentWidth });
|
8554 |
|
8555 |
|
8556 | var posX = 0;
|
8557 | if( imageCurrentWidth > G.VOM.window.lastWidth ) {
|
8558 | posX = -(imageCurrentWidth - G.VOM.window.lastWidth)/2;
|
8559 | }
|
8560 | var posY = 0;
|
8561 |
|
8562 |
|
8563 |
|
8564 |
|
8565 |
|
8566 |
|
8567 | if( isCurrent ) {
|
8568 | if( !G.VOM.zoom.isZooming ) {
|
8569 | G.VOM.panPosX = 0;
|
8570 | G.VOM.panPosY = 0;
|
8571 | }
|
8572 | G.VOM.zoom.posX = posX;
|
8573 | G.VOM.zoom.posY = posY;
|
8574 | ViewerImagePanSetPosition(G.VOM.panPosX, G.VOM.panPosY, $img, false);
|
8575 | }
|
8576 |
|
8577 |
|
8578 |
|
8579 | else {
|
8580 |
|
8581 | ViewerMediaPanX( G.VOM.swipePosX );
|
8582 | $img.children().eq(1)[0].style[G.CSStransformName]= 'translate(0px, 0px) rotate('+ item.rotationAngle +'deg)';
|
8583 | }
|
8584 |
|
8585 | }
|
8586 |
|
8587 |
|
8588 |
|
8589 | function ViewerImagePanSetPosition(posX, posY, imageContainer, savePosition ) {
|
8590 | if( savePosition ) {
|
8591 | G.VOM.panPosX = posX;
|
8592 | G.VOM.panPosY = posY;
|
8593 | }
|
8594 |
|
8595 | posX += G.VOM.zoom.posX;
|
8596 | posY += G.VOM.zoom.posY;
|
8597 |
|
8598 |
|
8599 | imageContainer.children().eq(1)[0].style[G.CSStransformName]= 'translate('+ posX + 'px, '+ posY + 'px) rotate('+ G.VOM.content.current.NGY2Item().rotationAngle +'deg)';
|
8600 |
|
8601 |
|
8602 | }
|
8603 |
|
8604 |
|
8605 |
|
8606 |
|
8607 | function LightboxOpen( idx ) {
|
8608 |
|
8609 |
|
8610 | G.GOM.firstDisplay = false;
|
8611 |
|
8612 |
|
8613 | jQuery('head').append('<style id="nGY2_body_scrollbar_style" type="text/css">.nGY2_body_scrollbar{margin-right: ' + (window.innerWidth - document.documentElement.clientWidth) + 'px;}</style>');
|
8614 | jQuery("body").addClass("nGY2_body_scrollbar");
|
8615 |
|
8616 |
|
8617 | G.VOM.$baseCont = jQuery('<div class="nGY2 nGY2ViewerContainer" style="opacity:1"></div>').appendTo('body');
|
8618 |
|
8619 | SetViewerTheme();
|
8620 |
|
8621 | G.VOM.$viewer = jQuery('<div class="nGY2Viewer" style="opacity:0" itemscope itemtype="http://schema.org/ImageObject"></div>').appendTo( G.VOM.$baseCont );
|
8622 | G.VOM.$viewer.css({ msTouchAction: 'none', touchAction: 'none' });
|
8623 |
|
8624 | if( idx == undefined ) {
|
8625 | G.VOM.content.current.vIdx = 0;
|
8626 | }
|
8627 | else {
|
8628 | G.VOM.content.current.vIdx = idx;
|
8629 | }
|
8630 | G.VOM.content.previous.vIdx = G.VOM.IdxNext();
|
8631 | G.VOM.content.next.vIdx = G.VOM.IdxPrevious();
|
8632 |
|
8633 | var sMedia = '<div class="nGY2ViewerMediaPan"><div class="nGY2ViewerMediaLoaderDisplayed"></div>' + G.VOM.content.previous.NGY2Item().mediaMarkup + '</div>';
|
8634 | sMedia += '<div class="nGY2ViewerMediaPan"><div class="nGY2ViewerMediaLoaderDisplayed"></div>' + G.VOM.content.current.NGY2Item().mediaMarkup + '</div>';
|
8635 | sMedia += '<div class="nGY2ViewerMediaPan"><div class="nGY2ViewerMediaLoaderDisplayed"></div>' + G.VOM.content.next.NGY2Item().mediaMarkup + '</div>';
|
8636 |
|
8637 | var sNav = '';
|
8638 | var iconP = G.O.icons.viewerImgPrevious;
|
8639 | if( iconP != undefined && iconP != '') {
|
8640 | sNav += '<div class="nGY2ViewerAreaPrevious ngy2viewerToolAction" data-ngy2action="previous">' + iconP + '</div>';
|
8641 | }
|
8642 | var iconN = G.O.icons.viewerImgNext;
|
8643 | if( iconN != undefined && iconN != '') {
|
8644 | sNav += '<div class="nGY2ViewerAreaNext ngy2viewerToolAction" data-ngy2action="next">' + iconN + '</div>';
|
8645 | }
|
8646 |
|
8647 | G.VOM.$content = jQuery('<div class="nGY2ViewerContent">' + sMedia + sNav + '</div>').appendTo( G.VOM.$viewer );
|
8648 |
|
8649 | G.VOM.$buttonLeft = G.VOM.$content.find('.nGY2ViewerAreaPrevious');
|
8650 | G.VOM.$buttonRight = G.VOM.$content.find('.nGY2ViewerAreaNext');
|
8651 |
|
8652 | var $mediaPan = G.VOM.$content.find('.nGY2ViewerMediaPan');
|
8653 | G.VOM.content.previous.$media = $mediaPan.eq(0);
|
8654 | G.VOM.content.current.$media = $mediaPan.eq(1);
|
8655 | G.VOM.content.next.$media = $mediaPan.eq(2);
|
8656 |
|
8657 |
|
8658 | var vP = G.GOM.cache.viewport;
|
8659 | G.VOM.content.previous.$media[0].style[G.CSStransformName] = 'translate(-' + vP.w + 'px, 0px)';
|
8660 | G.VOM.content.next.$media[0].style[G.CSStransformName] = 'translate(' + vP.w + 'px, 0px)';
|
8661 |
|
8662 |
|
8663 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, G.VOM.content.current.NGY2Item() );
|
8664 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, G.VOM.content.previous.NGY2Item() );
|
8665 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, G.VOM.content.next.NGY2Item() );
|
8666 |
|
8667 | G.VOM.padding.H = parseInt(G.VOM.$content.css("padding-left")) + parseInt(G.VOM.$content.css("padding-right"));
|
8668 | G.VOM.padding.V = parseInt(G.VOM.$content.css("padding-top")) + parseInt(G.VOM.$content.css("padding-bottom"));
|
8669 |
|
8670 |
|
8671 | var vtbBg1 = '';
|
8672 | var vtbBg2 = ' toolbarBackground';
|
8673 | if( G.O.viewerToolbar.fullWidth ) {
|
8674 | vtbBg1 = ' toolbarBackground';
|
8675 | vtbBg2 = '';
|
8676 | }
|
8677 | var vtbAlign = 'text-align:center;';
|
8678 | switch ( G.O.viewerToolbar.align ) {
|
8679 | case 'left':
|
8680 | vtbAlign = 'text-align:left;';
|
8681 | break;
|
8682 | case 'right':
|
8683 | vtbAlign = 'text-align:right;';
|
8684 | break;
|
8685 | }
|
8686 | var sTB = '<div class="toolbarContainer nGEvent' + vtbBg1 + '" style="visibility:' +(G.O.viewerToolbar.display ? "visible" : "hidden")+';'+vtbAlign+'"><div class="toolbar nGEvent' + vtbBg2 + '"></div></div>';
|
8687 | G.VOM.$toolbar = jQuery(sTB).appendTo(G.VOM.$viewer);
|
8688 |
|
8689 | if( G.VOM.toolbarMode == 'min' || (G.O.viewerToolbar.autoMinimize > 0 && G.O.viewerToolbar.autoMinimize >= G.GOM.cache.viewport.w) ) {
|
8690 | ViewerToolbarForVisibilityMin();
|
8691 | }
|
8692 | else {
|
8693 | ViewerToolbarForVisibilityStd();
|
8694 | }
|
8695 |
|
8696 |
|
8697 | var sTopLeft = '<div class="nGY2ViewerToolsTopLeft nGEvent"><div class="toolbar nGEvent">';
|
8698 | var sTL = G.O.viewerTools.topLeft.split(',');
|
8699 | for( var i = 0, sTLL = sTL.length; i < sTLL; i++) {
|
8700 | sTopLeft += ToolbarAddElt( sTL[i] );
|
8701 | }
|
8702 | sTopLeft += '</div></div>';
|
8703 | G.VOM.$toolbarTL = jQuery(sTopLeft).appendTo(G.VOM.$viewer);
|
8704 |
|
8705 |
|
8706 | var sTopRight = '<div class="nGY2ViewerToolsTopRight nGEvent"><div class="toolbar nGEvent">';
|
8707 | var sTR = G.O.viewerTools.topRight.split(',');
|
8708 | for( var i = 0, sTRL = sTR.length; i < sTRL; i++) {
|
8709 | sTopRight += ToolbarAddElt( sTR[i] );
|
8710 | }
|
8711 | sTopRight += '</div></div>';
|
8712 | G.VOM.$toolbarTR = jQuery(sTopRight).appendTo(G.VOM.$viewer);
|
8713 |
|
8714 |
|
8715 | ViewerToolsOn();
|
8716 |
|
8717 |
|
8718 | if( ngscreenfull.enabled && G.O.viewerFullscreen ) {
|
8719 | ngscreenfull.request();
|
8720 | G.VOM.viewerIsFullscreen=true;
|
8721 | }
|
8722 |
|
8723 |
|
8724 | LightboxGalleryBuild();
|
8725 |
|
8726 | setElementOnTop('', G.VOM.$viewer);
|
8727 | ResizeLightbox(true);
|
8728 | G.VOM.gallery.Resize();
|
8729 | G.VOM.timeImgChanged = new Date().getTime();
|
8730 |
|
8731 |
|
8732 | G.VOM.$toolbarTL.css('opacity', 0);
|
8733 | G.VOM.$toolbarTR.css('opacity', 0);
|
8734 | G.VOM.$buttonLeft.css('opacity', 0);
|
8735 | G.VOM.$buttonRight.css('opacity', 0);
|
8736 | if( G.O.viewerGallery != 'none' ) { G.VOM.gallery.$elt.css('opacity', 0); }
|
8737 | G.VOM.$content.css('opacity', 0);
|
8738 | G.VOM.$toolbarTR[0].style[G.CSStransformName] = 'translateY(-40px) ';
|
8739 | G.VOM.$toolbarTL[0].style[G.CSStransformName] = 'translateY(-40px) ';
|
8740 | G.VOM.$buttonLeft[0].style[G.CSStransformName] = 'translateX(-40px) ';
|
8741 | G.VOM.$buttonRight[0].style[G.CSStransformName] = 'translateX(40px) ';
|
8742 |
|
8743 |
|
8744 | new NGTweenable().tween({
|
8745 | from: { opacity: 0, posY: G.VOM.window.lastHeight*.5 },
|
8746 | to: { opacity: 1, posY: 0 },
|
8747 | delay: 10,
|
8748 | duration: 450,
|
8749 | easing: 'easeInOutQuint',
|
8750 | step: function (state) {
|
8751 |
|
8752 | G.VOM.$viewer.css('opacity', state.opacity);
|
8753 | G.VOM.$viewer[0].style[G.CSStransformName] = 'translateY(' + (state.posY) + 'px) ';
|
8754 |
|
8755 |
|
8756 | G.VOM.$content.css('opacity', state.opacity);
|
8757 | }
|
8758 | });
|
8759 |
|
8760 |
|
8761 |
|
8762 | new NGTweenable().tween({
|
8763 | from: { posY: -40, opacity: 0, scale: 3 },
|
8764 | to: { posY: 0, opacity: 1, scale: 1 },
|
8765 | delay: 300,
|
8766 | duration: 400,
|
8767 | easing: 'easeInOutQuint',
|
8768 | step: function (state) {
|
8769 |
|
8770 |
|
8771 | G.VOM.$toolbarTR[0].style[G.CSStransformName] = 'translateY(' + (state.posY) + 'px) ';
|
8772 | G.VOM.$toolbarTL[0].style[G.CSStransformName] = 'translateY(' + (state.posY) + 'px) ';
|
8773 | G.VOM.$buttonLeft[0].style[G.CSStransformName] = 'translateX(' + (state.posY) + 'px) ';
|
8774 | G.VOM.$buttonRight[0].style[G.CSStransformName] = 'translateX(' + (-state.posY) + 'px) ';
|
8775 |
|
8776 |
|
8777 | if( G.O.viewerGallery != 'none' ) {
|
8778 | G.VOM.gallery.$elt.css({ opacity: state.opacity });
|
8779 | G.VOM.gallery.$elt[0].style[G.CSStransformName] = 'scale('+state.scale+')';
|
8780 | }
|
8781 |
|
8782 | },
|
8783 | finish: function() {
|
8784 | G.VOM.viewerDisplayed = true;
|
8785 | ViewerMediaPanX(0);
|
8786 | ViewerSetEvents();
|
8787 |
|
8788 | LightboxDisplay('');
|
8789 |
|
8790 | if( G.O.slideshowAutoStart ) {
|
8791 | G.VOM.playSlideshow = false;
|
8792 | SlideshowToggle();
|
8793 | }
|
8794 |
|
8795 | ViewerToolsUnHide();
|
8796 | LightboxDisplayFinalize('');
|
8797 | }
|
8798 | });
|
8799 |
|
8800 |
|
8801 |
|
8802 |
|
8803 |
|
8804 |
|
8805 |
|
8806 |
|
8807 |
|
8808 |
|
8809 |
|
8810 |
|
8811 |
|
8812 |
|
8813 |
|
8814 |
|
8815 |
|
8816 |
|
8817 | }
|
8818 |
|
8819 | function ViewerEvents() {
|
8820 | if( !G.VOM.viewerDisplayed || G.VOM.viewerMediaIsChanged ) {
|
8821 |
|
8822 |
|
8823 | return false;
|
8824 | }
|
8825 | return true;
|
8826 | }
|
8827 |
|
8828 |
|
8829 | function LightboxGalleryBuild() {
|
8830 |
|
8831 | G.VOM.gallery.firstDisplay = true;
|
8832 |
|
8833 | if( G.O.viewerGallery != 'none' ) {
|
8834 |
|
8835 | var tw = G.O.viewerGalleryTWidth;
|
8836 | var th = G.O.viewerGalleryTHeight;
|
8837 | var gutter = 2;
|
8838 |
|
8839 | var t = '';
|
8840 | for( var i=0; i< G.VOM.items.length; i++) {
|
8841 | var idx = G.VOM.items[i].ngy2ItemIdx;
|
8842 | var o = G.I[idx];
|
8843 | var src = (o.thumbImg().src).replace(/'/g, "%27");
|
8844 | 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>';
|
8845 | }
|
8846 | G.VOM.gallery.gwidth = (tw+2*gutter) * G.VOM.items.length;
|
8847 | G.VOM.gallery.oneTmbWidth = tw+2*gutter;
|
8848 | 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>";
|
8849 | 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);
|
8850 | G.VOM.gallery.$tmbCont = G.VOM.gallery.$elt.find('.nGY2VThumbnailContainer')
|
8851 |
|
8852 | G.VOM.gallery.Resize();
|
8853 | G.VOM.gallery.SetThumbnailActive();
|
8854 |
|
8855 | }
|
8856 | }
|
8857 |
|
8858 |
|
8859 |
|
8860 | function ViewerSetEvents() {
|
8861 |
|
8862 | if( G.VOM.hammertime == null ) {
|
8863 |
|
8864 | G.VOM.hammertime = new NGHammer.Manager(G.VOM.$baseCont[0], {
|
8865 |
|
8866 | recognizers: [
|
8867 | [NGHammer.Pinch, { enable: true }],
|
8868 | [NGHammer.Pan, { direction: NGHammer.DIRECTION_ALL }]
|
8869 | ]
|
8870 | });
|
8871 |
|
8872 |
|
8873 | G.VOM.hammertime.on('pan', function(ev) {
|
8874 | if( !ViewerEvents() ) { return; }
|
8875 |
|
8876 |
|
8877 | if( G.VOM.panMode == 'off' ) {
|
8878 |
|
8879 | if( ev.target.dataset.ngy2_lightbox_thumbnail != undefined || ev.target.dataset.ngy2_lightbox_gallery != undefined ){
|
8880 | G.VOM.panMode = 'gallery';
|
8881 | }
|
8882 | else {
|
8883 | if( G.VOM.zoom.isZooming ) {
|
8884 | G.VOM.panMode = 'zoom';
|
8885 | }
|
8886 | else {
|
8887 | G.VOM.panMode = 'media';
|
8888 | }
|
8889 | }
|
8890 | }
|
8891 |
|
8892 |
|
8893 | switch( G.VOM.panMode ) {
|
8894 | case 'zoom':
|
8895 |
|
8896 | ViewerImagePanSetPosition(G.VOM.panPosX + ev.deltaX, G.VOM.panPosY + ev.deltaY, G.VOM.content.current.$media, false);
|
8897 | G.VOM.toolsHide();
|
8898 | break;
|
8899 |
|
8900 | case 'media':
|
8901 | if( Math.abs(ev.deltaY) > G.VOM.panThreshold && Math.abs(ev.deltaX) < G.VOM.panThreshold && !G.VOM.panXOnly ) {
|
8902 |
|
8903 | ViewerMediaPanX( 0 );
|
8904 | var dist = 0;
|
8905 | if( ev.deltaY < 0 ) {
|
8906 |
|
8907 | dist = Math.max( ev.deltaY, -200);
|
8908 | }
|
8909 | else {
|
8910 |
|
8911 | dist = Math.min( ev.deltaY, 200);
|
8912 | }
|
8913 | G.VOM.$viewer[0].style[G.CSStransformName] = 'translateY(' + dist + 'px) ';
|
8914 | G.VOM.$viewer.css('opacity', 1-Math.abs(dist)/200/2);
|
8915 | }
|
8916 | else {
|
8917 |
|
8918 | if( Math.abs(ev.deltaX) > G.VOM.panThreshold ) {
|
8919 | G.VOM.panXOnly = true;
|
8920 | }
|
8921 | ViewerMediaPanX( ev.deltaX );
|
8922 | G.VOM.$viewer[0].style[G.CSStransformName] = 'translateY(0px)';
|
8923 | G.VOM.$viewer.css('opacity', 1);
|
8924 | }
|
8925 | break;
|
8926 |
|
8927 | case 'gallery':
|
8928 | G.VOM.gallery.PanGallery( ev.deltaX );
|
8929 | break;
|
8930 | }
|
8931 |
|
8932 | });
|
8933 |
|
8934 |
|
8935 | G.VOM.hammertime.on('panend', function(ev) {
|
8936 | if( !ViewerEvents() ) { return; }
|
8937 |
|
8938 | switch( G.VOM.panMode ) {
|
8939 | case 'zoom':
|
8940 |
|
8941 | G.VOM.timeImgChanged = new Date().getTime();
|
8942 | ViewerImagePanSetPosition( G.VOM.panPosX+ev.deltaX, G.VOM.panPosY+ev.deltaY, G.VOM.content.current.$media, true);
|
8943 | break;
|
8944 | case 'media':
|
8945 | var panY = false;
|
8946 | if( !G.VOM.panXOnly ) {
|
8947 | if( Math.abs(ev.deltaY) > 50 && Math.abs(ev.deltaX) < 50 ) {
|
8948 |
|
8949 | LightboxClose();
|
8950 | panY = true;
|
8951 | }
|
8952 | }
|
8953 | if( !panY ) {
|
8954 | if( Math.abs( ev.deltaX ) < 50 ) {
|
8955 | ViewerMediaPanX(0);
|
8956 | }
|
8957 | else {
|
8958 | ev.deltaX > 50 ? DisplayPreviousMedia( Math.abs(ev.velocityX) ) : DisplayNextMedia( Math.abs(ev.velocityX) );
|
8959 | }
|
8960 | }
|
8961 | G.VOM.panXOnly = false;
|
8962 | break;
|
8963 | case 'gallery':
|
8964 |
|
8965 | G.VOM.gallery.posX += ev.deltaX;
|
8966 | G.VOM.gallery.PanGallery( 0 );
|
8967 | G.VOM.gallery.PanGalleryEnd( ev.velocityX );
|
8968 | break;
|
8969 | }
|
8970 |
|
8971 | G.VOM.panMode = 'off';
|
8972 | });
|
8973 |
|
8974 |
|
8975 |
|
8976 | if( G.O.viewerZoom ) {
|
8977 |
|
8978 | G.VOM.hammertime.add( new NGHammer.Tap({ event: 'doubletap', taps: 2, interval: 250 }) );
|
8979 | G.VOM.hammertime.add( new NGHammer.Tap({ event: 'singletap' }) );
|
8980 | G.VOM.hammertime.get('doubletap').recognizeWith('singletap');
|
8981 | G.VOM.hammertime.get('singletap').requireFailure('doubletap');
|
8982 |
|
8983 |
|
8984 | G.VOM.hammertime.on('singletap', function(ev) {
|
8985 |
|
8986 | if( !ViewerEvents() ) { return; }
|
8987 |
|
8988 |
|
8989 | if( ev.target.dataset.ngy2_lightbox_thumbnail != undefined ){
|
8990 |
|
8991 | var idx = parseInt(ev.target.dataset.ngy2_idx);
|
8992 | var vidx = parseInt(ev.target.dataset.ngy2_vidx);
|
8993 |
|
8994 | if( !isNaN(idx) && vidx != G.VOM.content.current.vIdx ) {
|
8995 |
|
8996 | if( vidx > G.VOM.content.current.vIdx ) {
|
8997 | TriggerCustomEvent('lightboxNextImage');
|
8998 |
|
8999 |
|
9000 | G.VOM.content.next.$media.empty();
|
9001 | var nextItem = G.I[idx];
|
9002 | G.VOM.content.next.vIdx = vidx;
|
9003 | let spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
9004 | if( nextItem.mediaKind == 'img' && nextItem.imageWidth != 0 && nextItem.imageHeight != 0 ) {
|
9005 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
9006 | }
|
9007 | G.VOM.content.next.$media.append( spreloader + nextItem.mediaMarkup );
|
9008 | if( nextItem.mediaKind == 'img' ) {
|
9009 | G.VOM.ImageLoader.loadImage(VieweImgSizeRetrieved, nextItem);
|
9010 | }
|
9011 | else {
|
9012 | ViewerMediaCenterNotImg( G.VOM.content.next.$media );
|
9013 | }
|
9014 | LightboxDisplay('nextImage');
|
9015 |
|
9016 | }
|
9017 | else {
|
9018 | TriggerCustomEvent('lightboxPreviousImage');
|
9019 |
|
9020 |
|
9021 | G.VOM.content.previous.$media.empty();
|
9022 | var previousItem = G.I[idx];
|
9023 | G.VOM.content.previous.vIdx = vidx;
|
9024 | let spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
9025 | if( previousItem.mediaKind == 'img' && previousItem.imageWidth != 0 && previousItem.imageHeight != 0 ) {
|
9026 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
9027 | }
|
9028 | G.VOM.content.previous.$media.append( spreloader + previousItem.mediaMarkup );
|
9029 | if( previousItem.mediaKind == 'img' ) {
|
9030 | G.VOM.ImageLoader.loadImage(VieweImgSizeRetrieved, previousItem);
|
9031 | }
|
9032 | else {
|
9033 | ViewerMediaCenterNotImg( G.VOM.content.previous.$media );
|
9034 | }
|
9035 | LightboxDisplay('previousImage');
|
9036 | }
|
9037 | return;
|
9038 | }
|
9039 | }
|
9040 |
|
9041 |
|
9042 | StopPropagationPreventDefault(ev.srcEvent);
|
9043 | if( G.VOM.toolbarsDisplayed == false ) {
|
9044 | debounce( ViewerToolsUnHide, 100, false)();
|
9045 | G.VOM.singletapTime = new Date().getTime();
|
9046 | }
|
9047 | else {
|
9048 |
|
9049 | if( (new Date().getTime()) - G.VOM.singletapTime < 400 ) { return; }
|
9050 |
|
9051 | if( G.VOM.content.current.NGY2Item().mediaKind == 'img' && ev.target.className.indexOf('nGY2ViewerMedia') !== -1 ) {
|
9052 | var x =0;
|
9053 | if( ev.srcEvent instanceof MouseEvent ) {
|
9054 | x = ev.srcEvent.pageX;
|
9055 | }
|
9056 | else {
|
9057 | x = ev.srcEvent.changedTouches[0].pageX;
|
9058 | }
|
9059 | if( x < (G.GOM.cache.viewport.w/2) ) {
|
9060 | DisplayPreviousMedia();
|
9061 | }
|
9062 | else {
|
9063 | DisplayNextMedia();
|
9064 | }
|
9065 | }
|
9066 | }
|
9067 | });
|
9068 |
|
9069 |
|
9070 | G.VOM.hammertime.on('doubletap', function(ev) {
|
9071 | if( !ViewerEvents() ) { return; }
|
9072 | StopPropagationPreventDefault(ev.srcEvent);
|
9073 |
|
9074 | if( ev.target.className.indexOf('nGY2ViewerMedia') !== -1 ) {
|
9075 |
|
9076 | if( G.VOM.zoom.isZooming ) {
|
9077 | G.VOM.zoom.isZooming = false;
|
9078 |
|
9079 | ResizeLightbox(true);
|
9080 | }
|
9081 | else {
|
9082 | if( ViewerZoomStart() ) {
|
9083 | G.VOM.zoom.userFactor = 1.5;
|
9084 | ViewerMediaSetPosAndZoom();
|
9085 | }
|
9086 | }
|
9087 | }
|
9088 | });
|
9089 |
|
9090 |
|
9091 | G.VOM.hammertime.on('pinchend', function(ev) {
|
9092 | ev.srcEvent.stopPropagation();
|
9093 | ev.srcEvent.preventDefault();
|
9094 | G.VOM.timeImgChanged = new Date().getTime();
|
9095 | });
|
9096 | G.VOM.hammertime.on('pinch', function(ev) {
|
9097 | ev.srcEvent.stopPropagation();
|
9098 | ev.srcEvent.preventDefault();
|
9099 |
|
9100 | if( ViewerZoomStart() ) {
|
9101 | G.VOM.zoom.userFactor = ev.scale;
|
9102 | ViewerZoomMax();
|
9103 | ViewerZoomMin();
|
9104 | ViewerMediaSetPosAndZoom();
|
9105 | }
|
9106 | });
|
9107 | }
|
9108 |
|
9109 |
|
9110 | else {
|
9111 |
|
9112 |
|
9113 | G.VOM.hammertime.add( new NGHammer.Tap({ event: 'singletap' }) );
|
9114 |
|
9115 |
|
9116 |
|
9117 | G.VOM.hammertime.on('singletap', function(ev) {
|
9118 | if( !ViewerEvents() ) { return; }
|
9119 | StopPropagationPreventDefault( ev.srcEvent );
|
9120 | if( G.VOM.toolbarsDisplayed == false ){
|
9121 |
|
9122 | debounce( ViewerToolsUnHide, 100, false)();
|
9123 | G.VOM.singletapTime = new Date().getTime();
|
9124 | }
|
9125 | else {
|
9126 |
|
9127 | if( (new Date().getTime()) - G.VOM.singletapTime < 400 ) { return; }
|
9128 | if( ev.target.className.indexOf('nGY2ViewerMedia') !== -1 ) {
|
9129 | var x = 0;
|
9130 | if( ev.srcEvent instanceof MouseEvent ) {
|
9131 | x = ev.srcEvent.pageX;
|
9132 | }
|
9133 | else {
|
9134 | x = ev.srcEvent.changedTouches[0].pageX;
|
9135 | }
|
9136 | if( x < (G.GOM.cache.viewport.w/2) ) {
|
9137 | DisplayPreviousMedia();
|
9138 | }
|
9139 | else {
|
9140 | DisplayNextMedia();
|
9141 | }
|
9142 | }
|
9143 | }
|
9144 |
|
9145 | });
|
9146 | }
|
9147 | }
|
9148 | }
|
9149 |
|
9150 |
|
9151 | function StopPropagationPreventDefault(e) {
|
9152 | e.stopPropagation();
|
9153 | e.preventDefault();
|
9154 | }
|
9155 |
|
9156 |
|
9157 | function ViewerToolsHide() {
|
9158 | if( G.VOM.viewerDisplayed ) {
|
9159 | G.VOM.toolbarsDisplayed = false;
|
9160 | ViewerToolsOpacity(0);
|
9161 | }
|
9162 | }
|
9163 |
|
9164 | function ViewerToolsUnHide() {
|
9165 | if( G.VOM.viewerDisplayed ) {
|
9166 | G.VOM.toolbarsDisplayed = true;
|
9167 | ViewerToolsOpacity(1);
|
9168 | G.VOM.toolsHide();
|
9169 | }
|
9170 | }
|
9171 |
|
9172 | function ViewerToolsOpacity( op ) {
|
9173 | if( G.VOM.$toolbar != null ) {
|
9174 | G.VOM.$toolbar.css('opacity', op);
|
9175 | }
|
9176 | if( G.VOM.$toolbarTL != null ) {
|
9177 | G.VOM.$toolbarTL.css('opacity', op);
|
9178 | }
|
9179 | if( G.VOM.$toolbarTR != null ) {
|
9180 | G.VOM.$toolbarTR.css('opacity', op);
|
9181 | }
|
9182 |
|
9183 |
|
9184 | G.VOM.$content.find('.nGY2ViewerAreaNext').css('opacity', op);
|
9185 | G.VOM.$content.find('.nGY2ViewerAreaPrevious').css('opacity', op);
|
9186 |
|
9187 |
|
9188 |
|
9189 | }
|
9190 |
|
9191 |
|
9192 |
|
9193 | function ViewerToolsOn() {
|
9194 |
|
9195 | G.VOM.$viewer.off('touchstart click', '.ngy2viewerToolAction', ViewerToolsAction);
|
9196 |
|
9197 |
|
9198 | G.VOM.$viewer.on('touchstart click', '.ngy2viewerToolAction', ViewerToolsAction);
|
9199 | }
|
9200 |
|
9201 |
|
9202 |
|
9203 | function ViewerToolsAction(e) {
|
9204 |
|
9205 | if( (new Date().getTime()) - G.timeLastTouchStart < 300 ) { return; }
|
9206 | G.timeLastTouchStart = new Date().getTime();
|
9207 |
|
9208 | var $this = $(this);
|
9209 | var ngy2action = $this.data('ngy2action');
|
9210 | if( ngy2action == undefined ) { return; }
|
9211 | switch( ngy2action ) {
|
9212 | case 'next':
|
9213 | StopPropagationPreventDefault(e);
|
9214 | DisplayNextMedia();
|
9215 | break;
|
9216 | case 'previous':
|
9217 | StopPropagationPreventDefault(e);
|
9218 | DisplayPreviousMedia();
|
9219 | break;
|
9220 | case 'playPause':
|
9221 | e.stopPropagation();
|
9222 | SlideshowToggle();
|
9223 | break;
|
9224 | case 'zoomIn':
|
9225 | StopPropagationPreventDefault(e);
|
9226 | if( ViewerZoomStart() ) { ViewerZoomIn( true ); }
|
9227 | break;
|
9228 | case 'zoomOut':
|
9229 | StopPropagationPreventDefault(e);
|
9230 | if( ViewerZoomStart() ) { ViewerZoomIn( false ); }
|
9231 | break;
|
9232 | case 'minimize':
|
9233 |
|
9234 | StopPropagationPreventDefault(e);
|
9235 | if( G.VOM.toolbarMode == 'std' ) {
|
9236 | ViewerToolbarForVisibilityMin();
|
9237 | }
|
9238 | else {
|
9239 | ViewerToolbarForVisibilityStd();
|
9240 | }
|
9241 | break;
|
9242 | case 'fullScreen':
|
9243 |
|
9244 | e.stopPropagation();
|
9245 | if( ngscreenfull.enabled ) {
|
9246 | ngscreenfull.toggle();
|
9247 | }
|
9248 | break;
|
9249 | case 'info':
|
9250 | e.stopPropagation();
|
9251 | ItemDisplayInfo( G.VOM.content.current.NGY2Item() );
|
9252 | break;
|
9253 | case 'close':
|
9254 | StopPropagationPreventDefault(e);
|
9255 | if( (new Date().getTime()) - G.VOM.timeImgChanged < 400 ) { return; }
|
9256 | LightboxClose();
|
9257 | break;
|
9258 | case 'download':
|
9259 | StopPropagationPreventDefault(e);
|
9260 | DownloadImage(G.VOM.items[G.VOM.content.current.vIdx].ngy2ItemIdx);
|
9261 | break;
|
9262 | case 'share':
|
9263 | StopPropagationPreventDefault(e);
|
9264 | PopupShare(G.VOM.items[G.VOM.content.current.vIdx].ngy2ItemIdx);
|
9265 | break;
|
9266 | case 'linkOriginal':
|
9267 | StopPropagationPreventDefault(e);
|
9268 | OpenOriginal( G.VOM.content.current.NGY2Item() );
|
9269 | break;
|
9270 | case 'rotateLeft':
|
9271 | StopPropagationPreventDefault(e);
|
9272 | ViewerImageRotate(-90);
|
9273 | break;
|
9274 | case 'rotateRight':
|
9275 | StopPropagationPreventDefault(e);
|
9276 | ViewerImageRotate(90);
|
9277 | break;
|
9278 | case 'shoppingcart':
|
9279 | StopPropagationPreventDefault(e);
|
9280 | AddToCart( G.VOM.items[G.VOM.content.current.vIdx].ngy2ItemIdx, 'lightbox');
|
9281 | break;
|
9282 | }
|
9283 |
|
9284 |
|
9285 | var fu = G.O.fnImgToolbarCustClick;
|
9286 | if( ngy2action.indexOf('custom') == 0 && fu !== null ) {
|
9287 | typeof fu == 'function' ? fu(ngy2action, $this, G.VOM.content.current.NGY2Item() ) : window[fu](ngy2action, $this, G.VOM.content.current.NGY2Item() );
|
9288 | }
|
9289 | }
|
9290 |
|
9291 |
|
9292 | function ViewerImageRotate( angle ) {
|
9293 | var item = G.VOM.content.current.NGY2Item();
|
9294 | if( item.mediaKind == 'img' ) {
|
9295 | item.rotationAngle += angle;
|
9296 | item.rotationAngle = item.rotationAngle % 360;
|
9297 | if( item.rotationAngle < 0 ) {
|
9298 | item.rotationAngle += 360;
|
9299 | }
|
9300 | ViewerMediaPanX( 0 );
|
9301 | ViewerMediaSetPosAndZoomOne( G.VOM.content.current, true );
|
9302 | }
|
9303 | }
|
9304 |
|
9305 |
|
9306 |
|
9307 | function ItemDisplayInfo( ng2item ) {
|
9308 |
|
9309 | var content = '<div class="nGY2PopupOneItem">' + ng2item.title + '</div>';
|
9310 | content += '<div class="nGY2PopupOneItemText">' + ng2item.description + '</div>';
|
9311 | if( ng2item.author != '' ) {
|
9312 | content += '<div class="nGY2PopupOneItemText">' + G.O.icons.user + ' ' + ng2item.author + '</div>';
|
9313 | }
|
9314 | if( ng2item.exif.model != '' ) {
|
9315 | content += '<div class="nGY2PopupOneItemText">' + G.O.icons.config + ' ' + ng2item.exif.model + '</div>';
|
9316 | }
|
9317 | var sexif = G.O.icons.picture + ':';
|
9318 | if( ng2item.exif.flash != '' || ng2item.exif.focallength != '' || ng2item.exif.fstop != '' || ng2item.exif.exposure != '' || ng2item.exif.iso != '' || ng2item.exif.time != '' ) {
|
9319 | sexif += '<br>';
|
9320 | sexif += ng2item.exif.flash == '' ? '' : ' ' + ng2item.exif.flash;
|
9321 | sexif += ng2item.exif.focallength == '' ? '' : ' ' + ng2item.exif.focallength+'mm';
|
9322 | sexif += ng2item.exif.fstop == '' ? '' : ' f' + ng2item.exif.fstop;
|
9323 | sexif += ng2item.exif.exposure == '' ? '' : ' ' + ng2item.exif.exposure+'s';
|
9324 | sexif += ng2item.exif.iso == '' ? '' : ' ' + ng2item.exif.iso+' ISO';
|
9325 | if( ng2item.exif.time != '' ) {
|
9326 |
|
9327 |
|
9328 | sexif += ' ' + ng2item.exif.time;
|
9329 | }
|
9330 | }
|
9331 | else {
|
9332 | sexif += ' n/a';
|
9333 | }
|
9334 | content += '<div class="nGY2PopupOneItemText">' + sexif + '</div>';
|
9335 |
|
9336 | if( ng2item.exif.location != '' ) {
|
9337 | 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>';
|
9338 |
|
9339 | 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>';
|
9340 | }
|
9341 | else {
|
9342 | content += '<div class="nGY2PopupOneItemText">' + G.O.icons.location + ': n/a</div>';
|
9343 | }
|
9344 |
|
9345 | var r = { title: G.O.icons.viewerInfo, content: content };
|
9346 |
|
9347 |
|
9348 | var fu = G.O.fnPopupMediaInfo;
|
9349 | if( fu !== null ) {
|
9350 | typeof fu == 'function' ? r=fu(ng2item, r.title, r.content) : r=window[fu](ng2item, r.title, r.content);
|
9351 | }
|
9352 |
|
9353 |
|
9354 | Popup( r.title, r.content, 'Left');
|
9355 |
|
9356 | }
|
9357 |
|
9358 |
|
9359 |
|
9360 | function ToolbarAddElt( elt ) {
|
9361 | var r = '<div class="ngbt ngy2viewerToolAction ',
|
9362 | e=elt.replace(/^\s+|\s+$/g, '');
|
9363 | switch( e ) {
|
9364 | case 'minimizeButton':
|
9365 | case 'minimize':
|
9366 | var ic = G.O.icons.viewerToolbarMin;
|
9367 | if( G.VOM.toolbarMode == 'min' ) {
|
9368 | ic = G.O.icons.viewerToolbarStd;
|
9369 | }
|
9370 | r += 'minimizeButton nGEvent" data-ngy2action="minimize">'+ic+'</div>';
|
9371 | break;
|
9372 | case 'previousButton':
|
9373 | case 'previous':
|
9374 | r += 'previousButton nGEvent" data-ngy2action="previous">'+ G.O.icons.viewerPrevious +'</div>';
|
9375 | break;
|
9376 | case 'pageCounter':
|
9377 | r += 'pageCounter nGEvent"></div>';
|
9378 | break;
|
9379 | case 'nextButton':
|
9380 | case 'next':
|
9381 | r += 'nextButton nGEvent" data-ngy2action="next">'+ G.O.icons.viewerNext +'</div>';
|
9382 | break;
|
9383 | case 'playPauseButton':
|
9384 | case 'playPause':
|
9385 | r += 'playButton playPauseButton nGEvent" data-ngy2action="playPause">'+ G.O.icons.viewerPlay +'</div>';
|
9386 | break;
|
9387 | case 'rotateLeft':
|
9388 | r += 'rotateLeftButton nGEvent" data-ngy2action="rotateLeft">'+ G.O.icons.viewerRotateLeft +'</div>';
|
9389 | break;
|
9390 | case 'rotateRight':
|
9391 | r += 'rotateRightButton nGEvent" data-ngy2action="rotateRight">'+ G.O.icons.viewerRotateRight +'</div>';
|
9392 | break;
|
9393 | case 'downloadButton':
|
9394 | case 'download':
|
9395 | r += 'downloadButton nGEvent" data-ngy2action="download">'+ G.O.icons.viewerDownload +'</div>';
|
9396 | break;
|
9397 | case 'zoomButton':
|
9398 | case 'zoom':
|
9399 | r += 'nGEvent" data-ngy2action="zoomIn">'+ G.O.icons.viewerZoomIn +'</div><div class="ngbt ngy2viewerToolAction nGEvent" data-ngy2action="zoomOut">'+ G.O.icons.viewerZoomOut +'</div>';
|
9400 | break;
|
9401 | case 'fullscreenButton':
|
9402 | case 'fullscreen':
|
9403 | var s = G.O.icons.viewerFullscreenOn;
|
9404 | if( ngscreenfull.enabled && G.VOM.viewerIsFullscreen ) {
|
9405 | s = G.O.icons.viewerFullscreenOff;
|
9406 | }
|
9407 | r += 'setFullscreenButton fullscreenButton nGEvent" data-ngy2action="fullScreen">'+s+'</div>';
|
9408 | break;
|
9409 | case 'infoButton':
|
9410 | case 'info':
|
9411 | r += 'infoButton nGEvent" data-ngy2action="info">'+ G.O.icons.viewerInfo +'</div>';
|
9412 | break;
|
9413 | case 'linkOriginalButton':
|
9414 | case 'linkOriginal':
|
9415 | r += 'linkOriginalButton nGEvent" data-ngy2action="linkOriginal">' + G.O.icons.viewerLinkOriginal + '</div>';
|
9416 | break;
|
9417 | case 'closeButton':
|
9418 | case 'close':
|
9419 | r += 'closeButton nGEvent" data-ngy2action="close">'+ G.O.icons.buttonClose +'</div>';
|
9420 | break;
|
9421 | case 'shareButton':
|
9422 | case 'share':
|
9423 | r += 'nGEvent" data-ngy2action="share">'+ G.O.icons.viewerShare +'</div>';
|
9424 | break;
|
9425 | case 'label':
|
9426 | r += '"><div class="label"><div class="title nGEvent" itemprop="name"></div><div class="description nGEvent" itemprop="description"></div></div></div>';
|
9427 | break;
|
9428 | case 'shoppingcart':
|
9429 | r += 'closeButton nGEvent" data-ngy2action="shoppingcart">'+ G.O.icons.viewerShoppingcart +'</div>';
|
9430 | break;
|
9431 | default:
|
9432 |
|
9433 | if( e.indexOf('custom') == 0 ) {
|
9434 | var t = '';
|
9435 |
|
9436 | var fu = G.O.fnImgToolbarCustInit;
|
9437 | if( fu !== null ) {
|
9438 | typeof fu == 'function' ? fu(e) : window[fu](e);
|
9439 | }
|
9440 | if( t == undefined || t == '' ) {
|
9441 |
|
9442 | var n = e.substring(6);
|
9443 | t = G.O.icons['viewerCustomTool'+n];
|
9444 | }
|
9445 | r += 'ngy2CustomBtn ' + e + ' nGEvent" data-ngy2action="' + e + '">' + t + '</div>';
|
9446 | }
|
9447 | else {
|
9448 | r = '';
|
9449 | }
|
9450 | break;
|
9451 | }
|
9452 | return r;
|
9453 | }
|
9454 |
|
9455 |
|
9456 |
|
9457 | function SlideshowToggle(){
|
9458 | if( G.VOM.playSlideshow ) {
|
9459 | window.clearTimeout(G.VOM.playSlideshowTimerID);
|
9460 | G.VOM.playSlideshow = false;
|
9461 | G.VOM.$viewer.find('.playPauseButton').html(G.O.icons.viewerPlay);
|
9462 | }
|
9463 | else {
|
9464 | G.VOM.playSlideshow = true;
|
9465 | DisplayNextMedia();
|
9466 | G.VOM.$viewer.find('.playPauseButton').html(G.O.icons.viewerPause);
|
9467 | }
|
9468 | }
|
9469 |
|
9470 | function ViewerToolbarForVisibilityStd() {
|
9471 | G.VOM.toolbarMode = 'std';
|
9472 |
|
9473 | var sTB = '';
|
9474 | var t = G.O.viewerToolbar.standard.split(',');
|
9475 | for( var i = 0, lt = t.length; i < lt; i++) {
|
9476 | sTB += ToolbarAddElt( t[i] );
|
9477 | }
|
9478 | G.VOM.$toolbar.find('.toolbar').html(sTB);
|
9479 | ViewerToolbarElementContent();
|
9480 | }
|
9481 |
|
9482 | function ViewerToolbarForVisibilityMin() {
|
9483 | if( G.O.viewerToolbar.minimized == undefined || G.O.viewerToolbar.minimized == '' ) {
|
9484 | ViewerToolbarForVisibilityStd();
|
9485 | }
|
9486 | else {
|
9487 | G.VOM.toolbarMode = 'min';
|
9488 | var sTB = '';
|
9489 | var t = G.O.viewerToolbar.minimized.split(',');
|
9490 | for( var i = 0, lt = t.length; i < lt; i++) {
|
9491 | sTB += ToolbarAddElt( t[i] );
|
9492 | }
|
9493 | G.VOM.$toolbar.find('.toolbar').html(sTB);
|
9494 | ViewerToolbarElementContent();
|
9495 | }
|
9496 | }
|
9497 |
|
9498 | function ViewerToolbarElementContent() {
|
9499 |
|
9500 | var vomIdx = G.VOM.content.current.vIdx;
|
9501 | if( vomIdx == null ) { return; }
|
9502 |
|
9503 | var item = G.VOM.content.current.NGY2Item();
|
9504 |
|
9505 |
|
9506 | var setTxt = false;
|
9507 |
|
9508 | if( item.title !== undefined && item.title != '' ) {
|
9509 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.title').html(item.title);
|
9510 | setTxt = true;
|
9511 | }
|
9512 | else {
|
9513 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.title').html('');
|
9514 | }
|
9515 |
|
9516 | if( item.description !== undefined && item.description != '' ) {
|
9517 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.description').html(item.description);
|
9518 | setTxt = true;
|
9519 | }
|
9520 | else {
|
9521 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.description').html('');
|
9522 | }
|
9523 |
|
9524 | if( setTxt ) {
|
9525 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.label').show();
|
9526 | }
|
9527 | else {
|
9528 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.label').hide();
|
9529 | }
|
9530 |
|
9531 |
|
9532 | var viewerMaxImages = G.VOM.items.length;
|
9533 | if( viewerMaxImages > 0 ) {
|
9534 | G.VOM.$viewer.find('.pageCounter').html((G.VOM.items[vomIdx].mediaNumber)+'/'+viewerMaxImages);
|
9535 | }
|
9536 |
|
9537 |
|
9538 | var $cu = G.VOM.$viewer.find('.ngy2CustomBtn');
|
9539 | var fu = G.O.fnImgToolbarCustDisplay;
|
9540 | if( $cu.length > 0 && fu !== null ) {
|
9541 | typeof fu == 'function' ? fu($cu, item) : window[fu]($cu, item);
|
9542 | }
|
9543 |
|
9544 |
|
9545 | ViewerToolsOn();
|
9546 | }
|
9547 |
|
9548 |
|
9549 | function ViewerMediaPanX( posX ) {
|
9550 | G.VOM.swipePosX = posX;
|
9551 | if( G.CSStransformName == null ) {
|
9552 |
|
9553 |
|
9554 | }
|
9555 | else {
|
9556 |
|
9557 |
|
9558 |
|
9559 | G.VOM.content.current.$media[0].style[G.CSStransformName] = 'translate(' + posX + 'px, 0px)';
|
9560 |
|
9561 |
|
9562 | var itemPrevious = G.VOM.content.previous.NGY2Item();
|
9563 | var itemNext = G.VOM.content.next.NGY2Item();
|
9564 |
|
9565 |
|
9566 | if( G.O.imageTransition.startsWith('SWIPE') ) {
|
9567 | if( itemPrevious.mediaTransition() ) {
|
9568 | ViewerSetMediaVisibility(G.VOM.content.previous, 1);
|
9569 | }
|
9570 | if( itemNext.mediaTransition() ) {
|
9571 | ViewerSetMediaVisibility(G.VOM.content.next, 1);
|
9572 | }
|
9573 |
|
9574 | var sc = Math.min( Math.max( Math.abs(posX) / G.VOM.window.lastWidth, .8), 1);
|
9575 | if( G.O.imageTransition == 'SWIPE' ) { sc = 1; }
|
9576 |
|
9577 | if( posX > 0 ) {
|
9578 | let dir = G.VOM.window.lastWidth;
|
9579 | if( itemPrevious.mediaTransition() ) {
|
9580 |
|
9581 | G.VOM.content.previous.$media[0].style[G.CSStransformName] = 'translate(' + (-dir + posX) + 'px, 0px) scale(' + sc + ')';
|
9582 |
|
9583 | }
|
9584 | if( itemNext.mediaTransition() ) {
|
9585 |
|
9586 | G.VOM.content.next.$media[0].style[G.CSStransformName] = 'translate(' + (dir) + 'px, 0px) scale(' + sc + ')';
|
9587 |
|
9588 | }
|
9589 | }
|
9590 | else {
|
9591 | let dir = -G.VOM.window.lastWidth;
|
9592 | if( itemNext.mediaTransition() ) {
|
9593 |
|
9594 | G.VOM.content.next.$media[0].style[G.CSStransformName] = 'translate(' + (-dir + posX) + 'px, 0px) scale(' + sc + ')';
|
9595 |
|
9596 | }
|
9597 | if( itemPrevious.mediaTransition() ) {
|
9598 |
|
9599 | G.VOM.content.previous.$media[0].style[G.CSStransformName] = 'translate(' + (dir) + 'px, 0px) scale(' + sc + ')';
|
9600 |
|
9601 | }
|
9602 | }
|
9603 | }
|
9604 |
|
9605 |
|
9606 | if( G.O.imageTransition == 'SLIDEAPPEAR' ) {
|
9607 | G.VOM.content.previous.$media[0].style[G.CSStransformName] = '';
|
9608 | G.VOM.content.next.$media[0].style[G.CSStransformName] = '';
|
9609 | if( posX < 0 ) {
|
9610 | let o = (-posX) / G.VOM.window.lastWidth;
|
9611 | if( itemNext.mediaTransition() ) {
|
9612 | ViewerSetMediaVisibility(G.VOM.content.next, o);
|
9613 | }
|
9614 | if( itemPrevious.mediaTransition() ) {
|
9615 | ViewerSetMediaVisibility(G.VOM.content.previous, 0);
|
9616 | }
|
9617 | }
|
9618 | else {
|
9619 | let o = posX / G.VOM.window.lastWidth;
|
9620 | if( itemPrevious.mediaTransition() ) {
|
9621 | ViewerSetMediaVisibility(G.VOM.content.previous, o);
|
9622 | }
|
9623 | if( itemNext.mediaTransition() ) {
|
9624 | ViewerSetMediaVisibility(G.VOM.content.next, 0);
|
9625 | }
|
9626 | }
|
9627 | }
|
9628 | }
|
9629 | }
|
9630 |
|
9631 |
|
9632 | function DisplayNextMedia( velocity ) {
|
9633 | velocity = velocity || 0;
|
9634 |
|
9635 | if( G.VOM.viewerMediaIsChanged || ((new Date().getTime()) - G.VOM.timeImgChanged < 300) ) { return; }
|
9636 |
|
9637 | TriggerCustomEvent('lightboxNextImage');
|
9638 | LightboxDisplay('nextImage', velocity);
|
9639 | };
|
9640 |
|
9641 |
|
9642 | function DisplayPreviousMedia( velocity ) {
|
9643 | velocity = velocity || 0;
|
9644 |
|
9645 | if( G.VOM.viewerMediaIsChanged || ((new Date().getTime()) - G.VOM.timeImgChanged < 300) ) { return; }
|
9646 | if( G.VOM.playSlideshow ) {
|
9647 | SlideshowToggle();
|
9648 | }
|
9649 |
|
9650 | TriggerCustomEvent('lightboxPreviousImage');
|
9651 | LightboxDisplay( 'previousImage', velocity);
|
9652 | };
|
9653 |
|
9654 |
|
9655 |
|
9656 |
|
9657 | function LightboxDisplay( displayType, velocity ) {
|
9658 |
|
9659 | velocity = velocity || 0;
|
9660 |
|
9661 | if( G.O.debugMode && console.timeline ) { console.timeline('nanogallery2_viewer'); }
|
9662 |
|
9663 | if( G.VOM.playSlideshow ) { window.clearTimeout( G.VOM.playSlideshowTimerID ); }
|
9664 |
|
9665 | var current_content_item = null;
|
9666 | var new_content_item = null;
|
9667 |
|
9668 | G.VOM.timeImgChanged = new Date().getTime();
|
9669 | G.VOM.viewerMediaIsChanged = true;
|
9670 | G.VOM.zoom.isZooming = false;
|
9671 | ResizeLightbox(true);
|
9672 |
|
9673 | switch( displayType ) {
|
9674 | case '':
|
9675 | current_content_item = G.VOM.content.current;
|
9676 | new_content_item = G.VOM.content.current;
|
9677 | break;
|
9678 | case 'previousImage':
|
9679 | current_content_item = G.VOM.content.current;
|
9680 | new_content_item = G.VOM.content.previous;
|
9681 | break;
|
9682 | default:
|
9683 | current_content_item = G.VOM.content.current;
|
9684 | new_content_item = G.VOM.content.next;
|
9685 | }
|
9686 |
|
9687 |
|
9688 | SetLocationHash( new_content_item.NGY2Item().albumID, new_content_item.NGY2Item().GetID() );
|
9689 |
|
9690 | if( displayType == '' ) {
|
9691 |
|
9692 | return;
|
9693 | }
|
9694 |
|
9695 |
|
9696 | var vP = G.GOM.cache.viewport;
|
9697 | var t_easing = '';
|
9698 | var t_dur = 500 * (vP.w - Math.abs(G.VOM.swipePosX)) / vP.w;
|
9699 | if( velocity > 0 ) {
|
9700 |
|
9701 | t_dur = Math.min( (vP.w - Math.abs(G.VOM.swipePosX)) / velocity, t_dur);
|
9702 | t_easing = 'linear';
|
9703 | }
|
9704 |
|
9705 |
|
9706 |
|
9707 |
|
9708 | if( G.CSStransformName == null ) {
|
9709 |
|
9710 | ViewerSetMediaVisibility(new_content_item, 1);
|
9711 | ViewerSetMediaVisibility(current_content_item, 1);
|
9712 | LightboxDisplayFinalize(displayType);
|
9713 | }
|
9714 | else {
|
9715 | switch( G.O.imageTransition ) {
|
9716 | case 'SWIPE':
|
9717 | case 'SWIPE2':
|
9718 | var dir = ( displayType == 'nextImage' ? - vP.w : vP.w );
|
9719 | new_content_item.$media[0].style[G.CSStransformName] = 'translate(' + (-dir) + 'px, 0px) '
|
9720 |
|
9721 | if( velocity == 0 ) {
|
9722 | t_easing = G.O.imageTransition == 'swipe' ? 'easeInOutSine' : 'easeOutCubic';
|
9723 | }
|
9724 |
|
9725 | ViewerSetMediaVisibility(G.VOM.content.current, 1);
|
9726 | G.VOM.content.current.$media[0].style[G.CSStransformName] = 'translate(0px, 0px)';
|
9727 | ViewerSetMediaVisibility(new_content_item, 1);
|
9728 |
|
9729 | new NGTweenable().tween({
|
9730 | from: { t: G.VOM.swipePosX },
|
9731 | to: { t: (displayType == 'nextImage' ? - vP.w : vP.w) },
|
9732 | attachment: { dT: displayType, new_content_item: new_content_item, dir: dir, media_transition: new_content_item.NGY2Item().mediaTransition()},
|
9733 |
|
9734 | duration: t_dur,
|
9735 | easing: ( t_easing ),
|
9736 | step: function (state, att) {
|
9737 |
|
9738 | G.VOM.content.current.$media[0].style[G.CSStransformName] = 'translate(' + state.t + 'px, 0px)';
|
9739 |
|
9740 |
|
9741 | if( att.media_transition ) {
|
9742 |
|
9743 | var sc = Math.min( Math.max( (Math.abs(state.t)) / G.VOM.window.lastWidth, .8), 1);
|
9744 | if( G.O.imageTransition == 'SWIPE' ) { sc = 1; }
|
9745 | att.new_content_item.$media[0].style[G.CSStransformName] = 'translate(' + (-att.dir+state.t) + 'px, 0px) scale(' + sc + ')';
|
9746 | }
|
9747 | },
|
9748 | finish: function (state, att) {
|
9749 | G.VOM.content.current.$media[0].style[G.CSStransformName] = '';
|
9750 | ViewerSetMediaVisibility(G.VOM.content.current, 0);
|
9751 | att.new_content_item.$media[0].style[G.CSStransformName] = '';
|
9752 | LightboxDisplayFinalize(att.dT);
|
9753 | }
|
9754 | });
|
9755 | break;
|
9756 |
|
9757 | case 'SLIDEAPPEAR':
|
9758 | default:
|
9759 |
|
9760 | var op = (Math.abs(G.VOM.swipePosX)) / G.VOM.window.lastWidth;
|
9761 | new_content_item.$media[0].style[G.CSStransformName] = '';
|
9762 | if( velocity == 0 ) {
|
9763 | t_easing ='easeInOutSine';
|
9764 | }
|
9765 | new NGTweenable().tween({
|
9766 | from: { o: op, t: G.VOM.swipePosX },
|
9767 | to: { o: 1, t: (displayType == 'nextImage' ? - vP.w : vP.w) },
|
9768 | attachment: { dT: displayType, new_content_item:new_content_item, media_transition: new_content_item.NGY2Item().mediaTransition() },
|
9769 | delay: 30,
|
9770 | duration: t_dur,
|
9771 | easing: t_easing,
|
9772 | step: function (state, att) {
|
9773 |
|
9774 | G.VOM.content.current.$media[0].style[G.CSStransformName]= 'translate('+state.t+'px, 0px)';
|
9775 |
|
9776 |
|
9777 | if( att.media_transition ) {
|
9778 |
|
9779 | ViewerSetMediaVisibility(att.new_content_item, state.o);
|
9780 | }
|
9781 | },
|
9782 | finish: function (state, att) {
|
9783 | G.VOM.content.current.$media[0].style[G.CSStransformName]= '';
|
9784 | LightboxDisplayFinalize(att.dT);
|
9785 | }
|
9786 | });
|
9787 | break;
|
9788 | }
|
9789 | }
|
9790 |
|
9791 | }
|
9792 |
|
9793 |
|
9794 | function LightboxDisplayFinalize( displayType ) {
|
9795 |
|
9796 | var newVomIdx = 0;
|
9797 | switch( displayType ) {
|
9798 | case '':
|
9799 |
|
9800 | newVomIdx = G.VOM.content.current.vIdx;
|
9801 | break;
|
9802 | case 'previousImage':
|
9803 |
|
9804 | newVomIdx = G.VOM.content.previous.vIdx;
|
9805 | break;
|
9806 | default:
|
9807 |
|
9808 | newVomIdx = G.VOM.content.next.vIdx;
|
9809 | }
|
9810 |
|
9811 |
|
9812 |
|
9813 | G.VOM.content.current.vIdx = newVomIdx;
|
9814 | G.VOM.content.next.vIdx = G.VOM.IdxNext();
|
9815 | G.VOM.content.previous.vIdx = G.VOM.IdxPrevious();
|
9816 | G.VOM.gallery.Resize();
|
9817 | G.VOM.gallery.SetThumbnailActive();
|
9818 |
|
9819 | var ngy2item = G.VOM.content.current.NGY2Item();
|
9820 |
|
9821 | ViewerToolbarElementContent();
|
9822 | if( G.O.debugMode && console.timeline ) { console.timelineEnd('nanogallery2_viewer'); }
|
9823 |
|
9824 | var fu=G.O.fnImgDisplayed;
|
9825 | if( fu !== null ) {
|
9826 | typeof fu == 'function' ? fu(ngy2item) : window[fu](ngy2item);
|
9827 | }
|
9828 |
|
9829 | G.VOM.swipePosX = 0;
|
9830 | if( displayType != '' ) {
|
9831 |
|
9832 | G.VOM.content.current.$media.removeClass('imgCurrent');
|
9833 |
|
9834 | var $tmp = G.VOM.content.current.$media;
|
9835 | switch( displayType ) {
|
9836 | case 'nextImage':
|
9837 | G.VOM.content.current.$media = G.VOM.content.next.$media;
|
9838 | G.VOM.content.next.$media = $tmp;
|
9839 | break;
|
9840 | case 'previousImage':
|
9841 | G.VOM.content.current.$media = G.VOM.content.previous.$media;
|
9842 | G.VOM.content.previous.$media = $tmp;
|
9843 | break;
|
9844 | }
|
9845 | }
|
9846 |
|
9847 | G.VOM.content.current.$media.addClass('imgCurrent');
|
9848 |
|
9849 |
|
9850 | var $pans = G.VOM.$content.find('.nGY2ViewerMediaPan');
|
9851 | G.VOM.content.current.$media.insertAfter($pans.last());
|
9852 |
|
9853 | if( ngy2item.mediaKind == 'img' && ngy2item.imageWidth == 0 ) {
|
9854 | ViewerSetMediaVisibility(G.VOM.content.current, 0);
|
9855 | }
|
9856 | else {
|
9857 | G.VOM.content.current.$media.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9858 | ViewerSetMediaVisibility(G.VOM.content.current, 1);
|
9859 | }
|
9860 |
|
9861 |
|
9862 |
|
9863 | G.VOM.content.next.$media.empty();
|
9864 | var nextItem = G.VOM.content.next.NGY2Item();
|
9865 | var spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
9866 | if( nextItem.mediaKind == 'img' && nextItem.imageWidth != 0 && nextItem.imageHeight != 0 ) {
|
9867 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
9868 | }
|
9869 | G.VOM.content.next.$media.append( spreloader + nextItem.mediaMarkup );
|
9870 | ViewerSetMediaVisibility(G.VOM.content.next, 0);
|
9871 | ViewerSetMediaVisibility(G.VOM.content.previous, 0);
|
9872 | if( nextItem.mediaKind == 'img' ) {
|
9873 | G.VOM.ImageLoader.loadImage(VieweImgSizeRetrieved, nextItem);
|
9874 | }
|
9875 | else {
|
9876 | ViewerMediaCenterNotImg( G.VOM.content.next.$media );
|
9877 | }
|
9878 |
|
9879 |
|
9880 | G.VOM.content.previous.$media.empty();
|
9881 | var previousItem = G.VOM.content.previous.NGY2Item();
|
9882 | spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
9883 | if( previousItem.mediaKind == 'img' && previousItem.imageWidth != 0 && previousItem.imageHeight != 0 ) {
|
9884 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
9885 | }
|
9886 | G.VOM.content.previous.$media.append( spreloader + previousItem.mediaMarkup );
|
9887 | ViewerSetMediaVisibility(G.VOM.content.previous, 0);
|
9888 | ViewerSetMediaVisibility(G.VOM.content.next, 0);
|
9889 | if( previousItem.mediaKind == 'img' ) {
|
9890 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, previousItem );
|
9891 | }
|
9892 | else {
|
9893 | ViewerMediaCenterNotImg( G.VOM.content.previous.$media );
|
9894 | }
|
9895 |
|
9896 |
|
9897 |
|
9898 | if( G.VOM.playSlideshow ) {
|
9899 | G.VOM.content.current.$media.children().eq(1).ngimagesLoaded().always( function( instance ) {
|
9900 | if( G.VOM.playSlideshow ) {
|
9901 |
|
9902 | G.VOM.playSlideshowTimerID = window.setTimeout( function(){ DisplayNextMedia(); }, G.VOM.slideshowDelay );
|
9903 | }
|
9904 | });
|
9905 | }
|
9906 |
|
9907 |
|
9908 |
|
9909 |
|
9910 |
|
9911 |
|
9912 |
|
9913 |
|
9914 |
|
9915 |
|
9916 | ResizeLightbox();
|
9917 |
|
9918 | G.VOM.viewerMediaIsChanged = false;
|
9919 | TriggerCustomEvent('lightboxImageDisplayed');
|
9920 |
|
9921 | }
|
9922 |
|
9923 |
|
9924 |
|
9925 | function VieweImgSizeRetrieved(w, h, item, n) {
|
9926 |
|
9927 | item.imageWidth = w;
|
9928 | item.imageHeight = h;
|
9929 |
|
9930 |
|
9931 | if( G.VOM.content.current.NGY2Item() == item ) {
|
9932 |
|
9933 | G.VOM.content.current.$media.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9934 | ViewerSetMediaVisibility(G.VOM.content.current, 1);
|
9935 | G.VOM.zoom.userFactor = 1;
|
9936 | }
|
9937 |
|
9938 | if( G.VOM.content.next.NGY2Item() == item ) {
|
9939 | G.VOM.content.next.$media.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9940 | }
|
9941 | if( G.VOM.content.previous.NGY2Item() == item ) {
|
9942 | G.VOM.content.previous.$media.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9943 | }
|
9944 |
|
9945 | ViewerMediaSetPosAndZoom();
|
9946 |
|
9947 | }
|
9948 |
|
9949 |
|
9950 |
|
9951 | function ViewerSetMediaVisibility( content_item, opacity ) {
|
9952 |
|
9953 | var item = content_item.NGY2Item();
|
9954 | var $media = content_item.$media;
|
9955 |
|
9956 | if( item.mediaKind == 'img' && item.imageWidth == 0 ) {
|
9957 |
|
9958 |
|
9959 |
|
9960 | $media.children().eq(1).css({ opacity: 0, visibility: 'hidden' });
|
9961 |
|
9962 | return;
|
9963 | }
|
9964 |
|
9965 | if( opacity == 0 ) {
|
9966 |
|
9967 |
|
9968 | $media.children().css({ opacity: 0, visibility: 'hidden' });
|
9969 | }
|
9970 | else {
|
9971 |
|
9972 | $media.children().css({ opacity: opacity, visibility: 'visible' });
|
9973 | }
|
9974 | }
|
9975 |
|
9976 |
|
9977 |
|
9978 | function LightboxClose( vomIdx ) {
|
9979 |
|
9980 |
|
9981 | if( vomIdx == undefined ) {
|
9982 | vomIdx = G.VOM.content.current.vIdx;
|
9983 | }
|
9984 |
|
9985 | G.VOM.viewerMediaIsChanged = false;
|
9986 |
|
9987 | if( G.VOM.viewerDisplayed ) {
|
9988 |
|
9989 |
|
9990 | jQuery("body").removeClass("nGY2_body_scrollbar");
|
9991 | jQuery("#nGY2_body_scrollbar_style").remove();
|
9992 |
|
9993 | if( G.VOM.playSlideshow ) {
|
9994 | window.clearTimeout( G.VOM.playSlideshowTimerID );
|
9995 | G.VOM.playSlideshow = false;
|
9996 | }
|
9997 |
|
9998 | G.VOM.hammertime.destroy();
|
9999 | G.VOM.hammertime = null;
|
10000 |
|
10001 | if( ngscreenfull.enabled && G.VOM.viewerIsFullscreen ) {
|
10002 | G.VOM.viewerIsFullscreen = false;
|
10003 | ngscreenfull.exit();
|
10004 | }
|
10005 |
|
10006 |
|
10007 |
|
10008 | jQuery('.nGY2ViewerContainer').remove();
|
10009 | G.VOM.$baseCont = null;
|
10010 | G.VOM.viewerDisplayed = false;
|
10011 |
|
10012 | if( G.O.lightboxStandalone ) { return; }
|
10013 |
|
10014 | if( G.O.thumbnailAlbumDisplayImage ) {
|
10015 |
|
10016 | if( vomIdx == null ) {
|
10017 |
|
10018 |
|
10019 | }
|
10020 | else {
|
10021 | var item = G.I[G.VOM.items[vomIdx].ngy2ItemIdx];
|
10022 | var parent = NGY2Item.Get(G, item.albumID);
|
10023 | if( G.GOM.albumIdx != parent.albumID ) {
|
10024 |
|
10025 | DisplayAlbum('-1', parent.albumID);
|
10026 | }
|
10027 | else {
|
10028 | GalleryResize();
|
10029 | SetLocationHash( '', '' );
|
10030 | ThumbnailHoverReInitAll();
|
10031 | }
|
10032 | }
|
10033 |
|
10034 | }
|
10035 | else {
|
10036 | if( vomIdx != null ) {
|
10037 | if( G.GOM.albumIdx == -1 ) {
|
10038 |
|
10039 | DisplayAlbum( '', G.I[G.VOM.items[vomIdx].ngy2ItemIdx].albumID );
|
10040 | }
|
10041 | else {
|
10042 | GalleryResize();
|
10043 | SetLocationHash( G.I[G.VOM.items[vomIdx].ngy2ItemIdx].albumID, '' );
|
10044 | ThumbnailHoverReInitAll();
|
10045 | }
|
10046 | }
|
10047 | }
|
10048 | G.VOM.timeImgChanged = new Date().getTime();
|
10049 | }
|
10050 | }
|
10051 |
|
10052 |
|
10053 |
|
10054 | function ResizeLightbox( forceUpdate ) {
|
10055 | forceUpdate = typeof forceUpdate !== 'undefined' ? forceUpdate : false;
|
10056 |
|
10057 | if( G.VOM.$toolbar === null ) { return; }
|
10058 |
|
10059 |
|
10060 |
|
10061 | var windowsW = G.VOM.$viewer.width();
|
10062 | var windowsH = G.VOM.$viewer.height();
|
10063 | var $elt = G.VOM.content.current.$media.children().eq(1);
|
10064 | if( $elt == null || G.VOM.content.current.vIdx == -1 ) { return; }
|
10065 |
|
10066 | if( !forceUpdate && G.VOM.window.lastWidth == windowsW && G.VOM.window.lastHeight == windowsH ) { return; }
|
10067 |
|
10068 | G.VOM.window.lastWidth = windowsW;
|
10069 | G.VOM.window.lastHeight = windowsH;
|
10070 |
|
10071 |
|
10072 |
|
10073 |
|
10074 |
|
10075 | var galleryHeight = 0;
|
10076 | var cBottom = 0;
|
10077 |
|
10078 | if( G.O.viewerGallery != 'none' ) {
|
10079 | galleryHeight = G.O.viewerGalleryTHeight + 10;
|
10080 | }
|
10081 | if( G.O.viewerGallery == 'bottom' ) {
|
10082 | cBottom = galleryHeight;
|
10083 | }
|
10084 |
|
10085 |
|
10086 | switch( G.O.viewerToolbar.position ) {
|
10087 | case 'top':
|
10088 | case 'topOverImage':
|
10089 | G.VOM.$content.css({height: windowsH, width: windowsW, top: 0 });
|
10090 | G.VOM.$toolbar.css({top: 0, bottom: ''});
|
10091 | break;
|
10092 |
|
10093 |
|
10094 |
|
10095 |
|
10096 |
|
10097 | case 'bottom':
|
10098 | case 'bottomOverImage':
|
10099 | default:
|
10100 | windowsH -= cBottom;
|
10101 | G.VOM.$content.css({height: windowsH, width: windowsW, bottom: -cBottom, top: 0 });
|
10102 | G.VOM.$toolbar.css({bottom: galleryHeight});
|
10103 | break;
|
10104 |
|
10105 |
|
10106 |
|
10107 |
|
10108 |
|
10109 |
|
10110 | }
|
10111 |
|
10112 |
|
10113 | if( !G.VOM.viewerMediaIsChanged && G.VOM.zoom.isZooming ) {
|
10114 | ViewerMediaSetPosAndZoom();
|
10115 | }
|
10116 | else {
|
10117 | 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 )) {
|
10118 |
|
10119 | G.VOM.zoom.isZooming= true;
|
10120 | new NGTweenable().tween({
|
10121 | from: { userFactor: G.VOM.zoom.userFactor, panPosX: G.VOM.panPosX, panPosY: G.VOM.panPosY, zoomPosX: G.VOM.zoom.posX, zoomPosY: G.VOM.zoom.posY },
|
10122 | to: { userFactor: 1, panPosX: 0, panPosY: 0, zoomPosX: 0, zoomPosY: 0 },
|
10123 | easing: 'easeInOutSine',
|
10124 | delay: 0,
|
10125 | duration: 150,
|
10126 | step: function (state) {
|
10127 | G.VOM.zoom.userFactor = state.userFactor;
|
10128 | G.VOM.panPosX = state.panPosX;
|
10129 | G.VOM.panPosY = state.panPosY;
|
10130 | G.VOM.zoom.posX = state.zoomPosX;
|
10131 | G.VOM.zoom.posY = state.zoomPosY;
|
10132 | ViewerMediaSetPosAndZoom();
|
10133 | },
|
10134 | finish: function (state) {
|
10135 | G.VOM.zoom.isZooming=false;
|
10136 | }
|
10137 | });
|
10138 |
|
10139 | }
|
10140 | else {
|
10141 | G.VOM.zoom.userFactor = 1;
|
10142 | G.VOM.zoom.isZooming = false;
|
10143 | G.VOM.panPosX = 0;
|
10144 | G.VOM.panPosY = 0;
|
10145 | G.VOM.zoom.posX = 0;
|
10146 | G.VOM.zoom.posY = 0;
|
10147 | ViewerMediaSetPosAndZoom();
|
10148 | }
|
10149 | }
|
10150 | }
|
10151 |
|
10152 |
|
10153 |
|
10154 |
|
10155 | function getScrollableParent (node) {
|
10156 | const regex = /(auto|scroll)/;
|
10157 | const parents = (_node, ps) => {
|
10158 | if (_node.parentNode === null) { return ps; }
|
10159 | return parents(_node.parentNode, ps.concat([_node]));
|
10160 | };
|
10161 |
|
10162 | const style = (_node, prop) => getComputedStyle(_node, null).getPropertyValue(prop);
|
10163 | const overflow = _node => style(_node, 'overflow') + style(_node, 'overflow-y') + style(_node, 'overflow-x');
|
10164 | const scroll = _node => regex.test(overflow(_node));
|
10165 |
|
10166 | const scrollParent = (_node) => {
|
10167 | if (!(_node instanceof HTMLElement || _node instanceof SVGElement)) {
|
10168 | return undefined;
|
10169 | }
|
10170 |
|
10171 | const ps = parents(_node.parentNode, []);
|
10172 |
|
10173 | for (let i = 0; i < ps.length; i += 1) {
|
10174 | if( ps[i] === document.body ) {
|
10175 | return null;
|
10176 | }
|
10177 | if (scroll(ps[i])) {
|
10178 | return ps[i];
|
10179 | }
|
10180 | }
|
10181 |
|
10182 | return document.scrollingElement || document.documentElement;
|
10183 | };
|
10184 |
|
10185 | return scrollParent(node);
|
10186 | };
|
10187 |
|
10188 |
|
10189 |
|
10190 |
|
10191 |
|
10192 | function BuildSkeleton() {
|
10193 |
|
10194 |
|
10195 |
|
10196 |
|
10197 | var $elements = G.$E.base.children();
|
10198 | if( $elements.length > 0 ) {
|
10199 | G.O.$markup = $elements;
|
10200 | }
|
10201 |
|
10202 | if( !G.O.lightboxStandalone ) {
|
10203 | G.$E.base.text('');
|
10204 | G.$E.base.addClass('ngy2_container');
|
10205 |
|
10206 |
|
10207 |
|
10208 |
|
10209 |
|
10210 |
|
10211 |
|
10212 |
|
10213 | G.$E.base.addClass(G.O.theme)
|
10214 |
|
10215 | SetGalleryTheme();
|
10216 |
|
10217 |
|
10218 | if( G.O.thumbnailLabel.get('hideIcons') ) {
|
10219 | G.O.icons.thumbnailAlbum = '';
|
10220 | G.O.icons.thumbnailImage = '';
|
10221 | }
|
10222 |
|
10223 |
|
10224 | var styleNavigation="";
|
10225 | if( G.O.navigationFontSize != undefined && G.O.navigationFontSize != '' ) {
|
10226 | styleNavigation=' style="font-size:'+G.O.navigationFontSize+';"';
|
10227 | }
|
10228 | G.$E.conNavigationBar = jQuery('<div class="nGY2Navigationbar" '+styleNavigation+'></div>').appendTo(G.$E.base);
|
10229 |
|
10230 |
|
10231 | G.$E.conLoadingB = jQuery('<div class="nanoGalleryLBarOff"><div></div><div></div><div></div><div></div><div></div></div>').appendTo(G.$E.base);
|
10232 |
|
10233 |
|
10234 | G.$E.conTnParent = jQuery('<div class="nGY2Gallery"></div>').appendTo( G.$E.base );
|
10235 | G.$E.conTn = jQuery('<div class="nGY2GallerySub"></div>').appendTo( G.$E.conTnParent );
|
10236 |
|
10237 |
|
10238 | switch( G.O.thumbnailAlignment ) {
|
10239 | case 'left':
|
10240 | G.$E.conTnParent.css({'text-align':'left'});
|
10241 |
|
10242 | break;
|
10243 | case 'right':
|
10244 | G.$E.conTnParent.css({'text-align':'right'});
|
10245 |
|
10246 | break;
|
10247 | }
|
10248 |
|
10249 |
|
10250 | if( G.O.galleryBuildInit2 !== undefined ) {
|
10251 | var t1=G.O.galleryBuildInit2.split('|');
|
10252 | for( var i=0; i<t1.length; i++ ) {
|
10253 | var o1=t1[i].split('_');
|
10254 | if( o1.length == 2 ) {
|
10255 | G.$E.conTn.css(o1[0], o1[1]);
|
10256 | }
|
10257 | }
|
10258 | }
|
10259 |
|
10260 |
|
10261 | var effects=G.tn.hoverEffects.std.concat(G.tn.hoverEffects.level1);
|
10262 | for( var j=0; j<effects.length; j++) {
|
10263 | switch( effects[j].type ) {
|
10264 | case 'scale':
|
10265 | case 'rotateZ':
|
10266 | case 'rotateX':
|
10267 | case 'rotateY':
|
10268 | case 'translateX':
|
10269 | case 'translateY':
|
10270 |
|
10271 | if( effects[j].element == '.nGY2GThumbnail' ) {
|
10272 |
|
10273 | G.$E.base.css('overflow', 'visible');
|
10274 | G.$E.base.find('.nGY2GallerySub').css('overflow', 'visible');
|
10275 | G.$E.conTnParent.css('overflow', 'visible');
|
10276 | }
|
10277 | break;
|
10278 | }
|
10279 | }
|
10280 |
|
10281 |
|
10282 | G.$E.conTnBottom = jQuery('<div class="nGY2GalleryBottom" '+styleNavigation+'></div>').appendTo( G.$E.conTnParent );
|
10283 |
|
10284 |
|
10285 | if( G.O.portable ) {
|
10286 |
|
10287 |
|
10288 |
|
10289 | 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';
|
10290 | 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;";
|
10291 | 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);
|
10292 |
|
10293 | G.$E.ngy2i.find('a').on({
|
10294 | mouseenter: function () {
|
10295 | jQuery(this).attr('style', st);
|
10296 | },
|
10297 | mouseleave: function () {
|
10298 | jQuery(this).attr('style', st);
|
10299 | }
|
10300 | });
|
10301 | }
|
10302 | }
|
10303 |
|
10304 |
|
10305 | G.$E.conConsole = jQuery('<div class="nGY2ConsoleParent"></div>').appendTo(G.$E.base);
|
10306 |
|
10307 |
|
10308 | i18n();
|
10309 |
|
10310 | if( !G.O.lightboxStandalone ) {
|
10311 |
|
10312 | ThumbnailDefCaches();
|
10313 |
|
10314 |
|
10315 |
|
10316 | switch( G.tn.opt.Get('displayTransition') ) {
|
10317 | case 'SCALEDOWN':
|
10318 | case 'RANDOMSCALE':
|
10319 | default:
|
10320 | G.$E.base.css('overflow', 'visible');
|
10321 | G.$E.conTnParent.css('overflow', 'visible');
|
10322 | G.$E.conTn.css('overflow', 'visible');
|
10323 | break;
|
10324 | }
|
10325 | }
|
10326 |
|
10327 | }
|
10328 |
|
10329 | function TriggerCustomEvent ( eventName ) {
|
10330 |
|
10331 | var eN = eventName + '.nanogallery2';
|
10332 | var event=null;
|
10333 | try {
|
10334 | event = new Event( eN );
|
10335 | } catch(e) {
|
10336 | event = document.createEvent('Event');
|
10337 | event.initEvent(eN, false, false);
|
10338 | }
|
10339 | G.$E.base.trigger(eN, event);
|
10340 | }
|
10341 |
|
10342 |
|
10343 |
|
10344 | function SetGlobalEvents() {
|
10345 |
|
10346 |
|
10347 | if( !G.O.lightboxStandalone ) {
|
10348 | G.$E.conTnParent.on({
|
10349 | mouseenter: GalleryMouseEnter,
|
10350 | mouseleave: GalleryMouseLeave
|
10351 | }, ".nGY2GThumbnail");
|
10352 |
|
10353 |
|
10354 | G.GOM.hammertime = new NGHammer( G.$E.conTn[0] );
|
10355 |
|
10356 |
|
10357 |
|
10358 |
|
10359 | G.GOM.hammertime.on('pan', function(ev) {
|
10360 | if( !G.VOM.viewerDisplayed ) {
|
10361 | if( G.O.paginationSwipe && G.layout.support.rows && G.galleryDisplayMode.Get() == 'PAGINATION' ) {
|
10362 | if( Math.abs(ev.deltaY) > G.GOM.panThreshold ) {
|
10363 | G.GOM.panYOnly = true;
|
10364 | }
|
10365 | if( !G.GOM.panYOnly ) {
|
10366 | G.$E.conTn.css( G.CSStransformName , 'translate('+(ev.deltaX)+'px,0px)');
|
10367 | }
|
10368 | }
|
10369 | }
|
10370 | });
|
10371 | G.GOM.hammertime.on('panend', function(ev) {
|
10372 | if( !G.VOM.viewerDisplayed ) {
|
10373 | if( G.O.paginationSwipe && G.layout.support.rows && G.galleryDisplayMode.Get() == 'PAGINATION' ) {
|
10374 | if( !G.GOM.panYOnly ) {
|
10375 | if( ev.deltaX > 50 ) {
|
10376 | paginationPreviousPage();
|
10377 | return;
|
10378 | }
|
10379 | if( ev.deltaX < -50 ) {
|
10380 | paginationNextPage();
|
10381 | return;
|
10382 | }
|
10383 | }
|
10384 | G.GOM.panYOnly = false;
|
10385 | G.$E.conTn.css( G.CSStransformName , 'translate(0px,0px)');
|
10386 |
|
10387 | }
|
10388 | }
|
10389 | });
|
10390 |
|
10391 | G.GOM.hammertime.on('tap', function(ev) {
|
10392 | if( !G.VOM.viewerDisplayed ) {
|
10393 | ev.srcEvent.stopPropagation();
|
10394 | ev.srcEvent.preventDefault();
|
10395 |
|
10396 | if( ev.pointerType == 'mouse') {
|
10397 | if( GalleryClicked(ev.srcEvent) == 'exit' ) { return; }
|
10398 | }
|
10399 | else {
|
10400 | var r = GalleryEventRetrieveElementl(ev.srcEvent, false);
|
10401 | if( r.GOMidx == -1 ) { return; }
|
10402 | if( r.action != 'NONE' && r.action != 'OPEN' ) {
|
10403 |
|
10404 | GalleryClicked(ev.srcEvent);
|
10405 | return;
|
10406 | }
|
10407 |
|
10408 | if( G.GOM.slider.hostIdx == r.GOMidx ) {
|
10409 |
|
10410 | ThumbnailHoverOutAll();
|
10411 | ThumbnailOpen(G.GOM.items[G.GOM.slider.currentIdx].thumbnailIdx, true);
|
10412 | return;
|
10413 | }
|
10414 |
|
10415 | if( (G.GOM.curNavLevel == 'l1' && G.O.touchAnimationL1 == false) || (G.GOM.curNavLevel == 'lN' && G.O.touchAnimation == false) ) {
|
10416 |
|
10417 | ThumbnailOpen(G.GOM.items[r.GOMidx].thumbnailIdx, true);
|
10418 | return;
|
10419 | }
|
10420 |
|
10421 | if( G.O.touchAutoOpenDelay > 0 ) {
|
10422 |
|
10423 | ThumbnailHoverOutAll();
|
10424 | ThumbnailHover( r.GOMidx );
|
10425 | window.clearInterval( G.touchAutoOpenDelayTimerID );
|
10426 | G.touchAutoOpenDelayTimerID = window.setInterval(function(){
|
10427 | window.clearInterval( G.touchAutoOpenDelayTimerID );
|
10428 | ThumbnailOpen( G.GOM.items[r.GOMidx].thumbnailIdx, true );
|
10429 | }, G.O.touchAutoOpenDelay );
|
10430 | }
|
10431 | else {
|
10432 |
|
10433 | if( !G.I[G.GOM.items[r.GOMidx].thumbnailIdx].hovered ) {
|
10434 | ThumbnailHoverOutAll();
|
10435 | ThumbnailHover(r.GOMidx);
|
10436 | }
|
10437 | else {
|
10438 |
|
10439 | ThumbnailOpen(G.GOM.items[r.GOMidx].thumbnailIdx, true);
|
10440 | }
|
10441 | }
|
10442 | }
|
10443 | }
|
10444 | });
|
10445 |
|
10446 |
|
10447 | if( G.O.locationHash ) {
|
10448 |
|
10449 |
|
10450 |
|
10451 | jQuery(window).on('hashchange.nanogallery2.' + G.baseEltID, function() {ProcessLocationHash();} );
|
10452 | }
|
10453 | }
|
10454 |
|
10455 |
|
10456 | jQuery(window).on('resize.nanogallery2.' + G.baseEltID + ' orientationChange.nanogallery2.' + G.baseEltID, debounce( ResizeWindowEvent, G.O.eventsDebounceDelay, false) );
|
10457 |
|
10458 |
|
10459 | jQuery(window).on('scroll.nanogallery2.' + G.baseEltID, debounce( OnScrollEvent, G.O.eventsDebounceDelay, false) );
|
10460 |
|
10461 | if( !G.O.lightboxStandalone ) {
|
10462 |
|
10463 | G.$E.scrollableParent = getScrollableParent( G.$E.base[0] );
|
10464 | var sp = getScrollableParent( G.$E.base[0] );
|
10465 | if( sp !== null ) {
|
10466 | G.$E.scrollableParent = jQuery( sp );
|
10467 | G.$E.scrollableParent.on('scroll.nanogallery2.' + G.baseEltID, debounce( OnScrollEvent, G.O.eventsDebounceDelay, false) );
|
10468 | }
|
10469 | }
|
10470 |
|
10471 |
|
10472 | G.VOM.toolsHide = debounce( ViewerToolsHide, G.O.viewerHideToolsDelay, false );
|
10473 |
|
10474 |
|
10475 | jQuery(document).keyup(function(e) {
|
10476 | if( G.popup.isDisplayed ) {
|
10477 | switch( e.keyCode) {
|
10478 | case 27:
|
10479 | G.popup.close();
|
10480 | break;
|
10481 | }
|
10482 | }
|
10483 | else {
|
10484 | if( G.VOM.viewerDisplayed ) {
|
10485 | ViewerToolsUnHide();
|
10486 | switch( e.keyCode) {
|
10487 | case 27:
|
10488 | case 40:
|
10489 | case 38:
|
10490 | LightboxClose();
|
10491 | break;
|
10492 | case 32:
|
10493 | case 13:
|
10494 | SlideshowToggle();
|
10495 | break;
|
10496 | case 39:
|
10497 | case 33:
|
10498 | DisplayNextMedia();
|
10499 | break;
|
10500 | case 37:
|
10501 | case 34:
|
10502 | DisplayPreviousMedia();
|
10503 | break;
|
10504 | case 35:
|
10505 | case 36:
|
10506 | }
|
10507 | }
|
10508 | }
|
10509 | });
|
10510 |
|
10511 |
|
10512 | jQuery(window).bind('mousewheel wheel', function(e){
|
10513 |
|
10514 | if( G.VOM.viewerDisplayed && G.VOM.content.current.NGY2Item().mediaKind == 'img' ) {
|
10515 |
|
10516 | var deltaY = 0;
|
10517 | e.preventDefault();
|
10518 |
|
10519 | if( ViewerZoomStart() ) {
|
10520 | if (e.originalEvent.deltaY) {
|
10521 | deltaY = e.originalEvent.deltaY;
|
10522 | } else if (e.originalEvent.wheelDelta) {
|
10523 | deltaY = -e.originalEvent.wheelDelta;
|
10524 | }
|
10525 | ViewerZoomIn( deltaY <= 0 ? true : false );
|
10526 | }
|
10527 | }
|
10528 | });
|
10529 |
|
10530 |
|
10531 | jQuery(window).bind('mousemove', function(e){
|
10532 | if( G.VOM.viewerDisplayed ) {
|
10533 | if( G.VOM.toolbarsDisplayed == false ) {
|
10534 | G.VOM.singletapTime = new Date().getTime();
|
10535 | debounce( ViewerToolsUnHide, 100, false )();
|
10536 | }
|
10537 | }
|
10538 | });
|
10539 |
|
10540 |
|
10541 | if( ngscreenfull.enabled ) {
|
10542 |
|
10543 | ngscreenfull.onchange( function() {
|
10544 | if( G.VOM.viewerDisplayed ) {
|
10545 | if( ngscreenfull.isFullscreen ) {
|
10546 | G.VOM.viewerIsFullscreen=true;
|
10547 | G.VOM.$viewer.find('.fullscreenButton').html(G.O.icons.viewerFullscreenOff);
|
10548 | }
|
10549 | else {
|
10550 | G.VOM.viewerIsFullscreen=false;
|
10551 | G.VOM.$viewer.find('.fullscreenButton').html(G.O.icons.viewerFullscreenOn);
|
10552 | }
|
10553 | }
|
10554 | });
|
10555 | }
|
10556 |
|
10557 | }
|
10558 |
|
10559 |
|
10560 |
|
10561 | function ProcessLocationHash() {
|
10562 |
|
10563 |
|
10564 | if( !G.O.locationHash ) { return false; }
|
10565 |
|
10566 | var curGal = '#nanogallery/' + G.baseEltID + '/',
|
10567 | newLocationHash = location.hash;
|
10568 | if( G.O.debugMode ) {
|
10569 | console.log('------------------------ PROCESS LOCATION HASH');
|
10570 | console.log('newLocationHash1: ' +newLocationHash);
|
10571 | console.log('G.locationHashLastUsed: ' +G.locationHashLastUsed);
|
10572 | }
|
10573 |
|
10574 | if( newLocationHash == '' ) {
|
10575 |
|
10576 | if( G.locationHashLastUsed !== '' ) {
|
10577 |
|
10578 | if( G.O.debugMode ) { console.log('display root album' ); }
|
10579 | G.locationHashLastUsed = '';
|
10580 | if( G.O.debugMode ) { console.log('new3 G.locationHashLastUsed: ' + G.locationHashLastUsed); }
|
10581 | DisplayAlbum('', '0');
|
10582 | return true;
|
10583 | }
|
10584 | }
|
10585 |
|
10586 | if( newLocationHash == G.locationHashLastUsed ) { return; }
|
10587 |
|
10588 | if( newLocationHash.indexOf(curGal) == 0 ) {
|
10589 |
|
10590 | var IDs=parseIDs( newLocationHash.substring(curGal.length) );
|
10591 | if( IDs.imageID != '0' ) {
|
10592 | if( G.O.debugMode ) { console.log('display image: ' + IDs.albumID +'-'+ IDs.imageID ); }
|
10593 | DisplayPhoto( IDs.imageID, IDs.albumID );
|
10594 | return true;
|
10595 | }
|
10596 | else {
|
10597 | if( G.O.debugMode ) { console.log('display album: ' + IDs.albumID ); }
|
10598 | DisplayAlbum( '-1', IDs.albumID );
|
10599 | return true;
|
10600 | }
|
10601 | }
|
10602 |
|
10603 | return false;
|
10604 | }
|
10605 |
|
10606 |
|
10607 | function SetLocationHash(albumID, imageID ) {
|
10608 | if( !G.O.locationHash || G.O.lightboxStandalone ) { return false; }
|
10609 |
|
10610 | if( G.O.debugMode ) {
|
10611 | console.log('------------------------ SET LOCATION HASH');
|
10612 | }
|
10613 |
|
10614 | if( imageID == '' && (albumID == '-1' || albumID == '0' || G.O.album == albumID ) ) {
|
10615 |
|
10616 | if( location.hash != '' ) {
|
10617 |
|
10618 | if ("pushState" in history) {
|
10619 | history.pushState("", document.title, window.location.pathname + window.location.search);
|
10620 | }
|
10621 | else {
|
10622 | location.hash='';
|
10623 | }
|
10624 | }
|
10625 | G.locationHashLastUsed='';
|
10626 | if( G.O.debugMode ) { console.log('new2 G.locationHashLastUsed: '+G.locationHashLastUsed); }
|
10627 | return;
|
10628 | }
|
10629 |
|
10630 | var newLocationHash='#'+'nanogallery/'+G.baseEltID+'/'+ albumID;
|
10631 | if( imageID != '' ) {
|
10632 | newLocationHash+='/'+imageID;
|
10633 | }
|
10634 |
|
10635 | var lH=location.hash;
|
10636 | if( G.O.debugMode ) {
|
10637 | console.log('newLocationHash2: '+newLocationHash);
|
10638 | console.log('location.hash: '+lH);
|
10639 | }
|
10640 |
|
10641 | G.locationHashLastUsed=newLocationHash;
|
10642 | if( G.O.debugMode ) { console.log('new G.locationHashLastUsed: '+G.locationHashLastUsed); }
|
10643 |
|
10644 | if( lH == '' || lH != newLocationHash ) {
|
10645 |
|
10646 | try {
|
10647 | top.location.hash=newLocationHash;
|
10648 | }
|
10649 | catch(e) {
|
10650 |
|
10651 | G.O.locationHash=false;
|
10652 | }
|
10653 | }
|
10654 | }
|
10655 |
|
10656 |
|
10657 |
|
10658 | function ResizeWindowEvent() {
|
10659 | CacheViewport();
|
10660 |
|
10661 | var l = G.GOM.curNavLevel;
|
10662 | var w = G.GOM.curWidth;
|
10663 |
|
10664 | if( G.VOM.viewerDisplayed ) {
|
10665 |
|
10666 | ResizeLightbox();
|
10667 | G.VOM.gallery.Resize();
|
10668 | }
|
10669 | else {
|
10670 |
|
10671 | if( G.galleryResizeEventEnabled ) {
|
10672 | var nw = RetrieveCurWidth();
|
10673 |
|
10674 | if( G.GOM.albumIdx != -1 ) {
|
10675 |
|
10676 |
|
10677 |
|
10678 | var s = G.tn.settings;
|
10679 | if( G.layout.engine == "MOSAIC") {
|
10680 |
|
10681 | if( JSON.stringify(s.mosaic[l][w]) !== JSON.stringify(s.mosaic[l][nw]) ) {
|
10682 |
|
10683 | G.GOM.curWidth = nw;
|
10684 | G.GOM.pagination.currentPage = 0;
|
10685 | GalleryRender( G.GOM.albumIdx );
|
10686 | return;
|
10687 | }
|
10688 | }
|
10689 | else {
|
10690 |
|
10691 | 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] ) {
|
10692 |
|
10693 | G.GOM.curWidth = nw;
|
10694 |
|
10695 | G.GOM.pagination.currentPage = 0;
|
10696 | GalleryRender( G.GOM.albumIdx );
|
10697 | return;
|
10698 | }
|
10699 | }
|
10700 |
|
10701 | }
|
10702 |
|
10703 | GalleryResize();
|
10704 |
|
10705 | }
|
10706 | }
|
10707 | }
|
10708 |
|
10709 |
|
10710 |
|
10711 |
|
10712 | function OnScrollEvent() {
|
10713 | if( !G.VOM.viewerDisplayed ) {
|
10714 | GalleryResizeOnScrollEvent();
|
10715 | }
|
10716 | }
|
10717 |
|
10718 |
|
10719 | function GalleryResizeOnScrollEvent() {
|
10720 | if( G.galleryResizeEventEnabled == false) {
|
10721 | window.setTimeout(GalleryResizeOnScrollEvent, 10);
|
10722 | } else {
|
10723 | GalleryResize();
|
10724 | }
|
10725 | }
|
10726 |
|
10727 |
|
10728 |
|
10729 |
|
10730 | function i18n() {
|
10731 |
|
10732 |
|
10733 | G.i18nLang = (navigator.language || navigator.userLanguage).toUpperCase();
|
10734 | if( G.i18nLang === 'UNDEFINED') { G.i18nLang=''; }
|
10735 |
|
10736 | var llang=-('_'+G.i18nLang).length;
|
10737 |
|
10738 | if( toType(G.O.i18n) == 'object' ){
|
10739 |
|
10740 | for( var key in G.O.i18n ) {
|
10741 |
|
10742 | var s=key.substr(llang);
|
10743 | if( s == ('_'+G.i18nLang) ) {
|
10744 | G.i18nTranslations[key.substr(0,key.length-s.length)]=G.O.i18n[key];
|
10745 | }
|
10746 | else {
|
10747 | G.i18nTranslations[key]=G.O.i18n[key];
|
10748 | }
|
10749 | }
|
10750 | }
|
10751 | }
|
10752 |
|
10753 | function GetI18nItem( item, property ) {
|
10754 | var s='';
|
10755 | if( G.i18nLang != '' ) {
|
10756 | if( item[property+'_'+G.i18nLang] !== undefined && item[property+'_'+G.i18nLang].length>0 ) {
|
10757 | s=item[property+'_'+G.i18nLang];
|
10758 | return s;
|
10759 | }
|
10760 | }
|
10761 | s=item[property];
|
10762 | return s;
|
10763 | }
|
10764 |
|
10765 |
|
10766 | function RetrieveCurWidth() {
|
10767 | var vpW = G.GOM.cache.viewport.w;
|
10768 |
|
10769 | if( G.O.breakpointSizeSM > 0 && vpW < G.O.breakpointSizeSM) { return 'xs'; }
|
10770 | if( G.O.breakpointSizeME > 0 && vpW < G.O.breakpointSizeME) { return 'sm'; }
|
10771 | if( G.O.breakpointSizeLA > 0 && vpW < G.O.breakpointSizeLA) { return 'me'; }
|
10772 | if( G.O.breakpointSizeXL > 0 && vpW < G.O.breakpointSizeXL) { return 'la'; }
|
10773 |
|
10774 | return 'xl';
|
10775 | }
|
10776 |
|
10777 |
|
10778 |
|
10779 | function browserNotification() {
|
10780 | 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>';
|
10781 | m += ' <a href="http://www.google.com/chrome/?hl=en-US)">Chrome</a><br>';
|
10782 | m += ' <a href="http://www.mozilla.com/firefox/)">Firefox</a><br>';
|
10783 | m += ' <a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">Internet Explorer</a><br>';
|
10784 | m += ' <a href="http://www.apple.com/safari/download/">Safari</a>';
|
10785 | NanoAlert(G, m, false);
|
10786 | }
|
10787 |
|
10788 |
|
10789 | function FirstSupportedPropertyName(prefixedPropertyNames) {
|
10790 | var tempDiv = document.createElement("div");
|
10791 | for (var i = 0; i < prefixedPropertyNames.length; ++i) {
|
10792 | if (typeof tempDiv.style[prefixedPropertyNames[i]] != 'undefined')
|
10793 | return prefixedPropertyNames[i];
|
10794 | }
|
10795 | return null;
|
10796 | }
|
10797 |
|
10798 |
|
10799 |
|
10800 |
|
10801 | }
|
10802 |
|
10803 |
|
10804 |
|
10805 |
|
10806 |
|
10807 |
|
10808 |
|
10809 |
|
10810 |
|
10811 |
|
10812 |
|
10813 |
|
10814 |
|
10815 |
|
10816 |
|
10817 |
|
10818 |
|
10819 |
|
10820 |
|
10821 |
|
10822 |
|
10823 |
|
10824 |
|
10825 |
|
10826 |
|
10827 |
|
10828 |
|
10829 |
|
10830 |
|
10831 |
|
10832 |
|
10833 |
|
10834 | ( function( global, factory ) {
|
10835 |
|
10836 |
|
10837 |
|
10838 |
|
10839 |
|
10840 |
|
10841 |
|
10842 |
|
10843 |
|
10844 |
|
10845 | global.ngEvEmitter = factory();
|
10846 |
|
10847 |
|
10848 | }( typeof window != 'undefined' ? window : this, function() {
|
10849 |
|
10850 |
|
10851 |
|
10852 | function ngEvEmitter() {}
|
10853 |
|
10854 | var proto = ngEvEmitter.prototype;
|
10855 |
|
10856 | proto.on = function( eventName, listener ) {
|
10857 | if ( !eventName || !listener ) {
|
10858 | return;
|
10859 | }
|
10860 |
|
10861 | var events = this._events = this._events || {};
|
10862 |
|
10863 | var listeners = events[ eventName ] = events[ eventName ] || [];
|
10864 |
|
10865 | if ( listeners.indexOf( listener ) == -1 ) {
|
10866 | listeners.push( listener );
|
10867 | }
|
10868 |
|
10869 | return this;
|
10870 | };
|
10871 |
|
10872 | proto.once = function( eventName, listener ) {
|
10873 | if ( !eventName || !listener ) {
|
10874 | return;
|
10875 | }
|
10876 |
|
10877 | this.on( eventName, listener );
|
10878 |
|
10879 |
|
10880 | var onceEvents = this._onceEvents = this._onceEvents || {};
|
10881 |
|
10882 | var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
|
10883 |
|
10884 | onceListeners[ listener ] = true;
|
10885 |
|
10886 | return this;
|
10887 | };
|
10888 |
|
10889 | proto.off = function( eventName, listener ) {
|
10890 | var listeners = this._events && this._events[ eventName ];
|
10891 | if ( !listeners || !listeners.length ) {
|
10892 | return;
|
10893 | }
|
10894 | var index = listeners.indexOf( listener );
|
10895 | if ( index != -1 ) {
|
10896 | listeners.splice( index, 1 );
|
10897 | }
|
10898 |
|
10899 | return this;
|
10900 | };
|
10901 |
|
10902 | proto.emitEvent = function( eventName, args ) {
|
10903 | var listeners = this._events && this._events[ eventName ];
|
10904 | if ( !listeners || !listeners.length ) {
|
10905 | return;
|
10906 | }
|
10907 | var i = 0;
|
10908 | var listener = listeners[i];
|
10909 | args = args || [];
|
10910 |
|
10911 | var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
|
10912 |
|
10913 | while ( listener ) {
|
10914 | var isOnce = onceListeners && onceListeners[ listener ];
|
10915 | if ( isOnce ) {
|
10916 |
|
10917 |
|
10918 | this.off( eventName, listener );
|
10919 |
|
10920 | delete onceListeners[ listener ];
|
10921 | }
|
10922 |
|
10923 | listener.apply( this, args );
|
10924 |
|
10925 | i += isOnce ? 0 : 1;
|
10926 | listener = listeners[i];
|
10927 | }
|
10928 |
|
10929 | return this;
|
10930 | };
|
10931 |
|
10932 | return ngEvEmitter;
|
10933 |
|
10934 | }));
|
10935 |
|
10936 |
|
10937 |
|
10938 |
|
10939 |
|
10940 |
|
10941 |
|
10942 | ( function( window, factory ) { 'use strict';
|
10943 |
|
10944 |
|
10945 |
|
10946 |
|
10947 |
|
10948 |
|
10949 |
|
10950 |
|
10951 |
|
10952 |
|
10953 |
|
10954 |
|
10955 |
|
10956 |
|
10957 |
|
10958 |
|
10959 |
|
10960 |
|
10961 |
|
10962 | window.ngimagesLoaded = factory(
|
10963 | window,
|
10964 | window.ngEvEmitter
|
10965 | );
|
10966 |
|
10967 |
|
10968 | })( window,
|
10969 |
|
10970 |
|
10971 |
|
10972 | function factory( window, ngEvEmitter ) {
|
10973 |
|
10974 |
|
10975 |
|
10976 |
|
10977 | var $ = jQuery;
|
10978 | var console = window.console;
|
10979 |
|
10980 |
|
10981 |
|
10982 |
|
10983 | function extend( a, b ) {
|
10984 | for ( var prop in b ) {
|
10985 | a[ prop ] = b[ prop ];
|
10986 | }
|
10987 | return a;
|
10988 | }
|
10989 |
|
10990 |
|
10991 | function makeArray( obj ) {
|
10992 | var ary = [];
|
10993 | if ( Array.isArray( obj ) ) {
|
10994 |
|
10995 | ary = obj;
|
10996 | } else if ( typeof obj.length == 'number' ) {
|
10997 |
|
10998 | for ( var i=0; i < obj.length; i++ ) {
|
10999 | ary.push( obj[i] );
|
11000 | }
|
11001 | } else {
|
11002 |
|
11003 | ary.push( obj );
|
11004 | }
|
11005 | return ary;
|
11006 | }
|
11007 |
|
11008 |
|
11009 |
|
11010 |
|
11011 |
|
11012 |
|
11013 |
|
11014 |
|
11015 | function ngImagesLoaded( elem, options, onAlways ) {
|
11016 |
|
11017 | if ( !( this instanceof ngImagesLoaded ) ) {
|
11018 | return new ngImagesLoaded( elem, options, onAlways );
|
11019 | }
|
11020 |
|
11021 | if ( typeof elem == 'string' ) {
|
11022 | elem = document.querySelectorAll( elem );
|
11023 | }
|
11024 |
|
11025 | this.elements = makeArray( elem );
|
11026 | this.options = extend( {}, this.options );
|
11027 |
|
11028 | if ( typeof options == 'function' ) {
|
11029 | onAlways = options;
|
11030 | } else {
|
11031 | extend( this.options, options );
|
11032 | }
|
11033 |
|
11034 | if ( onAlways ) {
|
11035 | this.on( 'always', onAlways );
|
11036 | }
|
11037 |
|
11038 | this.getImages();
|
11039 |
|
11040 | if ( $ ) {
|
11041 |
|
11042 | this.jqDeferred = new $.Deferred();
|
11043 | }
|
11044 |
|
11045 |
|
11046 | setTimeout( function() {
|
11047 | this.check();
|
11048 | }.bind( this ));
|
11049 | }
|
11050 |
|
11051 | ngImagesLoaded.prototype = Object.create( ngEvEmitter.prototype );
|
11052 |
|
11053 | ngImagesLoaded.prototype.options = {};
|
11054 |
|
11055 | ngImagesLoaded.prototype.getImages = function() {
|
11056 | this.images = [];
|
11057 |
|
11058 |
|
11059 | this.elements.forEach( this.addElementImages, this );
|
11060 | };
|
11061 |
|
11062 |
|
11063 |
|
11064 |
|
11065 | ngImagesLoaded.prototype.addElementImages = function( elem ) {
|
11066 |
|
11067 | if ( elem.nodeName == 'IMG' ) {
|
11068 | this.addImage( elem );
|
11069 | }
|
11070 |
|
11071 | if ( this.options.background === true ) {
|
11072 | this.addElementBackgroundImages( elem );
|
11073 | }
|
11074 |
|
11075 |
|
11076 |
|
11077 | var nodeType = elem.nodeType;
|
11078 | if ( !nodeType || !elementNodeTypes[ nodeType ] ) {
|
11079 | return;
|
11080 | }
|
11081 | var childImgs = elem.querySelectorAll('img');
|
11082 |
|
11083 | for ( var i=0; i < childImgs.length; i++ ) {
|
11084 | var img = childImgs[i];
|
11085 | this.addImage( img );
|
11086 | }
|
11087 |
|
11088 |
|
11089 | if ( typeof this.options.background == 'string' ) {
|
11090 | var children = elem.querySelectorAll( this.options.background );
|
11091 | for ( i=0; i < children.length; i++ ) {
|
11092 | var child = children[i];
|
11093 | this.addElementBackgroundImages( child );
|
11094 | }
|
11095 | }
|
11096 | };
|
11097 |
|
11098 | var elementNodeTypes = {
|
11099 | 1: true,
|
11100 | 9: true,
|
11101 | 11: true
|
11102 | };
|
11103 |
|
11104 | ngImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
|
11105 | var style = getComputedStyle( elem );
|
11106 | if ( !style ) {
|
11107 |
|
11108 | return;
|
11109 | }
|
11110 |
|
11111 | var reURL = /url\((['"])?(.*?)\1\)/gi;
|
11112 | var matches = reURL.exec( style.backgroundImage );
|
11113 | while ( matches !== null ) {
|
11114 | var url = matches && matches[2];
|
11115 | if ( url ) {
|
11116 | this.addBackground( url, elem );
|
11117 | }
|
11118 | matches = reURL.exec( style.backgroundImage );
|
11119 | }
|
11120 | };
|
11121 |
|
11122 |
|
11123 |
|
11124 |
|
11125 | ngImagesLoaded.prototype.addImage = function( img ) {
|
11126 | var loadingImage = new LoadingImage( img );
|
11127 | this.images.push( loadingImage );
|
11128 | };
|
11129 |
|
11130 | ngImagesLoaded.prototype.addBackground = function( url, elem ) {
|
11131 | var background = new Background( url, elem );
|
11132 | this.images.push( background );
|
11133 | };
|
11134 |
|
11135 | ngImagesLoaded.prototype.check = function() {
|
11136 | var _this = this;
|
11137 | this.progressedCount = 0;
|
11138 | this.hasAnyBroken = false;
|
11139 |
|
11140 | if ( !this.images.length ) {
|
11141 | this.complete();
|
11142 | return;
|
11143 | }
|
11144 |
|
11145 | function onProgress( image, elem, message ) {
|
11146 |
|
11147 | setTimeout( function() {
|
11148 | _this.progress( image, elem, message );
|
11149 | });
|
11150 | }
|
11151 |
|
11152 | this.images.forEach( function( loadingImage ) {
|
11153 | loadingImage.once( 'progress', onProgress );
|
11154 | loadingImage.check();
|
11155 | });
|
11156 | };
|
11157 |
|
11158 | ngImagesLoaded.prototype.progress = function( image, elem, message ) {
|
11159 | this.progressedCount++;
|
11160 | this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
|
11161 |
|
11162 | this.emitEvent( 'progress', [ this, image, elem ] );
|
11163 | if ( this.jqDeferred && this.jqDeferred.notify ) {
|
11164 | this.jqDeferred.notify( this, image );
|
11165 | }
|
11166 |
|
11167 | if ( this.progressedCount == this.images.length ) {
|
11168 | this.complete();
|
11169 | }
|
11170 |
|
11171 | if ( this.options.debug && console ) {
|
11172 | console.log( 'progress: ' + message, image, elem );
|
11173 | }
|
11174 | };
|
11175 |
|
11176 | ngImagesLoaded.prototype.complete = function() {
|
11177 | var eventName = this.hasAnyBroken ? 'fail' : 'done';
|
11178 | this.isComplete = true;
|
11179 | this.emitEvent( eventName, [ this ] );
|
11180 | this.emitEvent( 'always', [ this ] );
|
11181 | if ( this.jqDeferred ) {
|
11182 | var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
|
11183 | this.jqDeferred[ jqMethod ]( this );
|
11184 | }
|
11185 | };
|
11186 |
|
11187 |
|
11188 |
|
11189 | function LoadingImage( img ) {
|
11190 | this.img = img;
|
11191 | }
|
11192 |
|
11193 | LoadingImage.prototype = Object.create( ngEvEmitter.prototype );
|
11194 |
|
11195 | LoadingImage.prototype.check = function() {
|
11196 |
|
11197 |
|
11198 | var isComplete = this.getIsImageComplete();
|
11199 | if ( isComplete ) {
|
11200 |
|
11201 | this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
|
11202 | return;
|
11203 | }
|
11204 |
|
11205 |
|
11206 | this.proxyImage = new Image();
|
11207 | this.proxyImage.addEventListener( 'load', this );
|
11208 | this.proxyImage.addEventListener( 'error', this );
|
11209 |
|
11210 | this.img.addEventListener( 'load', this );
|
11211 | this.img.addEventListener( 'error', this );
|
11212 | this.proxyImage.src = this.img.src;
|
11213 | };
|
11214 |
|
11215 | LoadingImage.prototype.getIsImageComplete = function() {
|
11216 | return this.img.complete && this.img.naturalWidth !== undefined;
|
11217 | };
|
11218 |
|
11219 | LoadingImage.prototype.confirm = function( isLoaded, message ) {
|
11220 | this.isLoaded = isLoaded;
|
11221 | this.emitEvent( 'progress', [ this, this.img, message ] );
|
11222 | };
|
11223 |
|
11224 |
|
11225 |
|
11226 |
|
11227 | LoadingImage.prototype.handleEvent = function( event ) {
|
11228 | var method = 'on' + event.type;
|
11229 | if ( this[ method ] ) {
|
11230 | this[ method ]( event );
|
11231 | }
|
11232 | };
|
11233 |
|
11234 | LoadingImage.prototype.onload = function() {
|
11235 | this.confirm( true, 'onload' );
|
11236 | this.unbindEvents();
|
11237 | };
|
11238 |
|
11239 | LoadingImage.prototype.onerror = function() {
|
11240 | this.confirm( false, 'onerror' );
|
11241 | this.unbindEvents();
|
11242 | };
|
11243 |
|
11244 | LoadingImage.prototype.unbindEvents = function() {
|
11245 | this.proxyImage.removeEventListener( 'load', this );
|
11246 | this.proxyImage.removeEventListener( 'error', this );
|
11247 | this.img.removeEventListener( 'load', this );
|
11248 | this.img.removeEventListener( 'error', this );
|
11249 | };
|
11250 |
|
11251 |
|
11252 |
|
11253 | function Background( url, element ) {
|
11254 | this.url = url;
|
11255 | this.element = element;
|
11256 | this.img = new Image();
|
11257 | }
|
11258 |
|
11259 |
|
11260 | Background.prototype = Object.create( LoadingImage.prototype );
|
11261 |
|
11262 | Background.prototype.check = function() {
|
11263 | this.img.addEventListener( 'load', this );
|
11264 | this.img.addEventListener( 'error', this );
|
11265 | this.img.src = this.url;
|
11266 |
|
11267 | var isComplete = this.getIsImageComplete();
|
11268 | if ( isComplete ) {
|
11269 | this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
|
11270 | this.unbindEvents();
|
11271 | }
|
11272 | };
|
11273 |
|
11274 | Background.prototype.unbindEvents = function() {
|
11275 | this.img.removeEventListener( 'load', this );
|
11276 | this.img.removeEventListener( 'error', this );
|
11277 | };
|
11278 |
|
11279 | Background.prototype.confirm = function( isLoaded, message ) {
|
11280 | this.isLoaded = isLoaded;
|
11281 | this.emitEvent( 'progress', [ this, this.element, message ] );
|
11282 | };
|
11283 |
|
11284 |
|
11285 |
|
11286 | ngImagesLoaded.makeJQueryPlugin = function( jQuery ) {
|
11287 | jQuery = jQuery || window.jQuery;
|
11288 | if ( !jQuery ) {
|
11289 | return;
|
11290 | }
|
11291 |
|
11292 | $ = jQuery;
|
11293 |
|
11294 | $.fn.ngimagesLoaded = function( options, callback ) {
|
11295 | var instance = new ngImagesLoaded( this, options, callback );
|
11296 | return instance.jqDeferred.promise( $(this) );
|
11297 | };
|
11298 | };
|
11299 |
|
11300 | ngImagesLoaded.makeJQueryPlugin();
|
11301 |
|
11302 |
|
11303 |
|
11304 | return ngImagesLoaded;
|
11305 |
|
11306 | });
|
11307 |
|
11308 |
|
11309 |
|
11310 |
|
11311 |
|
11312 |
|
11313 |
|
11314 |
|
11315 |
|
11316 |
|
11317 |
|
11318 |
|
11319 |
|
11320 |
|
11321 |
|
11322 |
|
11323 |
|
11324 | (function () {
|
11325 | 'use strict';
|
11326 |
|
11327 | var document = typeof window !== 'undefined' && typeof window.document !== 'undefined' ? window.document : {};
|
11328 | var isCommonjs = typeof module !== 'undefined' && module.exports;
|
11329 | var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element;
|
11330 |
|
11331 | var fn = (function () {
|
11332 | var val;
|
11333 |
|
11334 | var fnMap = [
|
11335 | [
|
11336 | 'requestFullscreen',
|
11337 | 'exitFullscreen',
|
11338 | 'fullscreenElement',
|
11339 | 'fullscreenEnabled',
|
11340 | 'fullscreenchange',
|
11341 | 'fullscreenerror'
|
11342 | ],
|
11343 |
|
11344 | [
|
11345 | 'webkitRequestFullscreen',
|
11346 | 'webkitExitFullscreen',
|
11347 | 'webkitFullscreenElement',
|
11348 | 'webkitFullscreenEnabled',
|
11349 | 'webkitfullscreenchange',
|
11350 | 'webkitfullscreenerror'
|
11351 |
|
11352 | ],
|
11353 |
|
11354 | [
|
11355 | 'webkitRequestFullScreen',
|
11356 | 'webkitCancelFullScreen',
|
11357 | 'webkitCurrentFullScreenElement',
|
11358 | 'webkitCancelFullScreen',
|
11359 | 'webkitfullscreenchange',
|
11360 | 'webkitfullscreenerror'
|
11361 |
|
11362 | ],
|
11363 | [
|
11364 | 'mozRequestFullScreen',
|
11365 | 'mozCancelFullScreen',
|
11366 | 'mozFullScreenElement',
|
11367 | 'mozFullScreenEnabled',
|
11368 | 'mozfullscreenchange',
|
11369 | 'mozfullscreenerror'
|
11370 | ],
|
11371 | [
|
11372 | 'msRequestFullscreen',
|
11373 | 'msExitFullscreen',
|
11374 | 'msFullscreenElement',
|
11375 | 'msFullscreenEnabled',
|
11376 | 'MSFullscreenChange',
|
11377 | 'MSFullscreenError'
|
11378 | ]
|
11379 | ];
|
11380 |
|
11381 | var i = 0;
|
11382 | var l = fnMap.length;
|
11383 | var ret = {};
|
11384 |
|
11385 | for (; i < l; i++) {
|
11386 | val = fnMap[i];
|
11387 | if (val && val[1] in document) {
|
11388 | for (i = 0; i < val.length; i++) {
|
11389 | ret[fnMap[0][i]] = val[i];
|
11390 | }
|
11391 | return ret;
|
11392 | }
|
11393 | }
|
11394 |
|
11395 | return false;
|
11396 | })();
|
11397 |
|
11398 | var eventNameMap = {
|
11399 | change: fn.fullscreenchange,
|
11400 | error: fn.fullscreenerror
|
11401 | };
|
11402 |
|
11403 | var ngscreenfull = {
|
11404 | request: function (elem) {
|
11405 | return new Promise(function (resolve) {
|
11406 | var request = fn.requestFullscreen;
|
11407 |
|
11408 | var onFullScreenEntered = function () {
|
11409 | this.off('change', onFullScreenEntered);
|
11410 | resolve();
|
11411 | }.bind(this);
|
11412 |
|
11413 | elem = elem || document.documentElement;
|
11414 |
|
11415 |
|
11416 |
|
11417 |
|
11418 |
|
11419 | if (/ Version\/5\.1(?:\.\d+)? Safari\//.test(navigator.userAgent)) {
|
11420 | elem[request]();
|
11421 | } else {
|
11422 | elem[request](keyboardAllowed ? Element.ALLOW_KEYBOARD_INPUT : {});
|
11423 | }
|
11424 |
|
11425 | this.on('change', onFullScreenEntered);
|
11426 | }.bind(this));
|
11427 | },
|
11428 | exit: function () {
|
11429 | return new Promise(function (resolve) {
|
11430 | if (!this.isFullscreen) {
|
11431 | resolve();
|
11432 | return;
|
11433 | }
|
11434 |
|
11435 | var onFullScreenExit = function () {
|
11436 | this.off('change', onFullScreenExit);
|
11437 | resolve();
|
11438 | }.bind(this);
|
11439 |
|
11440 | document[fn.exitFullscreen]();
|
11441 |
|
11442 | this.on('change', onFullScreenExit);
|
11443 | }.bind(this));
|
11444 | },
|
11445 | toggle: function (elem) {
|
11446 | return this.isFullscreen ? this.exit() : this.request(elem);
|
11447 | },
|
11448 | onchange: function (callback) {
|
11449 | this.on('change', callback);
|
11450 | },
|
11451 | onerror: function (callback) {
|
11452 | this.on('error', callback);
|
11453 | },
|
11454 | on: function (event, callback) {
|
11455 | var eventName = eventNameMap[event];
|
11456 | if (eventName) {
|
11457 | document.addEventListener(eventName, callback, false);
|
11458 | }
|
11459 | },
|
11460 | off: function (event, callback) {
|
11461 | var eventName = eventNameMap[event];
|
11462 | if (eventName) {
|
11463 | document.removeEventListener(eventName, callback, false);
|
11464 | }
|
11465 | },
|
11466 | raw: fn
|
11467 | };
|
11468 |
|
11469 | if (!fn) {
|
11470 | if (isCommonjs) {
|
11471 | module.exports = false;
|
11472 | } else {
|
11473 | window.ngscreenfull = false;
|
11474 | }
|
11475 |
|
11476 | return;
|
11477 | }
|
11478 |
|
11479 | Object.defineProperties(ngscreenfull, {
|
11480 | isFullscreen: {
|
11481 | get: function () {
|
11482 | return Boolean(document[fn.fullscreenElement]);
|
11483 | }
|
11484 | },
|
11485 | element: {
|
11486 | enumerable: true,
|
11487 | get: function () {
|
11488 | return document[fn.fullscreenElement];
|
11489 | }
|
11490 | },
|
11491 | enabled: {
|
11492 | enumerable: true,
|
11493 | get: function () {
|
11494 |
|
11495 | return Boolean(document[fn.fullscreenEnabled]);
|
11496 | }
|
11497 | }
|
11498 | });
|
11499 |
|
11500 | if (isCommonjs) {
|
11501 | module.exports = ngscreenfull;
|
11502 | } else {
|
11503 | window.ngscreenfull = ngscreenfull;
|
11504 | }
|
11505 | })();
|
11506 |
|
11507 |
|
11508 |
|
11509 |
|
11510 |
|
11511 |
|
11512 |
|
11513 | |
11514 |
|
11515 |
|
11516 |
|
11517 |
|
11518 |
|
11519 |
|
11520 |
|
11521 |
|
11522 |
|
11523 |
|
11524 | ;(function () {
|
11525 | var root = this || Function('return this')();
|
11526 |
|
11527 |
|
11528 |
|
11529 |
|
11530 |
|
11531 |
|
11532 | var NGTweenable = (function () {
|
11533 |
|
11534 | 'use strict';
|
11535 |
|
11536 |
|
11537 | var formula;
|
11538 |
|
11539 |
|
11540 | var DEFAULT_SCHEDULE_FUNCTION;
|
11541 | var DEFAULT_EASING = 'linear';
|
11542 | var DEFAULT_DURATION = 500;
|
11543 | var UPDATE_TIME = 1000 / 60;
|
11544 |
|
11545 | var _now = Date.now
|
11546 | ? Date.now
|
11547 | : function () {return +new Date();};
|
11548 |
|
11549 | var now = typeof SHIFTY_DEBUG_NOW !== 'undefined' ? SHIFTY_DEBUG_NOW : _now;
|
11550 |
|
11551 | if (typeof window !== 'undefined') {
|
11552 |
|
11553 |
|
11554 | DEFAULT_SCHEDULE_FUNCTION = window.requestAnimationFrame
|
11555 | || window.webkitRequestAnimationFrame
|
11556 | || window.oRequestAnimationFrame
|
11557 | || window.msRequestAnimationFrame
|
11558 | || (window.mozCancelRequestAnimationFrame
|
11559 | && window.mozRequestAnimationFrame)
|
11560 | || setTimeout;
|
11561 | } else {
|
11562 | DEFAULT_SCHEDULE_FUNCTION = setTimeout;
|
11563 | }
|
11564 |
|
11565 | function noop () {
|
11566 |
|
11567 | }
|
11568 |
|
11569 | |
11570 |
|
11571 |
|
11572 |
|
11573 |
|
11574 |
|
11575 |
|
11576 |
|
11577 | function each (obj, fn) {
|
11578 | var key;
|
11579 | for (key in obj) {
|
11580 | if (Object.hasOwnProperty.call(obj, key)) {
|
11581 | fn(key);
|
11582 | }
|
11583 | }
|
11584 | }
|
11585 |
|
11586 | |
11587 |
|
11588 |
|
11589 |
|
11590 |
|
11591 |
|
11592 |
|
11593 | function shallowCopy (targetObj, srcObj) {
|
11594 | each(srcObj, function (prop) {
|
11595 | targetObj[prop] = srcObj[prop];
|
11596 | });
|
11597 |
|
11598 | return targetObj;
|
11599 | }
|
11600 |
|
11601 | |
11602 |
|
11603 |
|
11604 |
|
11605 |
|
11606 |
|
11607 |
|
11608 | function defaults (target, src) {
|
11609 | each(src, function (prop) {
|
11610 | if (typeof target[prop] === 'undefined') {
|
11611 | target[prop] = src[prop];
|
11612 | }
|
11613 | });
|
11614 | }
|
11615 |
|
11616 | |
11617 |
|
11618 |
|
11619 |
|
11620 |
|
11621 |
|
11622 |
|
11623 |
|
11624 |
|
11625 |
|
11626 |
|
11627 |
|
11628 |
|
11629 |
|
11630 |
|
11631 | function tweenProps (forPosition, currentState, originalState, targetState,
|
11632 | duration, timestamp, easing) {
|
11633 | var normalizedPosition =
|
11634 | forPosition < timestamp ? 0 : (forPosition - timestamp) / duration;
|
11635 |
|
11636 |
|
11637 | var prop;
|
11638 | var easingObjectProp;
|
11639 | var easingFn;
|
11640 | for (prop in currentState) {
|
11641 | if (currentState.hasOwnProperty(prop)) {
|
11642 | easingObjectProp = easing[prop];
|
11643 | easingFn = typeof easingObjectProp === 'function'
|
11644 | ? easingObjectProp
|
11645 | : formula[easingObjectProp];
|
11646 |
|
11647 | currentState[prop] = tweenProp(
|
11648 | originalState[prop],
|
11649 | targetState[prop],
|
11650 | easingFn,
|
11651 | normalizedPosition
|
11652 | );
|
11653 | }
|
11654 | }
|
11655 |
|
11656 | return currentState;
|
11657 | }
|
11658 |
|
11659 | |
11660 |
|
11661 |
|
11662 |
|
11663 |
|
11664 |
|
11665 |
|
11666 |
|
11667 |
|
11668 |
|
11669 | function tweenProp (start, end, easingFunc, position) {
|
11670 | return start + (end - start) * easingFunc(position);
|
11671 | }
|
11672 |
|
11673 | |
11674 |
|
11675 |
|
11676 |
|
11677 |
|
11678 |
|
11679 |
|
11680 | function applyFilter (tweenable, filterName) {
|
11681 | var filters = NGTweenable.prototype.filter;
|
11682 | var args = tweenable._filterArgs;
|
11683 |
|
11684 | each(filters, function (name) {
|
11685 | if (typeof filters[name][filterName] !== 'undefined') {
|
11686 | filters[name][filterName].apply(tweenable, args);
|
11687 | }
|
11688 | });
|
11689 | }
|
11690 |
|
11691 | var timeoutHandler_endTime;
|
11692 | var timeoutHandler_currentTime;
|
11693 | var timeoutHandler_isEnded;
|
11694 | var timeoutHandler_offset;
|
11695 | |
11696 |
|
11697 |
|
11698 |
|
11699 |
|
11700 |
|
11701 |
|
11702 |
|
11703 |
|
11704 |
|
11705 |
|
11706 |
|
11707 |
|
11708 |
|
11709 |
|
11710 |
|
11711 | function timeoutHandler (tweenable, timestamp, delay, duration, currentState,
|
11712 | originalState, targetState, easing, step, schedule,
|
11713 | opt_currentTimeOverride) {
|
11714 |
|
11715 | timeoutHandler_endTime = timestamp + delay + duration;
|
11716 |
|
11717 | timeoutHandler_currentTime =
|
11718 | Math.min(opt_currentTimeOverride || now(), timeoutHandler_endTime);
|
11719 |
|
11720 | timeoutHandler_isEnded =
|
11721 | timeoutHandler_currentTime >= timeoutHandler_endTime;
|
11722 |
|
11723 | timeoutHandler_offset = duration - (
|
11724 | timeoutHandler_endTime - timeoutHandler_currentTime);
|
11725 |
|
11726 | if (tweenable.isPlaying()) {
|
11727 | if (timeoutHandler_isEnded) {
|
11728 | step(targetState, tweenable._attachment, timeoutHandler_offset);
|
11729 | tweenable.stop(true);
|
11730 | } else {
|
11731 | tweenable._scheduleId =
|
11732 | schedule(tweenable._timeoutHandler, UPDATE_TIME);
|
11733 |
|
11734 | applyFilter(tweenable, 'beforeTween');
|
11735 |
|
11736 |
|
11737 |
|
11738 |
|
11739 | if (timeoutHandler_currentTime < (timestamp + delay)) {
|
11740 | tweenProps(1, currentState, originalState, targetState, 1, 1, easing);
|
11741 | } else {
|
11742 | tweenProps(timeoutHandler_currentTime, currentState, originalState,
|
11743 | targetState, duration, timestamp + delay, easing);
|
11744 | }
|
11745 |
|
11746 | applyFilter(tweenable, 'afterTween');
|
11747 |
|
11748 | step(currentState, tweenable._attachment, timeoutHandler_offset);
|
11749 | }
|
11750 | }
|
11751 | }
|
11752 |
|
11753 |
|
11754 | |
11755 |
|
11756 |
|
11757 |
|
11758 |
|
11759 |
|
11760 |
|
11761 |
|
11762 |
|
11763 | function composeEasingObject (fromTweenParams, easing) {
|
11764 | var composedEasing = {};
|
11765 | var typeofEasing = typeof easing;
|
11766 |
|
11767 | if (typeofEasing === 'string' || typeofEasing === 'function') {
|
11768 | each(fromTweenParams, function (prop) {
|
11769 | composedEasing[prop] = easing;
|
11770 | });
|
11771 | } else {
|
11772 | each(fromTweenParams, function (prop) {
|
11773 | if (!composedEasing[prop]) {
|
11774 | composedEasing[prop] = easing[prop] || DEFAULT_EASING;
|
11775 | }
|
11776 | });
|
11777 | }
|
11778 |
|
11779 | return composedEasing;
|
11780 | }
|
11781 |
|
11782 | |
11783 |
|
11784 |
|
11785 |
|
11786 |
|
11787 |
|
11788 |
|
11789 |
|
11790 |
|
11791 |
|
11792 |
|
11793 |
|
11794 | function NGTweenable (opt_initialState, opt_config) {
|
11795 | this._currentState = opt_initialState || {};
|
11796 | this._configured = false;
|
11797 | this._scheduleFunction = DEFAULT_SCHEDULE_FUNCTION;
|
11798 |
|
11799 |
|
11800 |
|
11801 |
|
11802 | if (typeof opt_config !== 'undefined') {
|
11803 | this.setConfig(opt_config);
|
11804 | }
|
11805 | }
|
11806 |
|
11807 | |
11808 |
|
11809 |
|
11810 |
|
11811 |
|
11812 |
|
11813 |
|
11814 | NGTweenable.prototype.tween = function (opt_config) {
|
11815 | if (this._isTweening) {
|
11816 | return this;
|
11817 | }
|
11818 |
|
11819 |
|
11820 |
|
11821 | if (opt_config !== undefined || !this._configured) {
|
11822 | this.setConfig(opt_config);
|
11823 | }
|
11824 |
|
11825 | this._timestamp = now();
|
11826 | this._start(this.get(), this._attachment);
|
11827 | return this.resume();
|
11828 | };
|
11829 |
|
11830 | |
11831 |
|
11832 |
|
11833 |
|
11834 |
|
11835 |
|
11836 |
|
11837 |
|
11838 |
|
11839 |
|
11840 |
|
11841 |
|
11842 |
|
11843 |
|
11844 |
|
11845 |
|
11846 |
|
11847 |
|
11848 |
|
11849 |
|
11850 |
|
11851 |
|
11852 |
|
11853 |
|
11854 |
|
11855 |
|
11856 |
|
11857 |
|
11858 |
|
11859 | NGTweenable.prototype.setConfig = function (config) {
|
11860 | config = config || {};
|
11861 | this._configured = true;
|
11862 |
|
11863 |
|
11864 |
|
11865 | this._attachment = config.attachment;
|
11866 |
|
11867 |
|
11868 | this._pausedAtTime = null;
|
11869 | this._scheduleId = null;
|
11870 | this._delay = config.delay || 0;
|
11871 | this._start = config.start || noop;
|
11872 | this._step = config.step || noop;
|
11873 | this._finish = config.finish || noop;
|
11874 | this._duration = config.duration || DEFAULT_DURATION;
|
11875 | this._currentState = shallowCopy({}, config.from || this.get());
|
11876 | this._originalState = this.get();
|
11877 | this._targetState = shallowCopy({}, config.to || this.get());
|
11878 |
|
11879 | var self = this;
|
11880 | this._timeoutHandler = function () {
|
11881 | timeoutHandler(self,
|
11882 | self._timestamp,
|
11883 | self._delay,
|
11884 | self._duration,
|
11885 | self._currentState,
|
11886 | self._originalState,
|
11887 | self._targetState,
|
11888 | self._easing,
|
11889 | self._step,
|
11890 | self._scheduleFunction
|
11891 | );
|
11892 | };
|
11893 |
|
11894 |
|
11895 | var currentState = this._currentState;
|
11896 | var targetState = this._targetState;
|
11897 |
|
11898 |
|
11899 | defaults(targetState, currentState);
|
11900 |
|
11901 | this._easing = composeEasingObject(
|
11902 | currentState, config.easing || DEFAULT_EASING);
|
11903 |
|
11904 | this._filterArgs =
|
11905 | [currentState, this._originalState, targetState, this._easing];
|
11906 |
|
11907 | applyFilter(this, 'tweenCreated');
|
11908 | return this;
|
11909 | };
|
11910 |
|
11911 | |
11912 |
|
11913 |
|
11914 |
|
11915 | NGTweenable.prototype.get = function () {
|
11916 | return shallowCopy({}, this._currentState);
|
11917 | };
|
11918 |
|
11919 | |
11920 |
|
11921 |
|
11922 |
|
11923 | NGTweenable.prototype.set = function (state) {
|
11924 | this._currentState = state;
|
11925 | };
|
11926 |
|
11927 | |
11928 |
|
11929 |
|
11930 |
|
11931 |
|
11932 |
|
11933 |
|
11934 |
|
11935 | NGTweenable.prototype.pause = function () {
|
11936 | this._pausedAtTime = now();
|
11937 | this._isPaused = true;
|
11938 | return this;
|
11939 | };
|
11940 |
|
11941 | |
11942 |
|
11943 |
|
11944 |
|
11945 |
|
11946 | NGTweenable.prototype.resume = function () {
|
11947 | if (this._isPaused) {
|
11948 | this._timestamp += now() - this._pausedAtTime;
|
11949 | }
|
11950 |
|
11951 | this._isPaused = false;
|
11952 | this._isTweening = true;
|
11953 |
|
11954 | this._timeoutHandler();
|
11955 |
|
11956 | return this;
|
11957 | };
|
11958 |
|
11959 | |
11960 |
|
11961 |
|
11962 |
|
11963 |
|
11964 |
|
11965 |
|
11966 |
|
11967 |
|
11968 | NGTweenable.prototype.seek = function (millisecond) {
|
11969 | millisecond = Math.max(millisecond, 0);
|
11970 | var currentTime = now();
|
11971 |
|
11972 | if ((this._timestamp + millisecond) === 0) {
|
11973 | return this;
|
11974 | }
|
11975 |
|
11976 | this._timestamp = currentTime - millisecond;
|
11977 |
|
11978 | if (!this.isPlaying()) {
|
11979 | this._isTweening = true;
|
11980 | this._isPaused = false;
|
11981 |
|
11982 |
|
11983 |
|
11984 | timeoutHandler(this,
|
11985 | this._timestamp,
|
11986 | this._delay,
|
11987 | this._duration,
|
11988 | this._currentState,
|
11989 | this._originalState,
|
11990 | this._targetState,
|
11991 | this._easing,
|
11992 | this._step,
|
11993 | this._scheduleFunction,
|
11994 | currentTime
|
11995 | );
|
11996 |
|
11997 | this.pause();
|
11998 | }
|
11999 |
|
12000 | return this;
|
12001 | };
|
12002 |
|
12003 | |
12004 |
|
12005 |
|
12006 |
|
12007 |
|
12008 |
|
12009 |
|
12010 |
|
12011 |
|
12012 | NGTweenable.prototype.stop = function (gotoEnd) {
|
12013 | this._isTweening = false;
|
12014 | this._isPaused = false;
|
12015 | this._timeoutHandler = noop;
|
12016 |
|
12017 | (root.cancelAnimationFrame ||
|
12018 | root.webkitCancelAnimationFrame ||
|
12019 | root.oCancelAnimationFrame ||
|
12020 | root.msCancelAnimationFrame ||
|
12021 | root.mozCancelRequestAnimationFrame ||
|
12022 | root.clearTimeout)(this._scheduleId);
|
12023 |
|
12024 | if (gotoEnd) {
|
12025 | applyFilter(this, 'beforeTween');
|
12026 | tweenProps(
|
12027 | 1,
|
12028 | this._currentState,
|
12029 | this._originalState,
|
12030 | this._targetState,
|
12031 | 1,
|
12032 | 0,
|
12033 | this._easing
|
12034 | );
|
12035 | applyFilter(this, 'afterTween');
|
12036 | applyFilter(this, 'afterTweenEnd');
|
12037 | this._finish.call(this, this._currentState, this._attachment);
|
12038 | }
|
12039 |
|
12040 | return this;
|
12041 | };
|
12042 |
|
12043 | |
12044 |
|
12045 |
|
12046 |
|
12047 | NGTweenable.prototype.isPlaying = function () {
|
12048 | return this._isTweening && !this._isPaused;
|
12049 | };
|
12050 |
|
12051 | |
12052 |
|
12053 |
|
12054 |
|
12055 |
|
12056 |
|
12057 |
|
12058 |
|
12059 |
|
12060 |
|
12061 |
|
12062 |
|
12063 | NGTweenable.prototype.setScheduleFunction = function (scheduleFunction) {
|
12064 | this._scheduleFunction = scheduleFunction;
|
12065 | };
|
12066 |
|
12067 | |
12068 |
|
12069 |
|
12070 |
|
12071 |
|
12072 | NGTweenable.prototype.dispose = function () {
|
12073 | var prop;
|
12074 | for (prop in this) {
|
12075 | if (this.hasOwnProperty(prop)) {
|
12076 | delete this[prop];
|
12077 | }
|
12078 | }
|
12079 | };
|
12080 |
|
12081 | |
12082 |
|
12083 |
|
12084 |
|
12085 |
|
12086 | NGTweenable.prototype.filter = {};
|
12087 |
|
12088 | |
12089 |
|
12090 |
|
12091 |
|
12092 |
|
12093 |
|
12094 |
|
12095 |
|
12096 |
|
12097 | NGTweenable.prototype.formula = {
|
12098 | linear: function (pos) {
|
12099 | return pos;
|
12100 | }
|
12101 | };
|
12102 |
|
12103 | formula = NGTweenable.prototype.formula;
|
12104 |
|
12105 | shallowCopy(NGTweenable, {
|
12106 | 'now': now
|
12107 | ,'each': each
|
12108 | ,'tweenProps': tweenProps
|
12109 | ,'tweenProp': tweenProp
|
12110 | ,'applyFilter': applyFilter
|
12111 | ,'shallowCopy': shallowCopy
|
12112 | ,'defaults': defaults
|
12113 | ,'composeEasingObject': composeEasingObject
|
12114 | });
|
12115 |
|
12116 |
|
12117 |
|
12118 |
|
12119 | if (typeof SHIFTY_DEBUG_NOW === 'function') {
|
12120 | root.timeoutHandler = timeoutHandler;
|
12121 | }
|
12122 |
|
12123 |
|
12124 | if (typeof exports === 'object') {
|
12125 |
|
12126 | module.exports = NGTweenable;
|
12127 | } else if (typeof define === 'function' && define.amdDISABLED) {
|
12128 |
|
12129 | define(function () {return NGTweenable;});
|
12130 | } else if (typeof root.NGTweenable === 'undefined') {
|
12131 |
|
12132 | root.NGTweenable = NGTweenable;
|
12133 | }
|
12134 |
|
12135 | return NGTweenable;
|
12136 |
|
12137 | } ());
|
12138 |
|
12139 |
|
12140 |
|
12141 |
|
12142 |
|
12143 |
|
12144 |
|
12145 |
|
12146 |
|
12147 |
|
12148 |
|
12149 |
|
12150 |
|
12151 |
|
12152 |
|
12153 |
|
12154 | ;(function () {
|
12155 |
|
12156 | NGTweenable.shallowCopy(NGTweenable.prototype.formula, {
|
12157 | easeInQuad: function (pos) {
|
12158 | return Math.pow(pos, 2);
|
12159 | },
|
12160 |
|
12161 | easeOutQuad: function (pos) {
|
12162 | return -(Math.pow((pos - 1), 2) - 1);
|
12163 | },
|
12164 |
|
12165 | easeInOutQuad: function (pos) {
|
12166 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,2);}
|
12167 | return -0.5 * ((pos -= 2) * pos - 2);
|
12168 | },
|
12169 |
|
12170 | easeInCubic: function (pos) {
|
12171 | return Math.pow(pos, 3);
|
12172 | },
|
12173 |
|
12174 | easeOutCubic: function (pos) {
|
12175 | return (Math.pow((pos - 1), 3) + 1);
|
12176 | },
|
12177 |
|
12178 | easeInOutCubic: function (pos) {
|
12179 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,3);}
|
12180 | return 0.5 * (Math.pow((pos - 2),3) + 2);
|
12181 | },
|
12182 |
|
12183 | easeInQuart: function (pos) {
|
12184 | return Math.pow(pos, 4);
|
12185 | },
|
12186 |
|
12187 | easeOutQuart: function (pos) {
|
12188 | return -(Math.pow((pos - 1), 4) - 1);
|
12189 | },
|
12190 |
|
12191 | easeInOutQuart: function (pos) {
|
12192 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,4);}
|
12193 | return -0.5 * ((pos -= 2) * Math.pow(pos,3) - 2);
|
12194 | },
|
12195 |
|
12196 | easeInQuint: function (pos) {
|
12197 | return Math.pow(pos, 5);
|
12198 | },
|
12199 |
|
12200 | easeOutQuint: function (pos) {
|
12201 | return (Math.pow((pos - 1), 5) + 1);
|
12202 | },
|
12203 |
|
12204 | easeInOutQuint: function (pos) {
|
12205 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,5);}
|
12206 | return 0.5 * (Math.pow((pos - 2),5) + 2);
|
12207 | },
|
12208 |
|
12209 | easeInSine: function (pos) {
|
12210 | return -Math.cos(pos * (Math.PI / 2)) + 1;
|
12211 | },
|
12212 |
|
12213 | easeOutSine: function (pos) {
|
12214 | return Math.sin(pos * (Math.PI / 2));
|
12215 | },
|
12216 |
|
12217 | easeInOutSine: function (pos) {
|
12218 | return (-0.5 * (Math.cos(Math.PI * pos) - 1));
|
12219 | },
|
12220 |
|
12221 | easeInExpo: function (pos) {
|
12222 | return (pos === 0) ? 0 : Math.pow(2, 10 * (pos - 1));
|
12223 | },
|
12224 |
|
12225 | easeOutExpo: function (pos) {
|
12226 | return (pos === 1) ? 1 : -Math.pow(2, -10 * pos) + 1;
|
12227 | },
|
12228 |
|
12229 | easeInOutExpo: function (pos) {
|
12230 | if (pos === 0) {return 0;}
|
12231 | if (pos === 1) {return 1;}
|
12232 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(2,10 * (pos - 1));}
|
12233 | return 0.5 * (-Math.pow(2, -10 * --pos) + 2);
|
12234 | },
|
12235 |
|
12236 | easeInCirc: function (pos) {
|
12237 | return -(Math.sqrt(1 - (pos * pos)) - 1);
|
12238 | },
|
12239 |
|
12240 | easeOutCirc: function (pos) {
|
12241 | return Math.sqrt(1 - Math.pow((pos - 1), 2));
|
12242 | },
|
12243 |
|
12244 | easeInOutCirc: function (pos) {
|
12245 | if ((pos /= 0.5) < 1) {return -0.5 * (Math.sqrt(1 - pos * pos) - 1);}
|
12246 | return 0.5 * (Math.sqrt(1 - (pos -= 2) * pos) + 1);
|
12247 | },
|
12248 |
|
12249 | easeOutBounce: function (pos) {
|
12250 | if ((pos) < (1 / 2.75)) {
|
12251 | return (7.5625 * pos * pos);
|
12252 | } else if (pos < (2 / 2.75)) {
|
12253 | return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
|
12254 | } else if (pos < (2.5 / 2.75)) {
|
12255 | return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
|
12256 | } else {
|
12257 | return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
|
12258 | }
|
12259 | },
|
12260 |
|
12261 | easeInBack: function (pos) {
|
12262 | var s = 1.70158;
|
12263 | return (pos) * pos * ((s + 1) * pos - s);
|
12264 | },
|
12265 |
|
12266 | easeOutBack: function (pos) {
|
12267 | var s = 1.70158;
|
12268 | return (pos = pos - 1) * pos * ((s + 1) * pos + s) + 1;
|
12269 | },
|
12270 |
|
12271 | easeInOutBack: function (pos) {
|
12272 | var s = 1.70158;
|
12273 | if ((pos /= 0.5) < 1) {
|
12274 | return 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s));
|
12275 | }
|
12276 | return 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
|
12277 | },
|
12278 |
|
12279 | elastic: function (pos) {
|
12280 |
|
12281 | return -1 * Math.pow(4,-8 * pos) * Math.sin((pos * 6 - 1) * (2 * Math.PI) / 2) + 1;
|
12282 | },
|
12283 |
|
12284 | swingFromTo: function (pos) {
|
12285 | var s = 1.70158;
|
12286 | return ((pos /= 0.5) < 1) ?
|
12287 | 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s)) :
|
12288 | 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
|
12289 | },
|
12290 |
|
12291 | swingFrom: function (pos) {
|
12292 | var s = 1.70158;
|
12293 | return pos * pos * ((s + 1) * pos - s);
|
12294 | },
|
12295 |
|
12296 | swingTo: function (pos) {
|
12297 | var s = 1.70158;
|
12298 | return (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
|
12299 | },
|
12300 |
|
12301 | bounce: function (pos) {
|
12302 | if (pos < (1 / 2.75)) {
|
12303 | return (7.5625 * pos * pos);
|
12304 | } else if (pos < (2 / 2.75)) {
|
12305 | return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
|
12306 | } else if (pos < (2.5 / 2.75)) {
|
12307 | return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
|
12308 | } else {
|
12309 | return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
|
12310 | }
|
12311 | },
|
12312 |
|
12313 | bouncePast: function (pos) {
|
12314 | if (pos < (1 / 2.75)) {
|
12315 | return (7.5625 * pos * pos);
|
12316 | } else if (pos < (2 / 2.75)) {
|
12317 | return 2 - (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
|
12318 | } else if (pos < (2.5 / 2.75)) {
|
12319 | return 2 - (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
|
12320 | } else {
|
12321 | return 2 - (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
|
12322 | }
|
12323 | },
|
12324 |
|
12325 | easeFromTo: function (pos) {
|
12326 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,4);}
|
12327 | return -0.5 * ((pos -= 2) * Math.pow(pos,3) - 2);
|
12328 | },
|
12329 |
|
12330 | easeFrom: function (pos) {
|
12331 | return Math.pow(pos,4);
|
12332 | },
|
12333 |
|
12334 | easeTo: function (pos) {
|
12335 | return Math.pow(pos,0.25);
|
12336 | }
|
12337 | });
|
12338 |
|
12339 | }());
|
12340 |
|
12341 |
|
12342 |
|
12343 |
|
12344 |
|
12345 |
|
12346 |
|
12347 |
|
12348 |
|
12349 |
|
12350 |
|
12351 |
|
12352 |
|
12353 |
|
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 | ;(function () {
|
12380 |
|
12381 | function cubicBezierAtTime(t,p1x,p1y,p2x,p2y,duration) {
|
12382 | var ax = 0,bx = 0,cx = 0,ay = 0,by = 0,cy = 0;
|
12383 | function sampleCurveX(t) {
|
12384 | return ((ax * t + bx) * t + cx) * t;
|
12385 | }
|
12386 | function sampleCurveY(t) {
|
12387 | return ((ay * t + by) * t + cy) * t;
|
12388 | }
|
12389 | function sampleCurveDerivativeX(t) {
|
12390 | return (3.0 * ax * t + 2.0 * bx) * t + cx;
|
12391 | }
|
12392 | function solveEpsilon(duration) {
|
12393 | return 1.0 / (200.0 * duration);
|
12394 | }
|
12395 | function solve(x,epsilon) {
|
12396 | return sampleCurveY(solveCurveX(x, epsilon));
|
12397 | }
|
12398 | function fabs(n) {
|
12399 | if (n >= 0) {
|
12400 | return n;
|
12401 | } else {
|
12402 | return 0 - n;
|
12403 | }
|
12404 | }
|
12405 | function solveCurveX(x, epsilon) {
|
12406 | var t0,t1,t2,x2,d2,i;
|
12407 | for (t2 = x, i = 0; i < 8; i++) {
|
12408 | x2 = sampleCurveX(t2) - x;
|
12409 | if (fabs(x2) < epsilon) {
|
12410 | return t2;
|
12411 | }
|
12412 | d2 = sampleCurveDerivativeX(t2);
|
12413 | if (fabs(d2) < 1e-6) {
|
12414 | break;
|
12415 | }
|
12416 | t2 = t2 - x2 / d2;
|
12417 | }
|
12418 | t0 = 0.0;
|
12419 | t1 = 1.0;
|
12420 | t2 = x;
|
12421 | if (t2 < t0) {
|
12422 | return t0;
|
12423 | }
|
12424 | if (t2 > t1) {
|
12425 | return t1;
|
12426 | }
|
12427 | while (t0 < t1) {
|
12428 | x2 = sampleCurveX(t2);
|
12429 | if (fabs(x2 - x) < epsilon) {
|
12430 | return t2;
|
12431 | }
|
12432 | if (x > x2) {
|
12433 | t0 = t2;
|
12434 | }else {
|
12435 | t1 = t2;
|
12436 | }
|
12437 | t2 = (t1 - t0) * 0.5 + t0;
|
12438 | }
|
12439 | return t2;
|
12440 | }
|
12441 | cx = 3.0 * p1x;
|
12442 | bx = 3.0 * (p2x - p1x) - cx;
|
12443 | ax = 1.0 - cx - bx;
|
12444 | cy = 3.0 * p1y;
|
12445 | by = 3.0 * (p2y - p1y) - cy;
|
12446 | ay = 1.0 - cy - by;
|
12447 | return solve(t, solveEpsilon(duration));
|
12448 | }
|
12449 | |
12450 |
|
12451 |
|
12452 |
|
12453 |
|
12454 |
|
12455 |
|
12456 |
|
12457 |
|
12458 |
|
12459 |
|
12460 |
|
12461 |
|
12462 |
|
12463 |
|
12464 |
|
12465 |
|
12466 | function getCubicBezierTransition (x1, y1, x2, y2) {
|
12467 | return function (pos) {
|
12468 | return cubicBezierAtTime(pos,x1,y1,x2,y2,1);
|
12469 | };
|
12470 | }
|
12471 |
|
12472 |
|
12473 | |
12474 |
|
12475 |
|
12476 |
|
12477 |
|
12478 |
|
12479 |
|
12480 |
|
12481 |
|
12482 |
|
12483 |
|
12484 |
|
12485 |
|
12486 |
|
12487 |
|
12488 |
|
12489 |
|
12490 |
|
12491 | NGTweenable.setBezierFunction = function (name, x1, y1, x2, y2) {
|
12492 | var cubicBezierTransition = getCubicBezierTransition(x1, y1, x2, y2);
|
12493 | cubicBezierTransition.displayName = name;
|
12494 | cubicBezierTransition.x1 = x1;
|
12495 | cubicBezierTransition.y1 = y1;
|
12496 | cubicBezierTransition.x2 = x2;
|
12497 | cubicBezierTransition.y2 = y2;
|
12498 |
|
12499 | return NGTweenable.prototype.formula[name] = cubicBezierTransition;
|
12500 | };
|
12501 |
|
12502 |
|
12503 | |
12504 |
|
12505 |
|
12506 |
|
12507 |
|
12508 |
|
12509 |
|
12510 |
|
12511 |
|
12512 | NGTweenable.unsetBezierFunction = function (name) {
|
12513 | delete NGTweenable.prototype.formula[name];
|
12514 | };
|
12515 |
|
12516 | })();
|
12517 |
|
12518 | ;(function () {
|
12519 |
|
12520 | function getInterpolatedValues (
|
12521 | from, current, targetState, position, easing, delay) {
|
12522 | return NGTweenable.tweenProps(
|
12523 | position, current, from, targetState, 1, delay, easing);
|
12524 | }
|
12525 |
|
12526 |
|
12527 |
|
12528 |
|
12529 | var mockNGTweenable = new NGTweenable();
|
12530 | mockNGTweenable._filterArgs = [];
|
12531 |
|
12532 | |
12533 |
|
12534 |
|
12535 |
|
12536 |
|
12537 |
|
12538 |
|
12539 |
|
12540 |
|
12541 |
|
12542 |
|
12543 |
|
12544 |
|
12545 |
|
12546 |
|
12547 |
|
12548 |
|
12549 |
|
12550 |
|
12551 |
|
12552 |
|
12553 |
|
12554 |
|
12555 |
|
12556 |
|
12557 |
|
12558 |
|
12559 |
|
12560 |
|
12561 |
|
12562 |
|
12563 |
|
12564 |
|
12565 |
|
12566 |
|
12567 |
|
12568 | NGTweenable.interpolate = function (
|
12569 | from, targetState, position, easing, opt_delay) {
|
12570 |
|
12571 | var current = NGTweenable.shallowCopy({}, from);
|
12572 | var delay = opt_delay || 0;
|
12573 | var easingObject = NGTweenable.composeEasingObject(
|
12574 | from, easing || 'linear');
|
12575 |
|
12576 | mockNGTweenable.set({});
|
12577 |
|
12578 |
|
12579 | var filterArgs = mockNGTweenable._filterArgs;
|
12580 | filterArgs.length = 0;
|
12581 | filterArgs[0] = current;
|
12582 | filterArgs[1] = from;
|
12583 | filterArgs[2] = targetState;
|
12584 | filterArgs[3] = easingObject;
|
12585 |
|
12586 |
|
12587 | NGTweenable.applyFilter(mockNGTweenable, 'tweenCreated');
|
12588 | NGTweenable.applyFilter(mockNGTweenable, 'beforeTween');
|
12589 |
|
12590 | var interpolatedValues = getInterpolatedValues(
|
12591 | from, current, targetState, position, easingObject, delay);
|
12592 |
|
12593 |
|
12594 | NGTweenable.applyFilter(mockNGTweenable, 'afterTween');
|
12595 |
|
12596 | return interpolatedValues;
|
12597 | };
|
12598 |
|
12599 | }());
|
12600 |
|
12601 |
|
12602 |
|
12603 |
|
12604 |
|
12605 |
|
12606 |
|
12607 |
|
12608 |
|
12609 |
|
12610 |
|
12611 |
|
12612 |
|
12613 |
|
12614 |
|
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 | ;(function (NGTweenable) {
|
12738 |
|
12739 | |
12740 |
|
12741 |
|
12742 |
|
12743 |
|
12744 |
|
12745 |
|
12746 | var formatManifest;
|
12747 |
|
12748 |
|
12749 |
|
12750 | var R_NUMBER_COMPONENT = /(\d|\-|\.)/;
|
12751 | var R_FORMAT_CHUNKS = /([^\-0-9\.]+)/g;
|
12752 | var R_UNFORMATTED_VALUES = /[0-9.\-]+/g;
|
12753 | var R_RGB = new RegExp(
|
12754 | 'rgb\\(' + R_UNFORMATTED_VALUES.source +
|
12755 | (/,\s*/.source) + R_UNFORMATTED_VALUES.source +
|
12756 | (/,\s*/.source) + R_UNFORMATTED_VALUES.source + '\\)', 'g');
|
12757 | var R_RGB_PREFIX = /^.*\(/;
|
12758 | var R_HEX = /#([0-9]|[a-f]){3,6}/gi;
|
12759 | var VALUE_PLACEHOLDER = 'VAL';
|
12760 |
|
12761 |
|
12762 |
|
12763 | |
12764 |
|
12765 |
|
12766 |
|
12767 |
|
12768 |
|
12769 |
|
12770 | function getFormatChunksFrom (rawValues, prefix) {
|
12771 | var accumulator = [];
|
12772 |
|
12773 | var rawValuesLength = rawValues.length;
|
12774 | var i;
|
12775 |
|
12776 | for (i = 0; i < rawValuesLength; i++) {
|
12777 | accumulator.push('_' + prefix + '_' + i);
|
12778 | }
|
12779 |
|
12780 | return accumulator;
|
12781 | }
|
12782 |
|
12783 | |
12784 |
|
12785 |
|
12786 |
|
12787 |
|
12788 |
|
12789 | function getFormatStringFrom (formattedString) {
|
12790 | var chunks = formattedString.match(R_FORMAT_CHUNKS);
|
12791 |
|
12792 | if (!chunks) {
|
12793 |
|
12794 |
|
12795 |
|
12796 | chunks = ['', ''];
|
12797 |
|
12798 |
|
12799 |
|
12800 |
|
12801 | } else if (chunks.length === 1 ||
|
12802 |
|
12803 |
|
12804 | formattedString.charAt(0).match(R_NUMBER_COMPONENT)) {
|
12805 |
|
12806 |
|
12807 | chunks.unshift('');
|
12808 | }
|
12809 |
|
12810 | return chunks.join(VALUE_PLACEHOLDER);
|
12811 | }
|
12812 |
|
12813 | |
12814 |
|
12815 |
|
12816 |
|
12817 |
|
12818 |
|
12819 |
|
12820 |
|
12821 | function sanitizeObjectForHexProps (stateObject) {
|
12822 | NGTweenable.each(stateObject, function (prop) {
|
12823 | var currentProp = stateObject[prop];
|
12824 |
|
12825 | if (typeof currentProp === 'string' && currentProp.match(R_HEX)) {
|
12826 | stateObject[prop] = sanitizeHexChunksToRGB(currentProp);
|
12827 | }
|
12828 | });
|
12829 | }
|
12830 |
|
12831 | |
12832 |
|
12833 |
|
12834 |
|
12835 |
|
12836 |
|
12837 | function sanitizeHexChunksToRGB (str) {
|
12838 | return filterStringChunks(R_HEX, str, convertHexToRGB);
|
12839 | }
|
12840 |
|
12841 | |
12842 |
|
12843 |
|
12844 |
|
12845 |
|
12846 |
|
12847 | function convertHexToRGB (hexString) {
|
12848 | var rgbArr = hexToRGBArray(hexString);
|
12849 | return 'rgb(' + rgbArr[0] + ',' + rgbArr[1] + ',' + rgbArr[2] + ')';
|
12850 | }
|
12851 |
|
12852 | var hexToRGBArray_returnArray = [];
|
12853 | |
12854 |
|
12855 |
|
12856 |
|
12857 |
|
12858 |
|
12859 |
|
12860 |
|
12861 |
|
12862 |
|
12863 | function hexToRGBArray (hex) {
|
12864 |
|
12865 | hex = hex.replace(/#/, '');
|
12866 |
|
12867 |
|
12868 |
|
12869 | if (hex.length === 3) {
|
12870 | hex = hex.split('');
|
12871 | hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
12872 | }
|
12873 |
|
12874 | hexToRGBArray_returnArray[0] = hexToDec(hex.substr(0, 2));
|
12875 | hexToRGBArray_returnArray[1] = hexToDec(hex.substr(2, 2));
|
12876 | hexToRGBArray_returnArray[2] = hexToDec(hex.substr(4, 2));
|
12877 |
|
12878 | return hexToRGBArray_returnArray;
|
12879 | }
|
12880 |
|
12881 | |
12882 |
|
12883 |
|
12884 |
|
12885 |
|
12886 |
|
12887 |
|
12888 |
|
12889 | function hexToDec (hex) {
|
12890 | return parseInt(hex, 16);
|
12891 | }
|
12892 |
|
12893 | |
12894 |
|
12895 |
|
12896 |
|
12897 |
|
12898 |
|
12899 |
|
12900 |
|
12901 |
|
12902 |
|
12903 | function filterStringChunks (pattern, unfilteredString, filter) {
|
12904 | var pattenMatches = unfilteredString.match(pattern);
|
12905 | var filteredString = unfilteredString.replace(pattern, VALUE_PLACEHOLDER);
|
12906 |
|
12907 | if (pattenMatches) {
|
12908 | var pattenMatchesLength = pattenMatches.length;
|
12909 | var currentChunk;
|
12910 |
|
12911 | for (var i = 0; i < pattenMatchesLength; i++) {
|
12912 | currentChunk = pattenMatches.shift();
|
12913 | filteredString = filteredString.replace(
|
12914 | VALUE_PLACEHOLDER, filter(currentChunk));
|
12915 | }
|
12916 | }
|
12917 |
|
12918 | return filteredString;
|
12919 | }
|
12920 |
|
12921 | |
12922 |
|
12923 |
|
12924 |
|
12925 |
|
12926 |
|
12927 |
|
12928 |
|
12929 | function sanitizeRGBChunks (formattedString) {
|
12930 | return filterStringChunks(R_RGB, formattedString, sanitizeRGBChunk);
|
12931 | }
|
12932 |
|
12933 | |
12934 |
|
12935 |
|
12936 |
|
12937 |
|
12938 |
|
12939 | function sanitizeRGBChunk (rgbChunk) {
|
12940 | var numbers = rgbChunk.match(R_UNFORMATTED_VALUES);
|
12941 | var numbersLength = numbers.length;
|
12942 | var sanitizedString = rgbChunk.match(R_RGB_PREFIX)[0];
|
12943 |
|
12944 | for (var i = 0; i < numbersLength; i++) {
|
12945 | sanitizedString += parseInt(numbers[i], 10) + ',';
|
12946 | }
|
12947 |
|
12948 | sanitizedString = sanitizedString.slice(0, -1) + ')';
|
12949 |
|
12950 | return sanitizedString;
|
12951 | }
|
12952 |
|
12953 | |
12954 |
|
12955 |
|
12956 |
|
12957 |
|
12958 |
|
12959 |
|
12960 | function getFormatManifests (stateObject) {
|
12961 | var manifestAccumulator = {};
|
12962 |
|
12963 | NGTweenable.each(stateObject, function (prop) {
|
12964 | var currentProp = stateObject[prop];
|
12965 |
|
12966 | if (typeof currentProp === 'string') {
|
12967 | var rawValues = getValuesFrom(currentProp);
|
12968 |
|
12969 | manifestAccumulator[prop] = {
|
12970 | 'formatString': getFormatStringFrom(currentProp)
|
12971 | ,'chunkNames': getFormatChunksFrom(rawValues, prop)
|
12972 | };
|
12973 | }
|
12974 | });
|
12975 |
|
12976 | return manifestAccumulator;
|
12977 | }
|
12978 |
|
12979 | |
12980 |
|
12981 |
|
12982 |
|
12983 |
|
12984 | function expandFormattedProperties (stateObject, formatManifests) {
|
12985 | NGTweenable.each(formatManifests, function (prop) {
|
12986 | var currentProp = stateObject[prop];
|
12987 | var rawValues = getValuesFrom(currentProp);
|
12988 | var rawValuesLength = rawValues.length;
|
12989 |
|
12990 | for (var i = 0; i < rawValuesLength; i++) {
|
12991 | stateObject[formatManifests[prop].chunkNames[i]] = +rawValues[i];
|
12992 | }
|
12993 |
|
12994 | delete stateObject[prop];
|
12995 | });
|
12996 | }
|
12997 |
|
12998 | |
12999 |
|
13000 |
|
13001 |
|
13002 |
|
13003 | function collapseFormattedProperties (stateObject, formatManifests) {
|
13004 | NGTweenable.each(formatManifests, function (prop) {
|
13005 | var currentProp = stateObject[prop];
|
13006 | var formatChunks = extractPropertyChunks(
|
13007 | stateObject, formatManifests[prop].chunkNames);
|
13008 | var valuesList = getValuesList(
|
13009 | formatChunks, formatManifests[prop].chunkNames);
|
13010 | currentProp = getFormattedValues(
|
13011 | formatManifests[prop].formatString, valuesList);
|
13012 | stateObject[prop] = sanitizeRGBChunks(currentProp);
|
13013 | });
|
13014 | }
|
13015 |
|
13016 | |
13017 |
|
13018 |
|
13019 |
|
13020 |
|
13021 |
|
13022 |
|
13023 | function extractPropertyChunks (stateObject, chunkNames) {
|
13024 | var extractedValues = {};
|
13025 | var currentChunkName, chunkNamesLength = chunkNames.length;
|
13026 |
|
13027 | for (var i = 0; i < chunkNamesLength; i++) {
|
13028 | currentChunkName = chunkNames[i];
|
13029 | extractedValues[currentChunkName] = stateObject[currentChunkName];
|
13030 | delete stateObject[currentChunkName];
|
13031 | }
|
13032 |
|
13033 | return extractedValues;
|
13034 | }
|
13035 |
|
13036 | var getValuesList_accumulator = [];
|
13037 | |
13038 |
|
13039 |
|
13040 |
|
13041 |
|
13042 |
|
13043 |
|
13044 | function getValuesList (stateObject, chunkNames) {
|
13045 | getValuesList_accumulator.length = 0;
|
13046 | var chunkNamesLength = chunkNames.length;
|
13047 |
|
13048 | for (var i = 0; i < chunkNamesLength; i++) {
|
13049 | getValuesList_accumulator.push(stateObject[chunkNames[i]]);
|
13050 | }
|
13051 |
|
13052 | return getValuesList_accumulator;
|
13053 | }
|
13054 |
|
13055 | |
13056 |
|
13057 |
|
13058 |
|
13059 |
|
13060 |
|
13061 |
|
13062 | function getFormattedValues (formatString, rawValues) {
|
13063 | var formattedValueString = formatString;
|
13064 | var rawValuesLength = rawValues.length;
|
13065 |
|
13066 | for (var i = 0; i < rawValuesLength; i++) {
|
13067 | formattedValueString = formattedValueString.replace(
|
13068 | VALUE_PLACEHOLDER, +rawValues[i].toFixed(4));
|
13069 | }
|
13070 |
|
13071 | return formattedValueString;
|
13072 | }
|
13073 |
|
13074 | |
13075 |
|
13076 |
|
13077 |
|
13078 |
|
13079 |
|
13080 |
|
13081 |
|
13082 |
|
13083 | function getValuesFrom (formattedString) {
|
13084 | return formattedString.match(R_UNFORMATTED_VALUES);
|
13085 | }
|
13086 |
|
13087 | |
13088 |
|
13089 |
|
13090 |
|
13091 |
|
13092 | function expandEasingObject (easingObject, tokenData) {
|
13093 | NGTweenable.each(tokenData, function (prop) {
|
13094 | var currentProp = tokenData[prop];
|
13095 | var chunkNames = currentProp.chunkNames;
|
13096 | var chunkLength = chunkNames.length;
|
13097 |
|
13098 | var easing = easingObject[prop];
|
13099 | var i;
|
13100 |
|
13101 | if (typeof easing === 'string') {
|
13102 | var easingChunks = easing.split(' ');
|
13103 | var lastEasingChunk = easingChunks[easingChunks.length - 1];
|
13104 |
|
13105 | for (i = 0; i < chunkLength; i++) {
|
13106 | easingObject[chunkNames[i]] = easingChunks[i] || lastEasingChunk;
|
13107 | }
|
13108 |
|
13109 | } else {
|
13110 | for (i = 0; i < chunkLength; i++) {
|
13111 | easingObject[chunkNames[i]] = easing;
|
13112 | }
|
13113 | }
|
13114 |
|
13115 | delete easingObject[prop];
|
13116 | });
|
13117 | }
|
13118 |
|
13119 | |
13120 |
|
13121 |
|
13122 |
|
13123 |
|
13124 | function collapseEasingObject (easingObject, tokenData) {
|
13125 | NGTweenable.each(tokenData, function (prop) {
|
13126 | var currentProp = tokenData[prop];
|
13127 | var chunkNames = currentProp.chunkNames;
|
13128 | var chunkLength = chunkNames.length;
|
13129 |
|
13130 | var firstEasing = easingObject[chunkNames[0]];
|
13131 | var typeofEasings = typeof firstEasing;
|
13132 |
|
13133 | if (typeofEasings === 'string') {
|
13134 | var composedEasingString = '';
|
13135 |
|
13136 | for (var i = 0; i < chunkLength; i++) {
|
13137 | composedEasingString += ' ' + easingObject[chunkNames[i]];
|
13138 | delete easingObject[chunkNames[i]];
|
13139 | }
|
13140 |
|
13141 | easingObject[prop] = composedEasingString.substr(1);
|
13142 | } else {
|
13143 | easingObject[prop] = firstEasing;
|
13144 | }
|
13145 | });
|
13146 | }
|
13147 |
|
13148 | NGTweenable.prototype.filter.token = {
|
13149 | 'tweenCreated': function (currentState, fromState, toState, easingObject) {
|
13150 | sanitizeObjectForHexProps(currentState);
|
13151 | sanitizeObjectForHexProps(fromState);
|
13152 | sanitizeObjectForHexProps(toState);
|
13153 | this._tokenData = getFormatManifests(currentState);
|
13154 | },
|
13155 |
|
13156 | 'beforeTween': function (currentState, fromState, toState, easingObject) {
|
13157 | expandEasingObject(easingObject, this._tokenData);
|
13158 | expandFormattedProperties(currentState, this._tokenData);
|
13159 | expandFormattedProperties(fromState, this._tokenData);
|
13160 | expandFormattedProperties(toState, this._tokenData);
|
13161 | },
|
13162 |
|
13163 | 'afterTween': function (currentState, fromState, toState, easingObject) {
|
13164 | collapseFormattedProperties(currentState, this._tokenData);
|
13165 | collapseFormattedProperties(fromState, this._tokenData);
|
13166 | collapseFormattedProperties(toState, this._tokenData);
|
13167 | collapseEasingObject(easingObject, this._tokenData);
|
13168 | }
|
13169 | };
|
13170 |
|
13171 | } (NGTweenable));
|
13172 |
|
13173 | }).call(null);
|
13174 |
|
13175 |
|
13176 |
|
13177 |
|
13178 |
|
13179 |
|
13180 |
|
13181 |
|
13182 |
|
13183 |
|
13184 |
|
13185 |
|
13186 |
|
13187 |
|
13188 |
|
13189 |
|
13190 |
|
13191 |
|
13192 |
|
13193 |
|
13194 |
|
13195 |
|
13196 |
|
13197 | (function(window, document, exportName, undefined) {
|
13198 | 'use strict';
|
13199 |
|
13200 | var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
|
13201 | var TEST_ELEMENT = document.createElement('div');
|
13202 |
|
13203 | var TYPE_FUNCTION = 'function';
|
13204 |
|
13205 | var round = Math.round;
|
13206 | var abs = Math.abs;
|
13207 | var now = Date.now;
|
13208 |
|
13209 |
|
13210 |
|
13211 |
|
13212 |
|
13213 |
|
13214 |
|
13215 |
|
13216 | function setTimeoutContext(fn, timeout, context) {
|
13217 | return setTimeout(bindFn(fn, context), timeout);
|
13218 | }
|
13219 |
|
13220 |
|
13221 |
|
13222 |
|
13223 |
|
13224 |
|
13225 |
|
13226 |
|
13227 |
|
13228 |
|
13229 | function invokeArrayArg(arg, fn, context) {
|
13230 | if (Array.isArray(arg)) {
|
13231 | each(arg, context[fn], context);
|
13232 | return true;
|
13233 | }
|
13234 | return false;
|
13235 | }
|
13236 |
|
13237 |
|
13238 |
|
13239 |
|
13240 |
|
13241 |
|
13242 |
|
13243 | function each(obj, iterator, context) {
|
13244 | var i;
|
13245 |
|
13246 | if (!obj) {
|
13247 | return;
|
13248 | }
|
13249 |
|
13250 | if (obj.forEach) {
|
13251 | obj.forEach(iterator, context);
|
13252 | } else if (obj.length !== undefined) {
|
13253 | i = 0;
|
13254 | while (i < obj.length) {
|
13255 | iterator.call(context, obj[i], i, obj);
|
13256 | i++;
|
13257 | }
|
13258 | } else {
|
13259 | for (i in obj) {
|
13260 | obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
|
13261 | }
|
13262 | }
|
13263 | }
|
13264 |
|
13265 |
|
13266 |
|
13267 |
|
13268 |
|
13269 |
|
13270 |
|
13271 |
|
13272 | function deprecate(method, name, message) {
|
13273 | var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
|
13274 | return function() {
|
13275 | var e = new Error('get-stack-trace');
|
13276 | var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '')
|
13277 | .replace(/^\s+at\s+/gm, '')
|
13278 | .replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';
|
13279 |
|
13280 | var log = window.console && (window.console.warn || window.console.log);
|
13281 | if (log) {
|
13282 | log.call(window.console, deprecationMessage, stack);
|
13283 | }
|
13284 | return method.apply(this, arguments);
|
13285 | };
|
13286 | }
|
13287 |
|
13288 |
|
13289 |
|
13290 |
|
13291 |
|
13292 |
|
13293 |
|
13294 |
|
13295 | var assign;
|
13296 | if (typeof Object.assign !== 'function') {
|
13297 | assign = function assign(target) {
|
13298 | if (target === undefined || target === null) {
|
13299 | throw new TypeError('Cannot convert undefined or null to object');
|
13300 | }
|
13301 |
|
13302 | var output = Object(target);
|
13303 | for (var index = 1; index < arguments.length; index++) {
|
13304 | var source = arguments[index];
|
13305 | if (source !== undefined && source !== null) {
|
13306 | for (var nextKey in source) {
|
13307 | if (source.hasOwnProperty(nextKey)) {
|
13308 | output[nextKey] = source[nextKey];
|
13309 | }
|
13310 | }
|
13311 | }
|
13312 | }
|
13313 | return output;
|
13314 | };
|
13315 | } else {
|
13316 | assign = Object.assign;
|
13317 | }
|
13318 |
|
13319 |
|
13320 |
|
13321 |
|
13322 |
|
13323 |
|
13324 |
|
13325 |
|
13326 |
|
13327 | var extend = deprecate(function extend(dest, src, merge) {
|
13328 | var keys = Object.keys(src);
|
13329 | var i = 0;
|
13330 | while (i < keys.length) {
|
13331 | if (!merge || (merge && dest[keys[i]] === undefined)) {
|
13332 | dest[keys[i]] = src[keys[i]];
|
13333 | }
|
13334 | i++;
|
13335 | }
|
13336 | return dest;
|
13337 | }, 'extend', 'Use `assign`.');
|
13338 |
|
13339 |
|
13340 |
|
13341 |
|
13342 |
|
13343 |
|
13344 |
|
13345 |
|
13346 | var merge = deprecate(function merge(dest, src) {
|
13347 | return extend(dest, src, true);
|
13348 | }, 'merge', 'Use `assign`.');
|
13349 |
|
13350 |
|
13351 |
|
13352 |
|
13353 |
|
13354 |
|
13355 |
|
13356 | function inherit(child, base, properties) {
|
13357 | var baseP = base.prototype,
|
13358 | childP;
|
13359 |
|
13360 | childP = child.prototype = Object.create(baseP);
|
13361 | childP.constructor = child;
|
13362 | childP._super = baseP;
|
13363 |
|
13364 | if (properties) {
|
13365 | assign(childP, properties);
|
13366 | }
|
13367 | }
|
13368 |
|
13369 |
|
13370 |
|
13371 |
|
13372 |
|
13373 |
|
13374 |
|
13375 | function bindFn(fn, context) {
|
13376 | return function boundFn() {
|
13377 | return fn.apply(context, arguments);
|
13378 | };
|
13379 | }
|
13380 |
|
13381 |
|
13382 |
|
13383 |
|
13384 |
|
13385 |
|
13386 |
|
13387 |
|
13388 | function boolOrFn(val, args) {
|
13389 | if (typeof val == TYPE_FUNCTION) {
|
13390 | return val.apply(args ? args[0] || undefined : undefined, args);
|
13391 | }
|
13392 | return val;
|
13393 | }
|
13394 |
|
13395 |
|
13396 |
|
13397 |
|
13398 |
|
13399 |
|
13400 |
|
13401 | function ifUndefined(val1, val2) {
|
13402 | return (val1 === undefined) ? val2 : val1;
|
13403 | }
|
13404 |
|
13405 |
|
13406 |
|
13407 |
|
13408 |
|
13409 |
|
13410 |
|
13411 | function addEventListeners(target, types, handler) {
|
13412 | each(splitStr(types), function(type) {
|
13413 | target.addEventListener(type, handler, false);
|
13414 | });
|
13415 | }
|
13416 |
|
13417 |
|
13418 |
|
13419 |
|
13420 |
|
13421 |
|
13422 |
|
13423 | function removeEventListeners(target, types, handler) {
|
13424 | each(splitStr(types), function(type) {
|
13425 | target.removeEventListener(type, handler, false);
|
13426 | });
|
13427 | }
|
13428 |
|
13429 |
|
13430 |
|
13431 |
|
13432 |
|
13433 |
|
13434 |
|
13435 |
|
13436 | function hasParent(node, parent) {
|
13437 | while (node) {
|
13438 | if (node == parent) {
|
13439 | return true;
|
13440 | }
|
13441 | node = node.parentNode;
|
13442 | }
|
13443 | return false;
|
13444 | }
|
13445 |
|
13446 |
|
13447 |
|
13448 |
|
13449 |
|
13450 |
|
13451 |
|
13452 | function inStr(str, find) {
|
13453 | return str.indexOf(find) > -1;
|
13454 | }
|
13455 |
|
13456 |
|
13457 |
|
13458 |
|
13459 |
|
13460 |
|
13461 | function splitStr(str) {
|
13462 | return str.trim().split(/\s+/g);
|
13463 | }
|
13464 |
|
13465 |
|
13466 |
|
13467 |
|
13468 |
|
13469 |
|
13470 |
|
13471 |
|
13472 | function inArray(src, find, findByKey) {
|
13473 | if (src.indexOf && !findByKey) {
|
13474 | return src.indexOf(find);
|
13475 | } else {
|
13476 | var i = 0;
|
13477 | while (i < src.length) {
|
13478 | if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
|
13479 | return i;
|
13480 | }
|
13481 | i++;
|
13482 | }
|
13483 | return -1;
|
13484 | }
|
13485 | }
|
13486 |
|
13487 |
|
13488 |
|
13489 |
|
13490 |
|
13491 |
|
13492 | function toArray(obj) {
|
13493 | return Array.prototype.slice.call(obj, 0);
|
13494 | }
|
13495 |
|
13496 |
|
13497 |
|
13498 |
|
13499 |
|
13500 |
|
13501 |
|
13502 |
|
13503 | function uniqueArray(src, key, sort) {
|
13504 | var results = [];
|
13505 | var values = [];
|
13506 | var i = 0;
|
13507 |
|
13508 | while (i < src.length) {
|
13509 | var val = key ? src[i][key] : src[i];
|
13510 | if (inArray(values, val) < 0) {
|
13511 | results.push(src[i]);
|
13512 | }
|
13513 | values[i] = val;
|
13514 | i++;
|
13515 | }
|
13516 |
|
13517 | if (sort) {
|
13518 | if (!key) {
|
13519 | results = results.sort();
|
13520 | } else {
|
13521 | results = results.sort(function sortUniqueArray(a, b) {
|
13522 | return a[key] > b[key];
|
13523 | });
|
13524 | }
|
13525 | }
|
13526 |
|
13527 | return results;
|
13528 | }
|
13529 |
|
13530 |
|
13531 |
|
13532 |
|
13533 |
|
13534 |
|
13535 |
|
13536 | function prefixed(obj, property) {
|
13537 | var prefix, prop;
|
13538 | var camelProp = property[0].toUpperCase() + property.slice(1);
|
13539 |
|
13540 | var i = 0;
|
13541 | while (i < VENDOR_PREFIXES.length) {
|
13542 | prefix = VENDOR_PREFIXES[i];
|
13543 | prop = (prefix) ? prefix + camelProp : property;
|
13544 |
|
13545 | if (prop in obj) {
|
13546 | return prop;
|
13547 | }
|
13548 | i++;
|
13549 | }
|
13550 | return undefined;
|
13551 | }
|
13552 |
|
13553 |
|
13554 |
|
13555 |
|
13556 |
|
13557 | var _uniqueId = 1;
|
13558 | function uniqueId() {
|
13559 | return _uniqueId++;
|
13560 | }
|
13561 |
|
13562 |
|
13563 |
|
13564 |
|
13565 |
|
13566 |
|
13567 | function getWindowForElement(element) {
|
13568 | var doc = element.ownerDocument || element;
|
13569 | return (doc.defaultView || doc.parentWindow || window);
|
13570 | }
|
13571 |
|
13572 | var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
13573 |
|
13574 | var SUPPORT_TOUCH = ('ontouchstart' in window);
|
13575 |
|
13576 | var SUPPORT_POINTER_EVENTS = false;
|
13577 | var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
13578 |
|
13579 | var INPUT_TYPE_TOUCH = 'touch';
|
13580 | var INPUT_TYPE_PEN = 'pen';
|
13581 | var INPUT_TYPE_MOUSE = 'mouse';
|
13582 | var INPUT_TYPE_KINECT = 'kinect';
|
13583 |
|
13584 | var COMPUTE_INTERVAL = 25;
|
13585 |
|
13586 | var INPUT_START = 1;
|
13587 | var INPUT_MOVE = 2;
|
13588 | var INPUT_END = 4;
|
13589 | var INPUT_CANCEL = 8;
|
13590 |
|
13591 | var DIRECTION_NONE = 1;
|
13592 | var DIRECTION_LEFT = 2;
|
13593 | var DIRECTION_RIGHT = 4;
|
13594 | var DIRECTION_UP = 8;
|
13595 | var DIRECTION_DOWN = 16;
|
13596 |
|
13597 | var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
13598 | var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
13599 | var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
13600 |
|
13601 | var PROPS_XY = ['x', 'y'];
|
13602 | var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
13603 |
|
13604 |
|
13605 |
|
13606 |
|
13607 |
|
13608 |
|
13609 |
|
13610 |
|
13611 | function Input(manager, callback) {
|
13612 | var self = this;
|
13613 | this.manager = manager;
|
13614 | this.callback = callback;
|
13615 | this.element = manager.element;
|
13616 | this.target = manager.options.inputTarget;
|
13617 |
|
13618 |
|
13619 |
|
13620 | this.domHandler = function(ev) {
|
13621 | if (boolOrFn(manager.options.enable, [manager])) {
|
13622 | self.handler(ev);
|
13623 | }
|
13624 | };
|
13625 |
|
13626 | this.init();
|
13627 |
|
13628 | }
|
13629 |
|
13630 | Input.prototype = {
|
13631 | |
13632 |
|
13633 |
|
13634 |
|
13635 | handler: function() { },
|
13636 |
|
13637 | |
13638 |
|
13639 |
|
13640 | init: function() {
|
13641 | this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
|
13642 | this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
|
13643 | this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
13644 | },
|
13645 |
|
13646 | |
13647 |
|
13648 |
|
13649 | destroy: function() {
|
13650 | this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
|
13651 | this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
13652 | this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
13653 | }
|
13654 | };
|
13655 |
|
13656 |
|
13657 |
|
13658 |
|
13659 |
|
13660 |
|
13661 |
|
13662 | function createInputInstance(manager) {
|
13663 | var Type;
|
13664 | var inputClass = manager.options.inputClass;
|
13665 |
|
13666 | if (inputClass) {
|
13667 | Type = inputClass;
|
13668 | } else if (SUPPORT_POINTER_EVENTS) {
|
13669 | Type = PointerEventInput;
|
13670 | } else if (SUPPORT_ONLY_TOUCH) {
|
13671 | Type = TouchInput;
|
13672 | } else if (!SUPPORT_TOUCH) {
|
13673 | Type = MouseInput;
|
13674 | } else {
|
13675 | Type = TouchMouseInput;
|
13676 | }
|
13677 | return new (Type)(manager, inputHandler);
|
13678 | }
|
13679 |
|
13680 |
|
13681 |
|
13682 |
|
13683 |
|
13684 |
|
13685 |
|
13686 | function inputHandler(manager, eventType, input) {
|
13687 | var pointersLen = input.pointers.length;
|
13688 | var changedPointersLen = input.changedPointers.length;
|
13689 | var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
|
13690 | var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - changedPointersLen === 0));
|
13691 |
|
13692 | input.isFirst = !!isFirst;
|
13693 | input.isFinal = !!isFinal;
|
13694 |
|
13695 | if (isFirst) {
|
13696 | manager.session = {};
|
13697 | }
|
13698 |
|
13699 |
|
13700 |
|
13701 | input.eventType = eventType;
|
13702 |
|
13703 |
|
13704 | computeInputData(manager, input);
|
13705 |
|
13706 |
|
13707 | manager.emit('hammer.input', input);
|
13708 |
|
13709 | manager.recognize(input);
|
13710 | manager.session.prevInput = input;
|
13711 | }
|
13712 |
|
13713 |
|
13714 |
|
13715 |
|
13716 |
|
13717 |
|
13718 | function computeInputData(manager, input) {
|
13719 | var session = manager.session;
|
13720 | var pointers = input.pointers;
|
13721 | var pointersLength = pointers.length;
|
13722 |
|
13723 |
|
13724 | if (!session.firstInput) {
|
13725 | session.firstInput = simpleCloneInputData(input);
|
13726 | }
|
13727 |
|
13728 |
|
13729 | if (pointersLength > 1 && !session.firstMultiple) {
|
13730 | session.firstMultiple = simpleCloneInputData(input);
|
13731 | } else if (pointersLength === 1) {
|
13732 | session.firstMultiple = false;
|
13733 | }
|
13734 |
|
13735 | var firstInput = session.firstInput;
|
13736 | var firstMultiple = session.firstMultiple;
|
13737 | var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
|
13738 |
|
13739 | var center = input.center = getCenter(pointers);
|
13740 | input.timeStamp = now();
|
13741 | input.deltaTime = input.timeStamp - firstInput.timeStamp;
|
13742 |
|
13743 | input.angle = getAngle(offsetCenter, center);
|
13744 | input.distance = getDistance(offsetCenter, center);
|
13745 |
|
13746 | computeDeltaXY(session, input);
|
13747 | input.offsetDirection = getDirection(input.deltaX, input.deltaY);
|
13748 |
|
13749 | var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
|
13750 | input.overallVelocityX = overallVelocity.x;
|
13751 | input.overallVelocityY = overallVelocity.y;
|
13752 | input.overallVelocity = (abs(overallVelocity.x) > abs(overallVelocity.y)) ? overallVelocity.x : overallVelocity.y;
|
13753 |
|
13754 | input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
|
13755 | input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
|
13756 |
|
13757 | input.maxPointers = !session.prevInput ? input.pointers.length : ((input.pointers.length >
|
13758 | session.prevInput.maxPointers) ? input.pointers.length : session.prevInput.maxPointers);
|
13759 |
|
13760 | computeIntervalInputData(session, input);
|
13761 |
|
13762 |
|
13763 | var target = manager.element;
|
13764 | if (hasParent(input.srcEvent.target, target)) {
|
13765 | target = input.srcEvent.target;
|
13766 | }
|
13767 | input.target = target;
|
13768 | }
|
13769 |
|
13770 | function computeDeltaXY(session, input) {
|
13771 | var center = input.center;
|
13772 | var offset = session.offsetDelta || {};
|
13773 | var prevDelta = session.prevDelta || {};
|
13774 | var prevInput = session.prevInput || {};
|
13775 |
|
13776 | if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
|
13777 | prevDelta = session.prevDelta = {
|
13778 | x: prevInput.deltaX || 0,
|
13779 | y: prevInput.deltaY || 0
|
13780 | };
|
13781 |
|
13782 | offset = session.offsetDelta = {
|
13783 | x: center.x,
|
13784 | y: center.y
|
13785 | };
|
13786 | }
|
13787 |
|
13788 | input.deltaX = prevDelta.x + (center.x - offset.x);
|
13789 | input.deltaY = prevDelta.y + (center.y - offset.y);
|
13790 | }
|
13791 |
|
13792 |
|
13793 |
|
13794 |
|
13795 |
|
13796 |
|
13797 | function computeIntervalInputData(session, input) {
|
13798 | var last = session.lastInterval || input,
|
13799 | deltaTime = input.timeStamp - last.timeStamp,
|
13800 | velocity, velocityX, velocityY, direction;
|
13801 |
|
13802 | if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
|
13803 | var deltaX = input.deltaX - last.deltaX;
|
13804 | var deltaY = input.deltaY - last.deltaY;
|
13805 |
|
13806 | var v = getVelocity(deltaTime, deltaX, deltaY);
|
13807 | velocityX = v.x;
|
13808 | velocityY = v.y;
|
13809 | velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
|
13810 | direction = getDirection(deltaX, deltaY);
|
13811 |
|
13812 | session.lastInterval = input;
|
13813 | } else {
|
13814 |
|
13815 | velocity = last.velocity;
|
13816 | velocityX = last.velocityX;
|
13817 | velocityY = last.velocityY;
|
13818 | direction = last.direction;
|
13819 | }
|
13820 |
|
13821 | input.velocity = velocity;
|
13822 | input.velocityX = velocityX;
|
13823 | input.velocityY = velocityY;
|
13824 | input.direction = direction;
|
13825 | }
|
13826 |
|
13827 |
|
13828 |
|
13829 |
|
13830 |
|
13831 |
|
13832 | function simpleCloneInputData(input) {
|
13833 |
|
13834 |
|
13835 | var pointers = [];
|
13836 | var i = 0;
|
13837 | while (i < input.pointers.length) {
|
13838 | pointers[i] = {
|
13839 | clientX: round(input.pointers[i].clientX),
|
13840 | clientY: round(input.pointers[i].clientY)
|
13841 | };
|
13842 | i++;
|
13843 | }
|
13844 |
|
13845 | return {
|
13846 | timeStamp: now(),
|
13847 | pointers: pointers,
|
13848 | center: getCenter(pointers),
|
13849 | deltaX: input.deltaX,
|
13850 | deltaY: input.deltaY
|
13851 | };
|
13852 | }
|
13853 |
|
13854 |
|
13855 |
|
13856 |
|
13857 |
|
13858 |
|
13859 | function getCenter(pointers) {
|
13860 | var pointersLength = pointers.length;
|
13861 |
|
13862 |
|
13863 | if (pointersLength === 1) {
|
13864 | return {
|
13865 | x: round(pointers[0].clientX),
|
13866 | y: round(pointers[0].clientY)
|
13867 | };
|
13868 | }
|
13869 |
|
13870 | var x = 0, y = 0, i = 0;
|
13871 | while (i < pointersLength) {
|
13872 | x += pointers[i].clientX;
|
13873 | y += pointers[i].clientY;
|
13874 | i++;
|
13875 | }
|
13876 |
|
13877 | return {
|
13878 | x: round(x / pointersLength),
|
13879 | y: round(y / pointersLength)
|
13880 | };
|
13881 | }
|
13882 |
|
13883 |
|
13884 |
|
13885 |
|
13886 |
|
13887 |
|
13888 |
|
13889 |
|
13890 | function getVelocity(deltaTime, x, y) {
|
13891 | return {
|
13892 | x: x / deltaTime || 0,
|
13893 | y: y / deltaTime || 0
|
13894 | };
|
13895 | }
|
13896 |
|
13897 |
|
13898 |
|
13899 |
|
13900 |
|
13901 |
|
13902 |
|
13903 | function getDirection(x, y) {
|
13904 | if (x === y) {
|
13905 | return DIRECTION_NONE;
|
13906 | }
|
13907 |
|
13908 | if (abs(x) >= abs(y)) {
|
13909 | return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
13910 | }
|
13911 | return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
13912 | }
|
13913 |
|
13914 |
|
13915 |
|
13916 |
|
13917 |
|
13918 |
|
13919 |
|
13920 |
|
13921 | function getDistance(p1, p2, props) {
|
13922 | if (!props) {
|
13923 | props = PROPS_XY;
|
13924 | }
|
13925 | var x = p2[props[0]] - p1[props[0]],
|
13926 | y = p2[props[1]] - p1[props[1]];
|
13927 |
|
13928 | return Math.sqrt((x * x) + (y * y));
|
13929 | }
|
13930 |
|
13931 |
|
13932 |
|
13933 |
|
13934 |
|
13935 |
|
13936 |
|
13937 |
|
13938 | function getAngle(p1, p2, props) {
|
13939 | if (!props) {
|
13940 | props = PROPS_XY;
|
13941 | }
|
13942 | var x = p2[props[0]] - p1[props[0]],
|
13943 | y = p2[props[1]] - p1[props[1]];
|
13944 | return Math.atan2(y, x) * 180 / Math.PI;
|
13945 | }
|
13946 |
|
13947 |
|
13948 |
|
13949 |
|
13950 |
|
13951 |
|
13952 |
|
13953 | function getRotation(start, end) {
|
13954 | return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
13955 | }
|
13956 |
|
13957 |
|
13958 |
|
13959 |
|
13960 |
|
13961 |
|
13962 |
|
13963 |
|
13964 | function getScale(start, end) {
|
13965 | return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
13966 | }
|
13967 |
|
13968 | var MOUSE_INPUT_MAP = {
|
13969 | mousedown: INPUT_START,
|
13970 | mousemove: INPUT_MOVE,
|
13971 | mouseup: INPUT_END
|
13972 | };
|
13973 |
|
13974 | var MOUSE_ELEMENT_EVENTS = 'mousedown';
|
13975 | var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
|
13976 |
|
13977 |
|
13978 |
|
13979 |
|
13980 |
|
13981 |
|
13982 | function MouseInput() {
|
13983 | this.evEl = MOUSE_ELEMENT_EVENTS;
|
13984 | this.evWin = MOUSE_WINDOW_EVENTS;
|
13985 |
|
13986 | this.pressed = false;
|
13987 |
|
13988 | Input.apply(this, arguments);
|
13989 | }
|
13990 |
|
13991 | inherit(MouseInput, Input, {
|
13992 | |
13993 |
|
13994 |
|
13995 |
|
13996 | handler: function MEhandler(ev) {
|
13997 | var eventType = MOUSE_INPUT_MAP[ev.type];
|
13998 |
|
13999 |
|
14000 | if (eventType & INPUT_START && ev.button === 0) {
|
14001 | this.pressed = true;
|
14002 | }
|
14003 |
|
14004 | if (eventType & INPUT_MOVE && ev.which !== 1) {
|
14005 | eventType = INPUT_END;
|
14006 | }
|
14007 |
|
14008 |
|
14009 | if (!this.pressed) {
|
14010 | return;
|
14011 | }
|
14012 |
|
14013 | if (eventType & INPUT_END) {
|
14014 | this.pressed = false;
|
14015 | }
|
14016 |
|
14017 | this.callback(this.manager, eventType, {
|
14018 | pointers: [ev],
|
14019 | changedPointers: [ev],
|
14020 | pointerType: INPUT_TYPE_MOUSE,
|
14021 | srcEvent: ev
|
14022 | });
|
14023 | }
|
14024 | });
|
14025 |
|
14026 | var POINTER_INPUT_MAP = {
|
14027 | pointerdown: INPUT_START,
|
14028 | pointermove: INPUT_MOVE,
|
14029 | pointerup: INPUT_END,
|
14030 | pointercancel: INPUT_CANCEL,
|
14031 | pointerout: INPUT_CANCEL
|
14032 | };
|
14033 |
|
14034 |
|
14035 | var IE10_POINTER_TYPE_ENUM = {
|
14036 | 2: INPUT_TYPE_TOUCH,
|
14037 | 3: INPUT_TYPE_PEN,
|
14038 | 4: INPUT_TYPE_MOUSE,
|
14039 | 5: INPUT_TYPE_KINECT
|
14040 | };
|
14041 |
|
14042 | var POINTER_ELEMENT_EVENTS = 'pointerdown';
|
14043 | var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
|
14044 |
|
14045 |
|
14046 | if (window.MSPointerEvent && !window.PointerEvent) {
|
14047 | POINTER_ELEMENT_EVENTS = 'MSPointerDown';
|
14048 | POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
|
14049 | }
|
14050 |
|
14051 |
|
14052 |
|
14053 |
|
14054 |
|
14055 |
|
14056 | function PointerEventInput() {
|
14057 | this.evEl = POINTER_ELEMENT_EVENTS;
|
14058 | this.evWin = POINTER_WINDOW_EVENTS;
|
14059 |
|
14060 | Input.apply(this, arguments);
|
14061 |
|
14062 | this.store = (this.manager.session.pointerEvents = []);
|
14063 | }
|
14064 |
|
14065 | inherit(PointerEventInput, Input, {
|
14066 | |
14067 |
|
14068 |
|
14069 |
|
14070 | handler: function PEhandler(ev) {
|
14071 | var store = this.store;
|
14072 | var removePointer = false;
|
14073 |
|
14074 | var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
|
14075 | var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
|
14076 | var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
|
14077 |
|
14078 | var isTouch = (pointerType == INPUT_TYPE_TOUCH);
|
14079 |
|
14080 |
|
14081 | var storeIndex = inArray(store, ev.pointerId, 'pointerId');
|
14082 |
|
14083 |
|
14084 | if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
|
14085 | if (storeIndex < 0) {
|
14086 | store.push(ev);
|
14087 | storeIndex = store.length - 1;
|
14088 | }
|
14089 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
14090 | removePointer = true;
|
14091 | }
|
14092 |
|
14093 |
|
14094 | if (storeIndex < 0) {
|
14095 | return;
|
14096 | }
|
14097 |
|
14098 |
|
14099 | store[storeIndex] = ev;
|
14100 |
|
14101 | this.callback(this.manager, eventType, {
|
14102 | pointers: store,
|
14103 | changedPointers: [ev],
|
14104 | pointerType: pointerType,
|
14105 | srcEvent: ev
|
14106 | });
|
14107 |
|
14108 | if (removePointer) {
|
14109 |
|
14110 | store.splice(storeIndex, 1);
|
14111 | }
|
14112 | }
|
14113 | });
|
14114 |
|
14115 | var SINGLE_TOUCH_INPUT_MAP = {
|
14116 | touchstart: INPUT_START,
|
14117 | touchmove: INPUT_MOVE,
|
14118 | touchend: INPUT_END,
|
14119 | touchcancel: INPUT_CANCEL
|
14120 | };
|
14121 |
|
14122 | var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
|
14123 | var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
|
14124 |
|
14125 |
|
14126 |
|
14127 |
|
14128 |
|
14129 |
|
14130 | function SingleTouchInput() {
|
14131 | this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
14132 | this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
14133 | this.started = false;
|
14134 |
|
14135 | Input.apply(this, arguments);
|
14136 | }
|
14137 |
|
14138 | inherit(SingleTouchInput, Input, {
|
14139 | handler: function TEhandler(ev) {
|
14140 | var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
14141 |
|
14142 |
|
14143 | if (type === INPUT_START) {
|
14144 | this.started = true;
|
14145 | }
|
14146 |
|
14147 | if (!this.started) {
|
14148 | return;
|
14149 | }
|
14150 |
|
14151 | var touches = normalizeSingleTouches.call(this, ev, type);
|
14152 |
|
14153 |
|
14154 | if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
|
14155 | this.started = false;
|
14156 | }
|
14157 |
|
14158 | this.callback(this.manager, type, {
|
14159 | pointers: touches[0],
|
14160 | changedPointers: touches[1],
|
14161 | pointerType: INPUT_TYPE_TOUCH,
|
14162 | srcEvent: ev
|
14163 | });
|
14164 | }
|
14165 | });
|
14166 |
|
14167 |
|
14168 |
|
14169 |
|
14170 |
|
14171 |
|
14172 |
|
14173 | function normalizeSingleTouches(ev, type) {
|
14174 | var all = toArray(ev.touches);
|
14175 | var changed = toArray(ev.changedTouches);
|
14176 |
|
14177 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
14178 | all = uniqueArray(all.concat(changed), 'identifier', true);
|
14179 | }
|
14180 |
|
14181 | return [all, changed];
|
14182 | }
|
14183 |
|
14184 | var TOUCH_INPUT_MAP = {
|
14185 | touchstart: INPUT_START,
|
14186 | touchmove: INPUT_MOVE,
|
14187 | touchend: INPUT_END,
|
14188 | touchcancel: INPUT_CANCEL
|
14189 | };
|
14190 |
|
14191 | var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
14192 |
|
14193 |
|
14194 |
|
14195 |
|
14196 |
|
14197 |
|
14198 | function TouchInput() {
|
14199 | this.evTarget = TOUCH_TARGET_EVENTS;
|
14200 | this.targetIds = {};
|
14201 |
|
14202 | Input.apply(this, arguments);
|
14203 | }
|
14204 |
|
14205 | inherit(TouchInput, Input, {
|
14206 | handler: function MTEhandler(ev) {
|
14207 | var type = TOUCH_INPUT_MAP[ev.type];
|
14208 | var touches = getTouches.call(this, ev, type);
|
14209 | if (!touches) {
|
14210 | return;
|
14211 | }
|
14212 |
|
14213 | this.callback(this.manager, type, {
|
14214 | pointers: touches[0],
|
14215 | changedPointers: touches[1],
|
14216 | pointerType: INPUT_TYPE_TOUCH,
|
14217 | srcEvent: ev
|
14218 | });
|
14219 | }
|
14220 | });
|
14221 |
|
14222 |
|
14223 |
|
14224 |
|
14225 |
|
14226 |
|
14227 |
|
14228 | function getTouches(ev, type) {
|
14229 | var allTouches = toArray(ev.touches);
|
14230 | var targetIds = this.targetIds;
|
14231 |
|
14232 |
|
14233 | if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
|
14234 | targetIds[allTouches[0].identifier] = true;
|
14235 | return [allTouches, allTouches];
|
14236 | }
|
14237 |
|
14238 | var i,
|
14239 | targetTouches,
|
14240 | changedTouches = toArray(ev.changedTouches),
|
14241 | changedTargetTouches = [],
|
14242 | target = this.target;
|
14243 |
|
14244 |
|
14245 | targetTouches = allTouches.filter(function(touch) {
|
14246 | return hasParent(touch.target, target);
|
14247 | });
|
14248 |
|
14249 |
|
14250 | if (type === INPUT_START) {
|
14251 | i = 0;
|
14252 | while (i < targetTouches.length) {
|
14253 | targetIds[targetTouches[i].identifier] = true;
|
14254 | i++;
|
14255 | }
|
14256 | }
|
14257 |
|
14258 |
|
14259 | i = 0;
|
14260 | while (i < changedTouches.length) {
|
14261 | if (targetIds[changedTouches[i].identifier]) {
|
14262 | changedTargetTouches.push(changedTouches[i]);
|
14263 | }
|
14264 |
|
14265 |
|
14266 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
14267 | delete targetIds[changedTouches[i].identifier];
|
14268 | }
|
14269 | i++;
|
14270 | }
|
14271 |
|
14272 | if (!changedTargetTouches.length) {
|
14273 | return;
|
14274 | }
|
14275 |
|
14276 | return [
|
14277 |
|
14278 | uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
|
14279 | changedTargetTouches
|
14280 | ];
|
14281 | }
|
14282 |
|
14283 |
|
14284 |
|
14285 |
|
14286 |
|
14287 |
|
14288 |
|
14289 |
|
14290 |
|
14291 |
|
14292 |
|
14293 | var DEDUP_TIMEOUT = 2500;
|
14294 | var DEDUP_DISTANCE = 25;
|
14295 |
|
14296 | function TouchMouseInput() {
|
14297 | Input.apply(this, arguments);
|
14298 |
|
14299 | var handler = bindFn(this.handler, this);
|
14300 | this.touch = new TouchInput(this.manager, handler);
|
14301 | this.mouse = new MouseInput(this.manager, handler);
|
14302 |
|
14303 | this.primaryTouch = null;
|
14304 | this.lastTouches = [];
|
14305 | }
|
14306 |
|
14307 | inherit(TouchMouseInput, Input, {
|
14308 | |
14309 |
|
14310 |
|
14311 |
|
14312 |
|
14313 |
|
14314 | handler: function TMEhandler(manager, inputEvent, inputData) {
|
14315 | var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
|
14316 | isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
|
14317 |
|
14318 | if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
|
14319 | return;
|
14320 | }
|
14321 |
|
14322 |
|
14323 | if (isTouch) {
|
14324 | recordTouches.call(this, inputEvent, inputData);
|
14325 | } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
|
14326 | return;
|
14327 | }
|
14328 |
|
14329 | this.callback(manager, inputEvent, inputData);
|
14330 | },
|
14331 |
|
14332 | |
14333 |
|
14334 |
|
14335 | destroy: function destroy() {
|
14336 | this.touch.destroy();
|
14337 | this.mouse.destroy();
|
14338 | }
|
14339 | });
|
14340 |
|
14341 | function recordTouches(eventType, eventData) {
|
14342 | if (eventType & INPUT_START) {
|
14343 | this.primaryTouch = eventData.changedPointers[0].identifier;
|
14344 | setLastTouch.call(this, eventData);
|
14345 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
14346 | setLastTouch.call(this, eventData);
|
14347 | }
|
14348 | }
|
14349 |
|
14350 | function setLastTouch(eventData) {
|
14351 | var touch = eventData.changedPointers[0];
|
14352 |
|
14353 | if (touch.identifier === this.primaryTouch) {
|
14354 | var lastTouch = {x: touch.clientX, y: touch.clientY};
|
14355 | this.lastTouches.push(lastTouch);
|
14356 | var lts = this.lastTouches;
|
14357 | var removeLastTouch = function() {
|
14358 | var i = lts.indexOf(lastTouch);
|
14359 | if (i > -1) {
|
14360 | lts.splice(i, 1);
|
14361 | }
|
14362 | };
|
14363 | setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
14364 | }
|
14365 | }
|
14366 |
|
14367 | function isSyntheticEvent(eventData) {
|
14368 | var x = eventData.srcEvent.clientX, y = eventData.srcEvent.clientY;
|
14369 | for (var i = 0; i < this.lastTouches.length; i++) {
|
14370 | var t = this.lastTouches[i];
|
14371 | var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y);
|
14372 | if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
|
14373 | return true;
|
14374 | }
|
14375 | }
|
14376 | return false;
|
14377 | }
|
14378 |
|
14379 | var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
|
14380 | var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
|
14381 |
|
14382 |
|
14383 | var TOUCH_ACTION_COMPUTE = 'compute';
|
14384 | var TOUCH_ACTION_AUTO = 'auto';
|
14385 | var TOUCH_ACTION_MANIPULATION = 'manipulation';
|
14386 | var TOUCH_ACTION_NONE = 'none';
|
14387 | var TOUCH_ACTION_PAN_X = 'pan-x';
|
14388 | var TOUCH_ACTION_PAN_Y = 'pan-y';
|
14389 | var TOUCH_ACTION_MAP = getTouchActionProps();
|
14390 |
|
14391 |
|
14392 |
|
14393 |
|
14394 |
|
14395 |
|
14396 |
|
14397 |
|
14398 | function TouchAction(manager, value) {
|
14399 | this.manager = manager;
|
14400 | this.set(value);
|
14401 | }
|
14402 |
|
14403 | TouchAction.prototype = {
|
14404 | |
14405 |
|
14406 |
|
14407 |
|
14408 | set: function(value) {
|
14409 |
|
14410 | if (value == TOUCH_ACTION_COMPUTE) {
|
14411 | value = this.compute();
|
14412 | }
|
14413 |
|
14414 | if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
|
14415 | this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
|
14416 | }
|
14417 | this.actions = value.toLowerCase().trim();
|
14418 | },
|
14419 |
|
14420 | |
14421 |
|
14422 |
|
14423 | update: function() {
|
14424 | this.set(this.manager.options.touchAction);
|
14425 | },
|
14426 |
|
14427 | |
14428 |
|
14429 |
|
14430 |
|
14431 | compute: function() {
|
14432 | var actions = [];
|
14433 | each(this.manager.recognizers, function(recognizer) {
|
14434 | if (boolOrFn(recognizer.options.enable, [recognizer])) {
|
14435 | actions = actions.concat(recognizer.getTouchAction());
|
14436 | }
|
14437 | });
|
14438 | return cleanTouchActions(actions.join(' '));
|
14439 | },
|
14440 |
|
14441 | |
14442 |
|
14443 |
|
14444 |
|
14445 | preventDefaults: function(input) {
|
14446 | var srcEvent = input.srcEvent;
|
14447 | var direction = input.offsetDirection;
|
14448 |
|
14449 |
|
14450 | if (this.manager.session.prevented) {
|
14451 | srcEvent.preventDefault();
|
14452 | return;
|
14453 | }
|
14454 |
|
14455 | var actions = this.actions;
|
14456 | var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
|
14457 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
|
14458 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
|
14459 |
|
14460 | if (hasNone) {
|
14461 |
|
14462 |
|
14463 | var isTapPointer = input.pointers.length === 1;
|
14464 | var isTapMovement = input.distance < 2;
|
14465 | var isTapTouchTime = input.deltaTime < 250;
|
14466 |
|
14467 | if (isTapPointer && isTapMovement && isTapTouchTime) {
|
14468 | return;
|
14469 | }
|
14470 | }
|
14471 |
|
14472 | if (hasPanX && hasPanY) {
|
14473 |
|
14474 | return;
|
14475 | }
|
14476 |
|
14477 | if (hasNone ||
|
14478 | (hasPanY && direction & DIRECTION_HORIZONTAL) ||
|
14479 | (hasPanX && direction & DIRECTION_VERTICAL)) {
|
14480 | return this.preventSrc(srcEvent);
|
14481 | }
|
14482 | },
|
14483 |
|
14484 | |
14485 |
|
14486 |
|
14487 |
|
14488 | preventSrc: function(srcEvent) {
|
14489 | this.manager.session.prevented = true;
|
14490 | srcEvent.preventDefault();
|
14491 | }
|
14492 | };
|
14493 |
|
14494 |
|
14495 |
|
14496 |
|
14497 |
|
14498 |
|
14499 | function cleanTouchActions(actions) {
|
14500 |
|
14501 | if (inStr(actions, TOUCH_ACTION_NONE)) {
|
14502 | return TOUCH_ACTION_NONE;
|
14503 | }
|
14504 |
|
14505 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
|
14506 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
|
14507 |
|
14508 |
|
14509 |
|
14510 |
|
14511 |
|
14512 | if (hasPanX && hasPanY) {
|
14513 | return TOUCH_ACTION_NONE;
|
14514 | }
|
14515 |
|
14516 |
|
14517 | if (hasPanX || hasPanY) {
|
14518 | return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
|
14519 | }
|
14520 |
|
14521 |
|
14522 | if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
|
14523 | return TOUCH_ACTION_MANIPULATION;
|
14524 | }
|
14525 |
|
14526 | return TOUCH_ACTION_AUTO;
|
14527 | }
|
14528 |
|
14529 | function getTouchActionProps() {
|
14530 | if (!NATIVE_TOUCH_ACTION) {
|
14531 | return false;
|
14532 | }
|
14533 | var touchMap = {};
|
14534 | var cssSupports = window.CSS && window.CSS.supports;
|
14535 | ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function(val) {
|
14536 |
|
14537 |
|
14538 |
|
14539 | touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
|
14540 | });
|
14541 | return touchMap;
|
14542 | }
|
14543 |
|
14544 |
|
14545 |
|
14546 |
|
14547 |
|
14548 |
|
14549 |
|
14550 |
|
14551 |
|
14552 |
|
14553 |
|
14554 |
|
14555 |
|
14556 |
|
14557 |
|
14558 |
|
14559 |
|
14560 |
|
14561 |
|
14562 |
|
14563 |
|
14564 |
|
14565 |
|
14566 |
|
14567 |
|
14568 |
|
14569 |
|
14570 |
|
14571 | var STATE_POSSIBLE = 1;
|
14572 | var STATE_BEGAN = 2;
|
14573 | var STATE_CHANGED = 4;
|
14574 | var STATE_ENDED = 8;
|
14575 | var STATE_RECOGNIZED = STATE_ENDED;
|
14576 | var STATE_CANCELLED = 16;
|
14577 | var STATE_FAILED = 32;
|
14578 |
|
14579 |
|
14580 |
|
14581 |
|
14582 |
|
14583 |
|
14584 |
|
14585 | function Recognizer(options) {
|
14586 | this.options = assign({}, this.defaults, options || {});
|
14587 |
|
14588 | this.id = uniqueId();
|
14589 |
|
14590 | this.manager = null;
|
14591 |
|
14592 |
|
14593 | this.options.enable = ifUndefined(this.options.enable, true);
|
14594 |
|
14595 | this.state = STATE_POSSIBLE;
|
14596 |
|
14597 | this.simultaneous = {};
|
14598 | this.requireFail = [];
|
14599 | }
|
14600 |
|
14601 | Recognizer.prototype = {
|
14602 | |
14603 |
|
14604 |
|
14605 |
|
14606 | defaults: {},
|
14607 |
|
14608 | |
14609 |
|
14610 |
|
14611 |
|
14612 |
|
14613 | set: function(options) {
|
14614 | assign(this.options, options);
|
14615 |
|
14616 |
|
14617 | this.manager && this.manager.touchAction.update();
|
14618 | return this;
|
14619 | },
|
14620 |
|
14621 | |
14622 |
|
14623 |
|
14624 |
|
14625 |
|
14626 | recognizeWith: function(otherRecognizer) {
|
14627 | if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
|
14628 | return this;
|
14629 | }
|
14630 |
|
14631 | var simultaneous = this.simultaneous;
|
14632 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
14633 | if (!simultaneous[otherRecognizer.id]) {
|
14634 | simultaneous[otherRecognizer.id] = otherRecognizer;
|
14635 | otherRecognizer.recognizeWith(this);
|
14636 | }
|
14637 | return this;
|
14638 | },
|
14639 |
|
14640 | |
14641 |
|
14642 |
|
14643 |
|
14644 |
|
14645 | dropRecognizeWith: function(otherRecognizer) {
|
14646 | if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
|
14647 | return this;
|
14648 | }
|
14649 |
|
14650 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
14651 | delete this.simultaneous[otherRecognizer.id];
|
14652 | return this;
|
14653 | },
|
14654 |
|
14655 | |
14656 |
|
14657 |
|
14658 |
|
14659 |
|
14660 | requireFailure: function(otherRecognizer) {
|
14661 | if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
|
14662 | return this;
|
14663 | }
|
14664 |
|
14665 | var requireFail = this.requireFail;
|
14666 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
14667 | if (inArray(requireFail, otherRecognizer) === -1) {
|
14668 | requireFail.push(otherRecognizer);
|
14669 | otherRecognizer.requireFailure(this);
|
14670 | }
|
14671 | return this;
|
14672 | },
|
14673 |
|
14674 | |
14675 |
|
14676 |
|
14677 |
|
14678 |
|
14679 | dropRequireFailure: function(otherRecognizer) {
|
14680 | if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
|
14681 | return this;
|
14682 | }
|
14683 |
|
14684 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
14685 | var index = inArray(this.requireFail, otherRecognizer);
|
14686 | if (index > -1) {
|
14687 | this.requireFail.splice(index, 1);
|
14688 | }
|
14689 | return this;
|
14690 | },
|
14691 |
|
14692 | |
14693 |
|
14694 |
|
14695 |
|
14696 | hasRequireFailures: function() {
|
14697 | return this.requireFail.length > 0;
|
14698 | },
|
14699 |
|
14700 | |
14701 |
|
14702 |
|
14703 |
|
14704 |
|
14705 | canRecognizeWith: function(otherRecognizer) {
|
14706 | return !!this.simultaneous[otherRecognizer.id];
|
14707 | },
|
14708 |
|
14709 | |
14710 |
|
14711 |
|
14712 |
|
14713 |
|
14714 | emit: function(input) {
|
14715 | var self = this;
|
14716 | var state = this.state;
|
14717 |
|
14718 | function emit(event) {
|
14719 | self.manager.emit(event, input);
|
14720 | }
|
14721 |
|
14722 |
|
14723 | if (state < STATE_ENDED) {
|
14724 | emit(self.options.event + stateStr(state));
|
14725 | }
|
14726 |
|
14727 | emit(self.options.event);
|
14728 |
|
14729 | if (input.additionalEvent) {
|
14730 | emit(input.additionalEvent);
|
14731 | }
|
14732 |
|
14733 |
|
14734 | if (state >= STATE_ENDED) {
|
14735 | emit(self.options.event + stateStr(state));
|
14736 | }
|
14737 | },
|
14738 |
|
14739 | |
14740 |
|
14741 |
|
14742 |
|
14743 |
|
14744 |
|
14745 | tryEmit: function(input) {
|
14746 | if (this.canEmit()) {
|
14747 | return this.emit(input);
|
14748 | }
|
14749 |
|
14750 | this.state = STATE_FAILED;
|
14751 | },
|
14752 |
|
14753 | |
14754 |
|
14755 |
|
14756 |
|
14757 | canEmit: function() {
|
14758 | var i = 0;
|
14759 | while (i < this.requireFail.length) {
|
14760 | if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
|
14761 | return false;
|
14762 | }
|
14763 | i++;
|
14764 | }
|
14765 | return true;
|
14766 | },
|
14767 |
|
14768 | |
14769 |
|
14770 |
|
14771 |
|
14772 | recognize: function(inputData) {
|
14773 |
|
14774 |
|
14775 | var inputDataClone = assign({}, inputData);
|
14776 |
|
14777 |
|
14778 | if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
|
14779 | this.reset();
|
14780 | this.state = STATE_FAILED;
|
14781 | return;
|
14782 | }
|
14783 |
|
14784 |
|
14785 | if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
|
14786 | this.state = STATE_POSSIBLE;
|
14787 | }
|
14788 |
|
14789 | this.state = this.process(inputDataClone);
|
14790 |
|
14791 |
|
14792 |
|
14793 | if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
|
14794 | this.tryEmit(inputDataClone);
|
14795 | }
|
14796 | },
|
14797 |
|
14798 | |
14799 |
|
14800 |
|
14801 |
|
14802 |
|
14803 |
|
14804 |
|
14805 | process: function(inputData) { },
|
14806 |
|
14807 | |
14808 |
|
14809 |
|
14810 |
|
14811 |
|
14812 | getTouchAction: function() { },
|
14813 |
|
14814 | |
14815 |
|
14816 |
|
14817 |
|
14818 |
|
14819 | reset: function() { }
|
14820 | };
|
14821 |
|
14822 |
|
14823 |
|
14824 |
|
14825 |
|
14826 |
|
14827 | function stateStr(state) {
|
14828 | if (state & STATE_CANCELLED) {
|
14829 | return 'cancel';
|
14830 | } else if (state & STATE_ENDED) {
|
14831 | return 'end';
|
14832 | } else if (state & STATE_CHANGED) {
|
14833 | return 'move';
|
14834 | } else if (state & STATE_BEGAN) {
|
14835 | return 'start';
|
14836 | }
|
14837 | return '';
|
14838 | }
|
14839 |
|
14840 |
|
14841 |
|
14842 |
|
14843 |
|
14844 |
|
14845 | function directionStr(direction) {
|
14846 | if (direction == DIRECTION_DOWN) {
|
14847 | return 'down';
|
14848 | } else if (direction == DIRECTION_UP) {
|
14849 | return 'up';
|
14850 | } else if (direction == DIRECTION_LEFT) {
|
14851 | return 'left';
|
14852 | } else if (direction == DIRECTION_RIGHT) {
|
14853 | return 'right';
|
14854 | }
|
14855 | return '';
|
14856 | }
|
14857 |
|
14858 |
|
14859 |
|
14860 |
|
14861 |
|
14862 |
|
14863 |
|
14864 | function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
14865 | var manager = recognizer.manager;
|
14866 | if (manager) {
|
14867 | return manager.get(otherRecognizer);
|
14868 | }
|
14869 | return otherRecognizer;
|
14870 | }
|
14871 |
|
14872 |
|
14873 |
|
14874 |
|
14875 |
|
14876 |
|
14877 | function AttrRecognizer() {
|
14878 | Recognizer.apply(this, arguments);
|
14879 | }
|
14880 |
|
14881 | inherit(AttrRecognizer, Recognizer, {
|
14882 | |
14883 |
|
14884 |
|
14885 |
|
14886 | defaults: {
|
14887 | |
14888 |
|
14889 |
|
14890 |
|
14891 | pointers: 1
|
14892 | },
|
14893 |
|
14894 | |
14895 |
|
14896 |
|
14897 |
|
14898 |
|
14899 |
|
14900 | attrTest: function(input) {
|
14901 | var optionPointers = this.options.pointers;
|
14902 | return optionPointers === 0 || input.pointers.length === optionPointers;
|
14903 | },
|
14904 |
|
14905 | |
14906 |
|
14907 |
|
14908 |
|
14909 |
|
14910 |
|
14911 | process: function(input) {
|
14912 | var state = this.state;
|
14913 | var eventType = input.eventType;
|
14914 |
|
14915 | var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
|
14916 | var isValid = this.attrTest(input);
|
14917 |
|
14918 |
|
14919 | if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
|
14920 | return state | STATE_CANCELLED;
|
14921 | } else if (isRecognized || isValid) {
|
14922 | if (eventType & INPUT_END) {
|
14923 | return state | STATE_ENDED;
|
14924 | } else if (!(state & STATE_BEGAN)) {
|
14925 | return STATE_BEGAN;
|
14926 | }
|
14927 | return state | STATE_CHANGED;
|
14928 | }
|
14929 | return STATE_FAILED;
|
14930 | }
|
14931 | });
|
14932 |
|
14933 |
|
14934 |
|
14935 |
|
14936 |
|
14937 |
|
14938 |
|
14939 | function PanRecognizer() {
|
14940 | AttrRecognizer.apply(this, arguments);
|
14941 |
|
14942 | this.pX = null;
|
14943 | this.pY = null;
|
14944 | }
|
14945 |
|
14946 | inherit(PanRecognizer, AttrRecognizer, {
|
14947 | |
14948 |
|
14949 |
|
14950 |
|
14951 | defaults: {
|
14952 | event: 'pan',
|
14953 | threshold: 10,
|
14954 | pointers: 1,
|
14955 | direction: DIRECTION_ALL
|
14956 | },
|
14957 |
|
14958 | getTouchAction: function() {
|
14959 | var direction = this.options.direction;
|
14960 | var actions = [];
|
14961 | if (direction & DIRECTION_HORIZONTAL) {
|
14962 | actions.push(TOUCH_ACTION_PAN_Y);
|
14963 | }
|
14964 | if (direction & DIRECTION_VERTICAL) {
|
14965 | actions.push(TOUCH_ACTION_PAN_X);
|
14966 | }
|
14967 | return actions;
|
14968 | },
|
14969 |
|
14970 | directionTest: function(input) {
|
14971 | var options = this.options;
|
14972 | var hasMoved = true;
|
14973 | var distance = input.distance;
|
14974 | var direction = input.direction;
|
14975 | var x = input.deltaX;
|
14976 | var y = input.deltaY;
|
14977 |
|
14978 |
|
14979 | if (!(direction & options.direction)) {
|
14980 | if (options.direction & DIRECTION_HORIZONTAL) {
|
14981 | direction = (x === 0) ? DIRECTION_NONE : (x < 0) ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
14982 | hasMoved = x != this.pX;
|
14983 | distance = Math.abs(input.deltaX);
|
14984 | } else {
|
14985 | direction = (y === 0) ? DIRECTION_NONE : (y < 0) ? DIRECTION_UP : DIRECTION_DOWN;
|
14986 | hasMoved = y != this.pY;
|
14987 | distance = Math.abs(input.deltaY);
|
14988 | }
|
14989 | }
|
14990 | input.direction = direction;
|
14991 | return hasMoved && distance > options.threshold && direction & options.direction;
|
14992 | },
|
14993 |
|
14994 | attrTest: function(input) {
|
14995 | return AttrRecognizer.prototype.attrTest.call(this, input) &&
|
14996 | (this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input)));
|
14997 | },
|
14998 |
|
14999 | emit: function(input) {
|
15000 |
|
15001 | this.pX = input.deltaX;
|
15002 | this.pY = input.deltaY;
|
15003 |
|
15004 | var direction = directionStr(input.direction);
|
15005 |
|
15006 | if (direction) {
|
15007 | input.additionalEvent = this.options.event + direction;
|
15008 | }
|
15009 | this._super.emit.call(this, input);
|
15010 | }
|
15011 | });
|
15012 |
|
15013 |
|
15014 |
|
15015 |
|
15016 |
|
15017 |
|
15018 |
|
15019 | function PinchRecognizer() {
|
15020 | AttrRecognizer.apply(this, arguments);
|
15021 | }
|
15022 |
|
15023 | inherit(PinchRecognizer, AttrRecognizer, {
|
15024 | |
15025 |
|
15026 |
|
15027 |
|
15028 | defaults: {
|
15029 | event: 'pinch',
|
15030 | threshold: 0,
|
15031 | pointers: 2
|
15032 | },
|
15033 |
|
15034 | getTouchAction: function() {
|
15035 | return [TOUCH_ACTION_NONE];
|
15036 | },
|
15037 |
|
15038 | attrTest: function(input) {
|
15039 | return this._super.attrTest.call(this, input) &&
|
15040 | (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
|
15041 | },
|
15042 |
|
15043 | emit: function(input) {
|
15044 | if (input.scale !== 1) {
|
15045 | var inOut = input.scale < 1 ? 'in' : 'out';
|
15046 | input.additionalEvent = this.options.event + inOut;
|
15047 | }
|
15048 | this._super.emit.call(this, input);
|
15049 | }
|
15050 | });
|
15051 |
|
15052 |
|
15053 |
|
15054 |
|
15055 |
|
15056 |
|
15057 |
|
15058 | function PressRecognizer() {
|
15059 | Recognizer.apply(this, arguments);
|
15060 |
|
15061 | this._timer = null;
|
15062 | this._input = null;
|
15063 | }
|
15064 |
|
15065 | inherit(PressRecognizer, Recognizer, {
|
15066 | |
15067 |
|
15068 |
|
15069 |
|
15070 | defaults: {
|
15071 | event: 'press',
|
15072 | pointers: 1,
|
15073 | time: 251,
|
15074 | threshold: 9
|
15075 | },
|
15076 |
|
15077 | getTouchAction: function() {
|
15078 | return [TOUCH_ACTION_AUTO];
|
15079 | },
|
15080 |
|
15081 | process: function(input) {
|
15082 | var options = this.options;
|
15083 | var validPointers = input.pointers.length === options.pointers;
|
15084 | var validMovement = input.distance < options.threshold;
|
15085 | var validTime = input.deltaTime > options.time;
|
15086 |
|
15087 | this._input = input;
|
15088 |
|
15089 |
|
15090 |
|
15091 | if (!validMovement || !validPointers || (input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime)) {
|
15092 | this.reset();
|
15093 | } else if (input.eventType & INPUT_START) {
|
15094 | this.reset();
|
15095 | this._timer = setTimeoutContext(function() {
|
15096 | this.state = STATE_RECOGNIZED;
|
15097 | this.tryEmit();
|
15098 | }, options.time, this);
|
15099 | } else if (input.eventType & INPUT_END) {
|
15100 | return STATE_RECOGNIZED;
|
15101 | }
|
15102 | return STATE_FAILED;
|
15103 | },
|
15104 |
|
15105 | reset: function() {
|
15106 | clearTimeout(this._timer);
|
15107 | },
|
15108 |
|
15109 | emit: function(input) {
|
15110 | if (this.state !== STATE_RECOGNIZED) {
|
15111 | return;
|
15112 | }
|
15113 |
|
15114 | if (input && (input.eventType & INPUT_END)) {
|
15115 | this.manager.emit(this.options.event + 'up', input);
|
15116 | } else {
|
15117 | this._input.timeStamp = now();
|
15118 | this.manager.emit(this.options.event, this._input);
|
15119 | }
|
15120 | }
|
15121 | });
|
15122 |
|
15123 |
|
15124 |
|
15125 |
|
15126 |
|
15127 |
|
15128 |
|
15129 | function RotateRecognizer() {
|
15130 | AttrRecognizer.apply(this, arguments);
|
15131 | }
|
15132 |
|
15133 | inherit(RotateRecognizer, AttrRecognizer, {
|
15134 | |
15135 |
|
15136 |
|
15137 |
|
15138 | defaults: {
|
15139 | event: 'rotate',
|
15140 | threshold: 0,
|
15141 | pointers: 2
|
15142 | },
|
15143 |
|
15144 | getTouchAction: function() {
|
15145 | return [TOUCH_ACTION_NONE];
|
15146 | },
|
15147 |
|
15148 | attrTest: function(input) {
|
15149 | return this._super.attrTest.call(this, input) &&
|
15150 | (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
15151 | }
|
15152 | });
|
15153 |
|
15154 |
|
15155 |
|
15156 |
|
15157 |
|
15158 |
|
15159 |
|
15160 | function SwipeRecognizer() {
|
15161 | AttrRecognizer.apply(this, arguments);
|
15162 | }
|
15163 |
|
15164 | inherit(SwipeRecognizer, AttrRecognizer, {
|
15165 | |
15166 |
|
15167 |
|
15168 |
|
15169 | defaults: {
|
15170 | event: 'swipe',
|
15171 | threshold: 10,
|
15172 | velocity: 0.3,
|
15173 | direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
|
15174 | pointers: 1
|
15175 | },
|
15176 |
|
15177 | getTouchAction: function() {
|
15178 | return PanRecognizer.prototype.getTouchAction.call(this);
|
15179 | },
|
15180 |
|
15181 | attrTest: function(input) {
|
15182 | var direction = this.options.direction;
|
15183 | var velocity;
|
15184 |
|
15185 | if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
15186 | velocity = input.overallVelocity;
|
15187 | } else if (direction & DIRECTION_HORIZONTAL) {
|
15188 | velocity = input.overallVelocityX;
|
15189 | } else if (direction & DIRECTION_VERTICAL) {
|
15190 | velocity = input.overallVelocityY;
|
15191 | }
|
15192 |
|
15193 | return this._super.attrTest.call(this, input) &&
|
15194 | direction & input.offsetDirection &&
|
15195 | input.distance > this.options.threshold &&
|
15196 | input.maxPointers == this.options.pointers &&
|
15197 | abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
|
15198 | },
|
15199 |
|
15200 | emit: function(input) {
|
15201 | var direction = directionStr(input.offsetDirection);
|
15202 | if (direction) {
|
15203 | this.manager.emit(this.options.event + direction, input);
|
15204 | }
|
15205 |
|
15206 | this.manager.emit(this.options.event, input);
|
15207 | }
|
15208 | });
|
15209 |
|
15210 |
|
15211 |
|
15212 |
|
15213 |
|
15214 |
|
15215 |
|
15216 |
|
15217 |
|
15218 |
|
15219 |
|
15220 | function TapRecognizer() {
|
15221 | Recognizer.apply(this, arguments);
|
15222 |
|
15223 |
|
15224 |
|
15225 | this.pTime = false;
|
15226 | this.pCenter = false;
|
15227 |
|
15228 | this._timer = null;
|
15229 | this._input = null;
|
15230 | this.count = 0;
|
15231 | }
|
15232 |
|
15233 | inherit(TapRecognizer, Recognizer, {
|
15234 | |
15235 |
|
15236 |
|
15237 |
|
15238 | defaults: {
|
15239 | event: 'tap',
|
15240 | pointers: 1,
|
15241 | taps: 1,
|
15242 | interval: 300,
|
15243 | time: 250,
|
15244 | threshold: 9,
|
15245 | posThreshold: 10
|
15246 | },
|
15247 |
|
15248 | getTouchAction: function() {
|
15249 | return [TOUCH_ACTION_MANIPULATION];
|
15250 | },
|
15251 |
|
15252 | process: function(input) {
|
15253 | var options = this.options;
|
15254 |
|
15255 | var validPointers = input.pointers.length === options.pointers;
|
15256 | var validMovement = input.distance < options.threshold;
|
15257 | var validTouchTime = input.deltaTime < options.time;
|
15258 |
|
15259 | this.reset();
|
15260 |
|
15261 | if ((input.eventType & INPUT_START) && (this.count === 0)) {
|
15262 | return this.failTimeout();
|
15263 | }
|
15264 |
|
15265 |
|
15266 |
|
15267 | if (validMovement && validTouchTime && validPointers) {
|
15268 | if (input.eventType != INPUT_END) {
|
15269 | return this.failTimeout();
|
15270 | }
|
15271 |
|
15272 | var validInterval = this.pTime ? (input.timeStamp - this.pTime < options.interval) : true;
|
15273 | var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
|
15274 |
|
15275 | this.pTime = input.timeStamp;
|
15276 | this.pCenter = input.center;
|
15277 |
|
15278 | if (!validMultiTap || !validInterval) {
|
15279 | this.count = 1;
|
15280 | } else {
|
15281 | this.count += 1;
|
15282 | }
|
15283 |
|
15284 | this._input = input;
|
15285 |
|
15286 |
|
15287 |
|
15288 | var tapCount = this.count % options.taps;
|
15289 | if (tapCount === 0) {
|
15290 |
|
15291 |
|
15292 | if (!this.hasRequireFailures()) {
|
15293 | return STATE_RECOGNIZED;
|
15294 | } else {
|
15295 | this._timer = setTimeoutContext(function() {
|
15296 | this.state = STATE_RECOGNIZED;
|
15297 | this.tryEmit();
|
15298 | }, options.interval, this);
|
15299 | return STATE_BEGAN;
|
15300 | }
|
15301 | }
|
15302 | }
|
15303 | return STATE_FAILED;
|
15304 | },
|
15305 |
|
15306 | failTimeout: function() {
|
15307 | this._timer = setTimeoutContext(function() {
|
15308 | this.state = STATE_FAILED;
|
15309 | }, this.options.interval, this);
|
15310 | return STATE_FAILED;
|
15311 | },
|
15312 |
|
15313 | reset: function() {
|
15314 | clearTimeout(this._timer);
|
15315 | },
|
15316 |
|
15317 | emit: function() {
|
15318 | if (this.state == STATE_RECOGNIZED) {
|
15319 | this._input.tapCount = this.count;
|
15320 | this.manager.emit(this.options.event, this._input);
|
15321 | }
|
15322 | }
|
15323 | });
|
15324 |
|
15325 |
|
15326 |
|
15327 |
|
15328 |
|
15329 |
|
15330 |
|
15331 | function NGHammer(element, options) {
|
15332 | options = options || {};
|
15333 | options.recognizers = ifUndefined(options.recognizers, NGHammer.defaults.preset);
|
15334 | return new Manager(element, options);
|
15335 | }
|
15336 |
|
15337 |
|
15338 |
|
15339 |
|
15340 | NGHammer.VERSION = '2.0.7';
|
15341 |
|
15342 |
|
15343 |
|
15344 |
|
15345 |
|
15346 | NGHammer.defaults = {
|
15347 | |
15348 |
|
15349 |
|
15350 |
|
15351 |
|
15352 |
|
15353 | domEvents: false,
|
15354 |
|
15355 | |
15356 |
|
15357 |
|
15358 |
|
15359 |
|
15360 |
|
15361 | touchAction: TOUCH_ACTION_COMPUTE,
|
15362 |
|
15363 | |
15364 |
|
15365 |
|
15366 |
|
15367 | enable: true,
|
15368 |
|
15369 | |
15370 |
|
15371 |
|
15372 |
|
15373 |
|
15374 |
|
15375 |
|
15376 | inputTarget: null,
|
15377 |
|
15378 | |
15379 |
|
15380 |
|
15381 |
|
15382 |
|
15383 | inputClass: null,
|
15384 |
|
15385 | |
15386 |
|
15387 |
|
15388 |
|
15389 |
|
15390 | preset: [
|
15391 |
|
15392 | [RotateRecognizer, {enable: false}],
|
15393 | [PinchRecognizer, {enable: false}, ['rotate']],
|
15394 | [SwipeRecognizer, {direction: DIRECTION_HORIZONTAL}],
|
15395 | [PanRecognizer, {direction: DIRECTION_HORIZONTAL}, ['swipe']],
|
15396 | [TapRecognizer],
|
15397 | [TapRecognizer, {event: 'doubletap', taps: 2}, ['tap']],
|
15398 | [PressRecognizer]
|
15399 | ],
|
15400 |
|
15401 | |
15402 |
|
15403 |
|
15404 |
|
15405 |
|
15406 | cssProps: {
|
15407 | |
15408 |
|
15409 |
|
15410 |
|
15411 |
|
15412 | userSelect: 'none',
|
15413 |
|
15414 | |
15415 |
|
15416 |
|
15417 |
|
15418 |
|
15419 | touchSelect: 'none',
|
15420 |
|
15421 | |
15422 |
|
15423 |
|
15424 |
|
15425 |
|
15426 |
|
15427 |
|
15428 | touchCallout: 'none',
|
15429 |
|
15430 | |
15431 |
|
15432 |
|
15433 |
|
15434 |
|
15435 | contentZooming: 'none',
|
15436 |
|
15437 | |
15438 |
|
15439 |
|
15440 |
|
15441 |
|
15442 | userDrag: 'none',
|
15443 |
|
15444 | |
15445 |
|
15446 |
|
15447 |
|
15448 |
|
15449 |
|
15450 | tapHighlightColor: 'rgba(0,0,0,0)'
|
15451 | }
|
15452 | };
|
15453 |
|
15454 | var STOP = 1;
|
15455 | var FORCED_STOP = 2;
|
15456 |
|
15457 |
|
15458 |
|
15459 |
|
15460 |
|
15461 |
|
15462 |
|
15463 | function Manager(element, options) {
|
15464 | this.options = assign({}, NGHammer.defaults, options || {});
|
15465 |
|
15466 | this.options.inputTarget = this.options.inputTarget || element;
|
15467 |
|
15468 | this.handlers = {};
|
15469 | this.session = {};
|
15470 | this.recognizers = [];
|
15471 | this.oldCssProps = {};
|
15472 |
|
15473 | this.element = element;
|
15474 | this.input = createInputInstance(this);
|
15475 | this.touchAction = new TouchAction(this, this.options.touchAction);
|
15476 |
|
15477 | toggleCssProps(this, true);
|
15478 |
|
15479 | each(this.options.recognizers, function(item) {
|
15480 | var recognizer = this.add(new (item[0])(item[1]));
|
15481 | item[2] && recognizer.recognizeWith(item[2]);
|
15482 | item[3] && recognizer.requireFailure(item[3]);
|
15483 | }, this);
|
15484 | }
|
15485 |
|
15486 | Manager.prototype = {
|
15487 | |
15488 |
|
15489 |
|
15490 |
|
15491 |
|
15492 | set: function(options) {
|
15493 | assign(this.options, options);
|
15494 |
|
15495 |
|
15496 | if (options.touchAction) {
|
15497 | this.touchAction.update();
|
15498 | }
|
15499 | if (options.inputTarget) {
|
15500 |
|
15501 | this.input.destroy();
|
15502 | this.input.target = options.inputTarget;
|
15503 | this.input.init();
|
15504 | }
|
15505 | return this;
|
15506 | },
|
15507 |
|
15508 | |
15509 |
|
15510 |
|
15511 |
|
15512 |
|
15513 |
|
15514 | stop: function(force) {
|
15515 | this.session.stopped = force ? FORCED_STOP : STOP;
|
15516 | },
|
15517 |
|
15518 | |
15519 |
|
15520 |
|
15521 |
|
15522 |
|
15523 |
|
15524 | recognize: function(inputData) {
|
15525 | var session = this.session;
|
15526 | if (session.stopped) {
|
15527 | return;
|
15528 | }
|
15529 |
|
15530 |
|
15531 | this.touchAction.preventDefaults(inputData);
|
15532 |
|
15533 | var recognizer;
|
15534 | var recognizers = this.recognizers;
|
15535 |
|
15536 |
|
15537 |
|
15538 |
|
15539 | var curRecognizer = session.curRecognizer;
|
15540 |
|
15541 |
|
15542 |
|
15543 | if (!curRecognizer || (curRecognizer && curRecognizer.state & STATE_RECOGNIZED)) {
|
15544 | curRecognizer = session.curRecognizer = null;
|
15545 | }
|
15546 |
|
15547 | var i = 0;
|
15548 | while (i < recognizers.length) {
|
15549 | recognizer = recognizers[i];
|
15550 |
|
15551 |
|
15552 |
|
15553 |
|
15554 |
|
15555 |
|
15556 |
|
15557 | if (session.stopped !== FORCED_STOP && (
|
15558 | !curRecognizer || recognizer == curRecognizer ||
|
15559 | recognizer.canRecognizeWith(curRecognizer))) {
|
15560 | recognizer.recognize(inputData);
|
15561 | } else {
|
15562 | recognizer.reset();
|
15563 | }
|
15564 |
|
15565 |
|
15566 |
|
15567 | if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
|
15568 | curRecognizer = session.curRecognizer = recognizer;
|
15569 | }
|
15570 | i++;
|
15571 | }
|
15572 | },
|
15573 |
|
15574 | |
15575 |
|
15576 |
|
15577 |
|
15578 |
|
15579 | get: function(recognizer) {
|
15580 | if (recognizer instanceof Recognizer) {
|
15581 | return recognizer;
|
15582 | }
|
15583 |
|
15584 | var recognizers = this.recognizers;
|
15585 | for (var i = 0; i < recognizers.length; i++) {
|
15586 | if (recognizers[i].options.event == recognizer) {
|
15587 | return recognizers[i];
|
15588 | }
|
15589 | }
|
15590 | return null;
|
15591 | },
|
15592 |
|
15593 | |
15594 |
|
15595 |
|
15596 |
|
15597 |
|
15598 |
|
15599 | add: function(recognizer) {
|
15600 | if (invokeArrayArg(recognizer, 'add', this)) {
|
15601 | return this;
|
15602 | }
|
15603 |
|
15604 |
|
15605 | var existing = this.get(recognizer.options.event);
|
15606 | if (existing) {
|
15607 | this.remove(existing);
|
15608 | }
|
15609 |
|
15610 | this.recognizers.push(recognizer);
|
15611 | recognizer.manager = this;
|
15612 |
|
15613 | this.touchAction.update();
|
15614 | return recognizer;
|
15615 | },
|
15616 |
|
15617 | |
15618 |
|
15619 |
|
15620 |
|
15621 |
|
15622 | remove: function(recognizer) {
|
15623 | if (invokeArrayArg(recognizer, 'remove', this)) {
|
15624 | return this;
|
15625 | }
|
15626 |
|
15627 | recognizer = this.get(recognizer);
|
15628 |
|
15629 |
|
15630 | if (recognizer) {
|
15631 | var recognizers = this.recognizers;
|
15632 | var index = inArray(recognizers, recognizer);
|
15633 |
|
15634 | if (index !== -1) {
|
15635 | recognizers.splice(index, 1);
|
15636 | this.touchAction.update();
|
15637 | }
|
15638 | }
|
15639 |
|
15640 | return this;
|
15641 | },
|
15642 |
|
15643 | |
15644 |
|
15645 |
|
15646 |
|
15647 |
|
15648 |
|
15649 | on: function(events, handler) {
|
15650 | if (events === undefined) {
|
15651 | return;
|
15652 | }
|
15653 | if (handler === undefined) {
|
15654 | return;
|
15655 | }
|
15656 |
|
15657 | var handlers = this.handlers;
|
15658 | each(splitStr(events), function(event) {
|
15659 | handlers[event] = handlers[event] || [];
|
15660 | handlers[event].push(handler);
|
15661 | });
|
15662 | return this;
|
15663 | },
|
15664 |
|
15665 | |
15666 |
|
15667 |
|
15668 |
|
15669 |
|
15670 |
|
15671 | off: function(events, handler) {
|
15672 | if (events === undefined) {
|
15673 | return;
|
15674 | }
|
15675 |
|
15676 | var handlers = this.handlers;
|
15677 | each(splitStr(events), function(event) {
|
15678 | if (!handler) {
|
15679 | delete handlers[event];
|
15680 | } else {
|
15681 | handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
|
15682 | }
|
15683 | });
|
15684 | return this;
|
15685 | },
|
15686 |
|
15687 | |
15688 |
|
15689 |
|
15690 |
|
15691 |
|
15692 | emit: function(event, data) {
|
15693 |
|
15694 | if (this.options.domEvents) {
|
15695 | triggerDomEvent(event, data);
|
15696 | }
|
15697 |
|
15698 |
|
15699 | var handlers = this.handlers[event] && this.handlers[event].slice();
|
15700 | if (!handlers || !handlers.length) {
|
15701 | return;
|
15702 | }
|
15703 |
|
15704 | data.type = event;
|
15705 | data.preventDefault = function() {
|
15706 | data.srcEvent.preventDefault();
|
15707 | };
|
15708 |
|
15709 | var i = 0;
|
15710 | while (i < handlers.length) {
|
15711 | handlers[i](data);
|
15712 | i++;
|
15713 | }
|
15714 | },
|
15715 |
|
15716 | |
15717 |
|
15718 |
|
15719 |
|
15720 | destroy: function() {
|
15721 | this.element && toggleCssProps(this, false);
|
15722 |
|
15723 | this.handlers = {};
|
15724 | this.session = {};
|
15725 | this.input.destroy();
|
15726 | this.element = null;
|
15727 | }
|
15728 | };
|
15729 |
|
15730 |
|
15731 |
|
15732 |
|
15733 |
|
15734 |
|
15735 | function toggleCssProps(manager, add) {
|
15736 | var element = manager.element;
|
15737 | if (!element.style) {
|
15738 | return;
|
15739 | }
|
15740 | var prop;
|
15741 | each(manager.options.cssProps, function(value, name) {
|
15742 | prop = prefixed(element.style, name);
|
15743 | if (add) {
|
15744 | manager.oldCssProps[prop] = element.style[prop];
|
15745 | element.style[prop] = value;
|
15746 | } else {
|
15747 | element.style[prop] = manager.oldCssProps[prop] || '';
|
15748 | }
|
15749 | });
|
15750 | if (!add) {
|
15751 | manager.oldCssProps = {};
|
15752 | }
|
15753 | }
|
15754 |
|
15755 |
|
15756 |
|
15757 |
|
15758 |
|
15759 |
|
15760 | function triggerDomEvent(event, data) {
|
15761 | var gestureEvent = document.createEvent('Event');
|
15762 | gestureEvent.initEvent(event, true, true);
|
15763 | gestureEvent.gesture = data;
|
15764 | data.target.dispatchEvent(gestureEvent);
|
15765 | }
|
15766 |
|
15767 | assign(NGHammer, {
|
15768 | INPUT_START: INPUT_START,
|
15769 | INPUT_MOVE: INPUT_MOVE,
|
15770 | INPUT_END: INPUT_END,
|
15771 | INPUT_CANCEL: INPUT_CANCEL,
|
15772 |
|
15773 | STATE_POSSIBLE: STATE_POSSIBLE,
|
15774 | STATE_BEGAN: STATE_BEGAN,
|
15775 | STATE_CHANGED: STATE_CHANGED,
|
15776 | STATE_ENDED: STATE_ENDED,
|
15777 | STATE_RECOGNIZED: STATE_RECOGNIZED,
|
15778 | STATE_CANCELLED: STATE_CANCELLED,
|
15779 | STATE_FAILED: STATE_FAILED,
|
15780 |
|
15781 | DIRECTION_NONE: DIRECTION_NONE,
|
15782 | DIRECTION_LEFT: DIRECTION_LEFT,
|
15783 | DIRECTION_RIGHT: DIRECTION_RIGHT,
|
15784 | DIRECTION_UP: DIRECTION_UP,
|
15785 | DIRECTION_DOWN: DIRECTION_DOWN,
|
15786 | DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
|
15787 | DIRECTION_VERTICAL: DIRECTION_VERTICAL,
|
15788 | DIRECTION_ALL: DIRECTION_ALL,
|
15789 |
|
15790 | Manager: Manager,
|
15791 | Input: Input,
|
15792 | TouchAction: TouchAction,
|
15793 |
|
15794 | TouchInput: TouchInput,
|
15795 | MouseInput: MouseInput,
|
15796 | PointerEventInput: PointerEventInput,
|
15797 | TouchMouseInput: TouchMouseInput,
|
15798 | SingleTouchInput: SingleTouchInput,
|
15799 |
|
15800 | Recognizer: Recognizer,
|
15801 | AttrRecognizer: AttrRecognizer,
|
15802 | Tap: TapRecognizer,
|
15803 | Pan: PanRecognizer,
|
15804 | Swipe: SwipeRecognizer,
|
15805 | Pinch: PinchRecognizer,
|
15806 | Rotate: RotateRecognizer,
|
15807 | Press: PressRecognizer,
|
15808 |
|
15809 | on: addEventListeners,
|
15810 | off: removeEventListeners,
|
15811 | each: each,
|
15812 | merge: merge,
|
15813 | extend: extend,
|
15814 | assign: assign,
|
15815 | inherit: inherit,
|
15816 | bindFn: bindFn,
|
15817 | prefixed: prefixed
|
15818 | });
|
15819 |
|
15820 |
|
15821 |
|
15822 | var freeGlobal = (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}));
|
15823 | freeGlobal.NGHammer = NGHammer;
|
15824 |
|
15825 | if (typeof define === 'function' && define.amdDISABLED) {
|
15826 | define(function() {
|
15827 | return NGHammer;
|
15828 | });
|
15829 | } else if (typeof module != 'undefined' && module.exports) {
|
15830 | module.exports = NGHammer;
|
15831 | } else {
|
15832 | window[exportName] = NGHammer;
|
15833 | }
|
15834 |
|
15835 | })(window, document, 'NGHammer');
|
15836 |
|
15837 |
|
15838 |
|
15839 |
|
15840 |
|
15841 |
|
15842 |
|
15843 |
|
15844 | }));
|
15845 |
|
15846 |
|
15847 |
|
15848 |
|
15849 |
|
15850 |
|
15851 |
|
15852 |
|
15853 |
|
15854 | (function(){
|
15855 | 'use strict';
|
15856 |
|
15857 | function document_ready(callback){
|
15858 |
|
15859 | if (document.readyState!='loading') callback();
|
15860 |
|
15861 | else if (document.addEventListener) document.addEventListener('DOMContentLoaded', callback);
|
15862 |
|
15863 | else document.attachEvent('onreadystatechange', function(){
|
15864 | if (document.readyState=='complete') callback();
|
15865 | });
|
15866 | }
|
15867 |
|
15868 | document_ready(function(){
|
15869 |
|
15870 |
|
15871 | var t=document.querySelectorAll('[data-nanogallery2]');
|
15872 | for( var i=0; i < t.length; i++ ) {
|
15873 | jQuery( t[i] ).nanogallery2( jQuery(t[i]).data('nanogallery2') );
|
15874 | }
|
15875 |
|
15876 |
|
15877 | var t = document.querySelectorAll('[data-nanogallery2-lightbox]');
|
15878 | for( var i=0; i < t.length; i++ ) {
|
15879 |
|
15880 |
|
15881 | t[i].classList.add('NGY2ThumbnailLightbox');
|
15882 |
|
15883 |
|
15884 | t[i].addEventListener('click', function(e) {
|
15885 |
|
15886 | e.preventDefault();
|
15887 |
|
15888 |
|
15889 | var options = {
|
15890 | lightboxStandalone: true,
|
15891 | viewerToolbar: { display: false }
|
15892 | };
|
15893 |
|
15894 |
|
15895 | var g = this.dataset.nanogallery2Lgroup;
|
15896 |
|
15897 |
|
15898 |
|
15899 | var t = document.querySelectorAll('[data-nanogallery2-lightbox]');
|
15900 | for( var i=0; i < t.length; i++ ) {
|
15901 | if( t[i].dataset.nanogallery2Lgroup == g ) {
|
15902 | if( t[i].dataset.nanogallery2Lightbox !== "" ) {
|
15903 | options = jQuery.extend(true, {}, options, jQuery(t[i]).data('nanogallery2Lightbox'));
|
15904 | break;
|
15905 | }
|
15906 | }
|
15907 | }
|
15908 | jQuery( this ).nanogallery2( options );
|
15909 |
|
15910 | });
|
15911 |
|
15912 | }
|
15913 | });
|
15914 |
|
15915 |
|
15916 |
|
15917 |
|
15918 |
|
15919 |
|
15920 |
|
15921 |
|
15922 |
|
15923 |
|
15924 |
|
15925 |
|
15926 |
|
15927 |
|
15928 |
|
15929 |
|
15930 |
|
15931 |
|
15932 |
|
15933 |
|
15934 |
|
15935 |
|
15936 |
|
15937 |
|
15938 |
|
15939 |
|
15940 |
|
15941 |
|
15942 |
|
15943 |
|
15944 |
|
15945 |
|
15946 | }).call(null);
|
15947 |
|
15948 |
|
15949 |
|
15950 |
|
15951 |
|
15952 |
|
15953 |
|
15954 |
|
15955 |
|
15956 |
|
15957 |
|
15958 |
|
15959 |
|
15960 |
|
15961 |
|
15962 |
|
15963 | (function (factory) {
|
15964 | "use strict";
|
15965 | if (typeof define === 'function' && define.amd) {
|
15966 |
|
15967 | define(['jquery', 'nanogallery2'], factory);
|
15968 | } else if (typeof exports === 'object' && typeof require === 'function') {
|
15969 |
|
15970 | factory(require(['jquery', 'nanogallery2']));
|
15971 | } else {
|
15972 |
|
15973 | factory(jQuery);
|
15974 | }
|
15975 | }(function ($) {
|
15976 |
|
15977 |
|
15978 | jQuery.nanogallery2.data_nano_photos_provider2 = function (instance, fnName){
|
15979 | var G = instance;
|
15980 |
|
15981 |
|
15982 | var AlbumGetContent = function(albumID, fnToCall, fnParam1, fnParam2) {
|
15983 |
|
15984 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
15985 |
|
15986 |
|
15987 | if( instance.I[albumIdx].title == '' ) {
|
15988 | instance.I[albumIdx].title = JsonConvertCharset(albumID);
|
15989 | }
|
15990 |
|
15991 |
|
15992 | var url = G.O.dataProvider + '?albumID='+albumID;
|
15993 |
|
15994 |
|
15995 | url += '&hxs=' + G.tn.settings.getH(G.GOM.curNavLevel, 'xs');
|
15996 | url += '&wxs=' + G.tn.settings.getW(G.GOM.curNavLevel, 'xs');
|
15997 | url += '&hsm=' + G.tn.settings.getH(G.GOM.curNavLevel, 'sm');
|
15998 | url += '&wsm=' + G.tn.settings.getW(G.GOM.curNavLevel, 'sm');
|
15999 | url += '&hme=' + G.tn.settings.getH(G.GOM.curNavLevel, 'me');
|
16000 | url += '&wme=' + G.tn.settings.getW(G.GOM.curNavLevel, 'me');
|
16001 | url += '&hla=' + G.tn.settings.getH(G.GOM.curNavLevel, 'la');
|
16002 | url += '&wla=' + G.tn.settings.getW(G.GOM.curNavLevel, 'la');
|
16003 | url += '&hxl=' + G.tn.settings.getH(G.GOM.curNavLevel, 'xl');
|
16004 | url += '&wxl=' + G.tn.settings.getW(G.GOM.curNavLevel, 'xl');
|
16005 |
|
16006 |
|
16007 |
|
16008 |
|
16009 |
|
16010 |
|
16011 |
|
16012 |
|
16013 |
|
16014 |
|
16015 |
|
16016 | PreloaderDisplay( true );
|
16017 |
|
16018 | jQuery.ajaxSetup({ cache: false });
|
16019 | jQuery.support.cors = true;
|
16020 | try {
|
16021 |
|
16022 | var tId = setTimeout( function() {
|
16023 |
|
16024 | PreloaderDisplay(false);
|
16025 | NanoAlert(G, 'Could not retrieve nanoPhotosProvider2 data (timeout).');
|
16026 | }, 60000 );
|
16027 |
|
16028 | if( G.O.debugMode ) { console.log('nanoPhotosProvider2 URL: ' + url); }
|
16029 |
|
16030 | jQuery.getJSON(url, function(data, status, xhr) {
|
16031 | clearTimeout( tId );
|
16032 | PreloaderDisplay( false );
|
16033 | JsonParseData(albumIdx, data);
|
16034 |
|
16035 | if( data.nano_status == 'ok' ) {
|
16036 | AlbumPostProcess( albumID );
|
16037 | if( fnToCall !== null && fnToCall !== undefined) {
|
16038 | fnToCall( fnParam1, fnParam2, null );
|
16039 | }
|
16040 | }
|
16041 | else {
|
16042 | NanoAlert(G, 'Could not retrieve nanoPhotosProvider2 data. Error: ' + data.nano_status + ' - ' + data.nano_message);
|
16043 | }
|
16044 | })
|
16045 | .fail( function(jqxhr, textStatus, error) {
|
16046 | clearTimeout( tId );
|
16047 | PreloaderDisplay( false );
|
16048 |
|
16049 | var k=''
|
16050 | for(var key in jqxhr) {
|
16051 | k+= key + '=' + jqxhr[key] +'<br>';
|
16052 | }
|
16053 | var err = textStatus + ', ' + error + ' ' + k + '<br><br>URL:'+url;
|
16054 | NanoAlert(G, 'Could not retrieve nanoPhotosProvider2 data. Error: ' + err);
|
16055 |
|
16056 | });
|
16057 |
|
16058 | }
|
16059 | catch(e) {
|
16060 | NanoAlert(G, 'Could not retrieve nanoPhotosProvider2 data. Error: ' + e);
|
16061 | }
|
16062 | }
|
16063 |
|
16064 |
|
16065 | function JsonConvertCharset( str ) {
|
16066 |
|
16067 | return decodeURIComponent(str);
|
16068 |
|
16069 |
|
16070 |
|
16071 |
|
16072 |
|
16073 |
|
16074 |
|
16075 |
|
16076 |
|
16077 |
|
16078 |
|
16079 |
|
16080 |
|
16081 | }
|
16082 |
|
16083 | function JsonParseData(albumIdx, data) {
|
16084 | if( G.O.debugMode ) {
|
16085 | console.log('nanoPhotosProvider2 parse data:');
|
16086 | console.dir(data);
|
16087 | }
|
16088 |
|
16089 |
|
16090 | var foundAlbumID = false;
|
16091 | var nb = 0;
|
16092 |
|
16093 |
|
16094 | jQuery.each( data.album_content, function( i, item ){
|
16095 |
|
16096 |
|
16097 | var baseURL = G.O.dataProvider.substring(0, G.O.dataProvider.indexOf('nano_photos_provider2.php'));
|
16098 |
|
16099 |
|
16100 | var src = baseURL + JsonConvertCharset( item.src );
|
16101 |
|
16102 |
|
16103 | var title = item.title;
|
16104 |
|
16105 |
|
16106 | var description = item.description.split('_').join(' ');
|
16107 |
|
16108 |
|
16109 | var kind = 'image';
|
16110 | if( item.kind !== undefined && item.kind.length > 0 ) {
|
16111 | kind = item.kind;
|
16112 | }
|
16113 |
|
16114 |
|
16115 | var ID=item.ID;
|
16116 |
|
16117 | var filterAlbum = false;
|
16118 | if( kind == 'album' ) {
|
16119 |
|
16120 | if( !FilterAlbumName(title, ID) ) { filterAlbum = true; }
|
16121 |
|
16122 | if( G.O.album != '' || G.O.photoset != '' ) { filterAlbum = true; }
|
16123 | }
|
16124 |
|
16125 |
|
16126 | if( kind == 'image' || !filterAlbum ) {
|
16127 |
|
16128 | var albumID = 0;
|
16129 | if( item.albumID !== undefined ) {
|
16130 | albumID = item.albumID;
|
16131 | foundAlbumID = true;
|
16132 | }
|
16133 |
|
16134 | var tags = (item.tags === undefined) ? '' : item.tags;
|
16135 | var newItem = NGY2Item.New( G, title.split('_').join(' ') , description, ID, albumID, kind, tags );
|
16136 | newItem.setMediaURL( src, 'img');
|
16137 |
|
16138 |
|
16139 | if( item.dcGIF !== undefined ) {
|
16140 | newItem.imageDominantColors = 'data:image/gif;base64,' + item.dcGIF;
|
16141 | }
|
16142 |
|
16143 | if( item.dc !== undefined && item.dc !== '' ) {
|
16144 | newItem.imageDominantColor = item.dc;
|
16145 | }
|
16146 |
|
16147 | if( kind == 'album' ) {
|
16148 |
|
16149 | newItem.numberItems = item.cnt;
|
16150 | }
|
16151 | else {
|
16152 |
|
16153 | newItem.imageWidth = item.imgWidth;
|
16154 | newItem.imageHeight = item.imgHeight;
|
16155 | }
|
16156 |
|
16157 |
|
16158 | if( item.originalURL != '' ) {
|
16159 | newItem.downloadURL = baseURL+JsonConvertCharset(item.originalURL);
|
16160 | }
|
16161 |
|
16162 |
|
16163 | var cnl = G.GOM.curNavLevel;
|
16164 | var l=['xs', 'sm', 'me', 'la', 'xl'];
|
16165 | for( var n = 0; n < l.length; n++ ) {
|
16166 | newItem.thumbs.url[cnl][l[n]] = baseURL + JsonConvertCharset(item.t_url[n]);
|
16167 | newItem.thumbs.width[cnl][l[n]] = parseInt(item.t_width[n]);
|
16168 | newItem.thumbs.height[cnl][l[n]] = parseInt(item.t_height[n]);
|
16169 | }
|
16170 |
|
16171 |
|
16172 | var fu = G.O.fnProcessData;
|
16173 | if( fu !== null ) {
|
16174 | typeof fu == 'function' ? fu(newItem, G.O.dataProvider, data) : window[fu](newItem, G.O.dataProvider, data);
|
16175 | }
|
16176 |
|
16177 | }
|
16178 | });
|
16179 |
|
16180 | G.I[albumIdx].contentIsLoaded = true;
|
16181 | }
|
16182 |
|
16183 |
|
16184 |
|
16185 |
|
16186 | function Init() {
|
16187 |
|
16188 | }
|
16189 |
|
16190 |
|
16191 |
|
16192 | var PreloaderDisplay = NGY2Tools.PreloaderDisplay.bind(G);
|
16193 |
|
16194 | var NanoAlert = NGY2Tools.NanoAlert;
|
16195 |
|
16196 | var FilterAlbumName = NGY2Tools.FilterAlbumName.bind(G);
|
16197 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
16198 |
|
16199 | switch( fnName ){
|
16200 | case 'GetHiddenAlbums':
|
16201 | break;
|
16202 | case 'AlbumGetContent':
|
16203 | var albumID = arguments[2],
|
16204 | callback = arguments[3],
|
16205 | cbParam1 = arguments[4],
|
16206 | cbParam2 = arguments[5];
|
16207 | AlbumGetContent(albumID, callback, cbParam1, cbParam2);
|
16208 | break;
|
16209 | case 'Init':
|
16210 | Init();
|
16211 | break;
|
16212 | case '':
|
16213 | break;
|
16214 | }
|
16215 |
|
16216 | };
|
16217 |
|
16218 |
|
16219 |
|
16220 | }));
|
16221 |
|
16222 |
|
16223 |
|
16224 |
|
16225 |
|
16226 |
|
16227 |
|
16228 |
|
16229 |
|
16230 |
|
16231 |
|
16232 |
|
16233 |
|
16234 |
|
16235 |
|
16236 |
|
16237 |
|
16238 |
|
16239 |
|
16240 | (function (factory) {
|
16241 | "use strict";
|
16242 | if (typeof define === 'function' && define.amd) {
|
16243 |
|
16244 | define(['jquery', 'nanogallery2'], factory);
|
16245 | } else if (typeof exports === 'object' && typeof require === 'function') {
|
16246 |
|
16247 | factory(require(['jquery', 'nanogallery2']));
|
16248 | } else {
|
16249 |
|
16250 | factory(jQuery);
|
16251 | }
|
16252 | }(function ($) {
|
16253 |
|
16254 |
|
16255 | jQuery.nanogallery2.data_google2 = function (instance, fnName){
|
16256 | var G=instance;
|
16257 |
|
16258 |
|
16259 |
|
16260 | var AlbumGetContent = function(albumID, fnToCall, fnParam1, fnParam2) {
|
16261 |
|
16262 | var url = '';
|
16263 | var kind = 'image';
|
16264 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
16265 |
|
16266 | var maxResults='';
|
16267 | if( G.galleryMaxItems.Get() > 0 ) {
|
16268 | maxResults = '&max-results=' + G.galleryMaxItems.Get();
|
16269 | }
|
16270 |
|
16271 | var gat='';
|
16272 | if( typeof ngy2_pwa_at !== 'undefined' ) {
|
16273 | gat=ngy2_pwa_at;
|
16274 | }
|
16275 |
|
16276 | if( albumID == 0 ) {
|
16277 |
|
16278 | if( gat != '' ) {
|
16279 |
|
16280 |
|
16281 | url = 'https://photoslibrary.googleapis.com/v1/albums';
|
16282 | }
|
16283 | else {
|
16284 |
|
16285 |
|
16286 | url = G.O.google2URL + '?nguserid=' + G.O.userID + '&alt=json&v=3&kind=album' + maxResults + '&rnd=' + (new Date().getTime());
|
16287 | }
|
16288 | kind='album';
|
16289 |
|
16290 | }
|
16291 | else {
|
16292 |
|
16293 | if( gat != '' ) {
|
16294 |
|
16295 |
|
16296 |
|
16297 | url = 'https://photoslibrary.googleapis.com/v1/mediaItems:search';
|
16298 | }
|
16299 | else {
|
16300 |
|
16301 |
|
16302 | url = G.O.google2URL + '?nguserid=' + G.O.userID + '&ngalbumid=' + albumID + '&alt=json&v=3&kind=photo&' + maxResults;
|
16303 | }
|
16304 | }
|
16305 |
|
16306 | if( G.O.debugMode ) { console.log('Google Photos URL: ' + url); }
|
16307 |
|
16308 | PreloaderDisplay(true);
|
16309 | jQuery.ajaxSetup({ cache: false });
|
16310 | jQuery.support.cors = true;
|
16311 | try {
|
16312 | var tId = setTimeout( function() {
|
16313 |
|
16314 | PreloaderDisplay(false);
|
16315 | NanoAlert('Could not retrieve AJAX data...');
|
16316 | }, 60000 );
|
16317 |
|
16318 | jQuery.getJSON( url + '&callback=?', function(data) {
|
16319 |
|
16320 | if( data.nano_status == 'error' ) {
|
16321 | clearTimeout(tId);
|
16322 | PreloaderDisplay(false);
|
16323 | NanoAlert(G, "Could not retrieve Google data. Error: " + data.nano_message);
|
16324 | return;
|
16325 | }
|
16326 | clearTimeout(tId);
|
16327 | PreloaderDisplay(false);
|
16328 | GoogleParseData( albumIdx, kind, data );
|
16329 | AlbumPostProcess(albumID);
|
16330 | if( fnToCall !== null && fnToCall !== undefined) {
|
16331 | fnToCall( fnParam1, fnParam2, null );
|
16332 | }
|
16333 |
|
16334 | })
|
16335 | .fail( function(jqxhr, textStatus, error) {
|
16336 | clearTimeout(tId);
|
16337 | PreloaderDisplay(false);
|
16338 |
|
16339 | var k=''
|
16340 | for(var key in jqxhr) {
|
16341 | k+= key + '=' + jqxhr[key] +'<br>';
|
16342 | }
|
16343 | var err = textStatus + ', ' + error + ' ' + k + '<br><br>URL:'+url;
|
16344 | NanoAlert(G, "Could not retrieve Google data. Error: " + err);
|
16345 | });
|
16346 | }
|
16347 | catch(e) {
|
16348 | NanoAlert(G, "Could not retrieve Google data. Error: " + e);
|
16349 | }
|
16350 | }
|
16351 |
|
16352 |
|
16353 |
|
16354 |
|
16355 |
|
16356 | function GoogleParseData(albumIdx, kind, data) {
|
16357 |
|
16358 | if( G.O.debugMode ) {
|
16359 | console.log('Google Photos data:');
|
16360 | console.dir(data);
|
16361 | }
|
16362 | var albumID = G.I[albumIdx].GetID();
|
16363 |
|
16364 |
|
16365 | jQuery.each(data, function(i,data){
|
16366 |
|
16367 | if( typeof data === 'object' && data !== null ) {
|
16368 |
|
16369 | var itemDescription = '';
|
16370 | var itemTitle = '';
|
16371 | if( kind == 'image') {
|
16372 | if (data.description !== undefined ){
|
16373 | itemDescription = data.description
|
16374 | }
|
16375 | if( G.O.thumbnailLabel.get('title') != '' ) {
|
16376 | itemTitle = GetImageTitleFromURL( data.filename );
|
16377 | }
|
16378 | }
|
16379 | else {
|
16380 | itemTitle = data.title;
|
16381 | }
|
16382 | if( itemTitle == undefined ) {
|
16383 |
|
16384 | itemTitle = '';
|
16385 | }
|
16386 |
|
16387 | var itemID = data.id;
|
16388 | if( kind == 'album' ) {
|
16389 | if( !FilterAlbumName(itemTitle, itemID) || data.coverPhotoBaseUrl == undefined ) {
|
16390 | return true;
|
16391 | }
|
16392 | }
|
16393 |
|
16394 |
|
16395 | var newItem = NGY2Item.New( G, itemTitle, itemDescription, itemID, albumID, kind, '' );
|
16396 |
|
16397 | var width = 0;
|
16398 | var height = 0;
|
16399 |
|
16400 |
|
16401 | var src = '';
|
16402 | if( kind == 'image' ) {
|
16403 | src = data.baseUrl;
|
16404 | if( !G.O.viewerZoom && G.O.viewerZoom != undefined ) {
|
16405 | if( window.screen.width > window.screen.height ) {
|
16406 | src += '=w' + window.screen.width;
|
16407 | }
|
16408 | else {
|
16409 | src = s + '=h' + window.screen.height;
|
16410 | }
|
16411 | }
|
16412 | else {
|
16413 |
|
16414 | src += '=h' + data.mediaMetadata.height + '-w' + data.mediaMetadata.width;
|
16415 |
|
16416 |
|
16417 |
|
16418 | }
|
16419 |
|
16420 |
|
16421 | newItem.setMediaURL( src, 'img');
|
16422 |
|
16423 |
|
16424 | if( data.mediaMetadata.width !== undefined ) {
|
16425 | newItem.imageWidth = parseInt(data.mediaMetadata.width);
|
16426 | width = newItem.imageWidth;
|
16427 | }
|
16428 | if( data.mediaMetadata.height !== undefined ) {
|
16429 | newItem.imageHeight=parseInt(data.mediaMetadata.height);
|
16430 | height = newItem.imageHeight;
|
16431 | }
|
16432 |
|
16433 |
|
16434 |
|
16435 |
|
16436 |
|
16437 |
|
16438 | if( data.mediaMetadata.photo !== undefined ) {
|
16439 |
|
16440 | if( data.mediaMetadata.photo.exposureTime != undefined ) {
|
16441 | newItem.exif.exposure = data.mediaMetadata.photo.exposureTime;
|
16442 | }
|
16443 | if( data.mediaMetadata.photo.focalLength != undefined ) {
|
16444 | newItem.exif.focallength = data.mediaMetadata.photo.focalLength;
|
16445 | }
|
16446 | if( data.mediaMetadata.photo.apertureFNumber != undefined ) {
|
16447 | newItem.exif.fstop = data.mediaMetadata.photo.apertureFNumber;
|
16448 | }
|
16449 | if( data.mediaMetadata.photo.isoEquivalent != undefined ) {
|
16450 | newItem.exif.iso = data.mediaMetadata.photo.isoEquivalent;
|
16451 | }
|
16452 | if( data.mediaMetadata.photo.cameraModel != undefined ) {
|
16453 | newItem.exif.model = data.mediaMetadata.photo.cameraModel;
|
16454 | }
|
16455 | }
|
16456 |
|
16457 |
|
16458 | if( data.mediaMetadata.video !== undefined ) {
|
16459 | if( data.mediaMetadata.video.cameraModel != undefined ) {
|
16460 | newItem.exif.model = data.mediaMetadata.video.cameraModel;
|
16461 | }
|
16462 |
|
16463 | newItem.downloadURL = data.baseUrl + '=dv';
|
16464 |
|
16465 |
|
16466 |
|
16467 | }
|
16468 |
|
16469 | }
|
16470 | else {
|
16471 |
|
16472 | newItem.numberItems = data.mediaItemsCount;
|
16473 | }
|
16474 |
|
16475 |
|
16476 | newItem.thumbs=GoogleThumbSetSizes2('l1', newItem.thumbs, data, kind, height, width );
|
16477 | newItem.thumbs=GoogleThumbSetSizes2('lN', newItem.thumbs, data, kind,height ,width );
|
16478 |
|
16479 |
|
16480 | var fu = G.O.fnProcessData;
|
16481 | if( fu !== null ) {
|
16482 | typeof fu == 'function' ? fu(newItem, 'google2', data) : window[fu](newItem, 'google2', data);
|
16483 | }
|
16484 |
|
16485 | }
|
16486 | });
|
16487 |
|
16488 | G.I[albumIdx].contentIsLoaded = true;
|
16489 | }
|
16490 |
|
16491 |
|
16492 |
|
16493 | function GoogleThumbSetSizes2(level, tn, data, kind, height, width ) {
|
16494 | var sizes=['xs','sm','me','la','xl'];
|
16495 |
|
16496 | for(var i=0; i<sizes.length; i++ ) {
|
16497 |
|
16498 |
|
16499 | if( kind == 'image' ) {
|
16500 | if( G.tn.settings.width[level][sizes[i]] == 'auto' ) {
|
16501 | let ratio1 = width / height;
|
16502 | tn.height[level][sizes[i]] = G.tn.settings.getH(level, sizes[i]);
|
16503 | tn.width[level][sizes[i]] = G.tn.settings.getH(level, sizes[i]) * ratio1;
|
16504 | tn.url[level][sizes[i]] = data.baseUrl + '=h' + G.tn.settings.getH(level, sizes[i]);
|
16505 | continue;
|
16506 | }
|
16507 | if( G.tn.settings.height[level][sizes[i]] == 'auto' ) {
|
16508 | let ratio1 = height / width;
|
16509 | tn.width[level][sizes[i]] = G.tn.settings.getW(level, sizes[i]);
|
16510 | tn.height[level][sizes[i]] = G.tn.settings.getW(level, sizes[i]) * ratio1;
|
16511 | tn.url[level][sizes[i]] = data.baseUrl + '=w' + G.tn.settings.getW(level, sizes[i]);
|
16512 | continue;
|
16513 | }
|
16514 |
|
16515 | tn.height[level][sizes[i]] = G.tn.settings.getH(level, sizes[i]);
|
16516 | tn.width[level][sizes[i]] = G.tn.settings.getW(level, sizes[i]);
|
16517 | tn.url[level][sizes[i]] = data.baseUrl + '=w' + G.tn.settings.getW(level, sizes[i]);
|
16518 |
|
16519 | }
|
16520 |
|
16521 |
|
16522 | if( kind == 'album' ) {
|
16523 | if( G.tn.settings.width[level][sizes[i]] == 'auto' ) {
|
16524 | tn.url[level][sizes[i]]= data.coverPhotoBaseUrl + '=h' + G.tn.settings.getH(level, sizes[i]);
|
16525 | continue;
|
16526 | }
|
16527 | if( G.tn.settings.height[level][sizes[i]] == 'auto' ) {
|
16528 | tn.url[level][sizes[i]]= data.coverPhotoBaseUrl + '=w' + G.tn.settings.getW(level, sizes[i]);
|
16529 | continue;
|
16530 | }
|
16531 |
|
16532 | tn.url[level][sizes[i]]= data.coverPhotoBaseUrl + '=h' + G.tn.settings.getH(level, sizes[i]) + '-w' + G.tn.settings.getW(level, sizes[i]);
|
16533 |
|
16534 | }
|
16535 | }
|
16536 |
|
16537 | return tn;
|
16538 | }
|
16539 |
|
16540 |
|
16541 |
|
16542 |
|
16543 |
|
16544 | function Init() {
|
16545 | }
|
16546 |
|
16547 |
|
16548 |
|
16549 | var PreloaderDisplay = NGY2Tools.PreloaderDisplay.bind(G);
|
16550 |
|
16551 | var NanoAlert = NGY2Tools.NanoAlert;
|
16552 | var GetImageTitleFromURL = NGY2Tools.GetImageTitleFromURL.bind(G);
|
16553 | var FilterAlbumName = NGY2Tools.FilterAlbumName.bind(G);
|
16554 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
16555 |
|
16556 | switch( fnName ){
|
16557 | case 'AlbumGetContent':
|
16558 | var albumID = arguments[2],
|
16559 | callback2 = arguments[3],
|
16560 | cbParam1 = arguments[4],
|
16561 | cbParam2 = arguments[5];
|
16562 | AlbumGetContent(albumID, callback2, cbParam1, cbParam2);
|
16563 | break;
|
16564 | case 'Init':
|
16565 | Init();
|
16566 | break;
|
16567 | case '':
|
16568 | break;
|
16569 | }
|
16570 |
|
16571 | };
|
16572 |
|
16573 |
|
16574 |
|
16575 | }));
|
16576 |
|
16577 |
|
16578 |
|
16579 |
|
16580 |
|
16581 |
|
16582 |
|
16583 |
|
16584 |
|
16585 |
|
16586 |
|
16587 |
|
16588 |
|
16589 |
|
16590 |
|
16591 |
|
16592 |
|
16593 |
|
16594 | (function (factory) {
|
16595 | "use strict";
|
16596 | if (typeof define === 'function' && define.amd) {
|
16597 |
|
16598 | define(['jquery', 'nanogallery2'], factory);
|
16599 | } else if (typeof exports === 'object' && typeof require === 'function') {
|
16600 |
|
16601 | factory(require(['jquery', 'nanogallery2']));
|
16602 | } else {
|
16603 |
|
16604 | factory(jQuery);
|
16605 | }
|
16606 | }(function ($) {
|
16607 |
|
16608 |
|
16609 | jQuery.nanogallery2.data_flickr = function (instance, fnName){
|
16610 | var G = instance;
|
16611 |
|
16612 |
|
16613 |
|
16614 | var Flickr = {
|
16615 | url: function() {
|
16616 |
|
16617 | return 'https://api.flickr.com/services/rest/';
|
16618 | },
|
16619 | thumbSize:' sq',
|
16620 | thumbAvailableSizes : new Array(75, 100, 150, 240, 500, 640),
|
16621 | thumbAvailableSizesStr : new Array('sq', 't', 'q', 's', 'm', 'z'),
|
16622 | photoSize : '0',
|
16623 | photoAvailableSizes : new Array(75, 100, 150, 240, 500, 640, 1024, 1024, 1600, 2048, 10000),
|
16624 | photoAvailableSizesStr : new Array('sq', 't', 'q', 's', 'm', 'z', 'b', 'l', 'h', 'k', 'o')
|
16625 | };
|
16626 |
|
16627 |
|
16628 |
|
16629 | var AlbumGetContent = function(albumID, fnToCall, fnParam1, fnParam2) {
|
16630 | if( G.O.flickrAPIKey == '' ) {
|
16631 | NanoAlert(G, 'Please set your Flickr API Key (option flickrAPIKey)');
|
16632 | }
|
16633 |
|
16634 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
16635 | var url = '';
|
16636 | var kind = 'image';
|
16637 |
|
16638 | if( G.O.photoset.toUpperCase() == 'NONE' || G.O.album.toUpperCase() == 'NONE' ) {
|
16639 |
|
16640 | 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";
|
16641 | }
|
16642 | else
|
16643 | if( G.I[albumIdx].GetID() == 0 ) {
|
16644 |
|
16645 | 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";
|
16646 | kind='album';
|
16647 | }
|
16648 | else {
|
16649 |
|
16650 | 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";
|
16651 | }
|
16652 |
|
16653 | if( G.O.debugMode ) { console.log('Flickr URL: ' + url); }
|
16654 |
|
16655 | PreloaderDisplay(true);
|
16656 | jQuery.ajaxSetup({ cache: false });
|
16657 | jQuery.support.cors = true;
|
16658 |
|
16659 | var tId = setTimeout( function() {
|
16660 |
|
16661 | PreloaderDisplay(false);
|
16662 | NanoAlert(G, 'Could not retrieve AJAX data...');
|
16663 | }, 60000 );
|
16664 |
|
16665 | var sourceData=[];
|
16666 |
|
16667 |
|
16668 | var FlickrGetDone = function() {
|
16669 | clearTimeout(tId);
|
16670 | PreloaderDisplay(false);
|
16671 |
|
16672 |
|
16673 | sourceData = FilterByTags(sourceData, G.O.tagBlockList);
|
16674 |
|
16675 | if( kind == 'album' ) {
|
16676 | FlickrParsePhotoSets(albumIdx, albumID, sourceData);
|
16677 | }
|
16678 | else {
|
16679 | FlickrParsePhotos(albumIdx, albumID, sourceData);
|
16680 | }
|
16681 |
|
16682 | AlbumPostProcess( albumID );
|
16683 |
|
16684 | if( fnToCall !== null && fnToCall !== undefined) {
|
16685 | fnToCall( fnParam1, fnParam2, null );
|
16686 | }
|
16687 | }
|
16688 |
|
16689 |
|
16690 | var FlickrGetOnePage = function( url, page ) {
|
16691 | jQuery.getJSON( url + '&page=' + page + '&jsoncallback=?', function(data, status, xhr) {
|
16692 |
|
16693 | var pages=0;
|
16694 | if( kind == 'album' ) {
|
16695 | if( data.stat !== undefined && data.stat === 'fail' ) {
|
16696 | NanoAlert(G, "Could not retrieve Flickr album list: " + data.message + " (code: "+data.code+").");
|
16697 | return false;
|
16698 | }
|
16699 | sourceData=sourceData.concat(data.photosets.photoset);
|
16700 | pages=data.photosets.pages;
|
16701 | }
|
16702 | else {
|
16703 | if( G.O.photoset.toUpperCase() == 'NONE' || G.O.album.toUpperCase() == 'NONE' ) {
|
16704 |
|
16705 | sourceData=sourceData.concat(data.photos.photo);
|
16706 | pages=data.photos.pages;
|
16707 | }
|
16708 | else {
|
16709 |
|
16710 | if( data.stat !== undefined && data.stat === 'fail' ) {
|
16711 | NanoAlert(G, "Could not retrieve Flickr album: " + data.message + " (code: "+data.code+").");
|
16712 | return false;
|
16713 | }
|
16714 | if( G.I[albumIdx].title == '' ) {
|
16715 | G.I[albumIdx].title=data.photoset.title;
|
16716 | }
|
16717 | sourceData=sourceData.concat(data.photoset.photo);
|
16718 | pages=data.photoset.pages;
|
16719 | }
|
16720 |
|
16721 | }
|
16722 |
|
16723 | if( pages > page ) {
|
16724 | FlickrGetOnePage(url, page+1);
|
16725 | }
|
16726 | else {
|
16727 | FlickrGetDone();
|
16728 | }
|
16729 | })
|
16730 | .fail( function(jqxhr, textStatus, error) {
|
16731 | clearTimeout(tId);
|
16732 | PreloaderDisplay(false);
|
16733 | NanoAlert(G, "Could not retrieve Flickr ajax data: " + textStatus + ', ' + error);
|
16734 | });
|
16735 |
|
16736 | }
|
16737 |
|
16738 | FlickrGetOnePage(url, 1);
|
16739 |
|
16740 | }
|
16741 |
|
16742 |
|
16743 |
|
16744 |
|
16745 |
|
16746 | function FlickrParsePhotos( albumIdx, albumID, source ) {
|
16747 |
|
16748 | if( G.O.debugMode ) {
|
16749 | console.log('Flickr parse photos:');
|
16750 | console.dir(source);
|
16751 | }
|
16752 |
|
16753 | jQuery.each(source, function(i,item){
|
16754 |
|
16755 | var itemID = item.id;
|
16756 |
|
16757 | var imgUrl=item.url_sq;
|
16758 |
|
16759 |
|
16760 | var itemTitle = item.title;
|
16761 | if( G.O.thumbnailLabel.get('title') != '' ) {
|
16762 | itemTitle=GetImageTitleFromURL(imgUrl);
|
16763 | }
|
16764 |
|
16765 |
|
16766 | var itemDescription=item.description._content;
|
16767 |
|
16768 |
|
16769 | var imgW=75, imgH=75;
|
16770 | var start=Flickr.photoAvailableSizesStr.length-1;
|
16771 | if( G.O.flickrSkipOriginal ) { start--; }
|
16772 | for( var i = start; i>=0 ; i-- ) {
|
16773 | if( item['url_'+Flickr.photoAvailableSizesStr[i]] != undefined ) {
|
16774 | imgUrl=item['url_'+Flickr.photoAvailableSizesStr[i]];
|
16775 | imgW=parseInt(item['width_'+Flickr.photoAvailableSizesStr[i]]);
|
16776 | imgH=parseInt(item['height_'+Flickr.photoAvailableSizesStr[i]]);
|
16777 | break;
|
16778 | }
|
16779 | }
|
16780 |
|
16781 | var sizes = {};
|
16782 | for( var p in item ) {
|
16783 | if( p.indexOf('height_') == 0 || p.indexOf('width_') == 0 || p.indexOf('url_') == 0 ) {
|
16784 | sizes[p]=item[p];
|
16785 | }
|
16786 | }
|
16787 |
|
16788 |
|
16789 | var tags = item.tags !== undefined ? item.tags : '';
|
16790 |
|
16791 |
|
16792 | var newItem = NGY2Item.New( G, itemTitle, itemDescription, itemID, albumID, 'image', tags );
|
16793 |
|
16794 |
|
16795 | newItem.setMediaURL( imgUrl, 'img');
|
16796 | newItem.imageWidth = imgW;
|
16797 | newItem.imageHeight = imgH;
|
16798 |
|
16799 |
|
16800 |
|
16801 | var tn = {
|
16802 | url: { l1 : { xs:'', sm:'', me:'', la:'', xl:'' }, lN : { xs:'', sm:'', me:'', la:'', xl:'' } },
|
16803 | width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
16804 | height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } }
|
16805 | };
|
16806 | tn = FlickrRetrieveImages(tn, item, 'l1' );
|
16807 | tn = FlickrRetrieveImages(tn, item, 'lN' );
|
16808 | newItem.thumbs=tn;
|
16809 |
|
16810 |
|
16811 | var fu = G.O.fnProcessData;
|
16812 | if( fu !== null ) {
|
16813 | typeof fu == 'function' ? fu(newItem, 'flickr', item) : window[fu](newItem, 'flickr', item);
|
16814 | }
|
16815 |
|
16816 |
|
16817 | });
|
16818 | G.I[albumIdx].contentIsLoaded=true;
|
16819 |
|
16820 | }
|
16821 |
|
16822 |
|
16823 |
|
16824 |
|
16825 |
|
16826 | function FlickrParsePhotoSets( albumIdx, albumID, source ) {
|
16827 |
|
16828 | if( G.O.debugMode ) {
|
16829 | console.log('Flickr parse list of albums:');
|
16830 | console.dir(source);
|
16831 | }
|
16832 |
|
16833 | jQuery.each(source, function(i,item){
|
16834 |
|
16835 | var itemTitle = item.title._content;
|
16836 |
|
16837 | if( item.visibility_can_see_set == 0 ) { return true; }
|
16838 |
|
16839 | if( FilterAlbumName(itemTitle, item.id) ) {
|
16840 | var itemID=item.id;
|
16841 |
|
16842 | var itemDescription = item.description._content != undefined ? item.description._content : '';
|
16843 |
|
16844 | var sizes = {};
|
16845 | for( var p in item.primary_photo_extras) {
|
16846 | sizes[p] = item.primary_photo_extras[p];
|
16847 | }
|
16848 | var tags='';
|
16849 | if( item.primary_photo_extras !== undefined ) {
|
16850 | if( item.primary_photo_extras.tags !== undefined ) {
|
16851 | tags = item.primary_photo_extras.tags;
|
16852 | }
|
16853 | }
|
16854 |
|
16855 | var newItem = NGY2Item.New( G, itemTitle, itemDescription, itemID, albumID, 'album', tags );
|
16856 | newItem.numberItems = item.photos;
|
16857 | newItem.thumbSizes = sizes;
|
16858 |
|
16859 | var tn = {
|
16860 | url: { l1 : { xs:'', sm:'', me:'', la:'', xl:'' }, lN : { xs:'', sm:'', me:'', la:'', xl:'' } },
|
16861 | width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
16862 | height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } }
|
16863 | };
|
16864 | tn = FlickrRetrieveImages(tn, item.primary_photo_extras, 'l1' );
|
16865 | tn = FlickrRetrieveImages(tn, item.primary_photo_extras, 'lN' );
|
16866 | newItem.thumbs = tn;
|
16867 |
|
16868 |
|
16869 | var fu = G.O.fnProcessData;
|
16870 | if( fu !== null ) {
|
16871 | typeof fu == 'function' ? fu(newItem, 'flickr', item) : window[fu](newItem, 'flickr', item);
|
16872 | }
|
16873 |
|
16874 | }
|
16875 | });
|
16876 |
|
16877 | G.I[albumIdx].contentIsLoaded=true;
|
16878 | }
|
16879 |
|
16880 | function FlickrRetrieveImages(tn, item, level ) {
|
16881 |
|
16882 | var sf=1;
|
16883 | if( G.tn.opt[level].crop === true ) {
|
16884 | sf=G.O.thumbnailCropScaleFactor;
|
16885 | }
|
16886 |
|
16887 |
|
16888 | var sizes=['xs','sm','me','la','xl'];
|
16889 | for( var i=0; i<sizes.length; i++ ) {
|
16890 | if( G.tn.settings.width[level][sizes[i]] == 'auto' || G.tn.settings.width[level][sizes[i]] == '' ) {
|
16891 | let sdir='height_';
|
16892 | let tsize=Math.ceil( G.tn.settings.height[level][sizes[i]] * G.tn.scale * sf * G.tn.settings.mosaic[level+'Factor']['h'][sizes[i]] );
|
16893 | let one=FlickrRetrieveOneImage(sdir, tsize, item );
|
16894 | tn.url[level][sizes[i]]=one.url;
|
16895 | tn.width[level][sizes[i]]=one.width;
|
16896 | tn.height[level][sizes[i]]=one.height;
|
16897 | }
|
16898 | else
|
16899 | if( G.tn.settings.height[level][sizes[i]] == 'auto' || G.tn.settings.height[level][sizes[i]] == '' ) {
|
16900 | let sdir='width_';
|
16901 | let tsize=Math.ceil( G.tn.settings.width[level][sizes[i]] * G.tn.scale * sf * G.tn.settings.mosaic[level+'Factor']['w'][sizes[i]] );
|
16902 | let one=FlickrRetrieveOneImage(sdir, tsize, item );
|
16903 | tn.url[level][sizes[i]]=one.url;
|
16904 | tn.width[level][sizes[i]]=one.width;
|
16905 | tn.height[level][sizes[i]]=one.height;
|
16906 | }
|
16907 | else {
|
16908 | let sdir='height_';
|
16909 | let tsize=Math.ceil( G.tn.settings.height[level][sizes[i]] * G.tn.scale * sf * G.tn.settings.mosaic[level+'Factor']['h'][sizes[i]] );
|
16910 | if( G.tn.settings.width[level][sizes[i]] > G.tn.settings.height[level][sizes[i]] ) {
|
16911 | sdir='width_';
|
16912 | tsize=Math.ceil( G.tn.settings.width[level][sizes[i]] * G.tn.scale * sf * G.tn.settings.mosaic[level+'Factor']['w'][sizes[i]] );
|
16913 | }
|
16914 | let one=FlickrRetrieveOneImage(sdir, tsize, item );
|
16915 | tn.url[level][sizes[i]]=one.url;
|
16916 | tn.width[level][sizes[i]]=one.width;
|
16917 | tn.height[level][sizes[i]]=one.height;
|
16918 | }
|
16919 | }
|
16920 | return tn;
|
16921 | }
|
16922 |
|
16923 | function FlickrRetrieveOneImage(sdir, tsize, item ) {
|
16924 | var one={ url: '', width: 0, height: 0 };
|
16925 | var tnIndex=0;
|
16926 | for( var j=0; j < Flickr.thumbAvailableSizes.length; j++ ) {
|
16927 | var size=item[sdir+Flickr.photoAvailableSizesStr[j]];
|
16928 | if( size != undefined ) {
|
16929 | tnIndex=j;
|
16930 | if( size >= tsize ) {
|
16931 | break;
|
16932 | }
|
16933 | }
|
16934 | }
|
16935 | var fSize=Flickr.photoAvailableSizesStr[tnIndex];
|
16936 | one.url = item['url_'+fSize];
|
16937 | one.width = parseInt(item['width_'+fSize]);
|
16938 | one.height = parseInt(item['height_'+fSize]);
|
16939 | return one;
|
16940 | }
|
16941 |
|
16942 | var FilterByTags = function(data, tagBlockList) {
|
16943 | if( tagBlockList!= '' && data != undefined) {
|
16944 | data = data.filter(function (item) {
|
16945 | var regex = new RegExp( tagBlockList, "i");
|
16946 | var tagsToTest = [item.tags];
|
16947 | if ( Array.isArray(item.tags) ) {
|
16948 | tagsToTest = item.tags;
|
16949 | }
|
16950 | return ! tagsToTest.some( function (x) { return regex.test(x); } );
|
16951 | });
|
16952 | }
|
16953 | return data;
|
16954 | };
|
16955 |
|
16956 |
|
16957 |
|
16958 |
|
16959 |
|
16960 |
|
16961 |
|
16962 |
|
16963 |
|
16964 | function Init() {
|
16965 | return;
|
16966 | }
|
16967 |
|
16968 |
|
16969 |
|
16970 | var PreloaderDisplay = NGY2Tools.PreloaderDisplay.bind(G);
|
16971 | var NanoAlert = NGY2Tools.NanoAlert;
|
16972 | var GetImageTitleFromURL = NGY2Tools.GetImageTitleFromURL.bind(G);
|
16973 | var FilterAlbumName = NGY2Tools.FilterAlbumName.bind(G);
|
16974 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
16975 |
|
16976 | switch( fnName ){
|
16977 |
|
16978 |
|
16979 |
|
16980 |
|
16981 |
|
16982 | case 'AlbumGetContent':
|
16983 | var albumID = arguments[2],
|
16984 | callback = arguments[3],
|
16985 | cbParam1 = arguments[4],
|
16986 | cbParam2 = arguments[5];
|
16987 | AlbumGetContent(albumID, callback, cbParam1, cbParam2);
|
16988 | break;
|
16989 | case 'Init':
|
16990 | Init();
|
16991 | break;
|
16992 | case '':
|
16993 | break;
|
16994 | }
|
16995 |
|
16996 | };
|
16997 |
|
16998 |
|
16999 |
|
17000 | }));
|
17001 |
|
17002 |
|
17003 |
|