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 | function inViewport( $elt, threshold ) {
|
133 | var wp = getViewport(),
|
134 | eltOS = $elt.offset(),
|
135 | th = $elt.outerHeight(true),
|
136 | tw = $elt.outerWidth(true);
|
137 | if( eltOS.top >= (wp.t - threshold)
|
138 | && (eltOS.top + th) <= (wp.t + wp.h + threshold)
|
139 | && eltOS.left >= (wp.l - threshold)
|
140 | && (eltOS.left + tw) <= (wp.l + wp.w + threshold) ) {
|
141 | return true;
|
142 | }
|
143 | else {
|
144 | return false;
|
145 | }
|
146 | }
|
147 |
|
148 |
|
149 | function inViewportVert( $elt, threshold ) {
|
150 | var wp = getViewport(),
|
151 | eltOS = $elt.offset(),
|
152 | th = $elt.outerHeight(true);
|
153 |
|
154 |
|
155 | if( wp.t == 0 && (eltOS.top) <= (wp.t + wp.h ) ) { return true; }
|
156 |
|
157 | if( eltOS.top >= (wp.t)
|
158 | && (eltOS.top + th) <= (wp.t + wp.h - threshold) ) {
|
159 | return true;
|
160 | }
|
161 | else {
|
162 | return false;
|
163 | }
|
164 | }
|
165 |
|
166 |
|
167 |
|
168 | function set2ElementsOnTop( start, elt1, elt2 ) {
|
169 | var highest_index = 0;
|
170 | if( start=='' ) { start= '*'; }
|
171 | jQuery(start).each(function() {
|
172 | var cur = parseInt(jQuery(this).css('z-index'));
|
173 | highest_index = cur > highest_index ? cur : highest_index;
|
174 | });
|
175 | highest_index++;
|
176 | jQuery(elt2).css('z-index',highest_index+1);
|
177 | jQuery(elt1).css('z-index',highest_index);
|
178 | }
|
179 |
|
180 |
|
181 | function setElementOnTop( start, elt ) {
|
182 | var highest_index = 0;
|
183 | if( start == '' ) { start = '*'; }
|
184 | jQuery(start).each(function() {
|
185 | var cur = parseInt(jQuery(this).css('z-index'));
|
186 | highest_index = cur > highest_index ? cur : highest_index;
|
187 | });
|
188 | highest_index++;
|
189 | jQuery(elt).css('z-index',highest_index);
|
190 | }
|
191 |
|
192 |
|
193 | var toType = function( obj ) {
|
194 |
|
195 | return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
|
196 | };
|
197 |
|
198 |
|
199 | $.nanogallery2 = function (elt, options) {
|
200 |
|
201 |
|
202 | var _this = this;
|
203 |
|
204 |
|
205 | _this.$e = jQuery(elt);
|
206 | _this.e = elt;
|
207 |
|
208 |
|
209 | _this.$e.data('nanogallery2data', _this);
|
210 |
|
211 | _this.init = function () {
|
212 |
|
213 |
|
214 | if (typeof window.NGY2Item === 'undefined') {
|
215 |
|
216 | window.NGY2Tools = (function () {
|
217 |
|
218 | function NGY2Tools() {
|
219 | var nextId = 1;
|
220 | }
|
221 |
|
222 |
|
223 | NGY2Tools.FilterAlbumName = function( title, ID ) {
|
224 | var s = title.toUpperCase();
|
225 | if( this.albumList.length > 0 ) {
|
226 | for( var j=0; j < this.albumList.length; j++) {
|
227 | if( s === this.albumList[j].toUpperCase() || ID === this.albumList[j] ) {
|
228 | return true;
|
229 | }
|
230 | }
|
231 | }
|
232 | else {
|
233 | var found = false;
|
234 | if( this.whiteList !== null ) {
|
235 |
|
236 | for( var j = 0; j < this.whiteList.length; j++) {
|
237 | if( s.indexOf(this.whiteList[j]) !== -1 ) {
|
238 | found = true;
|
239 | }
|
240 | }
|
241 | if( !found ) { return false; }
|
242 | }
|
243 |
|
244 |
|
245 | if( this.blackList !== null ) {
|
246 |
|
247 | for( var j = 0; j < this.blackList.length; j++) {
|
248 | if( s.indexOf(this.blackList[j]) !== -1 ) {
|
249 | return false;
|
250 | }
|
251 | }
|
252 | }
|
253 | return true;
|
254 | }
|
255 | };
|
256 |
|
257 |
|
258 |
|
259 |
|
260 | NGY2Tools.NanoAlert = function(context, msg, verbose) {
|
261 | NGY2Tools.NanoConsoleLog.call(context, msg);
|
262 | if( context.$E.conConsole != null ) {
|
263 | context.$E.conConsole.css({visibility: 'visible', minHeight: '100px'});
|
264 | if( verbose == false ) {
|
265 | context.$E.conConsole.append('<p>' + msg + '</p>');
|
266 | }
|
267 | else {
|
268 | context.$E.conConsole.append('<p>nanogallery2: '+ msg + ' [' + context.baseEltID + ']</p>');
|
269 | }
|
270 | }
|
271 | };
|
272 |
|
273 |
|
274 |
|
275 |
|
276 | NGY2Tools.NanoConsoleLog = function(context, msg) {
|
277 | if (window.console) { console.log('nanogallery2: ' + msg + ' [' + context.baseEltID + ']'); }
|
278 | };
|
279 |
|
280 |
|
281 |
|
282 |
|
283 | NGY2Tools.PreloaderDisplay = function(display) {
|
284 | if( display === true ) {
|
285 | this.$E.conLoadingB.removeClass('nanoGalleryLBarOff').addClass('nanoGalleryLBar');
|
286 | }
|
287 | else {
|
288 | this.$E.conLoadingB.removeClass('nanoGalleryLBar').addClass('nanoGalleryLBarOff');
|
289 | }
|
290 | };
|
291 |
|
292 |
|
293 |
|
294 | NGY2Tools.AreaShuffle = function (o) {
|
295 | for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
|
296 | return o;
|
297 | };
|
298 |
|
299 |
|
300 |
|
301 | NGY2Tools.GetImageTitleFromURL = function( imageURL ) {
|
302 | if( this.O.thumbnailLabel.get('title') == '%filename' ) {
|
303 | return (imageURL.split('/').pop()).replace('_',' ');
|
304 | }
|
305 |
|
306 | if( this.O.thumbnailLabel.get('title') == '%filenameNoExt' ) {
|
307 | var s=imageURL.split('/').pop();
|
308 | return (s.split('.').shift()).replace('_',' ');
|
309 | }
|
310 |
|
311 | return '';
|
312 | };
|
313 |
|
314 |
|
315 |
|
316 |
|
317 | NGY2Tools.AlbumPostProcess = function(albumID) {
|
318 |
|
319 |
|
320 |
|
321 | var sortOrder = this.gallerySorting[this.GOM.curNavLevel];
|
322 | var maxItems = this.galleryMaxItems[this.GOM.curNavLevel];
|
323 |
|
324 | if( sortOrder != '' || maxItems > 0 ) {
|
325 |
|
326 |
|
327 | var currentAlbum = this.I.filter( function( obj ) {
|
328 | return( obj.albumID == albumID && obj.kind != 'albumUp' );
|
329 | });
|
330 |
|
331 |
|
332 | switch( sortOrder ) {
|
333 | case 'RANDOM':
|
334 | currentAlbum = NGY2Tools.AreaShuffle(currentAlbum);
|
335 | break;
|
336 | case 'REVERSED':
|
337 | currentAlbum = currentAlbum.reverse();
|
338 | break;
|
339 | case 'TITLEASC':
|
340 | currentAlbum.sort(function (a, b) {
|
341 | return( (a.title.toUpperCase() < b.title.toUpperCase()) ? -1 : ((a.title.toUpperCase() > b.title.toUpperCase()) ? 1 : 0) );
|
342 | });
|
343 | break;
|
344 | case 'TITLEDESC':
|
345 | currentAlbum.sort(function (a, b) {
|
346 | return( (a.title.toUpperCase() > b.title.toUpperCase()) ? -1 : ((a.title.toUpperCase() < b.title.toUpperCase()) ? 1 : 0) );
|
347 | });
|
348 | break;
|
349 | }
|
350 |
|
351 |
|
352 | if( maxItems > 0 && currentAlbum.length > maxItems ) {
|
353 | currentAlbum.splice(maxItems - 1, currentAlbum.length-maxItems );
|
354 | }
|
355 |
|
356 |
|
357 | this.I.removeIf( function( obj ) {
|
358 | return( obj.albumID == albumID && obj.kind != 'albumUp' );
|
359 | });
|
360 |
|
361 |
|
362 | this.I.push.apply(this.I, currentAlbum);
|
363 |
|
364 | }
|
365 | };
|
366 |
|
367 | return NGY2Tools;
|
368 | })();
|
369 |
|
370 |
|
371 |
|
372 |
|
373 | window.NGY2Item = (function() {
|
374 | var nextId = 1;
|
375 |
|
376 |
|
377 | function NGY2Item( itemID ) {
|
378 |
|
379 | var ID = 0;
|
380 |
|
381 |
|
382 | if( itemID === undefined || itemID === null ) {
|
383 | ID = nextId++;
|
384 | }
|
385 | else {
|
386 | ID = itemID;
|
387 | }
|
388 | this.GetID = function () { return ID; };
|
389 |
|
390 |
|
391 | this.kind = '';
|
392 | this.mediaKind = 'img';
|
393 | this.mediaMarkup = '';
|
394 | this.G = null;
|
395 | this.title = '';
|
396 | this.description = '';
|
397 | this.albumID = 0;
|
398 | this.src = '';
|
399 | this.width = 0;
|
400 | this.height = 0;
|
401 | this.destinationURL = '';
|
402 | this.downloadURL = '';
|
403 | this.author = '';
|
404 | this.left= 0;
|
405 | this.top= 0;
|
406 | this.width= 0;
|
407 | this.height= 0;
|
408 | this.resizedContentWidth= 0;
|
409 | this.resizedContentHeight= 0;
|
410 | this.thumbs = {
|
411 | url: { l1: { xs: '', sm:'', me: '', la: '', xl: '' }, lN: { xs: '', sm: '', me: '', la:'', xl: '' } },
|
412 | width: { l1: { xs: 0, sm: 0, me: 0, la: 0 , xl: 0 }, lN: { xs: 0 , sm: 0, me: 0, la: 0, xl: 0 } },
|
413 | height: { l1: { xs: 0, sm: 0, me: 0, la: 0 , xl: 0 }, lN: { xs: 0, sm: 0, me: 0, la: 0, xl: 0 } }
|
414 | };
|
415 | this.thumbnailImgRevealed = false;
|
416 | this.imageDominantColors = null;
|
417 | this.imageDominantColor = null;
|
418 | this.featured = false;
|
419 | this.flickrThumbSizes = {};
|
420 | this.picasaThumbs = null;
|
421 | this.hovered = false;
|
422 | this.hoverInitDone = false;
|
423 | this.contentIsLoaded = false;
|
424 | this.contentLength = 0;
|
425 | this.numberItems = 0;
|
426 | this.mediaNumber = 0;
|
427 | this.imageCounter = 0;
|
428 | this.eltTransform = [];
|
429 | this.eltFilter = [];
|
430 | this.eltEffect = [];
|
431 | this.authkey = '';
|
432 | this.paginationLastPage = 0;
|
433 | this.paginationLastWidth = 0;
|
434 | this.customData = {};
|
435 | this.selected = false;
|
436 | this.imageWidth = 0;
|
437 | this.imageHeight = 0;
|
438 | this.$elt = null;
|
439 | this.$Elts = [];
|
440 | this.tags = [];
|
441 | this.albumTagList = [];
|
442 | this.albumTagListSel = [];
|
443 | this.exif = { exposure: '', flash: '', focallength: '', fstop: '', iso: '', model: '', time: '', location: ''};
|
444 | this.deleted = false;
|
445 | this.rotationAngle = 0;
|
446 | }
|
447 |
|
448 |
|
449 |
|
450 | NGY2Item.Get = function( instance, ID ) {
|
451 | var l = instance.I.length;
|
452 | for( var i = 0; i < l; i++ ) {
|
453 | if( instance.I[i].GetID() == ID ) {
|
454 | return instance.I[i];
|
455 | }
|
456 | }
|
457 | return null;
|
458 | };
|
459 |
|
460 | NGY2Item.GetIdx = function( instance, ID ) {
|
461 | var l = instance.I.length;
|
462 | for( var i = 0; i < l; i++ ) {
|
463 | if( instance.I[i].GetID() == ID ) {
|
464 | return i;
|
465 | }
|
466 | }
|
467 | return -1;
|
468 | };
|
469 |
|
470 |
|
471 | NGY2Item.New = function( instance, title, description, ID, albumID, kind, tags ) {
|
472 | var album = NGY2Item.Get( instance, albumID );
|
473 |
|
474 | if( albumID != -1 && albumID != 0 && title !='image gallery by nanogallery2 [build]' ) {
|
475 | if( instance.O.thumbnailLevelUp && album.getContentLength(false) == 0 && instance.O.album == '' ) {
|
476 |
|
477 | var item = new NGY2Item('0');
|
478 | instance.I.push( item );
|
479 | album.contentLength += 1;
|
480 | item.title = 'UP';
|
481 | item.albumID = albumID;
|
482 | item.kind = 'albumUp';
|
483 | item.G = instance;
|
484 |
|
485 | jQuery.extend( true, item.thumbs.width, instance.tn.defaultSize.width);
|
486 | jQuery.extend( true, item.thumbs.height, instance.tn.defaultSize.height);
|
487 | }
|
488 | }
|
489 |
|
490 | var item = NGY2Item.Get(instance, ID);
|
491 | if( item === null ){
|
492 |
|
493 | item = new NGY2Item(ID);
|
494 | instance.I.push(item);
|
495 | if( albumID != -1 && title !='image gallery by nanogallery2 [build]' ) {
|
496 | album.contentLength+=1;
|
497 | }
|
498 | }
|
499 | item.G = instance;
|
500 |
|
501 | item.albumID = albumID;
|
502 | item.kind = kind;
|
503 | if( kind == 'image' ) {
|
504 | album.imageCounter += 1;
|
505 | item.mediaNumber = album.imageCounter;
|
506 | }
|
507 |
|
508 |
|
509 | var kw = instance.O.thumbnailFeaturedKeyword;
|
510 | if( kw != '' ) {
|
511 |
|
512 | kw = kw.toUpperCase();
|
513 | var p = title.toUpperCase().indexOf(kw);
|
514 | if( p > -1) {
|
515 | item.featured = true;
|
516 |
|
517 | title = title.substring(0, p) + title.substring(p+kw.length, title.length);
|
518 | }
|
519 | p = description.toUpperCase().indexOf(kw);
|
520 | if( p > -1) {
|
521 | item.featured=true;
|
522 |
|
523 | description=description.substring(0, p) + description.substring(p + kw.length, description.length);
|
524 | }
|
525 | }
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 | if( typeof instance.galleryFilterTags.Get() == 'string' ) {
|
538 | switch( instance.galleryFilterTags.Get().toUpperCase() ) {
|
539 | case 'TITLE':
|
540 | var re = /(?:^|\W)#(\w+)(?!\w)/g, match, matches = [];
|
541 | var tags = "";
|
542 | while (match = re.exec(title)) {
|
543 | matches.push(match[1].replace(/^\s*|\s*$/, ''));
|
544 | }
|
545 | item.setTags(matches);
|
546 | title = title.split('#').join('');
|
547 | break;
|
548 | case 'DESCRIPTION':
|
549 | var re = /(?:^|\W)#(\w+)(?!\w)/g, match, matches = [];
|
550 | var tags = "";
|
551 | while (match = re.exec(description)) {
|
552 | matches.push(match[1].replace(/^\s*|\s*$/, ''));
|
553 | }
|
554 | item.setTags(matches);
|
555 | description = description.split('#').join('');
|
556 | break;
|
557 | }
|
558 | }
|
559 | else {
|
560 | if( tags != '' && tags != undefined ) {
|
561 |
|
562 | item.setTags(tags.split(' '));
|
563 | }
|
564 | }
|
565 |
|
566 |
|
567 |
|
568 |
|
569 | item.title = escapeHtml(instance, title);
|
570 | item.description = escapeHtml(instance, description);
|
571 | return item;
|
572 | };
|
573 |
|
574 |
|
575 |
|
576 | NGY2Item.prototype.delete = function( ) {
|
577 | this.deleted = true;
|
578 |
|
579 |
|
580 | this.G.I[NGY2Item.GetIdx(this.G, this.albumID)].contentLength--;
|
581 | this.G.I[NGY2Item.GetIdx(this.G, this.albumID)].numberItems--;
|
582 |
|
583 |
|
584 | var nbTn = this.G.GOM.items.length;
|
585 | var ID = this.GetID();
|
586 | var foundIdx = -1;
|
587 | var foundGOMidx = -1;
|
588 | for( var i = 0; i < nbTn ; i++ ) {
|
589 | var curTn = this.G.GOM.items[i];
|
590 | var item=this.G.I[curTn.thumbnailIdx];
|
591 | if( item.GetID() == ID ) {
|
592 |
|
593 | if( !curTn.neverDisplayed ) {
|
594 | foundIdx= curTn.thumbnailIdx;
|
595 | foundGOMidx= i;
|
596 | }
|
597 | }
|
598 | else {
|
599 | if( foundIdx != -1 ) {
|
600 | if( !curTn.neverDisplayed ) {
|
601 |
|
602 | item.$getElt('.nGY2GThumbnail').data('index', i-1);
|
603 | item.$getElt('.nGY2GThumbnailImg').data('index', i-1);
|
604 | }
|
605 | }
|
606 | }
|
607 | }
|
608 | if( foundIdx != -1 ) {
|
609 |
|
610 | var G = this.G;
|
611 | if( this.selected == true ) {
|
612 | this.selected = false;
|
613 | G.GOM.nbSelected--;
|
614 | }
|
615 | if( G.I[foundIdx].$elt !== null ) {
|
616 | G.I[foundIdx].$elt.remove();
|
617 | }
|
618 | G.GOM.items.splice(foundGOMidx, 1);
|
619 | if( G.GOM.lastDisplayedIdx != -1 ) {
|
620 | G.GOM.lastDisplayedIdx-=1;
|
621 | }
|
622 | }
|
623 | }
|
624 |
|
625 | NGY2Item.prototype.addToGOM = function( ) {
|
626 |
|
627 | var ID = this.GetID();
|
628 | var l = this.G.I.length;
|
629 | for( var idx = 0; idx < l; idx++ ) {
|
630 | var item = this.G.I[idx];
|
631 | if( item.GetID() == ID ) {
|
632 | var w = item.thumbImg().width;
|
633 | var h = item.thumbImg().height;
|
634 |
|
635 | if( h == 0 ) {
|
636 | h = this.G.tn.defaultSize.getHeight();
|
637 | }
|
638 | if( w == 0 ) {
|
639 | w = this.G.tn.defaultSize.getWidth();
|
640 | }
|
641 |
|
642 | var tn = new this.G.GOM.GTn(idx, w, h);
|
643 | this.G.GOM.items.push(tn);
|
644 | break;
|
645 | }
|
646 | }
|
647 |
|
648 | }
|
649 |
|
650 |
|
651 |
|
652 |
|
653 | var entityMap = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '/': '/', '`': '`', '=': '=' };
|
654 | function escapeHtml (instance, string) {
|
655 | if( instance.O.allowHTMLinData == true ) {
|
656 | return string;
|
657 | }
|
658 | else {
|
659 | return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
|
660 | return entityMap[s];
|
661 | });
|
662 | }
|
663 | }
|
664 |
|
665 |
|
666 | NGY2Item.get_nextId = function () {
|
667 | return nextId;
|
668 | };
|
669 |
|
670 |
|
671 |
|
672 |
|
673 | NGY2Item.prototype.$getElt = function( elt, forceRefresh ) {
|
674 | if( this.$elt == null ) { return null; }
|
675 | if( this.$Elts[elt] !== undefined && !forceRefresh == true ) {
|
676 | return this.$Elts[elt];
|
677 | }
|
678 | else {
|
679 | if( elt == '.nGY2GThumbnail' ) {
|
680 | this.$Elts[elt]=this.$elt;
|
681 | }
|
682 | else {
|
683 | this.$Elts[elt]=this.$elt.find(elt);
|
684 | }
|
685 | return this.$Elts[elt];
|
686 | }
|
687 | };
|
688 |
|
689 |
|
690 | NGY2Item.prototype.removeElt = function( elt ) {
|
691 | if( this.$elt == null ) { return; }
|
692 | if( this.$Elts[elt] == undefined) { return; }
|
693 | this.$Elts[elt].remove();
|
694 | var index = this.$Elts.indexOf(elt);
|
695 | this.$Elts.splice(index, 1);
|
696 | };
|
697 |
|
698 |
|
699 | NGY2Item.prototype.album = function() {
|
700 | return this.G.I[NGY2Item.GetIdx(this.G, this.albumID)];
|
701 | };
|
702 |
|
703 |
|
704 | NGY2Item.prototype.mediaTransition = function( ) {
|
705 | if( this.G.O.viewerTransitionMediaKind.indexOf( this.mediaKind ) > -1 ) {
|
706 | return true;
|
707 | }
|
708 | return false;
|
709 | };
|
710 |
|
711 |
|
712 | NGY2Item.prototype.imageSet = function( src, w, h ) {
|
713 | this.src = src;
|
714 | this.width = w;
|
715 | this.height = h;
|
716 | };
|
717 |
|
718 |
|
719 | NGY2Item.prototype.thumbSet = function( src, w, h, screenSize, level ) {
|
720 | var lst=['xs','sm','me','la','xl'];
|
721 | if( typeof screenSize === 'undefined' || screenSize == '' || screenSize == null ) {
|
722 | for( var i=0; i< lst.length; i++ ) {
|
723 | if( typeof level === 'undefined' || level == '' ) {
|
724 | this.thumbs.url.l1[lst[i]]=src;
|
725 | this.thumbs.height.l1[lst[i]]=h;
|
726 | this.thumbs.width.l1[lst[i]]=w;
|
727 | this.thumbs.url.lN[lst[i]]=src;
|
728 | this.thumbs.height.lN[lst[i]]=h;
|
729 | this.thumbs.width.lN[lst[i]]=w;
|
730 | }
|
731 | else {
|
732 | this.thumbs.url[level][lst[i]]=src;
|
733 | this.thumbs.height[level][lst[i]]=h;
|
734 | this.thumbs.width[level][lst[i]]=w;
|
735 | }
|
736 | }
|
737 | }
|
738 | else {
|
739 | if( typeof level === 'undefined' || level == '' || level == null ) {
|
740 | this.thumbs.url.l1[screenSize]=src;
|
741 | this.thumbs.height.l1[screenSize]=h;
|
742 | this.thumbs.width.l1[screenSize]=w;
|
743 | this.thumbs.url.lN[screenSize]=src;
|
744 | this.thumbs.height.lN[screenSize]=h;
|
745 | this.thumbs.width.lN[screenSize]=w;
|
746 | }
|
747 | else {
|
748 | this.thumbs.url[level][screenSize]=src;
|
749 | this.thumbs.height[level][screenSize]=h;
|
750 | this.thumbs.width[level][screenSize]=w;
|
751 | }
|
752 | }
|
753 |
|
754 | var lst=['xs','sm','me','la','xl'];
|
755 | for( var i=0; i< lst.length; i++ ) {
|
756 | this.thumbs.height.l1[lst[i]]=h;
|
757 | }
|
758 | for( var i=0; i< lst.length; i++ ) {
|
759 | 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() ) {
|
760 | this.thumbs.height.lN[lst[i]]=h;
|
761 | }
|
762 | }
|
763 | };
|
764 |
|
765 |
|
766 | NGY2Item.prototype.thumbSetImgHeight = function( h ) {
|
767 | var lst=['xs','sm','me','la','xl'];
|
768 | for( var i=0; i< lst.length; i++ ) {
|
769 | 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() ) {
|
770 | this.thumbs.height.l1[lst[i]]=h;
|
771 | }
|
772 | }
|
773 | for( var i=0; i< lst.length; i++ ) {
|
774 | 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() ) {
|
775 | this.thumbs.height.lN[lst[i]]=h;
|
776 | }
|
777 | }
|
778 | };
|
779 |
|
780 |
|
781 | NGY2Item.prototype.thumbSetImgWidth = function( w ) {
|
782 | var lst=['xs','sm','me','la','xl'];
|
783 | for( var i=0; i< lst.length; i++ ) {
|
784 | 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() ) {
|
785 | this.thumbs.width.l1[lst[i]]=w;
|
786 | }
|
787 | }
|
788 | for( var i=0; i< lst.length; i++ ) {
|
789 | 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() ) {
|
790 | this.thumbs.width.lN[lst[i]]=w;
|
791 | }
|
792 | }
|
793 | };
|
794 |
|
795 |
|
796 | NGY2Item.prototype.thumbImg = function () {
|
797 | var tnImg = { src: '', width: 0, height: 0 };
|
798 |
|
799 | if( this.title == 'image gallery by nanogallery2 [build]' ) {
|
800 | tnImg.src = this.G.emptyGif;
|
801 | tnImg.url = this.G.emptyGif;
|
802 | return tnImg;
|
803 | }
|
804 | tnImg.src = this.thumbs.url[this.G.GOM.curNavLevel][this.G.GOM.curWidth];
|
805 | tnImg.width = this.thumbs.width[this.G.GOM.curNavLevel][this.G.GOM.curWidth];
|
806 | tnImg.height = this.thumbs.height[this.G.GOM.curNavLevel][this.G.GOM.curWidth];
|
807 | return tnImg;
|
808 | };
|
809 |
|
810 |
|
811 | NGY2Item.prototype.setTags = function( tags ) {
|
812 | if( tags.length > 0 ) {
|
813 | this.tags = tags;
|
814 | var lstTags = this.album().albumTagList;
|
815 | for( var i = 0; i < tags.length; i++ ) {
|
816 | var tfound = false;
|
817 | for( var j = 0; j < lstTags.length; j++ ) {
|
818 | if( tags[i].toUpperCase() == lstTags[j].toUpperCase() ) {
|
819 | tfound = true;
|
820 | }
|
821 | }
|
822 | if( tfound == false) {
|
823 | this.album().albumTagList.push(tags[i])
|
824 | this.album().albumTagListSel.push(tags[i])
|
825 | }
|
826 | }
|
827 | }
|
828 | };
|
829 |
|
830 |
|
831 | NGY2Item.prototype.checkTagFilter = function() {
|
832 | if( this.G.galleryFilterTags.Get() != false && this.album().albumTagList.length > 0 ) {
|
833 | if( this.G.O.thumbnailLevelUp && this.kind=='albumUp' ) {
|
834 | return true;
|
835 | }
|
836 | var found = false;
|
837 | var lstTags = this.album().albumTagListSel;
|
838 | for( var i = 0; i < this.tags.length; i++ ) {
|
839 | for( var j = 0; j < lstTags.length; j++ ) {
|
840 | if( this.tags[i].toUpperCase() == lstTags[j].toUpperCase() ) {
|
841 | found = true;
|
842 | break;
|
843 | }
|
844 | }
|
845 | }
|
846 | return found;
|
847 | }
|
848 | else
|
849 | return true;
|
850 | };
|
851 |
|
852 |
|
853 | NGY2Item.prototype.isSearchTagFound = function() {
|
854 | if( this.G.GOM.albumSearchTags == '' ) { return true; }
|
855 | if( this.G.O.thumbnailLevelUp && this.kind == 'albumUp' ) { return true; }
|
856 |
|
857 |
|
858 | for( var i = 0; i < this.tags.length; i++ ) {
|
859 | if( this.tags[i].toUpperCase().indexOf( this.G.GOM.albumSearchTags ) >= 0 ) {
|
860 | return true;
|
861 | }
|
862 | }
|
863 | return false;
|
864 | };
|
865 |
|
866 |
|
867 |
|
868 | NGY2Item.prototype.setMediaURL = function( url, mediaKind ) {
|
869 | this.src = url;
|
870 | this.mediaKind = mediaKind;
|
871 | if( mediaKind == 'img' ) {
|
872 | this.mediaMarkup = '<img class="nGY2ViewerMedia" src="' + url + '" alt=" " itemprop="contentURL" draggable="false">';
|
873 | }
|
874 | };
|
875 |
|
876 |
|
877 |
|
878 | NGY2Item.prototype.isToDisplay = function( albumID ) {
|
879 | return this.albumID == albumID && this.checkTagFilter() && this.isSearchFound() && this.isSearchTagFound() && this.deleted == false;
|
880 | };
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 | NGY2Item.prototype.getContentLength = function( filterTags ) {
|
887 | if( filterTags == false || this.albumTagList.length == 0 || this.G.galleryFilterTags.Get() == false ) {
|
888 | return this.contentLength;
|
889 | }
|
890 | else {
|
891 | var l = this.G.I.length;
|
892 | var cnt = 0;
|
893 | var albumID = this.GetID();
|
894 | for( var idx = 0; idx < l; idx++ ) {
|
895 | var item = this.G.I[idx];
|
896 | if( item.isToDisplay(albumID) ) {
|
897 | cnt++;
|
898 | }
|
899 | }
|
900 | return cnt;
|
901 | }
|
902 | };
|
903 |
|
904 | NGY2Item.prototype.isSearchFound = function() {
|
905 | if( this.G.GOM.albumSearch != '' ) {
|
906 | if( this.title.toUpperCase().indexOf( this.G.GOM.albumSearch ) == -1 ) {
|
907 | return false;
|
908 | }
|
909 | }
|
910 | return true;
|
911 | }
|
912 |
|
913 |
|
914 |
|
915 | NGY2Item.prototype.responsiveURL = function () {
|
916 | var url = '';
|
917 | switch(this.G.O.kind) {
|
918 | case '':
|
919 | url = this.src;
|
920 | break;
|
921 | case 'flickr':
|
922 | url = this.src;
|
923 | break;
|
924 | case 'picasa':
|
925 | case 'google':
|
926 | case 'google2':
|
927 | default:
|
928 | url = this.src;
|
929 | break;
|
930 | }
|
931 | return url;
|
932 | };
|
933 |
|
934 |
|
935 |
|
936 | NGY2Item.prototype.ThumbnailImageReveal = function () {
|
937 |
|
938 | if( this.thumbnailImgRevealed == false ) {
|
939 | this.thumbnailImgRevealed = true;
|
940 | new NGTweenable().tween({
|
941 | from: { opacity: 0 },
|
942 | to: { opacity: 1 },
|
943 | attachment: { item: this },
|
944 | delay: 30,
|
945 | duration: 400,
|
946 | easing: 'easeOutQuart',
|
947 | step: function (state, att) {
|
948 | var $e=att.item.$getElt('.nGY2TnImg');
|
949 | if( $e != null ) {
|
950 | $e.css( state );
|
951 | }
|
952 | }
|
953 | });
|
954 | }
|
955 | };
|
956 |
|
957 |
|
958 |
|
959 | function ValueApplyPercent( str, percent ) {
|
960 | str=String(str);
|
961 | if( str === '0' || percent == 1 ) { return str; }
|
962 | var n = Number(str.replace(/[a-zA-Z]/g, ''));
|
963 | var ar = str.match(/([^\-0-9\.]+)/g);
|
964 | var a = '';
|
965 | if( ar != null && ar.length > 0 ) {
|
966 | a = ar.join();
|
967 | }
|
968 |
|
969 | if( isNaN(n) || n == 0 ) {
|
970 | return str;
|
971 | }
|
972 |
|
973 | n = n * percent;
|
974 | return n + a;
|
975 | }
|
976 |
|
977 |
|
978 | NGY2Item.prototype.CSSTransformApply = function ( eltClass ) {
|
979 | var obj = this.eltTransform[eltClass];
|
980 |
|
981 | if( eltClass == '.nGY2GThumbnail' ) {
|
982 |
|
983 | var nbStacks = obj.$elt.length-1;
|
984 | var pTranslateX = 1;
|
985 | var pTranslateY = 1;
|
986 | var pTranslateZ = 1;
|
987 | var pTranslate = 1;
|
988 | var pRotateX = 1;
|
989 | var pRotateY = 1;
|
990 | var pRotateZ = 1;
|
991 | var pRotate = 1;
|
992 | var pScale = 1;
|
993 | for( var n = nbStacks; n >= 0; n-- ) {
|
994 |
|
995 | 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) + ')';
|
996 | if( !(this.G.IE <= 9) && !this.G.isGingerbread ) {
|
997 | v += ' rotateX(' + ValueApplyPercent(obj.rotateX,pRotateX) + ') rotateY(' + ValueApplyPercent(obj.rotateY,pRotateY) + ') rotateZ(' + ValueApplyPercent(obj.rotateZ,pRotateZ) + ') rotate(' + ValueApplyPercent(obj.rotate,pRotate) + ')';
|
998 | }
|
999 | else {
|
1000 | v += ' rotate(' + ValueApplyPercent(obj.rotateZ,pRotateZ) + ')';
|
1001 | }
|
1002 | obj.$elt[n].style[this.G.CSStransformName] = v;
|
1003 |
|
1004 | if( nbStacks > 0 ) {
|
1005 |
|
1006 | pTranslateX -= this.G.tn.opt.Get('stacksTranslateX');
|
1007 | pTranslateY -= this.G.tn.opt.Get('stacksTranslateY');
|
1008 | pTranslateZ -= this.G.tn.opt.Get('stacksTranslateZ');
|
1009 | pRotateX -= this.G.tn.opt.Get('stacksRotateX');
|
1010 | pRotateY -= this.G.tn.opt.Get('stacksRotateY');
|
1011 | pRotateZ -= this.G.tn.opt.Get('stacksRotateZ');
|
1012 | pScale -= this.G.tn.opt.Get('stacksScale');
|
1013 | }
|
1014 | }
|
1015 | }
|
1016 | else {
|
1017 |
|
1018 | if( obj.$elt != null ) {
|
1019 | for( var n = 0; n < obj.$elt.length; n++ ) {
|
1020 | if( obj.$elt[n] != undefined ) {
|
1021 |
|
1022 | var v = 'translateX(' + obj.translateX + ') translateY(' + obj.translateY + ') translateZ(' + obj.translateZ + ') scale(' + obj.scale + ') translate(' + obj.translate + ')';
|
1023 | if( !(this.G.IE <= 9) && !this.G.isGingerbread ) {
|
1024 | v += ' rotateX(' + obj.rotateX + ') rotateY(' + obj.rotateY + ') rotateZ(' + obj.rotateZ + ') rotate(' + obj.rotate + ')';
|
1025 | }
|
1026 | else {
|
1027 | v += ' rotate(' + obj.rotateZ + ')';
|
1028 | }
|
1029 | obj.$elt[n].style[this.G.CSStransformName] = v;
|
1030 | }
|
1031 | }
|
1032 | }
|
1033 | }
|
1034 | };
|
1035 |
|
1036 |
|
1037 | NGY2Item.prototype.CSSTransformSet = function ( eltClass, transform, value, forceRefresh ) {
|
1038 | if( this.eltTransform[eltClass] == undefined ) {
|
1039 | this.eltTransform[eltClass] = { translateX: 0, translateY: 0, translateZ: 0, rotateX: 0, rotateY: 0, rotateZ: 0, scale: 1, translate: '0px,0px', rotate: 0 };
|
1040 | this.eltTransform[eltClass].$elt = this.$getElt(eltClass);
|
1041 | }
|
1042 | this.eltTransform[eltClass][transform] = value;
|
1043 | if( forceRefresh === true ) {
|
1044 | this.eltTransform[eltClass].$elt = this.$getElt(eltClass, true);
|
1045 | }
|
1046 | };
|
1047 |
|
1048 |
|
1049 | NGY2Item.prototype.CSSFilterApply = function ( eltClass ) {
|
1050 | var obj = this.eltFilter[eltClass];
|
1051 | var v = 'blur(' + obj.blur + ') brightness(' + obj.brightness + ') grayscale(' + obj.grayscale + ') sepia(' + obj.sepia + ') contrast(' + obj.contrast + ') opacity(' + obj.opacity + ') saturate(' + obj.saturate + ')';
|
1052 | if( obj.$elt != null ) {
|
1053 | for( var n = 0; n < obj.$elt.length; n++ ) {
|
1054 | if( obj.$elt[n] != undefined ) {
|
1055 | obj.$elt[n].style.WebkitFilter = v;
|
1056 | obj.$elt[n].style.filter = v;
|
1057 | }
|
1058 | }
|
1059 | }
|
1060 | };
|
1061 |
|
1062 |
|
1063 | NGY2Item.prototype.CSSFilterSet = function ( eltClass, filter, value, forceRefresh ) {
|
1064 | if( this.eltFilter[eltClass] == undefined ) {
|
1065 | this.eltFilter[eltClass] = { blur: 0, brightness: '100%', grayscale: '0%', sepia: '0%', contrast: '100%', opacity: '100%', saturate: '100%' };
|
1066 | this.eltFilter[eltClass].$elt = this.$getElt(eltClass);
|
1067 | }
|
1068 | this.eltFilter[eltClass][filter] = value;
|
1069 | if( forceRefresh === true ) {
|
1070 | this.eltTransform[eltClass].$elt = this.$getElt(eltClass, true);
|
1071 | }
|
1072 | };
|
1073 |
|
1074 |
|
1075 | NGY2Item.prototype.animate = function ( effect, delay, hoverIn ) {
|
1076 | if( this.$getElt() == null ) { return; }
|
1077 |
|
1078 | var context = {};
|
1079 | context.G = this.G;
|
1080 | context.item = this;
|
1081 | context.effect = effect;
|
1082 | context.hoverIn = hoverIn;
|
1083 | context.cssKind = '';
|
1084 | if( hoverIn ) {
|
1085 |
|
1086 |
|
1087 | if( this.eltEffect[effect.element] == undefined ) {
|
1088 | this.eltEffect[effect.element] = [];
|
1089 | }
|
1090 | if( this.eltEffect[effect.element][effect.type] == undefined ) {
|
1091 | this.eltEffect[effect.element][effect.type] = { initialValue: 0, lastValue: 0 };
|
1092 | }
|
1093 | if( effect.firstKeyframe ) {
|
1094 |
|
1095 | this.eltEffect[effect.element][effect.type] = { initialValue: effect.from, lastValue: effect.from};
|
1096 | }
|
1097 |
|
1098 | context.animeFrom = effect.from;
|
1099 | context.animeTo = effect.to;
|
1100 | context.animeDuration = parseInt(effect.duration);
|
1101 | context.animeDelay = 30 + parseInt(effect.delay + delay);
|
1102 | context.animeEasing = effect.easing;
|
1103 | }
|
1104 | else {
|
1105 |
|
1106 | if( effect.firstKeyframe ) {
|
1107 | context.animeFrom = this.eltEffect[effect.element][effect.type].lastValue;
|
1108 | context.animeTo = this.eltEffect[effect.element][effect.type].initialValue;
|
1109 |
|
1110 | }
|
1111 | else {
|
1112 |
|
1113 | context.animeFrom = this.eltEffect[effect.element][effect.type].lastValue;
|
1114 | context.animeTo = this.eltEffect[effect.element][effect.type].initialValue;
|
1115 |
|
1116 |
|
1117 | }
|
1118 |
|
1119 | context.animeDuration = parseInt(effect.durationBack);
|
1120 | context.animeDelay = 30 + parseInt(effect.delayBack + delay);
|
1121 | context.animeEasing = effect.easingBack;
|
1122 | }
|
1123 |
|
1124 |
|
1125 |
|
1126 | var transform=['translateX', 'translateY', 'translateZ', 'scale', 'rotateX', 'rotateY', 'rotateZ'];
|
1127 | for( var i = 0; i < transform.length; i++ ) {
|
1128 | if( effect.type == transform[i] ) {
|
1129 | context.cssKind = 'transform';
|
1130 | break;
|
1131 | }
|
1132 | }
|
1133 |
|
1134 |
|
1135 | var filter=['blur', 'brightness', 'grayscale', 'sepia', 'contrast', 'opacity', 'saturate'];
|
1136 | for( var i = 0; i < filter.length; i++ ) {
|
1137 | if( effect.type == filter[i] ) {
|
1138 | context.cssKind = 'filter';
|
1139 | break;
|
1140 | }
|
1141 | }
|
1142 |
|
1143 | if( hoverIn && effect.element == '.nGY2GThumbnail' && ( effect.type == 'scale' || effect.type == 'rotateX') ) {
|
1144 | this.G.GOM.lastZIndex++;
|
1145 | this.$getElt(effect.element).css('z-index', this.G.GOM.lastZIndex);
|
1146 |
|
1147 | }
|
1148 |
|
1149 |
|
1150 | var tweenable = new NGTweenable();
|
1151 | context.tweenable=tweenable;
|
1152 | tweenable.tween({
|
1153 | attachment: context,
|
1154 | from: { 'v': context.animeFrom },
|
1155 | to: { 'v': context.animeTo },
|
1156 | duration: context.animeDuration,
|
1157 | delay: context.animeDelay,
|
1158 | easing: context.animeEasing,
|
1159 |
|
1160 | step: function (state, att) {
|
1161 | if( att.item.$getElt() == null ) {
|
1162 |
|
1163 | att.tweenable.stop(false);
|
1164 |
|
1165 | return;
|
1166 | }
|
1167 | if( att.hoverIn && !att.item.hovered ) {
|
1168 |
|
1169 | att.tweenable.stop(false);
|
1170 |
|
1171 | return;
|
1172 | }
|
1173 |
|
1174 | if( att.G.VOM.viewerDisplayed ) {
|
1175 | att.tweenable.stop(false);
|
1176 |
|
1177 | return;
|
1178 | }
|
1179 |
|
1180 |
|
1181 | if( state.v == att.animeFrom ) { return; }
|
1182 |
|
1183 | switch( att.cssKind ) {
|
1184 | case 'transform':
|
1185 |
|
1186 | att.item.CSSTransformSet(att.effect.element, att.effect.type, state.v);
|
1187 | att.item.CSSTransformApply( att.effect.element );
|
1188 |
|
1189 | break;
|
1190 | case 'filter':
|
1191 |
|
1192 | att.item.CSSFilterSet(att.effect.element, att.effect.type, state.v);
|
1193 | att.item.CSSFilterApply( att.effect.element );
|
1194 |
|
1195 | break;
|
1196 | default:
|
1197 | var v=state.v;
|
1198 | if( state.v.substring(0,4) == 'rgb(' || state.v.substring(0,5) == 'rgba(' ) {
|
1199 |
|
1200 |
|
1201 | v = ShadeBlendConvert(0, v);
|
1202 | }
|
1203 |
|
1204 | att.item.$getElt( att.effect.element ).css( att.effect.type, v );
|
1205 |
|
1206 | break;
|
1207 | }
|
1208 | if( hoverIn ) {
|
1209 |
|
1210 | att.item.eltEffect[att.effect.element][att.effect.type].lastValue = state.v;
|
1211 | }
|
1212 | },
|
1213 |
|
1214 | finish: function (state, att) {
|
1215 | if( hoverIn ) {
|
1216 |
|
1217 | att.item.eltEffect[att.effect.element][att.effect.type].lastValue = state.v;
|
1218 | }
|
1219 |
|
1220 | if( att.item.$getElt() == null ) {
|
1221 |
|
1222 | return;
|
1223 | }
|
1224 | if( att.hoverIn && !att.item.hovered ) {
|
1225 |
|
1226 | return;
|
1227 | }
|
1228 |
|
1229 | if( att.G.VOM.viewerDisplayed ) {
|
1230 | return;
|
1231 | }
|
1232 |
|
1233 |
|
1234 | switch( att.cssKind ) {
|
1235 | case 'transform':
|
1236 | att.item.CSSTransformSet(att.effect.element, att.effect.type, att.animeTo);
|
1237 | att.item.CSSTransformApply(att.effect.element);
|
1238 | break;
|
1239 | case 'filter':
|
1240 | att.item.CSSFilterSet(att.effect.element, att.effect.type, att.animeTo);
|
1241 | att.item.CSSFilterApply(att.effect.element);
|
1242 | break;
|
1243 | default:
|
1244 | att.item.$getElt(att.effect.element).css(att.effect.type, att.animeTo);
|
1245 | break;
|
1246 | }
|
1247 |
|
1248 | }
|
1249 | });
|
1250 | };
|
1251 |
|
1252 | return NGY2Item;
|
1253 | })();
|
1254 |
|
1255 | }
|
1256 |
|
1257 | _this.options = jQuery.extend(true, {}, jQuery.nanogallery2.defaultOptions, options);
|
1258 |
|
1259 | _this.nG2 = null;
|
1260 | _this.nG2 = new nanoGALLERY2();
|
1261 | _this.nG2.initiateGallery2(_this.e, _this.options );
|
1262 |
|
1263 | };
|
1264 |
|
1265 |
|
1266 | _this.test = function() {
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 | }
|
1272 |
|
1273 |
|
1274 |
|
1275 | _this.init();
|
1276 | };
|
1277 |
|
1278 | jQuery.nanogallery2.defaultOptions = {
|
1279 | kind : '',
|
1280 | userID : '',
|
1281 | photoset : '',
|
1282 | album: '',
|
1283 | blackList : 'scrapbook|profil|auto backup',
|
1284 | whiteList : '',
|
1285 | albumList : '',
|
1286 | albumList2 : null,
|
1287 | RTL : false,
|
1288 | poogleplusUseUrlCrossDomain : true,
|
1289 | flickrSkipOriginal : true,
|
1290 | breadcrumbAutoHideTopLevel : true,
|
1291 | displayBreadcrumb : true,
|
1292 | breadcrumbOnlyCurrentLevel : true,
|
1293 | breadcrumbHideIcons : true,
|
1294 | theme : 'nGY2',
|
1295 | galleryTheme : 'dark',
|
1296 | viewerTheme : 'dark',
|
1297 | items : null,
|
1298 | itemsBaseURL : '',
|
1299 | thumbnailSelectable : false,
|
1300 | dataProvider: '',
|
1301 | dataCharset: 'Latin',
|
1302 | allowHTMLinData: false,
|
1303 | locationHash : true,
|
1304 | slideshowDelay : 3000,
|
1305 | slideshowAutoStart : false,
|
1306 |
|
1307 | debugMode: false,
|
1308 |
|
1309 | galleryDisplayMoreStep : 2,
|
1310 | galleryDisplayMode : 'fullContent',
|
1311 | galleryL1DisplayMode : null,
|
1312 | galleryPaginationMode : 'rectangles',
|
1313 |
|
1314 | galleryMaxRows : 2,
|
1315 | galleryL1MaxRows : null,
|
1316 | galleryLastRowFull: false,
|
1317 | galleryLayoutEngine : 'default',
|
1318 | paginationSwipe: true,
|
1319 | paginationVisiblePages : 10,
|
1320 |
|
1321 | galleryFilterTags : false,
|
1322 | galleryL1FilterTags : null,
|
1323 | galleryMaxItems : 0,
|
1324 | galleryL1MaxItems : null,
|
1325 | gallerySorting : '',
|
1326 | galleryL1Sorting : null,
|
1327 | galleryDisplayTransition : 'none',
|
1328 | galleryL1DisplayTransition : null,
|
1329 | galleryDisplayTransitionDuration : 1000,
|
1330 | galleryL1DisplayTransitionDuration : null,
|
1331 | galleryResizeAnimation : true,
|
1332 | galleryRenderDelay : 60,
|
1333 |
|
1334 | thumbnailCrop : true,
|
1335 | thumbnailL1Crop : null,
|
1336 | thumbnailCropScaleFactor : 1.5,
|
1337 | thumbnailLevelUp : false,
|
1338 | thumbnailAlignment : 'fillWidth',
|
1339 | thumbnailWidth : 300,
|
1340 | thumbnailL1Width : null,
|
1341 | thumbnailHeight : 200,
|
1342 | thumbnailL1Height : null,
|
1343 | thumbnailBaseGridHeight : 0,
|
1344 | thumbnailL1BaseGridHeight : null,
|
1345 | thumbnailGutterWidth : 2,
|
1346 | thumbnailL1GutterWidth : null,
|
1347 | thumbnailGutterHeight : 2,
|
1348 | thumbnailL1GutterHeight : null,
|
1349 | thumbnailBorderVertical : 2,
|
1350 | thumbnailBorderHorizontal : 2,
|
1351 | thumbnailFeaturedKeyword : '*featured',
|
1352 | thumbnailAlbumDisplayImage : false,
|
1353 | thumbnailHoverEffect2 : 'toolsAppear',
|
1354 | thumbnailBuildInit2 : '',
|
1355 | thumbnailStacks : 0,
|
1356 | thumbnailL1Stacks : null,
|
1357 | thumbnailStacksTranslateX : 0,
|
1358 | thumbnailL1StacksTranslateX : null,
|
1359 | thumbnailStacksTranslateY : 0,
|
1360 | thumbnailL1StacksTranslateY : null,
|
1361 | thumbnailStacksTranslateZ : 0,
|
1362 | thumbnailL1StacksTranslateZ : null,
|
1363 | thumbnailStacksRotateX : 0,
|
1364 | thumbnailL1StacksRotateX : null,
|
1365 | thumbnailStacksRotateY : 0,
|
1366 | thumbnailL1StacksRotateY : null,
|
1367 | thumbnailStacksRotateZ : 0,
|
1368 | thumbnailL1StacksRotateZ : null,
|
1369 | thumbnailStacksScale : 0,
|
1370 | thumbnailL1StacksScale : null,
|
1371 | thumbnailDisplayOutsideScreen: true,
|
1372 | thumbnailWaitImageLoaded: true,
|
1373 | thumbnailSliderDelay: 2000,
|
1374 | galleryBuildInit2 : '',
|
1375 | portable : false,
|
1376 | eventsDebounceDelay: 30,
|
1377 |
|
1378 | touchAnimation : true,
|
1379 | touchAnimationL1 : undefined,
|
1380 | touchAutoOpenDelay : 0,
|
1381 |
|
1382 | thumbnailLabel : {
|
1383 | position : 'overImageOnBottom',
|
1384 | align: 'center',
|
1385 | display : true,
|
1386 | displayDescription : false,
|
1387 | titleMaxLength : 0,
|
1388 | titleMultiLine : false,
|
1389 | descriptionMaxLength : 0,
|
1390 | descriptionMultiLine : false,
|
1391 | hideIcons : true,
|
1392 | title : ''
|
1393 | },
|
1394 |
|
1395 | thumbnailToolbarImage : { topLeft: 'select', topRight : 'featured' },
|
1396 | thumbnailToolbarAlbum : { topLeft: 'select', topRight : 'counter' },
|
1397 | thumbnailDisplayInterval : 15,
|
1398 | thumbnailL1DisplayInterval : null,
|
1399 | thumbnailDisplayTransition : 'fadeIn',
|
1400 | thumbnailL1DisplayTransition : null,
|
1401 | thumbnailDisplayTransitionDuration: 240,
|
1402 | thumbnailL1DisplayTransitionDuration: null,
|
1403 | thumbnailOpenImage : true,
|
1404 | thumbnailOpenOriginal : false,
|
1405 | thumbnailGlobalImageTitle : '',
|
1406 | thumbnailGlobalAlbumTitle : '',
|
1407 |
|
1408 | viewer : 'internal',
|
1409 | viewerFullscreen: false,
|
1410 | viewerDisplayLogo : false,
|
1411 | imageTransition : 'swipe2',
|
1412 | viewerTransitionMediaKind : 'img',
|
1413 | viewerZoom : true,
|
1414 | viewerImageDisplay : '',
|
1415 | openOnStart : '',
|
1416 | viewerHideToolsDelay : 3000,
|
1417 | viewerToolbar : {
|
1418 | display : true,
|
1419 | position : 'bottomOverImage',
|
1420 | fullWidth : true,
|
1421 | align : 'center',
|
1422 | autoMinimize : 0,
|
1423 | standard : 'minimizeButton,label',
|
1424 | minimized : 'minimizeButton,label,infoButton,shareButton,downloadButton,linkOriginalButton,fullscreenButton'
|
1425 | },
|
1426 | viewerTools : {
|
1427 | topLeft : 'pageCounter,playPauseButton',
|
1428 | topRight : 'rotateLeft,rotateRight,fullscreenButton,closeButton'
|
1429 | },
|
1430 |
|
1431 | breakpointSizeSM : 480,
|
1432 | breakpointSizeME : 992,
|
1433 | breakpointSizeLA : 1200,
|
1434 | breakpointSizeXL : 1800,
|
1435 |
|
1436 | fnThumbnailInit : null,
|
1437 | fnThumbnailHoverInit : null,
|
1438 | fnThumbnailHover : null,
|
1439 | fnThumbnailHoverOut : null,
|
1440 | fnThumbnailDisplayEffect : null,
|
1441 | fnViewerInfo : null,
|
1442 | fnImgToolbarCustInit : null,
|
1443 | fnImgToolbarCustDisplay : null,
|
1444 | fnImgToolbarCustClick : null,
|
1445 | fnProcessData : null,
|
1446 | fnThumbnailSelection : null,
|
1447 | fnGalleryRenderStart : null,
|
1448 | fnGalleryRenderEnd : null,
|
1449 | fnGalleryObjectModelBuilt : null,
|
1450 | fnGalleryLayoutApplied : null,
|
1451 | fnThumbnailClicked : null,
|
1452 | fnShoppingCartUpdated : null,
|
1453 | fnThumbnailToolCustAction : null,
|
1454 | fnThumbnailOpen : null,
|
1455 | fnImgDisplayed : null,
|
1456 |
|
1457 | i18n : {
|
1458 | 'breadcrumbHome' : 'Galleries', 'breadcrumbHome_FR' : 'Galeries',
|
1459 | 'thumbnailImageTitle' : '', 'thumbnailAlbumTitle' : '',
|
1460 | 'thumbnailImageDescription' : '', 'thumbnailAlbumDescription' : '',
|
1461 | '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'
|
1462 | },
|
1463 | icons : {
|
1464 |
|
1465 | thumbnailAlbum: '<i class="nGY2Icon-folder-empty"></i>',
|
1466 | thumbnailImage: '<i class="nGY2Icon-picture"></i>',
|
1467 | breadcrumbAlbum: '<i class="nGY2Icon-folder-empty"></i>',
|
1468 | breadcrumbHome: '<i class="nGY2Icon-home"></i>',
|
1469 | breadcrumbSeparator: '<i class="nGY2Icon-left-open"></i>',
|
1470 | breadcrumbSeparatorRtl: '<i class="nGY2Icon-right-open"></i>',
|
1471 | navigationFilterSelected: '<i style="color:#fff;" class="nGY2Icon-toggle-on"></i>',
|
1472 | navigationFilterUnselected: '<i style="color:#ddd;" class="nGY2Icon-toggle-off"></i>',
|
1473 | navigationFilterSelectedAll: '<i class="nGY2Icon-toggle-on"></i><i class="nGY2Icon-ok"></i>',
|
1474 | thumbnailSelected: '<i style="color:#bff;" class="nGY2Icon-ok-circled"></i>',
|
1475 | thumbnailUnselected: '<i style="color:#bff;" class="nGY2Icon-circle-empty"></i>',
|
1476 | thumbnailFeatured: '<i style="color:#dd5;" class="nGY2Icon-star"></i>',
|
1477 | thumbnailCounter: '<i class="nGY2Icon-picture"></i>',
|
1478 | thumbnailShare: '<i class="nGY2Icon-ngy2_share2"></i>',
|
1479 | thumbnailDownload: '<i class="nGY2Icon-ngy2_download2"></i>',
|
1480 | thumbnailInfo: '<i class="nGY2Icon-ngy2_info2"></i>',
|
1481 | thumbnailCart: '<i class="nGY2Icon-basket"></i>',
|
1482 | thumbnailDisplay: '<i class="nGY2Icon-ngy2_zoom_in2"></i>',
|
1483 | thumbnailCustomTool1: 'T1',
|
1484 | thumbnailCustomTool2: 'T2',
|
1485 | thumbnailCustomTool3: 'T3',
|
1486 | thumbnailCustomTool4: 'T4',
|
1487 | thumbnailCustomTool5: 'T5',
|
1488 | thumbnailCustomTool6: 'T6',
|
1489 | thumbnailCustomTool7: 'T7',
|
1490 | thumbnailCustomTool8: 'T8',
|
1491 | thumbnailCustomTool9: 'T9',
|
1492 | thumbnailCustomTool10: 'T10',
|
1493 | thumbnailAlbumUp: '<i style="font-size: 3em;" class="nGY2Icon-ngy2_chevron_up2"></i>',
|
1494 | paginationNext: '<i class="nGY2Icon-right-open"></i>',
|
1495 | paginationPrevious: '<i class="nGY2Icon-left-open"></i>',
|
1496 | galleryMoreButton: '<i class="nGY2Icon-picture"></i> <i class="nGY2Icon-right-open"></i>',
|
1497 | buttonClose: '<i class="nGY2Icon-ngy2_close2"></i>',
|
1498 | viewerPrevious: '<i class="nGY2Icon-ngy2_chevron-left"></i>',
|
1499 | viewerNext: '<i class="nGY2Icon-ngy2_chevron-right"></i>',
|
1500 | viewerImgPrevious: '<i class="nGY2Icon-ngy2_chevron_left3"></i>',
|
1501 | viewerImgNext: '<i class="nGY2Icon-ngy2_chevron_right3"></i>',
|
1502 | viewerDownload: '<i class="nGY2Icon-ngy2_download2"></i>',
|
1503 | viewerToolbarMin: '<i class="nGY2Icon-ellipsis-vert"></i>',
|
1504 | viewerToolbarStd: '<i class="nGY2Icon-menu"></i>',
|
1505 | viewerPlay: '<i class="nGY2Icon-play"></i>',
|
1506 | viewerPause: '<i class="nGY2Icon-pause"></i>',
|
1507 | viewerFullscreenOn: '<i class="nGY2Icon-resize-full"></i>',
|
1508 | viewerFullscreenOff: '<i class="nGY2Icon-resize-small"></i>',
|
1509 | viewerZoomIn: '<i class="nGY2Icon-ngy2_zoom_in2"></i>',
|
1510 | viewerZoomOut: '<i class="nGY2Icon-ngy2_zoom_out2"></i>',
|
1511 | viewerLinkOriginal: '<i class="nGY2Icon-ngy2_external2"></i>',
|
1512 | viewerInfo: '<i class="nGY2Icon-ngy2_info2"></i>',
|
1513 | viewerShare: '<i class="nGY2Icon-ngy2_share2"></i>',
|
1514 | viewerRotateLeft: '<i class="nGY2Icon-ccw"></i>',
|
1515 | viewerRotateRight: '<i class="nGY2Icon-cw"></i>',
|
1516 | user: '<i class="nGY2Icon-user"></i>',
|
1517 | location: '<i class="nGY2Icon-location"></i>',
|
1518 | config: '<i class="nGY2Icon-wrench"></i>',
|
1519 | shareFacebook: '<i style="color:#3b5998;" class="nGY2Icon-facebook-squared"></i>',
|
1520 | shareTwitter: '<i style="color:#00aced;" class="nGY2Icon-twitter-squared"></i>',
|
1521 |
|
1522 | shareTumblr: '<i style="color:#32506d;" class="nGY2Icon-tumblr-squared"></i>',
|
1523 | sharePinterest: '<i style="color:#cb2027;" class="nGY2Icon-pinterest-squared"></i>',
|
1524 | shareVK: '<i style="color:#3b5998;" class="nGY2Icon-vkontakte"></i>',
|
1525 | shareMail: '<i style="color:#555;" class="nGY2Icon-mail-alt"></i>',
|
1526 | viewerCustomTool1: 'T1',
|
1527 | viewerCustomTool2: 'T2',
|
1528 | viewerCustomTool3: 'T3',
|
1529 | viewerCustomTool4: 'T4',
|
1530 | viewerCustomTool5: 'T5',
|
1531 | viewerCustomTool6: 'T6',
|
1532 | viewerCustomTool7: 'T7',
|
1533 | viewerCustomTool8: 'T8',
|
1534 | viewerCustomTool9: 'T9',
|
1535 | viewerCustomTool10: 'T10'
|
1536 | }
|
1537 | };
|
1538 |
|
1539 | jQuery.fn.nanogallery2 = function (args, option, value) {
|
1540 |
|
1541 | if( typeof jQuery(this).data('nanogallery2data') === 'undefined'){
|
1542 | if( args == 'destroy' ) {
|
1543 |
|
1544 | return;
|
1545 | }
|
1546 |
|
1547 | return this.each( function(){
|
1548 | (new jQuery.nanogallery2(this, args));
|
1549 | });
|
1550 | }
|
1551 | else {
|
1552 |
|
1553 |
|
1554 |
|
1555 | var nG2=$(this).data('nanogallery2data').nG2;
|
1556 | switch(args){
|
1557 | case 'displayItem':
|
1558 | nG2.DisplayItem(option);
|
1559 | break;
|
1560 |
|
1561 | case 'search':
|
1562 | return( nG2.Search(option));
|
1563 | break;
|
1564 |
|
1565 | case 'search2':
|
1566 | return nG2.Search2(option, value);
|
1567 | break;
|
1568 |
|
1569 | case 'search2Execute':
|
1570 | return nG2.Search2Execute();
|
1571 | break;
|
1572 |
|
1573 | case 'refresh':
|
1574 | nG2.Refresh();
|
1575 | break;
|
1576 |
|
1577 | case 'resize':
|
1578 | nG2.Resize();
|
1579 | break;
|
1580 |
|
1581 | case 'instance':
|
1582 | return nG2;
|
1583 | break;
|
1584 |
|
1585 | case 'data':
|
1586 | nG2.data= {
|
1587 | items: nG2.I,
|
1588 | gallery: nG2.GOM,
|
1589 | lightbox: nG2.VOM
|
1590 | };
|
1591 | return nG2.data;
|
1592 | break;
|
1593 |
|
1594 | case 'reload':
|
1595 | nG2.ReloadAlbum();
|
1596 | return $(this);
|
1597 | break;
|
1598 |
|
1599 | case 'itemsSelectedGet':
|
1600 | return nG2.ItemsSelectedGet();
|
1601 | break;
|
1602 |
|
1603 | case 'itemsSetSelectedValue':
|
1604 | nG2.ItemsSetSelectedValue(option, value);
|
1605 | break;
|
1606 |
|
1607 | case 'option':
|
1608 | if(typeof value === 'undefined'){
|
1609 | return nG2.Get(option);
|
1610 | }else{
|
1611 | nG2.Set(option,value);
|
1612 | if( option == 'demoViewportWidth' ) {
|
1613 |
|
1614 | $(window).trigger('resize');
|
1615 | }
|
1616 | }
|
1617 | break;
|
1618 |
|
1619 | case 'destroy':
|
1620 | nG2.Destroy();
|
1621 | $(this).removeData('nanogallery2data');
|
1622 | break;
|
1623 |
|
1624 | case 'shoppingCartGet':
|
1625 | return nG2.shoppingCart;
|
1626 | break;
|
1627 |
|
1628 | case 'shoppingCartUpdate':
|
1629 | if( typeof value === 'undefined' || typeof option === 'undefined' ){
|
1630 | return false;
|
1631 | }
|
1632 | var ID = option;
|
1633 | var cnt = value;
|
1634 | for( var i = 0; i < nG2.shoppingCart.length; i++) {
|
1635 | if( nG2.shoppingCart[i].ID = ID ) {
|
1636 | nG2.shoppingCart[i].cnt = cnt;
|
1637 | }
|
1638 | }
|
1639 | var fu = G.O.fnShoppingCartUpdated;
|
1640 | if( fu !== null ) {
|
1641 | typeof fu == 'function' ? fu(nG2.shoppingCart, NGY2Item.Get(G, ID)) : window[fu](nG2.shoppingCart, NGY2Item.Get(G, ID));
|
1642 | }
|
1643 | return nG2.shoppingCart;
|
1644 | break;
|
1645 |
|
1646 | case 'shoppingCartRemove':
|
1647 | if( typeof option === 'undefined' ){
|
1648 | return false;
|
1649 | }
|
1650 | var ID=option;
|
1651 | for( var i=0; i<nG2.shoppingCart.length; i++) {
|
1652 | if( nG2.shoppingCart[i].ID=ID ) {
|
1653 | nG2.shoppingCart.splice(i,1);
|
1654 | break;
|
1655 | }
|
1656 | }
|
1657 | var fu = G.O.fnShoppingCartUpdated;
|
1658 | if( fu !== null ) {
|
1659 | typeof fu == 'function' ? fu(nG2.shoppingCart, NGY2Item.Get(G, ID)) : window[fu](nG2.shoppingCart, NGY2Item.Get(G, ID));
|
1660 | }
|
1661 | return nG2.shoppingCart;
|
1662 | break;
|
1663 |
|
1664 | case 'closeViewer':
|
1665 | nG2.CloseViewer();
|
1666 | break;
|
1667 | case 'minimizeToolbar':
|
1668 | nG2.MinimizeToolbar();
|
1669 | break;
|
1670 | case 'maximizeToolbar':
|
1671 | nG2.MaximizeToolbar();
|
1672 | break;
|
1673 | case 'paginationPreviousPage':
|
1674 | nG2.PaginationPreviousPage();
|
1675 | break;
|
1676 | case 'paginationNextPage':
|
1677 | nG2.paginationNextPage();
|
1678 | break;
|
1679 | case 'paginationGotoPage':
|
1680 | nG2.PaginationGotoPage( option );
|
1681 | break;
|
1682 | case 'paginationCountPages':
|
1683 | nG2.PaginationCountPages();
|
1684 | break;
|
1685 |
|
1686 | }
|
1687 | return $(this);
|
1688 |
|
1689 | }
|
1690 | };
|
1691 |
|
1692 |
|
1693 |
|
1694 |
|
1695 |
|
1696 |
|
1697 |
|
1698 | function nanoGALLERY2() {
|
1699 | "use strict";
|
1700 |
|
1701 | |
1702 |
|
1703 |
|
1704 | this.ReloadAlbum = function(){
|
1705 | if( G.O.kind === '' ) {
|
1706 | throw 'Not supported for this content source:' + G.O.kind;
|
1707 | }
|
1708 |
|
1709 | var albumIdx = G.GOM.albumIdx;
|
1710 | if( albumIdx == -1 ) {
|
1711 | throw ('Current album not found.');
|
1712 | }
|
1713 |
|
1714 | var albumID = G.I[albumIdx].GetID();
|
1715 |
|
1716 |
|
1717 | var l = G.I.length;
|
1718 | for( var i = 0; i < l ; i++ ) {
|
1719 | var item = G.I[i];
|
1720 | if( item.albumID == albumID ) {
|
1721 | item.selected = false;
|
1722 | }
|
1723 | }
|
1724 |
|
1725 | G.I[albumIdx].contentIsLoaded = false;
|
1726 |
|
1727 | DisplayAlbum('-1', albumID);
|
1728 | };
|
1729 |
|
1730 | |
1731 |
|
1732 |
|
1733 |
|
1734 | this.ItemsSetSelectedValue = function(items, value){
|
1735 | var l = items.length;
|
1736 | for( var j = 0; j < l ; j++) {
|
1737 | ThumbnailSelectionSet(items[j], value);
|
1738 | }
|
1739 | };
|
1740 |
|
1741 | |
1742 |
|
1743 |
|
1744 |
|
1745 | this.ItemsSelectedGet = function(){
|
1746 | var selectedItems = [];
|
1747 | var l = G.I.length;
|
1748 | for( var i = 0; i < l ; i++ ) {
|
1749 | if( G.I[i].selected == true ) {
|
1750 | selectedItems.push(G.I[i]);
|
1751 | }
|
1752 | }
|
1753 | return selectedItems;
|
1754 | };
|
1755 |
|
1756 | |
1757 |
|
1758 |
|
1759 |
|
1760 |
|
1761 | this.Get = function(option){
|
1762 | return G.O[option];
|
1763 | };
|
1764 |
|
1765 | |
1766 |
|
1767 |
|
1768 |
|
1769 | this.Set = function(option, value){
|
1770 | G.O[option] = value;
|
1771 | switch( option ) {
|
1772 | case 'thumbnailSelectable':
|
1773 | ThumbnailSelectionClear();
|
1774 |
|
1775 | GalleryRender( G.GOM.albumIdx );
|
1776 | break;
|
1777 | }
|
1778 | };
|
1779 |
|
1780 | |
1781 |
|
1782 |
|
1783 | this.Refresh = function() {
|
1784 |
|
1785 | GalleryRender( G.GOM.albumIdx );
|
1786 | };
|
1787 | |
1788 |
|
1789 |
|
1790 | this.Resize = function() {
|
1791 |
|
1792 | GalleryResize();
|
1793 | };
|
1794 |
|
1795 | |
1796 |
|
1797 |
|
1798 |
|
1799 |
|
1800 |
|
1801 | this.DisplayItem = function( itemID ) {
|
1802 | var IDs=parseIDs( itemID );
|
1803 | if( IDs.imageID != '0' ) {
|
1804 | DisplayPhoto( IDs.imageID, IDs.albumID );
|
1805 | }
|
1806 | else {
|
1807 | DisplayAlbum( '-1', IDs.albumID );
|
1808 | }
|
1809 | };
|
1810 |
|
1811 |
|
1812 |
|
1813 | var CountItemsToDisplay = function( gIdx ) {
|
1814 | if( G.I[gIdx] == undefined ) { return 0; }
|
1815 | var albumID = G.I[gIdx].GetID();
|
1816 | var l = G.I.length;
|
1817 | var cnt = 0;
|
1818 | for( var idx = 0; idx < l; idx++ ) {
|
1819 | var item = G.I[idx];
|
1820 | if( item.isToDisplay(albumID) ) {
|
1821 | cnt++;
|
1822 | }
|
1823 | }
|
1824 | return cnt;
|
1825 | }
|
1826 | |
1827 |
|
1828 |
|
1829 | this.Search = function( search ) {
|
1830 | G.GOM.albumSearch = search.toUpperCase();
|
1831 | var gIdx = G.GOM.albumIdx;
|
1832 | GalleryRender( G.GOM.albumIdx );
|
1833 | return CountItemsToDisplay( gIdx );
|
1834 | };
|
1835 |
|
1836 | |
1837 |
|
1838 |
|
1839 | this.Search2 = function( searchTitle, searchTags ) {
|
1840 | if( searchTitle != null && searchTitle != undefined ) {
|
1841 | G.GOM.albumSearch = searchTitle.toUpperCase();
|
1842 | }
|
1843 | else {
|
1844 | G.GOM.albumSearch = '';
|
1845 | }
|
1846 |
|
1847 | if( searchTags != null && searchTags != undefined ) {
|
1848 | G.GOM.albumSearchTags = searchTags.toUpperCase();
|
1849 | }
|
1850 | else {
|
1851 | G.GOM.albumSearchTags = '';
|
1852 | }
|
1853 | return CountItemsToDisplay( G.GOM.albumIdx );
|
1854 | };
|
1855 |
|
1856 | |
1857 |
|
1858 |
|
1859 | this.Search2Execute = function() {
|
1860 | var gIdx = G.GOM.albumIdx;
|
1861 | GalleryRender( G.GOM.albumIdx );
|
1862 | return CountItemsToDisplay( gIdx );
|
1863 | };
|
1864 |
|
1865 |
|
1866 | |
1867 |
|
1868 |
|
1869 | this.Destroy = function(){
|
1870 |
|
1871 |
|
1872 | if( G.GOM.hammertime != null ) {
|
1873 | G.GOM.hammertime.destroy();
|
1874 | G.GOM.hammertime = null;
|
1875 | }
|
1876 |
|
1877 |
|
1878 |
|
1879 |
|
1880 | if( G.VOM.hammertime != null ) {
|
1881 | G.VOM.hammertime.destroy();
|
1882 | G.VOM.hammertime = null;
|
1883 | }
|
1884 |
|
1885 |
|
1886 |
|
1887 | $('#ngycs_' + G.baseEltID).remove()
|
1888 |
|
1889 | G.GOM.items = [];
|
1890 | NGY2Item.New( G, G.i18nTranslations.breadcrumbHome, '', '0', '-1', 'album' );
|
1891 | G.GOM.navigationBar.$newContent = null;
|
1892 | G.$E.base.empty();
|
1893 | G.$E.base.removeData();
|
1894 | if( G.O.locationHash ) {
|
1895 | jQuery(window).off('hashchange.nanogallery2.' + G.baseEltID);
|
1896 | }
|
1897 | jQuery(window).off('resize.nanogallery2.' + G.baseEltID);
|
1898 | jQuery(window).off('orientationChange.nanogallery2.' + G.baseEltID);
|
1899 | jQuery(window).off('scroll.nanogallery2.' + G.baseEltID);
|
1900 | G.GOM.firstDisplay = false;
|
1901 | };
|
1902 |
|
1903 | |
1904 |
|
1905 |
|
1906 | this.CloseViewer = function() {
|
1907 | CloseInternalViewer(null);
|
1908 | return false;
|
1909 | };
|
1910 |
|
1911 | |
1912 |
|
1913 |
|
1914 | this.MinimizeToolbar = function() {
|
1915 | ViewerToolbarForVisibilityMin();
|
1916 | return false;
|
1917 | };
|
1918 |
|
1919 | |
1920 |
|
1921 |
|
1922 | this.MaximizeToolbar = function() {
|
1923 | ViewerToolbarForVisibilityStd();
|
1924 | return false;
|
1925 | };
|
1926 |
|
1927 | |
1928 |
|
1929 |
|
1930 | this.PaginationPreviousPage = function() {
|
1931 | paginationPreviousPage();
|
1932 | return false;
|
1933 | };
|
1934 |
|
1935 |
|
1936 | |
1937 |
|
1938 |
|
1939 | this.PaginationNextPage = function() {
|
1940 | paginationNextPage();
|
1941 | return false;
|
1942 | };
|
1943 |
|
1944 |
|
1945 | |
1946 |
|
1947 |
|
1948 | this.PaginationGotoPage = function( page ) {
|
1949 | var aIdx = G.$E.conPagin.data('galleryIdx');
|
1950 | if( page > 1 ) { page--; }
|
1951 | G.GOM.pagination.currentPage = page;
|
1952 |
|
1953 |
|
1954 | if( !inViewportVert(G.$E.base, 0) ) {
|
1955 | $('html, body').animate({scrollTop: G.$E.base.offset().top}, 200);
|
1956 | }
|
1957 | GalleryDisplayPart1( true );
|
1958 | GalleryDisplayPart2( true );
|
1959 | return false;
|
1960 | };
|
1961 |
|
1962 | |
1963 |
|
1964 |
|
1965 | this.PaginationCountPages = function() {
|
1966 | if( G.GOM.items.length == 0 ) { return 0; }
|
1967 |
|
1968 | var nbPages = Math.ceil((G.GOM.items[G.GOM.items.length - 1].row + 1) / G.galleryMaxRows.Get());
|
1969 | return nbPages;
|
1970 | };
|
1971 |
|
1972 |
|
1973 |
|
1974 |
|
1975 |
|
1976 |
|
1977 |
|
1978 |
|
1979 |
|
1980 |
|
1981 | var throttle = function(func, wait, options) {
|
1982 | var context, args, result;
|
1983 | var timeout = null;
|
1984 | var previous = 0;
|
1985 | if (!options) options = {};
|
1986 | var later = function() {
|
1987 | previous = options.leading === false ? 0 : new Date().getTime();
|
1988 | timeout = null;
|
1989 | result = func.apply(context, args);
|
1990 | if (!timeout) context = args = null;
|
1991 | };
|
1992 | return function() {
|
1993 | var now = new Date().getTime();
|
1994 | if (!previous && options.leading === false) previous = now;
|
1995 | var remaining = wait - (now - previous);
|
1996 | context = this;
|
1997 | args = arguments;
|
1998 | if (remaining <= 0 || remaining > wait) {
|
1999 | if (timeout) {
|
2000 | clearTimeout(timeout);
|
2001 | timeout = null;
|
2002 | }
|
2003 | previous = now;
|
2004 | result = func.apply(context, args);
|
2005 | if (!timeout) context = args = null;
|
2006 | } else if (!timeout && options.trailing !== false) {
|
2007 | timeout = setTimeout(later, remaining);
|
2008 | }
|
2009 | return result;
|
2010 | };
|
2011 | };
|
2012 |
|
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 | var debounce = function (func, threshold, execAsap) {
|
2018 | var timeout;
|
2019 | return function debounced () {
|
2020 | var obj = this, args = arguments;
|
2021 | function delayed () {
|
2022 | if (!execAsap)
|
2023 | func.apply(obj, args);
|
2024 | timeout = null;
|
2025 | };
|
2026 |
|
2027 | if (timeout)
|
2028 | clearTimeout(timeout);
|
2029 |
|
2030 | else if (execAsap)
|
2031 | func.apply(obj, args);
|
2032 | timeout = setTimeout(delayed, threshold || 100);
|
2033 |
|
2034 | };
|
2035 | }
|
2036 |
|
2037 |
|
2038 |
|
2039 | window.ng_draf = function (cb) {
|
2040 | return requestAnimationFrame(function() {
|
2041 | window.requestAnimationFrame(cb)
|
2042 | })
|
2043 | }
|
2044 |
|
2045 |
|
2046 | |
2047 |
|
2048 |
|
2049 |
|
2050 |
|
2051 |
|
2052 | window.requestTimeout = function(fn, delay) {
|
2053 |
|
2054 |
|
2055 |
|
2056 |
|
2057 |
|
2058 | return window.setTimeout(fn, delay);
|
2059 |
|
2060 | var start = new Date().getTime(),
|
2061 | handle = new Object();
|
2062 |
|
2063 | function loop(){
|
2064 | var current = new Date().getTime(),
|
2065 | delta = current - start;
|
2066 | delta = delay;
|
2067 |
|
2068 | delta >= delay ? fn.call() : handle.value = requestAnimFrame(loop);
|
2069 | };
|
2070 |
|
2071 | handle.value = requestAnimFrame(loop);
|
2072 | return handle;
|
2073 | };
|
2074 |
|
2075 |
|
2076 |
|
2077 |
|
2078 | window.requestAnimFrame = (function() {
|
2079 | return window.requestAnimationFrame ||
|
2080 | window.webkitRequestAnimationFrame ||
|
2081 | window.mozRequestAnimationFrame ||
|
2082 | window.oRequestAnimationFrame ||
|
2083 | window.msRequestAnimationFrame ||
|
2084 | function(/* function */ callback, /* DOMElement */ element){
|
2085 | window.setTimeout(callback, 1000 / 60);
|
2086 | };
|
2087 | })();
|
2088 |
|
2089 |
|
2090 |
|
2091 | |
2092 |
|
2093 |
|
2094 |
|
2095 | window.clearRequestTimeout = function(handle) {
|
2096 | window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) :
|
2097 | window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) :
|
2098 | window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) :
|
2099 | window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) :
|
2100 | window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) :
|
2101 | window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) :
|
2102 | clearTimeout(handle);
|
2103 | };
|
2104 |
|
2105 |
|
2106 |
|
2107 | |
2108 |
|
2109 |
|
2110 | var G=this;
|
2111 | G.I = [];
|
2112 | G.Id = [];
|
2113 | G.O = null;
|
2114 | G.baseEltID = null;
|
2115 | G.$E = {
|
2116 | base: null,
|
2117 | conTnParent: null,
|
2118 | conLoadingB: null,
|
2119 | conConsole: null,
|
2120 | conNavigationBar: null,
|
2121 | conTnBottom: null
|
2122 | };
|
2123 | G.shoppingCart = [];
|
2124 | G.layout = {
|
2125 | internal : true,
|
2126 | engine : '',
|
2127 | support : { rows: false },
|
2128 | prerequisite : { imageSize: false },
|
2129 | SetEngine: function() {
|
2130 |
|
2131 | if( G.layout.internal ) {
|
2132 | if( G.tn.settings.width[G.GOM.curNavLevel][G.GOM.curWidth] == 'auto' || G.tn.settings.width[G.GOM.curNavLevel][G.GOM.curWidth] == '' ) {
|
2133 |
|
2134 | G.layout.engine = 'JUSTIFIED';
|
2135 | G.layout.support.rows = true;
|
2136 | G.layout.prerequisite.imageSize = true;
|
2137 | return;
|
2138 | }
|
2139 | if( G.tn.settings.height[G.GOM.curNavLevel][G.GOM.curWidth] == 'auto' || G.tn.settings.height[G.GOM.curNavLevel][G.GOM.curWidth] == '' ) {
|
2140 |
|
2141 | G.layout.engine = 'CASCADING';
|
2142 | G.layout.support.rows = false;
|
2143 | G.layout.prerequisite.imageSize = true;
|
2144 | return;
|
2145 | }
|
2146 |
|
2147 | if( G.tn.settings.getMosaic() != null ) {
|
2148 | G.layout.engine = 'MOSAIC';
|
2149 | G.layout.support.rows = true;
|
2150 | G.layout.prerequisite.imageSize = false;
|
2151 | return;
|
2152 | }
|
2153 |
|
2154 | G.layout.engine='GRID';
|
2155 | G.layout.support.rows=true;
|
2156 |
|
2157 |
|
2158 |
|
2159 |
|
2160 | G.layout.prerequisite.imageSize = false;
|
2161 |
|
2162 | }
|
2163 | }
|
2164 | };
|
2165 | G.galleryResizeEventEnabled = false;
|
2166 | G.galleryMaxRows = { l1: 0, lN: 0,
|
2167 | Get: function() {
|
2168 | return G.galleryMaxRows[G.GOM.curNavLevel];
|
2169 | }
|
2170 | };
|
2171 | G.galleryMaxItems = { l1: 0, lN: 0,
|
2172 | Get: function() {
|
2173 | return G.galleryMaxItems[G.GOM.curNavLevel];
|
2174 | }
|
2175 | };
|
2176 | G.galleryFilterTags = { l1: 0, lN: 0,
|
2177 | Get: function() {
|
2178 | return G.galleryFilterTags[G.GOM.curNavLevel];
|
2179 | }
|
2180 | };
|
2181 | G.galleryDisplayMode = { l1: 'FULLCONTENT', lN: 'FULLCONTENT',
|
2182 | Get: function() {
|
2183 | return G.galleryDisplayMode[G.GOM.curNavLevel];
|
2184 | }
|
2185 | };
|
2186 | G.galleryLastRowFull = { l1: false, lN: false,
|
2187 | Get: function() {
|
2188 | return G.galleryLastRowFull[G.GOM.curNavLevel];
|
2189 | }
|
2190 | };
|
2191 | G.gallerySorting = { l1: '', lN: '',
|
2192 | Get: function() {
|
2193 | return G.gallerySorting[G.GOM.curNavLevel];
|
2194 | }
|
2195 | };
|
2196 | G.galleryDisplayTransition = { l1: 'none', lN: 'none',
|
2197 | Get: function() {
|
2198 | return G.galleryDisplayTransition[G.GOM.curNavLevel];
|
2199 | }
|
2200 | };
|
2201 | G.galleryDisplayTransitionDuration = { l1: 500, lN: 500,
|
2202 | Get: function() {
|
2203 | return G.galleryDisplayTransitionDuration[G.GOM.curNavLevel];
|
2204 | }
|
2205 | };
|
2206 | G.$currentTouchedThumbnail = null;
|
2207 |
|
2208 |
|
2209 | G.tn = {
|
2210 |
|
2211 | opt: {
|
2212 | l1: { crop: true, stacks: 0, stacksTranslateX: 0, stacksTranslateY: 0, stacksTranslateZ: 0, stacksRotateX: 0, stacksRotateY: 0, stacksRotateZ: 0, stacksScale: 0, gutterHeight: 0, gutterWidth: 0, baseGridHeight: 0, displayTransition: 'FADEIN', displayTransitionStartVal: 0, displayTransitionEasing: 'easeOutQuart', displayTransitionDuration: 240, displayInterval: 15 },
|
2213 | lN: { crop: true, stacks: 0, stacksTranslateX: 0, stacksTranslateY: 0, stacksTranslateZ: 0, stacksRotateX: 0, stacksRotateY: 0, stacksRotateZ: 0, stacksScale: 0, gutterHeight: 0, gutterWidth: 0, baseGridHeight: 0, displayTransition: 'FADEIN', displayTransitionStartVal: 0, displayTransitionEasing: 'easeOutQuart', displayTransitionDuration: 240, displayInterval: 15 },
|
2214 | Get: function(opt) {
|
2215 | return G.tn.opt[G.GOM.curNavLevel][opt];
|
2216 | }
|
2217 | },
|
2218 | scale: 1,
|
2219 | borderWidth: 0,
|
2220 | borderHeight: 0,
|
2221 | labelHeight: {
|
2222 | l1: 0, lN: 0,
|
2223 | get: function() {
|
2224 | return G.tn.labelHeight[G.GOM.curNavLevel];
|
2225 | }
|
2226 | },
|
2227 | defaultSize: {
|
2228 |
|
2229 | width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
2230 | height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } },
|
2231 | getWidth: function() {
|
2232 | return G.tn.defaultSize.width[G.GOM.curNavLevel][G.GOM.curWidth];
|
2233 | },
|
2234 | getOuterWidth: function() {
|
2235 | return G.tn.defaultSize.width[G.GOM.curNavLevel][G.GOM.curWidth]+G.tn.borderWidth*2;
|
2236 | },
|
2237 | getHeight: function() {
|
2238 | return G.tn.defaultSize.height[G.GOM.curNavLevel][G.GOM.curWidth];
|
2239 | },
|
2240 | getOuterHeight: function() {
|
2241 | return G.tn.defaultSize.height[G.GOM.curNavLevel][G.GOM.curWidth]+G.tn.borderHeight*2;
|
2242 | }
|
2243 | },
|
2244 | settings: {
|
2245 | width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0, xsc:'u', smc:'u', mec:'u', lac:'u', xlc:'u' },
|
2246 | lN : { xs:0, sm:0, me:0, la:0, xl:0, xsc:'u', smc:'u', mec:'u', lac:'u', xlc:'u' } },
|
2247 | height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0, xsc:'u', smc:'u', mec:'u', lac:'u', xlc:'u' },
|
2248 | lN : { xs:0, sm:0, me:0, la:0, xl:0, xsc:'u', smc:'u', mec:'u', lac:'u', xlc:'u' } },
|
2249 | getH: function(l, w) {
|
2250 | var cl = (l == undefined ? G.GOM.curNavLevel : l);
|
2251 | var cw = (w == undefined ? G.GOM.curWidth : w);
|
2252 | if( G.layout.engine == 'MOSAIC' ) {
|
2253 | return G.tn.settings.height[cl][cw] * G.tn.settings.mosaic[cl+'Factor']['h'][cw];
|
2254 | }
|
2255 | else {
|
2256 | return G.tn.settings.height[cl][cw];
|
2257 | }
|
2258 | },
|
2259 | getW: function(l, w) {
|
2260 | var cl = (l == undefined ? G.GOM.curNavLevel : l);
|
2261 | var cw = (w == undefined ? G.GOM.curWidth : w);
|
2262 | if( G.layout.engine == 'MOSAIC' ) {
|
2263 | return G.tn.settings.width[cl][cw] * G.tn.settings.mosaic[cl+'Factor']['w'][cw];
|
2264 | }
|
2265 | else {
|
2266 | return G.tn.settings.width[cl][cw];
|
2267 |
|
2268 | }
|
2269 | },
|
2270 | mosaic: { l1 : { xs: null, sm: null, me: null, la: null, xl: null },
|
2271 | lN : { xs: null, sm: null, me: null, la: null, xl: null },
|
2272 | l1Factor : { h :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }, w :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }},
|
2273 | lNFactor : { h :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }, w :{ xs: 1, sm: 1, me: 1, la: 1, xl: 1 }}
|
2274 | },
|
2275 | getMosaic: function() {
|
2276 | return G.tn.settings.mosaic[G.GOM.curNavLevel][G.GOM.curWidth];
|
2277 | },
|
2278 | mosaicCalcFactor: function(l, w) {
|
2279 |
|
2280 | var maxW = 1;
|
2281 | var maxH = 1;
|
2282 | for( var n = 0; n < G.tn.settings.mosaic[l][w].length; n++ ) {
|
2283 | maxW = Math.max(maxW, G.tn.settings.mosaic[l][w][n]['w']);
|
2284 | maxH = Math.max(maxH, G.tn.settings.mosaic[l][w][n]['h']);
|
2285 | }
|
2286 | G.tn.settings.mosaic[l + 'Factor']['h'][w] = maxH;
|
2287 | G.tn.settings.mosaic[l + 'Factor']['w'][w] = maxW;
|
2288 | }
|
2289 | },
|
2290 |
|
2291 | hoverEffects : {
|
2292 | std : [],
|
2293 | level1: [],
|
2294 | get: function() {
|
2295 | if( G.GOM.curNavLevel == 'l1' && G.tn.hoverEffects.level1.length !== 0 ) {
|
2296 | return G.tn.hoverEffects.level1;
|
2297 | }
|
2298 | else {
|
2299 | return G.tn.hoverEffects.std;
|
2300 | }
|
2301 | }
|
2302 | },
|
2303 |
|
2304 | buildInit : {
|
2305 | std : [],
|
2306 | level1: [],
|
2307 | get: function() {
|
2308 | if( G.GOM.curNavLevel == 'l1' && G.tn.buildInit.level1.length !== 0 ) {
|
2309 | return G.tn.buildInit.level1;
|
2310 | }
|
2311 | else {
|
2312 | return G.tn.buildInit.std;
|
2313 | }
|
2314 | }
|
2315 | },
|
2316 |
|
2317 | toolbar: {
|
2318 | album : { topLeft : '', topRight: '', bottomLeft: '', bottomRight: '' },
|
2319 | image : { topLeft : '', topRight: '', bottomLeft: '', bottomRight: '' },
|
2320 | albumUp : { topLeft : '', topRight: '', bottomLeft: '', bottomRight: '' },
|
2321 | get: function( item ) {
|
2322 | return G.tn.toolbar[item.kind];
|
2323 | },
|
2324 | },
|
2325 | style: {
|
2326 |
|
2327 | l1 : { label: '', title: '', desc: '' },
|
2328 | lN : { label: '', title: '', desc: '' },
|
2329 | getTitle : function() {
|
2330 | return ('style="' + G.tn.style[G.GOM.curNavLevel].title + '"');
|
2331 | },
|
2332 | getDesc : function() {
|
2333 | return ('style="' + G.tn.style[G.GOM.curNavLevel].desc + '"');
|
2334 | },
|
2335 | getLabel: function() {
|
2336 | var s='style="'+ G.tn.style[G.GOM.curNavLevel].label;
|
2337 | s+= (G.O.RTL ? '"direction:RTL;"' :'');
|
2338 | s+='"';
|
2339 | return s;
|
2340 | }
|
2341 | }
|
2342 | };
|
2343 | G.scrollTimeOut = 0;
|
2344 | G.i18nTranslations = {'paginationPrevious':'Previous', 'paginationNext':'Next', 'breadcrumbHome':'List of Albums', 'thumbnailImageTitle':'', 'thumbnailAlbumTitle':'', 'thumbnailImageDescription':'', 'thumbnailAlbumDescription':'' };
|
2345 | G.emptyGif = 'data:image/gif;base64,R0lGODlhEAAQAIAAAP///////yH5BAEKAAEALAAAAAAQABAAAAIOjI+py+0Po5y02ouzPgUAOw==';
|
2346 | G.CSStransformName = FirstSupportedPropertyName(["transform", "msTransform", "MozTransform", "WebkitTransform", "OTransform"]);
|
2347 |
|
2348 | G.CSStransformStyle = FirstSupportedPropertyName(["transformStyle", "msTransformStyle", "MozTransformStyle", "WebkitTransformStyle", "OTransformStyle"]);
|
2349 | G.CSSperspective = FirstSupportedPropertyName(["perspective", "msPerspective", "MozPerspective", "WebkitPerspective", "OPerspective"]);
|
2350 | G.CSSbackfaceVisibilityName = FirstSupportedPropertyName(["backfaceVisibility", "msBackfaceVisibility", "MozBackfaceVisibility", "WebkitBackfaceVisibility", "OBackfaceVisibility"]);
|
2351 | G.CSStransitionName = FirstSupportedPropertyName(["transition", "msTransition", "MozTransition", "WebkitTransition", "OTransition"]);
|
2352 | G.CSSanimationName = FirstSupportedPropertyName(["animation", "msAnimation", "MozAnimation", "WebkitAnimation", "OAnimation"]);
|
2353 | G.GalleryResizeThrottled = throttle(GalleryResize, 30, {leading: false});
|
2354 |
|
2355 | G.blackList = null;
|
2356 | G.whiteList = null;
|
2357 | G.albumList = [];
|
2358 | G.locationHashLastUsed = '';
|
2359 | G.custGlobals = {};
|
2360 | G.touchAutoOpenDelayTimerID = 0;
|
2361 | G.i18nLang = '';
|
2362 | G.timeLastTouchStart = 0;
|
2363 | G.custGlobals = {};
|
2364 | G.markupOrApiProcessed = false;
|
2365 |
|
2366 |
|
2367 |
|
2368 | G.GOM = {
|
2369 | albumIdx : -1,
|
2370 | clipArea : { top: 0, height: 0 },
|
2371 | displayArea : { width: 0 , height: 0 },
|
2372 | displayAreaLast : { width: 0 , height: 0 },
|
2373 | displayedMoreSteps : 0,
|
2374 | items: [],
|
2375 | $imgPreloader: [],
|
2376 | thumbnails2Display: [],
|
2377 | itemsDisplayed : 0,
|
2378 | firstDisplay : true,
|
2379 | firstDisplayTime : 0,
|
2380 | navigationBar : {
|
2381 | displayed: false,
|
2382 | $newContent: ''
|
2383 | },
|
2384 | cache : {
|
2385 | viewport: null,
|
2386 | containerOffset: null,
|
2387 | areaWidth: 100
|
2388 | },
|
2389 | nbSelected : 0,
|
2390 | pagination : { currentPage: 0 },
|
2391 | panThreshold: 60,
|
2392 | panYOnly: false,
|
2393 | lastFullRow : -1,
|
2394 | lastDisplayedIdx: -1,
|
2395 | displayInterval : { from: 0, len: 0 },
|
2396 | userEvents: null,
|
2397 | hammertime: null,
|
2398 | curNavLevel: 'l1',
|
2399 | curWidth: 'me',
|
2400 | albumSearch: '',
|
2401 | albumSearchTags: '',
|
2402 | lastZIndex: 0,
|
2403 | lastRandomValue: 0,
|
2404 | slider : {
|
2405 | hostIdx: -1,
|
2406 | hostItem: null,
|
2407 | currentIdx: 0,
|
2408 | nextIdx: 0,
|
2409 | timerID: 0,
|
2410 | tween: null
|
2411 | },
|
2412 | NGY2Item: function( idx ) {
|
2413 | if( G.GOM.items[idx] == undefined || G.GOM.items[idx] == null ) { return null; }
|
2414 | var i = G.GOM.items[idx].thumbnailIdx;
|
2415 | return G.I[i];
|
2416 | },
|
2417 |
|
2418 |
|
2419 | GTn: function(index, width, height) {
|
2420 | this.thumbnailIdx = index;
|
2421 | this.width = 0;
|
2422 | this.height = 0;
|
2423 | this.top = 0;
|
2424 | this.left = 0;
|
2425 | this.row = 0;
|
2426 | this.imageWidth = width;
|
2427 | this.imageHeight = height;
|
2428 | this.resizedContentWidth = 0;
|
2429 | this.resizedContentHeight = 0;
|
2430 | this.displayed = false;
|
2431 | this.neverDisplayed = true;
|
2432 | this.inDisplayArea = false;
|
2433 | }
|
2434 | };
|
2435 |
|
2436 |
|
2437 |
|
2438 |
|
2439 |
|
2440 | G.VOM = {
|
2441 | viewerDisplayed: false,
|
2442 | viewerIsFullscreen: false,
|
2443 | infoDisplayed: false,
|
2444 | toolbarsDisplayed: true,
|
2445 | toolsHide: null,
|
2446 | saveOverflowX: 'visible',
|
2447 | saveOverflowY: 'visible',
|
2448 | zoom : {
|
2449 | posX: 0,
|
2450 | posY: 0,
|
2451 | userFactor: 1,
|
2452 | isZooming: false
|
2453 | },
|
2454 | padding: { H: 0, V: 0 },
|
2455 | window: { lastWidth: 0, lastHeight: 0 },
|
2456 | $cont: null,
|
2457 | $viewer: null,
|
2458 | $toolbar: null,
|
2459 | $toolbarTL: null,
|
2460 | $toolbarTR: null,
|
2461 | $content: null,
|
2462 |
|
2463 | $mediaPrevious: null,
|
2464 | $mediaCurrent: null,
|
2465 | $mediaNext: null,
|
2466 | toolbarMode: 'std',
|
2467 | playSlideshow : false,
|
2468 | playSlideshowTimerID: 0,
|
2469 | slideshowDelay: 3000,
|
2470 | albumID: -1,
|
2471 | currItemIdx: -1,
|
2472 | viewerMediaIsChanged: false,
|
2473 | items: [],
|
2474 | NGY2Item: function( n ) {
|
2475 | switch( n ) {
|
2476 | case -1:
|
2477 | var idx=this.IdxPrevious();
|
2478 | return G.I[this.items[idx].ngy2ItemIdx];
|
2479 | break;
|
2480 | case 1:
|
2481 | var idx=this.IdxNext();
|
2482 | return G.I[this.items[idx].ngy2ItemIdx];
|
2483 | break;
|
2484 | case 0:
|
2485 | default:
|
2486 | return G.I[this.items[G.VOM.currItemIdx].ngy2ItemIdx];
|
2487 | break;
|
2488 | }
|
2489 | },
|
2490 | IdxNext: function() {
|
2491 | var n = 0;
|
2492 | if( G.VOM.currItemIdx != (G.VOM.items.length-1) ) {
|
2493 | n = G.VOM.currItemIdx + 1;
|
2494 | }
|
2495 | return n;
|
2496 | },
|
2497 | IdxPrevious: function() {
|
2498 | var n = G.VOM.currItemIdx - 1;
|
2499 | if( G.VOM.currItemIdx == 0 ) {
|
2500 | n = G.VOM.items.length - 1;
|
2501 | }
|
2502 | return n;
|
2503 | },
|
2504 | userEvents: null,
|
2505 | hammertime: null,
|
2506 | swipePosX: 0,
|
2507 | panPosX: 0,
|
2508 | panPosY: 0,
|
2509 | panThreshold: 60,
|
2510 | panXOnly: false,
|
2511 | viewerTheme: '',
|
2512 | timeImgChanged: 0,
|
2513 | ImageLoader: {
|
2514 |
|
2515 |
|
2516 | maxChecks: 1000,
|
2517 | list: [],
|
2518 | intervalHandle : null,
|
2519 |
|
2520 | loadImage : function (callback, ngitem) {
|
2521 | if( ngitem.mediaKind != 'img' ) { return; }
|
2522 | var img = new Image ();
|
2523 | img.src = ngitem.responsiveURL();
|
2524 | if (img.width && img.height) {
|
2525 | callback (img.width, img.height, ngitem, 0);
|
2526 | }
|
2527 | else {
|
2528 | var obj = {image: img, url: ngitem.responsiveURL(), ngitem: ngitem, callback: callback, checks: 1};
|
2529 | var i;
|
2530 | for (i=0; i < this.list.length; i++) {
|
2531 | if (this.list[i] == null)
|
2532 | break;
|
2533 | }
|
2534 | this.list[i] = obj;
|
2535 | if (!this.intervalHandle)
|
2536 | this.intervalHandle = setInterval(this.interval, 50);
|
2537 | }
|
2538 | },
|
2539 |
|
2540 |
|
2541 | interval : function () {
|
2542 | var count = 0;
|
2543 | var list = G.VOM.ImageLoader.list, item;
|
2544 | for (var i=0; i<list.length; i++) {
|
2545 | item = list[i];
|
2546 | if (item != null) {
|
2547 | if (item.image.width && item.image.height) {
|
2548 | G.VOM.ImageLoader.list[i] = null;
|
2549 | item.callback (item.image.width, item.image.height, item.ngitem, item.checks);
|
2550 | }
|
2551 | else if (item.checks > G.VOM.ImageLoader.maxChecks) {
|
2552 | G.VOM.ImageLoader.list[i] = null;
|
2553 | item.callback (0, 0, item.ngitem, item.checks);
|
2554 | }
|
2555 | else {
|
2556 | count++;
|
2557 | item.checks++;
|
2558 | }
|
2559 | }
|
2560 | }
|
2561 | if (count == 0) {
|
2562 | G.VOM.ImageLoader.list = [];
|
2563 | clearInterval (G.VOM.ImageLoader.intervalHandle);
|
2564 | delete G.VOM.ImageLoader.intervalHandle;
|
2565 | }
|
2566 | }
|
2567 | }
|
2568 | }
|
2569 |
|
2570 | function VImg(index) {
|
2571 | this.$e = null;
|
2572 | this.ngy2ItemIdx = index;
|
2573 | this.mediaNumber = 0;
|
2574 | this.posX = 0;
|
2575 | this.posY = 0;
|
2576 | }
|
2577 |
|
2578 |
|
2579 |
|
2580 |
|
2581 | G.popup = {
|
2582 | isDisplayed: false,
|
2583 | $elt: null,
|
2584 | close: function() {
|
2585 | if( this.$elt != null ) {
|
2586 | var tweenable = new NGTweenable();
|
2587 | tweenable.tween({
|
2588 | from: { opacity:1 },
|
2589 | to: { opacity:0 },
|
2590 | attachment: { t: this },
|
2591 | easing: 'easeInOutSine',
|
2592 | duration: 100,
|
2593 | step: function (state, att) {
|
2594 | if( att.t.$elt != null ) {
|
2595 | att.t.$elt.css('opacity',state.opacity);
|
2596 | }
|
2597 | },
|
2598 | finish: function (state, att) {
|
2599 | if( att.t.$elt != null ) {
|
2600 | att.t.$elt.remove();
|
2601 | att.t.$elt=null;
|
2602 | }
|
2603 | att.t.isDisplayed=false;
|
2604 | }
|
2605 | });
|
2606 | }
|
2607 | }
|
2608 | }
|
2609 |
|
2610 |
|
2611 |
|
2612 |
|
2613 | G.galleryTheme_dark = {
|
2614 | navigationBar : { background: 'none', borderTop: '', borderBottom: '', borderRight: '', borderLeft: '' },
|
2615 | navigationBreadcrumb : { background: '#111', color: '#fff', colorHover: '#ccc', borderRadius: '4px' },
|
2616 | navigationFilter : { color: '#ddd', background: '#111', colorSelected: '#fff', backgroundSelected: '#111', borderRadius: '4px' },
|
2617 | 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: '#aaa' },
|
2618 | thumbnailIcon : { padding: '5px', color: '#fff' },
|
2619 | pagination : { background: '#181818', backgroundSelected: '#666', color: '#fff', borderRadius: '2px', shapeBorder: '3px solid #666', shapeColor: '#444', shapeSelectedColor: '#aaa'}
|
2620 | };
|
2621 |
|
2622 | G.galleryTheme_light = {
|
2623 | navigationBar : { background: 'none', borderTop: '', borderBottom: '', borderRight: '', borderLeft: '' },
|
2624 | navigationBreadcrumb : { background: '#eee', color: '#000', colorHover: '#333', borderRadius: '4px' },
|
2625 | navigationFilter : { background: '#eee', color: '#222', colorSelected: '#000', backgroundSelected: '#eee', borderRadius: '4px' },
|
2626 | 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' },
|
2627 | thumbnailIcon : { padding: '5px', color: '#fff' },
|
2628 | pagination : { background: '#eee', backgroundSelected: '#aaa', color: '#000', borderRadius: '2px', shapeBorder: '3px solid #666', shapeColor: '#444', shapeSelectedColor: '#aaa'}
|
2629 | };
|
2630 |
|
2631 |
|
2632 | G.viewerTheme_dark = {
|
2633 | background: '#000',
|
2634 | imageBorder: 'none',
|
2635 | imageBoxShadow: 'none',
|
2636 | barBackground: 'rgba(4, 4, 4, 0.2)',
|
2637 | barBorder: '0px solid #111',
|
2638 | barColor: '#eee',
|
2639 | barDescriptionColor: '#aaa'
|
2640 | };
|
2641 | G.viewerTheme_border = {
|
2642 | background: 'rgba(1, 1, 1, 0.75)',
|
2643 | imageBorder: '4px solid #f8f8f8',
|
2644 | imageBoxShadow: '#888 0px 0px 20px',
|
2645 | barBackground: 'rgba(4, 4, 4, 0.2)',
|
2646 | barBorder: '0px solid #111',
|
2647 | barColor: '#eee',
|
2648 | barDescriptionColor: '#aaa'
|
2649 | };
|
2650 | G.viewerTheme_light = {
|
2651 | background: '#f8f8f8',
|
2652 | imageBorder: 'none',
|
2653 | imageBoxShadow: 'none',
|
2654 | barBackground: 'rgba(4, 4, 4, 0.7)',
|
2655 | barBorder: '0px solid #111',
|
2656 | barColor: '#eee',
|
2657 | barDescriptionColor: '#aaa'
|
2658 | };
|
2659 |
|
2660 |
|
2661 |
|
2662 |
|
2663 |
|
2664 |
|
2665 | var NanoAlert = NGY2Tools.NanoAlert;
|
2666 | var NanoConsoleLog = NGY2Tools.NanoConsoleLog;
|
2667 |
|
2668 |
|
2669 |
|
2670 | this.initiateGallery2 = function( element, params ) {
|
2671 |
|
2672 |
|
2673 | G.O = params;
|
2674 |
|
2675 | G.$E.base = jQuery(element);
|
2676 | G.baseEltID = G.$E.base.attr('id');
|
2677 | if( G.baseEltID == undefined ) {
|
2678 |
|
2679 | G.baseEltID='my_nanogallery';
|
2680 | G.$E.base.attr('id', G.baseEltID)
|
2681 | }
|
2682 | G.O.$markup = [];
|
2683 | DefineVariables();
|
2684 | SetPolyFills();
|
2685 | BuildSkeleton();
|
2686 | G.GOM.firstDisplayTime=Date.now();
|
2687 |
|
2688 | SetGlobalEvents();
|
2689 |
|
2690 |
|
2691 | var albumToDisplay = G.O.album;
|
2692 | if( albumToDisplay == '' && G.O.photoset != '' ) {
|
2693 | albumToDisplay = G.O.photoset;
|
2694 | G.O.album = G.O.photoset;
|
2695 | }
|
2696 | if( albumToDisplay != '' ) {
|
2697 | G.O.displayBreadcrumb = false;
|
2698 | if( albumToDisplay.toUpperCase() != 'NONE' ) {
|
2699 |
|
2700 |
|
2701 | var p=albumToDisplay.indexOf('&authkey=');
|
2702 | if( p == -1 ) {
|
2703 | p=albumToDisplay.indexOf('?authkey=');
|
2704 | }
|
2705 | if( p > 0 ) {
|
2706 |
|
2707 | G.O.locationHash=false;
|
2708 | var albumID=albumToDisplay.substring(0,p);
|
2709 | var opt=albumToDisplay.substring(p);
|
2710 | if( opt.indexOf('Gv1sRg') == -1 ) {
|
2711 | opt = '&authkey=Gv1sRg'+opt.substring(9);
|
2712 | }
|
2713 | var newItem = NGY2Item.New( G, '', '', albumID, '-1', 'album' );
|
2714 | newItem.authkey = opt;
|
2715 | DisplayAlbum('-1', albumID);
|
2716 | }
|
2717 | else {
|
2718 |
|
2719 | if( G.O.kind == "nano_photos_provider2") {
|
2720 | if( albumToDisplay == decodeURIComponent(albumToDisplay)) {
|
2721 |
|
2722 | albumToDisplay = encodeURIComponent(albumToDisplay);
|
2723 | G.O.album = albumToDisplay;
|
2724 | }
|
2725 | }
|
2726 | NGY2Item.New( G, '', '', albumToDisplay, '-1', 'album' );
|
2727 | if( !ProcessLocationHash() ) {
|
2728 | DisplayAlbum('-1', albumToDisplay);
|
2729 | }
|
2730 | }
|
2731 | return;
|
2732 | }
|
2733 | }
|
2734 |
|
2735 |
|
2736 |
|
2737 | NGY2Item.New( G, G.i18nTranslations.breadcrumbHome, '', '0', '-1', 'album' );
|
2738 |
|
2739 | processStartOptions();
|
2740 |
|
2741 | }
|
2742 |
|
2743 |
|
2744 |
|
2745 | function processStartOptions() {
|
2746 |
|
2747 |
|
2748 |
|
2749 |
|
2750 |
|
2751 |
|
2752 |
|
2753 |
|
2754 |
|
2755 |
|
2756 |
|
2757 |
|
2758 | if( !ProcessLocationHash() ) {
|
2759 | processStartOptionsPart2();
|
2760 | }
|
2761 | }
|
2762 |
|
2763 |
|
2764 | function processStartOptionsPart2() {
|
2765 |
|
2766 |
|
2767 |
|
2768 | if( G.O.openOnStart != '' ) {
|
2769 | var IDs = parseIDs(G.O.openOnStart);
|
2770 | if( IDs.imageID != '0' ) {
|
2771 | DisplayPhoto(IDs.imageID, IDs.albumID);
|
2772 | }
|
2773 | else {
|
2774 | DisplayAlbum('-1', IDs.albumID);
|
2775 | }
|
2776 | }
|
2777 | else {
|
2778 |
|
2779 | DisplayAlbum('-1', 0);
|
2780 | }
|
2781 | }
|
2782 |
|
2783 |
|
2784 | function parseIDs( IDs ) {
|
2785 | var r={ albumID: '0', imageID: '0' };
|
2786 |
|
2787 | var t=IDs.split('/');
|
2788 | if( t.length > 0 ) {
|
2789 | r.albumID = t[0];
|
2790 | if( t.length > 1 ) {
|
2791 | r.imageID = t[1];
|
2792 | }
|
2793 | }
|
2794 | return r;
|
2795 | }
|
2796 |
|
2797 |
|
2798 |
|
2799 | function DisplayAlbum( imageID, albumID ) {
|
2800 |
|
2801 | if( G.VOM.viewerDisplayed ) {
|
2802 | CloseInternalViewer(null);
|
2803 | }
|
2804 |
|
2805 |
|
2806 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
2807 | G.GOM.curNavLevel = 'lN';
|
2808 | if( albumIdx == 0 ) {
|
2809 | G.GOM.curNavLevel = 'l1';
|
2810 | }
|
2811 | G.layout.SetEngine();
|
2812 | G.galleryResizeEventEnabled = false;
|
2813 |
|
2814 | if( albumIdx == -1 ) {
|
2815 | NGY2Item.New( G, '', '', albumID, '0', 'album' );
|
2816 | albumIdx = G.I.length - 1;
|
2817 | }
|
2818 |
|
2819 | if( !G.I[albumIdx].contentIsLoaded ) {
|
2820 |
|
2821 | AlbumGetContent( albumID, DisplayAlbum, imageID, albumID );
|
2822 | return;
|
2823 | }
|
2824 |
|
2825 | ThumbnailSelectionClear();
|
2826 |
|
2827 | G.GOM.pagination.currentPage = 0;
|
2828 | SetLocationHash( albumID, '' );
|
2829 | GalleryRender( albumIdx );
|
2830 |
|
2831 | }
|
2832 |
|
2833 |
|
2834 |
|
2835 | function GalleryBottomManage() {
|
2836 |
|
2837 | switch( G.galleryDisplayMode.Get() ) {
|
2838 | case 'PAGINATION':
|
2839 | if( G.layout.support.rows && G.galleryMaxRows.Get() > 0 ) {
|
2840 | ManagePagination( G.GOM.albumIdx );
|
2841 | }
|
2842 | break;
|
2843 | case 'MOREBUTTON':
|
2844 | G.$E.conTnBottom.off('click');
|
2845 | var nb = G.GOM.items.length-G.GOM.itemsDisplayed;
|
2846 | if( nb == 0 ) {
|
2847 | G.$E.conTnBottom.empty();
|
2848 | }
|
2849 | else {
|
2850 | G.$E.conTnBottom.html('<div class="nGY2GalleryMoreButton"><div class="nGY2GalleryMoreButtonAnnotation">+'+nb+' ' + G.O.icons.galleryMoreButton +'</div></div>');
|
2851 | G.$E.conTnBottom.on('click', function(e) {
|
2852 | G.GOM.displayedMoreSteps++;
|
2853 | GalleryResize();
|
2854 | });
|
2855 | }
|
2856 | break;
|
2857 | case 'FULLCONTENT':
|
2858 | default:
|
2859 | break;
|
2860 | }
|
2861 | }
|
2862 |
|
2863 |
|
2864 |
|
2865 | function breadcrumbAdd( albumIdx ) {
|
2866 |
|
2867 | var ic='';
|
2868 | if( !G.O.breadcrumbHideIcons ) {
|
2869 | ic=G.O.icons.breadcrumbAlbum;
|
2870 | if( albumIdx == 0 ) {
|
2871 | ic=G.O.icons.breadcrumbHome;
|
2872 | }
|
2873 | }
|
2874 | var $newDiv =jQuery('<div class="oneItem">'+ic + G.I[albumIdx].title+'</div>').appendTo(G.GOM.navigationBar.$newContent.find('.nGY2Breadcrumb'));
|
2875 | if( G.O.breadcrumbOnlyCurrentLevel ) {
|
2876 |
|
2877 | if( albumIdx == 0 ) {
|
2878 |
|
2879 | jQuery($newDiv).data('albumID','0');
|
2880 | }
|
2881 | else {
|
2882 | jQuery($newDiv).data('albumID',G.I[albumIdx].albumID);
|
2883 | }
|
2884 | }
|
2885 | else {
|
2886 |
|
2887 | jQuery($newDiv).data('albumID',G.I[albumIdx].GetID());
|
2888 | }
|
2889 | $newDiv.click(function() {
|
2890 | var cAlbumID=jQuery(this).data('albumID');
|
2891 | DisplayAlbum('-1', cAlbumID);
|
2892 | return;
|
2893 | });
|
2894 | }
|
2895 |
|
2896 |
|
2897 | function breadcrumbAddSeparator( lastAlbumID ) {
|
2898 | 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'));
|
2899 | jQuery($newSep).data('albumIdx',lastAlbumID);
|
2900 | $newSep.click(function() {
|
2901 | var sepAlbumIdx=jQuery(this).data('albumIdx');
|
2902 | DisplayAlbum('-1', G.I[sepAlbumIdx].GetID());
|
2903 | return;
|
2904 | });
|
2905 | }
|
2906 |
|
2907 |
|
2908 |
|
2909 |
|
2910 | function GalleryNavigationBar( albumIdx ) {
|
2911 |
|
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 |
|
2917 |
|
2918 |
|
2919 |
|
2920 |
|
2921 |
|
2922 |
|
2923 |
|
2924 |
|
2925 |
|
2926 |
|
2927 | G.GOM.navigationBar.$newContent=jQuery('<div class="nGY2Navigationbar"></div>');
|
2928 |
|
2929 |
|
2930 |
|
2931 |
|
2932 | if( G.O.displayBreadcrumb == true && !G.O.thumbnailAlbumDisplayImage) {
|
2933 |
|
2934 | var newLevel = 0,
|
2935 | lstItems=[];
|
2936 | if( albumIdx != 0 ) {
|
2937 | var l=G.I.length,
|
2938 | parentID=0;
|
2939 |
|
2940 | lstItems.push(albumIdx);
|
2941 | var curIdx=albumIdx;
|
2942 | newLevel++;
|
2943 |
|
2944 | while( G.I[curIdx].albumID != 0 && G.I[curIdx].albumID != -1) {
|
2945 | for(var i=1; i < l; i++ ) {
|
2946 | if( G.I[i].GetID() == G.I[curIdx].albumID ) {
|
2947 | curIdx=i;
|
2948 | lstItems.push(curIdx);
|
2949 | newLevel++;
|
2950 | break;
|
2951 | }
|
2952 | }
|
2953 | }
|
2954 | }
|
2955 |
|
2956 |
|
2957 | if( !(G.O.breadcrumbAutoHideTopLevel && newLevel == 0) ) {
|
2958 | BreadcrumbBuild( lstItems );
|
2959 | }
|
2960 | }
|
2961 |
|
2962 |
|
2963 |
|
2964 | if( G.galleryFilterTags.Get() != false ) {
|
2965 | var nTags=G.I[albumIdx].albumTagList.length;
|
2966 | if( nTags > 0 ) {
|
2967 | for(var i=0; i < nTags; i++ ) {
|
2968 | var s=G.I[albumIdx].albumTagList[i];
|
2969 | var ic=G.O.icons.navigationFilterUnselected;
|
2970 | var tagClass='Unselected';
|
2971 | if( jQuery.inArray(s, G.I[albumIdx].albumTagListSel) >= 0 ) {
|
2972 | tagClass='Selected';
|
2973 | ic=G.O.icons.navigationFilterSelected;
|
2974 | }
|
2975 | var $newTag=jQuery('<div class="nGY2NavigationbarItem nGY2NavFilter'+tagClass+'">'+ic+' '+s+'</div>').appendTo(G.GOM.navigationBar.$newContent);
|
2976 | $newTag.click(function() {
|
2977 | var $this=jQuery(this);
|
2978 | var tag=$this.text().replace(/^\s*|\s*$/, '');
|
2979 |
|
2980 | if( $this.hasClass('nGY2NavFilterUnselected') ){
|
2981 | G.I[albumIdx].albumTagListSel.push(tag);
|
2982 | }
|
2983 | else {
|
2984 | var tidx=jQuery.inArray(tag,G.I[albumIdx].albumTagListSel);
|
2985 | if( tidx != -1 ) {
|
2986 | G.I[albumIdx].albumTagListSel.splice(tidx,1);
|
2987 | }
|
2988 | }
|
2989 | $this.toggleClass('nGY2NavFilters-oneTagUnselected nGY2NavFilters-oneTagSelected');
|
2990 | DisplayAlbum('-1', G.I[albumIdx].GetID());
|
2991 | });
|
2992 | }
|
2993 | var $newClearFilter=jQuery('<div class="nGY2NavigationbarItem nGY2NavFilterSelectAll">'+G.O.icons.navigationFilterSelectedAll+'</div>').appendTo(G.GOM.navigationBar.$newContent);
|
2994 | $newClearFilter.click(function() {
|
2995 | var nTags=G.I[albumIdx].albumTagList.length;
|
2996 | G.I[albumIdx].albumTagListSel=[];
|
2997 | for(var i=0; i <nTags; i++ ) {
|
2998 | var s=G.I[albumIdx].albumTagList[i];
|
2999 | G.I[albumIdx].albumTagListSel.push(s);
|
3000 | }
|
3001 | DisplayAlbum('-1', G.I[albumIdx].GetID());
|
3002 | });
|
3003 | }
|
3004 | }
|
3005 |
|
3006 | }
|
3007 |
|
3008 | function BreadcrumbBuild(lstItems) {
|
3009 |
|
3010 |
|
3011 | jQuery('<div class="nGY2NavigationbarItem nGY2Breadcrumb"></div>').appendTo(G.GOM.navigationBar.$newContent);
|
3012 |
|
3013 |
|
3014 | if( G.O.breadcrumbOnlyCurrentLevel ) {
|
3015 |
|
3016 | if( lstItems.length == 0 ) {
|
3017 | breadcrumbAdd(0);
|
3018 | }
|
3019 | else {
|
3020 | var last=lstItems.length-1;
|
3021 | if( lstItems.length == 1 ) {
|
3022 | breadcrumbAddSeparator(0);
|
3023 | }
|
3024 | else {
|
3025 | breadcrumbAddSeparator(lstItems[0]);
|
3026 | }
|
3027 | breadcrumbAdd(lstItems[0]);
|
3028 | }
|
3029 | }
|
3030 | else {
|
3031 |
|
3032 | breadcrumbAdd(0);
|
3033 | if( lstItems.length > 0 ) {
|
3034 | breadcrumbAddSeparator(0);
|
3035 | for(var i=lstItems.length-1; i>=0 ; i-- ) {
|
3036 | breadcrumbAdd(lstItems[i]);
|
3037 | if( i > 0 ) {
|
3038 | breadcrumbAddSeparator(lstItems[i-1]);
|
3039 | }
|
3040 | }
|
3041 | }
|
3042 | }
|
3043 |
|
3044 | }
|
3045 |
|
3046 |
|
3047 |
|
3048 | function ManagePagination( albumIdx ) {
|
3049 |
|
3050 | G.$E.conTnBottom.css('opacity', 0);
|
3051 | G.$E.conTnBottom.children().remove();
|
3052 |
|
3053 | if( G.GOM.items.length == 0 ) { return; }
|
3054 |
|
3055 |
|
3056 | var nbPages=Math.ceil((G.GOM.items[G.GOM.items.length - 1].row + 1)/G.galleryMaxRows.Get());
|
3057 |
|
3058 |
|
3059 | if( nbPages == 1 ) { return; }
|
3060 |
|
3061 |
|
3062 | if( G.GOM.pagination.currentPage > (nbPages-1) ) {
|
3063 | G.GOM.pagination.currentPage = nbPages-1;
|
3064 | }
|
3065 |
|
3066 | GalleryRenderGetInterval();
|
3067 |
|
3068 | if( G.GOM.displayInterval.len == 0 ) { return; }
|
3069 |
|
3070 |
|
3071 | if( G.O.galleryPaginationMode == 'NUMBERS' && G.GOM.pagination.currentPage > 0 ) {
|
3072 | var $eltPrev = jQuery('<div class="nGY2PaginationPrev">'+G.O.icons.paginationPrevious+'</div>').appendTo(G.$E.conTnBottom);
|
3073 | $eltPrev.click(function(e) {
|
3074 | paginationPreviousPage();
|
3075 | });
|
3076 | }
|
3077 |
|
3078 | var firstPage = 0;
|
3079 | var lastPage = nbPages;
|
3080 | if( G.O.galleryPaginationMode != 'NUMBERS' ) {
|
3081 |
|
3082 | firstPage = 0;
|
3083 | }
|
3084 | else {
|
3085 |
|
3086 | var vp = G.O.paginationVisiblePages;
|
3087 | var numberOfPagesToDisplay = G.O.paginationVisiblePages;
|
3088 | if( numberOfPagesToDisplay >= nbPages ) {
|
3089 | firstPage = 0;
|
3090 | }
|
3091 | else {
|
3092 |
|
3093 | var nbBeforeAfter = 0;
|
3094 | if( isOdd(numberOfPagesToDisplay) ) {
|
3095 | nbBeforeAfter = (numberOfPagesToDisplay + 1) / 2;
|
3096 | }
|
3097 | else {
|
3098 | nbBeforeAfter = numberOfPagesToDisplay / 2;
|
3099 | }
|
3100 |
|
3101 | if( G.GOM.pagination.currentPage < nbBeforeAfter ) {
|
3102 | firstPage = 0;
|
3103 | lastPage = numberOfPagesToDisplay - 1;
|
3104 | if( lastPage > nbPages ) {
|
3105 | lastPage = nbPages - 1;
|
3106 | }
|
3107 | }
|
3108 | else {
|
3109 | firstPage = G.GOM.pagination.currentPage - nbBeforeAfter;
|
3110 | lastPage = firstPage + numberOfPagesToDisplay;
|
3111 | if( lastPage > nbPages ) {
|
3112 | lastPage = nbPages - 1;
|
3113 | }
|
3114 | }
|
3115 |
|
3116 | if( (lastPage - firstPage) < numberOfPagesToDisplay ) {
|
3117 | firstPage = lastPage - numberOfPagesToDisplay;
|
3118 | if( firstPage < 0 ) {
|
3119 | firstPage = 0;
|
3120 | }
|
3121 | }
|
3122 |
|
3123 | }
|
3124 | }
|
3125 |
|
3126 |
|
3127 | for(var i = firstPage; i < lastPage; i++ ) {
|
3128 | var c = '';
|
3129 | var p = '';
|
3130 |
|
3131 | switch( G.O.galleryPaginationMode ) {
|
3132 | case 'NUMBERS':
|
3133 | c = 'nGY2paginationItem';
|
3134 | p = i + 1;
|
3135 | break;
|
3136 | case 'DOTS':
|
3137 | c = 'nGY2paginationDot';
|
3138 | break;
|
3139 | case 'RECTANGLES':
|
3140 | c = 'nGY2paginationRectangle';
|
3141 | break;
|
3142 | }
|
3143 | if( i == G.GOM.pagination.currentPage ) {
|
3144 | c += 'CurrentPage';
|
3145 | }
|
3146 |
|
3147 | var elt$ = jQuery('<div class="' + c + '">' + p + '</div>').appendTo(G.$E.conTnBottom);
|
3148 | elt$.data('pageNumber', i );
|
3149 | elt$.click( function(e) {
|
3150 | G.GOM.pagination.currentPage = jQuery(this).data('pageNumber');
|
3151 | TriggerCustomEvent('pageChanged');
|
3152 |
|
3153 |
|
3154 | if( !inViewportVert(G.$E.base, 0) ) {
|
3155 | $('html, body').animate({scrollTop: G.$E.base.offset().top}, 200);
|
3156 | }
|
3157 | GalleryDisplayPart1( true );
|
3158 | GalleryDisplayPart2( true );
|
3159 | });
|
3160 |
|
3161 | }
|
3162 |
|
3163 |
|
3164 | if( G.O.galleryPaginationMode == 'NUMBERS' && (G.GOM.pagination.currentPage + 1) < nbPages ) {
|
3165 | var $eltNext = jQuery('<div class="nGY2PaginationNext">' + G.O.icons.paginationNext + '</div>').appendTo(G.$E.conTnBottom);
|
3166 | $eltNext.click( function(e) {
|
3167 | paginationNextPage();
|
3168 | });
|
3169 | }
|
3170 |
|
3171 | G.$E.conTnBottom.css('opacity', 1);
|
3172 |
|
3173 | }
|
3174 | function isOdd(num) { return (num % 2) == 1;}
|
3175 |
|
3176 |
|
3177 | function paginationNextPage() {
|
3178 | var aIdx = G.GOM.albumIdx,
|
3179 | n1 = 0;
|
3180 | ThumbnailHoverOutAll();
|
3181 |
|
3182 |
|
3183 | if( G.galleryMaxRows.Get() > 0 ) {
|
3184 |
|
3185 | n1 = (G.GOM.items[G.GOM.items.length - 1].row + 1) / G.galleryMaxRows.Get();
|
3186 | }
|
3187 | var n2 = Math.ceil(n1);
|
3188 | var pn = G.GOM.pagination.currentPage;
|
3189 | if( pn < (n2-1) ) {
|
3190 | pn++;
|
3191 | }
|
3192 | else {
|
3193 | pn = 0;
|
3194 | }
|
3195 |
|
3196 | G.GOM.pagination.currentPage = pn;
|
3197 | TriggerCustomEvent('pageChanged');
|
3198 |
|
3199 |
|
3200 | if( !inViewportVert(G.$E.base, 0) ) {
|
3201 | $('html, body').animate({scrollTop: G.$E.base.offset().top}, 200);
|
3202 | }
|
3203 | GalleryDisplayPart1( true );
|
3204 | GalleryDisplayPart2( true );
|
3205 | }
|
3206 |
|
3207 |
|
3208 | function paginationPreviousPage() {
|
3209 |
|
3210 | var aIdx = G.GOM.albumIdx,
|
3211 | n1 = 0;
|
3212 |
|
3213 | ThumbnailHoverOutAll();
|
3214 |
|
3215 |
|
3216 | if( G.galleryMaxRows.Get() > 0 ) {
|
3217 |
|
3218 | n1 = (G.GOM.items[G.GOM.items.length - 1].row + 1) / G.galleryMaxRows.Get();
|
3219 | }
|
3220 | var n2 = Math.ceil(n1);
|
3221 |
|
3222 |
|
3223 | var pn = G.GOM.pagination.currentPage;
|
3224 | if( pn > 0 ) {
|
3225 | pn--;
|
3226 | }
|
3227 | else {
|
3228 | pn = n2 - 1;
|
3229 | }
|
3230 |
|
3231 | G.GOM.pagination.currentPage = pn;
|
3232 | TriggerCustomEvent('pageChanged');
|
3233 |
|
3234 |
|
3235 | if( !inViewportVert(G.$E.base, 0) ) {
|
3236 | $('html, body').animate({scrollTop: G.$E.base.offset().top}, 200);
|
3237 | }
|
3238 | GalleryDisplayPart1( true );
|
3239 | GalleryDisplayPart2( true );
|
3240 | }
|
3241 |
|
3242 |
|
3243 | function GalleryRenderGetInterval() {
|
3244 | G.GOM.displayInterval.from = 0;
|
3245 | G.GOM.displayInterval.len = G.I.length;
|
3246 |
|
3247 | switch( G.galleryDisplayMode.Get() ) {
|
3248 | case 'PAGINATION':
|
3249 | if( G.layout.support.rows ) {
|
3250 | var nbTn = G.GOM.items.length;
|
3251 | var firstRow = G.GOM.pagination.currentPage * G.galleryMaxRows.Get();
|
3252 | var lastRow = firstRow + G.galleryMaxRows.Get();
|
3253 | var firstTn = -1;
|
3254 | G.GOM.displayInterval.len = 0;
|
3255 | for( var i = 0; i < nbTn ; i++ ) {
|
3256 | var curTn = G.GOM.items[i];
|
3257 | if( curTn.row >= firstRow && curTn.row < lastRow ) {
|
3258 | if( firstTn == -1 ) {
|
3259 | G.GOM.displayInterval.from = i;
|
3260 | firstTn = i;
|
3261 | }
|
3262 | G.GOM.displayInterval.len++;
|
3263 | }
|
3264 | }
|
3265 | }
|
3266 | break;
|
3267 | case 'MOREBUTTON':
|
3268 | if( G.layout.support.rows ) {
|
3269 | var nbTn = G.GOM.items.length;
|
3270 | var lastRow = G.O.galleryDisplayMoreStep * (G.GOM.displayedMoreSteps+1);
|
3271 | G.GOM.displayInterval.len = 0;
|
3272 | for( var i = 0; i < nbTn ; i++ ) {
|
3273 | var curTn = G.GOM.items[i];
|
3274 | if( curTn.row < lastRow ) {
|
3275 | G.GOM.displayInterval.len++;
|
3276 | }
|
3277 | }
|
3278 | }
|
3279 | break;
|
3280 | case 'ROWS':
|
3281 | if( G.layout.support.rows ) {
|
3282 | var nbTn = G.GOM.items.length;
|
3283 | var lastRow = G.galleryMaxRows.Get();
|
3284 | if( G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1 ) {
|
3285 | if( lastRow > (G.GOM.lastFullRow + 1) ) {
|
3286 | lastRow = G.GOM.lastFullRow + 1;
|
3287 | }
|
3288 | }
|
3289 | G.GOM.displayInterval.len = 0;
|
3290 | for( var i = 0; i < nbTn ; i++ ) {
|
3291 | var curTn = G.GOM.items[i];
|
3292 | if( curTn.row < lastRow ) {
|
3293 | G.GOM.displayInterval.len++;
|
3294 | }
|
3295 | }
|
3296 | }
|
3297 | break;
|
3298 | default:
|
3299 | case 'FULLCONTENT':
|
3300 | if( G.layout.support.rows && G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1 ) {
|
3301 | var nbTn = G.GOM.items.length;
|
3302 | var lastRow = G.GOM.lastFullRow + 1;
|
3303 | G.GOM.displayInterval.len = 0;
|
3304 | for( var i = 0; i < nbTn ; i++ ) {
|
3305 | var curTn = G.GOM.items[i];
|
3306 | if( curTn.row < lastRow ) {
|
3307 | G.GOM.displayInterval.len++;
|
3308 | }
|
3309 | }
|
3310 | }
|
3311 | break;
|
3312 | }
|
3313 | }
|
3314 |
|
3315 |
|
3316 |
|
3317 | function GalleryRender( albumIdx ) {
|
3318 | TriggerCustomEvent('galleryRenderStart');
|
3319 |
|
3320 | clearTimeout(G.GOM.slider.timerID);
|
3321 | G.GOM.slider.hostIdx = -1;
|
3322 |
|
3323 | var fu=G.O.fnGalleryRenderStart;
|
3324 | if( fu !== null ) {
|
3325 | typeof fu == 'function' ? fu(albumIdx) : window[fu](albumIdx);
|
3326 | }
|
3327 |
|
3328 | G.layout.SetEngine();
|
3329 | G.galleryResizeEventEnabled = false;
|
3330 | G.GOM.albumIdx = -1;
|
3331 | G.GOM.lastDisplayedIdx = -1;
|
3332 |
|
3333 |
|
3334 | if( G.$E.conTnBottom !== undefined ) {
|
3335 |
|
3336 | G.$E.conTnBottom.empty();
|
3337 | }
|
3338 |
|
3339 |
|
3340 | GalleryNavigationBar(albumIdx);
|
3341 |
|
3342 | if( G.GOM.firstDisplay ) {
|
3343 | G.GOM.firstDisplay = false;
|
3344 | var d = Date.now()-G.GOM.firstDisplayTime;
|
3345 | if( d < G.O.galleryRenderDelay ) {
|
3346 |
|
3347 | requestTimeout( function() { GalleryRenderPart1( albumIdx )}, G.O.galleryRenderDelay-d );
|
3348 | }
|
3349 | else {
|
3350 | GalleryRenderPart1( albumIdx );
|
3351 | }
|
3352 | G.O.galleryRenderDelay = 0;
|
3353 |
|
3354 | }
|
3355 | else {
|
3356 | var hideNavigationBar = false;
|
3357 | if( G.GOM.navigationBar.$newContent.children().length == 0 ) {
|
3358 | hideNavigationBar = true;
|
3359 | }
|
3360 |
|
3361 |
|
3362 | var tweenable = new NGTweenable();
|
3363 | tweenable.tween({
|
3364 | from: { 'opacity': 1 },
|
3365 | to: { 'opacity': 0 },
|
3366 | duration: 300,
|
3367 | easing: 'easeInQuart',
|
3368 | attachment: { h: hideNavigationBar },
|
3369 | step: function (state, att) {
|
3370 |
|
3371 | G.$E.conTnParent.css({'opacity': state.opacity });
|
3372 | if( att.h ) {
|
3373 | G.$E.conNavigationBar.css({ 'opacity': state.opacity });
|
3374 | }
|
3375 |
|
3376 | },
|
3377 | finish: function (state, att) {
|
3378 |
|
3379 | if( att.h ) {
|
3380 | G.$E.conNavigationBar.css({ 'opacity': 0, 'display': 'none' });
|
3381 | }
|
3382 |
|
3383 | var galleryOTop = G.$E.base.offset().top;
|
3384 | if( galleryOTop < G.GOM.cache.viewport.t ) {
|
3385 |
|
3386 | jQuery('html, body').animate({scrollTop: galleryOTop}, 500, "linear", function() {
|
3387 | GalleryRenderPart1( albumIdx );
|
3388 | });
|
3389 | }
|
3390 | else {
|
3391 | GalleryRenderPart1( albumIdx );
|
3392 | }
|
3393 |
|
3394 | }
|
3395 | });
|
3396 | }
|
3397 | }
|
3398 |
|
3399 |
|
3400 | function GalleryRenderPart1( albumIdx ) {
|
3401 |
|
3402 | var oldN = G.$E.conNavigationBar.children().length;
|
3403 | G.$E.conNavigationBar.empty();
|
3404 | G.GOM.navigationBar.$newContent.children().clone(true,true).appendTo(G.$E.conNavigationBar);
|
3405 |
|
3406 | if( G.$E.conNavigationBar.children().length > 0 && oldN == 0 ) {
|
3407 | G.$E.conNavigationBar.css({ 'opacity': 0, 'display': 'block' });
|
3408 | var tweenable = new NGTweenable();
|
3409 | tweenable.tween({
|
3410 | from: { opacity: 0 },
|
3411 | to: { opacity: 1 },
|
3412 | duration: 200,
|
3413 | easing: 'easeInQuart',
|
3414 | step: function (state) {
|
3415 |
|
3416 | G.$E.conNavigationBar.css( state );
|
3417 |
|
3418 | },
|
3419 | finish: function (state) {
|
3420 |
|
3421 | G.$E.conNavigationBar.css({ 'opacity': 1 });
|
3422 |
|
3423 |
|
3424 |
|
3425 | requestTimeout(function(){ GalleryRenderPart2(albumIdx) }, 60);
|
3426 |
|
3427 | }
|
3428 | });
|
3429 | }
|
3430 | else {
|
3431 |
|
3432 |
|
3433 |
|
3434 | requestTimeout(function(){ GalleryRenderPart2(albumIdx) }, 60);
|
3435 | }
|
3436 |
|
3437 | }
|
3438 |
|
3439 |
|
3440 | function GalleryRenderPart2(albumIdx) {
|
3441 | G.GOM.lastZIndex = parseInt(G.$E.base.css('z-index'));
|
3442 | if( isNaN(G.GOM.lastZIndex) ) {
|
3443 | G.GOM.lastZIndex=0;
|
3444 | }
|
3445 | G.$E.conTnParent.css({ 'opacity': 0 });
|
3446 | G.$E.conTn.off().empty();
|
3447 | var l = G.I.length;
|
3448 | for( var i = 0; i < l ; i++ ) {
|
3449 |
|
3450 | var item = G.I[i];
|
3451 | item.hovered = false;
|
3452 | item.$elt = null;
|
3453 | item.$Elts = [];
|
3454 | item.eltTransform = [];
|
3455 | item.eltFilter = [];
|
3456 | item.width = 0;
|
3457 | item.height = 0;
|
3458 | item.left = 0;
|
3459 | item.top = 0;
|
3460 | item.resizedContentWidth = 0;
|
3461 | item.resizedContentHeight = 0;
|
3462 | item.thumbnailImgRevealed = false;
|
3463 | }
|
3464 |
|
3465 | if( G.CSStransformName == null ) {
|
3466 | G.$E.conTn.css('left', '0px');
|
3467 | }
|
3468 | else {
|
3469 |
|
3470 | G.$E.conTn.css( G.CSStransformName, 'none');
|
3471 | }
|
3472 |
|
3473 |
|
3474 | requestTimeout(function(){ GalleryRenderPart3(albumIdx) }, 60);
|
3475 |
|
3476 |
|
3477 | }
|
3478 |
|
3479 |
|
3480 | function GalleryRenderPart3(albumIdx) {
|
3481 | var d = new Date();
|
3482 |
|
3483 | G.$E.conTnParent.css( 'opacity', 1);
|
3484 |
|
3485 | G.GOM.items = [];
|
3486 | G.GOM.displayedMoreSteps = 0;
|
3487 |
|
3488 | if( G.O.thumbnailLabel.get('position') == 'onBottom' ) {
|
3489 |
|
3490 | G.tn.labelHeight[G.GOM.curNavLevel]=ThumbnailGetLabelHeight();
|
3491 | }
|
3492 | else {
|
3493 | G.tn.labelHeight[G.GOM.curNavLevel]=0;
|
3494 | }
|
3495 | G.GOM.albumIdx=albumIdx;
|
3496 |
|
3497 | TriggerCustomEvent('galleryRenderEnd');
|
3498 | var fu=G.O.fnGalleryRenderEnd;
|
3499 | if( fu !== null ) {
|
3500 | typeof fu == 'function' ? fu(albumIdx) : window[fu](albumIdx);
|
3501 | }
|
3502 |
|
3503 |
|
3504 | if( GalleryPopulateGOM() ) {
|
3505 |
|
3506 |
|
3507 | GallerySetLayout();
|
3508 |
|
3509 |
|
3510 | GalleryAppear();
|
3511 |
|
3512 | GalleryDisplayPart1( false );
|
3513 |
|
3514 | requestTimeout(function(){ GalleryDisplayPart2( false ) }, 120);
|
3515 | }
|
3516 | else {
|
3517 | G.galleryResizeEventEnabled = true;
|
3518 | }
|
3519 |
|
3520 | if( G.O.debugMode ) { console.log('GalleryRenderPart3: '+ (new Date()-d)); }
|
3521 |
|
3522 | }
|
3523 |
|
3524 |
|
3525 |
|
3526 | function GalleryResize() {
|
3527 | var d = new Date();
|
3528 | G.galleryResizeEventEnabled = false;
|
3529 |
|
3530 | if( GallerySetLayout() == false ) {
|
3531 | G.galleryResizeEventEnabled = true;
|
3532 | if( G.O.debugMode ) { console.log('GalleryResize1: '+ (new Date()-d)); }
|
3533 | return;
|
3534 | }
|
3535 | if( G.O.debugMode ) { console.log('GalleryResizeSetLayout: '+ (new Date()-d)); }
|
3536 |
|
3537 | GalleryDisplayPart1( false );
|
3538 | GalleryDisplayPart2( false );
|
3539 |
|
3540 | if( G.O.debugMode ) { console.log('GalleryResizeFull: '+ (new Date()-d)); }
|
3541 | }
|
3542 |
|
3543 |
|
3544 |
|
3545 |
|
3546 | function GalleryPopulateGOM() {
|
3547 |
|
3548 | var preloadImages = '';
|
3549 | var imageSizeRequested = false;
|
3550 | var albumID = G.I[G.GOM.albumIdx].GetID();
|
3551 | var l = G.I.length;
|
3552 | var cnt = 0;
|
3553 |
|
3554 | for( var idx = 0; idx < l; idx++ ) {
|
3555 | var item = G.I[idx];
|
3556 |
|
3557 | if( item.isToDisplay(albumID) ) {
|
3558 | var w = item.thumbImg().width;
|
3559 | var h = item.thumbImg().height;
|
3560 |
|
3561 | if( G.layout.prerequisite.imageSize && ( w == 0 || h == 0) ) {
|
3562 |
|
3563 | imageSizeRequested = true;
|
3564 | preloadImages += '<img src="'+item.thumbImg().src+'" data-idx="'+cnt+'" data-albumidx="'+G.GOM.albumIdx+'">';
|
3565 | }
|
3566 |
|
3567 |
|
3568 | if( h == 0 ) {
|
3569 | h = G.tn.defaultSize.getHeight();
|
3570 | }
|
3571 | if( w == 0 ) {
|
3572 | w = G.tn.defaultSize.getWidth();
|
3573 | }
|
3574 | var tn = new G.GOM.GTn(idx, w, h);
|
3575 | G.GOM.items.push(tn);
|
3576 | cnt++;
|
3577 | }
|
3578 | }
|
3579 |
|
3580 | TriggerCustomEvent('galleryObjectModelBuilt');
|
3581 | var fu = G.O.fnGalleryObjectModelBuilt;
|
3582 | if( fu !== null ) {
|
3583 | typeof fu == 'function' ? fu() : window[fu]();
|
3584 | }
|
3585 |
|
3586 | if( imageSizeRequested ) {
|
3587 |
|
3588 | var $newImg = jQuery(preloadImages);
|
3589 | var gi_imgLoad = ngimagesLoaded( $newImg );
|
3590 | $newImg = null;
|
3591 | gi_imgLoad.on( 'progress', function( instance, image ) {
|
3592 |
|
3593 | if( image.isLoaded ) {
|
3594 | var idx = image.img.getAttribute('data-idx');
|
3595 | var albumIdx = image.img.getAttribute('data-albumidx');
|
3596 | if( albumIdx == G.GOM.albumIdx ) {
|
3597 |
|
3598 | var curTn = G.GOM.items[idx];
|
3599 | curTn.imageWidth = image.img.naturalWidth;
|
3600 | curTn.imageHeight = image.img.naturalHeight;
|
3601 | var item = G.I[curTn.thumbnailIdx];
|
3602 | item.thumbs.width[G.GOM.curNavLevel][G.GOM.curWidth] = curTn.imageWidth;
|
3603 | item.thumbs.height[G.GOM.curNavLevel][G.GOM.curWidth] = curTn.imageHeight;
|
3604 |
|
3605 |
|
3606 | G.GalleryResizeThrottled();
|
3607 |
|
3608 |
|
3609 | var object = item.thumbs.width.l1;
|
3610 | for (var property in object) {
|
3611 | if (object.hasOwnProperty(property)) {
|
3612 | if( property != G.GOM.curWidth ) {
|
3613 | if( G.tn.settings.width.l1[property] == G.tn.settings.getW() && G.tn.settings.height.l1[property] == G.tn.settings.getH() ) {
|
3614 | item.thumbs.width.l1[property] = curTn.imageWidth;
|
3615 | item.thumbs.height.l1[property] = curTn.imageHeight;
|
3616 | }
|
3617 | }
|
3618 | }
|
3619 | }
|
3620 | object = item.thumbs.width.lN;
|
3621 | for (var property in object) {
|
3622 | if (object.hasOwnProperty(property)) {
|
3623 | if( property != G.GOM.curWidth ) {
|
3624 | if( G.tn.settings.width.lN[property] == G.tn.settings.getW() && G.tn.settings.height.lN[property] == G.tn.settings.getH() ) {
|
3625 | item.thumbs.width.lN[property] = curTn.imageWidth;
|
3626 | item.thumbs.height.lN[property] = curTn.imageHeight;
|
3627 | }
|
3628 | }
|
3629 | }
|
3630 | }
|
3631 | }
|
3632 | }
|
3633 | });
|
3634 | G.galleryResizeEventEnabled = true;
|
3635 | return false;
|
3636 | }
|
3637 | else {
|
3638 | return true;
|
3639 | }
|
3640 |
|
3641 | }
|
3642 |
|
3643 |
|
3644 | function GallerySetLayout() {
|
3645 | var r = true;
|
3646 |
|
3647 | G.GOM.cache.areaWidth = G.$E.conTnParent.width();
|
3648 | G.GOM.displayArea = { width:0, height:0 };
|
3649 |
|
3650 | switch( G.layout.engine ) {
|
3651 | case 'JUSTIFIED':
|
3652 | r = GallerySetLayoutWidthtAuto();
|
3653 | break;
|
3654 | case 'CASCADING':
|
3655 | r = GallerySetLayoutHeightAuto();
|
3656 | break;
|
3657 | case 'MOSAIC':
|
3658 | r = GallerySetLayoutMosaic();
|
3659 | break;
|
3660 | case 'GRID':
|
3661 | default:
|
3662 | r = GallerySetLayoutGrid();
|
3663 | break;
|
3664 | }
|
3665 |
|
3666 | TriggerCustomEvent('galleryLayoutApplied');
|
3667 | var fu = G.O.fnGalleryLayoutApplied;
|
3668 | if( fu !== null ) {
|
3669 | typeof fu == 'function' ? fu() : window[fu]();
|
3670 | }
|
3671 | return r;
|
3672 |
|
3673 | }
|
3674 |
|
3675 |
|
3676 |
|
3677 | function GallerySetLayoutHeightAuto() {
|
3678 | var curCol = 0,
|
3679 | areaWidth = G.GOM.cache.areaWidth,
|
3680 | curRow = 0,
|
3681 | colHeight = [],
|
3682 | maxCol = NbThumbnailsPerRow(areaWidth),
|
3683 | gutterWidth = 0,
|
3684 | gutterHeight = G.tn.opt.Get('gutterHeight');
|
3685 | var w = 0;
|
3686 | var scaleFactor = 1;
|
3687 | var tnWidth = G.tn.defaultSize.getOuterWidth();
|
3688 | var nbTn = G.GOM.items.length;
|
3689 | var curPosY = 0;
|
3690 |
|
3691 | if( G.O.thumbnailAlignment == 'justified' ) {
|
3692 | maxCol = Math.min(maxCol, nbTn);
|
3693 | gutterWidth = ( maxCol == 1 ? 0 : (areaWidth - (maxCol * tnWidth) ) / (maxCol - 1) );
|
3694 | }
|
3695 | else {
|
3696 | gutterWidth=G.tn.opt.Get('gutterWidth');
|
3697 | }
|
3698 |
|
3699 |
|
3700 | var borderWidth = G.tn.borderWidth * 2;
|
3701 | var borderHeight = G.tn.borderHeight * 2;
|
3702 |
|
3703 | G.GOM.lastFullRow=-1;
|
3704 |
|
3705 |
|
3706 | if( G.O.thumbnailAlignment == 'fillWidth' ) {
|
3707 |
|
3708 | var totalGutterWidth = (maxCol - 1) * gutterWidth;
|
3709 | scaleFactor = (areaWidth - totalGutterWidth) / (maxCol * tnWidth);
|
3710 | if( scaleFactor > 1 ) {
|
3711 | maxCol++;
|
3712 | }
|
3713 | totalGutterWidth = (maxCol - 1) * gutterWidth;
|
3714 | scaleFactor = Math.min( (areaWidth - totalGutterWidth) / (maxCol*tnWidth), 1);
|
3715 | }
|
3716 |
|
3717 |
|
3718 | tnWidth = tnWidth * scaleFactor;
|
3719 | var contentWidth = tnWidth - borderWidth;
|
3720 |
|
3721 |
|
3722 | var baseHeight = G.tn.opt.Get('baseGridHeight') * scaleFactor;
|
3723 | for( var i = 0; i < nbTn ; i++ ) {
|
3724 | var curTn = G.GOM.items[i];
|
3725 | if( curTn.deleted == true ) { break; }
|
3726 | if( curTn.imageHeight > 0 && curTn.imageWidth > 0 ) {
|
3727 | var curPosX = 0,
|
3728 | curPosY = 0;
|
3729 | var imageRatio = curTn.imageHeight / curTn.imageWidth;
|
3730 |
|
3731 | curTn.resizedContentWidth = contentWidth;
|
3732 | curTn.resizedContentHeight = curTn.resizedContentWidth * imageRatio;
|
3733 | if( baseHeight > 0 ) {
|
3734 |
|
3735 | var t= Math.max( Math.trunc(curTn.resizedContentHeight/baseHeight), 1) ;
|
3736 | curTn.resizedContentHeight = baseHeight * t + ((t-1)*(borderHeight+gutterHeight));
|
3737 | }
|
3738 |
|
3739 | curTn.height = curTn.resizedContentHeight + borderHeight + G.tn.labelHeight.get();
|
3740 | curTn.width = tnWidth;
|
3741 | curTn.row = 0;
|
3742 |
|
3743 | if( curRow == 0 ) {
|
3744 |
|
3745 | curPosX = curCol * (tnWidth + gutterWidth);
|
3746 | colHeight[curCol] = curTn.height + gutterHeight;
|
3747 |
|
3748 | curCol++;
|
3749 | if( curCol >= maxCol ) {
|
3750 | curCol = 0;
|
3751 | curRow++;
|
3752 | }
|
3753 | }
|
3754 | else {
|
3755 | var c=0,
|
3756 | minColHeight=colHeight[0];
|
3757 | for( var j = 1; j < maxCol; j++) {
|
3758 | if( (colHeight[j] + 5) < minColHeight ) {
|
3759 | minColHeight = colHeight[j];
|
3760 | c = j;
|
3761 |
|
3762 | }
|
3763 | }
|
3764 | curPosY = colHeight[c];
|
3765 | curPosX = c * (tnWidth + gutterWidth);
|
3766 | colHeight[c] = curPosY + curTn.height + gutterHeight;
|
3767 | }
|
3768 |
|
3769 | var x = curPosX;
|
3770 | if( G.O.RTL) {
|
3771 | x= w - curPosX - tnWidth;
|
3772 | }
|
3773 |
|
3774 | curTn.left = x;
|
3775 | curTn.top = curPosY;
|
3776 | }
|
3777 | }
|
3778 |
|
3779 | G.GOM.displayArea.width= maxCol * (tnWidth + gutterWidth) - gutterWidth;
|
3780 | return true;
|
3781 | }
|
3782 |
|
3783 |
|
3784 |
|
3785 | function GallerySetLayoutWidthtAuto() {
|
3786 | var curWidth = 0,
|
3787 | areaWidth = G.GOM.cache.areaWidth,
|
3788 | lastPosX = 0,
|
3789 | curPosY = 0,
|
3790 | rowLastItem = [],
|
3791 | rowNum = 0,
|
3792 | rowHeight = [],
|
3793 | bNewRow = false,
|
3794 | cnt = 0,
|
3795 | gutterWidth = G.tn.opt.Get('gutterWidth'),
|
3796 | gutterHeight = G.tn.opt.Get('gutterHeight');
|
3797 |
|
3798 | var maxRowHeightVertical = 0;
|
3799 | var maxRowHeightHorizontal = 0;
|
3800 | var rowHasVertical = false;
|
3801 | var rowHasHorizontal = false;
|
3802 |
|
3803 | var tnHeight = G.tn.defaultSize.getOuterHeight();
|
3804 | var borderWidth = G.tn.borderWidth * 2;
|
3805 | var borderHeight = G.tn.borderHeight * 2;
|
3806 | var nbTnInCurrRow = 1;
|
3807 | var nbTn = G.GOM.items.length;
|
3808 |
|
3809 |
|
3810 | for( var i = 0; i < nbTn ; i++ ) {
|
3811 | var curTn = G.GOM.items[i];
|
3812 | if( curTn.deleted == true ) { break; }
|
3813 | if( curTn.imageWidth > 0 ) {
|
3814 | var imageRatio = curTn.imageWidth / curTn.imageHeight;
|
3815 | var imageWidth = Math.floor( tnHeight * imageRatio );
|
3816 |
|
3817 | if( bNewRow ) {
|
3818 | bNewRow = false;
|
3819 | rowNum++;
|
3820 | curWidth = 0;
|
3821 | rowHasVertical = false;
|
3822 | rowHasHorizontal = false;
|
3823 | nbTnInCurrRow = 1;
|
3824 | }
|
3825 |
|
3826 | if( curTn.imageHeight > curTn.imageWidth ) {
|
3827 | rowHasVertical = true;
|
3828 | }
|
3829 | else {
|
3830 | rowHasHorizontal = true;
|
3831 | }
|
3832 |
|
3833 | if( (curWidth + gutterWidth + imageWidth) < (areaWidth - (nbTnInCurrRow * borderWidth)) ) {
|
3834 |
|
3835 | curWidth += imageWidth + gutterWidth;
|
3836 | rowHeight[rowNum] = tnHeight;
|
3837 |
|
3838 |
|
3839 |
|
3840 | var rowHeightLimit = Math.max(rowHasVertical ? maxRowHeightVertical : 0, rowHasHorizontal ? maxRowHeightHorizontal : 0);
|
3841 | if( rowHeightLimit > 0 ) {
|
3842 | rowHeight[rowNum] = Math.min(rowHeight[rowNum], rowHeightLimit);
|
3843 | }
|
3844 |
|
3845 | rowLastItem[rowNum] = i;
|
3846 | }
|
3847 | else {
|
3848 |
|
3849 | curWidth += gutterWidth+imageWidth;
|
3850 | var ratio = (areaWidth - nbTnInCurrRow * borderWidth) / curWidth;
|
3851 | var rH = Math.floor(tnHeight * ratio);
|
3852 | rowHeight[rowNum] = rH;
|
3853 |
|
3854 |
|
3855 |
|
3856 | if( rowHasVertical ) {
|
3857 | maxRowHeightVertical = Math.max( maxRowHeightVertical, rH );
|
3858 | }
|
3859 | if( rowHasHorizontal ) {
|
3860 | maxRowHeightHorizontal = Math.max( maxRowHeightHorizontal, rH );
|
3861 | }
|
3862 |
|
3863 | rowLastItem[rowNum] = i;
|
3864 | bNewRow = true;
|
3865 | }
|
3866 | cnt++;
|
3867 | nbTnInCurrRow++;
|
3868 | }
|
3869 | }
|
3870 |
|
3871 | rowNum = 0;
|
3872 | curPosY = 0;
|
3873 | lastPosX = 0;
|
3874 | cnt = 0;
|
3875 |
|
3876 | G.GOM.lastFullRow = 0;
|
3877 |
|
3878 |
|
3879 | for( var i = 0; i < nbTn ; i++ ) {
|
3880 | var curTn = G.GOM.items[i];
|
3881 | if( curTn.imageWidth > 0 ) {
|
3882 | var imageRatio = curTn.imageWidth / curTn.imageHeight;
|
3883 | var imageWidth = Math.floor( imageRatio * rowHeight[rowNum] );
|
3884 |
|
3885 | if( i == rowLastItem[rowNum] ) {
|
3886 |
|
3887 | if( rowLastItem.length != (rowNum+1) ) {
|
3888 |
|
3889 | imageWidth = areaWidth - lastPosX - borderWidth;
|
3890 | }
|
3891 | else {
|
3892 |
|
3893 | if( (lastPosX + gutterWidth + imageWidth + borderWidth ) > areaWidth ) {
|
3894 |
|
3895 | imageWidth = areaWidth - lastPosX - borderWidth;
|
3896 | }
|
3897 | }
|
3898 | }
|
3899 |
|
3900 | var rh = parseInt( rowHeight[rowNum] );
|
3901 | imageWidth = parseInt( imageWidth );
|
3902 |
|
3903 |
|
3904 | curTn.resizedContentWidth = imageWidth;
|
3905 | curTn.resizedContentHeight = rh;
|
3906 |
|
3907 | curTn.width = imageWidth + borderWidth;
|
3908 | curTn.height= rh + G.tn.labelHeight.get() + borderHeight;
|
3909 | curTn.row = rowNum;
|
3910 |
|
3911 | curTn.top = curPosY;
|
3912 | var x = lastPosX;
|
3913 | if( G.O.RTL) {
|
3914 | x = areaWidth - lastPosX - curTn.width ;
|
3915 | }
|
3916 | curTn.left = x;
|
3917 |
|
3918 | lastPosX += curTn.width + gutterWidth;
|
3919 |
|
3920 | if( i == rowLastItem[rowNum] ) {
|
3921 |
|
3922 | curPosY += curTn.height + gutterHeight;
|
3923 | G.GOM.lastFullRow = rowNum - 1;
|
3924 | rowNum++;
|
3925 | lastPosX = 0;
|
3926 | }
|
3927 | cnt++;
|
3928 | }
|
3929 | else {
|
3930 | return false;
|
3931 | }
|
3932 | }
|
3933 |
|
3934 | if( false ) {
|
3935 | var newTop = 0;
|
3936 | if( typeof GOMidx !== 'undefined' ) {
|
3937 |
|
3938 | if( G.GOM.albumIdx != -1 ) {
|
3939 | var hoveredTn = G.GOM.items[GOMidx];
|
3940 | var item = G.I[hoveredTn.thumbnailIdx];
|
3941 |
|
3942 |
|
3943 | hoveredTn.width += 40;
|
3944 | hoveredTn.height += 40;
|
3945 |
|
3946 |
|
3947 | for( var i = 0; i < nbTn ; i++ ) {
|
3948 | var curTn = G.GOM.items[i];
|
3949 | if( curTn.imageWidth > 0 ) {
|
3950 | if( curTn.row == hoveredTn.row ) {
|
3951 |
|
3952 | newTop = 40;
|
3953 | if( hoveredTn.thumbnailIdx != curTn.thumbnailIdx ) {
|
3954 |
|
3955 |
|
3956 |
|
3957 |
|
3958 | curTn.top += 30;
|
3959 | curTn.width -= 20;
|
3960 | curTn.height -= 20;
|
3961 | }
|
3962 | }
|
3963 | else {
|
3964 |
|
3965 | if( curTn.row == 0 ) {
|
3966 |
|
3967 | }
|
3968 | else {
|
3969 | curTn.top += newTop;
|
3970 | }
|
3971 | }
|
3972 | }
|
3973 | }
|
3974 | }
|
3975 | }
|
3976 | }
|
3977 |
|
3978 | G.GOM.displayArea.width = areaWidth;
|
3979 | return true;
|
3980 | }
|
3981 |
|
3982 |
|
3983 |
|
3984 |
|
3985 |
|
3986 | function GallerySetLayoutMosaic() {
|
3987 | var areaWidth = G.GOM.cache.areaWidth;
|
3988 | var gutterHeight = G.tn.opt.Get('gutterHeight');
|
3989 | var gutterWidth = G.tn.opt.Get('gutterWidth');
|
3990 | var borderWidth = G.tn.borderWidth * 2;
|
3991 | var borderHeight = G.tn.borderHeight * 2;
|
3992 |
|
3993 | var nbTn = G.GOM.items.length;
|
3994 | var row = 0;
|
3995 | var h = 0;
|
3996 | var n = 0;
|
3997 |
|
3998 |
|
3999 |
|
4000 | var nbCols = 0;
|
4001 | var maxW = 0;
|
4002 | var mosaicPattern = G.tn.settings.getMosaic();
|
4003 | for( var i = 0; i < nbTn ; i++ ) {
|
4004 | var curPatternElt = mosaicPattern[n];
|
4005 |
|
4006 | var cLeft = (curPatternElt.c - 1) * G.tn.defaultSize.getOuterWidth() + (curPatternElt.c - 1) * gutterWidth;
|
4007 | var cWidth = curPatternElt.w * G.tn.defaultSize.getOuterWidth() + (curPatternElt.w - 1) * gutterWidth;
|
4008 |
|
4009 | maxW=Math.max(maxW, cLeft + cWidth );
|
4010 |
|
4011 | nbCols=Math.max(nbCols, (curPatternElt.c - 1) + curPatternElt.w );
|
4012 |
|
4013 | n++;
|
4014 | if( n >= mosaicPattern.length ) {
|
4015 |
|
4016 | break;
|
4017 | }
|
4018 | }
|
4019 | var totalGutterWidth = (nbCols - 1) * gutterWidth;
|
4020 | var scaleFactor = Math.min( (areaWidth - totalGutterWidth ) / ( maxW - totalGutterWidth ), 1);
|
4021 |
|
4022 |
|
4023 | row = 0;
|
4024 | n = 0;
|
4025 | var mosaicPattern = G.tn.settings.getMosaic();
|
4026 | for( var i = 0; i < nbTn ; i++ ) {
|
4027 | var curTn = G.GOM.items[i];
|
4028 | var curPatternElt = mosaicPattern[n];
|
4029 |
|
4030 | curTn.top = (curPatternElt.r - 1) * G.tn.defaultSize.getOuterHeight()*scaleFactor + (curPatternElt.r - 1) * gutterHeight + row * h + (G.tn.labelHeight.get()*(curPatternElt.r-1)) ;
|
4031 | if( row > 0 ) {
|
4032 | curTn.top += gutterHeight;
|
4033 | }
|
4034 |
|
4035 | curTn.left = (curPatternElt.c - 1) * G.tn.defaultSize.getOuterWidth()*scaleFactor + (curPatternElt.c - 1) * gutterWidth;
|
4036 |
|
4037 | curTn.height = curPatternElt.h * G.tn.defaultSize.getOuterHeight() * scaleFactor + (curPatternElt.h - 1) * gutterHeight + (G.tn.labelHeight.get() * curPatternElt.h);
|
4038 | curTn.resizedContentHeight = curTn.height - G.tn.labelHeight.get() - borderHeight;
|
4039 |
|
4040 | curTn.width = curPatternElt.w * G.tn.defaultSize.getOuterWidth()*scaleFactor + (curPatternElt.w - 1) * gutterWidth;
|
4041 | curTn.resizedContentWidth = curTn.width - borderWidth ;
|
4042 |
|
4043 | curTn.row = row;
|
4044 | if( row == 0 ) {
|
4045 | h=Math.max(h, curTn.top + curTn.height);
|
4046 | }
|
4047 |
|
4048 | n++;
|
4049 | if( n >= mosaicPattern.length ) {
|
4050 |
|
4051 | n = 0;
|
4052 | row++;
|
4053 | }
|
4054 | }
|
4055 |
|
4056 | G.GOM.displayArea.width = (maxW - totalGutterWidth) * scaleFactor + totalGutterWidth;
|
4057 | return true;
|
4058 | }
|
4059 |
|
4060 |
|
4061 |
|
4062 |
|
4063 | function GallerySetLayoutGrid() {
|
4064 | var curPosX= 0,
|
4065 | curPosY= 0,
|
4066 | areaWidth= G.GOM.cache.areaWidth,
|
4067 | gutterWidth= 0,
|
4068 | gutterHeight= G.tn.opt.Get('gutterHeight'),
|
4069 | maxCol= NbThumbnailsPerRow(areaWidth),
|
4070 | w= 0,
|
4071 | cols= [],
|
4072 | curCol= 0,
|
4073 | newAreaWidth = areaWidth,
|
4074 | tnWidth= G.tn.defaultSize.getOuterWidth();
|
4075 | var scaleFactor = 1;
|
4076 | var nbTn= G.GOM.items.length;
|
4077 | var borderWidth = G.tn.borderWidth * 2;
|
4078 | var borderHeight =G.tn.borderHeight * 2;
|
4079 |
|
4080 |
|
4081 | if( G.O.thumbnailAlignment == 'justified' ) {
|
4082 | maxCol = Math.min( maxCol, nbTn);
|
4083 | gutterWidth = (maxCol==1 ? 0 : (areaWidth-(maxCol*tnWidth))/(maxCol-1));
|
4084 | }
|
4085 | else {
|
4086 | gutterWidth = G.tn.opt.Get('gutterWidth');
|
4087 | }
|
4088 |
|
4089 |
|
4090 |
|
4091 | if( G.O.RTL || G.O.thumbnailAlignment == 'fillWidth' ) {
|
4092 |
|
4093 | var totalGutterWidth = (maxCol-1) * gutterWidth;
|
4094 | scaleFactor = (areaWidth - totalGutterWidth) / (maxCol*tnWidth);
|
4095 | if( scaleFactor > 1 ) {
|
4096 | maxCol++;
|
4097 | }
|
4098 | totalGutterWidth = (maxCol-1) * gutterWidth;
|
4099 | scaleFactor = Math.min( (areaWidth - totalGutterWidth) / (maxCol*tnWidth), 1);
|
4100 | newAreaWidth = (maxCol*tnWidth) + totalGutterWidth;
|
4101 | }
|
4102 |
|
4103 |
|
4104 | G.GOM.lastFullRow = 0 ;
|
4105 | var lastPosY = 0;
|
4106 | var row = 0;
|
4107 |
|
4108 | tnWidth = tnWidth * scaleFactor;
|
4109 | var contentWidth = tnWidth - borderWidth;
|
4110 | var tnHeight = G.tn.defaultSize.getOuterHeight() * scaleFactor + G.tn.labelHeight.get();
|
4111 | var contentHeight = G.tn.defaultSize.getOuterHeight() * scaleFactor - borderHeight;
|
4112 |
|
4113 |
|
4114 | for( var i = 0; i < nbTn ; i++ ) {
|
4115 | if( curPosY == 0 ) {
|
4116 | curPosX = curCol * (tnWidth + gutterWidth)
|
4117 | cols[curCol] = curPosX;
|
4118 | w = curPosX + tnWidth;
|
4119 | }
|
4120 | else {
|
4121 | curPosX = cols[curCol];
|
4122 | }
|
4123 |
|
4124 | var x = curPosX;
|
4125 | if( G.O.RTL ) {
|
4126 | x = parseInt(newAreaWidth) - curPosX - tnWidth;
|
4127 | }
|
4128 |
|
4129 |
|
4130 | var curTn=G.GOM.items[i];
|
4131 | curTn.top = curPosY;
|
4132 | curTn.left = x;
|
4133 | curTn.height = tnHeight;
|
4134 | curTn.width = tnWidth;
|
4135 |
|
4136 | if( G.O.thumbnailAlignment == 'fillWidth' ) {
|
4137 | curTn.resizedContentWidth = contentWidth;
|
4138 | curTn.resizedContentHeight = contentHeight;
|
4139 | }
|
4140 | curTn.row = row;
|
4141 | lastPosY = curPosY;
|
4142 |
|
4143 | curCol++;
|
4144 | if( curCol >= maxCol ){
|
4145 |
|
4146 | curCol = 0;
|
4147 | curPosY += tnHeight + gutterHeight;
|
4148 | G.GOM.lastFullRow = row;
|
4149 | row++;
|
4150 | }
|
4151 | }
|
4152 | G.GOM.displayArea.width = w;
|
4153 | return true;
|
4154 | }
|
4155 |
|
4156 |
|
4157 |
|
4158 | function GalleryDisplayPart1( forceTransition ) {
|
4159 | if( G.CSStransformName == null ) {
|
4160 | G.$E.conTn.css( 'left' , '0px');
|
4161 | }
|
4162 | else {
|
4163 | G.$E.conTn.css( G.CSStransformName , 'none');
|
4164 | }
|
4165 | CacheViewport();
|
4166 | }
|
4167 |
|
4168 | function CacheViewport() {
|
4169 | G.GOM.cache.viewport = getViewport();
|
4170 | G.GOM.cache.areaWidth = G.$E.conTnParent.width();
|
4171 | G.GOM.cache.containerOffset = G.$E.conTnParent.offset();
|
4172 | }
|
4173 |
|
4174 |
|
4175 |
|
4176 | function GalleryDisplayPart2( forceTransition ) {
|
4177 |
|
4178 | var nbTn = G.GOM.items.length;
|
4179 | G.GOM.itemsDisplayed = 0;
|
4180 | var threshold = 50;
|
4181 | var cnt = 0;
|
4182 |
|
4183 |
|
4184 | GalleryRenderGetInterval();
|
4185 |
|
4186 | for( var i = 0; i < nbTn ; i++ ) {
|
4187 | var curTn = G.GOM.items[i];
|
4188 | if( i >= G.GOM.displayInterval.from && cnt < G.GOM.displayInterval.len ) {
|
4189 | curTn.inDisplayArea = true;
|
4190 | if( forceTransition ) {
|
4191 | curTn.neverDisplayed = true;
|
4192 | }
|
4193 | G.GOM.itemsDisplayed++;
|
4194 | cnt++;
|
4195 | }
|
4196 | else{
|
4197 | curTn.inDisplayArea = false;
|
4198 | }
|
4199 | }
|
4200 |
|
4201 |
|
4202 | GalleryBottomManage();
|
4203 |
|
4204 | var tnToDisplay = [];
|
4205 | var tnToReDisplay = [];
|
4206 |
|
4207 | G.GOM.clipArea.top = -1;
|
4208 | cnt = 0 ;
|
4209 | var lastTnIdx = -1;
|
4210 | G.GOM.clipArea.height = 0;
|
4211 |
|
4212 | for( var i = 0; i < nbTn ; i++ ) {
|
4213 | var curTn = G.GOM.items[i];
|
4214 | if( curTn.inDisplayArea ) {
|
4215 | if( G.GOM.clipArea.top == -1 ) {
|
4216 | G.GOM.clipArea.top = curTn.top;
|
4217 | }
|
4218 | if( (curTn.top - G.GOM.clipArea.top) <= -1 ) {
|
4219 |
|
4220 | G.GOM.clipArea.top = curTn.top;
|
4221 | }
|
4222 |
|
4223 | G.GOM.clipArea.height = Math.max( G.GOM.clipArea.height, curTn.top-G.GOM.clipArea.top + curTn.height);
|
4224 |
|
4225 | if( curTn.neverDisplayed ) {
|
4226 |
|
4227 | var top = G.GOM.cache.containerOffset.top + (curTn.top - G.GOM.clipArea.top);
|
4228 |
|
4229 | if( (top + curTn.height) >= (G.GOM.cache.viewport.t - threshold) && top <= (G.GOM.cache.viewport.t + G.GOM.cache.viewport.h + threshold) ) {
|
4230 |
|
4231 | var item = G.I[curTn.thumbnailIdx];
|
4232 | if( item.$elt == null ) {
|
4233 | ThumbnailBuild( item, curTn.thumbnailIdx, i, (i+1) == nbTn );
|
4234 | }
|
4235 | tnToDisplay.push({idx:i, delay:cnt});
|
4236 | cnt++;
|
4237 | }
|
4238 | }
|
4239 | else {
|
4240 | tnToReDisplay.push({idx: i, delay: 0});
|
4241 | }
|
4242 |
|
4243 | lastTnIdx = i;
|
4244 | }
|
4245 | else {
|
4246 | curTn.displayed = false;
|
4247 | var item = G.I[curTn.thumbnailIdx];
|
4248 | if( item.$elt != null ){
|
4249 | item.$elt.css({ opacity: 0, display: 'none' });
|
4250 | }
|
4251 | }
|
4252 | }
|
4253 |
|
4254 | var areaWidth = G.$E.conTnParent.width();
|
4255 |
|
4256 |
|
4257 |
|
4258 | if( G.GOM.displayArea.width != G.GOM.displayAreaLast.width || G.GOM.clipArea.height != G.GOM.displayAreaLast.height ) {
|
4259 | G.$E.conTn.width( G.GOM.displayArea.width ).height( G.GOM.clipArea.height );
|
4260 | G.GOM.displayAreaLast.width = G.GOM.displayArea.width;
|
4261 | G.GOM.displayAreaLast.height = G.GOM.clipArea.height;
|
4262 |
|
4263 | }
|
4264 |
|
4265 | if( areaWidth != G.$E.conTnParent.width() ) {
|
4266 |
|
4267 |
|
4268 | G.GOM.cache.areaWidth = G.$E.conTnParent.width();
|
4269 | GallerySetLayout();
|
4270 | GalleryDisplayPart1( forceTransition );
|
4271 | GalleryDisplayPart2( forceTransition );
|
4272 | return;
|
4273 | }
|
4274 |
|
4275 |
|
4276 | if( G.layout.support.rows ) {
|
4277 | if( G.galleryDisplayMode.Get() == 'ROWS' || (G.galleryDisplayMode.Get() == 'FULLCONTENT' && G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1) ){
|
4278 | if( lastTnIdx < (nbTn - 1) ) {
|
4279 | G.GOM.lastDisplayedIdxNew = lastTnIdx;
|
4280 | }
|
4281 | else {
|
4282 | G.GOM.lastDisplayedIdxNew =- 1;
|
4283 | }
|
4284 |
|
4285 | if( G.GOM.lastDisplayedIdx != -1 ) {
|
4286 | var item = G.I[G.GOM.items[G.GOM.lastDisplayedIdx].thumbnailIdx];
|
4287 | item.$getElt('.nGY2GThumbnailIconsFullThumbnail').html('');
|
4288 | }
|
4289 | }
|
4290 | }
|
4291 |
|
4292 |
|
4293 |
|
4294 |
|
4295 | var nbBuild = tnToDisplay.length;
|
4296 | G.GOM.thumbnails2Display=[];
|
4297 | for( var i = 0; i < nbBuild ; i++ ) {
|
4298 |
|
4299 | ThumbnailSetPosition(tnToDisplay[i].idx, i);
|
4300 | }
|
4301 |
|
4302 |
|
4303 | var n = tnToReDisplay.length;
|
4304 | for( var i = 0; i < n ; i++ ) {
|
4305 |
|
4306 | ThumbnailSetPosition(tnToReDisplay[i].idx, i);
|
4307 | }
|
4308 |
|
4309 | ThumbnailDisplayAnimBatch();
|
4310 |
|
4311 | if( G.tn.opt.Get('displayTransition') == 'NONE' ) {
|
4312 | G.galleryResizeEventEnabled = true;
|
4313 |
|
4314 | TriggerCustomEvent('galleryDisplayed');
|
4315 | }
|
4316 | else {
|
4317 |
|
4318 | requestTimeout( function() {
|
4319 |
|
4320 | G.galleryResizeEventEnabled = true;
|
4321 |
|
4322 | TriggerCustomEvent('galleryDisplayed');
|
4323 | }, nbBuild * G.tn.opt.Get('displayInterval'));
|
4324 | }
|
4325 |
|
4326 | }
|
4327 |
|
4328 |
|
4329 |
|
4330 | function ThumbnailSetPosition( GOMidx, cnt ) {
|
4331 | var newTop= 0;
|
4332 | var curTn= G.GOM.items[GOMidx];
|
4333 | var idx= G.GOM.items[GOMidx].thumbnailIdx;
|
4334 | var item= G.I[idx];
|
4335 |
|
4336 | if( curTn.neverDisplayed ) {
|
4337 |
|
4338 | var top = curTn.top - G.GOM.clipArea.top;
|
4339 | if( G.tn.opt.Get('stacks') > 0 ) {
|
4340 |
|
4341 | item.$elt.last().css({ display: 'block'});
|
4342 | item.$elt.css({ top: top , left: curTn.left });
|
4343 | }
|
4344 | else {
|
4345 | item.$elt.css({ display: 'block', top: top , left: curTn.left });
|
4346 | }
|
4347 | newTop=top;
|
4348 |
|
4349 |
|
4350 | if( G.O.thumbnailWaitImageLoaded === true ) {
|
4351 | var gi_imgLoad = ngimagesLoaded( item.$getElt('.nGY2TnImg2') );
|
4352 | gi_imgLoad.on( 'progress', function( instance, image ) {
|
4353 | if( image.isLoaded ) {
|
4354 | var albumIdx = image.img.getAttribute('data-albumidx');
|
4355 | if( albumIdx == G.GOM.albumIdx ) {
|
4356 |
|
4357 | var idx = image.img.getAttribute('data-idx');
|
4358 | G.I[idx].ThumbnailImageReveal();
|
4359 | }
|
4360 | }
|
4361 | });
|
4362 | }
|
4363 |
|
4364 | ThumbnailAppear(GOMidx, cnt);
|
4365 |
|
4366 | curTn.displayed = true;
|
4367 | curTn.neverDisplayed = false;
|
4368 | }
|
4369 | else {
|
4370 | var topOld = G.GOM.cache.containerOffset.top + item.top;
|
4371 | var top = G.GOM.cache.containerOffset.top + (curTn.top - G.GOM.clipArea.top);
|
4372 | newTop = curTn.top - G.GOM.clipArea.top;
|
4373 | var vp = G.GOM.cache.viewport;
|
4374 | if( G.O.thumbnailDisplayOutsideScreen || ( ( (topOld + curTn.height) >= (vp.t - vp.h) && topOld <= (vp.t + vp.h * 4) ) ||
|
4375 | ( (top + curTn.height) >= (vp.t - vp.h) && top <= (vp.t + vp.h * 4) ) ) ) {
|
4376 |
|
4377 | if( curTn.displayed ) {
|
4378 |
|
4379 | if( item.top != curTn.top || item.left != curTn.left ) {
|
4380 |
|
4381 | if( G.O.galleryResizeAnimation == true ) {
|
4382 |
|
4383 | var tweenable = new NGTweenable();
|
4384 | tweenable.tween({
|
4385 | from: { top: item.top, left: item.left, height: item.height, width: item.width },
|
4386 | to: { top: newTop, left: curTn.left, height: curTn.height, width: curTn.width },
|
4387 | attachment: { $e: item.$elt },
|
4388 | duration: 100,
|
4389 | delay: cnt * G.tn.opt.Get('displayInterval') / 5,
|
4390 |
|
4391 | easing: 'easeOutQuart',
|
4392 | step: function (state, att) {
|
4393 |
|
4394 | att.$e.css(state);
|
4395 |
|
4396 | },
|
4397 | finish: function (state, att) {
|
4398 | var _this=this;
|
4399 |
|
4400 | _this.dispose();
|
4401 |
|
4402 | }
|
4403 | });
|
4404 | }
|
4405 | else {
|
4406 |
|
4407 |
|
4408 | item.$elt.css({ top: newTop , left: curTn.left });
|
4409 | }
|
4410 | }
|
4411 | }
|
4412 | else {
|
4413 |
|
4414 | curTn.displayed = true;
|
4415 |
|
4416 | item.$elt.css({ display: 'block', top: newTop, left: curTn.left, opacity: 1 });
|
4417 | ThumbnailAppearFinish(item);
|
4418 | }
|
4419 | }
|
4420 | else {
|
4421 |
|
4422 | curTn.displayed = false;
|
4423 | item.$elt.css({ display: 'none'});
|
4424 | }
|
4425 | }
|
4426 | item.left = curTn.left;
|
4427 | item.top = newTop;
|
4428 |
|
4429 |
|
4430 | if( item.width != curTn.width || item.height != curTn.height ) {
|
4431 | item.$elt.css({ width: curTn.width , height: curTn.height });
|
4432 | item.width = curTn.width;
|
4433 | item.height = curTn.height;
|
4434 |
|
4435 |
|
4436 |
|
4437 | if( item.resizedContentWidth != curTn.resizedContentWidth || item.resizedContentHeight != curTn.resizedContentHeight ) {
|
4438 | if( item.kind == 'albumUp' ) {
|
4439 |
|
4440 | }
|
4441 | else {
|
4442 | item.$getElt('.nGY2GThumbnailImage').css({'height': curTn.resizedContentHeight, 'width': curTn.resizedContentWidth});
|
4443 |
|
4444 | if( G.layout.engine == 'JUSTIFIED' ) {
|
4445 | item.$getElt('.nGY2GThumbnailImg').css({'height': curTn.resizedContentHeight, 'width': curTn.resizedContentWidth});
|
4446 | }
|
4447 | }
|
4448 | item.resizedContentWidth = curTn.resizedContentWidth;
|
4449 | item.resizedContentHeight = curTn.resizedContentHeight;
|
4450 | }
|
4451 | }
|
4452 |
|
4453 |
|
4454 |
|
4455 | if( G.GOM.lastDisplayedIdxNew == GOMidx && G.layout.support.rows ) {
|
4456 | if( (G.galleryDisplayMode.Get() == 'ROWS' && G.galleryMaxRows.Get() > 0) || (G.galleryDisplayMode.Get() == 'FULLCONTENT' && G.galleryLastRowFull.Get() && G.GOM.lastFullRow != -1) ){
|
4457 |
|
4458 | var nb = G.GOM.items.length - GOMidx - 1;
|
4459 | if( item.albumID != '0' && G.O.thumbnailLevelUp ) {
|
4460 | nb--;
|
4461 | }
|
4462 |
|
4463 | if( nb > 0 ) {
|
4464 |
|
4465 | if( G.O.thumbnailOpenImage || G.O.thumbnailSliderDelay > 0 ) {
|
4466 | item.$getElt('.nGY2GThumbnailIconsFullThumbnail').html( '+' + nb);
|
4467 | }
|
4468 |
|
4469 |
|
4470 |
|
4471 | if( G.GOM.slider.hostItem != G.GOM.NGY2Item(GOMidx) ) {
|
4472 |
|
4473 |
|
4474 | GalleryThumbnailSliderSetContent( G.GOM.slider.hostItem );
|
4475 |
|
4476 | G.GOM.slider.hostIdx = GOMidx;
|
4477 | G.GOM.slider.hostItem = G.GOM.NGY2Item(GOMidx);
|
4478 | G.GOM.slider.nextIdx = GOMidx;
|
4479 | G.GOM.slider.currentIdx = GOMidx;
|
4480 | GalleryThumbnailSliderBuildAndStart();
|
4481 |
|
4482 | }
|
4483 | }
|
4484 | else {
|
4485 |
|
4486 | GalleryThumbnailSliderSetContent( G.GOM.slider.hostItem );
|
4487 | G.GOM.slider.hostIdx = -1;
|
4488 | }
|
4489 |
|
4490 | G.GOM.lastDisplayedIdx = GOMidx;
|
4491 | }
|
4492 | }
|
4493 |
|
4494 | }
|
4495 |
|
4496 |
|
4497 |
|
4498 |
|
4499 | function GalleryThumbnailSliderBuildAndStart() {
|
4500 |
|
4501 | if( G.O.thumbnailSliderDelay == 0 || G.GOM.slider.hostIdx == -1 ) {
|
4502 | return;
|
4503 | }
|
4504 | clearTimeout(G.GOM.slider.timerID);
|
4505 |
|
4506 | var item = G.GOM.slider.hostItem;
|
4507 |
|
4508 |
|
4509 | if( item.$getElt('.nGY2TnImgNext').length == 0 ) {
|
4510 | item.$getElt('.nGY2TnImg').clone().removeClass('nGY2TnImg').addClass('nGY2TnImgNext').insertAfter(item.$getElt('.nGY2TnImg'));
|
4511 | item.$getElt('.nGY2TnImgBack').clone().removeClass('nGY2TnImgBack').addClass('nGY2TnImgBackNext').insertAfter(item.$getElt('.nGY2TnImg', true));
|
4512 | item.$getElt('.nGY2GThumbnailImage', true);
|
4513 | item.$getElt('.nGY2GThumbnailImg', true);
|
4514 | }
|
4515 |
|
4516 | item.CSSTransformSet('.nGY2TnImgNext', 'translateX', '100%', true);
|
4517 | item.CSSTransformApply( '.nGY2TnImgNext' );
|
4518 | item.CSSTransformSet('.nGY2TnImgBackNext', 'translateX', '100%', true);
|
4519 | item.CSSTransformApply( '.nGY2TnImgBackNext' );
|
4520 |
|
4521 | GalleryThumbnailSliderSetNextContent();
|
4522 |
|
4523 |
|
4524 |
|
4525 | G.GOM.slider.timerID = requestTimeout(function(){ GalleryThumbnailSliderStartTransition() }, G.O.thumbnailSliderDelay);
|
4526 | }
|
4527 |
|
4528 |
|
4529 | function GalleryThumbnailSliderSetNextContent() {
|
4530 |
|
4531 | G.GOM.slider.nextIdx++;
|
4532 | if( G.GOM.slider.nextIdx >= G.GOM.items.length ) {
|
4533 | G.GOM.slider.nextIdx = G.GOM.slider.hostIdx;
|
4534 | }
|
4535 |
|
4536 |
|
4537 | var newItem = G.GOM.NGY2Item(G.GOM.slider.nextIdx);
|
4538 | var imgBlurred = G.emptyGif;
|
4539 | var bgImg = "url('" + G.emptyGif + "')";
|
4540 | if( newItem.imageDominantColors != null ) {
|
4541 | imgBlurred = newItem.imageDominantColors;
|
4542 | bgImg = "url('" + newItem.imageDominantColors + "')";
|
4543 | }
|
4544 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgBackNext', true).css({'background-image': bgImg, opacity: 1 });
|
4545 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgNext', true).css({ 'background-image': "url('" + newItem.thumbImg().src + "')", opacity: 1 });
|
4546 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgNext .nGY2GThumbnailImg', true).attr('src', newItem.thumbImg().src );
|
4547 |
|
4548 |
|
4549 | }
|
4550 |
|
4551 |
|
4552 | function GalleryThumbnailSliderStartTransition() {
|
4553 |
|
4554 | if( G.GOM.slider.hostItem.$getElt() != null ) {
|
4555 |
|
4556 |
|
4557 | var tweenable = new NGTweenable();
|
4558 | G.GOM.slider.tween = tweenable;
|
4559 | tweenable.tween({
|
4560 | from: { 'left': 100 },
|
4561 | to: { 'left': 0 },
|
4562 | duration: 800,
|
4563 | delay: 0,
|
4564 |
|
4565 | easing: 'easeOutQuart',
|
4566 |
|
4567 | step: function (state) {
|
4568 | if( G.GOM.slider.hostItem.$getElt() == null ) {
|
4569 |
|
4570 | G.GOM.slider.tween.stop(false);
|
4571 | return;
|
4572 | }
|
4573 |
|
4574 |
|
4575 |
|
4576 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBack', 'translateX', -(100 - state.left) + '%');
|
4577 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBack' );
|
4578 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImg', 'translateX', -(100 - state.left) + '%');
|
4579 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImg' );
|
4580 |
|
4581 |
|
4582 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBackNext', 'translateX', state.left + '%');
|
4583 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBackNext' );
|
4584 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgNext', 'translateX', state.left + '%');
|
4585 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgNext' );
|
4586 |
|
4587 |
|
4588 |
|
4589 | },
|
4590 | finish: function (state) {
|
4591 | if( G.GOM.slider.hostItem.$getElt() == null ) {
|
4592 |
|
4593 | return;
|
4594 | }
|
4595 |
|
4596 | if( G.GOM.NGY2Item(G.GOM.slider.nextIdx) == null ) { return; }
|
4597 |
|
4598 |
|
4599 |
|
4600 | GalleryThumbnailSliderSetContent( G.GOM.NGY2Item(G.GOM.slider.nextIdx) );
|
4601 | G.GOM.slider.currentIdx = G.GOM.slider.nextIdx;
|
4602 | GalleryThumbnailSliderSetNextContent();
|
4603 |
|
4604 | clearTimeout(G.GOM.slider.timerID);
|
4605 |
|
4606 | G.GOM.slider.timerID = requestTimeout(function(){ GalleryThumbnailSliderStartTransition() }, G.O.thumbnailSliderDelay);
|
4607 |
|
4608 | }
|
4609 | });
|
4610 | }
|
4611 | }
|
4612 |
|
4613 |
|
4614 |
|
4615 | function GalleryThumbnailSliderSetContent( ngy2itemContent ) {
|
4616 | if( G.GOM.slider.hostIdx == -1 ) { return; }
|
4617 |
|
4618 | if( G.GOM.slider.tween != null ) {
|
4619 | if( G.GOM.slider.tween._isTweening == true ) {
|
4620 | G.GOM.slider.tween.stop(false);
|
4621 | }
|
4622 | }
|
4623 |
|
4624 | var bgImg = "url('" + G.emptyGif + "')";
|
4625 | if( ngy2itemContent.imageDominantColors != null ) {
|
4626 | bgImg = "url('" + ngy2itemContent.imageDominantColors + "')";
|
4627 | }
|
4628 | G.GOM.slider.hostItem.$getElt('.nGY2TnImgBack').css('background-image', bgImg);
|
4629 | G.GOM.slider.hostItem.$getElt('.nGY2TnImg').css('background-image', "url('" + ngy2itemContent.thumbImg().src + "')" );
|
4630 | G.GOM.slider.hostItem.$getElt('.nGY2TnImg .nGY2GThumbnailImg').attr('src', ngy2itemContent.thumbImg().src );
|
4631 |
|
4632 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBack', 'translateX', '0');
|
4633 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBack' );
|
4634 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImg', 'translateX', '0');
|
4635 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImg' );
|
4636 |
|
4637 |
|
4638 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgBackNext', 'translateX', '100%', true);
|
4639 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgBackNext' );
|
4640 | G.GOM.slider.hostItem.CSSTransformSet('.nGY2TnImgNext', 'translateX', '100%', true);
|
4641 | G.GOM.slider.hostItem.CSSTransformApply( '.nGY2TnImgNext' );
|
4642 |
|
4643 |
|
4644 | if( G.O.thumbnailLabel.get('display') == true ) {
|
4645 | var icons = G.O.icons.thumbnailAlbum;
|
4646 | if( ngy2itemContent.kind != 'album' ) {
|
4647 | icons = G.O.icons.thumbnailImage;
|
4648 | }
|
4649 | G.GOM.slider.hostItem.$getElt('.nGY2GThumbnailTitle').html(icons + getThumbnailTitle(ngy2itemContent));
|
4650 | G.GOM.slider.hostItem.$getElt('.nGY2GThumbnailDescription').html(icons + getTumbnailDescription(ngy2itemContent));
|
4651 | }
|
4652 | }
|
4653 |
|
4654 |
|
4655 |
|
4656 |
|
4657 | function ThumbnailGetLabelHeight() {
|
4658 | var newElt = [],
|
4659 | newEltIdx = 0;
|
4660 |
|
4661 |
|
4662 | if( G.O.thumbnailLabel.get('display') == false ) {
|
4663 | return 0;
|
4664 | }
|
4665 |
|
4666 | var desc='';
|
4667 | if( G.O.thumbnailLabel.get('displayDescription') == true ) {
|
4668 | desc = 'aAzZjJ';
|
4669 | }
|
4670 |
|
4671 |
|
4672 | newElt[newEltIdx++] = '<div class="nGY2GThumbnail ' + G.O.theme + '" style="display:block;visibility:hidden;position:absolute;top:-9999px;left:-9999px;" ><div class="nGY2GThumbnailSub">';
|
4673 | if( G.O.thumbnailLabel.get('display') == true ) {
|
4674 |
|
4675 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailLabel" '+ G.tn.style.getLabel() +'>';
|
4676 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailAlbumTitle" '+G.tn.style.getTitle()+'>aAzZjJ</div>';
|
4677 | if( G.O.thumbnailLabel.get('displayDescription') == true ) {
|
4678 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailDescription" '+G.tn.style.getDesc()+'>'+'aAzZjJ'+'</div>';
|
4679 | }
|
4680 | newElt[newEltIdx++] = ' </div>';
|
4681 | }
|
4682 |
|
4683 | newElt[newEltIdx++] = '</div></div>';
|
4684 |
|
4685 | var $newDiv = jQuery(newElt.join('')).appendTo(G.$E.conTn);
|
4686 | var h = $newDiv.find('.nGY2GThumbnailLabel').outerHeight(true);
|
4687 | $newDiv.remove();
|
4688 |
|
4689 | return h;
|
4690 | }
|
4691 |
|
4692 | function ThumbnailBuildStacks( bgColor ) {
|
4693 | var ns=G.tn.opt.Get('stacks');
|
4694 | if( ns == 0 ) { return ''; }
|
4695 |
|
4696 | var s='';
|
4697 | for( var i=0; i<ns; i++ ) {
|
4698 | s='<div class="nGY2GThumbnailStack " style="display:none;'+bgColor+'"></div>'+s;
|
4699 | }
|
4700 | return s;
|
4701 | }
|
4702 |
|
4703 |
|
4704 | function ThumbnailBuildAlbumpUp( item, idx, GOMidx ) {
|
4705 | var newElt = [],
|
4706 | newEltIdx = 0;
|
4707 |
|
4708 | var mp = '';
|
4709 | if( G.O.thumbnailOpenImage === false ) {
|
4710 | mp = 'cursor:default;'
|
4711 | }
|
4712 |
|
4713 | newElt[newEltIdx++] = ThumbnailBuildStacks('') + '<div class="nGY2GThumbnail" style="display:none;opacity:0;' + mp + '" >';
|
4714 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailSub">';
|
4715 |
|
4716 | var h=G.tn.defaultSize.getHeight(),
|
4717 | w=G.tn.defaultSize.getWidth();
|
4718 |
|
4719 | 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>';
|
4720 |
|
4721 | newElt[newEltIdx++] = ' <div class="nGY2GThumbnailAlbumUp" >'+G.O.icons.thumbnailAlbumUp+'</div>';
|
4722 | newElt[newEltIdx++] = ' </div>';
|
4723 | newElt[newEltIdx++] = '</div>';
|
4724 |
|
4725 | var $newDiv = jQuery(newElt.join('')).appendTo(G.$E.conTn);
|
4726 |
|
4727 | item.$elt = $newDiv;
|
4728 | $newDiv.data('index', GOMidx);
|
4729 | item.$getElt('.nGY2GThumbnailImg').data('index', GOMidx);
|
4730 |
|
4731 | return;
|
4732 | }
|
4733 |
|
4734 |
|
4735 |
|
4736 | function ThumbnailBuild( item, idx, GOMidx, lastOne ) {
|
4737 | item.eltTransform = [];
|
4738 | item.eltFilter = [];
|
4739 | item.hoverInitDone = false;
|
4740 | item.$Elts = [];
|
4741 |
|
4742 | if( item.kind == 'albumUp' ) {
|
4743 | ThumbnailBuildAlbumpUp( item, idx, GOMidx);
|
4744 | return;
|
4745 | }
|
4746 |
|
4747 | var newElt = [],
|
4748 | newEltIdx = 0;
|
4749 |
|
4750 | var mp = '';
|
4751 | if( G.O.thumbnailOpenImage === false ) {
|
4752 | mp = 'cursor:default;'
|
4753 | }
|
4754 |
|
4755 |
|
4756 | var src = (item.thumbImg().src).replace(/'/g, "%27"),
|
4757 | sTitle = getThumbnailTitle(item);
|
4758 |
|
4759 |
|
4760 | var bg = '';
|
4761 | var bgImg = "background-image: url('" + G.emptyGif + "');";
|
4762 | if( item.imageDominantColors != null ) {
|
4763 |
|
4764 | bgImg = "background-image: url('" + item.imageDominantColors + "');";
|
4765 | }
|
4766 | else {
|
4767 |
|
4768 | if( item.imageDominantColor != null ) {
|
4769 | bg = 'background-color:' + item.imageDominantColor + ';';
|
4770 | }
|
4771 | else {
|
4772 | bgImg = '';
|
4773 | }
|
4774 | }
|
4775 |
|
4776 | var op = 'opacity:1;';
|
4777 | if( G.O.thumbnailWaitImageLoaded == true ) {
|
4778 | op = 'opacity:0;';
|
4779 | }
|
4780 |
|
4781 |
|
4782 | newElt[newEltIdx++] = ThumbnailBuildStacks(bg) + '<div class="nGY2GThumbnail" style="display:none;opacity:0;' + mp + '"><div class="nGY2GThumbnailSub ' + ( G.O.thumbnailSelectable && item.selected ? "nGY2GThumbnailSubSelected" : "" ) + '">';
|
4783 |
|
4784 |
|
4785 |
|
4786 | var w = G.tn.settings.getW();
|
4787 | var h = G.tn.settings.getH();
|
4788 | if( G.tn.settings.getMosaic() !== null ) {
|
4789 |
|
4790 | w = G.GOM.items[GOMidx].width;
|
4791 | h = G.GOM.items[GOMidx].height;
|
4792 | }
|
4793 |
|
4794 | var bgSize = 'contain';
|
4795 | if( G.tn.opt.Get('crop') ) {
|
4796 | bgSize = 'cover';
|
4797 | }
|
4798 |
|
4799 |
|
4800 | 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;";
|
4801 | newElt[newEltIdx++]='<div class="nGY2GThumbnailImage nGY2TnImgBack" style="' + s1 + '"></div>';
|
4802 |
|
4803 |
|
4804 | 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;";
|
4805 | newElt[newEltIdx++]='<div class="nGY2GThumbnailImage nGY2TnImg" style="' + s2 + '">';
|
4806 | newElt[newEltIdx++]=' <img class="nGY2GThumbnailImg nGY2TnImg2" src="' + src + '" alt="' + sTitle + '" style="opacity:0;" data-idx="' + idx + '" data-albumidx="' + G.GOM.albumIdx + '" >';
|
4807 | newElt[newEltIdx++]='</div>';
|
4808 |
|
4809 |
|
4810 | newElt[newEltIdx++]='<div class="nGY2GThumbnailCustomLayer"></div>';
|
4811 |
|
4812 |
|
4813 | if( G.O.thumbnailLabel.get('display') == true ) {
|
4814 |
|
4815 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailLabel" '+ G.tn.style.getLabel(item) + '>';
|
4816 | if( item.kind == 'album' ) {
|
4817 |
|
4818 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailTitle nGY2GThumbnailAlbumTitle" ' + G.tn.style.getTitle() + '>' + G.O.icons.thumbnailAlbum + sTitle + '</div>';
|
4819 | }
|
4820 | else {
|
4821 |
|
4822 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailTitle nGY2GThumbnailImageTitle" ' + G.tn.style.getTitle() + '>' + G.O.icons.thumbnailImage + sTitle + '</div>';
|
4823 | }
|
4824 | newElt[newEltIdx++]= ' <div class="nGY2GThumbnailDescription" ' + G.tn.style.getDesc() + '>' + getTumbnailDescription(item) + '</div>';
|
4825 | newElt[newEltIdx++]= ' </div>';
|
4826 | }
|
4827 |
|
4828 |
|
4829 | newElt[newEltIdx++] = ThumbnailBuildTools(item, lastOne);
|
4830 |
|
4831 |
|
4832 | newElt[newEltIdx++]='</div></div>';
|
4833 |
|
4834 | var $newDiv =jQuery(newElt.join('')).appendTo(G.$E.conTn);
|
4835 |
|
4836 | item.$elt=$newDiv;
|
4837 | $newDiv.data('index',GOMidx);
|
4838 | item.$getElt('.nGY2GThumbnailImg').data('index',GOMidx);
|
4839 |
|
4840 |
|
4841 | var fu=G.O.fnThumbnailInit;
|
4842 | if( fu !== null ) {
|
4843 | typeof fu == 'function' ? fu($newDiv, item, GOMidx) : window[fu]($newDiv, item, GOMidx);
|
4844 | }
|
4845 |
|
4846 | if( item.title != 'image gallery by nanogallery2 [build]' ) {
|
4847 | ThumbnailOverInit(GOMidx);
|
4848 | }
|
4849 |
|
4850 | return ;
|
4851 | }
|
4852 |
|
4853 |
|
4854 |
|
4855 | function ThumbnailBuildTools( item, lastThumbnail ) {
|
4856 |
|
4857 |
|
4858 | var tb = ThumbnailBuildToolbarOne(item, 'topLeft') + ThumbnailBuildToolbarOne(item, 'topRight') + ThumbnailBuildToolbarOne(item, 'bottomLeft') + ThumbnailBuildToolbarOne(item, 'bottomRight');
|
4859 |
|
4860 |
|
4861 | tb += '<div class="nGY2GThumbnailIconsFullThumbnail"></div>';
|
4862 |
|
4863 | return tb;
|
4864 | }
|
4865 |
|
4866 | function ThumbnailBuildToolbarOne( item, position ) {
|
4867 | var toolbar = '';
|
4868 | var tb = G.tn.toolbar.get(item);
|
4869 | var width = { xs:0, sm:1, me:2, la:3, xl:4 };
|
4870 | var cnt = 0;
|
4871 |
|
4872 | if( tb[position] != '' ) {
|
4873 | var pos='top: 0; right: 0; text-align: right;';
|
4874 | switch( position ) {
|
4875 | case 'topLeft':
|
4876 | pos = 'top: 0; left: 0; text-align: left;';
|
4877 | break;
|
4878 | case 'bottomRight':
|
4879 | pos = 'bottom: 0; right: 0; text-align: right;';
|
4880 | break;
|
4881 | case 'bottomLeft':
|
4882 | pos = 'bottom: 0; left: 0; text-align: left;';
|
4883 | break;
|
4884 | }
|
4885 |
|
4886 | toolbar += ' <ul class="nGY2GThumbnailIcons" style="' + pos + '">';
|
4887 |
|
4888 | var icons = tb[position].split(',');
|
4889 | var nb = icons.length;
|
4890 | for( var i = 0; i < nb; i++ ) {
|
4891 | var icon = icons[i].replace(/^\s*|\s*$/, '');
|
4892 |
|
4893 | var minWidth = icon.substring(0,2).toLowerCase();
|
4894 | var tIcon = icon;
|
4895 | var display = true;
|
4896 | if( /xs|sm|me|la|xl/i.test(minWidth) ) {
|
4897 |
|
4898 | if( width[minWidth] > width[G.GOM.curWidth] ) {
|
4899 | display = false;
|
4900 | }
|
4901 | tIcon = icon.substring(2);
|
4902 | }
|
4903 |
|
4904 | if( display ) {
|
4905 | var sp=(i+1<nb ? ' ' :'');
|
4906 | switch( tIcon ) {
|
4907 | case 'COUNTER':
|
4908 | if( item.kind == 'album' ) {
|
4909 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="">';
|
4910 | toolbar += ' <div class="nGY2GThumbnailIconImageCounter"></div>';
|
4911 | toolbar += ' <div class="nGY2GThumbnailIconText">' + G.O.icons.thumbnailCounter+Math.max((item.getContentLength(false)),item.numberItems) + sp + '</div>';
|
4912 | toolbar += ' </li>';
|
4913 | cnt++;
|
4914 | }
|
4915 | break;
|
4916 | case 'COUNTER2':
|
4917 | if( item.kind == 'album' ) {
|
4918 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="">';
|
4919 | toolbar += ' <div class="nGY2GThumbnailIconTextBadge">' + G.O.icons.thumbnailCounter+Math.max((item.getContentLength(false)),item.numberItems) + sp + '</div>';
|
4920 | toolbar += ' </li>';
|
4921 | cnt++;
|
4922 | }
|
4923 | break;
|
4924 | case 'SHARE':
|
4925 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
4926 | toolbar += ' <div>' + G.O.icons.thumbnailShare + '</div>';
|
4927 | toolbar += ' </li>';
|
4928 | cnt++;
|
4929 | break;
|
4930 | case 'DOWNLOAD':
|
4931 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
4932 | toolbar += ' <div>' + G.O.icons.thumbnailDownload + '</div>';
|
4933 | toolbar += ' </li>';
|
4934 | cnt++;
|
4935 | break;
|
4936 | case 'INFO':
|
4937 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
4938 | toolbar += ' <div>' + G.O.icons.thumbnailInfo + '</div>';
|
4939 | toolbar += ' </li>';
|
4940 | cnt++;
|
4941 | break;
|
4942 | case 'CART':
|
4943 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon + '">';
|
4944 | toolbar += ' <div>' + G.O.icons.thumbnailCart + '</div>';
|
4945 | toolbar += ' </li>';
|
4946 | cnt++;
|
4947 | break;
|
4948 | case 'DISPLAY':
|
4949 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="DISPLAY">';
|
4950 | toolbar += ' <div class="nGY2GThumbnailIconImageShare">' + G.O.icons.thumbnailDisplay + '</div>';
|
4951 | toolbar += ' </li>';
|
4952 | cnt++;
|
4953 | break;
|
4954 | case 'CUSTOM1':
|
4955 | case 'CUSTOM2':
|
4956 | case 'CUSTOM3':
|
4957 | case 'CUSTOM4':
|
4958 | case 'CUSTOM5':
|
4959 | case 'CUSTOM6':
|
4960 | case 'CUSTOM7':
|
4961 | case 'CUSTOM8':
|
4962 | case 'CUSTOM9':
|
4963 | case 'CUSTOM10':
|
4964 | var cust = tIcon.replace('CUSTOM', '');
|
4965 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="' + tIcon.toLowerCase() + '">';
|
4966 | toolbar += ' <div class="nGY2GThumbnailIconImageShare">' + G.O.icons['thumbnailCustomTool' + cust] + '</div>';
|
4967 | toolbar += ' </li>';
|
4968 | cnt++;
|
4969 | break;
|
4970 | case 'FEATURED':
|
4971 | if( item.featured === true ) {
|
4972 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="">';
|
4973 | toolbar += ' <div class="nGY2GThumbnailIconImageFeatured">' + G.O.icons.thumbnailFeatured + '</div>';
|
4974 | toolbar += ' </li>';
|
4975 | cnt++;
|
4976 | }
|
4977 | break;
|
4978 | case 'SELECT':
|
4979 | if( G.O.thumbnailSelectable == true ) {
|
4980 | toolbar += ' <li class="nGY2GThumbnailIcon" data-ngy2action="TOGGLESELECT">';
|
4981 | if( item.selected === true ) {
|
4982 | toolbar += ' <div class="nGY2GThumbnailIconImageSelect nGY2ThumbnailSelected">' + G.O.icons.thumbnailSelected + '</div>';
|
4983 | }
|
4984 | else {
|
4985 | toolbar += ' <div class="nGY2GThumbnailIconImageSelect nGY2ThumbnailUnselected">' + G.O.icons.thumbnailUnselected + '</div>';
|
4986 | }
|
4987 | toolbar += ' </li>';
|
4988 | cnt++;
|
4989 | }
|
4990 | break;
|
4991 | }
|
4992 | }
|
4993 | }
|
4994 | toolbar += ' </ul>';
|
4995 | }
|
4996 |
|
4997 | if( cnt > 0 ) {
|
4998 | return toolbar;
|
4999 | }
|
5000 | else {
|
5001 | return '';
|
5002 | }
|
5003 | }
|
5004 |
|
5005 | function getThumbnailTitle( item ) {
|
5006 |
|
5007 | var sTitle = item.title;
|
5008 | if( G.O.thumbnailLabel.get('display') == true ) {
|
5009 | if( sTitle === undefined || sTitle.length == 0 ) { sTitle = ' '; }
|
5010 |
|
5011 | if( G.i18nTranslations.thumbnailImageTitle != '' ) {
|
5012 | sTitle = G.i18nTranslations.thumbnailImageTitle;
|
5013 | }
|
5014 | var ml = G.O.thumbnailLabel.get('titleMaxLength');
|
5015 | if( ml > 3 && sTitle.length > ml ){
|
5016 | sTitle = sTitle.substring(0, ml) + '...';
|
5017 | }
|
5018 | }
|
5019 |
|
5020 | return sTitle;
|
5021 | }
|
5022 |
|
5023 | function getTumbnailDescription( item ) {
|
5024 | var sDesc = '';
|
5025 | if( G.O.thumbnailLabel.get('displayDescription') == true ) {
|
5026 | if( item.kind == 'album' ) {
|
5027 | if( G.i18nTranslations.thumbnailImageDescription != '' ) {
|
5028 | sDesc = G.i18nTranslations.thumbnailAlbumDescription;
|
5029 | }
|
5030 | else {
|
5031 | sDesc = item.description;
|
5032 | }
|
5033 | }
|
5034 | else {
|
5035 | if( G.i18nTranslations.thumbnailImageDescription != '' ) {
|
5036 | sDesc = G.i18nTranslations.thumbnailImageDescription;
|
5037 | }
|
5038 | else {
|
5039 | sDesc = item.description;
|
5040 | }
|
5041 | }
|
5042 | var ml = G.O.thumbnailLabel.get('descriptionMaxLength');
|
5043 | if( ml > 3 && sDesc.length > ml ){
|
5044 | sDesc = sDesc.substring(0, ml) + '...';
|
5045 | }
|
5046 | if( sDesc.length == 0 ) {
|
5047 | sDesc = ' ';
|
5048 | }
|
5049 | }
|
5050 |
|
5051 | return sDesc;
|
5052 | }
|
5053 |
|
5054 |
|
5055 |
|
5056 |
|
5057 | function NbThumbnailsPerRow( areaWidth ) {
|
5058 | var tnW = G.tn.defaultSize.getOuterWidth();
|
5059 |
|
5060 | var nbMaxTn = 0;
|
5061 | if( G.O.thumbnailAlignment == 'justified' ) {
|
5062 | nbMaxTn = Math.floor((areaWidth)/(tnW));
|
5063 | }
|
5064 | else {
|
5065 | nbMaxTn = Math.floor((areaWidth + G.tn.opt.Get('gutterWidth'))/(tnW + G.tn.opt.Get('gutterWidth')));
|
5066 | }
|
5067 |
|
5068 | if( G.O.maxItemsPerLine >0 && nbMaxTn > G.O.maxItemsPerLine ) {
|
5069 | nbMaxTn = G.O.maxItemsPerLine;
|
5070 | }
|
5071 |
|
5072 | if( nbMaxTn < 1 ) { nbMaxTn = 1; }
|
5073 |
|
5074 | return nbMaxTn
|
5075 | }
|
5076 |
|
5077 |
|
5078 | function ThumbnailAppear( n, cnt ) {
|
5079 | var curTn = G.GOM.items[n];
|
5080 | var item = G.I[curTn.thumbnailIdx];
|
5081 |
|
5082 |
|
5083 | if( G.tn.opt.Get('displayTransition') == 'NONE' ) {
|
5084 | item.$elt.css({ opacity: 1 });
|
5085 | ThumbnailAppearFinish( item );
|
5086 | }
|
5087 | else {
|
5088 | if( item.$elt == null ) { return; }
|
5089 | var top = G.GOM.cache.containerOffset.top + ( curTn.top - G.GOM.clipArea.top );
|
5090 | var vp = G.GOM.cache.viewport;
|
5091 | if( (top + (curTn.top - G.GOM.clipArea.top)) >= (vp.t - 50) && top <= (vp.t + vp.h + 50) ) {
|
5092 |
|
5093 | var delay = cnt * G.tn.opt.Get('displayInterval');
|
5094 | if( G.tn.opt.Get('displayTransition') == 'CUSTOM' ) {
|
5095 | if( G.GOM.curNavLevel == 'lN' ) {
|
5096 | G.O.fnThumbnailDisplayEffect(item.$elt, item, n, delay);
|
5097 | }
|
5098 | else {
|
5099 | G.O.fnThumbnailL1DisplayEffect(item.$elt, item, n, delay);
|
5100 | }
|
5101 | }
|
5102 | else {
|
5103 | G.GOM.thumbnails2Display.push({itm: item, d: delay});
|
5104 |
|
5105 | }
|
5106 | return;
|
5107 | }
|
5108 | else {
|
5109 | item.$elt.css({ opacity: 1 });
|
5110 | ThumbnailAppearFinish(item);
|
5111 | }
|
5112 | }
|
5113 | }
|
5114 |
|
5115 |
|
5116 |
|
5117 | function ThumbnailAppearFinish( item ) {
|
5118 |
|
5119 |
|
5120 | var ns = G.tn.opt.Get('stacks');
|
5121 | if( ns > 0 ) {
|
5122 |
|
5123 | item.$elt.css({ display: 'block'});
|
5124 | var o = 0.9;
|
5125 |
|
5126 | for( var i = ns-1; i>=0; i-- ) {
|
5127 | item.$elt.eq(i).css('opacity', o);
|
5128 | o = o - 0.2;
|
5129 | }
|
5130 |
|
5131 | }
|
5132 | }
|
5133 |
|
5134 |
|
5135 | function ThumbnailDisplayAnim2( item, delay ) {
|
5136 | function randomIntFromInterval(min,max) {
|
5137 | return Math.floor(Math.random()*(max-min+1)+min);
|
5138 | }
|
5139 | var oFrom = {};
|
5140 | var oTo = {};
|
5141 |
|
5142 | switch (G.tn.opt.Get('displayTransition')) {
|
5143 | case 'RANDOMSCALE':
|
5144 | var scales = [0.95, 1, 1.05, 1.1];
|
5145 | var zi = [1, 2, 3, 4];
|
5146 |
|
5147 | var r = randomIntFromInterval(0,3);
|
5148 | while( r == G.GOM.lastRandomValue ) {
|
5149 | r = randomIntFromInterval(0,3);
|
5150 | }
|
5151 | G.GOM.lastRandomValue = r;
|
5152 | var f = scales[r];
|
5153 |
|
5154 | item.$elt.css({ 'z-index': G.GOM.lastZIndex+zi[r], 'box-shadow': '0px 0px 5px 3px rgba(0,0,0,0.74)' });
|
5155 |
|
5156 | oFrom = { scale: 0.5, opacity:0 };
|
5157 | oTo = { scale: f, opacity:1 };
|
5158 | break;
|
5159 |
|
5160 | case 'SCALEUP':
|
5161 | var f = G.tn.opt.Get('displayTransitionStartVal');
|
5162 | if( f == 0 ) { f = 0.6; }
|
5163 | oFrom = { scale: f, opacity: 0 };
|
5164 | oTo = { scale: 1, opacity: 1 };
|
5165 | break;
|
5166 |
|
5167 | case 'SCALEDOWN':
|
5168 | var f = G.tn.opt.Get('displayTransitionStartVal');
|
5169 | if( f == 0 ) { f=1.3; }
|
5170 | oFrom = { scale: f, opacity: 0 };
|
5171 | oTo = { scale: 1, opacity: 1 };
|
5172 | break;
|
5173 | case 'SLIDEUP':
|
5174 | var f = G.tn.opt.Get('displayTransitionStartVal');
|
5175 | if( f == 0 ) { f=50; }
|
5176 | oFrom = { opacity: 0, translateY: f };
|
5177 | oTo = { opacity: 1, translateY: 0 };
|
5178 | break;
|
5179 | case 'SLIDEDOWN':
|
5180 | var f=G.tn.opt.Get('displayTransitionStartVal');
|
5181 | if( f == 0 ) { f=-50; }
|
5182 | oFrom = { opacity: 0, translateY: f };
|
5183 | oTo = { opacity: 1, translateY: 0 };
|
5184 | break;
|
5185 | case 'FLIPUP':
|
5186 | var f=G.tn.opt.Get('displayTransitionStartVal');
|
5187 | if( f == 0 ) { f=100; }
|
5188 | oFrom = { opacity: 0, translateY: f, rotateX: 45 };
|
5189 | oTo = { opacity: 1, translateY: 0, rotateX: 0 };
|
5190 | break;
|
5191 |
|
5192 | case 'FLIPDOWN':
|
5193 | var f=G.tn.opt.Get('displayTransitionStartVal');
|
5194 | if( f == 0 ) { f=-100; }
|
5195 | oFrom = { opacity: 0, translateY: f, rotateX: -45 };
|
5196 | oTo = { opacity: 1, translateY: 0, rotateX: 0 };
|
5197 | break;
|
5198 | case 'SLIDEUP2':
|
5199 | var f=G.tn.opt.Get('displayTransitionStartVal');
|
5200 | if( f == 0 ) { f=100; }
|
5201 | oFrom = { opacity: 0, translateY: f, rotateY: 40 };
|
5202 | oTo = { opacity: 1, translateY: 0, rotateY: 0 };
|
5203 | break;
|
5204 | case 'SLIDEDOWN2':
|
5205 | var f=G.tn.opt.Get('displayTransitionStartVal');
|
5206 | if( f == 0 ) { f=-100; }
|
5207 | oFrom = { opacity: 0, translateY: f, rotateY: 40 };
|
5208 | oTo = { opacity: 1, translateY: 0, rotateY: 0 };
|
5209 | break;
|
5210 | case 'SLIDERIGHT':
|
5211 | var f=G.tn.opt.Get('displayTransitionStartVal');
|
5212 | if( f == 0 ) { f=-150; }
|
5213 | oFrom = { opacity: 0, translateX: f };
|
5214 | oTo = { opacity: 1, translateX: 0 };
|
5215 | break;
|
5216 |
|
5217 | case 'SLIDELEFT':
|
5218 | var f=G.tn.opt.Get('displayTransitionStartVal');
|
5219 | if( f == 0 ) { f=150; }
|
5220 | oFrom = { opacity: 0, translateX: f };
|
5221 | oTo = { opacity: 1, translateX: 0 };
|
5222 | break;
|
5223 |
|
5224 | case 'FADEIN':
|
5225 | oFrom = { opacity: 0 };
|
5226 | oTo = { opacity: 1 };
|
5227 | break;
|
5228 |
|
5229 |
|
5230 | }
|
5231 |
|
5232 | var tweenable = new NGTweenable();
|
5233 | tweenable.tween({
|
5234 | from: oFrom,
|
5235 | to: oTo,
|
5236 | attachment: { $e:item.$elt, item: item, tw: tweenable },
|
5237 | delay: delay,
|
5238 | duration: G.tn.opt.Get('displayTransitionDuration'),
|
5239 | easing: G.tn.opt.Get('displayTransitionEasing'),
|
5240 | step: function (state, att) {
|
5241 | window.requestAnimationFrame( function() {
|
5242 | if( att.item.$elt === null ) {
|
5243 | att.tw.stop(false);
|
5244 | return;
|
5245 | }
|
5246 | switch (G.tn.opt.Get('displayTransition')) {
|
5247 | case 'RANDOMSCALE':
|
5248 | att.$e.css( G.CSStransformName , 'scale(' + state.scale + ')').css('opacity', state.opacity);
|
5249 | break;
|
5250 | case 'SCALEUP':
|
5251 | att.$e.css( G.CSStransformName , 'scale('+state.scale+')').css('opacity',state.opacity);
|
5252 | break;
|
5253 | case 'SCALEDOWN':
|
5254 | att.item.$elt.last().css('opacity', state.opacity);
|
5255 | att.item.CSSTransformSet('.nGY2GThumbnail', 'scale', state.scale);
|
5256 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5257 | break;
|
5258 | case 'SLIDEUP':
|
5259 | att.item.$elt.css('opacity', state.opacity);
|
5260 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px, '+state.translateY + 'px');
|
5261 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5262 | break;
|
5263 | case 'SLIDEDOWN':
|
5264 | att.item.$elt.css('opacity', state.opacity);
|
5265 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,'+state.translateY+'px');
|
5266 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5267 | break;
|
5268 | case 'FLIPUP':
|
5269 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,'+state.translateY+'px');
|
5270 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateX', state.rotateX+'deg');
|
5271 | att.item.$elt.css('opacity', state.opacity);
|
5272 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5273 | break;
|
5274 | case 'FLIPDOWN':
|
5275 | att.item.$elt.css('opacity', state.opacity);
|
5276 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,' + state.translateY + 'px');
|
5277 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateX', state.rotateX + 'deg');
|
5278 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5279 | break;
|
5280 | case 'SLIDEUP2':
|
5281 | att.item.$elt.css('opacity', state.opacity);
|
5282 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px,' + state.translateY + 'px');
|
5283 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateY', state.rotateY + 'deg');
|
5284 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5285 | break;
|
5286 | case 'SLIDEDOWN2':
|
5287 | att.item.$elt.css('opacity', state.opacity);
|
5288 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', '0px, ' + state.translateY + 'px');
|
5289 | att.item.CSSTransformSet('.nGY2GThumbnail', 'rotateY', state.rotateY + 'deg');
|
5290 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5291 | break;
|
5292 | case 'SLIDERIGHT':
|
5293 | att.item.$elt.css('opacity', state.opacity);
|
5294 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', state.translateX + 'px, 0px');
|
5295 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5296 | break;
|
5297 | case 'SLIDELEFT':
|
5298 | att.item.CSSTransformSet('.nGY2GThumbnail', 'translate', state.translateX + 'px, 0px');
|
5299 | att.item.$elt.css('opacity', state.opacity);
|
5300 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5301 | break;
|
5302 | case 'FADEIN':
|
5303 | att.$e.css(state);
|
5304 | break;
|
5305 | }
|
5306 | });
|
5307 |
|
5308 | },
|
5309 | finish: function (state, att) {
|
5310 | window.requestAnimationFrame( function() {
|
5311 | if( att.item.$elt === null ) { return; }
|
5312 |
|
5313 | switch (G.tn.opt.Get('displayTransition')) {
|
5314 | case 'RANDOMSCALE':
|
5315 | att.$e.css( G.CSStransformName , 'scale('+state.scale+')').css('opacity', '');
|
5316 | break;
|
5317 | case 'SCALEUP':
|
5318 | att.$e.css( G.CSStransformName , '').css('opacity', '');
|
5319 | break;
|
5320 | case 'SCALEDOWN':
|
5321 | att.item.$elt.last().css('opacity', '');
|
5322 | att.item.CSSTransformSet('.nGY2GThumbnail', 'scale', state.scale);
|
5323 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5324 | break;
|
5325 | case 'SLIDEUP':
|
5326 | att.item.$elt.css('opacity', '');
|
5327 | break;
|
5328 | case 'SLIDEDOWN':
|
5329 | att.item.$elt.css('opacity', '');
|
5330 | break;
|
5331 | case 'FLIPUP':
|
5332 | att.item.$elt.css('opacity', '');
|
5333 | break;
|
5334 | case 'FLIPDOWN':
|
5335 | att.item.$elt.css('opacity', '');
|
5336 | break;
|
5337 | case 'SLIDEUP2':
|
5338 | att.item.$elt.css('opacity', '');
|
5339 | break;
|
5340 | case 'SLIDEDOWN2':
|
5341 | att.item.$elt.css('opacity', '');
|
5342 | att.item.CSSTransformApply('.nGY2GThumbnail');
|
5343 | break;
|
5344 | case 'SLIDERIGHT':
|
5345 | att.item.$elt.css('opacity', '');
|
5346 | break;
|
5347 | case 'SLIDELEFT':
|
5348 | att.item.$elt.css('opacity', '');
|
5349 | break;
|
5350 | case 'FADEIN':
|
5351 | att.$e.css('opacity', '');
|
5352 | break;
|
5353 | }
|
5354 | ThumbnailAppearFinish(att.item);
|
5355 | });
|
5356 |
|
5357 | }
|
5358 | });
|
5359 |
|
5360 | }
|
5361 |
|
5362 |
|
5363 | function ThumbnailDisplayAnimBatch() {
|
5364 |
|
5365 | G.GOM.thumbnails2Display.forEach( function(one) {
|
5366 | ThumbnailDisplayAnim2(one.itm, one.d);
|
5367 | });
|
5368 | G.GOM.thumbnails2Display=[];
|
5369 | }
|
5370 |
|
5371 |
|
5372 |
|
5373 |
|
5374 |
|
5375 | function GalleryAppear() {
|
5376 |
|
5377 | var d=G.galleryDisplayTransitionDuration.Get();
|
5378 | switch( G.galleryDisplayTransition.Get() ){
|
5379 | case 'ROTATEX':
|
5380 | G.$E.base.css({ perspective: '1000px', 'perspective-origin': '50% 0%' });
|
5381 | var tweenable = new NGTweenable();
|
5382 | tweenable.tween({
|
5383 | from: { r: 50 },
|
5384 | to: { r: 0 },
|
5385 | attachment: { orgIdx: G.GOM.albumIdx },
|
5386 | duration: d,
|
5387 | easing: 'easeOutCirc',
|
5388 | step: function (state, att) {
|
5389 | if( att.orgIdx == G.GOM.albumIdx ) {
|
5390 |
|
5391 | G.$E.conTnParent.css( G.CSStransformName , 'rotateX(' + state.r + 'deg)');
|
5392 |
|
5393 | }
|
5394 | }
|
5395 | });
|
5396 | break;
|
5397 | case 'SLIDEUP':
|
5398 | G.$E.conTnParent.css({ opacity: 0 });
|
5399 | var tweenable = new NGTweenable();
|
5400 | tweenable.tween({
|
5401 | from: { y: 200, o: 0 },
|
5402 | to: { y: 0, o: 1 },
|
5403 | attachment: { orgIdx: G.GOM.albumIdx },
|
5404 | duration: d,
|
5405 | easing: 'easeOutCirc',
|
5406 | step: function (state, att) {
|
5407 | if( att.orgIdx == G.GOM.albumIdx ) {
|
5408 |
|
5409 | G.$E.conTnParent.css( G.CSStransformName , 'translate( 0px, '+state.y + 'px)').css('opacity', state.o);
|
5410 |
|
5411 | }
|
5412 | }
|
5413 | });
|
5414 | break;
|
5415 | case 'NONE':
|
5416 | default:
|
5417 | break;
|
5418 | }
|
5419 |
|
5420 |
|
5421 | }
|
5422 |
|
5423 |
|
5424 |
|
5425 |
|
5426 |
|
5427 | function ThumbnailOverInit( GOMidx ) {
|
5428 |
|
5429 |
|
5430 |
|
5431 |
|
5432 |
|
5433 | var curTn = G.GOM.items[GOMidx];
|
5434 | var item = G.I[curTn.thumbnailIdx];
|
5435 |
|
5436 | if( item.$elt == null ) { return; }
|
5437 |
|
5438 | var fu = G.O.fnThumbnailHoverInit;
|
5439 | if( fu !== null ) {
|
5440 | typeof fu == 'function' ? fu($e, item, GOMidx) : window[fu]($e, item, GOMidx);
|
5441 | }
|
5442 |
|
5443 |
|
5444 | var inits = G.tn.buildInit.get();
|
5445 | for( var j = 0; j < inits.length; j++) {
|
5446 | switch( inits[j].property ) {
|
5447 |
|
5448 | case 'scale':
|
5449 | case 'rotateX':
|
5450 | case 'rotateY':
|
5451 | case 'rotateZ':
|
5452 | case 'translateX':
|
5453 | case 'translateY':
|
5454 | case 'translateZ':
|
5455 | item.CSSTransformSet(inits[j].element, inits[j].property, inits[j].value);
|
5456 | item.CSSTransformApply(inits[j].element);
|
5457 | break;
|
5458 |
|
5459 | case 'blur':
|
5460 | case 'brightness':
|
5461 | case 'grayscale':
|
5462 | case 'sepia':
|
5463 | case 'contrast':
|
5464 | case 'opacity':
|
5465 | case 'saturate':
|
5466 | item.CSSFilterSet(inits[j].element, inits[j].property, inits[j].value);
|
5467 | item.CSSFilterApply(inits[j].element);
|
5468 | break;
|
5469 | default:
|
5470 | var $t=item.$getElt(inits[j].element);
|
5471 | $t.css( inits[j].property, inits[j].value );
|
5472 | break;
|
5473 | }
|
5474 | }
|
5475 |
|
5476 |
|
5477 | var effects = G.tn.hoverEffects.get();
|
5478 | for( var j = 0; j < effects.length; j++) {
|
5479 | if( effects[j].firstKeyframe === true ) {
|
5480 | switch( effects[j].type ) {
|
5481 | case 'scale':
|
5482 | case 'rotateX':
|
5483 | case 'rotateY':
|
5484 | case 'rotateZ':
|
5485 | case 'translateX':
|
5486 | case 'translateY':
|
5487 | case 'translateZ':
|
5488 | item.CSSTransformSet(effects[j].element, effects[j].type, effects[j].from);
|
5489 | item.CSSTransformApply(effects[j].element);
|
5490 | break;
|
5491 | case 'blur':
|
5492 | case 'brightness':
|
5493 | case 'grayscale':
|
5494 | case 'sepia':
|
5495 | case 'contrast':
|
5496 | case 'opacity':
|
5497 | case 'saturate':
|
5498 | item.CSSFilterSet(effects[j].element, effects[j].type, effects[j].from);
|
5499 | item.CSSFilterApply(effects[j].element);
|
5500 | break;
|
5501 | default:
|
5502 | var $t = item.$getElt(effects[j].element);
|
5503 | $t.css( effects[j].type, effects[j].from );
|
5504 | break;
|
5505 |
|
5506 | }
|
5507 | }
|
5508 | }
|
5509 | item.hoverInitDone=true;
|
5510 | }
|
5511 |
|
5512 | function ThumbnailHoverReInitAll() {
|
5513 | if( G.GOM.albumIdx == -1 ) { return; };
|
5514 | var l = G.GOM.items.length;
|
5515 | for( var i = 0; i < l ; i++ ) {
|
5516 | ThumbnailOverInit(i);
|
5517 |
|
5518 | G.I[G.GOM.items[i].thumbnailIdx].hovered = false;
|
5519 | }
|
5520 | }
|
5521 |
|
5522 |
|
5523 | function ThumbnailHover( GOMidx ) {
|
5524 | if( G.GOM.albumIdx == -1 || !G.galleryResizeEventEnabled ) { return; };
|
5525 | if( G.GOM.slider.hostIdx == GOMidx ) {
|
5526 |
|
5527 | return;
|
5528 | }
|
5529 | var curTn = G.GOM.items[GOMidx];
|
5530 | var item = G.I[curTn.thumbnailIdx];
|
5531 | if( item.kind == 'albumUp' || item.$elt == null ) { return; }
|
5532 |
|
5533 | item.hovered = true;
|
5534 |
|
5535 | var fu = G.O.fnThumbnailHover;
|
5536 | if( fu !== null ) {
|
5537 | typeof fu == 'function' ? fu(item.$elt, item, GOMidx) : window[fu](item.$elt, item, GOMidx);
|
5538 | }
|
5539 | var effects = G.tn.hoverEffects.get();
|
5540 |
|
5541 | try {
|
5542 | for( var j = 0; j < effects.length; j++) {
|
5543 | if( effects[j].hoverin === true ) {
|
5544 |
|
5545 | item.animate( effects[j], 0, true );
|
5546 | }
|
5547 | }
|
5548 |
|
5549 |
|
5550 | }
|
5551 | catch (e) {
|
5552 | NanoAlert(G, 'error on hover: ' + e.message );
|
5553 | }
|
5554 |
|
5555 | }
|
5556 |
|
5557 | function ThumbnailHoverOutAll() {
|
5558 | if( G.GOM.albumIdx == -1 ) { return; };
|
5559 | var l = G.GOM.items.length;
|
5560 | for( var i = 0; i < l ; i++ ) {
|
5561 | if( G.GOM.items[i].inDisplayArea ) {
|
5562 | ThumbnailHoverOut(i);
|
5563 | }
|
5564 | else {
|
5565 | G.I[G.GOM.items[i].thumbnailIdx].hovered = false;
|
5566 | }
|
5567 | }
|
5568 | }
|
5569 |
|
5570 |
|
5571 | function ThumbnailHoverOut( GOMidx ) {
|
5572 | if( G.GOM.albumIdx == -1 || !G.galleryResizeEventEnabled ) { return; }
|
5573 |
|
5574 | if( G.GOM.slider.hostIdx == GOMidx ) {
|
5575 |
|
5576 | return;
|
5577 | }
|
5578 |
|
5579 | var curTn = G.GOM.items[GOMidx];
|
5580 | var item = G.I[curTn.thumbnailIdx];
|
5581 | if( item.kind == 'albumUp' || !item.hovered ) { return; }
|
5582 | item.hovered = false;
|
5583 | if( item.$elt == null ) { return; }
|
5584 |
|
5585 | var fu = G.O.fnThumbnailHoverOut;
|
5586 | if( fu !== null ) {
|
5587 | typeof fu == 'function' ? fu(item.$elt, item, GOMidx) : window[fu](item.$elt, item, GOMidx);
|
5588 | }
|
5589 |
|
5590 | var effects = G.tn.hoverEffects.get();
|
5591 | try {
|
5592 | for( var j = 0; j < effects.length; j++) {
|
5593 | if( effects[j].hoverout === true ) {
|
5594 |
|
5595 | item.animate( effects[j], 0, false );
|
5596 | }
|
5597 | }
|
5598 |
|
5599 |
|
5600 | }
|
5601 | catch (e) {
|
5602 | NanoAlert(G, 'error on hoverOut: ' + e.message );
|
5603 | }
|
5604 |
|
5605 | }
|
5606 |
|
5607 |
|
5608 |
|
5609 | function DisplayPhoto( imageID, albumID ) {
|
5610 |
|
5611 | if( G.O.debugMode ) { console.log('#DisplayPhoto : '+ albumID +'-'+ imageID); }
|
5612 | var albumIdx = NGY2Item.GetIdx(G, albumID);
|
5613 | if( albumIdx == 0 ) {
|
5614 | G.GOM.curNavLevel = 'l1';
|
5615 | }
|
5616 | else {
|
5617 | G.GOM.curNavLevel = 'lN';
|
5618 | }
|
5619 |
|
5620 | if( albumIdx == -1 ) {
|
5621 |
|
5622 | if( G.O.kind != '' ) {
|
5623 |
|
5624 | NGY2Item.New( G, '', '', albumID, '0', 'album' );
|
5625 | albumIdx = G.I.length - 1;
|
5626 | }
|
5627 | }
|
5628 |
|
5629 | var ngy2ItemIdx = NGY2Item.GetIdx(G, imageID);
|
5630 | if( ngy2ItemIdx == -1 ) {
|
5631 |
|
5632 | AlbumGetContent( albumID, DisplayPhoto, imageID, albumID );
|
5633 | return;
|
5634 | }
|
5635 |
|
5636 | if( G.O.debugMode ) { console.log('#DisplayPhoto : '+ ngy2ItemIdx); }
|
5637 |
|
5638 | DisplayPhotoIdx(ngy2ItemIdx);
|
5639 |
|
5640 | }
|
5641 |
|
5642 |
|
5643 |
|
5644 |
|
5645 | function albumGetInfo( albumIdx, fnToCall ) {
|
5646 | var url = '';
|
5647 | var kind = 'image';
|
5648 |
|
5649 | switch( G.O.kind ) {
|
5650 | case 'json':
|
5651 |
|
5652 | case 'flickr':
|
5653 |
|
5654 | case 'picasa':
|
5655 | case 'google':
|
5656 | case 'google2':
|
5657 | default:
|
5658 | url = G.Google.url() + 'user/'+G.O.userID+'/albumid/'+G.I[albumIdx].GetID()+'?alt=json&&max-results=1&fields=title';
|
5659 | break;
|
5660 | }
|
5661 |
|
5662 | jQuery.ajaxSetup({ cache: false });
|
5663 | jQuery.support.cors = true;
|
5664 |
|
5665 | var tId = setTimeout( function() {
|
5666 |
|
5667 |
|
5668 | NanoAlert(G, 'Could not retrieve AJAX data...');
|
5669 | }, 60000 );
|
5670 | jQuery.getJSON(url, function(data, status, xhr) {
|
5671 | clearTimeout(tId);
|
5672 |
|
5673 |
|
5674 | fnToCall( G.I[albumIdx].GetID() );
|
5675 |
|
5676 | })
|
5677 | .fail( function(jqxhr, textStatus, error) {
|
5678 | clearTimeout(tId);
|
5679 |
|
5680 | var err = textStatus + ', ' + error;
|
5681 | NanoAlert('Could not retrieve ajax data: ' + err);
|
5682 | });
|
5683 |
|
5684 | }
|
5685 |
|
5686 |
|
5687 |
|
5688 | function AlbumGetContent( albumID, fnToCall, fnParam1, fnParam2 ) {
|
5689 |
|
5690 |
|
5691 |
|
5692 |
|
5693 |
|
5694 | switch( G.O.kind ) {
|
5695 |
|
5696 | case '':
|
5697 | AlbumGetMarkupOrApi(fnToCall, fnParam1, fnParam2);
|
5698 | break;
|
5699 |
|
5700 | default:
|
5701 | jQuery.nanogallery2['data_'+G.O.kind](G, 'AlbumGetContent', albumID, fnToCall, fnParam1, fnParam2 );
|
5702 | }
|
5703 |
|
5704 | }
|
5705 |
|
5706 | var mediaList = {
|
5707 | youtube : {
|
5708 | getID: function( url ) {
|
5709 |
|
5710 | var s = url.match( /(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/ );
|
5711 | return s != null ? s[1] : null;
|
5712 | },
|
5713 | thumbUrl: function( id ) {
|
5714 | return 'https://img.youtube.com/vi/' + id + '/hqdefault.jpg';
|
5715 | },
|
5716 | url: function( id ) {
|
5717 | return 'https://www.youtube.com/embed/' + id;
|
5718 | },
|
5719 | markup: function( id ) {
|
5720 |
|
5721 | return '<iframe class="nGY2ViewerMedia" src="https://www.youtube.com/embed/' + id + '?rel=0" frameborder="0" allow="autoplay" allowfullscreen></iframe>';
|
5722 | },
|
5723 | kind: 'iframe'
|
5724 | },
|
5725 | vimeo : {
|
5726 | getID: function( url ) {
|
5727 |
|
5728 | var s = url.match( /^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/ );
|
5729 | return s != null ? s[5] : null;
|
5730 | },
|
5731 | url: function( id ) {
|
5732 | return 'https://player.vimeo.com/video/' + id;
|
5733 | },
|
5734 | markup: function( id ) {
|
5735 |
|
5736 | return '<iframe class="nGY2ViewerMedia" src="https://player.vimeo.com/video/' + id + '?rel=0" frameborder="0" allow="autoplay" allowfullscreen></iframe>';
|
5737 | },
|
5738 | kind: 'iframe'
|
5739 | },
|
5740 | dailymotion : {
|
5741 | getID: function( url ) {
|
5742 |
|
5743 | var m = url.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);
|
5744 | if (m !== null) {
|
5745 | if(m[4] !== undefined) {
|
5746 | return m[4];
|
5747 | }
|
5748 | return m[2];
|
5749 | }
|
5750 | return null;
|
5751 | },
|
5752 | thumbUrl: function( id ) {
|
5753 | return 'https://www.dailymotion.com/thumbnail/video/' + id;
|
5754 | },
|
5755 | url: function( id ) {
|
5756 | return 'https://www.dailymotion.com/embed/video/' + id;
|
5757 | },
|
5758 | markup: function( id ) {
|
5759 |
|
5760 | return '<iframe class="nGY2ViewerMedia" src="https://www.dailymotion.com/embed/video/' + id + '?rel=0" frameborder="0" allow="autoplay" allowfullscreen></iframe>';
|
5761 | },
|
5762 | kind: 'iframe'
|
5763 | },
|
5764 | selfhosted : {
|
5765 |
|
5766 | getID: function( url ) {
|
5767 |
|
5768 |
|
5769 |
|
5770 | var extension = url.split('.').pop();
|
5771 |
|
5772 |
|
5773 | var s = ( extension === 'mp4' || extension === 'webm' || extension === 'ogv' || extension === '3gp' ) ? extension : null ;
|
5774 | return s;
|
5775 | },
|
5776 | markup: function( url ) {
|
5777 |
|
5778 | var extension = url.split('.').pop();
|
5779 | return '<video controls class="nGY2ViewerMedia"><source src="'+ url +'" type="video/'+ extension +'" preload="auto">Your browser does not support the video tag (HTML 5).</video>';
|
5780 | },
|
5781 | kind: 'video',
|
5782 | selfhosted : true
|
5783 | }
|
5784 | };
|
5785 |
|
5786 | function AlbumGetMarkupOrApi ( fnToCall, fnParam1, fnParam2 ) {
|
5787 |
|
5788 | if( G.markupOrApiProcessed === true ) {
|
5789 |
|
5790 | DisplayAlbum('-1', 0);
|
5791 | return;
|
5792 | }
|
5793 |
|
5794 | if( G.O.items !== undefined && G.O.items !== null ) {
|
5795 |
|
5796 | GetContentApiObject();
|
5797 | }
|
5798 | else {
|
5799 | if( G.O.$markup.length > 0 ) {
|
5800 |
|
5801 | GetContentMarkup( G.O.$markup );
|
5802 | G.O.$markup=[] ;
|
5803 | }
|
5804 | else {
|
5805 | NanoConsoleLog(G, 'error: no media to process.');
|
5806 | return;
|
5807 | }
|
5808 | }
|
5809 |
|
5810 | G.markupOrApiProcessed = true;
|
5811 | if( fnToCall !== null && fnToCall !== undefined) {
|
5812 | fnToCall( fnParam1, fnParam2, null );
|
5813 | }
|
5814 | }
|
5815 |
|
5816 | function StartsWithProtocol ( path ) {
|
5817 | if( path == null || path == undefined ) { return false; }
|
5818 |
|
5819 | var pattern = /^((http|https|ftp|ftps|file):\/\/)/;
|
5820 | if( !pattern.test(path) ) {
|
5821 |
|
5822 | return false;
|
5823 | }
|
5824 | return true;
|
5825 | }
|
5826 |
|
5827 | function GetContentApiObject() {
|
5828 | var foundAlbumID=false;
|
5829 | var nbTitles = 0;
|
5830 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
5831 |
|
5832 | G.I[0].contentIsLoaded=true;
|
5833 |
|
5834 | jQuery.each(G.O.items, function(i,item){
|
5835 |
|
5836 | var title = '';
|
5837 | title=GetI18nItem(item, 'title');
|
5838 | if( title === undefined ) { title=''; }
|
5839 |
|
5840 | var src='';
|
5841 | if( item['src'+RetrieveCurWidth().toUpperCase()] !== undefined ) {
|
5842 | src = item['src'+RetrieveCurWidth().toUpperCase()];
|
5843 | }
|
5844 | else {
|
5845 | src = item.src;
|
5846 | }
|
5847 | if( !StartsWithProtocol(src) ) {
|
5848 | src = G.O.itemsBaseURL + src;
|
5849 | }
|
5850 |
|
5851 | var thumbsrc = '';
|
5852 | if( item.srct !== undefined && item.srct.length > 0 ) {
|
5853 | thumbsrc = item.srct;
|
5854 | if( !StartsWithProtocol(thumbsrc) ) {
|
5855 | thumbsrc = G.O.itemsBaseURL + thumbsrc;
|
5856 | }
|
5857 | }
|
5858 | else {
|
5859 | thumbsrc = src;
|
5860 | }
|
5861 |
|
5862 | var thumbsrcX2 = '';
|
5863 | if( item.srct2x !== undefined && item.srct2x.length > 0 ) {
|
5864 | thumbsrcX2 = item.srct2x;
|
5865 | if( !StartsWithProtocol(thumbsrcX2) ) {
|
5866 | thumbsrcX2 = G.O.itemsBaseURL + thumbsrcX2;
|
5867 | }
|
5868 | }
|
5869 | else {
|
5870 | if( thumbsrc != '' ) {
|
5871 | thumbsrcX2 = thumbsrc;
|
5872 | }
|
5873 | else {
|
5874 | thumbsrcX2 = src;
|
5875 | }
|
5876 | }
|
5877 |
|
5878 | if( G.O.thumbnailLabel.get('title') != '' ) {
|
5879 | title = GetImageTitle(src);
|
5880 | }
|
5881 |
|
5882 | var description='';
|
5883 | description=GetI18nItem(item,'description');
|
5884 | if( description === undefined ) { description=''; }
|
5885 |
|
5886 |
|
5887 |
|
5888 |
|
5889 | var tags = GetI18nItem(item, 'tags');
|
5890 | if( tags === undefined ) { tags=''; }
|
5891 |
|
5892 | var albumID = 0;
|
5893 | if( item.albumID !== undefined ) {
|
5894 | albumID=item.albumID;
|
5895 | foundAlbumID = true;
|
5896 | }
|
5897 | var ID = null;
|
5898 | if( item.ID !== undefined ) {
|
5899 | ID = item.ID;
|
5900 | }
|
5901 | var kind = 'image';
|
5902 | if( item.kind !== undefined && item.kind.length > 0 ) {
|
5903 | kind = item.kind;
|
5904 | }
|
5905 |
|
5906 | var newItem=NGY2Item.New( G, title, description, ID, albumID, kind, tags );
|
5907 | if( title != '' ) {
|
5908 | nbTitles++;
|
5909 | }
|
5910 |
|
5911 |
|
5912 | newItem.setMediaURL( src, 'img');
|
5913 |
|
5914 |
|
5915 | jQuery.each(mediaList, function ( n, media ) {
|
5916 | var id = media.getID(src);
|
5917 | if( id != null ) {
|
5918 | if( typeof media.url == 'function' ) { src = media.url(id); }
|
5919 | if( typeof media.thumbUrl == 'function' ) { thumbsrc = media.thumbUrl(id); }
|
5920 | newItem.mediaKind = media.kind;
|
5921 | newItem.mediaMarkup = ( media.selfhosted ) ? media.markup( src ) : media.markup(id);
|
5922 | return false;
|
5923 | }
|
5924 | });
|
5925 |
|
5926 |
|
5927 | if( item.imageWidth !== undefined ) { newItem.imageWidth = item.width; }
|
5928 | if( item.imageHeight !== undefined ) { newItem.imageHeight = item.height; }
|
5929 |
|
5930 |
|
5931 |
|
5932 |
|
5933 | var tw = item.imgtWidth !== undefined ? item.imgtWidth : 0;
|
5934 | var th = item.imgtHeight !== undefined ? item.imgtHeight : 0;
|
5935 |
|
5936 |
|
5937 | newItem.thumbs = {
|
5938 | url: { l1 : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc }, lN : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc } },
|
5939 | width: { l1 : { xs: tw, sm: tw, me: tw, la: tw, xl: tw }, lN : { xs: tw, sm: tw, me: tw, la: tw, xl: tw } },
|
5940 | height: { l1 : { xs: th, sm: th, me: th, la: th, xl: th }, lN : { xs: th, sm: th, me: th, la: th, xl: th } }
|
5941 | };
|
5942 |
|
5943 |
|
5944 | if( newItem.mediaKind == 'img' ) {
|
5945 |
|
5946 |
|
5947 | var lst=['xs', 'sm', 'me', 'la', 'xl'];
|
5948 | for( var i=0; i< lst.length; i++ ) {
|
5949 |
|
5950 | var turl = item['srct' + lst[i].toUpperCase()];
|
5951 | if( turl !== undefined ) {
|
5952 | if( !StartsWithProtocol(turl) ) {
|
5953 | turl = G.O.itemsBaseURL + turl;
|
5954 | }
|
5955 | newItem.url.l1[lst[i]] = turl;
|
5956 | newItem.url.lN[lst[i]] = turl;
|
5957 | }
|
5958 |
|
5959 | var tw = item['imgt' + lst[i].toUpperCase() + 'Width'];
|
5960 | if( tw != undefined ) {
|
5961 | newItem.width.l1[lst[i]] = parseInt(tw);
|
5962 | newItem.width.lN[lst[i]] = parseInt(tw);
|
5963 | }
|
5964 |
|
5965 | var th = item['imgt' + lst[i].toUpperCase() + 'Height'];
|
5966 | if( th != undefined ) {
|
5967 | newItem.height.l1[lst[i]] = parseInt(th);
|
5968 | newItem.height.lN[lst[i]] = parseInt(th);
|
5969 | }
|
5970 | }
|
5971 | }
|
5972 |
|
5973 |
|
5974 | if( item.imageDominantColors !== undefined ) {
|
5975 | newItem.imageDominantColors = item.imageDominantColors;
|
5976 | }
|
5977 |
|
5978 | if( item.imageDominantColor !== undefined ) {
|
5979 | newItem.imageDominantColor = item.imageDominantColor;
|
5980 | }
|
5981 |
|
5982 |
|
5983 | if( item.destURL !== undefined && item.destURL.length>0 ) {
|
5984 | newItem.destinationURL = item.destURL;
|
5985 | }
|
5986 |
|
5987 |
|
5988 | if( item.downloadURL !== undefined && item.downloadURL.length>0 ) {
|
5989 | newItem.downloadURL = item.downloadURL;
|
5990 | }
|
5991 |
|
5992 |
|
5993 |
|
5994 | if( item.exifModel !== undefined ) { newItem.exif.model = item.exifModel; }
|
5995 |
|
5996 | if( item.exifFlash !== undefined ) { newItem.exif.flash = item.exifFlash; }
|
5997 |
|
5998 | if( item.exifFocalLength !== undefined ) { newItem.exif.focallength = item.exifFocalLength; }
|
5999 |
|
6000 | if( item.exifFStop !== undefined ) { newItem.exif.fstop = item.exifFStop; }
|
6001 |
|
6002 | if( item.exifExposure !== undefined ) { newItem.exif.exposure = item.exifExposure; }
|
6003 |
|
6004 | if( item.exifIso !== undefined ) { newItem.exif.iso = item.exifIso; }
|
6005 |
|
6006 | if( item.exifTime !== undefined ) { newItem.exif.time = item.exifTime; }
|
6007 |
|
6008 | if( item.exifLocation !== undefined ) { newItem.exif.location = item.exifLocation; }
|
6009 |
|
6010 |
|
6011 |
|
6012 | if( item.customData !== null ) {
|
6013 | newItem.customData = cloneJSObject( item.customData );
|
6014 | }
|
6015 |
|
6016 | newItem.contentIsLoaded = true;
|
6017 |
|
6018 | var fu = G.O.fnProcessData;
|
6019 | if( fu !== null ) {
|
6020 | typeof fu == 'function' ? fu(newItem, 'api', item) : window[fu](newItem, 'api', item);
|
6021 | }
|
6022 |
|
6023 | AlbumPostProcess(albumID);
|
6024 | });
|
6025 |
|
6026 |
|
6027 | if( nbTitles == 0 ) { G.O.thumbnailLabel.display=false; }
|
6028 |
|
6029 | }
|
6030 |
|
6031 |
|
6032 | function GetContentMarkup( $elements ) {
|
6033 | var foundAlbumID = false;
|
6034 | var nbTitles = 0;
|
6035 | var AlbumPostProcess = NGY2Tools.AlbumPostProcess.bind(G);
|
6036 |
|
6037 | G.I[0].contentIsLoaded = true;
|
6038 |
|
6039 | jQuery.each($elements, function(i, item){
|
6040 |
|
6041 |
|
6042 | var data = {
|
6043 |
|
6044 | 'data-ngdesc': '',
|
6045 | 'data-ngid': null,
|
6046 | 'data-ngkind': 'image',
|
6047 | 'data-ngtags': null,
|
6048 | 'data-ngdest': '',
|
6049 | 'data-ngthumbimgwidth': 0,
|
6050 | 'data-ngthumbimgheight': 0,
|
6051 | 'data-ngimagewidth': 0,
|
6052 | 'data-ngimageheight': 0,
|
6053 | 'data-ngimagedominantcolors': null,
|
6054 | 'data-ngimagedominantcolor': null,
|
6055 | 'data-ngexifmodel': '',
|
6056 | 'data-ngexifflash': '',
|
6057 | 'data-ngexiffocallength': '',
|
6058 | 'data-ngexiffstop': '',
|
6059 | 'data-ngexifexposure': '',
|
6060 | 'data-ngexifiso': '',
|
6061 | 'data-ngexiftime': '',
|
6062 | 'data-ngexiflocation': ''
|
6063 | };
|
6064 | [].forEach.call( item.attributes, function(attr) {
|
6065 | data[attr.name.toLowerCase()] = attr.value;
|
6066 | });
|
6067 |
|
6068 |
|
6069 | var src = '',
|
6070 | st = RetrieveCurWidth().toUpperCase();
|
6071 | if( data.hasOwnProperty('data-ngsrc'+st) ) {
|
6072 | src = data['data-ngsrc'+st];
|
6073 | }
|
6074 | if( src == '' ) {
|
6075 | src = data['href'];
|
6076 | }
|
6077 | if( !StartsWithProtocol(src) ) {
|
6078 | src = G.O.itemsBaseURL + src;
|
6079 | }
|
6080 |
|
6081 |
|
6082 | var thumbsrc = '';
|
6083 | if( data.hasOwnProperty('data-ngthumb') ) {
|
6084 | thumbsrc = data['data-ngthumb'];
|
6085 | if( !StartsWithProtocol(thumbsrc) ) {
|
6086 | thumbsrc = G.O.itemsBaseURL + thumbsrc;
|
6087 | }
|
6088 | }
|
6089 | else {
|
6090 | thumbsrc = src;
|
6091 | }
|
6092 | var thumbsrcX2 = '';
|
6093 | if( data.hasOwnProperty('data-ngthumb2x') ) {
|
6094 | thumbsrcX2 = data['data-ngthumb2x'];
|
6095 | if( !StartsWithProtocol(thumbsrcX2) ) {
|
6096 | thumbsrcX2 = G.O.itemsBaseURL + thumbsrcX2;
|
6097 | }
|
6098 | }
|
6099 |
|
6100 |
|
6101 | var description = data['data-ngdesc'];
|
6102 | var ID = data['id'];
|
6103 | if( ID == undefined ) {
|
6104 | ID = data['data-ngid'];
|
6105 | }
|
6106 | var kind = data['data-ngkind'];
|
6107 | var tags = data['data-ngtags'];
|
6108 |
|
6109 | var albumID = '0';
|
6110 | if( data.hasOwnProperty('data-ngalbumid') ) {
|
6111 | albumID = data['data-ngalbumid'];
|
6112 | foundAlbumID = true;
|
6113 | }
|
6114 |
|
6115 | var title = jQuery(item).text();
|
6116 | if( !(G.O.thumbnailLabel.get('title') == '' || G.O.thumbnailLabel.get('title') == undefined) ) {
|
6117 | title = GetImageTitle(src);
|
6118 | }
|
6119 |
|
6120 |
|
6121 | var newItem = NGY2Item.New( G, title, description, ID, albumID, kind, tags );
|
6122 | if( title != '' ) {
|
6123 | nbTitles++;
|
6124 | }
|
6125 |
|
6126 |
|
6127 | newItem.setMediaURL( src, 'img');
|
6128 |
|
6129 |
|
6130 | newItem.mediaKind = 'img';
|
6131 | jQuery.each(mediaList, function ( n, media ) {
|
6132 | var id = media.getID(src);
|
6133 | if( id != null ) {
|
6134 | if( typeof media.url == 'function' ) { src = media.url(id); }
|
6135 | if( typeof media.thumbUrl == 'function' ) { thumbsrc = media.thumbUrl(id); }
|
6136 | newItem.mediaKind = media.kind;
|
6137 | newItem.mediaMarkup = ( media.selfhosted ) ? media.markup( src ) : media.markup(id);
|
6138 | return false;
|
6139 | }
|
6140 | });
|
6141 |
|
6142 |
|
6143 |
|
6144 | newItem.imageWidth = parseInt( data['data-ngimagewidth'] );
|
6145 | newItem.imageHeight = parseInt( data['data-ngimageheight'] );
|
6146 |
|
6147 |
|
6148 | var tw = parseInt(data['data-ngthumbimgwidth']);
|
6149 | var th = parseInt(data['data-ngthumbimgheight']);
|
6150 | newItem.thumbs = {
|
6151 | url: { l1 : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc }, lN : { xs: thumbsrc, sm: thumbsrc, me: thumbsrc, la: thumbsrc, xl: thumbsrc } },
|
6152 | width: { l1 : { xs: tw, sm: tw, me: tw, la: tw, xl: tw }, lN : { xs: tw, sm: tw, me: tw, la: tw, xl: tw } },
|
6153 | height: { l1 : { xs: th, sm: th, me: th, la: th, xl: th }, lN : { xs: th, sm: th, me: th, la: th, xl: th } }
|
6154 | };
|
6155 |
|
6156 |
|
6157 | if( newItem.mediaKind == 'img' ) {
|
6158 |
|
6159 |
|
6160 | var lst = ['xs', 'sm', 'me', 'la', 'xl'];
|
6161 | for( var i = 0; i < lst.length; i++ ) {
|
6162 |
|
6163 | if( data.hasOwnProperty('data-ngthumb' + lst[i]) ) {
|
6164 | var turl=data['data-ngthumb' + lst[i]];
|
6165 | if( !StartsWithProtocol(turl) ) {
|
6166 | turl = G.O.itemsBaseURL + turl;
|
6167 | }
|
6168 | newItem.url.l1[lst[i]] = turl;
|
6169 | newItem.url.lN[lst[i]] = turl;
|
6170 | }
|
6171 |
|
6172 |
|
6173 | if( data.hasOwnProperty('data-ngthumb' + lst[i] + 'width') ) {
|
6174 | var tw=parseInt(data['data-ngthumb' + lst[i] + 'width']);
|
6175 | newItem.width.l1[lst[i]] = tw;
|
6176 | newItem.width.lN[lst[i]] = tw;
|
6177 | }
|
6178 |
|
6179 | if( data.hasOwnProperty('data-ngthumb' + lst[i] + 'height') ) {
|
6180 | var th=parseInt('data-ngthumb' + lst[i] + 'height');
|
6181 | newItem.height.l1[lst[i]] = th;
|
6182 | newItem.height.lN[lst[i]] = th;
|
6183 | }
|
6184 | }
|
6185 | }
|
6186 |
|
6187 |
|
6188 |
|
6189 | newItem.imageDominantColors = data['data-ngimagedominantcolors'];
|
6190 |
|
6191 | newItem.imageDominantColor = data['data-ngimagedominantcolors'];
|
6192 |
|
6193 | newItem.destinationURL = data['data-ngdest'];
|
6194 | newItem.downloadURL = data['data-ngdownloadurl'];
|
6195 |
|
6196 |
|
6197 | newItem.exif.model=data['data-ngexifmodel'];
|
6198 |
|
6199 | newItem.exif.flash=data['data-ngexifflash'];
|
6200 |
|
6201 | newItem.exif.focallength=data['data-ngexiffocallength'];
|
6202 |
|
6203 | newItem.exif.fstop=data['data-ngexiffstop'];
|
6204 |
|
6205 | newItem.exif.exposure=data['data-ngexifexposure'];
|
6206 |
|
6207 | newItem.exif.iso=data['data-ngexifiso'];
|
6208 |
|
6209 | newItem.exif.time=data['data-ngexiftime'];
|
6210 |
|
6211 | newItem.exif.location=data['data-ngexiflocation'];
|
6212 |
|
6213 | newItem.contentIsLoaded=true;
|
6214 |
|
6215 |
|
6216 | if( jQuery(item).data('customdata') !== undefined ) {
|
6217 | newItem.customData=cloneJSObject(jQuery(item).data('customdata'));
|
6218 | }
|
6219 |
|
6220 | if( jQuery(item).data('ngcustomdata') !== undefined ) {
|
6221 | newItem.customData=cloneJSObject(jQuery(item).data('ngcustomdata'));
|
6222 | }
|
6223 |
|
6224 | var fu=G.O.fnProcessData;
|
6225 | if( fu !== null ) {
|
6226 | typeof fu == 'function' ? fu(newItem, 'markup', item) : window[fu](newItem, 'markup', item);
|
6227 | }
|
6228 |
|
6229 | AlbumPostProcess(albumID);
|
6230 |
|
6231 | });
|
6232 |
|
6233 |
|
6234 | if( nbTitles == 0 ) { G.O.thumbnailLabel.display = false; }
|
6235 |
|
6236 | }
|
6237 |
|
6238 |
|
6239 |
|
6240 |
|
6241 |
|
6242 |
|
6243 |
|
6244 |
|
6245 | function DefineVariables() {
|
6246 |
|
6247 |
|
6248 | if( G.O.kind.toUpperCase() == 'PICASA' || G.O.kind.toUpperCase() == 'GOOGLE') {
|
6249 | G.O.kind='google2';
|
6250 | }
|
6251 |
|
6252 |
|
6253 | G.GOM.cache.viewport = getViewport();
|
6254 | G.GOM.curWidth = RetrieveCurWidth();
|
6255 |
|
6256 |
|
6257 | jQuery.extend(true, G.tn.toolbar.image, G.O.thumbnailToolbarImage );
|
6258 | jQuery.extend(true, G.tn.toolbar.album, G.O.thumbnailToolbarAlbum );
|
6259 | var t = ['image', 'album'];
|
6260 | var pos= ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']
|
6261 | for( var i=0; i < t.length ; i++ ) {
|
6262 | for( var j=0; j < pos.length ; j++ ) {
|
6263 | G.tn.toolbar[t[i]][pos[j]] = G.tn.toolbar[t[i]][pos[j]].toUpperCase();
|
6264 | }
|
6265 | }
|
6266 |
|
6267 |
|
6268 | G.O.thumbnailLabel.get = function( opt ) {
|
6269 | if( G.GOM.curNavLevel == 'l1' && G.O.thumbnailL1Label !== undefined && G.O.thumbnailL1Label[opt] !== undefined ) {
|
6270 | return G.O.thumbnailL1Label[opt];
|
6271 | }
|
6272 | else {
|
6273 | return G.O.thumbnailLabel[opt];
|
6274 | }
|
6275 | };
|
6276 | G.O.thumbnailLabel.set = function( opt, value ) {
|
6277 | if( G.GOM.curNavLevel == 'l1' && G.O.thumbnailL1Label !== undefined && G.O.thumbnailL1Label[opt] !== undefined ) {
|
6278 | G.O.thumbnailL1Label[opt]=value;
|
6279 | }
|
6280 | else {
|
6281 | G.O.thumbnailLabel[opt]=value;
|
6282 | }
|
6283 | };
|
6284 |
|
6285 | if( G.O.blackList != '' ) { G.blackList=G.O.blackList.toUpperCase().split('|'); }
|
6286 | if( G.O.whiteList != '' ) { G.whiteList=G.O.whiteList.toUpperCase().split('|'); }
|
6287 |
|
6288 | if( G.O.albumList2 !== undefined && G.O.albumList2 !== null && G.O.albumList2.constructor === Array ) {
|
6289 | var l=G.O.albumList2.length;
|
6290 | for(var i=0; i< l; i++ ) {
|
6291 | G.albumList.push(G.O.albumList2[i]);
|
6292 | }
|
6293 |
|
6294 | }
|
6295 | if( G.O.albumList2 !== undefined && typeof G.O.albumList2 == 'string' ) {
|
6296 | G.albumList.push(G.O.albumList2);
|
6297 | }
|
6298 |
|
6299 |
|
6300 |
|
6301 | G.tn.opt.lN.crop = G.O.thumbnailCrop;
|
6302 | G.tn.opt.l1.crop = G.O.thumbnailL1Crop != null ? G.O.thumbnailL1Crop : G.O.thumbnailCrop;
|
6303 |
|
6304 |
|
6305 | function ThumbnailOpt( lN, l1, opt) {
|
6306 | G.tn.opt.lN[opt]=G.O[lN];
|
6307 | G.tn.opt.l1[opt]=G.O[lN];
|
6308 | if( toType(G.O[l1]) == 'number' ) {
|
6309 | G.tn.opt.l1[opt]=G.O[l1];
|
6310 | }
|
6311 | }
|
6312 |
|
6313 | ThumbnailOpt('thumbnailStacks', 'thumbnailL1Stacks', 'stacks');
|
6314 |
|
6315 | ThumbnailOpt('thumbnailStacksTranslateX', 'thumbnailL1StacksTranslateX', 'stacksTranslateX');
|
6316 |
|
6317 | ThumbnailOpt('thumbnailStacksTranslateY', 'thumbnailL1StacksTranslateY', 'stacksTranslateY');
|
6318 |
|
6319 | ThumbnailOpt('thumbnailStacksTranslateZ', 'thumbnailL1StacksTranslateZ', 'stacksTranslateZ');
|
6320 |
|
6321 | ThumbnailOpt('thumbnailStacksRotateX', 'thumbnailL1StacksRotateX', 'stacksRotateX');
|
6322 |
|
6323 | ThumbnailOpt('thumbnailStacksRotateY', 'thumbnailL1StacksRotateY', 'stacksRotateY');
|
6324 |
|
6325 | ThumbnailOpt('thumbnailStacksRotateZ', 'thumbnailL1StacksRotateZ', 'stacksRotateZ');
|
6326 |
|
6327 | ThumbnailOpt('thumbnailStacksScale', 'thumbnailL1StacksScale', 'stacksScale');
|
6328 |
|
6329 | ThumbnailOpt('thumbnailGutterWidth', 'thumbnailL1GutterWidth', 'gutterWidth');
|
6330 |
|
6331 | ThumbnailOpt('thumbnailGutterHeight', 'thumbnailL1GutterHeight', 'gutterHeight');
|
6332 |
|
6333 | ThumbnailOpt('thumbnailBaseGridHeight', 'thumbnailL1BaseGridHeight', 'baseGridHeight');
|
6334 |
|
6335 |
|
6336 | G.galleryDisplayMode.lN = G.O.galleryDisplayMode.toUpperCase();
|
6337 | G.galleryDisplayMode.l1 = G.O.galleryL1DisplayMode != null ? G.O.galleryL1DisplayMode.toUpperCase() : G.O.galleryDisplayMode.toUpperCase();
|
6338 |
|
6339 |
|
6340 | G.galleryMaxRows.lN = G.O.galleryMaxRows;
|
6341 | G.galleryMaxRows.l1 = toType(G.O.galleryL1MaxRows) == 'number' ? G.O.galleryL1MaxRows : G.O.galleryMaxRows;
|
6342 |
|
6343 |
|
6344 | G.galleryLastRowFull.lN = G.O.galleryLastRowFull;
|
6345 | G.galleryLastRowFull.l1 = G.O.galleryL1LastRowFull != null ? G.O.galleryL1LastRowFull : G.O.galleryLastRowFull;
|
6346 |
|
6347 |
|
6348 | G.gallerySorting.lN = G.O.gallerySorting.toUpperCase();
|
6349 | G.gallerySorting.l1 = G.O.galleryL1Sorting != null ? G.O.galleryL1Sorting.toUpperCase() : G.gallerySorting.lN;
|
6350 |
|
6351 |
|
6352 | G.galleryDisplayTransition.lN = G.O.galleryDisplayTransition.toUpperCase();
|
6353 | G.galleryDisplayTransition.l1 = G.O.galleryL1DisplayTransition != null ? G.O.galleryL1DisplayTransition.toUpperCase() : G.galleryDisplayTransition.lN;
|
6354 |
|
6355 |
|
6356 | G.galleryDisplayTransitionDuration.lN = G.O.galleryDisplayTransitionDuration;
|
6357 | G.galleryDisplayTransitionDuration.l1 = G.O.galleryL1DisplayTransitionDuration != null ? G.O.galleryL1DisplayTransitionDuration : G.galleryDisplayTransitionDuration.lN;
|
6358 |
|
6359 |
|
6360 | G.galleryMaxItems.lN = G.O.galleryMaxItems;
|
6361 | G.galleryMaxItems.l1 = toType(G.O.galleryL1MaxItems) == 'number' ? G.O.galleryL1MaxItems : G.O.galleryMaxItems;
|
6362 |
|
6363 |
|
6364 | G.galleryFilterTags.lN = G.O.galleryFilterTags;
|
6365 | G.galleryFilterTags.l1 = G.O.galleryL1FilterTags != null ? G.O.galleryL1FilterTags : G.O.galleryFilterTags;
|
6366 |
|
6367 |
|
6368 | G.O.galleryPaginationMode = G.O.galleryPaginationMode.toUpperCase();
|
6369 |
|
6370 | if( toType(G.O.slideshowDelay) == 'number' && G.O.slideshowDelay >= 2000 ) {
|
6371 | G.VOM.slideshowDelay = G.O.slideshowDelay;
|
6372 | }
|
6373 | else {
|
6374 | NanoConsoleLog(G, 'Parameter "slideshowDelay" must be an integer >= 2000 ms.');
|
6375 | }
|
6376 |
|
6377 |
|
6378 | if( typeof G.O.thumbnailDisplayTransition == 'boolean' ) {
|
6379 | if( G.O.thumbnailDisplayTransition === true ) {
|
6380 | G.tn.opt.lN.displayTransition = 'FADEIN';
|
6381 | G.tn.opt.l1.displayTransition = 'FADEIN';
|
6382 | }
|
6383 | else {
|
6384 | G.tn.opt.lN.displayTransition = 'NONE';
|
6385 | G.tn.opt.l1.displayTransition = 'NONE';
|
6386 | }
|
6387 | }
|
6388 |
|
6389 | if( G.O.fnThumbnailDisplayEffect !== '' ) {
|
6390 | G.tn.opt.lN.displayTransition = 'CUSTOM';
|
6391 | G.tn.opt.l1.displayTransition = 'CUSTOM';
|
6392 | }
|
6393 | if( G.O.fnThumbnailL1DisplayEffect !== '' ) {
|
6394 | G.tn.opt.l1.displayTransition = 'CUSTOM';
|
6395 | }
|
6396 |
|
6397 |
|
6398 | function thumbnailDisplayTransitionParse( cfg, level ) {
|
6399 | if( typeof cfg == 'string' ) {
|
6400 | var st=cfg.split('_');
|
6401 | if( st.length == 1 ) {
|
6402 | G.tn.opt[level]['displayTransition'] = cfg.toUpperCase();
|
6403 | }
|
6404 | if( st.length == 2 ) {
|
6405 | G.tn.opt[level]['displayTransition'] = st[0].toUpperCase();
|
6406 | G.tn.opt[level]['displayTransitionStartVal'] = Number(st[1]);
|
6407 | }
|
6408 | if( st.length == 3 ) {
|
6409 | G.tn.opt[level]['displayTransition'] = st[0].toUpperCase();
|
6410 | G.tn.opt[level]['displayTransitionStartVal'] = Number(st[1]);
|
6411 | G.tn.opt[level]['displayTransitionEasing'] = st[2];
|
6412 | }
|
6413 | }
|
6414 | }
|
6415 | thumbnailDisplayTransitionParse( G.O.thumbnailDisplayTransition, 'lN');
|
6416 | thumbnailDisplayTransitionParse( G.O.thumbnailDisplayTransition, 'l1');
|
6417 | thumbnailDisplayTransitionParse( G.O.thumbnailL1DisplayTransition, 'l1');
|
6418 |
|
6419 |
|
6420 |
|
6421 | ThumbnailOpt('thumbnailDisplayTransitionDuration', 'thumbnailL1DisplayTransitionDuration', 'displayTransitionDuration');
|
6422 |
|
6423 | ThumbnailOpt('thumbnailDisplayInterval', 'thumbnailL1DisplayInterval', 'displayInterval');
|
6424 |
|
6425 |
|
6426 |
|
6427 | if( G.O.thumbnailSizeSM !== undefined ) { G.O.breakpointSizeSM = G.O.thumbnailSizeSM; }
|
6428 | if( G.O.thumbnailSizeME !== undefined ) { G.O.breakpointSizeME = G.O.thumbnailSizeME; }
|
6429 | if( G.O.thumbnailSizeLA !== undefined ) { G.O.breakpointSizeLA = G.O.thumbnailSizeLA; }
|
6430 | if( G.O.thumbnailSizeXL !== undefined ) { G.O.breakpointSizeXL = G.O.thumbnailSizeXL; }
|
6431 |
|
6432 |
|
6433 |
|
6434 | if( G.O.thumbnailL1BuildInit2 !== undefined ) {
|
6435 | var t1 = G.O.thumbnailL1BuildInit2.split('|');
|
6436 | for( var i = 0; i < t1.length; i++ ) {
|
6437 | var o1 = t1[i].trim().split('_');
|
6438 | if( o1.length == 3 ) {
|
6439 | var i1 = NewTBuildInit();
|
6440 | i1.element = ThumbnailOverEffectsGetCSSElement(o1[0], '');
|
6441 | i1.property = o1[1];
|
6442 | i1.value = o1[2];
|
6443 | G.tn.buildInit.level1.push(i1);
|
6444 | }
|
6445 | }
|
6446 | }
|
6447 |
|
6448 | if( G.O.thumbnailBuildInit2 !== undefined ) {
|
6449 | var t1 = G.O.thumbnailBuildInit2.split('|');
|
6450 | for( var i = 0; i < t1.length; i++ ) {
|
6451 | var o1 = t1[i].trim().split('_');
|
6452 | if( o1.length == 3 ) {
|
6453 | var i1 = NewTBuildInit();
|
6454 | i1.element = ThumbnailOverEffectsGetCSSElement(o1[0], '');
|
6455 | i1.property = o1[1];
|
6456 | i1.value = o1[2];
|
6457 | G.tn.buildInit.std.push(i1);
|
6458 | }
|
6459 | }
|
6460 | }
|
6461 |
|
6462 |
|
6463 |
|
6464 |
|
6465 |
|
6466 | var tL1HE = G.O.thumbnailL1HoverEffect2;
|
6467 | if( tL1HE !== undefined ) {
|
6468 | switch( toType(tL1HE) ) {
|
6469 | case 'string':
|
6470 | var tmp = tL1HE.split('|');
|
6471 | for(var i = 0; i < tmp.length; i++) {
|
6472 | var oDef = NewTHoverEffect();
|
6473 | oDef = ThumbnailHoverEffectExtract( tmp[i].trim(), oDef );
|
6474 | if( oDef != null ) {
|
6475 | G.tn.hoverEffects.level1.push(oDef);
|
6476 | }
|
6477 | }
|
6478 | break;
|
6479 | case 'object':
|
6480 | var oDef = NewTHoverEffect();
|
6481 | oDef = jQuery.extend(oDef,tL1HE);
|
6482 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
6483 | if( oDef != null ) {
|
6484 | G.tn.hoverEffects.level1.push(oDef);
|
6485 | }
|
6486 | break;
|
6487 | case 'array':
|
6488 | for(var i = 0; i < tL1HE.length; i++) {
|
6489 | var oDef = NewTHoverEffect();
|
6490 | oDef = jQuery.extend(oDef,tL1HE[i]);
|
6491 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
6492 | if( oDef != null ) {
|
6493 | G.tn.hoverEffects.level1.push(oDef);
|
6494 | }
|
6495 | }
|
6496 | break;
|
6497 | case 'null':
|
6498 | break;
|
6499 | default:
|
6500 | NanoAlert(G, 'incorrect parameter for "thumbnailL1HoverEffect2".');
|
6501 | }
|
6502 | }
|
6503 | G.tn.hoverEffects.level1 = ThumbnailOverEffectsPreset(G.tn.hoverEffects.level1);
|
6504 |
|
6505 |
|
6506 | var tHE = G.O.thumbnailHoverEffect2;
|
6507 | switch( toType(tHE) ) {
|
6508 | case 'string':
|
6509 | var tmp = tHE.split('|');
|
6510 | for(var i = 0; i < tmp.length; i++) {
|
6511 | var oDef = NewTHoverEffect();
|
6512 | oDef = ThumbnailHoverEffectExtract( tmp[i].trim(), oDef );
|
6513 | if( oDef != null ) {
|
6514 | G.tn.hoverEffects.std.push(oDef);
|
6515 | }
|
6516 | }
|
6517 | break;
|
6518 | case 'object':
|
6519 | var oDef = NewTHoverEffect();
|
6520 | oDef = jQuery.extend(oDef, tHE);
|
6521 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
6522 | if( oDef != null ) {
|
6523 | G.tn.hoverEffects.std.push(oDef);
|
6524 | }
|
6525 | break;
|
6526 | case 'array':
|
6527 | for(var i = 0; i < tHE.length; i++) {
|
6528 | var oDef = NewTHoverEffect();
|
6529 | oDef = jQuery.extend(oDef,tHE[i]);
|
6530 | oDef = ThumbnailHoverEffectExtract( oDef.name, oDef );
|
6531 | if( oDef!= null ) {
|
6532 | G.tn.hoverEffects.std.push(oDef);
|
6533 | }
|
6534 | }
|
6535 | break;
|
6536 | case 'null':
|
6537 | break;
|
6538 | default:
|
6539 | NanoAlert(G, 'incorrect parameter for "thumbnailHoverEffect2".');
|
6540 | }
|
6541 | G.tn.hoverEffects.std = ThumbnailOverEffectsPreset(G.tn.hoverEffects.std);
|
6542 |
|
6543 |
|
6544 | if( G.O.touchAnimationL1 == undefined ) {
|
6545 | G.O.touchAnimationL1 = G.O.touchAnimation;
|
6546 | }
|
6547 |
|
6548 |
|
6549 | if( G.tn.hoverEffects.std.length == 0 ) {
|
6550 | if( G.tn.hoverEffects.level1.length == 0 ) {
|
6551 | G.O.touchAnimationL1 = false;
|
6552 | }
|
6553 | G.O.touchAnimation = false;
|
6554 | }
|
6555 |
|
6556 |
|
6557 |
|
6558 | if( G.O.thumbnailHeight == 0 || G.O.thumbnailHeight == '' ) { G.O.thumbnailHeight = 'auto'; }
|
6559 | if( G.O.thumbnailWidth == 0 || G.O.thumbnailWidth == '' ) { G.O.thumbnailWidth = 'auto'; }
|
6560 | if( G.O.thumbnailL1Height == 0 || G.O.thumbnailL1Height == '' ) { G.O.thumbnailL1Height = 'auto'; }
|
6561 | if( G.O.thumbnailL1Width == 0 || G.O.thumbnailL1Width == '' ) { G.O.thumbnailL1Width = 'auto'; }
|
6562 |
|
6563 |
|
6564 | function ThumbnailSizes( srcOpt, onlyl1, opt) {
|
6565 | if( G.O[srcOpt] == null ) { return; }
|
6566 |
|
6567 | if( toType(G.O[srcOpt]) == 'number' ) {
|
6568 | ThumbnailsSetSize( opt, 'l1', G.O[srcOpt], 'u');
|
6569 | if( !onlyl1 ) {
|
6570 | ThumbnailsSetSize( opt, 'lN', G.O[srcOpt], 'u');
|
6571 | }
|
6572 | }
|
6573 | else {
|
6574 | var ws=G.O[srcOpt].split(' ');
|
6575 | var v = 'auto';
|
6576 | if( ws[0].substring(0,4) != 'auto' ) { v=parseInt(ws[0]); }
|
6577 | var c = 'u';
|
6578 | if( ws[0].charAt(ws[0].length - 1) == 'C' ) { c='c'; }
|
6579 | ThumbnailsSetSize( opt, 'l1', v, c );
|
6580 | if( !onlyl1 ) {
|
6581 | ThumbnailsSetSize( opt, 'lN', v, c );
|
6582 | }
|
6583 | for( var i = 1; i < ws.length; i++ ) {
|
6584 | var r = ws[i].substring(0,2).toLowerCase();
|
6585 | if( /xs|sm|me|la|xl/i.test(r) ) {
|
6586 | var w = ws[i].substring(2);
|
6587 | var v = 'auto';
|
6588 | if( w.substring(0,4) != 'auto' ) { v = parseInt(w); }
|
6589 | var c = 'u';
|
6590 | if( w.charAt(w.length - 1) == 'C' ) { c = 'c'; }
|
6591 | G.tn.settings[opt]['l1'][r] = v;
|
6592 | G.tn.settings[opt]['l1'][r + 'c'] = c;
|
6593 | if( !onlyl1 ) {
|
6594 | G.tn.settings[opt]['lN'][r] = v;
|
6595 | G.tn.settings[opt]['lN'][r + 'c'] = c;
|
6596 | }
|
6597 | }
|
6598 | }
|
6599 | }
|
6600 | }
|
6601 | ThumbnailSizes( 'thumbnailWidth', false, 'width');
|
6602 | ThumbnailSizes( 'thumbnailL1Width', true, 'width');
|
6603 |
|
6604 | ThumbnailSizes( 'thumbnailHeight', false, 'height');
|
6605 | ThumbnailSizes( 'thumbnailL1Height', true, 'height');
|
6606 |
|
6607 |
|
6608 | G.O.thumbnailBorderHorizontal = parseInt(G.O.thumbnailBorderHorizontal);
|
6609 | G.O.thumbnailBorderVertical = parseInt(G.O.thumbnailBorderVertical);
|
6610 | G.O.thumbnailLabelHeight = parseInt(G.O.thumbnailLabelHeight);
|
6611 |
|
6612 |
|
6613 |
|
6614 |
|
6615 | if( G.O.galleryMosaic != undefined ) {
|
6616 |
|
6617 | G.tn.settings.mosaic.l1.xs = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
6618 | G.tn.settings.mosaic.l1.sm = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
6619 | G.tn.settings.mosaic.l1.me = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
6620 | G.tn.settings.mosaic.l1.la = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
6621 | G.tn.settings.mosaic.l1.xl = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
6622 | G.tn.settings.mosaic.lN.xs = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
6623 | G.tn.settings.mosaic.lN.sm = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
6624 | G.tn.settings.mosaic.lN.me = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
6625 | G.tn.settings.mosaic.lN.la = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
6626 | G.tn.settings.mosaic.lN.xl = JSON.parse(JSON.stringify(G.O.galleryMosaic));
|
6627 | G.tn.settings.mosaicCalcFactor('l1', 'xs');
|
6628 | G.tn.settings.mosaicCalcFactor('l1', 'sm');
|
6629 | G.tn.settings.mosaicCalcFactor('l1', 'me');
|
6630 | G.tn.settings.mosaicCalcFactor('l1', 'la');
|
6631 | G.tn.settings.mosaicCalcFactor('l1', 'xl');
|
6632 | G.tn.settings.mosaicCalcFactor('lN', 'xs');
|
6633 | G.tn.settings.mosaicCalcFactor('lN', 'sm');
|
6634 | G.tn.settings.mosaicCalcFactor('lN', 'me');
|
6635 | G.tn.settings.mosaicCalcFactor('lN', 'la');
|
6636 | G.tn.settings.mosaicCalcFactor('lN', 'xl');
|
6637 | }
|
6638 | if( G.O.galleryL1Mosaic != undefined ) {
|
6639 |
|
6640 | G.tn.settings.mosaic.l1.xs = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
6641 | G.tn.settings.mosaic.l1.sm = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
6642 | G.tn.settings.mosaic.l1.me = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
6643 | G.tn.settings.mosaic.l1.la = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
6644 | G.tn.settings.mosaic.l1.xl = JSON.parse(JSON.stringify(G.O.galleryL1Mosaic));
|
6645 | G.tn.settings.mosaicCalcFactor('l1', 'xs');
|
6646 | G.tn.settings.mosaicCalcFactor('l1', 'sm');
|
6647 | G.tn.settings.mosaicCalcFactor('l1', 'me');
|
6648 | G.tn.settings.mosaicCalcFactor('l1', 'la');
|
6649 | G.tn.settings.mosaicCalcFactor('l1', 'xl');
|
6650 | }
|
6651 | for( var w = 0; w < G.tn.settings.mosaic.l1; w++ ) {
|
6652 | if( G.O['galleryMosaic' + G.tn.settings.mosaic.l1[w].toUpperCase()] != undefined ) {
|
6653 | G.tn.settings.mosaic.lN[tn.settings.mosaic.l1[w]] = JSON.parse(JSON.stringify( G.O['galleryMosaic' + G.tn.settings.mosaic.l1[w].toUpperCase()] ));
|
6654 | G.tn.settings.mosaic.l1[tn.settings.mosaic.l1[w]] = JSON.parse(JSON.stringify( G.O['galleryMosaic' + G.tn.settings.mosaic.l1[w].toUpperCase()] ));
|
6655 | G.tn.settings.mosaicCalcFactor('l1', G.tn.settings.mosaic.l1[w]);
|
6656 | G.tn.settings.mosaicCalcFactor('lN', G.tn.settings.mosaic.l1[w]);
|
6657 | }
|
6658 | }
|
6659 | for( var w = 0; w < G.tn.settings.mosaic.l1; w++ ) {
|
6660 | if( G.O['galleryL1Mosaic'+G.tn.settings.mosaic.l1[w].toUpperCase()] != undefined ) {
|
6661 | G.tn.settings.mosaic.l1[tn.settings.mosaic.l1[w]] = JSON.parse(JSON.stringify( G.O['galleryL1Mosaic'+G.tn.settings.mosaic.l1[w].toUpperCase()] ));
|
6662 | G.tn.settings.mosaicCalcFactor('l1', G.tn.settings.mosaic.l1[w]);
|
6663 | }
|
6664 | }
|
6665 |
|
6666 | G.O.imageTransition = G.O.imageTransition.toUpperCase();
|
6667 |
|
6668 | G.layout.SetEngine();
|
6669 |
|
6670 |
|
6671 | switch( G.O.kind ) {
|
6672 |
|
6673 | case '':
|
6674 | break;
|
6675 |
|
6676 | default:
|
6677 | jQuery.nanogallery2['data_' + G.O.kind](G, 'Init' );
|
6678 | }
|
6679 |
|
6680 | }
|
6681 |
|
6682 |
|
6683 | function ThumbnailHoverEffectExtract( name, effect) {
|
6684 | 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'];
|
6685 |
|
6686 | var sp = name.split('_');
|
6687 | if( sp.length >= 4 ) {
|
6688 |
|
6689 | effect.name = '';
|
6690 | effect.type = sp[1];
|
6691 | effect.from = sp[2];
|
6692 | effect.to = sp[3];
|
6693 | if( sp.length >= 5 ) {
|
6694 |
|
6695 |
|
6696 | for( var n = 4; n < sp.length; n++ ) {
|
6697 | var v = sp[n];
|
6698 |
|
6699 |
|
6700 | var foundEasing = false;
|
6701 | for( var e = 0; e < easings.length; e++) {
|
6702 | if( v == easings[e] ) {
|
6703 | foundEasing = true;
|
6704 | effect.easing = v;
|
6705 | break;
|
6706 | }
|
6707 | }
|
6708 | if( foundEasing === true ) {
|
6709 | continue;
|
6710 | }
|
6711 |
|
6712 | v = v.toUpperCase();
|
6713 |
|
6714 | if( v == 'HOVERIN' ) {
|
6715 | effect.hoverout = false;
|
6716 | continue;
|
6717 | }
|
6718 | if( v == 'HOVEROUT' ) {
|
6719 | effect.hoverin = false;
|
6720 | continue;
|
6721 | }
|
6722 |
|
6723 | if( v == 'KEYFRAME' ) {
|
6724 | effect.firstKeyframe = false;
|
6725 | continue;
|
6726 | }
|
6727 |
|
6728 | var num = parseInt(v.replace(/[^0-9\.]/g, ''), 10);
|
6729 |
|
6730 | if( num > 0 ) {
|
6731 |
|
6732 | if( v.indexOf('DURATION') >= 0 ) {
|
6733 | effect.duration = num;
|
6734 | continue;
|
6735 | }
|
6736 | if( v.indexOf('DURATIONBACK') >= 0 ) {
|
6737 | effect.durationBack = num;
|
6738 | continue;
|
6739 | }
|
6740 | if( v.indexOf('DELAY') >= 0 ) {
|
6741 | effect.delay = num;
|
6742 | continue;
|
6743 | }
|
6744 | if( v.indexOf('DELAYBACK') >= 0 ) {
|
6745 | effect.delayBack = num;
|
6746 | continue;
|
6747 | }
|
6748 |
|
6749 |
|
6750 | effect.duration = num;
|
6751 | }
|
6752 | }
|
6753 | }
|
6754 | effect.element=ThumbnailOverEffectsGetCSSElement(sp[0], effect.type);
|
6755 |
|
6756 | }
|
6757 | else {
|
6758 | effect.name = name;
|
6759 |
|
6760 |
|
6761 | }
|
6762 | return effect;
|
6763 | }
|
6764 |
|
6765 |
|
6766 | function ThumbnailOverEffectsGetCSSElement( element, property ) {
|
6767 | var r = element;
|
6768 |
|
6769 | switch ( element ) {
|
6770 | case 'image':
|
6771 | if( property == 'blur' || property == 'brightness' || property == 'grayscale' || property == 'sepia' || property == 'contrast' || property == 'opacity'|| property == 'saturate' ) {
|
6772 |
|
6773 | r = '.nGY2GThumbnailImage';
|
6774 | }
|
6775 | else {
|
6776 | r = '.nGY2GThumbnailImage';
|
6777 | }
|
6778 | break;
|
6779 | case 'thumbnail':
|
6780 | r = '.nGY2GThumbnail';
|
6781 | break;
|
6782 | case 'label':
|
6783 | r = '.nGY2GThumbnailLabel';
|
6784 | break;
|
6785 | case 'title':
|
6786 | r = '.nGY2GThumbnailTitle';
|
6787 | break;
|
6788 | case 'description':
|
6789 | r = '.nGY2GThumbnailDescription';
|
6790 | break;
|
6791 | case 'tools':
|
6792 | r = '.nGY2GThumbnailIcons';
|
6793 | break;
|
6794 | case 'customlayer':
|
6795 | r = '.nGY2GThumbnailCustomLayer';
|
6796 | break;
|
6797 | }
|
6798 | return r;
|
6799 | }
|
6800 |
|
6801 |
|
6802 | function ThumbnailOverEffectsPreset( effects ) {
|
6803 |
|
6804 |
|
6805 |
|
6806 |
|
6807 |
|
6808 |
|
6809 |
|
6810 |
|
6811 |
|
6812 |
|
6813 |
|
6814 |
|
6815 |
|
6816 |
|
6817 |
|
6818 | var newEffects=[];
|
6819 | for( var i=0; i< effects.length; i++ ) {
|
6820 | switch( effects[i].name.toUpperCase() ) {
|
6821 | case 'BORDERLIGHTER':
|
6822 |
|
6823 |
|
6824 |
|
6825 | var rgb = ColorHelperToRGB(GalleryThemeGetCurrent().thumbnail.borderColor);
|
6826 | name = 'thumbnail_borderColor_'+rgb+'_'+ShadeBlendConvert(0.5, rgb );
|
6827 | newEffects.push(ThumbnailHoverEffectExtract(name, effects[i]));
|
6828 | break;
|
6829 | case 'BORDERDARKER':
|
6830 |
|
6831 |
|
6832 | var rgb = ColorHelperToRGB(GalleryThemeGetCurrent().thumbnail.borderColor);
|
6833 | name = 'thumbnail_borderColor_'+rgb+'_'+ShadeBlendConvert(-0.5, rgb );
|
6834 | newEffects.push(ThumbnailHoverEffectExtract(name, effects[i]));
|
6835 | break;
|
6836 | case 'SCALE120':
|
6837 | newEffects.push(ThumbnailHoverEffectExtract('thumbnail_scale_1.00_1.20', effects[i]));
|
6838 | break;
|
6839 | case 'LABELAPPEAR':
|
6840 | case 'LABELAPPEAR75':
|
6841 | newEffects.push(ThumbnailHoverEffectExtract('label_opacity_0.00_1.00', effects[i]));
|
6842 | break;
|
6843 | case 'TOOLSAPPEAR':
|
6844 | newEffects.push(ThumbnailHoverEffectExtract('tools_opacity_0_1', effects[i]));
|
6845 | break;
|
6846 | case 'TOOLSSLIDEDOWN':
|
6847 | newEffects.push(ThumbnailHoverEffectExtract('tools_translateY_-100%_0%', effects[i]));
|
6848 | break;
|
6849 | case 'TOOLSSLIDEUP':
|
6850 | newEffects.push(ThumbnailHoverEffectExtract('tools_translateY_100%_0%', effects[i]));
|
6851 | break;
|
6852 | case 'LABELOPACITY50':
|
6853 | newEffects.push(ThumbnailHoverEffectExtract('label_opacity_1.00_0.50', effects[i]));
|
6854 | break;
|
6855 | case 'LABELSLIDEUPTOP':
|
6856 | case 'LABELSLIDEUP':
|
6857 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_100%_0%', effects[i]));
|
6858 | break;
|
6859 | case 'LABELSLIDEDOWN':
|
6860 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_-100%_0%', effects[i]));
|
6861 | break;
|
6862 | case 'SCALELABELOVERIMAGE':
|
6863 | newEffects.push(ThumbnailHoverEffectExtract('label_scale_0.00_1.00', effects[i]));
|
6864 | var n = cloneJSObject(effects[i]);
|
6865 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.00_0.00', n));
|
6866 | break;
|
6867 | case 'OVERSCALE':
|
6868 | case 'OVERSCALEOUTSIDE':
|
6869 | name = 'label_scale_0_100';
|
6870 | newEffects.push(ThumbnailHoverEffectExtract('label_scale_2.00_1.00', effects[i]));
|
6871 | var n = cloneJSObject(effects[i]);
|
6872 | newEffects.push(ThumbnailHoverEffectExtract('label_opacity_0.00_1.00', n));
|
6873 | n = cloneJSObject(effects[i]);
|
6874 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.00_0.00', n));
|
6875 | n = cloneJSObject(effects[i]);
|
6876 | newEffects.push(ThumbnailHoverEffectExtract('image_opacity_1.00_0.00', n));
|
6877 | break;
|
6878 | case 'DESCRIPTIONAPPEAR':
|
6879 | newEffects.push(ThumbnailHoverEffectExtract('description_opacity_0_1', effects[i]));
|
6880 | break;
|
6881 | case 'SLIDERIGHT':
|
6882 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_100%', effects[i]));
|
6883 | newEffects.push(ThumbnailHoverEffectExtract('label_translateX_-100%_0%', cloneJSObject(effects[i])));
|
6884 | break;
|
6885 | case 'SLIDELEFT':
|
6886 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_-100%', effects[i]));
|
6887 | newEffects.push(ThumbnailHoverEffectExtract('label_translateX_100%_0%', cloneJSObject(effects[i])));
|
6888 | break;
|
6889 | case 'SLIDEUP':
|
6890 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_-100%', effects[i]));
|
6891 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_100%_0%', cloneJSObject(effects[i])));
|
6892 | break;
|
6893 | case 'SLIDEDOWN':
|
6894 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_100%', effects[i]));
|
6895 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_-100%_0%', cloneJSObject(effects[i])));
|
6896 | break;
|
6897 | case 'IMAGESCALE150':
|
6898 | case 'IMAGESCALE150OUTSIDE':
|
6899 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.00_1.50', effects[i]));
|
6900 | break;
|
6901 | case 'IMAGESCALEIN80':
|
6902 | newEffects.push(ThumbnailHoverEffectExtract('image_scale_1.20_1.00', effects[i]));
|
6903 | break;
|
6904 | case 'IMAGESLIDERIGHT':
|
6905 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_100%', effects[i]));
|
6906 | break;
|
6907 | case 'IMAGESLIDELEFT':
|
6908 | newEffects.push(ThumbnailHoverEffectExtract('image_translateX_0%_-100%', effects[i]));
|
6909 | break;
|
6910 | case 'IMAGESLIDEUP':
|
6911 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_-100%', effects[i]));
|
6912 | break;
|
6913 | case 'IMAGESLIDEDOWN':
|
6914 | newEffects.push(ThumbnailHoverEffectExtract('image_translateY_0%_100%', effects[i]));
|
6915 | break;
|
6916 | case 'LABELSLIDEUP':
|
6917 | case 'LABELSLIDEUPTOP':
|
6918 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_100%_0%', effects[i]));
|
6919 | break;
|
6920 | case 'LABELSLIDEUPDOWN':
|
6921 | newEffects.push(ThumbnailHoverEffectExtract('label_translateY_0%_100%', effects[i]));
|
6922 | break;
|
6923 | case 'DESCRIPTIONSLIDEUP':
|
6924 | newEffects.push(ThumbnailHoverEffectExtract('description_translateY_110%_0%', effects[i]));
|
6925 | break;
|
6926 |
|
6927 | case 'IMAGEBLURON':
|
6928 | newEffects.push(ThumbnailHoverEffectExtract('image_blur_2.00px_0.00px', effects[i]));
|
6929 | break;
|
6930 | case 'IMAGEBLUROFF':
|
6931 | newEffects.push(ThumbnailHoverEffectExtract('image_blur_0.00px_2.00px', effects[i]));
|
6932 | break;
|
6933 | case 'IMAGEGRAYON':
|
6934 | newEffects.push(ThumbnailHoverEffectExtract('image_grayscale_0%_100%', effects[i]));
|
6935 | break;
|
6936 | case 'IMAGEGRAYOFF':
|
6937 | newEffects.push(ThumbnailHoverEffectExtract('image_grayscale_100%_0%', effects[i]));
|
6938 | break;
|
6939 | case 'IMAGESEPIAON':
|
6940 | newEffects.push(ThumbnailHoverEffectExtract('image_sepia_100%_1%', effects[i]));
|
6941 | break;
|
6942 | case 'IMAGESEPIAOFF':
|
6943 | newEffects.push(ThumbnailHoverEffectExtract('image_sepia_1%_100%', effects[i]));
|
6944 | break;
|
6945 |
|
6946 | default:
|
6947 | newEffects.push(effects[i]);
|
6948 | break;
|
6949 | }
|
6950 | }
|
6951 |
|
6952 | return newEffects;
|
6953 | }
|
6954 |
|
6955 |
|
6956 |
|
6957 | function NewTHoverEffect() {
|
6958 | var oDef={
|
6959 | name: '',
|
6960 | element: '',
|
6961 | type: '',
|
6962 | from: '',
|
6963 | to: '',
|
6964 | hoverin: true,
|
6965 | hoverout: true,
|
6966 | firstKeyframe: true,
|
6967 | delay: 0,
|
6968 | delayBack: 0,
|
6969 | duration: 400,
|
6970 | durationBack: 300,
|
6971 | easing: 'easeOutQuart',
|
6972 | easingBack: 'easeOutQuart',
|
6973 | animParam: null
|
6974 | };
|
6975 | return oDef;
|
6976 | }
|
6977 |
|
6978 | function NewTBuildInit() {
|
6979 |
|
6980 | var oDef={ element: '', property: '', value: '' };
|
6981 | return oDef;
|
6982 | }
|
6983 |
|
6984 |
|
6985 | function ThumbnailStyle( cfg, level) {
|
6986 |
|
6987 | switch( cfg.position ){
|
6988 | case 'onBottom' :
|
6989 | G.tn.style[level]['label'] = 'bottom:0; ';
|
6990 | break;
|
6991 | case 'overImageOnTop' :
|
6992 | G.tn.style[level]['label'] = 'top:0; position:absolute;';
|
6993 | break;
|
6994 | case 'overImageOnMiddle' :
|
6995 | G.tn.style[level]['label'] = 'top:0; bottom:0;';
|
6996 | G.tn.style[level]['title'] = 'position:absolute; bottom:50%;';
|
6997 | G.tn.style[level]['desc'] = 'position:absolute; top:50%;';
|
6998 | break;
|
6999 | case 'custom' :
|
7000 | break;
|
7001 | case 'overImageOnBottom' :
|
7002 | default :
|
7003 | G.O.thumbnailLabel.position = 'overImageOnBottom';
|
7004 | G.tn.style[level].label = 'bottom:0; position:absolute;';
|
7005 | break;
|
7006 | }
|
7007 |
|
7008 | if( cfg.position != 'onBottom' ) {
|
7009 |
|
7010 | if( cfg.titleMultiLine ) {
|
7011 | G.tn.style[level]['title'] = 'white-space:normal;';
|
7012 | }
|
7013 | if( cfg.descriptionMultiLine ) {
|
7014 | G.tn.style[level]['desc'] = 'white-space:normal;';
|
7015 | }
|
7016 | }
|
7017 |
|
7018 |
|
7019 | switch( cfg.align ) {
|
7020 | case 'right':
|
7021 | G.tn.style[level].label += 'text-align:right;';
|
7022 | break;
|
7023 | case 'left':
|
7024 | G.tn.style[level].label += 'text-align:left;';
|
7025 | break;
|
7026 | default:
|
7027 | G.tn.style[level].label += 'text-align:center;';
|
7028 | break;
|
7029 | }
|
7030 | if( cfg.titleFontSize != undefined && cfg.titleFontSize != '' ) {
|
7031 | G.tn.style[level].title += 'font-size:' + cfg.titleFontSize + ';';
|
7032 | }
|
7033 | if( cfg.descriptionFontSize != undefined && cfg.descriptionFontSize != '' ) {
|
7034 | G.tn.style[level].desc += 'font-size:' + cfg.descriptionFontSize + ';';
|
7035 | }
|
7036 |
|
7037 | if( cfg.displayDescription == false ) {
|
7038 | G.tn.style[level].desc += 'display:none;';
|
7039 | }
|
7040 | }
|
7041 |
|
7042 |
|
7043 |
|
7044 | function ThumbnailDefCaches() {
|
7045 |
|
7046 |
|
7047 |
|
7048 | ThumbnailStyle( G.O.thumbnailLabel, 'lN');
|
7049 | ThumbnailStyle( G.O.thumbnailLabel, 'l1');
|
7050 |
|
7051 | if( G.O.thumbnailL1Label && G.O.thumbnailL1Label.display ) {
|
7052 |
|
7053 | ThumbnailStyle( G.O.thumbnailL1Label, 'l1');
|
7054 | }
|
7055 |
|
7056 | G.tn.borderWidth = G.O.thumbnailBorderHorizontal;
|
7057 | G.tn.borderHeight = G.O.thumbnailBorderVertical;
|
7058 |
|
7059 |
|
7060 |
|
7061 | var lst=['xs','sm','me','la','xl'];
|
7062 | for( var i = 0; i < lst.length; i++ ) {
|
7063 | var w = G.tn.settings.width.lN[lst[i]];
|
7064 | if( w != 'auto' ) {
|
7065 | G.tn.defaultSize.width.lN[lst[i]] = w;
|
7066 | G.tn.defaultSize.width.l1[lst[i]] = w;
|
7067 | }
|
7068 | else {
|
7069 | var h = G.tn.settings.height.lN[lst[i]];
|
7070 | G.tn.defaultSize.width.lN[lst[i]] = h;
|
7071 | G.tn.defaultSize.width.l1[lst[i]] = h;
|
7072 | }
|
7073 | }
|
7074 | for( var i = 0; i < lst.length; i++ ) {
|
7075 | var h = G.tn.settings.height.lN[lst[i]];
|
7076 | if( h != 'auto' ) {
|
7077 |
|
7078 | G.tn.defaultSize.height.lN[lst[i]] = h;
|
7079 | G.tn.defaultSize.height.l1[lst[i]] = h;
|
7080 | }
|
7081 | else {
|
7082 | var w = G.tn.settings.width.lN[lst[i]];
|
7083 | G.tn.defaultSize.height.lN[lst[i]] = w;
|
7084 | G.tn.defaultSize.height.l1[lst[i]] = w;
|
7085 | }
|
7086 | }
|
7087 |
|
7088 |
|
7089 | for( var i = 0; i < lst.length; i++ ) {
|
7090 | var w = G.tn.settings.width.l1[lst[i]];
|
7091 | if( w != 'auto' ) {
|
7092 | G.tn.defaultSize.width.l1[lst[i]] = w;
|
7093 | }
|
7094 | else {
|
7095 | var h = G.tn.settings.height.l1[lst[i]];
|
7096 | G.tn.defaultSize.width.l1[lst[i]] = h;
|
7097 | }
|
7098 | }
|
7099 | for( var i = 0; i < lst.length; i++ ) {
|
7100 | var h = G.tn.settings.height.l1[lst[i]];
|
7101 | if( h != 'auto' ) {
|
7102 |
|
7103 | G.tn.defaultSize.height.l1[lst[i]] = h;
|
7104 | }
|
7105 | else {
|
7106 | var w = G.tn.settings.width.l1[lst[i]];
|
7107 | G.tn.defaultSize.height.l1[lst[i]]= w ;
|
7108 | }
|
7109 | }
|
7110 |
|
7111 | }
|
7112 |
|
7113 |
|
7114 |
|
7115 | function ThumbnailsSetSize( dir, level, v, crop ) {
|
7116 | G.tn.settings[dir][level]['xs'] = v;
|
7117 | G.tn.settings[dir][level]['sm'] = v;
|
7118 | G.tn.settings[dir][level]['me'] = v;
|
7119 | G.tn.settings[dir][level]['la'] = v;
|
7120 | G.tn.settings[dir][level]['xl'] = v;
|
7121 | G.tn.settings[dir][level]['xsc'] = crop;
|
7122 | G.tn.settings[dir][level]['smc'] = crop;
|
7123 | G.tn.settings[dir][level]['mec'] = crop;
|
7124 | G.tn.settings[dir][level]['lac'] = crop;
|
7125 | G.tn.settings[dir][level]['xlc'] = crop;
|
7126 | }
|
7127 |
|
7128 |
|
7129 |
|
7130 | function GalleryThemeGetCurrent() {
|
7131 |
|
7132 | var cs=null;
|
7133 | switch(toType(G.O.galleryTheme)) {
|
7134 | case 'object':
|
7135 | cs = G.galleryTheme_dark;
|
7136 | jQuery.extend(true,cs,G.O.galleryTheme);
|
7137 | break;
|
7138 | case 'string':
|
7139 | switch( G.O.galleryTheme ) {
|
7140 | case 'light':
|
7141 | cs = G.galleryTheme_light;
|
7142 | break;
|
7143 | case 'default':
|
7144 | case 'dark':
|
7145 | case 'none':
|
7146 | default:
|
7147 | cs = G.galleryTheme_dark;
|
7148 | }
|
7149 | break;
|
7150 | default:
|
7151 | cs = G.galleryTheme_dark;
|
7152 | }
|
7153 | return cs;
|
7154 | }
|
7155 |
|
7156 |
|
7157 | function SetGalleryTheme() {
|
7158 |
|
7159 | if( typeof G.O.colorScheme !== 'undefined' ) {
|
7160 | G.O.galleryTheme = G.O.colorScheme;
|
7161 | }
|
7162 |
|
7163 | var cs = null;
|
7164 | var galleryTheme = '';
|
7165 | switch(toType(G.O.galleryTheme)) {
|
7166 | case 'object':
|
7167 | cs = G.galleryTheme_dark;
|
7168 | jQuery.extend(true,cs,G.O.galleryTheme);
|
7169 | galleryTheme='nanogallery_gallerytheme_custom_' + G.baseEltID;
|
7170 | break;
|
7171 | case 'string':
|
7172 | switch( G.O.galleryTheme ) {
|
7173 | case 'light':
|
7174 | cs = G.galleryTheme_light;
|
7175 | galleryTheme='nanogallery_gallerytheme_light_' + G.baseEltID;
|
7176 | break;
|
7177 | case 'default':
|
7178 | case 'dark':
|
7179 | case 'none':
|
7180 | default:
|
7181 | cs = G.galleryTheme_dark;
|
7182 | galleryTheme='nanogallery_gallerytheme_dark_' + G.baseEltID;
|
7183 | }
|
7184 | break;
|
7185 | default:
|
7186 | NanoAlert(G, 'Error in galleryTheme parameter.');
|
7187 | return;
|
7188 | }
|
7189 |
|
7190 |
|
7191 | var s1='.' + galleryTheme + ' ';
|
7192 |
|
7193 |
|
7194 | var s=s1+'.nGY2Navigationbar { background:'+cs.navigationBar.background+'; }'+'\n';
|
7195 | if( cs.navigationBar.border !== undefined && cs.navigationBar.border !== '' ) { s+=s1+'.nGY2Navigationbar { border:'+cs.navigationBar.border+'; }'+'\n'; }
|
7196 | if( cs.navigationBar.borderTop !== undefined && cs.navigationBar.borderTop !== '' ) { s+=s1+'.nGY2Navigationbar { border-top:'+cs.navigationBar.borderTop+'; }'+'\n'; }
|
7197 | if( cs.navigationBar.borderBottom !== undefined && cs.navigationBar.borderBottom !== '' ) { s+=s1+'.nGY2Navigationbar { border-bottom:'+cs.navigationBar.borderBottom+'; }'+'\n'; }
|
7198 | if( cs.navigationBar.borderRight !== undefined && cs.navigationBar.borderRight !== '' ) { s+=s1+'.nGY2Navigationbar { border-right:'+cs.navigationBar.borderRight+'; }'+'\n'; }
|
7199 | if( cs.navigationBar.borderLeft !== undefined && cs.navigationBar.borderLeft !== '' ) { s+=s1+'.nGY2Navigationbar { border-left:'+cs.navigationBar.borderLeft+'; }'+'\n'; }
|
7200 |
|
7201 |
|
7202 | s+=s1+'.nGY2Breadcrumb { background:'+cs.navigationBreadcrumb.background+'; border-radius:'+cs.navigationBreadcrumb.borderRadius+'; }'+'\n';
|
7203 | s+=s1+'.nGY2Breadcrumb .oneItem { color:'+cs.navigationBreadcrumb.color+'; }'+'\n';
|
7204 | s+=s1+'.nGY2Breadcrumb .oneItem:hover { color:'+cs.navigationBreadcrumb.colorHover+'; }'+'\n';
|
7205 |
|
7206 |
|
7207 | s+=s1+'.nGY2NavFilterUnselected { color:'+cs.navigationFilter.color+'; background:'+cs.navigationFilter.background+'; border-radius:'+cs.navigationFilter.borderRadius+'; }'+'\n';
|
7208 | s+=s1+'.nGY2NavFilterSelected { color:'+cs.navigationFilter.colorSelected+'; background:'+cs.navigationFilter.backgroundSelected+'; border-radius:'+cs.navigationFilter.borderRadius+'; }'+'\n';
|
7209 | s+=s1+'.nGY2NavFilterSelectAll { color:'+cs.navigationFilter.colorSelected+'; background:'+cs.navigationFilter.background+'; border-radius:'+cs.navigationFilter.borderRadius+'; }'+'\n';
|
7210 |
|
7211 |
|
7212 | s+=s1+'.nGY2GThumbnail { background:'+cs.thumbnail.background+'; border-color:'+cs.thumbnail.borderColor+'; border-top-width:'+G.O.thumbnailBorderVertical+'px; border-right-width:'+G.O.thumbnailBorderHorizontal+'px; border-bottom-width:'+G.O.thumbnailBorderVertical+'px; border-left-width:'+G.O.thumbnailBorderHorizontal+'px;}'+'\n';
|
7213 | s+=s1+'.nGY2GThumbnailStack { background:'+cs.thumbnail.stackBackground+'; }'+'\n';
|
7214 |
|
7215 | s+=s1+'.nGY2TnImgBack { background:'+cs.thumbnail.background+'; background-image:'+cs.thumbnail.backgroundImage+'; }'+'\n';
|
7216 | s+=s1+'.nGY2GThumbnailAlbumUp { background:'+cs.thumbnail.background+'; background-image:'+cs.thumbnail.backgroundImage+'; color:'+cs.thumbnail.titleColor+'; }'+'\n';
|
7217 | s+=s1+'.nGY2GThumbnailIconsFullThumbnail { color:'+cs.thumbnail.titleColor+'; }\n';
|
7218 | s+=s1+'.nGY2GThumbnailLabel { background:'+cs.thumbnail.labelBackground+'; opacity:'+cs.thumbnail.labelOpacity+'; }'+'\n';
|
7219 | s+=s1+'.nGY2GThumbnailImageTitle { color:'+cs.thumbnail.titleColor+'; background-color:'+cs.thumbnail.titleBgColor+'; '+(cs.thumbnail.titleShadow =='' ? '': 'Text-Shadow:'+cs.thumbnail.titleShadow+';')+' }'+'\n';
|
7220 | s+=s1+'.nGY2GThumbnailAlbumTitle { color:'+cs.thumbnail.titleColor+'; background-color:'+cs.thumbnail.titleBgColor+'; '+(cs.thumbnail.titleShadow =='' ? '': 'Text-Shadow:'+cs.thumbnail.titleShadow+';')+' }'+'\n';
|
7221 | s+=s1+'.nGY2GThumbnailDescription { color:'+cs.thumbnail.descriptionColor+'; background-color:'+cs.thumbnail.descriptionBgColor+'; '+(cs.thumbnail.descriptionShadow =='' ? '': 'Text-Shadow:'+cs.thumbnail.descriptionShadow+';')+' }'+'\n';
|
7222 |
|
7223 |
|
7224 | s+=s1+'.nGY2GThumbnailIcons { padding:'+cs.thumbnailIcon.padding+'; }\n';
|
7225 | s+=s1+'.nGY2GThumbnailIcon { color:'+cs.thumbnailIcon.color+'; }\n';
|
7226 | s+=s1+'.nGY2GThumbnailIconTextBadge { background-color:'+cs.thumbnailIcon.color+'; }\n';
|
7227 |
|
7228 |
|
7229 | if( G.O.galleryPaginationMode != 'NUMBERS' ) {
|
7230 | s+=s1+'.nGY2paginationDot { border:'+cs.pagination.shapeBorder+'; background:'+cs.pagination.shapeColor+';}\n';
|
7231 | s+=s1+'.nGY2paginationDotCurrentPage { border:'+cs.pagination.shapeBorder+'; background:'+cs.pagination.shapeSelectedColor+';}\n';
|
7232 | s+=s1+'.nGY2paginationRectangle { border:'+cs.pagination.shapeBorder+'; background:'+cs.pagination.shapeColor+';}\n';
|
7233 | s+=s1+'.nGY2paginationRectangleCurrentPage { border:'+cs.pagination.shapeBorder+'; background:'+cs.pagination.shapeSelectedColor+';}\n';
|
7234 | } else {
|
7235 | s+=s1+'.nGY2paginationItem { background:'+cs.pagination.background+'; color:'+cs.pagination.color+'; border-radius:'+cs.pagination.borderRadius+'; }\n';
|
7236 | s+=s1+'.nGY2paginationItemCurrentPage { background:'+cs.pagination.background+'; color:'+cs.pagination.color+'; border-radius:'+cs.pagination.borderRadius+'; }\n';
|
7237 | s+=s1+'.nGY2PaginationPrev { background:'+cs.pagination.background+'; color:'+cs.pagination.color+'; border-radius:'+cs.pagination.borderRadius+'; }\n';
|
7238 | s+=s1+'.nGY2PaginationNext { background:'+cs.pagination.background+'; color:'+cs.pagination.color+'; border-radius:'+cs.pagination.borderRadius+'; }\n';
|
7239 | s+=s1+'.nGY2paginationItemCurrentPage { background:'+cs.pagination.backgroundSelected+'; }\n';
|
7240 | }
|
7241 |
|
7242 |
|
7243 | s+=s1+'.nGY2GalleryMoreButtonAnnotation { background:'+cs.thumbnail.background+'; border-color:'+cs.thumbnail.borderColor+'; border-top-width:'+G.O.thumbnailBorderVertical+'px; border-right-width:'+G.O.thumbnailBorderHorizontal+'px; border-bottom-width:'+G.O.thumbnailBorderVertical+'px; border-left-width:'+G.O.thumbnailBorderHorizontal+'px;}\n';
|
7244 | s+=s1+'.nGY2GalleryMoreButtonAnnotation { color:'+cs.thumbnail.titleColor+'; '+(cs.thumbnail.titleShadow =='' ? '': 'Text-Shadow:'+cs.thumbnail.titleShadow)+'; }\n';
|
7245 |
|
7246 | jQuery('head').append('<style id="ngycs_'+G.baseEltID+'">'+s+'</style>');
|
7247 | G.$E.base.addClass(galleryTheme);
|
7248 |
|
7249 | };
|
7250 |
|
7251 |
|
7252 | function SetViewerTheme( ) {
|
7253 |
|
7254 | if( G.VOM.viewerTheme != '' ) {
|
7255 | G.VOM.$cont.addClass(G.VOM.viewerTheme);
|
7256 | return;
|
7257 | }
|
7258 |
|
7259 | if( typeof G.O.colorSchemeViewer !== 'undefined' ) {
|
7260 | G.O.viewerTheme = G.O.colorSchemeViewer;
|
7261 | }
|
7262 |
|
7263 | var cs=null;
|
7264 | switch(toType(G.O.viewerTheme)) {
|
7265 | case 'object':
|
7266 | cs = G.viewerTheme_dark;
|
7267 | jQuery.extend(true, cs, G.O.viewerTheme);
|
7268 | G.VOM.viewerTheme = 'nanogallery_viewertheme_custom_' + G.baseEltID;
|
7269 | break;
|
7270 | case 'string':
|
7271 | switch( G.O.viewerTheme ) {
|
7272 | case 'none':
|
7273 | return;
|
7274 | break;
|
7275 | case 'light':
|
7276 | cs = G.viewerTheme_light;
|
7277 | G.VOM.viewerTheme = 'nanogallery_viewertheme_light_' + G.baseEltID;
|
7278 | break;
|
7279 | case 'border':
|
7280 | cs = G.viewerTheme_border;
|
7281 | G.VOM.viewerTheme = 'nanogallery_viewertheme_border_' + G.baseEltID;
|
7282 | break;
|
7283 | case 'dark':
|
7284 | case 'default':
|
7285 | cs = G.viewerTheme_dark;
|
7286 | G.VOM.viewerTheme = 'nanogallery_viewertheme_dark_' + G.baseEltID;
|
7287 | break;
|
7288 | }
|
7289 | break;
|
7290 | default:
|
7291 | NanoAlert(G, 'Error in viewerTheme parameter.');
|
7292 | return;
|
7293 | }
|
7294 |
|
7295 | var s1 = '.' + G.VOM.viewerTheme + ' ';
|
7296 | var s = s1 + '.nGY2Viewer { background:' + cs.background + '; }'+'\n';
|
7297 | s += s1 + '.nGY2ViewerMedia { border:' + cs.imageBorder + '; box-shadow:' + cs.imageBoxShadow + '; }'+'\n';
|
7298 | s += s1 + '.nGY2Viewer .toolbarBackground { background:' + cs.barBackground + '; }'+'\n';
|
7299 | s += s1 + '.nGY2Viewer .nGY2ViewerToolsTopLeft { background:' + cs.barBackground + '; }'+'\n';
|
7300 | s += s1 + '.nGY2Viewer .nGY2ViewerToolsTopRight { background:' + cs.barBackground + '; }'+'\n';
|
7301 | s += s1 + '.nGY2Viewer .nGY2ViewerAreaNext { background:' + cs.barBackground + '; }'+'\n';
|
7302 | s += s1 + '.nGY2Viewer .nGY2ViewerAreaPrevious { background:' + cs.barBackground + '; }'+'\n';
|
7303 | s += s1 + '.nGY2Viewer .toolbar { border:' + cs.barBorder + '; color:' + cs.barColor + '; }'+'\n';
|
7304 | s += s1 + '.nGY2Viewer .toolbar .previousButton:after { color:' + cs.barColor + '; }'+'\n';
|
7305 | s += s1 + '.nGY2Viewer .toolbar .nextButton:after { color:' + cs.barColor + '; }'+'\n';
|
7306 | s += s1 + '.nGY2Viewer .toolbar .closeButton:after { color:' + cs.barColor + '; }'+'\n';
|
7307 | s += s1 + '.nGY2Viewer .toolbar .label .title { color:' + cs.barColor + '; }'+'\n';
|
7308 | s += s1 + '.nGY2Viewer .toolbar .label .description { color:' + cs.barDescriptionColor + '; }'+'\n';
|
7309 | jQuery('head').append('<style>' + s + '</style>');
|
7310 | G.VOM.$cont.addClass(G.VOM.viewerTheme);
|
7311 | };
|
7312 |
|
7313 |
|
7314 |
|
7315 |
|
7316 | function SetPolyFills() {
|
7317 |
|
7318 |
|
7319 |
|
7320 | if (!Function.prototype.bind) {
|
7321 | Function.prototype.bind = function (oThis) {
|
7322 | if (typeof this !== "function") {
|
7323 |
|
7324 |
|
7325 | throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
7326 | }
|
7327 |
|
7328 | var aArgs = Array.prototype.slice.call(arguments, 1),
|
7329 | fToBind = this,
|
7330 | fNOP = function () {},
|
7331 | fBound = function () {
|
7332 | return fToBind.apply(this instanceof fNOP && oThis
|
7333 | ? this
|
7334 | : oThis,
|
7335 | aArgs.concat(Array.prototype.slice.call(arguments)));
|
7336 | };
|
7337 |
|
7338 | fNOP.prototype = this.prototype;
|
7339 | fBound.prototype = new fNOP();
|
7340 |
|
7341 | return fBound;
|
7342 | };
|
7343 | }
|
7344 |
|
7345 |
|
7346 |
|
7347 |
|
7348 |
|
7349 | (function() {
|
7350 | var lastTime = 0;
|
7351 | var vendors = ['ms', 'moz', 'webkit', 'o'];
|
7352 | for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
7353 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
7354 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
|
7355 | }
|
7356 | if (!window.requestAnimationFrame)
|
7357 | window.requestAnimationFrame = function(callback, element) {
|
7358 | var currTime = new Date().getTime();
|
7359 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
7360 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
|
7361 | lastTime = currTime + timeToCall;
|
7362 | return id;
|
7363 | };
|
7364 |
|
7365 | if (!window.cancelAnimationFrame)
|
7366 | window.cancelAnimationFrame = function(id) {
|
7367 | clearTimeout(id);
|
7368 | };
|
7369 | }());
|
7370 |
|
7371 |
|
7372 | Array.prototype.removeIf = function(callback) {
|
7373 | var i = this.length;
|
7374 | while (i--) {
|
7375 | if (callback(this[i], i)) {
|
7376 | this.splice(i, 1);
|
7377 | }
|
7378 | }
|
7379 | };
|
7380 |
|
7381 |
|
7382 |
|
7383 | if (!String.prototype.startsWith) {
|
7384 | String.prototype.startsWith = function(searchString, position) {
|
7385 | position = position || 0;
|
7386 | return this.indexOf(searchString, position) === position;
|
7387 | };
|
7388 | }
|
7389 |
|
7390 | }
|
7391 |
|
7392 |
|
7393 |
|
7394 | function GalleryClicked(e) {
|
7395 |
|
7396 | var r = GalleryEventRetrieveElementl(e, false);
|
7397 |
|
7398 | if( r.GOMidx == -1 ) { return 'exit'; }
|
7399 |
|
7400 | var idx = G.GOM.items[r.GOMidx].thumbnailIdx;
|
7401 | if( G.GOM.slider.hostIdx == r.GOMidx ) {
|
7402 |
|
7403 | idx = G.GOM.items[G.GOM.slider.currentIdx].thumbnailIdx;
|
7404 | }
|
7405 | switch( r.action ) {
|
7406 | case 'OPEN':
|
7407 | ThumbnailOpen(idx, false);
|
7408 | return 'exit';
|
7409 | break;
|
7410 | case 'DISPLAY':
|
7411 |
|
7412 | ThumbnailOpen(idx, true);
|
7413 | return 'exit';
|
7414 | break;
|
7415 | case 'TOGGLESELECT':
|
7416 | ThumbnailSelectionToggle(idx);
|
7417 | return 'exit';
|
7418 | break;
|
7419 | case 'SHARE':
|
7420 | PopupShare(idx);
|
7421 | return 'exit';
|
7422 | break;
|
7423 | case 'DOWNLOAD':
|
7424 | DownloadImage(idx);
|
7425 | return 'exit';
|
7426 | break;
|
7427 | case 'INFO':
|
7428 | ItemDisplayInfo(G.I[idx]);
|
7429 | return 'exit';
|
7430 | break;
|
7431 | case 'CART':
|
7432 | AddToCart(idx);
|
7433 | return 'exit';
|
7434 | break;
|
7435 | default:
|
7436 |
|
7437 | var fu = G.O.fnThumbnailToolCustAction;
|
7438 | if( fu !== null ) {
|
7439 | typeof fu == 'function' ? fu(r.action, G.I[idx]) : window[fu](r.action, G.I[idx]);
|
7440 | }
|
7441 | break;
|
7442 | }
|
7443 | }
|
7444 |
|
7445 |
|
7446 | function DownloadImage(idx) {
|
7447 | if( G.I[idx].mediaKind != 'img' ) { return; }
|
7448 |
|
7449 |
|
7450 | var url = G.I[idx].src;
|
7451 |
|
7452 | if( G.I[idx].downloadURL != undefined && G.I[idx].downloadURL != '' ) {
|
7453 | url = G.I[idx].downloadURL;
|
7454 | }
|
7455 |
|
7456 | var a = document.createElement('a');
|
7457 | a.href = url;
|
7458 |
|
7459 | a.download = url.split('/').pop();
|
7460 | a.target = '_blank';
|
7461 | a.style.display = 'none';
|
7462 | document.body.appendChild(a);
|
7463 | a.click();
|
7464 | document.body.removeChild(a);
|
7465 |
|
7466 | }
|
7467 |
|
7468 |
|
7469 | function AddToCart( idx ) {
|
7470 |
|
7471 | var found=false;
|
7472 | for( var i=0; i<G.shoppingCart.length; i++ ) {
|
7473 | if( G.shoppingCart[i].idx == idx ) {
|
7474 | G.shoppingCart[i].cnt++;
|
7475 | var fu = G.O.fnShoppingCartUpdated;
|
7476 | if( fu !== null ) {
|
7477 | typeof fu == 'function' ? fu(G.shoppingCart, G.I[idx]) : window[fu](G.shoppingCart, G.I[idx]);
|
7478 | }
|
7479 | TriggerCustomEvent('shoppingCartUpdated');
|
7480 | return;
|
7481 | }
|
7482 | }
|
7483 |
|
7484 |
|
7485 | if( !found) {
|
7486 | G.shoppingCart.push( { idx:idx, ID:G.I[idx].GetID(), cnt:1} );
|
7487 | var fu=G.O.fnShoppingCartUpdated;
|
7488 | if( fu !== null ) {
|
7489 | typeof fu == 'function' ? fu(G.shoppingCart, G.I[idx]) : window[fu](G.shoppingCart, G.I[idx]);
|
7490 | }
|
7491 | TriggerCustomEvent('shoppingCartUpdated');
|
7492 | }
|
7493 | }
|
7494 |
|
7495 |
|
7496 |
|
7497 | function ThumbnailSelectionClear() {
|
7498 | G.GOM.nbSelected = 0;
|
7499 | for( var i = 0, nbTn = G.GOM.items.length; i < nbTn ; i++ ) {
|
7500 | var item = G .I[G.GOM.items[i].thumbnailIdx];
|
7501 | if( item.selected ) {
|
7502 | item.selected = false;
|
7503 | var fu = G.O.fnThumbnailSelection;
|
7504 | if( fu !== null ) {
|
7505 | typeof fu == 'function' ? fu(item.$elt, item, G.I) : window[fu](item.$elt, item, G.I);
|
7506 | }
|
7507 | }
|
7508 | item.selected = false;
|
7509 | }
|
7510 | }
|
7511 |
|
7512 | function ThumbnailSelectionToggle( idx ){
|
7513 | var item = G.I[idx];
|
7514 | if( item.selected === true ) {
|
7515 | ThumbnailSelectionSet(item, false);
|
7516 | G.GOM.nbSelected--;
|
7517 | TriggerCustomEvent('itemUnSelected');
|
7518 | }
|
7519 | else {
|
7520 | ThumbnailSelectionSet(item, true);
|
7521 | G.GOM.nbSelected++;
|
7522 | TriggerCustomEvent('itemSelected');
|
7523 | }
|
7524 | }
|
7525 |
|
7526 |
|
7527 |
|
7528 | function ThumbnailSelectionSet(item, selected ){
|
7529 |
|
7530 | item.selected = selected;
|
7531 |
|
7532 | ThumbnailSelectionSetIcon( item );
|
7533 |
|
7534 |
|
7535 | var fu=G.O.fnThumbnailSelection;
|
7536 | if( fu !== null ) {
|
7537 | typeof fu == 'function' ? fu(item.$elt, item, G.I) : window[fu](item.$elt, item, G.I);
|
7538 | }
|
7539 |
|
7540 | }
|
7541 |
|
7542 | function ThumbnailSelectionSetIcon( item ) {
|
7543 | if( item.$elt == null ) {
|
7544 |
|
7545 | return;
|
7546 | }
|
7547 |
|
7548 | var $sub = item.$getElt('.nGY2GThumbnail');
|
7549 | var $icon = item.$getElt('.nGY2GThumbnailIconImageSelect');
|
7550 | if( item.selected === true) {
|
7551 | $sub.addClass('nGY2GThumbnailSubSelected');
|
7552 | $icon.addClass('nGY2ThumbnailSelected');
|
7553 | $icon.removeClass('nGY2ThumbnailUnselected');
|
7554 | $icon.html(G.O.icons.thumbnailSelected);
|
7555 | }
|
7556 | else {
|
7557 | $sub.removeClass('nGY2GThumbnailSubSelected');
|
7558 | $icon.removeClass('nGY2ThumbnailSelected');
|
7559 | $icon.addClass('nGY2ThumbnailUnselected');
|
7560 | $icon.html(G.O.icons.thumbnailUnselected);
|
7561 | }
|
7562 | }
|
7563 |
|
7564 |
|
7565 |
|
7566 | function PopupShare(idx) {
|
7567 |
|
7568 |
|
7569 |
|
7570 |
|
7571 | var item=G.I[idx];
|
7572 |
|
7573 | var currentURL=document.location.protocol + '//' + document.location.hostname + document.location.pathname;
|
7574 | var newLocationHash = '#nanogallery/' + G.baseEltID + '/';
|
7575 | if( item.kind == 'image' ) {
|
7576 | newLocationHash += item.albumID + '/' + item.GetID();
|
7577 | }
|
7578 | else {
|
7579 | newLocationHash += item.GetID();
|
7580 | }
|
7581 |
|
7582 | var content = '';
|
7583 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="facebook">' + G.O.icons.shareFacebook + '</div>';
|
7584 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="pinterest">' + G.O.icons.sharePinterest + '</div>';
|
7585 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="tumblr">' + G.O.icons.shareTumblr + '</div>';
|
7586 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="twitter">' + G.O.icons.shareTwitter + '</div>';
|
7587 |
|
7588 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="vk">' + G.O.icons.shareVK + '</div>';
|
7589 | content += '<div class="nGY2PopupOneItem" style="text-align:center;" data-share="mail">' + G.O.icons.shareMail + '</div>';
|
7590 | content += '<div class="nGY2PopupOneItem" style="text-align:center;"></div>';
|
7591 | content += '<input class="nGY2PopupOneItemText" readonly type="text" value="' + currentURL+newLocationHash + '" style="width:100%;text-align:center;">';
|
7592 | content += '<br>';
|
7593 |
|
7594 | currentURL = encodeURIComponent(document.location.protocol + '//' + document.location.hostname + document.location.pathname + newLocationHash);
|
7595 |
|
7596 | var currentTitle = item.title;
|
7597 | var currentTn = item.thumbImg().src;
|
7598 |
|
7599 |
|
7600 | Popup('Share to:', content, 'Center');
|
7601 |
|
7602 | G.popup.$elt.find('.nGY2PopupOneItem').on('click', function(e) {
|
7603 | e.stopPropagation();
|
7604 |
|
7605 | var shareURL = '';
|
7606 | var found = true;
|
7607 | switch(jQuery(this).attr('data-share').toUpperCase()) {
|
7608 | case 'FACEBOOK':
|
7609 |
|
7610 |
|
7611 | shareURL = 'https://www.facebook.com/sharer.php?u=' + currentURL;
|
7612 | break;
|
7613 | case 'VK':
|
7614 | shareURL = 'http://vk.com/share.php?url=' + currentURL;
|
7615 | break;
|
7616 | case 'GOOGLEPLUS':
|
7617 | shareURL = "https://plus.google.com/share?url=" + currentURL;
|
7618 | break;
|
7619 | case 'TWITTER':
|
7620 |
|
7621 | shareURL = 'https://twitter.com/intent/tweet?text=' + currentTitle + 'url=' + currentURL;
|
7622 | break;
|
7623 | case 'PINTEREST':
|
7624 |
|
7625 | shareURL = 'https://pinterest.com/pin/create/button/?media=' + currentTn + '&url=' + currentURL + '&description=' + currentTitle;
|
7626 | break;
|
7627 | case 'TUMBLR':
|
7628 |
|
7629 | shareURL = 'http://www.tumblr.com/share/link?url=' + currentURL + '&name=' + currentTitle;
|
7630 | break;
|
7631 | case 'MAIL':
|
7632 | shareURL = 'mailto:?subject=' + currentTitle + '&body=' + currentURL;
|
7633 | break;
|
7634 | default:
|
7635 | found = false;
|
7636 | break;
|
7637 | }
|
7638 |
|
7639 | if( found ) {
|
7640 | window.open(shareURL, "" , "height=550,width=500,left=100,top=100,menubar=0" );
|
7641 | G.popup.close();
|
7642 |
|
7643 | }
|
7644 |
|
7645 | });
|
7646 | }
|
7647 |
|
7648 |
|
7649 | function Popup(title, content, align) {
|
7650 | var pp = '<div class="nGY2Popup" style="opacity:0;"><div class="nGY2PopupContent' + align + '">';
|
7651 | pp += '<div class="nGY2PopupCloseButton">' + G.O.icons.buttonClose + '</div>';
|
7652 | pp += '<div class="nGY2PopupTitle">' + title + '</div>';
|
7653 | pp += content;
|
7654 | pp += '</div></div>';
|
7655 |
|
7656 | G.popup.$elt = jQuery(pp).appendTo('body');
|
7657 | setElementOnTop( G.VOM.$viewer, G.popup.$elt);
|
7658 |
|
7659 | G.popup.isDisplayed = true;
|
7660 |
|
7661 | var tweenable = new NGTweenable();
|
7662 | tweenable.tween({
|
7663 | from: { opacity: 0 },
|
7664 | to: { opacity: 1 },
|
7665 | easing: 'easeInOutSine',
|
7666 | duration: 250,
|
7667 | step: function (state, att) {
|
7668 | G.popup.$elt.css( state );
|
7669 | }
|
7670 | });
|
7671 |
|
7672 | G.popup.$elt.find('.nGY2PopupCloseButton').on('click', function(e) {
|
7673 | e.stopPropagation();
|
7674 | G.popup.close();
|
7675 | });
|
7676 |
|
7677 | }
|
7678 |
|
7679 |
|
7680 | function GalleryMouseEnter(e) {
|
7681 | if( !G.VOM.viewerDisplayed && G.GOM.albumIdx != -1 ) {
|
7682 | var r = GalleryEventRetrieveElementl(e, true);
|
7683 |
|
7684 | if( r.GOMidx != -1 ) {
|
7685 | var target = e.target || e.srcElement;
|
7686 |
|
7687 | ThumbnailHover(r.GOMidx);
|
7688 | }
|
7689 | }
|
7690 | }
|
7691 |
|
7692 | function GalleryMouseLeave(e) {
|
7693 | if( !G.VOM.viewerDisplayed && G.GOM.albumIdx != -1 ) {
|
7694 | var r = GalleryEventRetrieveElementl(e, true);
|
7695 | if( r.GOMidx != -1 ) {
|
7696 | var target = e.target || e.srcElement;
|
7697 |
|
7698 | ThumbnailHoverOut(r.GOMidx);
|
7699 | }
|
7700 | }
|
7701 | }
|
7702 |
|
7703 | function GalleryEventRetrieveElementl( e, ignoreSubItems ) {
|
7704 | var r = { action: 'NONE', GOMidx: -1 };
|
7705 |
|
7706 | if( e == undefined ) {
|
7707 | return r;
|
7708 | }
|
7709 | var target = e.target || e.srcElement;
|
7710 | while( target != G.$E.conTnParent[0] ) {
|
7711 | if( jQuery(target).hasClass('nGY2GThumbnail') ) {
|
7712 | if( r.action == 'NONE' ) {
|
7713 | r.action = 'OPEN';
|
7714 | }
|
7715 | r.GOMidx = jQuery(target).data('index');
|
7716 | return r;
|
7717 | }
|
7718 |
|
7719 | if( !ignoreSubItems ) {
|
7720 | var a = jQuery(target).data('ngy2action');
|
7721 | if( a != '' && a != undefined ) {
|
7722 | r.action = a;
|
7723 | }
|
7724 | }
|
7725 | if( target.parentNode == null ) {
|
7726 | return r;
|
7727 | }
|
7728 | target = target.parentNode;
|
7729 | }
|
7730 | return r;
|
7731 | }
|
7732 |
|
7733 |
|
7734 |
|
7735 | function ThumbnailOpen( idx, ignoreSelected ) {
|
7736 | var item = G.I[idx];
|
7737 |
|
7738 | var fu = G.O.fnThumbnailClicked;
|
7739 | if( fu !== null ) {
|
7740 | typeof fu == 'function' ? fu(item.$elt, item) : window[fu](item.$elt, item);
|
7741 | }
|
7742 |
|
7743 |
|
7744 | if( item.destinationURL !== undefined && item.destinationURL.length > 0 ) {
|
7745 | window.location = item.destinationURL;
|
7746 | return;
|
7747 | }
|
7748 |
|
7749 | switch( item.kind ) {
|
7750 | case 'image':
|
7751 | if( ignoreSelected === false && G.GOM.nbSelected > 0 ) {
|
7752 | ThumbnailSelectionToggle(idx);
|
7753 | }
|
7754 | else {
|
7755 |
|
7756 | DisplayPhotoIdx(idx);
|
7757 | }
|
7758 | break;
|
7759 | case 'album':
|
7760 | if( ignoreSelected === false && G.GOM.nbSelected > 0 ) {
|
7761 | ThumbnailSelectionToggle(idx);
|
7762 | }
|
7763 | else {
|
7764 | if( G.O.thumbnailAlbumDisplayImage && idx != 0 ) {
|
7765 |
|
7766 | DisplayFirstMediaInAlbum(idx);
|
7767 | return;
|
7768 | }
|
7769 | else {
|
7770 |
|
7771 | DisplayAlbum('-1', item.GetID());
|
7772 | }
|
7773 | }
|
7774 | break;
|
7775 | case 'albumUp':
|
7776 | var parent = NGY2Item.Get(G, item.albumID);
|
7777 | DisplayAlbum('-1', parent.albumID);
|
7778 | break;
|
7779 | }
|
7780 | }
|
7781 |
|
7782 | function DisplayFirstMediaInAlbum( albumIdx ) {
|
7783 | if( G.O.debugMode ) { console.log('#DisplayFirstPhotoInAlbum : '+ albumIdx); }
|
7784 |
|
7785 | var item = G.I[albumIdx];
|
7786 |
|
7787 | var l = G.I.length;
|
7788 | for( var i = 0; i < l; i++ ) {
|
7789 | if( G.I[i].albumID == item.GetID() ) {
|
7790 | DisplayPhotoIdx( i );
|
7791 | return;
|
7792 | }
|
7793 | }
|
7794 |
|
7795 |
|
7796 | AlbumGetContent( item.GetID(), DisplayFirstMediaInAlbum, albumIdx, null );
|
7797 |
|
7798 | }
|
7799 |
|
7800 |
|
7801 |
|
7802 | function OpenOriginal( item ) {
|
7803 | switch( G.O.kind ) {
|
7804 | case 'flickr':
|
7805 | var sU = 'https://www.flickr.com/photos/' + G.O.userID + '/' + item.GetID();
|
7806 | if( item.albumID != '0' ) {
|
7807 | sU += '/in/album-' + item.albumID + '/';
|
7808 | }
|
7809 | window.open(sU, '_blank');
|
7810 | break;
|
7811 | case 'picasa':
|
7812 | case 'google':
|
7813 | case 'google2':
|
7814 |
|
7815 |
|
7816 |
|
7817 |
|
7818 | default:
|
7819 | var sU = item.responsiveURL();
|
7820 | window.open(sU, '_blank');
|
7821 | break;
|
7822 | }
|
7823 | }
|
7824 |
|
7825 |
|
7826 | function DisplayPhotoIdx( ngy2ItemIdx ) {
|
7827 |
|
7828 | if( !G.O.thumbnailOpenImage ) { return; }
|
7829 |
|
7830 | if( G.O.thumbnailOpenOriginal ) {
|
7831 |
|
7832 | OpenOriginal( G.I[ngy2ItemIdx] );
|
7833 | return;
|
7834 | }
|
7835 |
|
7836 | var items = [];
|
7837 | G.VOM.currItemIdx = 0;
|
7838 | G.VOM.items = [];
|
7839 | G.VOM.albumID = G.I[ngy2ItemIdx].albumID;
|
7840 |
|
7841 | var vimg = new VImg(ngy2ItemIdx);
|
7842 | G.VOM.items.push(vimg);
|
7843 | items.push(G.I[ngy2ItemIdx]);
|
7844 |
|
7845 | var l = G.I.length;
|
7846 | for( var idx = ngy2ItemIdx+1; idx < l ; idx++) {
|
7847 | var item = G.I[idx];
|
7848 | if( item.kind == 'image' && item.isToDisplay(G.VOM.albumID) && item.destinationURL == '' ) {
|
7849 | var vimg = new VImg(idx);
|
7850 | G.VOM.items.push(vimg);
|
7851 | items.push(item);
|
7852 | }
|
7853 | }
|
7854 | var last = G.VOM.items.length;
|
7855 | var cnt = 1;
|
7856 | for( var idx = 0; idx < ngy2ItemIdx ; idx++) {
|
7857 | var item = G.I[idx];
|
7858 | if( item.kind == 'image' && item.isToDisplay(G.VOM.albumID) && item.destinationURL == '' ) {
|
7859 | var vimg = new VImg(idx);
|
7860 | vimg.mediaNumber = cnt;
|
7861 | G.VOM.items.push(vimg);
|
7862 | items.push(item);
|
7863 | cnt++;
|
7864 | }
|
7865 | }
|
7866 | for( var i = 0; i < last; i++ ) {
|
7867 | G.VOM.items[i].mediaNumber = cnt;
|
7868 | cnt++;
|
7869 | }
|
7870 |
|
7871 |
|
7872 | var fu = G.O.fnThumbnailOpen;
|
7873 | if( fu !== null ) {
|
7874 | typeof fu == 'function' ? fu(items) : window[fu](items);
|
7875 | return;
|
7876 | }
|
7877 |
|
7878 |
|
7879 | if( !G.VOM.viewerDisplayed ) {
|
7880 |
|
7881 | OpenInternalViewer();
|
7882 | }
|
7883 | else {
|
7884 |
|
7885 | G.VOM.$mediaCurrent.empty();
|
7886 | var item = G.VOM.NGY2Item(0);
|
7887 | var spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
7888 | if( item.mediaKind == 'img' && item.imageWidth != 0 && item.imageHeight != 0 ) {
|
7889 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
7890 | }
|
7891 | G.VOM.$mediaCurrent.append( spreloader + item.mediaMarkup);
|
7892 | ViewerSetMediaVisibility(G.VOM.NGY2Item(1), G.VOM.$mediaNext, 0);
|
7893 | ViewerSetMediaVisibility(G.VOM.NGY2Item(-1), G.VOM.$mediaPrevious, 0);
|
7894 | if( item.mediaKind == 'img' ) {
|
7895 | G.VOM.ImageLoader.loadImage(VieweImgSizeRetrieved, item);
|
7896 | }
|
7897 |
|
7898 |
|
7899 |
|
7900 | DisplayInternalViewer(0, '');
|
7901 | }
|
7902 | }
|
7903 |
|
7904 | function ViewerZoomStart() {
|
7905 | if( G.O.viewerZoom && !G.VOM.viewerMediaIsChanged ) {
|
7906 | var item=G.VOM.NGY2Item(0);
|
7907 | if( item.imageHeight > 0 && item.imageWidth > 0 ) {
|
7908 | if( G.VOM.zoom.isZooming === false ) {
|
7909 |
|
7910 | G.VOM.zoom.userFactor = 1;
|
7911 | G.VOM.zoom.isZooming = true;
|
7912 | }
|
7913 | return true;
|
7914 | }
|
7915 | }
|
7916 | }
|
7917 |
|
7918 | function ViewerZoomIn( zoomIn ) {
|
7919 | if( zoomIn ) {
|
7920 |
|
7921 | G.VOM.zoom.userFactor+=0.1;
|
7922 | ViewerZoomMax();
|
7923 | }
|
7924 | else {
|
7925 |
|
7926 | G.VOM.zoom.userFactor-=0.1;
|
7927 | ViewerZoomMin();
|
7928 | }
|
7929 | ViewerMediaSetPosAndZoom();
|
7930 | }
|
7931 |
|
7932 | function ViewerZoomMax() {
|
7933 | if( G.VOM.zoom.userFactor > 3 ) {
|
7934 | G.VOM.zoom.userFactor = 3;
|
7935 | }
|
7936 | }
|
7937 | function ViewerZoomMin() {
|
7938 |
|
7939 | if( G.VOM.zoom.userFactor < 0.2 ) {
|
7940 | G.VOM.zoom.userFactor = 0.2;
|
7941 | }
|
7942 | }
|
7943 |
|
7944 |
|
7945 |
|
7946 |
|
7947 | function ViewerMediaSetPosAndZoom() {
|
7948 |
|
7949 | if( !G.VOM.zoom.isZooming ) {
|
7950 | G.VOM.zoom.userFactor = 1;
|
7951 | }
|
7952 |
|
7953 | ViewerMediaSetPosAndZoomOne( G.VOM.NGY2Item(0), G.VOM.$mediaCurrent, true );
|
7954 | ViewerMediaSetPosAndZoomOne( G.VOM.NGY2Item(-1), G.VOM.$mediaPrevious, false );
|
7955 | ViewerMediaSetPosAndZoomOne( G.VOM.NGY2Item(1), G.VOM.$mediaNext, false );
|
7956 |
|
7957 | }
|
7958 |
|
7959 |
|
7960 |
|
7961 |
|
7962 | function ViewerMediaCenterNotImg( $mediaContainer ) {
|
7963 | var $media = $mediaContainer.children().eq(1);
|
7964 | $media.css( {'height': '80%' });
|
7965 | $media.css( {'width': '90%' });
|
7966 | $media[0].style[G.CSStransformName] = 'translate(0px, "50%") ';
|
7967 | }
|
7968 |
|
7969 |
|
7970 | function ViewerMediaSetPosAndZoomOne(item, $img, isCurrent ) {
|
7971 |
|
7972 | if( item.mediaKind != 'img' ) {
|
7973 | ViewerMediaCenterNotImg($img);
|
7974 | return;
|
7975 | }
|
7976 |
|
7977 | if( item.imageHeight == 0 || item.imageWidth == 0 ) {
|
7978 | ViewerSetMediaVisibility( item, $img, 0 );
|
7979 | return;
|
7980 | }
|
7981 |
|
7982 |
|
7983 | var zoomUserFactor = isCurrent == true ? G.VOM.zoom.userFactor : 1;
|
7984 |
|
7985 | var dpr = 1;
|
7986 | if( G.O.viewerImageDisplay == 'bestImageQuality' ) {
|
7987 | dpr = window.devicePixelRatio;
|
7988 | }
|
7989 |
|
7990 |
|
7991 | var zoomBaseFactorW = (G.VOM.window.lastWidth - G.VOM.padding.V) / (item.imageWidth / dpr);
|
7992 | var zoomBaseFactorH = (G.VOM.window.lastHeight - G.VOM.padding.H) / (item.imageHeight / dpr);
|
7993 | var zoomBaseFactor = Math.min(zoomBaseFactorW, zoomBaseFactorH);
|
7994 | if( zoomBaseFactor > 1 && G.O.viewerImageDisplay != 'upscale' ) {
|
7995 |
|
7996 | zoomBaseFactor = 1;
|
7997 | }
|
7998 |
|
7999 | var imageCurrentHeight = (item.imageHeight / dpr) * zoomUserFactor * zoomBaseFactor;
|
8000 | var imageCurrentWidth = (item.imageWidth / dpr) * zoomUserFactor * zoomBaseFactor;
|
8001 | $img.children().eq(1).css( {'height': imageCurrentHeight });
|
8002 | $img.children().eq(1).css( {'width': imageCurrentWidth });
|
8003 |
|
8004 |
|
8005 | var posX = 0;
|
8006 | if( imageCurrentWidth > G.VOM.window.lastWidth ) {
|
8007 | posX = -(imageCurrentWidth - G.VOM.window.lastWidth)/2;
|
8008 | }
|
8009 | var posY = 0;
|
8010 | if( imageCurrentHeight > G.VOM.window.lastHeight ) {
|
8011 | posY = ( imageCurrentHeight - G.VOM.window.lastHeight ) / 2;
|
8012 | }
|
8013 | posY = 0;
|
8014 |
|
8015 |
|
8016 | if( isCurrent ) {
|
8017 | if( !G.VOM.zoom.isZooming ) {
|
8018 | G.VOM.panPosX = 0;
|
8019 | G.VOM.panPosY = 0;
|
8020 | }
|
8021 | G.VOM.zoom.posX = posX;
|
8022 | G.VOM.zoom.posY = posY;
|
8023 | ViewerImagePanSetPosition(G.VOM.panPosX, G.VOM.panPosY, $img, false);
|
8024 | }
|
8025 |
|
8026 |
|
8027 |
|
8028 | else {
|
8029 |
|
8030 | ViewerMediaPanX( G.VOM.swipePosX );
|
8031 | $img.children().eq(1)[0].style[G.CSStransformName]= 'translate(0px, 0px) rotate('+ item.rotationAngle +'deg)';
|
8032 | }
|
8033 |
|
8034 | }
|
8035 |
|
8036 |
|
8037 |
|
8038 | function ViewerImagePanSetPosition(posX, posY, imageContainer, savePosition ) {
|
8039 | if( savePosition ) {
|
8040 | G.VOM.panPosX = posX;
|
8041 | G.VOM.panPosY = posY;
|
8042 | }
|
8043 |
|
8044 | posX += G.VOM.zoom.posX;
|
8045 | posY += G.VOM.zoom.posY;
|
8046 |
|
8047 |
|
8048 | imageContainer.children().eq(1)[0].style[G.CSStransformName]= 'translate('+ posX + 'px, '+ posY + 'px) rotate('+ G.VOM.NGY2Item(0).rotationAngle +'deg)';
|
8049 |
|
8050 |
|
8051 | }
|
8052 |
|
8053 |
|
8054 |
|
8055 | function OpenInternalViewer( ) {
|
8056 |
|
8057 | G.VOM.viewerDisplayed = true;
|
8058 | G.GOM.firstDisplay = false;
|
8059 |
|
8060 | G.VOM.saveOverflowX = window.getComputedStyle(document.body)['overflow-x'];
|
8061 | G.VOM.saveOverflowY = window.getComputedStyle(document.body)['overflow-y'];
|
8062 | jQuery('body').css({ overflow: 'hidden' });
|
8063 |
|
8064 | G.VOM.$cont = jQuery('<div class="nGY2 nGY2ViewerContainer" style="opacity:1"></div>').appendTo('body');
|
8065 |
|
8066 | SetViewerTheme();
|
8067 |
|
8068 | G.VOM.$viewer = jQuery('<div class="nGY2Viewer" style="opacity:0" itemscope itemtype="http://schema.org/ImageObject"></div>').appendTo( G.VOM.$cont );
|
8069 | G.VOM.$viewer.css({ msTouchAction: 'none', touchAction: 'none' });
|
8070 |
|
8071 | G.VOM.currItemIdx = 0;
|
8072 | var sMedia = '<div class="nGY2ViewerMediaPan"><div class="nGY2ViewerMediaLoaderDisplayed"></div>' + G.VOM.NGY2Item(-1).mediaMarkup + '</div>';
|
8073 | sMedia += '<div class="nGY2ViewerMediaPan"><div class="nGY2ViewerMediaLoaderDisplayed"></div>' + G.VOM.NGY2Item(0).mediaMarkup + '</div>';
|
8074 | sMedia += '<div class="nGY2ViewerMediaPan"><div class="nGY2ViewerMediaLoaderDisplayed"></div>' + G.VOM.NGY2Item(1).mediaMarkup + '</div>';
|
8075 |
|
8076 | var sNav = '';
|
8077 | var iconP = G.O.icons.viewerImgPrevious;
|
8078 | if( iconP != undefined && iconP != '') {
|
8079 | sNav += '<div class="nGY2ViewerAreaPrevious ngy2viewerToolAction" data-ngy2action="previous">' + iconP + '</div>';
|
8080 | }
|
8081 | var iconN = G.O.icons.viewerImgNext;
|
8082 | if( iconN != undefined && iconN != '') {
|
8083 | sNav += '<div class="nGY2ViewerAreaNext ngy2viewerToolAction" data-ngy2action="next">' + iconN + '</div>';
|
8084 | }
|
8085 |
|
8086 | G.VOM.$content = jQuery('<div class="nGY2ViewerContent">' + sMedia + sNav + '</div>').appendTo( G.VOM.$viewer );
|
8087 |
|
8088 | var $mediaPan = G.VOM.$content.find('.nGY2ViewerMediaPan');
|
8089 | G.VOM.$mediaPrevious = $mediaPan.eq(0);
|
8090 | G.VOM.$mediaCurrent = $mediaPan.eq(1);
|
8091 | G.VOM.$mediaNext = $mediaPan.eq(2);
|
8092 |
|
8093 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, G.VOM.NGY2Item(0) );
|
8094 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, G.VOM.NGY2Item(-1) );
|
8095 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, G.VOM.NGY2Item(1) );
|
8096 |
|
8097 | G.VOM.padding.H = parseInt(G.VOM.$content.css("padding-left")) + parseInt(G.VOM.$content.css("padding-right"));
|
8098 | G.VOM.padding.V = parseInt(G.VOM.$content.css("padding-top")) + parseInt(G.VOM.$content.css("padding-bottom"));
|
8099 |
|
8100 |
|
8101 | var vtbBg1 = '';
|
8102 | var vtbBg2 = ' toolbarBackground';
|
8103 | if( G.O.viewerToolbar.fullWidth ) {
|
8104 | vtbBg1 = ' toolbarBackground';
|
8105 | vtbBg2 = '';
|
8106 | }
|
8107 | var vtbAlign = 'text-align:center;';
|
8108 | switch ( G.O.viewerToolbar.align ) {
|
8109 | case 'left':
|
8110 | vtbAlign = 'text-align:left;';
|
8111 | break;
|
8112 | case 'right':
|
8113 | vtbAlign = 'text-align:right;';
|
8114 | break;
|
8115 | }
|
8116 | var sTB = '<div class="toolbarContainer nGEvent' + vtbBg1 + '" style="visibility:' +(G.O.viewerToolbar.display ? "visible" : "hidden")+';'+vtbAlign+'"><div class="toolbar nGEvent' + vtbBg2 + '"></div></div>';
|
8117 | G.VOM.$toolbar = jQuery(sTB).appendTo(G.VOM.$viewer);
|
8118 |
|
8119 | if( G.VOM.toolbarMode == 'min' || (G.O.viewerToolbar.autoMinimize > 0 && G.O.viewerToolbar.autoMinimize >= G.GOM.cache.viewport.w) ) {
|
8120 | ViewerToolbarForVisibilityMin();
|
8121 | }
|
8122 | else {
|
8123 | ViewerToolbarForVisibilityStd();
|
8124 | }
|
8125 |
|
8126 |
|
8127 | if( G.O.viewerTools.topLeft != '' ) {
|
8128 | var sTopLeft = '<div class="nGY2ViewerToolsTopLeft nGEvent"><div class="toolbar nGEvent">';
|
8129 | var sTL = G.O.viewerTools.topLeft.split(',');
|
8130 | for( var i = 0, sTLL = sTL.length; i < sTLL; i++) {
|
8131 | sTopLeft += ToolbarAddElt( sTL[i] );
|
8132 | }
|
8133 | sTopLeft += '</div></div>';
|
8134 | G.VOM.$toolbarTL = jQuery(sTopLeft).appendTo(G.VOM.$viewer);
|
8135 | }
|
8136 |
|
8137 | if( G.O.viewerTools.topRight != '' ) {
|
8138 | var sTopRight = '<div class="nGY2ViewerToolsTopRight nGEvent"><div class="toolbar nGEvent">';
|
8139 | var sTR = G.O.viewerTools.topRight.split(',');
|
8140 | for( var i = 0, sTRL = sTR.length; i < sTRL; i++) {
|
8141 | sTopRight += ToolbarAddElt( sTR[i] );
|
8142 | }
|
8143 | sTopRight += '</div></div>';
|
8144 | G.VOM.$toolbarTR = jQuery(sTopRight).appendTo(G.VOM.$viewer);
|
8145 | }
|
8146 |
|
8147 |
|
8148 | ViewerToolsOn();
|
8149 |
|
8150 |
|
8151 | if( G.O.viewerDisplayLogo ) { G.$E.vwLogo=jQuery('<div class="nGY2 nGY2ViewerLogo"></div>').appendTo(G.VOM.$viewer); }
|
8152 |
|
8153 |
|
8154 | if( ngscreenfull.enabled && G.O.viewerFullscreen ) { ngscreenfull.request(); }
|
8155 |
|
8156 | setElementOnTop('', G.VOM.$viewer);
|
8157 | ResizeInternalViewer(true);
|
8158 | G.VOM.timeImgChanged = new Date().getTime();
|
8159 |
|
8160 |
|
8161 | var tweenable = new NGTweenable();
|
8162 | tweenable.tween({
|
8163 | from: { opacity: 0, posY: G.VOM.window.lastHeight*.5 },
|
8164 | to: { opacity: 1, posY: 0 },
|
8165 | delay: 30,
|
8166 | duration: 500,
|
8167 | easing: 'easeOutQuart',
|
8168 | step: function (state) {
|
8169 | G.VOM.$viewer.css('opacity', state.opacity);
|
8170 | G.VOM.$viewer[0].style[G.CSStransformName] = 'translateY(' + (state.posY) + 'px) ';
|
8171 | }
|
8172 | });
|
8173 |
|
8174 |
|
8175 |
|
8176 |
|
8177 |
|
8178 |
|
8179 | ViewerMediaPanX(0);
|
8180 | ViewerSetEvents();
|
8181 |
|
8182 | DisplayInternalViewer(0, '');
|
8183 |
|
8184 | if( G.O.slideshowAutoStart ) {
|
8185 | G.VOM.playSlideshow = false;
|
8186 | SlideshowToggle();
|
8187 | }
|
8188 | }
|
8189 |
|
8190 | function ViewerEvents() {
|
8191 | if( !G.VOM.viewerDisplayed || G.VOM.viewerMediaIsChanged || G.VOM.NGY2Item(0).mediaKind != 'img') {
|
8192 |
|
8193 | return false;
|
8194 | }
|
8195 | return true;
|
8196 | }
|
8197 |
|
8198 |
|
8199 |
|
8200 | function ViewerSetEvents() {
|
8201 |
|
8202 | if( G.VOM.hammertime == null ) {
|
8203 |
|
8204 | G.VOM.hammertime = new NGHammer.Manager(G.VOM.$cont[0], {
|
8205 | recognizers: [
|
8206 | [NGHammer.Pinch, { enable: true }],
|
8207 | [NGHammer.Pan, { direction: NGHammer.DIRECTION_ALL }]
|
8208 | ]
|
8209 | });
|
8210 |
|
8211 |
|
8212 | G.VOM.hammertime.on('pan', function(ev) {
|
8213 | if( !ViewerEvents() ) { return; }
|
8214 |
|
8215 | if( G.VOM.zoom.isZooming ) {
|
8216 |
|
8217 | ViewerImagePanSetPosition(G.VOM.panPosX + ev.deltaX, G.VOM.panPosY + ev.deltaY, G.VOM.$mediaCurrent, false);
|
8218 | if( G.VOM.toolbarsDisplayed == true ) {
|
8219 | G.VOM.toolsHide();
|
8220 | }
|
8221 | }
|
8222 | else {
|
8223 | if( ev.deltaY > G.VOM.panThreshold && Math.abs(ev.deltaX) < G.VOM.panThreshold && !G.VOM.panXOnly ) {
|
8224 |
|
8225 | ViewerMediaPanX( 0 );
|
8226 | var dist = Math.min(ev.deltaY, 200);
|
8227 | G.VOM.$viewer[0].style[G.CSStransformName] = 'translateY(' + dist + 'px) ';
|
8228 | G.VOM.$viewer.css('opacity', 1-dist/200/2);
|
8229 | }
|
8230 | else {
|
8231 |
|
8232 | if( Math.abs(ev.deltaX) > G.VOM.panThreshold ) {
|
8233 | G.VOM.panXOnly = true;
|
8234 | }
|
8235 | ViewerMediaPanX( ev.deltaX );
|
8236 | G.VOM.$viewer[0].style[G.CSStransformName] = 'translateY(0px)';
|
8237 | G.VOM.$viewer.css('opacity', 1);
|
8238 | }
|
8239 | }
|
8240 | });
|
8241 |
|
8242 |
|
8243 | G.VOM.hammertime.on('panend', function(ev) {
|
8244 | if( !ViewerEvents() ) { return; }
|
8245 | if( G.VOM.zoom.isZooming ) {
|
8246 | G.VOM.timeImgChanged = new Date().getTime();
|
8247 | ViewerImagePanSetPosition(G.VOM.panPosX+ev.deltaX, G.VOM.panPosY+ev.deltaY, G.VOM.$mediaCurrent, true);
|
8248 | }
|
8249 | else {
|
8250 | var panY = false;
|
8251 | if( !G.VOM.panXOnly ) {
|
8252 | if( ev.deltaY > 50 && Math.abs(ev.deltaX) < 50 ) {
|
8253 |
|
8254 | CloseInternalViewer(G.VOM.currItemIdx);
|
8255 | panY = true;
|
8256 | }
|
8257 | }
|
8258 | if( !panY ) {
|
8259 | if( Math.abs( ev.deltaX ) < 50 ) {
|
8260 | ViewerMediaPanX(0);
|
8261 | }
|
8262 | else {
|
8263 | ev.deltaX > 50 ? DisplayPreviousMedia() : DisplayNextMedia();
|
8264 | }
|
8265 | }
|
8266 | }
|
8267 | G.VOM.panXOnly = false;
|
8268 | });
|
8269 |
|
8270 | if( G.O.viewerZoom ) {
|
8271 |
|
8272 | G.VOM.hammertime.add( new NGHammer.Tap({ event: 'doubletap', taps: 2 }) );
|
8273 | G.VOM.hammertime.add( new NGHammer.Tap({ event: 'singletap' }) );
|
8274 | G.VOM.hammertime.get('doubletap').recognizeWith('singletap');
|
8275 | G.VOM.hammertime.get('singletap').requireFailure('doubletap');
|
8276 |
|
8277 |
|
8278 | G.VOM.hammertime.on('singletap', function(ev) {
|
8279 | if( !ViewerEvents() ) { return; }
|
8280 | StopPropagationPreventDefault(ev.srcEvent);
|
8281 | if( G.VOM.toolbarsDisplayed == false ) {
|
8282 | debounce( ViewerToolsUnHide, 100, false)();
|
8283 | }
|
8284 | else {
|
8285 | if( ev.target.className.indexOf('nGY2ViewerMedia') !== -1 ) {
|
8286 | if( ev.srcEvent.pageX < (G.GOM.cache.viewport.w/2) ) {
|
8287 | DisplayPreviousMedia();
|
8288 | }
|
8289 | else {
|
8290 | DisplayNextMedia();
|
8291 | }
|
8292 | }
|
8293 | }
|
8294 | });
|
8295 |
|
8296 |
|
8297 | G.VOM.hammertime.on('doubletap', function(ev) {
|
8298 | if( !ViewerEvents() ) { return; }
|
8299 | StopPropagationPreventDefault(ev.srcEvent);
|
8300 |
|
8301 | if( ev.target.className.indexOf('nGY2ViewerMedia') !== -1 ) {
|
8302 |
|
8303 | if( G.VOM.zoom.isZooming ) {
|
8304 | G.VOM.zoom.isZooming = false;
|
8305 |
|
8306 | ResizeInternalViewer(true);
|
8307 | }
|
8308 | else {
|
8309 | if( ViewerZoomStart() ) {
|
8310 | G.VOM.zoom.userFactor = 1.5;
|
8311 | ViewerMediaSetPosAndZoom();
|
8312 | }
|
8313 | }
|
8314 | }
|
8315 | });
|
8316 |
|
8317 |
|
8318 | G.VOM.hammertime.on('pinchend', function(ev) {
|
8319 | ev.srcEvent.stopPropagation();
|
8320 | ev.srcEvent.preventDefault();
|
8321 | G.VOM.timeImgChanged = new Date().getTime();
|
8322 | });
|
8323 | G.VOM.hammertime.on('pinch', function(ev) {
|
8324 | ev.srcEvent.stopPropagation();
|
8325 | ev.srcEvent.preventDefault();
|
8326 |
|
8327 | if( ViewerZoomStart() ) {
|
8328 | G.VOM.zoom.userFactor = ev.scale;
|
8329 | ViewerZoomMax();
|
8330 | ViewerZoomMin();
|
8331 | ViewerMediaSetPosAndZoom();
|
8332 | }
|
8333 | });
|
8334 | }
|
8335 | else {
|
8336 |
|
8337 | G.VOM.hammertime.on('tap', function(ev) {
|
8338 | if( !ViewerEvents() ) { return; }
|
8339 | StopPropagationPreventDefault(ev.srcEvent);
|
8340 | if( G.VOM.toolbarsDisplayed == false ){
|
8341 |
|
8342 | debounce( ViewerToolsUnHide, 100, false)();
|
8343 | }
|
8344 | else {
|
8345 |
|
8346 | if( ev.target.className.indexOf('nGY2ViewerMedia') !== -1 ) {
|
8347 | if( ev.srcEvent.pageX < (G.GOM.cache.viewport.w/2) ) {
|
8348 | DisplayPreviousMedia();
|
8349 | }
|
8350 | else {
|
8351 | DisplayNextMedia();
|
8352 | }
|
8353 | }
|
8354 | }
|
8355 |
|
8356 | });
|
8357 | }
|
8358 | }
|
8359 | }
|
8360 |
|
8361 | function StopPropagationPreventDefault(e) {
|
8362 | e.stopPropagation();
|
8363 | e.preventDefault();
|
8364 | }
|
8365 |
|
8366 |
|
8367 | function ViewerToolsHide() {
|
8368 | if( G.VOM.viewerDisplayed ) {
|
8369 | G.VOM.toolbarsDisplayed = false;
|
8370 | ViewerToolsOpacity(0);
|
8371 | }
|
8372 | }
|
8373 |
|
8374 | function ViewerToolsUnHide() {
|
8375 | if( G.VOM.viewerDisplayed ) {
|
8376 | G.VOM.toolbarsDisplayed = true;
|
8377 | ViewerToolsOpacity(1);
|
8378 | G.VOM.toolsHide();
|
8379 | }
|
8380 | }
|
8381 |
|
8382 | function ViewerToolsOpacity( op ) {
|
8383 | if( G.VOM.$toolbar != null ) {
|
8384 | G.VOM.$toolbar.css('opacity', op);
|
8385 | }
|
8386 | if( G.VOM.$toolbarTL != null ) {
|
8387 | G.VOM.$toolbarTL.css('opacity', op);
|
8388 | }
|
8389 | if( G.VOM.$toolbarTR != null ) {
|
8390 | G.VOM.$toolbarTR.css('opacity', op);
|
8391 | }
|
8392 | G.VOM.$content.find('.nGY2ViewerAreaNext').css('opacity', op);
|
8393 | G.VOM.$content.find('.nGY2ViewerAreaPrevious').css('opacity', op);
|
8394 | }
|
8395 |
|
8396 |
|
8397 |
|
8398 | function ViewerToolsOn() {
|
8399 |
|
8400 | G.VOM.$viewer.off('touchstart click', '.ngy2viewerToolAction', ViewerToolsAction);
|
8401 |
|
8402 |
|
8403 | G.VOM.$viewer.on('touchstart click', '.ngy2viewerToolAction', ViewerToolsAction);
|
8404 | }
|
8405 |
|
8406 |
|
8407 |
|
8408 | function ViewerToolsAction(e) {
|
8409 |
|
8410 | if( (new Date().getTime()) - G.timeLastTouchStart < 300 ) { return; }
|
8411 | G.timeLastTouchStart = new Date().getTime();
|
8412 |
|
8413 | var $this = $(this);
|
8414 | var ngy2action = $this.data('ngy2action');
|
8415 | if( ngy2action == undefined ) { return; }
|
8416 | switch( ngy2action ) {
|
8417 | case 'next':
|
8418 | StopPropagationPreventDefault(e);
|
8419 | DisplayNextMedia();
|
8420 | break;
|
8421 | case 'previous':
|
8422 | StopPropagationPreventDefault(e);
|
8423 | DisplayPreviousMedia();
|
8424 | break;
|
8425 | case 'playPause':
|
8426 | e.stopPropagation();
|
8427 | SlideshowToggle();
|
8428 | break;
|
8429 | case 'zoomIn':
|
8430 | StopPropagationPreventDefault(e);
|
8431 | if( ViewerZoomStart() ) { ViewerZoomIn( true ); }
|
8432 | break;
|
8433 | case 'zoomOut':
|
8434 | StopPropagationPreventDefault(e);
|
8435 | if( ViewerZoomStart() ) { ViewerZoomIn( false ); }
|
8436 | break;
|
8437 | case 'minimize':
|
8438 |
|
8439 | StopPropagationPreventDefault(e);
|
8440 | if( G.VOM.toolbarMode == 'std' ) {
|
8441 | ViewerToolbarForVisibilityMin();
|
8442 | }
|
8443 | else {
|
8444 | ViewerToolbarForVisibilityStd();
|
8445 | }
|
8446 | break;
|
8447 | case 'fullScreen':
|
8448 |
|
8449 | e.stopPropagation();
|
8450 | if( ngscreenfull.enabled ) {
|
8451 | ngscreenfull.toggle();
|
8452 | }
|
8453 | break;
|
8454 | case 'info':
|
8455 | e.stopPropagation();
|
8456 | ItemDisplayInfo(G.VOM.NGY2Item(0));
|
8457 | break;
|
8458 | case 'close':
|
8459 | StopPropagationPreventDefault(e);
|
8460 | if( (new Date().getTime()) - G.VOM.timeImgChanged < 400 ) { return; }
|
8461 | CloseInternalViewer(G.VOM.currItemIdx);
|
8462 | break;
|
8463 | case 'download':
|
8464 | StopPropagationPreventDefault(e);
|
8465 | DownloadImage(G.VOM.items[G.VOM.currItemIdx].ngy2ItemIdx);
|
8466 | break;
|
8467 | case 'share':
|
8468 | StopPropagationPreventDefault(e);
|
8469 | PopupShare(G.VOM.items[G.VOM.currItemIdx].ngy2ItemIdx);
|
8470 | break;
|
8471 | case 'linkOriginal':
|
8472 | StopPropagationPreventDefault(e);
|
8473 | OpenOriginal( G.VOM.NGY2Item(0) );
|
8474 | break;
|
8475 | case 'rotateLeft':
|
8476 | StopPropagationPreventDefault(e);
|
8477 | ViewerImageRotate(-90);
|
8478 | break;
|
8479 | case 'rotateRight':
|
8480 | StopPropagationPreventDefault(e);
|
8481 | ViewerImageRotate(90);
|
8482 | break;
|
8483 | }
|
8484 |
|
8485 |
|
8486 | var fu = G.O.fnImgToolbarCustClick;
|
8487 | if( ngy2action.indexOf('custom') == 0 && fu !== null ) {
|
8488 | typeof fu == 'function' ? fu(ngy2action, $this, G.VOM.NGY2Item(0)) : window[fu](ngy2action, $this, G.VOM.NGY2Item(0));
|
8489 | }
|
8490 | }
|
8491 |
|
8492 |
|
8493 | function ViewerImageRotate( angle ) {
|
8494 | var item = G.VOM.NGY2Item(0);
|
8495 | if( item.mediaKind == 'img' ) {
|
8496 | item.rotationAngle += angle;
|
8497 | item.rotationAngle = item.rotationAngle % 360;
|
8498 | if( item.rotationAngle < 0 ) {
|
8499 | item.rotationAngle += 360;
|
8500 | }
|
8501 | ViewerMediaPanX( 0 );
|
8502 | ViewerMediaSetPosAndZoomOne( G.VOM.NGY2Item(0), G.VOM.$mediaCurrent, true );
|
8503 | }
|
8504 | }
|
8505 |
|
8506 |
|
8507 |
|
8508 | function ItemDisplayInfo( item ) {
|
8509 |
|
8510 | var content = '<div class="nGY2PopupOneItemText">' + item.title + '</div>';
|
8511 | content += '<div class="nGY2PopupOneItemText">' + item.description + '</div>';
|
8512 | if( item.author != '' ) {
|
8513 | content += '<div class="nGY2PopupOneItemText">' + G.O.icons.user + ' ' + item.author + '</div>';
|
8514 | }
|
8515 | if( item.exif.model != '' ) {
|
8516 | content += '<div class="nGY2PopupOneItemText">' + G.O.icons.config + ' ' + item.exif.model + '</div>';
|
8517 | }
|
8518 | var sexif = '';
|
8519 | sexif += item.exif.flash == '' ? '' : ' ' + item.exif.flash;
|
8520 | sexif += item.exif.focallength == '' ? '' : ' ' + item.exif.focallength+'mm';
|
8521 | sexif += item.exif.fstop == '' ? '' : ' f' + item.exif.fstop;
|
8522 | sexif += item.exif.exposure == '' ? '' : ' ' + item.exif.exposure+'s';
|
8523 | sexif += item.exif.iso == '' ? '' : ' ' + item.exif.iso+' ISO';
|
8524 | if( item.exif.time != '' ) {
|
8525 |
|
8526 |
|
8527 | sexif += ' ' + item.exif.time;
|
8528 | }
|
8529 | content += '<div class="nGY2PopupOneItemText">' + sexif + '</div>';
|
8530 |
|
8531 | if( item.exif.location != '' ) {
|
8532 | content += '<div class="nGY2PopupOneItemText">'+G.O.icons.location+' <a href="http://maps.google.com/maps?z=12&t=m&q='+encodeURIComponent(item.exif.location)+'" target="_blank">'+item.exif.location+'</a></div>';
|
8533 |
|
8534 | content += '<iframe width="300" height="150" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?&t=m&q='+encodeURIComponent( item.exif.location ) +'&output=embed"></iframe>';
|
8535 | }
|
8536 |
|
8537 | Popup(G.O.icons.viewerInfo, content, 'Left');
|
8538 |
|
8539 | }
|
8540 |
|
8541 |
|
8542 |
|
8543 | function ToolbarAddElt( elt ) {
|
8544 | var r = '<div class="ngbt ngy2viewerToolAction ',
|
8545 | e=elt.replace(/^\s+|\s+$/g, '');
|
8546 | switch( e ) {
|
8547 | case 'minimizeButton':
|
8548 | var ic = G.O.icons.viewerToolbarMin;
|
8549 | if( G.VOM.toolbarMode == 'min' ) {
|
8550 | ic = G.O.icons.viewerToolbarStd;
|
8551 | }
|
8552 | r += 'minimizeButton nGEvent" data-ngy2action="minimize">'+ic+'</div>';
|
8553 | break;
|
8554 | case 'previousButton':
|
8555 | r += 'previousButton nGEvent" data-ngy2action="previous">'+G.O.icons.viewerPrevious+'</div>';
|
8556 | break;
|
8557 | case 'pageCounter':
|
8558 | r += 'pageCounter nGEvent"></div>';
|
8559 | break;
|
8560 | case 'nextButton':
|
8561 | r += 'nextButton nGEvent" data-ngy2action="next">'+G.O.icons.viewerNext+'</div>';
|
8562 | break;
|
8563 | case 'playPauseButton':
|
8564 | r += 'playButton playPauseButton nGEvent" data-ngy2action="playPause">'+G.O.icons.viewerPlay+'</div>';
|
8565 | break;
|
8566 | case 'rotateLeft':
|
8567 | r += 'rotateLeftButton nGEvent" data-ngy2action="rotateLeft">'+G.O.icons.viewerRotateLeft+'</div>';
|
8568 | break;
|
8569 | case 'rotateRight':
|
8570 | r += 'rotateRightButton nGEvent" data-ngy2action="rotateRight">'+G.O.icons.viewerRotateRight+'</div>';
|
8571 | break;
|
8572 | case 'downloadButton':
|
8573 | r += 'downloadButton nGEvent" data-ngy2action="download">'+G.O.icons.viewerDownload+'</div>';
|
8574 | break;
|
8575 | case 'zoomButton':
|
8576 | r += 'nGEvent" data-ngy2action="zoomIn">'+G.O.icons.viewerZoomIn+'</div><div class="ngbt ngy2viewerToolAction nGEvent" data-ngy2action="zoomOut">'+G.O.icons.viewerZoomOut+'</div>';
|
8577 | break;
|
8578 | case 'fullscreenButton':
|
8579 | var s = G.O.icons.viewerFullscreenOn;
|
8580 | if( ngscreenfull.enabled && G.VOM.viewerIsFullscreen ) {
|
8581 | s = G.O.icons.viewerFullscreenOff;
|
8582 | }
|
8583 | r += 'setFullscreenButton fullscreenButton nGEvent" data-ngy2action="fullScreen">'+s+'</div>';
|
8584 | break;
|
8585 | case 'infoButton':
|
8586 | r += 'infoButton nGEvent" data-ngy2action="info">'+G.O.icons.viewerInfo+'</div>';
|
8587 | break;
|
8588 | case 'linkOriginalButton':
|
8589 | r += 'linkOriginalButton nGEvent" data-ngy2action="linkOriginal">' + G.O.icons.viewerLinkOriginal + '</div>';
|
8590 | break;
|
8591 | case 'closeButton':
|
8592 | r += 'closeButton nGEvent" data-ngy2action="close">'+G.O.icons.buttonClose+'</div>';
|
8593 | break;
|
8594 | case 'shareButton':
|
8595 | r += 'nGEvent" data-ngy2action="share">'+G.O.icons.viewerShare+'</div>';
|
8596 | break;
|
8597 | case 'label':
|
8598 | r += '"><div class="title nGEvent" itemprop="name"></div><div class="description nGEvent" itemprop="description"></div></div>';
|
8599 | break;
|
8600 | default:
|
8601 |
|
8602 | if( e.indexOf('custom') == 0 ) {
|
8603 | var t = '';
|
8604 |
|
8605 | var fu = G.O.fnImgToolbarCustInit;
|
8606 | if( fu !== null ) {
|
8607 | typeof fu == 'function' ? fu(e) : window[fu](e);
|
8608 | }
|
8609 | if( t == undefined || t == '' ) {
|
8610 |
|
8611 | var n = e.substring(6);
|
8612 | t = G.O.icons['viewerCustomTool'+n];
|
8613 | }
|
8614 | r += 'ngy2CustomBtn ' + e + ' nGEvent" data-ngy2action="' + e + '">' + t + '</div>';
|
8615 | }
|
8616 | else {
|
8617 | r = '';
|
8618 | }
|
8619 | break;
|
8620 | }
|
8621 | return r;
|
8622 | }
|
8623 |
|
8624 |
|
8625 |
|
8626 | function SlideshowToggle(){
|
8627 | if( G.VOM.playSlideshow ) {
|
8628 | window.clearTimeout(G.VOM.playSlideshowTimerID);
|
8629 | G.VOM.playSlideshow = false;
|
8630 | G.VOM.$viewer.find('.playPauseButton').html(G.O.icons.viewerPlay);
|
8631 | }
|
8632 | else {
|
8633 | G.VOM.playSlideshow = true;
|
8634 | DisplayNextMedia();
|
8635 | G.VOM.$viewer.find('.playPauseButton').html(G.O.icons.viewerPause);
|
8636 | }
|
8637 | }
|
8638 |
|
8639 | function ViewerToolbarForVisibilityStd() {
|
8640 | G.VOM.toolbarMode = 'std';
|
8641 |
|
8642 | var sTB = '';
|
8643 | var t = G.O.viewerToolbar.standard.split(',');
|
8644 | for( var i = 0, lt = t.length; i < lt; i++) {
|
8645 | sTB += ToolbarAddElt( t[i] );
|
8646 | }
|
8647 | G.VOM.$toolbar.find('.toolbar').html(sTB);
|
8648 | ViewerToolbarElementContent();
|
8649 | }
|
8650 |
|
8651 | function ViewerToolbarForVisibilityMin() {
|
8652 | if( G.O.viewerToolbar.minimized == undefined || G.O.viewerToolbar.minimized == '' ) {
|
8653 | ViewerToolbarForVisibilityStd();
|
8654 | }
|
8655 | else {
|
8656 | G.VOM.toolbarMode = 'min';
|
8657 | var sTB = '';
|
8658 | var t = G.O.viewerToolbar.minimized.split(',');
|
8659 | for( var i = 0, lt = t.length; i < lt; i++) {
|
8660 | sTB += ToolbarAddElt( t[i] );
|
8661 | }
|
8662 | G.VOM.$toolbar.find('.toolbar').html(sTB);
|
8663 | ViewerToolbarElementContent();
|
8664 | }
|
8665 | }
|
8666 |
|
8667 | function ViewerToolbarElementContent() {
|
8668 |
|
8669 | var vomIdx=G.VOM.currItemIdx;
|
8670 | if( vomIdx == null ) { return; }
|
8671 |
|
8672 | var item=G.VOM.NGY2Item(0);
|
8673 |
|
8674 |
|
8675 | var setTxt = false;
|
8676 |
|
8677 | if( item.title !== undefined && item.title != '' ) {
|
8678 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.title').html(item.title);
|
8679 | setTxt = true;
|
8680 | }
|
8681 | else {
|
8682 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.title').html('');
|
8683 | }
|
8684 |
|
8685 | if( item.description !== undefined && item.description != '' ) {
|
8686 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.description').html(item.description);
|
8687 | setTxt = true;
|
8688 | }
|
8689 | else {
|
8690 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.description').html('');
|
8691 | }
|
8692 |
|
8693 | if( setTxt ) {
|
8694 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.label').show();
|
8695 | }
|
8696 | else {
|
8697 | G.VOM.$viewer.find('.ngy2viewerToolAction').find('.label').hide();
|
8698 | }
|
8699 |
|
8700 |
|
8701 | var viewerMaxImages = G.VOM.items.length;
|
8702 | if( viewerMaxImages > 0 ) {
|
8703 | G.VOM.$viewer.find('.pageCounter').html((G.VOM.items[vomIdx].mediaNumber)+'/'+viewerMaxImages);
|
8704 | }
|
8705 |
|
8706 |
|
8707 | var $cu = G.VOM.$viewer.find('.ngy2CustomBtn');
|
8708 | var fu = G.O.fnImgToolbarCustDisplay;
|
8709 | if( $cu.length > 0 && fu !== null ) {
|
8710 | typeof fu == 'function' ? fu($cu, item) : window[fu]($cu, item);
|
8711 | }
|
8712 |
|
8713 |
|
8714 | ViewerToolsOn();
|
8715 | }
|
8716 |
|
8717 |
|
8718 | function ViewerMediaPanX( posX ) {
|
8719 | G.VOM.swipePosX = posX;
|
8720 | if( G.CSStransformName == null ) {
|
8721 |
|
8722 |
|
8723 | }
|
8724 | else {
|
8725 |
|
8726 |
|
8727 |
|
8728 | G.VOM.$mediaCurrent[0].style[G.CSStransformName] = 'translate(' + posX + 'px, 0px)';
|
8729 |
|
8730 |
|
8731 | var itemPrevious = G.VOM.NGY2Item(-1);
|
8732 | var itemNext = G.VOM.NGY2Item(1);
|
8733 |
|
8734 |
|
8735 | if( G.O.imageTransition.startsWith('SWIPE') ) {
|
8736 | if( itemPrevious.mediaTransition() ) {
|
8737 | ViewerSetMediaVisibility(G.VOM.NGY2Item(-1), G.VOM.$mediaPrevious, 1);
|
8738 | }
|
8739 | if( itemNext.mediaTransition() ) {
|
8740 | ViewerSetMediaVisibility(G.VOM.NGY2Item(1), G.VOM.$mediaNext, 1);
|
8741 | }
|
8742 |
|
8743 | var sc = Math.min( Math.max( Math.abs(posX) / G.VOM.window.lastWidth, .8), 1);
|
8744 | if( G.O.imageTransition == 'SWIPE' ) { sc = 1; }
|
8745 |
|
8746 | if( posX > 0 ) {
|
8747 | var dir = G.VOM.window.lastWidth;
|
8748 | if( itemPrevious.mediaTransition() ) {
|
8749 |
|
8750 | G.VOM.$mediaPrevious[0].style[G.CSStransformName] = 'translate(' + (-dir + posX) + 'px, 0px) scale(' + sc + ')';
|
8751 |
|
8752 | }
|
8753 | if( itemNext.mediaTransition() ) {
|
8754 |
|
8755 | G.VOM.$mediaNext[0].style[G.CSStransformName] = 'translate(' + (dir) + 'px, 0px) scale(' + sc + ')';
|
8756 |
|
8757 | }
|
8758 | }
|
8759 | else {
|
8760 | var dir = -G.VOM.window.lastWidth;
|
8761 | if( itemNext.mediaTransition() ) {
|
8762 |
|
8763 | G.VOM.$mediaNext[0].style[G.CSStransformName] = 'translate(' + (-dir + posX) + 'px, 0px) scale(' + sc + ')';
|
8764 |
|
8765 | }
|
8766 | if( itemPrevious.mediaTransition() ) {
|
8767 |
|
8768 | G.VOM.$mediaPrevious[0].style[G.CSStransformName] = 'translate(' + (dir) + 'px, 0px) scale(' + sc + ')';
|
8769 |
|
8770 | }
|
8771 | }
|
8772 | }
|
8773 |
|
8774 |
|
8775 | if( G.O.imageTransition == 'SLIDEAPPEAR' ) {
|
8776 | G.VOM.$mediaPrevious[0].style[G.CSStransformName] = '';
|
8777 | G.VOM.$mediaNext[0].style[G.CSStransformName] = '';
|
8778 | if( posX < 0 ) {
|
8779 | var o = (-posX) / G.VOM.window.lastWidth;
|
8780 | if( itemNext.mediaTransition() ) {
|
8781 | ViewerSetMediaVisibility(itemNext, G.VOM.$mediaNext, o);
|
8782 | }
|
8783 | if( itemPrevious.mediaTransition() ) {
|
8784 | ViewerSetMediaVisibility(itemPrevious, G.VOM.$mediaPrevious, 0);
|
8785 | }
|
8786 | }
|
8787 | else {
|
8788 | var o = posX / G.VOM.window.lastWidth;
|
8789 | if( itemPrevious.mediaTransition() ) {
|
8790 | ViewerSetMediaVisibility(itemPrevious, G.VOM.$mediaPrevious, o);
|
8791 | }
|
8792 | if( itemNext.mediaTransition() ) {
|
8793 | ViewerSetMediaVisibility(itemNext, G.VOM.$mediaNext, 0);
|
8794 | }
|
8795 | }
|
8796 | }
|
8797 | }
|
8798 | }
|
8799 |
|
8800 |
|
8801 | function DisplayNextMedia() {
|
8802 | if( G.VOM.viewerMediaIsChanged || ((new Date().getTime()) - G.VOM.timeImgChanged < 300) ) { return; }
|
8803 |
|
8804 | TriggerCustomEvent('lightboxNextImage');
|
8805 | DisplayInternalViewer(G.VOM.IdxNext(), 'nextImage');
|
8806 | };
|
8807 |
|
8808 |
|
8809 | function DisplayPreviousMedia() {
|
8810 | if( G.VOM.viewerMediaIsChanged || ((new Date().getTime()) - G.VOM.timeImgChanged < 300) ) { return; }
|
8811 | if( G.VOM.playSlideshow ) {
|
8812 | SlideshowToggle();
|
8813 | }
|
8814 |
|
8815 | TriggerCustomEvent('lightboxPreviousImage');
|
8816 | DisplayInternalViewer(G.VOM.IdxPrevious(), 'previousImage');
|
8817 | };
|
8818 |
|
8819 |
|
8820 | function DisplayInternalViewer( newVomIdx, displayType ) {
|
8821 |
|
8822 | if( G.VOM.playSlideshow ) { window.clearTimeout(G.VOM.playSlideshowTimerID); }
|
8823 |
|
8824 | var itemOld = G.VOM.NGY2Item(0);
|
8825 | var itemNew = G.I[G.VOM.items[newVomIdx].ngy2ItemIdx];
|
8826 | var $new = (displayType == 'nextImage' ? G.VOM.$mediaNext : G.VOM.$mediaPrevious);
|
8827 | if( displayType == 'nextImage' ) {
|
8828 | ViewerSetMediaVisibility(G.VOM.NGY2Item(-1), G.VOM.$mediaPrevious, 0);
|
8829 | }
|
8830 | else {
|
8831 | ViewerSetMediaVisibility(G.VOM.NGY2Item(1), G.VOM.$mediaNext, 0);
|
8832 | }
|
8833 |
|
8834 | G.VOM.timeImgChanged = new Date().getTime();
|
8835 | G.VOM.viewerMediaIsChanged = true;
|
8836 | G.VOM.zoom.isZooming = false;
|
8837 | ResizeInternalViewer(true);
|
8838 |
|
8839 | if( G.O.debugMode && console.timeline ) { console.timeline('nanogallery2_viewer'); }
|
8840 |
|
8841 | SetLocationHash( itemNew.albumID, itemNew.GetID() );
|
8842 |
|
8843 |
|
8844 | var vP = G.GOM.cache.viewport;
|
8845 | var dur = 400 * (vP.w - Math.abs(G.VOM.swipePosX)) / vP.w;
|
8846 |
|
8847 | if( displayType == '' ) {
|
8848 |
|
8849 | ViewerSetMediaVisibility(G.VOM.NGY2Item(0), G.VOM.$mediaCurrent, 1);
|
8850 | if( G.CSStransformName == null ) {
|
8851 |
|
8852 | ViewerSetMediaVisibility(itemNew, $new, 1);
|
8853 | DisplayInternalViewerComplete(displayType, newVomIdx);
|
8854 | }
|
8855 | else {
|
8856 | ViewerSetMediaVisibility(itemNew, $new, 0);
|
8857 | new NGTweenable().tween({
|
8858 | from: { opacity: 0 },
|
8859 | to: { opacity: 1 },
|
8860 | attachment: { dT: displayType, item: itemOld },
|
8861 | easing: 'easeInOutSine',
|
8862 | delay: 30,
|
8863 | duration: 400,
|
8864 | step: function (state, att) {
|
8865 |
|
8866 | G.VOM.$content.css('opacity', state.opacity);
|
8867 | },
|
8868 | finish: function (state, att) {
|
8869 | ViewerToolsUnHide();
|
8870 | DisplayInternalViewerComplete(att.dT, newVomIdx);
|
8871 | }
|
8872 | });
|
8873 | }
|
8874 | }
|
8875 | else {
|
8876 |
|
8877 | if( G.CSStransformName == null ) {
|
8878 |
|
8879 | ViewerSetMediaVisibility(itemNew, $new, 1);
|
8880 | ViewerSetMediaVisibility(G.VOM.NGY2Item(0), G.VOM.$mediaCurrent, 1);
|
8881 | DisplayInternalViewerComplete(displayType, newVomIdx);
|
8882 | }
|
8883 | else {
|
8884 | switch( G.O.imageTransition ) {
|
8885 | case 'SWIPE':
|
8886 | case 'SWIPE2':
|
8887 | var dir = ( displayType == 'nextImage' ? - vP.w : vP.w );
|
8888 | $new[0].style[G.CSStransformName] = 'translate('+(-dir)+'px, 0px) '
|
8889 |
|
8890 | new NGTweenable().tween({
|
8891 | from: { t: G.VOM.swipePosX },
|
8892 | to: { t: (displayType == 'nextImage' ? - vP.w : vP.w) },
|
8893 | attachment: { dT: displayType, $e: $new, itemNew: itemNew, itemOld: itemOld, dir: dir },
|
8894 | delay: 30,
|
8895 | duration: dur,
|
8896 | easing: (G.O.imageTransition == 'swipe' ? 'easeInOutSine' : 'easeInOutCubic'),
|
8897 | step: function (state, att) {
|
8898 |
|
8899 | ViewerSetMediaVisibility(G.VOM.NGY2Item(0), G.VOM.$mediaCurrent, 1);
|
8900 |
|
8901 | G.VOM.$mediaCurrent[0].style[G.CSStransformName] = 'translate(' + state.t + 'px, 0px)';
|
8902 |
|
8903 | if( att.itemNew.mediaTransition() ) {
|
8904 | ViewerSetMediaVisibility(att.itemNew, att.$e, 1);
|
8905 |
|
8906 | var sc = Math.min( Math.max( (Math.abs(state.t)) / G.VOM.window.lastWidth, .8), 1);
|
8907 | if( G.O.imageTransition == 'SWIPE' ) { sc = 1; }
|
8908 |
|
8909 | att.$e[0].style[G.CSStransformName] = 'translate(' + (-att.dir+state.t) + 'px, 0px) scale(' + sc + ')';
|
8910 | }
|
8911 | },
|
8912 | finish: function (state, att) {
|
8913 | G.VOM.$mediaCurrent[0].style[G.CSStransformName] = '';
|
8914 | att.$e[0].style[G.CSStransformName] = '';
|
8915 | DisplayInternalViewerComplete(att.dT, newVomIdx);
|
8916 | }
|
8917 | });
|
8918 | break;
|
8919 |
|
8920 | case 'SLIDEAPPEAR':
|
8921 | default:
|
8922 | var dir=(displayType == 'nextImage' ? - vP.w : vP.w);
|
8923 | var op = (Math.abs(G.VOM.swipePosX)) / G.VOM.window.lastWidth;
|
8924 | $new[0].style[G.CSStransformName] = '';
|
8925 | new NGTweenable().tween({
|
8926 | from: { o: op, t: G.VOM.swipePosX },
|
8927 | to: { o: 1, t: (displayType == 'nextImage' ? - vP.w : vP.w) },
|
8928 | attachment: { dT:displayType, $e:$new, itemNew: itemNew, itemOld: itemOld, dir: dir },
|
8929 | delay: 30,
|
8930 | duration: dur,
|
8931 | easing: 'easeInOutSine',
|
8932 | step: function (state, att) {
|
8933 |
|
8934 |
|
8935 | G.VOM.$mediaCurrent[0].style[G.CSStransformName]= 'translate('+state.t+'px, 0px)';
|
8936 |
|
8937 | if( att.itemNew.mediaTransition() ) {
|
8938 | ViewerSetMediaVisibility(att.itemNew, att.$e, state.o);
|
8939 | }
|
8940 | },
|
8941 | finish: function (state, att) {
|
8942 | G.VOM.$mediaCurrent[0].style[G.CSStransformName]= '';
|
8943 | DisplayInternalViewerComplete(att.dT, newVomIdx);
|
8944 | }
|
8945 | });
|
8946 | break;
|
8947 | }
|
8948 | }
|
8949 | }
|
8950 | }
|
8951 |
|
8952 |
|
8953 | function DisplayInternalViewerComplete( displayType, newVomIdx ) {
|
8954 | G.VOM.currItemIdx = newVomIdx;
|
8955 |
|
8956 | var ngy2item = G.VOM.NGY2Item(0);
|
8957 |
|
8958 | ViewerToolbarElementContent();
|
8959 | if( G.O.debugMode && console.timeline ) { console.timelineEnd('nanogallery2_viewer'); }
|
8960 |
|
8961 | var fu=G.O.fnImgDisplayed;
|
8962 | if( fu !== null ) {
|
8963 | typeof fu == 'function' ? fu(ngy2item) : window[fu](ngy2item);
|
8964 | }
|
8965 |
|
8966 | G.VOM.swipePosX = 0;
|
8967 | if( displayType != '' ) {
|
8968 |
|
8969 |
|
8970 | G.VOM.$mediaCurrent.removeClass('imgCurrent');
|
8971 |
|
8972 | var $tmp = G.VOM.$mediaCurrent;
|
8973 | switch( displayType ) {
|
8974 | case 'nextImage':
|
8975 | G.VOM.$mediaCurrent = G.VOM.$mediaNext;
|
8976 | G.VOM.$mediaNext = $tmp;
|
8977 | break;
|
8978 | case 'previousImage':
|
8979 | G.VOM.$mediaCurrent = G.VOM.$mediaPrevious;
|
8980 | G.VOM.$mediaPrevious = $tmp;
|
8981 | break;
|
8982 | }
|
8983 | }
|
8984 |
|
8985 | G.VOM.$mediaCurrent.addClass('imgCurrent');
|
8986 |
|
8987 |
|
8988 | var $pans = G.VOM.$content.find('.nGY2ViewerMediaPan');
|
8989 | G.VOM.$mediaCurrent.insertAfter($pans.last());
|
8990 |
|
8991 | if( ngy2item.mediaKind == 'img' && ngy2item.imageWidth == 0 ) {
|
8992 | ViewerSetMediaVisibility(G.VOM.NGY2Item(0), G.VOM.$mediaCurrent, 0);
|
8993 | }
|
8994 | else {
|
8995 | G.VOM.$mediaCurrent.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
8996 | ViewerSetMediaVisibility(G.VOM.NGY2Item(0), G.VOM.$mediaCurrent, 1);
|
8997 | }
|
8998 |
|
8999 |
|
9000 |
|
9001 | G.VOM.$mediaNext.empty();
|
9002 | var nextItem = G.VOM.NGY2Item(1);
|
9003 | var 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.$mediaNext.append( spreloader + nextItem.mediaMarkup );
|
9008 | ViewerSetMediaVisibility(nextItem, G.VOM.$mediaNext, 0);
|
9009 | if( nextItem.mediaKind == 'img' ) {
|
9010 | G.VOM.ImageLoader.loadImage(VieweImgSizeRetrieved, nextItem);
|
9011 | }
|
9012 | else {
|
9013 | ViewerMediaCenterNotImg( G.VOM.$mediaNext );
|
9014 | }
|
9015 |
|
9016 |
|
9017 | G.VOM.$mediaPrevious.empty();
|
9018 | var previousItem = G.VOM.NGY2Item(-1);
|
9019 | spreloader = '<div class="nGY2ViewerMediaLoaderDisplayed"></div>';
|
9020 | if( previousItem.mediaKind == 'img' && previousItem.imageWidth != 0 && previousItem.imageHeight != 0 ) {
|
9021 | spreloader = '<div class="nGY2ViewerMediaLoaderHidden"></div>';
|
9022 | }
|
9023 | G.VOM.$mediaPrevious.append( spreloader + previousItem.mediaMarkup );
|
9024 | ViewerSetMediaVisibility(previousItem, G.VOM.$mediaPrevious, 0);
|
9025 | if( previousItem.mediaKind == 'img' ) {
|
9026 | G.VOM.ImageLoader.loadImage( VieweImgSizeRetrieved, previousItem );
|
9027 | }
|
9028 | else {
|
9029 | ViewerMediaCenterNotImg( G.VOM.$mediaPrevious );
|
9030 | }
|
9031 |
|
9032 |
|
9033 |
|
9034 | if( G.VOM.playSlideshow ) {
|
9035 | G.VOM.$mediaCurrent.children().eq(1).ngimagesLoaded().always( function( instance ) {
|
9036 | if( G.VOM.playSlideshow ) {
|
9037 |
|
9038 | G.VOM.playSlideshowTimerID = window.setTimeout( function(){ DisplayNextMedia(); }, G.VOM.slideshowDelay );
|
9039 | }
|
9040 | });
|
9041 | }
|
9042 |
|
9043 |
|
9044 |
|
9045 |
|
9046 |
|
9047 |
|
9048 |
|
9049 |
|
9050 |
|
9051 |
|
9052 | ResizeInternalViewer();
|
9053 |
|
9054 | G.VOM.viewerMediaIsChanged = false;
|
9055 | TriggerCustomEvent('lightboxImageDisplayed');
|
9056 |
|
9057 | }
|
9058 |
|
9059 |
|
9060 |
|
9061 | function VieweImgSizeRetrieved(w, h, item, n) {
|
9062 | item.imageWidth = w;
|
9063 | item.imageHeight = h;
|
9064 |
|
9065 |
|
9066 |
|
9067 | if( G.VOM.NGY2Item(0) == item ) {
|
9068 |
|
9069 | G.VOM.$mediaCurrent.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9070 | ViewerSetMediaVisibility(G.VOM.NGY2Item(0), G.VOM.$mediaCurrent, 1);
|
9071 | G.VOM.zoom.userFactor = 1;
|
9072 | }
|
9073 |
|
9074 | if( G.VOM.NGY2Item(1) == item ) {
|
9075 | G.VOM.$mediaNext.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9076 | }
|
9077 | if( G.VOM.NGY2Item(-1) == item ) {
|
9078 | G.VOM.$mediaPrevious.children().eq(0).attr('class', 'nGY2ViewerMediaLoaderHidden');
|
9079 | }
|
9080 |
|
9081 | ViewerMediaSetPosAndZoom();
|
9082 |
|
9083 | }
|
9084 |
|
9085 |
|
9086 | function ViewerSetMediaVisibility(item, $media, opacity ) {
|
9087 |
|
9088 | if( item.mediaKind == 'img' && item.imageWidth == 0 ) {
|
9089 |
|
9090 |
|
9091 |
|
9092 | $media.children().eq(1).css({ opacity: 0, visibility: 'hidden' });
|
9093 |
|
9094 | return;
|
9095 | }
|
9096 |
|
9097 | if( opacity == 0 ) {
|
9098 |
|
9099 |
|
9100 | $media.children().css({ opacity: 0, visibility: 'hidden' });
|
9101 | }
|
9102 | else {
|
9103 |
|
9104 | $media.children().css({ opacity: opacity, visibility: 'visible' });
|
9105 | }
|
9106 | }
|
9107 |
|
9108 |
|
9109 |
|
9110 | function CloseInternalViewer( vomIdx ) {
|
9111 |
|
9112 | G.VOM.viewerMediaIsChanged = false;
|
9113 |
|
9114 | if( G.VOM.viewerDisplayed ) {
|
9115 |
|
9116 |
|
9117 | jQuery('body').css({ overflowX: G.VOM.saveOverflowX, overflowY: G.VOM.saveOverflowY});
|
9118 |
|
9119 |
|
9120 |
|
9121 | if( G.VOM.playSlideshow ) {
|
9122 | window.clearTimeout(G.VOM.playSlideshowTimerID);
|
9123 | G.VOM.playSlideshow = false;
|
9124 | }
|
9125 |
|
9126 |
|
9127 |
|
9128 | G.VOM.hammertime.destroy();
|
9129 | G.VOM.hammertime = null;
|
9130 |
|
9131 | if( ngscreenfull.enabled && G.VOM.viewerIsFullscreen ) {
|
9132 | G.VOM.viewerIsFullscreen = false;
|
9133 | ngscreenfull.exit();
|
9134 | }
|
9135 |
|
9136 | G.VOM.$cont.hide(0).off().show(0).html('').remove();
|
9137 | G.VOM.viewerDisplayed = false;
|
9138 |
|
9139 | if( G.O.thumbnailAlbumDisplayImage ) {
|
9140 |
|
9141 | if( vomIdx == null ) {
|
9142 |
|
9143 |
|
9144 | }
|
9145 | else {
|
9146 | var item = G.I[G.VOM.items[vomIdx].ngy2ItemIdx];
|
9147 | var parent = NGY2Item.Get(G, item.albumID);
|
9148 | if( G.GOM.albumIdx != parent.albumID ) {
|
9149 |
|
9150 | DisplayAlbum('-1', parent.albumID);
|
9151 | }
|
9152 | else {
|
9153 | GalleryResize();
|
9154 | SetLocationHash( '', '' );
|
9155 | ThumbnailHoverReInitAll();
|
9156 | }
|
9157 | }
|
9158 |
|
9159 | }
|
9160 | else {
|
9161 | if( vomIdx != null ) {
|
9162 | if( G.GOM.albumIdx == -1 ) {
|
9163 |
|
9164 | DisplayAlbum( '', G.I[G.VOM.items[vomIdx].ngy2ItemIdx].albumID );
|
9165 | }
|
9166 | else {
|
9167 | GalleryResize();
|
9168 | SetLocationHash( G.I[G.VOM.items[vomIdx].ngy2ItemIdx].albumID, '' );
|
9169 | ThumbnailHoverReInitAll();
|
9170 | }
|
9171 | }
|
9172 | }
|
9173 | G.VOM.timeImgChanged = new Date().getTime();
|
9174 | }
|
9175 | }
|
9176 |
|
9177 |
|
9178 |
|
9179 | function ResizeInternalViewer( forceUpdate ) {
|
9180 | forceUpdate = typeof forceUpdate !== 'undefined' ? forceUpdate : false;
|
9181 |
|
9182 | if( G.VOM.$toolbar === null ) { return; }
|
9183 |
|
9184 |
|
9185 |
|
9186 | var windowsW = G.VOM.$viewer.width();
|
9187 | var windowsH = G.VOM.$viewer.height();
|
9188 | var $elt = G.VOM.$mediaCurrent.children().eq(1);
|
9189 | if( $elt == null || G.VOM.currItemIdx == -1 ) { return; }
|
9190 |
|
9191 | if( !forceUpdate && G.VOM.window.lastWidth == windowsW && G.VOM.window.lastHeight == windowsH ) { return; }
|
9192 |
|
9193 | G.VOM.window.lastWidth = windowsW;
|
9194 | G.VOM.window.lastHeight = windowsH;
|
9195 |
|
9196 |
|
9197 |
|
9198 |
|
9199 |
|
9200 |
|
9201 | var $tb = G.VOM.$toolbar.find('.toolbar');
|
9202 | var tb_OHt = $tb.outerHeight(true);
|
9203 |
|
9204 | switch( G.O.viewerToolbar.position ) {
|
9205 | case 'topOverImage':
|
9206 | G.VOM.$content.css({height: windowsH, width: windowsW, top: 0 });
|
9207 | G.VOM.$toolbar.css({top: 0, bottom: ''});
|
9208 | break;
|
9209 | case 'top':
|
9210 | windowsH -= tb_OHt;
|
9211 | G.VOM.$content.css({height: windowsH, width: windowsW, top: tb_OHt });
|
9212 | G.VOM.$toolbar.css({top: 0});
|
9213 | break;
|
9214 | case 'bottomOverImage':
|
9215 | G.VOM.$content.css({height:windowsH, width: windowsW, bottom: 0, top: 0 });
|
9216 | G.VOM.$toolbar.css({bottom: 0});
|
9217 | break;
|
9218 | case 'bottom':
|
9219 | default:
|
9220 | windowsH -= tb_OHt;
|
9221 | G.VOM.$content.css({ width: windowsW, top: 0, bottom: tb_OHt });
|
9222 | G.VOM.$toolbar.css({bottom: 0});
|
9223 | break;
|
9224 | }
|
9225 |
|
9226 | if( !G.VOM.viewerMediaIsChanged && G.VOM.zoom.isZooming ) {
|
9227 | ViewerMediaSetPosAndZoom();
|
9228 | }
|
9229 | else {
|
9230 | 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 )) {
|
9231 |
|
9232 | G.VOM.zoom.isZooming= true;
|
9233 | new NGTweenable().tween({
|
9234 | from: { userFactor: G.VOM.zoom.userFactor, panPosX: G.VOM.panPosX, panPosY: G.VOM.panPosY, zoomPosX: G.VOM.zoom.posX, zoomPosY: G.VOM.zoom.posY },
|
9235 | to: { userFactor: 1, panPosX: 0, panPosY: 0, zoomPosX: 0, zoomPosY: 0 },
|
9236 | easing: 'easeInOutSine',
|
9237 | delay: 0,
|
9238 | duration: 150,
|
9239 | step: function (state) {
|
9240 | G.VOM.zoom.userFactor=state.userFactor;
|
9241 | G.VOM.panPosX=state.panPosX;
|
9242 | G.VOM.panPosY=state.panPosY;
|
9243 | G.VOM.zoom.posX=state.zoomPosX;
|
9244 | G.VOM.zoom.posY=state.zoomPosY;
|
9245 | ViewerMediaSetPosAndZoom();
|
9246 | },
|
9247 | finish: function (state) {
|
9248 | G.VOM.zoom.isZooming=false;
|
9249 | }
|
9250 | });
|
9251 |
|
9252 | }
|
9253 | else {
|
9254 | G.VOM.zoom.userFactor = 1;
|
9255 | G.VOM.zoom.isZooming = false;
|
9256 | G.VOM.panPosX = 0;
|
9257 | G.VOM.panPosY = 0;
|
9258 | G.VOM.zoom.posX = 0;
|
9259 | G.VOM.zoom.posY = 0;
|
9260 | ViewerMediaSetPosAndZoom();
|
9261 | }
|
9262 | }
|
9263 | }
|
9264 |
|
9265 |
|
9266 |
|
9267 |
|
9268 |
|
9269 | function BuildSkeleton() {
|
9270 |
|
9271 |
|
9272 | var $elements = G.$E.base.children('a');
|
9273 | if( $elements.length > 0 ) {
|
9274 | G.O.$markup = $elements;
|
9275 | }
|
9276 | G.$E.base.text('');
|
9277 | G.$E.base.addClass('ngy2_container');
|
9278 |
|
9279 |
|
9280 | var sRTL='';
|
9281 | if( G.O.RTL ) {
|
9282 | sRTL = 'style="text-align:right;direction:rtl;"';
|
9283 | }
|
9284 |
|
9285 |
|
9286 | G.$E.base.addClass(G.O.theme)
|
9287 |
|
9288 | SetGalleryTheme();
|
9289 |
|
9290 |
|
9291 | if( G.O.thumbnailLabel.get('hideIcons') ) {
|
9292 | G.O.icons.thumbnailAlbum = '';
|
9293 | G.O.icons.thumbnailImage = '';
|
9294 | }
|
9295 |
|
9296 |
|
9297 | var styleNavigation="";
|
9298 | if( G.O.navigationFontSize != undefined && G.O.navigationFontSize != '' ) {
|
9299 | styleNavigation=' style="font-size:'+G.O.navigationFontSize+';"';
|
9300 | }
|
9301 | G.$E.conNavigationBar = jQuery('<div class="nGY2Navigationbar" '+styleNavigation+'></div>').appendTo(G.$E.base);
|
9302 |
|
9303 |
|
9304 | G.$E.conLoadingB = jQuery('<div class="nanoGalleryLBarOff"><div></div><div></div><div></div><div></div><div></div></div>').appendTo(G.$E.base);
|
9305 |
|
9306 |
|
9307 | G.$E.conTnParent = jQuery('<div class="nGY2Gallery"></div>').appendTo( G.$E.base );
|
9308 | G.$E.conTn = jQuery('<div class="nGY2GallerySub"></div>').appendTo( G.$E.conTnParent );
|
9309 |
|
9310 |
|
9311 | switch( G.O.thumbnailAlignment ) {
|
9312 | case 'left':
|
9313 | G.$E.conTnParent.css({'text-align':'left'});
|
9314 |
|
9315 | break;
|
9316 | case 'right':
|
9317 | G.$E.conTnParent.css({'text-align':'right'});
|
9318 |
|
9319 | break;
|
9320 | }
|
9321 |
|
9322 |
|
9323 | if( G.O.galleryBuildInit2 !== undefined ) {
|
9324 | var t1=G.O.galleryBuildInit2.split('|');
|
9325 | for( var i=0; i<t1.length; i++ ) {
|
9326 | var o1=t1[i].split('_');
|
9327 | if( o1.length == 2 ) {
|
9328 | G.$E.conTn.css(o1[0], o1[1]);
|
9329 | }
|
9330 | }
|
9331 | }
|
9332 |
|
9333 |
|
9334 | var effects=G.tn.hoverEffects.std.concat(G.tn.hoverEffects.level1);
|
9335 | for( var j=0; j<effects.length; j++) {
|
9336 | switch( effects[j].type ) {
|
9337 | case 'scale':
|
9338 | case 'rotateZ':
|
9339 | case 'rotateX':
|
9340 | case 'rotateY':
|
9341 | case 'translateX':
|
9342 | case 'translateY':
|
9343 |
|
9344 | if( effects[j].element == '.nGY2GThumbnail' ) {
|
9345 |
|
9346 | G.$E.base.css('overflow', 'visible');
|
9347 | G.$E.base.find('.nGY2GallerySub').css('overflow', 'visible');
|
9348 | G.$E.conTnParent.css('overflow', 'visible');
|
9349 | }
|
9350 | break;
|
9351 | }
|
9352 | }
|
9353 |
|
9354 |
|
9355 | G.$E.conTnBottom = jQuery('<div class="nGY2GalleryBottom" '+styleNavigation+'></div>').appendTo( G.$E.conTnParent );
|
9356 |
|
9357 |
|
9358 | if( G.O.portable ) {
|
9359 |
|
9360 |
|
9361 |
|
9362 | 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';
|
9363 | 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;";
|
9364 | 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);
|
9365 |
|
9366 | G.$E.ngy2i.find('a').on({
|
9367 | mouseenter: function () {
|
9368 | jQuery(this).attr('style', st);
|
9369 | },
|
9370 | mouseleave: function () {
|
9371 | jQuery(this).attr('style', st);
|
9372 | }
|
9373 | });
|
9374 | }
|
9375 |
|
9376 |
|
9377 | G.$E.conConsole = jQuery('<div class="nGY2ConsoleParent"></div>').appendTo(G.$E.base);
|
9378 |
|
9379 |
|
9380 | i18n();
|
9381 |
|
9382 |
|
9383 | ThumbnailDefCaches();
|
9384 |
|
9385 |
|
9386 |
|
9387 | switch( G.tn.opt.Get('displayTransition') ) {
|
9388 | case 'SCALEDOWN':
|
9389 | case 'RANDOMSCALE':
|
9390 | default:
|
9391 | G.$E.base.css('overflow', 'visible');
|
9392 | G.$E.conTnParent.css('overflow', 'visible');
|
9393 | G.$E.conTn.css('overflow', 'visible');
|
9394 | break;
|
9395 | }
|
9396 |
|
9397 | }
|
9398 |
|
9399 | function TriggerCustomEvent ( eventName ) {
|
9400 |
|
9401 | var eN = eventName + '.nanogallery2';
|
9402 | var event=null;
|
9403 | try {
|
9404 | event = new Event( eN );
|
9405 | } catch(e) {
|
9406 | event = document.createEvent('Event');
|
9407 | event.initEvent(eN, false, false);
|
9408 | }
|
9409 | G.$E.base.trigger(eN, event);
|
9410 | }
|
9411 |
|
9412 |
|
9413 |
|
9414 | function SetGlobalEvents() {
|
9415 |
|
9416 |
|
9417 | G.$E.conTnParent.on({
|
9418 | mouseenter: GalleryMouseEnter,
|
9419 | mouseleave: GalleryMouseLeave
|
9420 | }, ".nGY2GThumbnail");
|
9421 |
|
9422 |
|
9423 | G.GOM.hammertime = new NGHammer( G.$E.conTn[0] );
|
9424 |
|
9425 |
|
9426 | G.GOM.hammertime.on('pan', function(ev) {
|
9427 | if( !G.VOM.viewerDisplayed ) {
|
9428 | if( G.O.paginationSwipe && G.layout.support.rows && G.galleryDisplayMode.Get() == 'PAGINATION' ) {
|
9429 | if( Math.abs(ev.deltaY) > G.GOM.panThreshold ) {
|
9430 | G.GOM.panYOnly = true;
|
9431 | }
|
9432 | if( !G.GOM.panYOnly ) {
|
9433 | G.$E.conTn.css( G.CSStransformName , 'translate('+(ev.deltaX)+'px,0px)');
|
9434 | }
|
9435 | }
|
9436 | }
|
9437 | });
|
9438 | G.GOM.hammertime.on('panend', function(ev) {
|
9439 | if( !G.VOM.viewerDisplayed ) {
|
9440 | if( G.O.paginationSwipe && G.layout.support.rows && G.galleryDisplayMode.Get() == 'PAGINATION' ) {
|
9441 | if( !G.GOM.panYOnly ) {
|
9442 | if( ev.deltaX > 50 ) {
|
9443 | paginationPreviousPage();
|
9444 | return;
|
9445 | }
|
9446 | if( ev.deltaX < -50 ) {
|
9447 | paginationNextPage();
|
9448 | return;
|
9449 | }
|
9450 | }
|
9451 | G.GOM.panYOnly = false;
|
9452 | G.$E.conTn.css( G.CSStransformName , 'translate(0px,0px)');
|
9453 |
|
9454 | }
|
9455 | }
|
9456 | });
|
9457 | G.GOM.hammertime.on('tap', function(ev) {
|
9458 | if( !G.VOM.viewerDisplayed ) {
|
9459 | ev.srcEvent.stopPropagation();
|
9460 | ev.srcEvent.preventDefault();
|
9461 |
|
9462 | if( ev.pointerType == 'mouse') {
|
9463 | if( GalleryClicked(ev.srcEvent) == 'exit' ) { return; }
|
9464 | }
|
9465 | else {
|
9466 | var r = GalleryEventRetrieveElementl(ev.srcEvent, false);
|
9467 | if( r.GOMidx == -1 ) { return; }
|
9468 | if( r.action != 'NONE' && r.action != 'OPEN' ) {
|
9469 |
|
9470 | GalleryClicked(ev.srcEvent);
|
9471 | return;
|
9472 | }
|
9473 |
|
9474 | if( G.GOM.slider.hostIdx == r.GOMidx ) {
|
9475 |
|
9476 | ThumbnailHoverOutAll();
|
9477 | ThumbnailOpen(G.GOM.items[G.GOM.slider.currentIdx].thumbnailIdx, true);
|
9478 | return;
|
9479 | }
|
9480 |
|
9481 | if( (G.GOM.curNavLevel == 'l1' && G.O.touchAnimationL1 == false) || (G.GOM.curNavLevel == 'lN' && G.O.touchAnimation == false) ) {
|
9482 |
|
9483 | ThumbnailOpen(G.GOM.items[r.GOMidx].thumbnailIdx, true);
|
9484 | return;
|
9485 | }
|
9486 |
|
9487 | if( G.O.touchAutoOpenDelay > 0 ) {
|
9488 |
|
9489 | ThumbnailHoverOutAll();
|
9490 | ThumbnailHover( r.GOMidx );
|
9491 | window.clearInterval( G.touchAutoOpenDelayTimerID );
|
9492 | G.touchAutoOpenDelayTimerID = window.setInterval(function(){
|
9493 | window.clearInterval( G.touchAutoOpenDelayTimerID );
|
9494 | ThumbnailOpen( G.GOM.items[r.GOMidx].thumbnailIdx, true );
|
9495 | }, G.O.touchAutoOpenDelay );
|
9496 | }
|
9497 | else {
|
9498 |
|
9499 | if( !G.I[G.GOM.items[r.GOMidx].thumbnailIdx].hovered ) {
|
9500 | ThumbnailHoverOutAll();
|
9501 | ThumbnailHover(r.GOMidx);
|
9502 | }
|
9503 | else {
|
9504 |
|
9505 | ThumbnailOpen(G.GOM.items[r.GOMidx].thumbnailIdx, true);
|
9506 | }
|
9507 | }
|
9508 | }
|
9509 | }
|
9510 | });
|
9511 |
|
9512 |
|
9513 |
|
9514 | if( G.O.locationHash ) {
|
9515 |
|
9516 |
|
9517 |
|
9518 | jQuery(window).on('hashchange.nanogallery2.' + G.baseEltID, function() {ProcessLocationHash();} );
|
9519 | }
|
9520 |
|
9521 |
|
9522 | jQuery(window).on('resize.nanogallery2.' + G.baseEltID + ' orientationChange.nanogallery2.' + G.baseEltID, debounce( ResizeWindowEvent, G.O.eventsDebounceDelay, false) );
|
9523 |
|
9524 |
|
9525 | jQuery(window).on('scroll.nanogallery2.' + G.baseEltID, debounce( OnScrollEvent, G.O.eventsDebounceDelay, false) );
|
9526 |
|
9527 |
|
9528 | G.VOM.toolsHide = debounce( ViewerToolsHide, G.O.viewerHideToolsDelay, false );
|
9529 |
|
9530 |
|
9531 | jQuery(document).keyup(function(e) {
|
9532 | if( G.popup.isDisplayed ) {
|
9533 | switch( e.keyCode) {
|
9534 | case 27:
|
9535 | G.popup.close();
|
9536 | break;
|
9537 | }
|
9538 | }
|
9539 | else {
|
9540 | if( G.VOM.viewerDisplayed ) {
|
9541 | ViewerToolsUnHide();
|
9542 | switch( e.keyCode) {
|
9543 | case 27:
|
9544 | case 40:
|
9545 | CloseInternalViewer(G.VOM.currItemIdx);
|
9546 | break;
|
9547 | case 32:
|
9548 | case 13:
|
9549 | SlideshowToggle();
|
9550 | break;
|
9551 | case 38:
|
9552 | case 39:
|
9553 | case 33:
|
9554 | DisplayNextMedia();
|
9555 | break;
|
9556 | case 37:
|
9557 | case 34:
|
9558 | DisplayPreviousMedia();
|
9559 | break;
|
9560 | case 35:
|
9561 | case 36:
|
9562 | }
|
9563 | }
|
9564 | }
|
9565 | });
|
9566 |
|
9567 |
|
9568 | jQuery(window).bind('mousewheel wheel', function(e){
|
9569 | if( G.VOM.viewerDisplayed ) {
|
9570 | var deltaY = 0;
|
9571 | e.preventDefault();
|
9572 |
|
9573 | if( ViewerZoomStart() ) {
|
9574 | if (e.originalEvent.deltaY) {
|
9575 | deltaY = e.originalEvent.deltaY;
|
9576 | } else if (e.originalEvent.wheelDelta) {
|
9577 | deltaY = -e.originalEvent.wheelDelta;
|
9578 | }
|
9579 | ViewerZoomIn( deltaY <= 0 ? true : false );
|
9580 | }
|
9581 | }
|
9582 | });
|
9583 |
|
9584 |
|
9585 | jQuery(window).bind('mousemove', function(e){
|
9586 | if( G.VOM.viewerDisplayed ) {
|
9587 | debounce( ViewerToolsUnHide, 100, false )();
|
9588 | }
|
9589 | });
|
9590 |
|
9591 |
|
9592 | if( ngscreenfull.enabled ) {
|
9593 |
|
9594 | ngscreenfull.onchange( function() {
|
9595 | if( G.VOM.viewerDisplayed ) {
|
9596 | if( ngscreenfull.isFullscreen ) {
|
9597 | G.VOM.viewerIsFullscreen=true;
|
9598 | G.VOM.$viewer.find('.fullscreenButton').html(G.O.icons.viewerFullscreenOff);
|
9599 | }
|
9600 | else {
|
9601 | G.VOM.viewerIsFullscreen=false;
|
9602 | G.VOM.$viewer.find('.fullscreenButton').html(G.O.icons.viewerFullscreenOn);
|
9603 | }
|
9604 | }
|
9605 | });
|
9606 | }
|
9607 |
|
9608 | }
|
9609 |
|
9610 |
|
9611 | function ProcessLocationHash() {
|
9612 |
|
9613 |
|
9614 | if( !G.O.locationHash ) { return false; }
|
9615 |
|
9616 | var curGal = '#nanogallery/' + G.baseEltID + '/',
|
9617 | newLocationHash = location.hash;
|
9618 | if( G.O.debugMode ) {
|
9619 | console.log('------------------------ PROCESS LOCATION HASH');
|
9620 | console.log('newLocationHash1: ' +newLocationHash);
|
9621 | console.log('G.locationHashLastUsed: ' +G.locationHashLastUsed);
|
9622 | }
|
9623 |
|
9624 | if( newLocationHash == '' ) {
|
9625 |
|
9626 | if( G.locationHashLastUsed !== '' ) {
|
9627 |
|
9628 | if( G.O.debugMode ) { console.log('display root album' ); }
|
9629 | G.locationHashLastUsed = '';
|
9630 | if( G.O.debugMode ) { console.log('new3 G.locationHashLastUsed: ' + G.locationHashLastUsed); }
|
9631 | DisplayAlbum('', '0');
|
9632 | return true;
|
9633 | }
|
9634 | }
|
9635 |
|
9636 | if( newLocationHash == G.locationHashLastUsed ) { return; }
|
9637 |
|
9638 | if( newLocationHash.indexOf(curGal) == 0 ) {
|
9639 |
|
9640 | var IDs=parseIDs( newLocationHash.substring(curGal.length) );
|
9641 | if( IDs.imageID != '0' ) {
|
9642 | if( G.O.debugMode ) { console.log('display image: ' + IDs.albumID +'-'+ IDs.imageID ); }
|
9643 | DisplayPhoto( IDs.imageID, IDs.albumID );
|
9644 | return true;
|
9645 | }
|
9646 | else {
|
9647 | if( G.O.debugMode ) { console.log('display album: ' + IDs.albumID ); }
|
9648 | DisplayAlbum( '-1', IDs.albumID );
|
9649 | return true;
|
9650 | }
|
9651 | }
|
9652 |
|
9653 | return false;
|
9654 | }
|
9655 |
|
9656 |
|
9657 | function SetLocationHash(albumID, imageID ) {
|
9658 | if( !G.O.locationHash ) { return false; }
|
9659 |
|
9660 | if( G.O.debugMode ) {
|
9661 | console.log('------------------------ SET LOCATION HASH');
|
9662 | }
|
9663 |
|
9664 | if( imageID == '' && (albumID == '-1' || albumID == '0' || G.O.album == albumID ) ) {
|
9665 |
|
9666 | if( location.hash != '' ) {
|
9667 |
|
9668 | if ("pushState" in history) {
|
9669 | history.pushState("", document.title, window.location.pathname + window.location.search);
|
9670 | }
|
9671 | else {
|
9672 | location.hash='';
|
9673 | }
|
9674 | }
|
9675 | G.locationHashLastUsed='';
|
9676 | if( G.O.debugMode ) { console.log('new2 G.locationHashLastUsed: '+G.locationHashLastUsed); }
|
9677 | return;
|
9678 | }
|
9679 |
|
9680 | var newLocationHash='#'+'nanogallery/'+G.baseEltID+'/'+ albumID;
|
9681 | if( imageID != '' ) {
|
9682 | newLocationHash+='/'+imageID;
|
9683 | }
|
9684 |
|
9685 | var lH=location.hash;
|
9686 | if( G.O.debugMode ) {
|
9687 | console.log('newLocationHash2: '+newLocationHash);
|
9688 | console.log('location.hash: '+lH);
|
9689 | }
|
9690 |
|
9691 | G.locationHashLastUsed=newLocationHash;
|
9692 | if( G.O.debugMode ) { console.log('new G.locationHashLastUsed: '+G.locationHashLastUsed); }
|
9693 |
|
9694 | if( lH == '' || lH != newLocationHash ) {
|
9695 |
|
9696 | try {
|
9697 | top.location.hash=newLocationHash;
|
9698 | }
|
9699 | catch(e) {
|
9700 |
|
9701 | G.O.locationHash=false;
|
9702 | }
|
9703 | }
|
9704 | }
|
9705 |
|
9706 |
|
9707 | function ResizeWindowEvent() {
|
9708 | CacheViewport();
|
9709 |
|
9710 | if( G.VOM.viewerDisplayed ) {
|
9711 | ResizeInternalViewer();
|
9712 | }
|
9713 | else {
|
9714 | if( G.galleryResizeEventEnabled ) {
|
9715 | var nw = RetrieveCurWidth();
|
9716 | if( G.GOM.albumIdx != -1 &&
|
9717 | ( G.tn.settings.height[G.GOM.curNavLevel][G.GOM.curWidth] != G.tn.settings.height[G.GOM.curNavLevel][nw] ||
|
9718 | G.tn.settings.width[G.GOM.curNavLevel][G.GOM.curWidth] != G.tn.settings.width[G.GOM.curNavLevel][nw] ) ) {
|
9719 |
|
9720 |
|
9721 | G.GOM.curWidth = nw;
|
9722 |
|
9723 | G.GOM.pagination.currentPage = 0;
|
9724 | GalleryRender( G.GOM.albumIdx );
|
9725 | }
|
9726 | else {
|
9727 | GalleryResize();
|
9728 | }
|
9729 | }
|
9730 | }
|
9731 | }
|
9732 |
|
9733 |
|
9734 |
|
9735 | function OnScrollEvent_OLD() {
|
9736 | if( !G.VOM.viewerDisplayed ) {
|
9737 | if( G.galleryResizeEventEnabled ) {
|
9738 | GalleryResize();
|
9739 | }
|
9740 | return;
|
9741 | }
|
9742 | }
|
9743 |
|
9744 |
|
9745 | function OnScrollEvent() {
|
9746 | if( !G.VOM.viewerDisplayed ) {
|
9747 | GalleryResizeOnScrollEvent();
|
9748 | }
|
9749 | }
|
9750 |
|
9751 | function GalleryResizeOnScrollEvent() {
|
9752 | if( G.galleryResizeEventEnabled == false) {
|
9753 | window.setTimeout(GalleryResizeOnScrollEvent, 10);
|
9754 | } else {
|
9755 | GalleryResize();
|
9756 | }
|
9757 | }
|
9758 |
|
9759 |
|
9760 |
|
9761 |
|
9762 | function i18n() {
|
9763 |
|
9764 |
|
9765 | G.i18nLang = (navigator.language || navigator.userLanguage).toUpperCase();
|
9766 | if( G.i18nLang === 'UNDEFINED') { G.i18nLang=''; }
|
9767 |
|
9768 | var llang=-('_'+G.i18nLang).length;
|
9769 |
|
9770 | if( toType(G.O.i18n) == 'object' ){
|
9771 |
|
9772 | for( var key in G.O.i18n ) {
|
9773 |
|
9774 | var s=key.substr(llang);
|
9775 | if( s == ('_'+G.i18nLang) ) {
|
9776 | G.i18nTranslations[key.substr(0,key.length-s.length)]=G.O.i18n[key];
|
9777 | }
|
9778 | else {
|
9779 | G.i18nTranslations[key]=G.O.i18n[key];
|
9780 | }
|
9781 | }
|
9782 | }
|
9783 | }
|
9784 |
|
9785 | function GetI18nItem( item, property ) {
|
9786 | var s='';
|
9787 | if( G.i18nLang != '' ) {
|
9788 | if( item[property+'_'+G.i18nLang] !== undefined && item[property+'_'+G.i18nLang].length>0 ) {
|
9789 | s=item[property+'_'+G.i18nLang];
|
9790 | return s;
|
9791 | }
|
9792 | }
|
9793 | s=item[property];
|
9794 | return s;
|
9795 | }
|
9796 |
|
9797 |
|
9798 | function RetrieveCurWidth() {
|
9799 | var vpW = G.GOM.cache.viewport.w;
|
9800 |
|
9801 | if( G.O.breakpointSizeSM > 0 && vpW < G.O.breakpointSizeSM) { return 'xs'; }
|
9802 | if( G.O.breakpointSizeME > 0 && vpW < G.O.breakpointSizeME) { return 'sm'; }
|
9803 | if( G.O.breakpointSizeLA > 0 && vpW < G.O.breakpointSizeLA) { return 'me'; }
|
9804 | if( G.O.breakpointSizeXL > 0 && vpW < G.O.breakpointSizeXL) { return 'la'; }
|
9805 |
|
9806 | return 'xl';
|
9807 | }
|
9808 |
|
9809 |
|
9810 |
|
9811 | function browserNotification() {
|
9812 | 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>';
|
9813 | m += ' <a href="http://www.google.com/chrome/?hl=en-US)">Chrome</a><br>';
|
9814 | m += ' <a href="http://www.mozilla.com/firefox/)">Firefox</a><br>';
|
9815 | m += ' <a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">Internet Explorer</a><br>';
|
9816 | m += ' <a href="http://www.apple.com/safari/download/">Safari</a>';
|
9817 | NanoAlert(G, m, false);
|
9818 | }
|
9819 |
|
9820 |
|
9821 | function FirstSupportedPropertyName(prefixedPropertyNames) {
|
9822 | var tempDiv = document.createElement("div");
|
9823 | for (var i = 0; i < prefixedPropertyNames.length; ++i) {
|
9824 | if (typeof tempDiv.style[prefixedPropertyNames[i]] != 'undefined')
|
9825 | return prefixedPropertyNames[i];
|
9826 | }
|
9827 | return null;
|
9828 | }
|
9829 |
|
9830 |
|
9831 |
|
9832 |
|
9833 | }
|
9834 |
|
9835 |
|
9836 |
|
9837 |
|
9838 |
|
9839 |
|
9840 |
|
9841 |
|
9842 |
|
9843 |
|
9844 |
|
9845 |
|
9846 |
|
9847 |
|
9848 |
|
9849 |
|
9850 |
|
9851 |
|
9852 |
|
9853 |
|
9854 |
|
9855 |
|
9856 |
|
9857 |
|
9858 |
|
9859 |
|
9860 |
|
9861 |
|
9862 |
|
9863 |
|
9864 |
|
9865 |
|
9866 | ( function( global, factory ) {
|
9867 |
|
9868 |
|
9869 |
|
9870 |
|
9871 |
|
9872 |
|
9873 |
|
9874 |
|
9875 |
|
9876 |
|
9877 | global.ngEvEmitter = factory();
|
9878 |
|
9879 |
|
9880 | }( typeof window != 'undefined' ? window : this, function() {
|
9881 |
|
9882 |
|
9883 |
|
9884 | function ngEvEmitter() {}
|
9885 |
|
9886 | var proto = ngEvEmitter.prototype;
|
9887 |
|
9888 | proto.on = function( eventName, listener ) {
|
9889 | if ( !eventName || !listener ) {
|
9890 | return;
|
9891 | }
|
9892 |
|
9893 | var events = this._events = this._events || {};
|
9894 |
|
9895 | var listeners = events[ eventName ] = events[ eventName ] || [];
|
9896 |
|
9897 | if ( listeners.indexOf( listener ) == -1 ) {
|
9898 | listeners.push( listener );
|
9899 | }
|
9900 |
|
9901 | return this;
|
9902 | };
|
9903 |
|
9904 | proto.once = function( eventName, listener ) {
|
9905 | if ( !eventName || !listener ) {
|
9906 | return;
|
9907 | }
|
9908 |
|
9909 | this.on( eventName, listener );
|
9910 |
|
9911 |
|
9912 | var onceEvents = this._onceEvents = this._onceEvents || {};
|
9913 |
|
9914 | var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
|
9915 |
|
9916 | onceListeners[ listener ] = true;
|
9917 |
|
9918 | return this;
|
9919 | };
|
9920 |
|
9921 | proto.off = function( eventName, listener ) {
|
9922 | var listeners = this._events && this._events[ eventName ];
|
9923 | if ( !listeners || !listeners.length ) {
|
9924 | return;
|
9925 | }
|
9926 | var index = listeners.indexOf( listener );
|
9927 | if ( index != -1 ) {
|
9928 | listeners.splice( index, 1 );
|
9929 | }
|
9930 |
|
9931 | return this;
|
9932 | };
|
9933 |
|
9934 | proto.emitEvent = function( eventName, args ) {
|
9935 | var listeners = this._events && this._events[ eventName ];
|
9936 | if ( !listeners || !listeners.length ) {
|
9937 | return;
|
9938 | }
|
9939 | var i = 0;
|
9940 | var listener = listeners[i];
|
9941 | args = args || [];
|
9942 |
|
9943 | var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
|
9944 |
|
9945 | while ( listener ) {
|
9946 | var isOnce = onceListeners && onceListeners[ listener ];
|
9947 | if ( isOnce ) {
|
9948 |
|
9949 |
|
9950 | this.off( eventName, listener );
|
9951 |
|
9952 | delete onceListeners[ listener ];
|
9953 | }
|
9954 |
|
9955 | listener.apply( this, args );
|
9956 |
|
9957 | i += isOnce ? 0 : 1;
|
9958 | listener = listeners[i];
|
9959 | }
|
9960 |
|
9961 | return this;
|
9962 | };
|
9963 |
|
9964 | return ngEvEmitter;
|
9965 |
|
9966 | }));
|
9967 |
|
9968 |
|
9969 |
|
9970 |
|
9971 |
|
9972 |
|
9973 |
|
9974 | ( function( window, factory ) { 'use strict';
|
9975 |
|
9976 |
|
9977 |
|
9978 |
|
9979 |
|
9980 |
|
9981 |
|
9982 |
|
9983 |
|
9984 |
|
9985 |
|
9986 |
|
9987 |
|
9988 |
|
9989 |
|
9990 |
|
9991 |
|
9992 |
|
9993 |
|
9994 | window.ngimagesLoaded = factory(
|
9995 | window,
|
9996 | window.ngEvEmitter
|
9997 | );
|
9998 |
|
9999 |
|
10000 | })( window,
|
10001 |
|
10002 |
|
10003 |
|
10004 | function factory( window, ngEvEmitter ) {
|
10005 |
|
10006 |
|
10007 |
|
10008 |
|
10009 | var $ = jQuery;
|
10010 | var console = window.console;
|
10011 |
|
10012 |
|
10013 |
|
10014 |
|
10015 | function extend( a, b ) {
|
10016 | for ( var prop in b ) {
|
10017 | a[ prop ] = b[ prop ];
|
10018 | }
|
10019 | return a;
|
10020 | }
|
10021 |
|
10022 |
|
10023 | function makeArray( obj ) {
|
10024 | var ary = [];
|
10025 | if ( Array.isArray( obj ) ) {
|
10026 |
|
10027 | ary = obj;
|
10028 | } else if ( typeof obj.length == 'number' ) {
|
10029 |
|
10030 | for ( var i=0; i < obj.length; i++ ) {
|
10031 | ary.push( obj[i] );
|
10032 | }
|
10033 | } else {
|
10034 |
|
10035 | ary.push( obj );
|
10036 | }
|
10037 | return ary;
|
10038 | }
|
10039 |
|
10040 |
|
10041 |
|
10042 |
|
10043 |
|
10044 |
|
10045 |
|
10046 |
|
10047 | function ngImagesLoaded( elem, options, onAlways ) {
|
10048 |
|
10049 | if ( !( this instanceof ngImagesLoaded ) ) {
|
10050 | return new ngImagesLoaded( elem, options, onAlways );
|
10051 | }
|
10052 |
|
10053 | if ( typeof elem == 'string' ) {
|
10054 | elem = document.querySelectorAll( elem );
|
10055 | }
|
10056 |
|
10057 | this.elements = makeArray( elem );
|
10058 | this.options = extend( {}, this.options );
|
10059 |
|
10060 | if ( typeof options == 'function' ) {
|
10061 | onAlways = options;
|
10062 | } else {
|
10063 | extend( this.options, options );
|
10064 | }
|
10065 |
|
10066 | if ( onAlways ) {
|
10067 | this.on( 'always', onAlways );
|
10068 | }
|
10069 |
|
10070 | this.getImages();
|
10071 |
|
10072 | if ( $ ) {
|
10073 |
|
10074 | this.jqDeferred = new $.Deferred();
|
10075 | }
|
10076 |
|
10077 |
|
10078 | setTimeout( function() {
|
10079 | this.check();
|
10080 | }.bind( this ));
|
10081 | }
|
10082 |
|
10083 | ngImagesLoaded.prototype = Object.create( ngEvEmitter.prototype );
|
10084 |
|
10085 | ngImagesLoaded.prototype.options = {};
|
10086 |
|
10087 | ngImagesLoaded.prototype.getImages = function() {
|
10088 | this.images = [];
|
10089 |
|
10090 |
|
10091 | this.elements.forEach( this.addElementImages, this );
|
10092 | };
|
10093 |
|
10094 |
|
10095 |
|
10096 |
|
10097 | ngImagesLoaded.prototype.addElementImages = function( elem ) {
|
10098 |
|
10099 | if ( elem.nodeName == 'IMG' ) {
|
10100 | this.addImage( elem );
|
10101 | }
|
10102 |
|
10103 | if ( this.options.background === true ) {
|
10104 | this.addElementBackgroundImages( elem );
|
10105 | }
|
10106 |
|
10107 |
|
10108 |
|
10109 | var nodeType = elem.nodeType;
|
10110 | if ( !nodeType || !elementNodeTypes[ nodeType ] ) {
|
10111 | return;
|
10112 | }
|
10113 | var childImgs = elem.querySelectorAll('img');
|
10114 |
|
10115 | for ( var i=0; i < childImgs.length; i++ ) {
|
10116 | var img = childImgs[i];
|
10117 | this.addImage( img );
|
10118 | }
|
10119 |
|
10120 |
|
10121 | if ( typeof this.options.background == 'string' ) {
|
10122 | var children = elem.querySelectorAll( this.options.background );
|
10123 | for ( i=0; i < children.length; i++ ) {
|
10124 | var child = children[i];
|
10125 | this.addElementBackgroundImages( child );
|
10126 | }
|
10127 | }
|
10128 | };
|
10129 |
|
10130 | var elementNodeTypes = {
|
10131 | 1: true,
|
10132 | 9: true,
|
10133 | 11: true
|
10134 | };
|
10135 |
|
10136 | ngImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
|
10137 | var style = getComputedStyle( elem );
|
10138 | if ( !style ) {
|
10139 |
|
10140 | return;
|
10141 | }
|
10142 |
|
10143 | var reURL = /url\((['"])?(.*?)\1\)/gi;
|
10144 | var matches = reURL.exec( style.backgroundImage );
|
10145 | while ( matches !== null ) {
|
10146 | var url = matches && matches[2];
|
10147 | if ( url ) {
|
10148 | this.addBackground( url, elem );
|
10149 | }
|
10150 | matches = reURL.exec( style.backgroundImage );
|
10151 | }
|
10152 | };
|
10153 |
|
10154 |
|
10155 |
|
10156 |
|
10157 | ngImagesLoaded.prototype.addImage = function( img ) {
|
10158 | var loadingImage = new LoadingImage( img );
|
10159 | this.images.push( loadingImage );
|
10160 | };
|
10161 |
|
10162 | ngImagesLoaded.prototype.addBackground = function( url, elem ) {
|
10163 | var background = new Background( url, elem );
|
10164 | this.images.push( background );
|
10165 | };
|
10166 |
|
10167 | ngImagesLoaded.prototype.check = function() {
|
10168 | var _this = this;
|
10169 | this.progressedCount = 0;
|
10170 | this.hasAnyBroken = false;
|
10171 |
|
10172 | if ( !this.images.length ) {
|
10173 | this.complete();
|
10174 | return;
|
10175 | }
|
10176 |
|
10177 | function onProgress( image, elem, message ) {
|
10178 |
|
10179 | setTimeout( function() {
|
10180 | _this.progress( image, elem, message );
|
10181 | });
|
10182 | }
|
10183 |
|
10184 | this.images.forEach( function( loadingImage ) {
|
10185 | loadingImage.once( 'progress', onProgress );
|
10186 | loadingImage.check();
|
10187 | });
|
10188 | };
|
10189 |
|
10190 | ngImagesLoaded.prototype.progress = function( image, elem, message ) {
|
10191 | this.progressedCount++;
|
10192 | this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
|
10193 |
|
10194 | this.emitEvent( 'progress', [ this, image, elem ] );
|
10195 | if ( this.jqDeferred && this.jqDeferred.notify ) {
|
10196 | this.jqDeferred.notify( this, image );
|
10197 | }
|
10198 |
|
10199 | if ( this.progressedCount == this.images.length ) {
|
10200 | this.complete();
|
10201 | }
|
10202 |
|
10203 | if ( this.options.debug && console ) {
|
10204 | console.log( 'progress: ' + message, image, elem );
|
10205 | }
|
10206 | };
|
10207 |
|
10208 | ngImagesLoaded.prototype.complete = function() {
|
10209 | var eventName = this.hasAnyBroken ? 'fail' : 'done';
|
10210 | this.isComplete = true;
|
10211 | this.emitEvent( eventName, [ this ] );
|
10212 | this.emitEvent( 'always', [ this ] );
|
10213 | if ( this.jqDeferred ) {
|
10214 | var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
|
10215 | this.jqDeferred[ jqMethod ]( this );
|
10216 | }
|
10217 | };
|
10218 |
|
10219 |
|
10220 |
|
10221 | function LoadingImage( img ) {
|
10222 | this.img = img;
|
10223 | }
|
10224 |
|
10225 | LoadingImage.prototype = Object.create( ngEvEmitter.prototype );
|
10226 |
|
10227 | LoadingImage.prototype.check = function() {
|
10228 |
|
10229 |
|
10230 | var isComplete = this.getIsImageComplete();
|
10231 | if ( isComplete ) {
|
10232 |
|
10233 | this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
|
10234 | return;
|
10235 | }
|
10236 |
|
10237 |
|
10238 | this.proxyImage = new Image();
|
10239 | this.proxyImage.addEventListener( 'load', this );
|
10240 | this.proxyImage.addEventListener( 'error', this );
|
10241 |
|
10242 | this.img.addEventListener( 'load', this );
|
10243 | this.img.addEventListener( 'error', this );
|
10244 | this.proxyImage.src = this.img.src;
|
10245 | };
|
10246 |
|
10247 | LoadingImage.prototype.getIsImageComplete = function() {
|
10248 | return this.img.complete && this.img.naturalWidth !== undefined;
|
10249 | };
|
10250 |
|
10251 | LoadingImage.prototype.confirm = function( isLoaded, message ) {
|
10252 | this.isLoaded = isLoaded;
|
10253 | this.emitEvent( 'progress', [ this, this.img, message ] );
|
10254 | };
|
10255 |
|
10256 |
|
10257 |
|
10258 |
|
10259 | LoadingImage.prototype.handleEvent = function( event ) {
|
10260 | var method = 'on' + event.type;
|
10261 | if ( this[ method ] ) {
|
10262 | this[ method ]( event );
|
10263 | }
|
10264 | };
|
10265 |
|
10266 | LoadingImage.prototype.onload = function() {
|
10267 | this.confirm( true, 'onload' );
|
10268 | this.unbindEvents();
|
10269 | };
|
10270 |
|
10271 | LoadingImage.prototype.onerror = function() {
|
10272 | this.confirm( false, 'onerror' );
|
10273 | this.unbindEvents();
|
10274 | };
|
10275 |
|
10276 | LoadingImage.prototype.unbindEvents = function() {
|
10277 | this.proxyImage.removeEventListener( 'load', this );
|
10278 | this.proxyImage.removeEventListener( 'error', this );
|
10279 | this.img.removeEventListener( 'load', this );
|
10280 | this.img.removeEventListener( 'error', this );
|
10281 | };
|
10282 |
|
10283 |
|
10284 |
|
10285 | function Background( url, element ) {
|
10286 | this.url = url;
|
10287 | this.element = element;
|
10288 | this.img = new Image();
|
10289 | }
|
10290 |
|
10291 |
|
10292 | Background.prototype = Object.create( LoadingImage.prototype );
|
10293 |
|
10294 | Background.prototype.check = function() {
|
10295 | this.img.addEventListener( 'load', this );
|
10296 | this.img.addEventListener( 'error', this );
|
10297 | this.img.src = this.url;
|
10298 |
|
10299 | var isComplete = this.getIsImageComplete();
|
10300 | if ( isComplete ) {
|
10301 | this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
|
10302 | this.unbindEvents();
|
10303 | }
|
10304 | };
|
10305 |
|
10306 | Background.prototype.unbindEvents = function() {
|
10307 | this.img.removeEventListener( 'load', this );
|
10308 | this.img.removeEventListener( 'error', this );
|
10309 | };
|
10310 |
|
10311 | Background.prototype.confirm = function( isLoaded, message ) {
|
10312 | this.isLoaded = isLoaded;
|
10313 | this.emitEvent( 'progress', [ this, this.element, message ] );
|
10314 | };
|
10315 |
|
10316 |
|
10317 |
|
10318 | ngImagesLoaded.makeJQueryPlugin = function( jQuery ) {
|
10319 | jQuery = jQuery || window.jQuery;
|
10320 | if ( !jQuery ) {
|
10321 | return;
|
10322 | }
|
10323 |
|
10324 | $ = jQuery;
|
10325 |
|
10326 | $.fn.ngimagesLoaded = function( options, callback ) {
|
10327 | var instance = new ngImagesLoaded( this, options, callback );
|
10328 | return instance.jqDeferred.promise( $(this) );
|
10329 | };
|
10330 | };
|
10331 |
|
10332 | ngImagesLoaded.makeJQueryPlugin();
|
10333 |
|
10334 |
|
10335 |
|
10336 | return ngImagesLoaded;
|
10337 |
|
10338 | });
|
10339 |
|
10340 |
|
10341 |
|
10342 |
|
10343 |
|
10344 |
|
10345 |
|
10346 |
|
10347 |
|
10348 |
|
10349 |
|
10350 |
|
10351 |
|
10352 |
|
10353 |
|
10354 |
|
10355 |
|
10356 | (function () {
|
10357 | 'use strict';
|
10358 |
|
10359 | var document = typeof window !== 'undefined' && typeof window.document !== 'undefined' ? window.document : {};
|
10360 | var isCommonjs = typeof module !== 'undefined' && module.exports;
|
10361 | var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element;
|
10362 |
|
10363 | var fn = (function () {
|
10364 | var val;
|
10365 |
|
10366 | var fnMap = [
|
10367 | [
|
10368 | 'requestFullscreen',
|
10369 | 'exitFullscreen',
|
10370 | 'fullscreenElement',
|
10371 | 'fullscreenEnabled',
|
10372 | 'fullscreenchange',
|
10373 | 'fullscreenerror'
|
10374 | ],
|
10375 |
|
10376 | [
|
10377 | 'webkitRequestFullscreen',
|
10378 | 'webkitExitFullscreen',
|
10379 | 'webkitFullscreenElement',
|
10380 | 'webkitFullscreenEnabled',
|
10381 | 'webkitfullscreenchange',
|
10382 | 'webkitfullscreenerror'
|
10383 |
|
10384 | ],
|
10385 |
|
10386 | [
|
10387 | 'webkitRequestFullScreen',
|
10388 | 'webkitCancelFullScreen',
|
10389 | 'webkitCurrentFullScreenElement',
|
10390 | 'webkitCancelFullScreen',
|
10391 | 'webkitfullscreenchange',
|
10392 | 'webkitfullscreenerror'
|
10393 |
|
10394 | ],
|
10395 | [
|
10396 | 'mozRequestFullScreen',
|
10397 | 'mozCancelFullScreen',
|
10398 | 'mozFullScreenElement',
|
10399 | 'mozFullScreenEnabled',
|
10400 | 'mozfullscreenchange',
|
10401 | 'mozfullscreenerror'
|
10402 | ],
|
10403 | [
|
10404 | 'msRequestFullscreen',
|
10405 | 'msExitFullscreen',
|
10406 | 'msFullscreenElement',
|
10407 | 'msFullscreenEnabled',
|
10408 | 'MSFullscreenChange',
|
10409 | 'MSFullscreenError'
|
10410 | ]
|
10411 | ];
|
10412 |
|
10413 | var i = 0;
|
10414 | var l = fnMap.length;
|
10415 | var ret = {};
|
10416 |
|
10417 | for (; i < l; i++) {
|
10418 | val = fnMap[i];
|
10419 | if (val && val[1] in document) {
|
10420 | for (i = 0; i < val.length; i++) {
|
10421 | ret[fnMap[0][i]] = val[i];
|
10422 | }
|
10423 | return ret;
|
10424 | }
|
10425 | }
|
10426 |
|
10427 | return false;
|
10428 | })();
|
10429 |
|
10430 | var eventNameMap = {
|
10431 | change: fn.fullscreenchange,
|
10432 | error: fn.fullscreenerror
|
10433 | };
|
10434 |
|
10435 | var ngscreenfull = {
|
10436 | request: function (elem) {
|
10437 | return new Promise(function (resolve) {
|
10438 | var request = fn.requestFullscreen;
|
10439 |
|
10440 | var onFullScreenEntered = function () {
|
10441 | this.off('change', onFullScreenEntered);
|
10442 | resolve();
|
10443 | }.bind(this);
|
10444 |
|
10445 | elem = elem || document.documentElement;
|
10446 |
|
10447 |
|
10448 |
|
10449 |
|
10450 |
|
10451 | if (/ Version\/5\.1(?:\.\d+)? Safari\//.test(navigator.userAgent)) {
|
10452 | elem[request]();
|
10453 | } else {
|
10454 | elem[request](keyboardAllowed ? Element.ALLOW_KEYBOARD_INPUT : {});
|
10455 | }
|
10456 |
|
10457 | this.on('change', onFullScreenEntered);
|
10458 | }.bind(this));
|
10459 | },
|
10460 | exit: function () {
|
10461 | return new Promise(function (resolve) {
|
10462 | if (!this.isFullscreen) {
|
10463 | resolve();
|
10464 | return;
|
10465 | }
|
10466 |
|
10467 | var onFullScreenExit = function () {
|
10468 | this.off('change', onFullScreenExit);
|
10469 | resolve();
|
10470 | }.bind(this);
|
10471 |
|
10472 | document[fn.exitFullscreen]();
|
10473 |
|
10474 | this.on('change', onFullScreenExit);
|
10475 | }.bind(this));
|
10476 | },
|
10477 | toggle: function (elem) {
|
10478 | return this.isFullscreen ? this.exit() : this.request(elem);
|
10479 | },
|
10480 | onchange: function (callback) {
|
10481 | this.on('change', callback);
|
10482 | },
|
10483 | onerror: function (callback) {
|
10484 | this.on('error', callback);
|
10485 | },
|
10486 | on: function (event, callback) {
|
10487 | var eventName = eventNameMap[event];
|
10488 | if (eventName) {
|
10489 | document.addEventListener(eventName, callback, false);
|
10490 | }
|
10491 | },
|
10492 | off: function (event, callback) {
|
10493 | var eventName = eventNameMap[event];
|
10494 | if (eventName) {
|
10495 | document.removeEventListener(eventName, callback, false);
|
10496 | }
|
10497 | },
|
10498 | raw: fn
|
10499 | };
|
10500 |
|
10501 | if (!fn) {
|
10502 | if (isCommonjs) {
|
10503 | module.exports = false;
|
10504 | } else {
|
10505 | window.ngscreenfull = false;
|
10506 | }
|
10507 |
|
10508 | return;
|
10509 | }
|
10510 |
|
10511 | Object.defineProperties(ngscreenfull, {
|
10512 | isFullscreen: {
|
10513 | get: function () {
|
10514 | return Boolean(document[fn.fullscreenElement]);
|
10515 | }
|
10516 | },
|
10517 | element: {
|
10518 | enumerable: true,
|
10519 | get: function () {
|
10520 | return document[fn.fullscreenElement];
|
10521 | }
|
10522 | },
|
10523 | enabled: {
|
10524 | enumerable: true,
|
10525 | get: function () {
|
10526 |
|
10527 | return Boolean(document[fn.fullscreenEnabled]);
|
10528 | }
|
10529 | }
|
10530 | });
|
10531 |
|
10532 | if (isCommonjs) {
|
10533 | module.exports = ngscreenfull;
|
10534 | } else {
|
10535 | window.ngscreenfull = ngscreenfull;
|
10536 | }
|
10537 | })();
|
10538 |
|
10539 |
|
10540 |
|
10541 |
|
10542 |
|
10543 |
|
10544 |
|
10545 | |
10546 |
|
10547 |
|
10548 |
|
10549 |
|
10550 |
|
10551 |
|
10552 |
|
10553 |
|
10554 |
|
10555 |
|
10556 | ;(function () {
|
10557 | var root = this || Function('return this')();
|
10558 |
|
10559 |
|
10560 |
|
10561 |
|
10562 |
|
10563 |
|
10564 | var NGTweenable = (function () {
|
10565 |
|
10566 | 'use strict';
|
10567 |
|
10568 |
|
10569 | var formula;
|
10570 |
|
10571 |
|
10572 | var DEFAULT_SCHEDULE_FUNCTION;
|
10573 | var DEFAULT_EASING = 'linear';
|
10574 | var DEFAULT_DURATION = 500;
|
10575 | var UPDATE_TIME = 1000 / 60;
|
10576 |
|
10577 | var _now = Date.now
|
10578 | ? Date.now
|
10579 | : function () {return +new Date();};
|
10580 |
|
10581 | var now = typeof SHIFTY_DEBUG_NOW !== 'undefined' ? SHIFTY_DEBUG_NOW : _now;
|
10582 |
|
10583 | if (typeof window !== 'undefined') {
|
10584 |
|
10585 |
|
10586 | DEFAULT_SCHEDULE_FUNCTION = window.requestAnimationFrame
|
10587 | || window.webkitRequestAnimationFrame
|
10588 | || window.oRequestAnimationFrame
|
10589 | || window.msRequestAnimationFrame
|
10590 | || (window.mozCancelRequestAnimationFrame
|
10591 | && window.mozRequestAnimationFrame)
|
10592 | || setTimeout;
|
10593 | } else {
|
10594 | DEFAULT_SCHEDULE_FUNCTION = setTimeout;
|
10595 | }
|
10596 |
|
10597 | function noop () {
|
10598 |
|
10599 | }
|
10600 |
|
10601 | |
10602 |
|
10603 |
|
10604 |
|
10605 |
|
10606 |
|
10607 |
|
10608 |
|
10609 | function each (obj, fn) {
|
10610 | var key;
|
10611 | for (key in obj) {
|
10612 | if (Object.hasOwnProperty.call(obj, key)) {
|
10613 | fn(key);
|
10614 | }
|
10615 | }
|
10616 | }
|
10617 |
|
10618 | |
10619 |
|
10620 |
|
10621 |
|
10622 |
|
10623 |
|
10624 |
|
10625 | function shallowCopy (targetObj, srcObj) {
|
10626 | each(srcObj, function (prop) {
|
10627 | targetObj[prop] = srcObj[prop];
|
10628 | });
|
10629 |
|
10630 | return targetObj;
|
10631 | }
|
10632 |
|
10633 | |
10634 |
|
10635 |
|
10636 |
|
10637 |
|
10638 |
|
10639 |
|
10640 | function defaults (target, src) {
|
10641 | each(src, function (prop) {
|
10642 | if (typeof target[prop] === 'undefined') {
|
10643 | target[prop] = src[prop];
|
10644 | }
|
10645 | });
|
10646 | }
|
10647 |
|
10648 | |
10649 |
|
10650 |
|
10651 |
|
10652 |
|
10653 |
|
10654 |
|
10655 |
|
10656 |
|
10657 |
|
10658 |
|
10659 |
|
10660 |
|
10661 |
|
10662 |
|
10663 | function tweenProps (forPosition, currentState, originalState, targetState,
|
10664 | duration, timestamp, easing) {
|
10665 | var normalizedPosition =
|
10666 | forPosition < timestamp ? 0 : (forPosition - timestamp) / duration;
|
10667 |
|
10668 |
|
10669 | var prop;
|
10670 | var easingObjectProp;
|
10671 | var easingFn;
|
10672 | for (prop in currentState) {
|
10673 | if (currentState.hasOwnProperty(prop)) {
|
10674 | easingObjectProp = easing[prop];
|
10675 | easingFn = typeof easingObjectProp === 'function'
|
10676 | ? easingObjectProp
|
10677 | : formula[easingObjectProp];
|
10678 |
|
10679 | currentState[prop] = tweenProp(
|
10680 | originalState[prop],
|
10681 | targetState[prop],
|
10682 | easingFn,
|
10683 | normalizedPosition
|
10684 | );
|
10685 | }
|
10686 | }
|
10687 |
|
10688 | return currentState;
|
10689 | }
|
10690 |
|
10691 | |
10692 |
|
10693 |
|
10694 |
|
10695 |
|
10696 |
|
10697 |
|
10698 |
|
10699 |
|
10700 |
|
10701 | function tweenProp (start, end, easingFunc, position) {
|
10702 | return start + (end - start) * easingFunc(position);
|
10703 | }
|
10704 |
|
10705 | |
10706 |
|
10707 |
|
10708 |
|
10709 |
|
10710 |
|
10711 |
|
10712 | function applyFilter (tweenable, filterName) {
|
10713 | var filters = NGTweenable.prototype.filter;
|
10714 | var args = tweenable._filterArgs;
|
10715 |
|
10716 | each(filters, function (name) {
|
10717 | if (typeof filters[name][filterName] !== 'undefined') {
|
10718 | filters[name][filterName].apply(tweenable, args);
|
10719 | }
|
10720 | });
|
10721 | }
|
10722 |
|
10723 | var timeoutHandler_endTime;
|
10724 | var timeoutHandler_currentTime;
|
10725 | var timeoutHandler_isEnded;
|
10726 | var timeoutHandler_offset;
|
10727 | |
10728 |
|
10729 |
|
10730 |
|
10731 |
|
10732 |
|
10733 |
|
10734 |
|
10735 |
|
10736 |
|
10737 |
|
10738 |
|
10739 |
|
10740 |
|
10741 |
|
10742 |
|
10743 | function timeoutHandler (tweenable, timestamp, delay, duration, currentState,
|
10744 | originalState, targetState, easing, step, schedule,
|
10745 | opt_currentTimeOverride) {
|
10746 |
|
10747 | timeoutHandler_endTime = timestamp + delay + duration;
|
10748 |
|
10749 | timeoutHandler_currentTime =
|
10750 | Math.min(opt_currentTimeOverride || now(), timeoutHandler_endTime);
|
10751 |
|
10752 | timeoutHandler_isEnded =
|
10753 | timeoutHandler_currentTime >= timeoutHandler_endTime;
|
10754 |
|
10755 | timeoutHandler_offset = duration - (
|
10756 | timeoutHandler_endTime - timeoutHandler_currentTime);
|
10757 |
|
10758 | if (tweenable.isPlaying()) {
|
10759 | if (timeoutHandler_isEnded) {
|
10760 | step(targetState, tweenable._attachment, timeoutHandler_offset);
|
10761 | tweenable.stop(true);
|
10762 | } else {
|
10763 | tweenable._scheduleId =
|
10764 | schedule(tweenable._timeoutHandler, UPDATE_TIME);
|
10765 |
|
10766 | applyFilter(tweenable, 'beforeTween');
|
10767 |
|
10768 |
|
10769 |
|
10770 |
|
10771 | if (timeoutHandler_currentTime < (timestamp + delay)) {
|
10772 | tweenProps(1, currentState, originalState, targetState, 1, 1, easing);
|
10773 | } else {
|
10774 | tweenProps(timeoutHandler_currentTime, currentState, originalState,
|
10775 | targetState, duration, timestamp + delay, easing);
|
10776 | }
|
10777 |
|
10778 | applyFilter(tweenable, 'afterTween');
|
10779 |
|
10780 | step(currentState, tweenable._attachment, timeoutHandler_offset);
|
10781 | }
|
10782 | }
|
10783 | }
|
10784 |
|
10785 |
|
10786 | |
10787 |
|
10788 |
|
10789 |
|
10790 |
|
10791 |
|
10792 |
|
10793 |
|
10794 |
|
10795 | function composeEasingObject (fromTweenParams, easing) {
|
10796 | var composedEasing = {};
|
10797 | var typeofEasing = typeof easing;
|
10798 |
|
10799 | if (typeofEasing === 'string' || typeofEasing === 'function') {
|
10800 | each(fromTweenParams, function (prop) {
|
10801 | composedEasing[prop] = easing;
|
10802 | });
|
10803 | } else {
|
10804 | each(fromTweenParams, function (prop) {
|
10805 | if (!composedEasing[prop]) {
|
10806 | composedEasing[prop] = easing[prop] || DEFAULT_EASING;
|
10807 | }
|
10808 | });
|
10809 | }
|
10810 |
|
10811 | return composedEasing;
|
10812 | }
|
10813 |
|
10814 | |
10815 |
|
10816 |
|
10817 |
|
10818 |
|
10819 |
|
10820 |
|
10821 |
|
10822 |
|
10823 |
|
10824 |
|
10825 |
|
10826 | function NGTweenable (opt_initialState, opt_config) {
|
10827 | this._currentState = opt_initialState || {};
|
10828 | this._configured = false;
|
10829 | this._scheduleFunction = DEFAULT_SCHEDULE_FUNCTION;
|
10830 |
|
10831 |
|
10832 |
|
10833 |
|
10834 | if (typeof opt_config !== 'undefined') {
|
10835 | this.setConfig(opt_config);
|
10836 | }
|
10837 | }
|
10838 |
|
10839 | |
10840 |
|
10841 |
|
10842 |
|
10843 |
|
10844 |
|
10845 |
|
10846 | NGTweenable.prototype.tween = function (opt_config) {
|
10847 | if (this._isTweening) {
|
10848 | return this;
|
10849 | }
|
10850 |
|
10851 |
|
10852 |
|
10853 | if (opt_config !== undefined || !this._configured) {
|
10854 | this.setConfig(opt_config);
|
10855 | }
|
10856 |
|
10857 | this._timestamp = now();
|
10858 | this._start(this.get(), this._attachment);
|
10859 | return this.resume();
|
10860 | };
|
10861 |
|
10862 | |
10863 |
|
10864 |
|
10865 |
|
10866 |
|
10867 |
|
10868 |
|
10869 |
|
10870 |
|
10871 |
|
10872 |
|
10873 |
|
10874 |
|
10875 |
|
10876 |
|
10877 |
|
10878 |
|
10879 |
|
10880 |
|
10881 |
|
10882 |
|
10883 |
|
10884 |
|
10885 |
|
10886 |
|
10887 |
|
10888 |
|
10889 |
|
10890 |
|
10891 | NGTweenable.prototype.setConfig = function (config) {
|
10892 | config = config || {};
|
10893 | this._configured = true;
|
10894 |
|
10895 |
|
10896 |
|
10897 | this._attachment = config.attachment;
|
10898 |
|
10899 |
|
10900 | this._pausedAtTime = null;
|
10901 | this._scheduleId = null;
|
10902 | this._delay = config.delay || 0;
|
10903 | this._start = config.start || noop;
|
10904 | this._step = config.step || noop;
|
10905 | this._finish = config.finish || noop;
|
10906 | this._duration = config.duration || DEFAULT_DURATION;
|
10907 | this._currentState = shallowCopy({}, config.from || this.get());
|
10908 | this._originalState = this.get();
|
10909 | this._targetState = shallowCopy({}, config.to || this.get());
|
10910 |
|
10911 | var self = this;
|
10912 | this._timeoutHandler = function () {
|
10913 | timeoutHandler(self,
|
10914 | self._timestamp,
|
10915 | self._delay,
|
10916 | self._duration,
|
10917 | self._currentState,
|
10918 | self._originalState,
|
10919 | self._targetState,
|
10920 | self._easing,
|
10921 | self._step,
|
10922 | self._scheduleFunction
|
10923 | );
|
10924 | };
|
10925 |
|
10926 |
|
10927 | var currentState = this._currentState;
|
10928 | var targetState = this._targetState;
|
10929 |
|
10930 |
|
10931 | defaults(targetState, currentState);
|
10932 |
|
10933 | this._easing = composeEasingObject(
|
10934 | currentState, config.easing || DEFAULT_EASING);
|
10935 |
|
10936 | this._filterArgs =
|
10937 | [currentState, this._originalState, targetState, this._easing];
|
10938 |
|
10939 | applyFilter(this, 'tweenCreated');
|
10940 | return this;
|
10941 | };
|
10942 |
|
10943 | |
10944 |
|
10945 |
|
10946 |
|
10947 | NGTweenable.prototype.get = function () {
|
10948 | return shallowCopy({}, this._currentState);
|
10949 | };
|
10950 |
|
10951 | |
10952 |
|
10953 |
|
10954 |
|
10955 | NGTweenable.prototype.set = function (state) {
|
10956 | this._currentState = state;
|
10957 | };
|
10958 |
|
10959 | |
10960 |
|
10961 |
|
10962 |
|
10963 |
|
10964 |
|
10965 |
|
10966 |
|
10967 | NGTweenable.prototype.pause = function () {
|
10968 | this._pausedAtTime = now();
|
10969 | this._isPaused = true;
|
10970 | return this;
|
10971 | };
|
10972 |
|
10973 | |
10974 |
|
10975 |
|
10976 |
|
10977 |
|
10978 | NGTweenable.prototype.resume = function () {
|
10979 | if (this._isPaused) {
|
10980 | this._timestamp += now() - this._pausedAtTime;
|
10981 | }
|
10982 |
|
10983 | this._isPaused = false;
|
10984 | this._isTweening = true;
|
10985 |
|
10986 | this._timeoutHandler();
|
10987 |
|
10988 | return this;
|
10989 | };
|
10990 |
|
10991 | |
10992 |
|
10993 |
|
10994 |
|
10995 |
|
10996 |
|
10997 |
|
10998 |
|
10999 |
|
11000 | NGTweenable.prototype.seek = function (millisecond) {
|
11001 | millisecond = Math.max(millisecond, 0);
|
11002 | var currentTime = now();
|
11003 |
|
11004 | if ((this._timestamp + millisecond) === 0) {
|
11005 | return this;
|
11006 | }
|
11007 |
|
11008 | this._timestamp = currentTime - millisecond;
|
11009 |
|
11010 | if (!this.isPlaying()) {
|
11011 | this._isTweening = true;
|
11012 | this._isPaused = false;
|
11013 |
|
11014 |
|
11015 |
|
11016 | timeoutHandler(this,
|
11017 | this._timestamp,
|
11018 | this._delay,
|
11019 | this._duration,
|
11020 | this._currentState,
|
11021 | this._originalState,
|
11022 | this._targetState,
|
11023 | this._easing,
|
11024 | this._step,
|
11025 | this._scheduleFunction,
|
11026 | currentTime
|
11027 | );
|
11028 |
|
11029 | this.pause();
|
11030 | }
|
11031 |
|
11032 | return this;
|
11033 | };
|
11034 |
|
11035 | |
11036 |
|
11037 |
|
11038 |
|
11039 |
|
11040 |
|
11041 |
|
11042 |
|
11043 |
|
11044 | NGTweenable.prototype.stop = function (gotoEnd) {
|
11045 | this._isTweening = false;
|
11046 | this._isPaused = false;
|
11047 | this._timeoutHandler = noop;
|
11048 |
|
11049 | (root.cancelAnimationFrame ||
|
11050 | root.webkitCancelAnimationFrame ||
|
11051 | root.oCancelAnimationFrame ||
|
11052 | root.msCancelAnimationFrame ||
|
11053 | root.mozCancelRequestAnimationFrame ||
|
11054 | root.clearTimeout)(this._scheduleId);
|
11055 |
|
11056 | if (gotoEnd) {
|
11057 | applyFilter(this, 'beforeTween');
|
11058 | tweenProps(
|
11059 | 1,
|
11060 | this._currentState,
|
11061 | this._originalState,
|
11062 | this._targetState,
|
11063 | 1,
|
11064 | 0,
|
11065 | this._easing
|
11066 | );
|
11067 | applyFilter(this, 'afterTween');
|
11068 | applyFilter(this, 'afterTweenEnd');
|
11069 | this._finish.call(this, this._currentState, this._attachment);
|
11070 | }
|
11071 |
|
11072 | return this;
|
11073 | };
|
11074 |
|
11075 | |
11076 |
|
11077 |
|
11078 |
|
11079 | NGTweenable.prototype.isPlaying = function () {
|
11080 | return this._isTweening && !this._isPaused;
|
11081 | };
|
11082 |
|
11083 | |
11084 |
|
11085 |
|
11086 |
|
11087 |
|
11088 |
|
11089 |
|
11090 |
|
11091 |
|
11092 |
|
11093 |
|
11094 |
|
11095 | NGTweenable.prototype.setScheduleFunction = function (scheduleFunction) {
|
11096 | this._scheduleFunction = scheduleFunction;
|
11097 | };
|
11098 |
|
11099 | |
11100 |
|
11101 |
|
11102 |
|
11103 |
|
11104 | NGTweenable.prototype.dispose = function () {
|
11105 | var prop;
|
11106 | for (prop in this) {
|
11107 | if (this.hasOwnProperty(prop)) {
|
11108 | delete this[prop];
|
11109 | }
|
11110 | }
|
11111 | };
|
11112 |
|
11113 | |
11114 |
|
11115 |
|
11116 |
|
11117 |
|
11118 | NGTweenable.prototype.filter = {};
|
11119 |
|
11120 | |
11121 |
|
11122 |
|
11123 |
|
11124 |
|
11125 |
|
11126 |
|
11127 |
|
11128 |
|
11129 | NGTweenable.prototype.formula = {
|
11130 | linear: function (pos) {
|
11131 | return pos;
|
11132 | }
|
11133 | };
|
11134 |
|
11135 | formula = NGTweenable.prototype.formula;
|
11136 |
|
11137 | shallowCopy(NGTweenable, {
|
11138 | 'now': now
|
11139 | ,'each': each
|
11140 | ,'tweenProps': tweenProps
|
11141 | ,'tweenProp': tweenProp
|
11142 | ,'applyFilter': applyFilter
|
11143 | ,'shallowCopy': shallowCopy
|
11144 | ,'defaults': defaults
|
11145 | ,'composeEasingObject': composeEasingObject
|
11146 | });
|
11147 |
|
11148 |
|
11149 |
|
11150 |
|
11151 | if (typeof SHIFTY_DEBUG_NOW === 'function') {
|
11152 | root.timeoutHandler = timeoutHandler;
|
11153 | }
|
11154 |
|
11155 |
|
11156 | if (typeof exports === 'object') {
|
11157 |
|
11158 | module.exports = NGTweenable;
|
11159 | } else if (typeof define === 'function' && define.amdDISABLED) {
|
11160 |
|
11161 | define(function () {return NGTweenable;});
|
11162 | } else if (typeof root.NGTweenable === 'undefined') {
|
11163 |
|
11164 | root.NGTweenable = NGTweenable;
|
11165 | }
|
11166 |
|
11167 | return NGTweenable;
|
11168 |
|
11169 | } ());
|
11170 |
|
11171 |
|
11172 |
|
11173 |
|
11174 |
|
11175 |
|
11176 |
|
11177 |
|
11178 |
|
11179 |
|
11180 |
|
11181 |
|
11182 |
|
11183 |
|
11184 |
|
11185 |
|
11186 | ;(function () {
|
11187 |
|
11188 | NGTweenable.shallowCopy(NGTweenable.prototype.formula, {
|
11189 | easeInQuad: function (pos) {
|
11190 | return Math.pow(pos, 2);
|
11191 | },
|
11192 |
|
11193 | easeOutQuad: function (pos) {
|
11194 | return -(Math.pow((pos - 1), 2) - 1);
|
11195 | },
|
11196 |
|
11197 | easeInOutQuad: function (pos) {
|
11198 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,2);}
|
11199 | return -0.5 * ((pos -= 2) * pos - 2);
|
11200 | },
|
11201 |
|
11202 | easeInCubic: function (pos) {
|
11203 | return Math.pow(pos, 3);
|
11204 | },
|
11205 |
|
11206 | easeOutCubic: function (pos) {
|
11207 | return (Math.pow((pos - 1), 3) + 1);
|
11208 | },
|
11209 |
|
11210 | easeInOutCubic: function (pos) {
|
11211 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,3);}
|
11212 | return 0.5 * (Math.pow((pos - 2),3) + 2);
|
11213 | },
|
11214 |
|
11215 | easeInQuart: function (pos) {
|
11216 | return Math.pow(pos, 4);
|
11217 | },
|
11218 |
|
11219 | easeOutQuart: function (pos) {
|
11220 | return -(Math.pow((pos - 1), 4) - 1);
|
11221 | },
|
11222 |
|
11223 | easeInOutQuart: function (pos) {
|
11224 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,4);}
|
11225 | return -0.5 * ((pos -= 2) * Math.pow(pos,3) - 2);
|
11226 | },
|
11227 |
|
11228 | easeInQuint: function (pos) {
|
11229 | return Math.pow(pos, 5);
|
11230 | },
|
11231 |
|
11232 | easeOutQuint: function (pos) {
|
11233 | return (Math.pow((pos - 1), 5) + 1);
|
11234 | },
|
11235 |
|
11236 | easeInOutQuint: function (pos) {
|
11237 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,5);}
|
11238 | return 0.5 * (Math.pow((pos - 2),5) + 2);
|
11239 | },
|
11240 |
|
11241 | easeInSine: function (pos) {
|
11242 | return -Math.cos(pos * (Math.PI / 2)) + 1;
|
11243 | },
|
11244 |
|
11245 | easeOutSine: function (pos) {
|
11246 | return Math.sin(pos * (Math.PI / 2));
|
11247 | },
|
11248 |
|
11249 | easeInOutSine: function (pos) {
|
11250 | return (-0.5 * (Math.cos(Math.PI * pos) - 1));
|
11251 | },
|
11252 |
|
11253 | easeInExpo: function (pos) {
|
11254 | return (pos === 0) ? 0 : Math.pow(2, 10 * (pos - 1));
|
11255 | },
|
11256 |
|
11257 | easeOutExpo: function (pos) {
|
11258 | return (pos === 1) ? 1 : -Math.pow(2, -10 * pos) + 1;
|
11259 | },
|
11260 |
|
11261 | easeInOutExpo: function (pos) {
|
11262 | if (pos === 0) {return 0;}
|
11263 | if (pos === 1) {return 1;}
|
11264 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(2,10 * (pos - 1));}
|
11265 | return 0.5 * (-Math.pow(2, -10 * --pos) + 2);
|
11266 | },
|
11267 |
|
11268 | easeInCirc: function (pos) {
|
11269 | return -(Math.sqrt(1 - (pos * pos)) - 1);
|
11270 | },
|
11271 |
|
11272 | easeOutCirc: function (pos) {
|
11273 | return Math.sqrt(1 - Math.pow((pos - 1), 2));
|
11274 | },
|
11275 |
|
11276 | easeInOutCirc: function (pos) {
|
11277 | if ((pos /= 0.5) < 1) {return -0.5 * (Math.sqrt(1 - pos * pos) - 1);}
|
11278 | return 0.5 * (Math.sqrt(1 - (pos -= 2) * pos) + 1);
|
11279 | },
|
11280 |
|
11281 | easeOutBounce: function (pos) {
|
11282 | if ((pos) < (1 / 2.75)) {
|
11283 | return (7.5625 * pos * pos);
|
11284 | } else if (pos < (2 / 2.75)) {
|
11285 | return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
|
11286 | } else if (pos < (2.5 / 2.75)) {
|
11287 | return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
|
11288 | } else {
|
11289 | return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
|
11290 | }
|
11291 | },
|
11292 |
|
11293 | easeInBack: function (pos) {
|
11294 | var s = 1.70158;
|
11295 | return (pos) * pos * ((s + 1) * pos - s);
|
11296 | },
|
11297 |
|
11298 | easeOutBack: function (pos) {
|
11299 | var s = 1.70158;
|
11300 | return (pos = pos - 1) * pos * ((s + 1) * pos + s) + 1;
|
11301 | },
|
11302 |
|
11303 | easeInOutBack: function (pos) {
|
11304 | var s = 1.70158;
|
11305 | if ((pos /= 0.5) < 1) {
|
11306 | return 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s));
|
11307 | }
|
11308 | return 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
|
11309 | },
|
11310 |
|
11311 | elastic: function (pos) {
|
11312 |
|
11313 | return -1 * Math.pow(4,-8 * pos) * Math.sin((pos * 6 - 1) * (2 * Math.PI) / 2) + 1;
|
11314 | },
|
11315 |
|
11316 | swingFromTo: function (pos) {
|
11317 | var s = 1.70158;
|
11318 | return ((pos /= 0.5) < 1) ?
|
11319 | 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s)) :
|
11320 | 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
|
11321 | },
|
11322 |
|
11323 | swingFrom: function (pos) {
|
11324 | var s = 1.70158;
|
11325 | return pos * pos * ((s + 1) * pos - s);
|
11326 | },
|
11327 |
|
11328 | swingTo: function (pos) {
|
11329 | var s = 1.70158;
|
11330 | return (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
|
11331 | },
|
11332 |
|
11333 | bounce: function (pos) {
|
11334 | if (pos < (1 / 2.75)) {
|
11335 | return (7.5625 * pos * pos);
|
11336 | } else if (pos < (2 / 2.75)) {
|
11337 | return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
|
11338 | } else if (pos < (2.5 / 2.75)) {
|
11339 | return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
|
11340 | } else {
|
11341 | return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
|
11342 | }
|
11343 | },
|
11344 |
|
11345 | bouncePast: function (pos) {
|
11346 | if (pos < (1 / 2.75)) {
|
11347 | return (7.5625 * pos * pos);
|
11348 | } else if (pos < (2 / 2.75)) {
|
11349 | return 2 - (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
|
11350 | } else if (pos < (2.5 / 2.75)) {
|
11351 | return 2 - (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
|
11352 | } else {
|
11353 | return 2 - (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
|
11354 | }
|
11355 | },
|
11356 |
|
11357 | easeFromTo: function (pos) {
|
11358 | if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,4);}
|
11359 | return -0.5 * ((pos -= 2) * Math.pow(pos,3) - 2);
|
11360 | },
|
11361 |
|
11362 | easeFrom: function (pos) {
|
11363 | return Math.pow(pos,4);
|
11364 | },
|
11365 |
|
11366 | easeTo: function (pos) {
|
11367 | return Math.pow(pos,0.25);
|
11368 | }
|
11369 | });
|
11370 |
|
11371 | }());
|
11372 |
|
11373 |
|
11374 |
|
11375 |
|
11376 |
|
11377 |
|
11378 |
|
11379 |
|
11380 |
|
11381 |
|
11382 |
|
11383 |
|
11384 |
|
11385 |
|
11386 |
|
11387 |
|
11388 |
|
11389 |
|
11390 |
|
11391 |
|
11392 |
|
11393 |
|
11394 |
|
11395 |
|
11396 |
|
11397 |
|
11398 |
|
11399 |
|
11400 |
|
11401 |
|
11402 |
|
11403 |
|
11404 |
|
11405 |
|
11406 |
|
11407 |
|
11408 |
|
11409 |
|
11410 |
|
11411 | ;(function () {
|
11412 |
|
11413 | function cubicBezierAtTime(t,p1x,p1y,p2x,p2y,duration) {
|
11414 | var ax = 0,bx = 0,cx = 0,ay = 0,by = 0,cy = 0;
|
11415 | function sampleCurveX(t) {
|
11416 | return ((ax * t + bx) * t + cx) * t;
|
11417 | }
|
11418 | function sampleCurveY(t) {
|
11419 | return ((ay * t + by) * t + cy) * t;
|
11420 | }
|
11421 | function sampleCurveDerivativeX(t) {
|
11422 | return (3.0 * ax * t + 2.0 * bx) * t + cx;
|
11423 | }
|
11424 | function solveEpsilon(duration) {
|
11425 | return 1.0 / (200.0 * duration);
|
11426 | }
|
11427 | function solve(x,epsilon) {
|
11428 | return sampleCurveY(solveCurveX(x, epsilon));
|
11429 | }
|
11430 | function fabs(n) {
|
11431 | if (n >= 0) {
|
11432 | return n;
|
11433 | } else {
|
11434 | return 0 - n;
|
11435 | }
|
11436 | }
|
11437 | function solveCurveX(x, epsilon) {
|
11438 | var t0,t1,t2,x2,d2,i;
|
11439 | for (t2 = x, i = 0; i < 8; i++) {
|
11440 | x2 = sampleCurveX(t2) - x;
|
11441 | if (fabs(x2) < epsilon) {
|
11442 | return t2;
|
11443 | }
|
11444 | d2 = sampleCurveDerivativeX(t2);
|
11445 | if (fabs(d2) < 1e-6) {
|
11446 | break;
|
11447 | }
|
11448 | t2 = t2 - x2 / d2;
|
11449 | }
|
11450 | t0 = 0.0;
|
11451 | t1 = 1.0;
|
11452 | t2 = x;
|
11453 | if (t2 < t0) {
|
11454 | return t0;
|
11455 | }
|
11456 | if (t2 > t1) {
|
11457 | return t1;
|
11458 | }
|
11459 | while (t0 < t1) {
|
11460 | x2 = sampleCurveX(t2);
|
11461 | if (fabs(x2 - x) < epsilon) {
|
11462 | return t2;
|
11463 | }
|
11464 | if (x > x2) {
|
11465 | t0 = t2;
|
11466 | }else {
|
11467 | t1 = t2;
|
11468 | }
|
11469 | t2 = (t1 - t0) * 0.5 + t0;
|
11470 | }
|
11471 | return t2;
|
11472 | }
|
11473 | cx = 3.0 * p1x;
|
11474 | bx = 3.0 * (p2x - p1x) - cx;
|
11475 | ax = 1.0 - cx - bx;
|
11476 | cy = 3.0 * p1y;
|
11477 | by = 3.0 * (p2y - p1y) - cy;
|
11478 | ay = 1.0 - cy - by;
|
11479 | return solve(t, solveEpsilon(duration));
|
11480 | }
|
11481 | |
11482 |
|
11483 |
|
11484 |
|
11485 |
|
11486 |
|
11487 |
|
11488 |
|
11489 |
|
11490 |
|
11491 |
|
11492 |
|
11493 |
|
11494 |
|
11495 |
|
11496 |
|
11497 |
|
11498 | function getCubicBezierTransition (x1, y1, x2, y2) {
|
11499 | return function (pos) {
|
11500 | return cubicBezierAtTime(pos,x1,y1,x2,y2,1);
|
11501 | };
|
11502 | }
|
11503 |
|
11504 |
|
11505 | |
11506 |
|
11507 |
|
11508 |
|
11509 |
|
11510 |
|
11511 |
|
11512 |
|
11513 |
|
11514 |
|
11515 |
|
11516 |
|
11517 |
|
11518 |
|
11519 |
|
11520 |
|
11521 |
|
11522 |
|
11523 | NGTweenable.setBezierFunction = function (name, x1, y1, x2, y2) {
|
11524 | var cubicBezierTransition = getCubicBezierTransition(x1, y1, x2, y2);
|
11525 | cubicBezierTransition.displayName = name;
|
11526 | cubicBezierTransition.x1 = x1;
|
11527 | cubicBezierTransition.y1 = y1;
|
11528 | cubicBezierTransition.x2 = x2;
|
11529 | cubicBezierTransition.y2 = y2;
|
11530 |
|
11531 | return NGTweenable.prototype.formula[name] = cubicBezierTransition;
|
11532 | };
|
11533 |
|
11534 |
|
11535 | |
11536 |
|
11537 |
|
11538 |
|
11539 |
|
11540 |
|
11541 |
|
11542 |
|
11543 |
|
11544 | NGTweenable.unsetBezierFunction = function (name) {
|
11545 | delete NGTweenable.prototype.formula[name];
|
11546 | };
|
11547 |
|
11548 | })();
|
11549 |
|
11550 | ;(function () {
|
11551 |
|
11552 | function getInterpolatedValues (
|
11553 | from, current, targetState, position, easing, delay) {
|
11554 | return NGTweenable.tweenProps(
|
11555 | position, current, from, targetState, 1, delay, easing);
|
11556 | }
|
11557 |
|
11558 |
|
11559 |
|
11560 |
|
11561 | var mockNGTweenable = new NGTweenable();
|
11562 | mockNGTweenable._filterArgs = [];
|
11563 |
|
11564 | |
11565 |
|
11566 |
|
11567 |
|
11568 |
|
11569 |
|
11570 |
|
11571 |
|
11572 |
|
11573 |
|
11574 |
|
11575 |
|
11576 |
|
11577 |
|
11578 |
|
11579 |
|
11580 |
|
11581 |
|
11582 |
|
11583 |
|
11584 |
|
11585 |
|
11586 |
|
11587 |
|
11588 |
|
11589 |
|
11590 |
|
11591 |
|
11592 |
|
11593 |
|
11594 |
|
11595 |
|
11596 |
|
11597 |
|
11598 |
|
11599 |
|
11600 | NGTweenable.interpolate = function (
|
11601 | from, targetState, position, easing, opt_delay) {
|
11602 |
|
11603 | var current = NGTweenable.shallowCopy({}, from);
|
11604 | var delay = opt_delay || 0;
|
11605 | var easingObject = NGTweenable.composeEasingObject(
|
11606 | from, easing || 'linear');
|
11607 |
|
11608 | mockNGTweenable.set({});
|
11609 |
|
11610 |
|
11611 | var filterArgs = mockNGTweenable._filterArgs;
|
11612 | filterArgs.length = 0;
|
11613 | filterArgs[0] = current;
|
11614 | filterArgs[1] = from;
|
11615 | filterArgs[2] = targetState;
|
11616 | filterArgs[3] = easingObject;
|
11617 |
|
11618 |
|
11619 | NGTweenable.applyFilter(mockNGTweenable, 'tweenCreated');
|
11620 | NGTweenable.applyFilter(mockNGTweenable, 'beforeTween');
|
11621 |
|
11622 | var interpolatedValues = getInterpolatedValues(
|
11623 | from, current, targetState, position, easingObject, delay);
|
11624 |
|
11625 |
|
11626 | NGTweenable.applyFilter(mockNGTweenable, 'afterTween');
|
11627 |
|
11628 | return interpolatedValues;
|
11629 | };
|
11630 |
|
11631 | }());
|
11632 |
|
11633 |
|
11634 |
|
11635 |
|
11636 |
|
11637 |
|
11638 |
|
11639 |
|
11640 |
|
11641 |
|
11642 |
|
11643 |
|
11644 |
|
11645 |
|
11646 |
|
11647 |
|
11648 |
|
11649 |
|
11650 |
|
11651 |
|
11652 |
|
11653 |
|
11654 |
|
11655 |
|
11656 |
|
11657 |
|
11658 |
|
11659 |
|
11660 |
|
11661 |
|
11662 |
|
11663 |
|
11664 |
|
11665 |
|
11666 |
|
11667 |
|
11668 |
|
11669 |
|
11670 |
|
11671 |
|
11672 |
|
11673 |
|
11674 |
|
11675 |
|
11676 |
|
11677 |
|
11678 |
|
11679 |
|
11680 |
|
11681 |
|
11682 |
|
11683 |
|
11684 |
|
11685 |
|
11686 |
|
11687 |
|
11688 |
|
11689 |
|
11690 |
|
11691 |
|
11692 |
|
11693 |
|
11694 |
|
11695 |
|
11696 |
|
11697 |
|
11698 |
|
11699 |
|
11700 |
|
11701 |
|
11702 |
|
11703 |
|
11704 |
|
11705 |
|
11706 |
|
11707 |
|
11708 |
|
11709 |
|
11710 |
|
11711 |
|
11712 |
|
11713 |
|
11714 |
|
11715 |
|
11716 |
|
11717 |
|
11718 |
|
11719 |
|
11720 |
|
11721 |
|
11722 |
|
11723 |
|
11724 |
|
11725 |
|
11726 |
|
11727 |
|
11728 |
|
11729 |
|
11730 |
|
11731 |
|
11732 |
|
11733 |
|
11734 |
|
11735 |
|
11736 |
|
11737 |
|
11738 |
|
11739 |
|
11740 |
|
11741 |
|
11742 |
|
11743 |
|
11744 |
|
11745 |
|
11746 |
|
11747 |
|
11748 |
|
11749 |
|
11750 |
|
11751 |
|
11752 |
|
11753 |
|
11754 |
|
11755 |
|
11756 |
|
11757 |
|
11758 |
|
11759 |
|
11760 |
|
11761 |
|
11762 |
|
11763 |
|
11764 |
|
11765 |
|
11766 |
|
11767 |
|
11768 |
|
11769 | ;(function (NGTweenable) {
|
11770 |
|
11771 | |
11772 |
|
11773 |
|
11774 |
|
11775 |
|
11776 |
|
11777 |
|
11778 | var formatManifest;
|
11779 |
|
11780 |
|
11781 |
|
11782 | var R_NUMBER_COMPONENT = /(\d|\-|\.)/;
|
11783 | var R_FORMAT_CHUNKS = /([^\-0-9\.]+)/g;
|
11784 | var R_UNFORMATTED_VALUES = /[0-9.\-]+/g;
|
11785 | var R_RGB = new RegExp(
|
11786 | 'rgb\\(' + R_UNFORMATTED_VALUES.source +
|
11787 | (/,\s*/.source) + R_UNFORMATTED_VALUES.source +
|
11788 | (/,\s*/.source) + R_UNFORMATTED_VALUES.source + '\\)', 'g');
|
11789 | var R_RGB_PREFIX = /^.*\(/;
|
11790 | var R_HEX = /#([0-9]|[a-f]){3,6}/gi;
|
11791 | var VALUE_PLACEHOLDER = 'VAL';
|
11792 |
|
11793 |
|
11794 |
|
11795 | |
11796 |
|
11797 |
|
11798 |
|
11799 |
|
11800 |
|
11801 |
|
11802 | function getFormatChunksFrom (rawValues, prefix) {
|
11803 | var accumulator = [];
|
11804 |
|
11805 | var rawValuesLength = rawValues.length;
|
11806 | var i;
|
11807 |
|
11808 | for (i = 0; i < rawValuesLength; i++) {
|
11809 | accumulator.push('_' + prefix + '_' + i);
|
11810 | }
|
11811 |
|
11812 | return accumulator;
|
11813 | }
|
11814 |
|
11815 | |
11816 |
|
11817 |
|
11818 |
|
11819 |
|
11820 |
|
11821 | function getFormatStringFrom (formattedString) {
|
11822 | var chunks = formattedString.match(R_FORMAT_CHUNKS);
|
11823 |
|
11824 | if (!chunks) {
|
11825 |
|
11826 |
|
11827 |
|
11828 | chunks = ['', ''];
|
11829 |
|
11830 |
|
11831 |
|
11832 |
|
11833 | } else if (chunks.length === 1 ||
|
11834 |
|
11835 |
|
11836 | formattedString.charAt(0).match(R_NUMBER_COMPONENT)) {
|
11837 |
|
11838 |
|
11839 | chunks.unshift('');
|
11840 | }
|
11841 |
|
11842 | return chunks.join(VALUE_PLACEHOLDER);
|
11843 | }
|
11844 |
|
11845 | |
11846 |
|
11847 |
|
11848 |
|
11849 |
|
11850 |
|
11851 |
|
11852 |
|
11853 | function sanitizeObjectForHexProps (stateObject) {
|
11854 | NGTweenable.each(stateObject, function (prop) {
|
11855 | var currentProp = stateObject[prop];
|
11856 |
|
11857 | if (typeof currentProp === 'string' && currentProp.match(R_HEX)) {
|
11858 | stateObject[prop] = sanitizeHexChunksToRGB(currentProp);
|
11859 | }
|
11860 | });
|
11861 | }
|
11862 |
|
11863 | |
11864 |
|
11865 |
|
11866 |
|
11867 |
|
11868 |
|
11869 | function sanitizeHexChunksToRGB (str) {
|
11870 | return filterStringChunks(R_HEX, str, convertHexToRGB);
|
11871 | }
|
11872 |
|
11873 | |
11874 |
|
11875 |
|
11876 |
|
11877 |
|
11878 |
|
11879 | function convertHexToRGB (hexString) {
|
11880 | var rgbArr = hexToRGBArray(hexString);
|
11881 | return 'rgb(' + rgbArr[0] + ',' + rgbArr[1] + ',' + rgbArr[2] + ')';
|
11882 | }
|
11883 |
|
11884 | var hexToRGBArray_returnArray = [];
|
11885 | |
11886 |
|
11887 |
|
11888 |
|
11889 |
|
11890 |
|
11891 |
|
11892 |
|
11893 |
|
11894 |
|
11895 | function hexToRGBArray (hex) {
|
11896 |
|
11897 | hex = hex.replace(/#/, '');
|
11898 |
|
11899 |
|
11900 |
|
11901 | if (hex.length === 3) {
|
11902 | hex = hex.split('');
|
11903 | hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
11904 | }
|
11905 |
|
11906 | hexToRGBArray_returnArray[0] = hexToDec(hex.substr(0, 2));
|
11907 | hexToRGBArray_returnArray[1] = hexToDec(hex.substr(2, 2));
|
11908 | hexToRGBArray_returnArray[2] = hexToDec(hex.substr(4, 2));
|
11909 |
|
11910 | return hexToRGBArray_returnArray;
|
11911 | }
|
11912 |
|
11913 | |
11914 |
|
11915 |
|
11916 |
|
11917 |
|
11918 |
|
11919 |
|
11920 |
|
11921 | function hexToDec (hex) {
|
11922 | return parseInt(hex, 16);
|
11923 | }
|
11924 |
|
11925 | |
11926 |
|
11927 |
|
11928 |
|
11929 |
|
11930 |
|
11931 |
|
11932 |
|
11933 |
|
11934 |
|
11935 | function filterStringChunks (pattern, unfilteredString, filter) {
|
11936 | var pattenMatches = unfilteredString.match(pattern);
|
11937 | var filteredString = unfilteredString.replace(pattern, VALUE_PLACEHOLDER);
|
11938 |
|
11939 | if (pattenMatches) {
|
11940 | var pattenMatchesLength = pattenMatches.length;
|
11941 | var currentChunk;
|
11942 |
|
11943 | for (var i = 0; i < pattenMatchesLength; i++) {
|
11944 | currentChunk = pattenMatches.shift();
|
11945 | filteredString = filteredString.replace(
|
11946 | VALUE_PLACEHOLDER, filter(currentChunk));
|
11947 | }
|
11948 | }
|
11949 |
|
11950 | return filteredString;
|
11951 | }
|
11952 |
|
11953 | |
11954 |
|
11955 |
|
11956 |
|
11957 |
|
11958 |
|
11959 |
|
11960 |
|
11961 | function sanitizeRGBChunks (formattedString) {
|
11962 | return filterStringChunks(R_RGB, formattedString, sanitizeRGBChunk);
|
11963 | }
|
11964 |
|
11965 | |
11966 |
|
11967 |
|
11968 |
|
11969 |
|
11970 |
|
11971 | function sanitizeRGBChunk (rgbChunk) {
|
11972 | var numbers = rgbChunk.match(R_UNFORMATTED_VALUES);
|
11973 | var numbersLength = numbers.length;
|
11974 | var sanitizedString = rgbChunk.match(R_RGB_PREFIX)[0];
|
11975 |
|
11976 | for (var i = 0; i < numbersLength; i++) {
|
11977 | sanitizedString += parseInt(numbers[i], 10) + ',';
|
11978 | }
|
11979 |
|
11980 | sanitizedString = sanitizedString.slice(0, -1) + ')';
|
11981 |
|
11982 | return sanitizedString;
|
11983 | }
|
11984 |
|
11985 | |
11986 |
|
11987 |
|
11988 |
|
11989 |
|
11990 |
|
11991 |
|
11992 | function getFormatManifests (stateObject) {
|
11993 | var manifestAccumulator = {};
|
11994 |
|
11995 | NGTweenable.each(stateObject, function (prop) {
|
11996 | var currentProp = stateObject[prop];
|
11997 |
|
11998 | if (typeof currentProp === 'string') {
|
11999 | var rawValues = getValuesFrom(currentProp);
|
12000 |
|
12001 | manifestAccumulator[prop] = {
|
12002 | 'formatString': getFormatStringFrom(currentProp)
|
12003 | ,'chunkNames': getFormatChunksFrom(rawValues, prop)
|
12004 | };
|
12005 | }
|
12006 | });
|
12007 |
|
12008 | return manifestAccumulator;
|
12009 | }
|
12010 |
|
12011 | |
12012 |
|
12013 |
|
12014 |
|
12015 |
|
12016 | function expandFormattedProperties (stateObject, formatManifests) {
|
12017 | NGTweenable.each(formatManifests, function (prop) {
|
12018 | var currentProp = stateObject[prop];
|
12019 | var rawValues = getValuesFrom(currentProp);
|
12020 | var rawValuesLength = rawValues.length;
|
12021 |
|
12022 | for (var i = 0; i < rawValuesLength; i++) {
|
12023 | stateObject[formatManifests[prop].chunkNames[i]] = +rawValues[i];
|
12024 | }
|
12025 |
|
12026 | delete stateObject[prop];
|
12027 | });
|
12028 | }
|
12029 |
|
12030 | |
12031 |
|
12032 |
|
12033 |
|
12034 |
|
12035 | function collapseFormattedProperties (stateObject, formatManifests) {
|
12036 | NGTweenable.each(formatManifests, function (prop) {
|
12037 | var currentProp = stateObject[prop];
|
12038 | var formatChunks = extractPropertyChunks(
|
12039 | stateObject, formatManifests[prop].chunkNames);
|
12040 | var valuesList = getValuesList(
|
12041 | formatChunks, formatManifests[prop].chunkNames);
|
12042 | currentProp = getFormattedValues(
|
12043 | formatManifests[prop].formatString, valuesList);
|
12044 | stateObject[prop] = sanitizeRGBChunks(currentProp);
|
12045 | });
|
12046 | }
|
12047 |
|
12048 | |
12049 |
|
12050 |
|
12051 |
|
12052 |
|
12053 |
|
12054 |
|
12055 | function extractPropertyChunks (stateObject, chunkNames) {
|
12056 | var extractedValues = {};
|
12057 | var currentChunkName, chunkNamesLength = chunkNames.length;
|
12058 |
|
12059 | for (var i = 0; i < chunkNamesLength; i++) {
|
12060 | currentChunkName = chunkNames[i];
|
12061 | extractedValues[currentChunkName] = stateObject[currentChunkName];
|
12062 | delete stateObject[currentChunkName];
|
12063 | }
|
12064 |
|
12065 | return extractedValues;
|
12066 | }
|
12067 |
|
12068 | var getValuesList_accumulator = [];
|
12069 | |
12070 |
|
12071 |
|
12072 |
|
12073 |
|
12074 |
|
12075 |
|
12076 | function getValuesList (stateObject, chunkNames) {
|
12077 | getValuesList_accumulator.length = 0;
|
12078 | var chunkNamesLength = chunkNames.length;
|
12079 |
|
12080 | for (var i = 0; i < chunkNamesLength; i++) {
|
12081 | getValuesList_accumulator.push(stateObject[chunkNames[i]]);
|
12082 | }
|
12083 |
|
12084 | return getValuesList_accumulator;
|
12085 | }
|
12086 |
|
12087 | |
12088 |
|
12089 |
|
12090 |
|
12091 |
|
12092 |
|
12093 |
|
12094 | function getFormattedValues (formatString, rawValues) {
|
12095 | var formattedValueString = formatString;
|
12096 | var rawValuesLength = rawValues.length;
|
12097 |
|
12098 | for (var i = 0; i < rawValuesLength; i++) {
|
12099 | formattedValueString = formattedValueString.replace(
|
12100 | VALUE_PLACEHOLDER, +rawValues[i].toFixed(4));
|
12101 | }
|
12102 |
|
12103 | return formattedValueString;
|
12104 | }
|
12105 |
|
12106 | |
12107 |
|
12108 |
|
12109 |
|
12110 |
|
12111 |
|
12112 |
|
12113 |
|
12114 |
|
12115 | function getValuesFrom (formattedString) {
|
12116 | return formattedString.match(R_UNFORMATTED_VALUES);
|
12117 | }
|
12118 |
|
12119 | |
12120 |
|
12121 |
|
12122 |
|
12123 |
|
12124 | function expandEasingObject (easingObject, tokenData) {
|
12125 | NGTweenable.each(tokenData, function (prop) {
|
12126 | var currentProp = tokenData[prop];
|
12127 | var chunkNames = currentProp.chunkNames;
|
12128 | var chunkLength = chunkNames.length;
|
12129 |
|
12130 | var easing = easingObject[prop];
|
12131 | var i;
|
12132 |
|
12133 | if (typeof easing === 'string') {
|
12134 | var easingChunks = easing.split(' ');
|
12135 | var lastEasingChunk = easingChunks[easingChunks.length - 1];
|
12136 |
|
12137 | for (i = 0; i < chunkLength; i++) {
|
12138 | easingObject[chunkNames[i]] = easingChunks[i] || lastEasingChunk;
|
12139 | }
|
12140 |
|
12141 | } else {
|
12142 | for (i = 0; i < chunkLength; i++) {
|
12143 | easingObject[chunkNames[i]] = easing;
|
12144 | }
|
12145 | }
|
12146 |
|
12147 | delete easingObject[prop];
|
12148 | });
|
12149 | }
|
12150 |
|
12151 | |
12152 |
|
12153 |
|
12154 |
|
12155 |
|
12156 | function collapseEasingObject (easingObject, tokenData) {
|
12157 | NGTweenable.each(tokenData, function (prop) {
|
12158 | var currentProp = tokenData[prop];
|
12159 | var chunkNames = currentProp.chunkNames;
|
12160 | var chunkLength = chunkNames.length;
|
12161 |
|
12162 | var firstEasing = easingObject[chunkNames[0]];
|
12163 | var typeofEasings = typeof firstEasing;
|
12164 |
|
12165 | if (typeofEasings === 'string') {
|
12166 | var composedEasingString = '';
|
12167 |
|
12168 | for (var i = 0; i < chunkLength; i++) {
|
12169 | composedEasingString += ' ' + easingObject[chunkNames[i]];
|
12170 | delete easingObject[chunkNames[i]];
|
12171 | }
|
12172 |
|
12173 | easingObject[prop] = composedEasingString.substr(1);
|
12174 | } else {
|
12175 | easingObject[prop] = firstEasing;
|
12176 | }
|
12177 | });
|
12178 | }
|
12179 |
|
12180 | NGTweenable.prototype.filter.token = {
|
12181 | 'tweenCreated': function (currentState, fromState, toState, easingObject) {
|
12182 | sanitizeObjectForHexProps(currentState);
|
12183 | sanitizeObjectForHexProps(fromState);
|
12184 | sanitizeObjectForHexProps(toState);
|
12185 | this._tokenData = getFormatManifests(currentState);
|
12186 | },
|
12187 |
|
12188 | 'beforeTween': function (currentState, fromState, toState, easingObject) {
|
12189 | expandEasingObject(easingObject, this._tokenData);
|
12190 | expandFormattedProperties(currentState, this._tokenData);
|
12191 | expandFormattedProperties(fromState, this._tokenData);
|
12192 | expandFormattedProperties(toState, this._tokenData);
|
12193 | },
|
12194 |
|
12195 | 'afterTween': function (currentState, fromState, toState, easingObject) {
|
12196 | collapseFormattedProperties(currentState, this._tokenData);
|
12197 | collapseFormattedProperties(fromState, this._tokenData);
|
12198 | collapseFormattedProperties(toState, this._tokenData);
|
12199 | collapseEasingObject(easingObject, this._tokenData);
|
12200 | }
|
12201 | };
|
12202 |
|
12203 | } (NGTweenable));
|
12204 |
|
12205 | }).call(null);
|
12206 |
|
12207 |
|
12208 |
|
12209 |
|
12210 |
|
12211 |
|
12212 |
|
12213 |
|
12214 |
|
12215 |
|
12216 |
|
12217 |
|
12218 |
|
12219 |
|
12220 |
|
12221 |
|
12222 |
|
12223 |
|
12224 |
|
12225 |
|
12226 |
|
12227 |
|
12228 |
|
12229 | (function(window, document, exportName, undefined) {
|
12230 | 'use strict';
|
12231 |
|
12232 | var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
|
12233 | var TEST_ELEMENT = document.createElement('div');
|
12234 |
|
12235 | var TYPE_FUNCTION = 'function';
|
12236 |
|
12237 | var round = Math.round;
|
12238 | var abs = Math.abs;
|
12239 | var now = Date.now;
|
12240 |
|
12241 |
|
12242 |
|
12243 |
|
12244 |
|
12245 |
|
12246 |
|
12247 |
|
12248 | function setTimeoutContext(fn, timeout, context) {
|
12249 | return setTimeout(bindFn(fn, context), timeout);
|
12250 | }
|
12251 |
|
12252 |
|
12253 |
|
12254 |
|
12255 |
|
12256 |
|
12257 |
|
12258 |
|
12259 |
|
12260 |
|
12261 | function invokeArrayArg(arg, fn, context) {
|
12262 | if (Array.isArray(arg)) {
|
12263 | each(arg, context[fn], context);
|
12264 | return true;
|
12265 | }
|
12266 | return false;
|
12267 | }
|
12268 |
|
12269 |
|
12270 |
|
12271 |
|
12272 |
|
12273 |
|
12274 |
|
12275 | function each(obj, iterator, context) {
|
12276 | var i;
|
12277 |
|
12278 | if (!obj) {
|
12279 | return;
|
12280 | }
|
12281 |
|
12282 | if (obj.forEach) {
|
12283 | obj.forEach(iterator, context);
|
12284 | } else if (obj.length !== undefined) {
|
12285 | i = 0;
|
12286 | while (i < obj.length) {
|
12287 | iterator.call(context, obj[i], i, obj);
|
12288 | i++;
|
12289 | }
|
12290 | } else {
|
12291 | for (i in obj) {
|
12292 | obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
|
12293 | }
|
12294 | }
|
12295 | }
|
12296 |
|
12297 |
|
12298 |
|
12299 |
|
12300 |
|
12301 |
|
12302 |
|
12303 |
|
12304 | function deprecate(method, name, message) {
|
12305 | var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
|
12306 | return function() {
|
12307 | var e = new Error('get-stack-trace');
|
12308 | var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '')
|
12309 | .replace(/^\s+at\s+/gm, '')
|
12310 | .replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';
|
12311 |
|
12312 | var log = window.console && (window.console.warn || window.console.log);
|
12313 | if (log) {
|
12314 | log.call(window.console, deprecationMessage, stack);
|
12315 | }
|
12316 | return method.apply(this, arguments);
|
12317 | };
|
12318 | }
|
12319 |
|
12320 |
|
12321 |
|
12322 |
|
12323 |
|
12324 |
|
12325 |
|
12326 |
|
12327 | var assign;
|
12328 | if (typeof Object.assign !== 'function') {
|
12329 | assign = function assign(target) {
|
12330 | if (target === undefined || target === null) {
|
12331 | throw new TypeError('Cannot convert undefined or null to object');
|
12332 | }
|
12333 |
|
12334 | var output = Object(target);
|
12335 | for (var index = 1; index < arguments.length; index++) {
|
12336 | var source = arguments[index];
|
12337 | if (source !== undefined && source !== null) {
|
12338 | for (var nextKey in source) {
|
12339 | if (source.hasOwnProperty(nextKey)) {
|
12340 | output[nextKey] = source[nextKey];
|
12341 | }
|
12342 | }
|
12343 | }
|
12344 | }
|
12345 | return output;
|
12346 | };
|
12347 | } else {
|
12348 | assign = Object.assign;
|
12349 | }
|
12350 |
|
12351 |
|
12352 |
|
12353 |
|
12354 |
|
12355 |
|
12356 |
|
12357 |
|
12358 |
|
12359 | var extend = deprecate(function extend(dest, src, merge) {
|
12360 | var keys = Object.keys(src);
|
12361 | var i = 0;
|
12362 | while (i < keys.length) {
|
12363 | if (!merge || (merge && dest[keys[i]] === undefined)) {
|
12364 | dest[keys[i]] = src[keys[i]];
|
12365 | }
|
12366 | i++;
|
12367 | }
|
12368 | return dest;
|
12369 | }, 'extend', 'Use `assign`.');
|
12370 |
|
12371 |
|
12372 |
|
12373 |
|
12374 |
|
12375 |
|
12376 |
|
12377 |
|
12378 | var merge = deprecate(function merge(dest, src) {
|
12379 | return extend(dest, src, true);
|
12380 | }, 'merge', 'Use `assign`.');
|
12381 |
|
12382 |
|
12383 |
|
12384 |
|
12385 |
|
12386 |
|
12387 |
|
12388 | function inherit(child, base, properties) {
|
12389 | var baseP = base.prototype,
|
12390 | childP;
|
12391 |
|
12392 | childP = child.prototype = Object.create(baseP);
|
12393 | childP.constructor = child;
|
12394 | childP._super = baseP;
|
12395 |
|
12396 | if (properties) {
|
12397 | assign(childP, properties);
|
12398 | }
|
12399 | }
|
12400 |
|
12401 |
|
12402 |
|
12403 |
|
12404 |
|
12405 |
|
12406 |
|
12407 | function bindFn(fn, context) {
|
12408 | return function boundFn() {
|
12409 | return fn.apply(context, arguments);
|
12410 | };
|
12411 | }
|
12412 |
|
12413 |
|
12414 |
|
12415 |
|
12416 |
|
12417 |
|
12418 |
|
12419 |
|
12420 | function boolOrFn(val, args) {
|
12421 | if (typeof val == TYPE_FUNCTION) {
|
12422 | return val.apply(args ? args[0] || undefined : undefined, args);
|
12423 | }
|
12424 | return val;
|
12425 | }
|
12426 |
|
12427 |
|
12428 |
|
12429 |
|
12430 |
|
12431 |
|
12432 |
|
12433 | function ifUndefined(val1, val2) {
|
12434 | return (val1 === undefined) ? val2 : val1;
|
12435 | }
|
12436 |
|
12437 |
|
12438 |
|
12439 |
|
12440 |
|
12441 |
|
12442 |
|
12443 | function addEventListeners(target, types, handler) {
|
12444 | each(splitStr(types), function(type) {
|
12445 | target.addEventListener(type, handler, false);
|
12446 | });
|
12447 | }
|
12448 |
|
12449 |
|
12450 |
|
12451 |
|
12452 |
|
12453 |
|
12454 |
|
12455 | function removeEventListeners(target, types, handler) {
|
12456 | each(splitStr(types), function(type) {
|
12457 | target.removeEventListener(type, handler, false);
|
12458 | });
|
12459 | }
|
12460 |
|
12461 |
|
12462 |
|
12463 |
|
12464 |
|
12465 |
|
12466 |
|
12467 |
|
12468 | function hasParent(node, parent) {
|
12469 | while (node) {
|
12470 | if (node == parent) {
|
12471 | return true;
|
12472 | }
|
12473 | node = node.parentNode;
|
12474 | }
|
12475 | return false;
|
12476 | }
|
12477 |
|
12478 |
|
12479 |
|
12480 |
|
12481 |
|
12482 |
|
12483 |
|
12484 | function inStr(str, find) {
|
12485 | return str.indexOf(find) > -1;
|
12486 | }
|
12487 |
|
12488 |
|
12489 |
|
12490 |
|
12491 |
|
12492 |
|
12493 | function splitStr(str) {
|
12494 | return str.trim().split(/\s+/g);
|
12495 | }
|
12496 |
|
12497 |
|
12498 |
|
12499 |
|
12500 |
|
12501 |
|
12502 |
|
12503 |
|
12504 | function inArray(src, find, findByKey) {
|
12505 | if (src.indexOf && !findByKey) {
|
12506 | return src.indexOf(find);
|
12507 | } else {
|
12508 | var i = 0;
|
12509 | while (i < src.length) {
|
12510 | if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
|
12511 | return i;
|
12512 | }
|
12513 | i++;
|
12514 | }
|
12515 | return -1;
|
12516 | }
|
12517 | }
|
12518 |
|
12519 |
|
12520 |
|
12521 |
|
12522 |
|
12523 |
|
12524 | function toArray(obj) {
|
12525 | return Array.prototype.slice.call(obj, 0);
|
12526 | }
|
12527 |
|
12528 |
|
12529 |
|
12530 |
|
12531 |
|
12532 |
|
12533 |
|
12534 |
|
12535 | function uniqueArray(src, key, sort) {
|
12536 | var results = [];
|
12537 | var values = [];
|
12538 | var i = 0;
|
12539 |
|
12540 | while (i < src.length) {
|
12541 | var val = key ? src[i][key] : src[i];
|
12542 | if (inArray(values, val) < 0) {
|
12543 | results.push(src[i]);
|
12544 | }
|
12545 | values[i] = val;
|
12546 | i++;
|
12547 | }
|
12548 |
|
12549 | if (sort) {
|
12550 | if (!key) {
|
12551 | results = results.sort();
|
12552 | } else {
|
12553 | results = results.sort(function sortUniqueArray(a, b) {
|
12554 | return a[key] > b[key];
|
12555 | });
|
12556 | }
|
12557 | }
|
12558 |
|
12559 | return results;
|
12560 | }
|
12561 |
|
12562 |
|
12563 |
|
12564 |
|
12565 |
|
12566 |
|
12567 |
|
12568 | function prefixed(obj, property) {
|
12569 | var prefix, prop;
|
12570 | var camelProp = property[0].toUpperCase() + property.slice(1);
|
12571 |
|
12572 | var i = 0;
|
12573 | while (i < VENDOR_PREFIXES.length) {
|
12574 | prefix = VENDOR_PREFIXES[i];
|
12575 | prop = (prefix) ? prefix + camelProp : property;
|
12576 |
|
12577 | if (prop in obj) {
|
12578 | return prop;
|
12579 | }
|
12580 | i++;
|
12581 | }
|
12582 | return undefined;
|
12583 | }
|
12584 |
|
12585 |
|
12586 |
|
12587 |
|
12588 |
|
12589 | var _uniqueId = 1;
|
12590 | function uniqueId() {
|
12591 | return _uniqueId++;
|
12592 | }
|
12593 |
|
12594 |
|
12595 |
|
12596 |
|
12597 |
|
12598 |
|
12599 | function getWindowForElement(element) {
|
12600 | var doc = element.ownerDocument || element;
|
12601 | return (doc.defaultView || doc.parentWindow || window);
|
12602 | }
|
12603 |
|
12604 | var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
12605 |
|
12606 | var SUPPORT_TOUCH = ('ontouchstart' in window);
|
12607 |
|
12608 | var SUPPORT_POINTER_EVENTS = false;
|
12609 | var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
12610 |
|
12611 | var INPUT_TYPE_TOUCH = 'touch';
|
12612 | var INPUT_TYPE_PEN = 'pen';
|
12613 | var INPUT_TYPE_MOUSE = 'mouse';
|
12614 | var INPUT_TYPE_KINECT = 'kinect';
|
12615 |
|
12616 | var COMPUTE_INTERVAL = 25;
|
12617 |
|
12618 | var INPUT_START = 1;
|
12619 | var INPUT_MOVE = 2;
|
12620 | var INPUT_END = 4;
|
12621 | var INPUT_CANCEL = 8;
|
12622 |
|
12623 | var DIRECTION_NONE = 1;
|
12624 | var DIRECTION_LEFT = 2;
|
12625 | var DIRECTION_RIGHT = 4;
|
12626 | var DIRECTION_UP = 8;
|
12627 | var DIRECTION_DOWN = 16;
|
12628 |
|
12629 | var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
12630 | var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
12631 | var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
12632 |
|
12633 | var PROPS_XY = ['x', 'y'];
|
12634 | var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
12635 |
|
12636 |
|
12637 |
|
12638 |
|
12639 |
|
12640 |
|
12641 |
|
12642 |
|
12643 | function Input(manager, callback) {
|
12644 | var self = this;
|
12645 | this.manager = manager;
|
12646 | this.callback = callback;
|
12647 | this.element = manager.element;
|
12648 | this.target = manager.options.inputTarget;
|
12649 |
|
12650 |
|
12651 |
|
12652 | this.domHandler = function(ev) {
|
12653 | if (boolOrFn(manager.options.enable, [manager])) {
|
12654 | self.handler(ev);
|
12655 | }
|
12656 | };
|
12657 |
|
12658 | this.init();
|
12659 |
|
12660 | }
|
12661 |
|
12662 | Input.prototype = {
|
12663 | |
12664 |
|
12665 |
|
12666 |
|
12667 | handler: function() { },
|
12668 |
|
12669 | |
12670 |
|
12671 |
|
12672 | init: function() {
|
12673 | this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
|
12674 | this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
|
12675 | this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
12676 | },
|
12677 |
|
12678 | |
12679 |
|
12680 |
|
12681 | destroy: function() {
|
12682 | this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
|
12683 | this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
12684 | this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
12685 | }
|
12686 | };
|
12687 |
|
12688 |
|
12689 |
|
12690 |
|
12691 |
|
12692 |
|
12693 |
|
12694 | function createInputInstance(manager) {
|
12695 | var Type;
|
12696 | var inputClass = manager.options.inputClass;
|
12697 |
|
12698 | if (inputClass) {
|
12699 | Type = inputClass;
|
12700 | } else if (SUPPORT_POINTER_EVENTS) {
|
12701 | Type = PointerEventInput;
|
12702 | } else if (SUPPORT_ONLY_TOUCH) {
|
12703 | Type = TouchInput;
|
12704 | } else if (!SUPPORT_TOUCH) {
|
12705 | Type = MouseInput;
|
12706 | } else {
|
12707 | Type = TouchMouseInput;
|
12708 | }
|
12709 | return new (Type)(manager, inputHandler);
|
12710 | }
|
12711 |
|
12712 |
|
12713 |
|
12714 |
|
12715 |
|
12716 |
|
12717 |
|
12718 | function inputHandler(manager, eventType, input) {
|
12719 | var pointersLen = input.pointers.length;
|
12720 | var changedPointersLen = input.changedPointers.length;
|
12721 | var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
|
12722 | var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - changedPointersLen === 0));
|
12723 |
|
12724 | input.isFirst = !!isFirst;
|
12725 | input.isFinal = !!isFinal;
|
12726 |
|
12727 | if (isFirst) {
|
12728 | manager.session = {};
|
12729 | }
|
12730 |
|
12731 |
|
12732 |
|
12733 | input.eventType = eventType;
|
12734 |
|
12735 |
|
12736 | computeInputData(manager, input);
|
12737 |
|
12738 |
|
12739 | manager.emit('hammer.input', input);
|
12740 |
|
12741 | manager.recognize(input);
|
12742 | manager.session.prevInput = input;
|
12743 | }
|
12744 |
|
12745 |
|
12746 |
|
12747 |
|
12748 |
|
12749 |
|
12750 | function computeInputData(manager, input) {
|
12751 | var session = manager.session;
|
12752 | var pointers = input.pointers;
|
12753 | var pointersLength = pointers.length;
|
12754 |
|
12755 |
|
12756 | if (!session.firstInput) {
|
12757 | session.firstInput = simpleCloneInputData(input);
|
12758 | }
|
12759 |
|
12760 |
|
12761 | if (pointersLength > 1 && !session.firstMultiple) {
|
12762 | session.firstMultiple = simpleCloneInputData(input);
|
12763 | } else if (pointersLength === 1) {
|
12764 | session.firstMultiple = false;
|
12765 | }
|
12766 |
|
12767 | var firstInput = session.firstInput;
|
12768 | var firstMultiple = session.firstMultiple;
|
12769 | var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
|
12770 |
|
12771 | var center = input.center = getCenter(pointers);
|
12772 | input.timeStamp = now();
|
12773 | input.deltaTime = input.timeStamp - firstInput.timeStamp;
|
12774 |
|
12775 | input.angle = getAngle(offsetCenter, center);
|
12776 | input.distance = getDistance(offsetCenter, center);
|
12777 |
|
12778 | computeDeltaXY(session, input);
|
12779 | input.offsetDirection = getDirection(input.deltaX, input.deltaY);
|
12780 |
|
12781 | var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
|
12782 | input.overallVelocityX = overallVelocity.x;
|
12783 | input.overallVelocityY = overallVelocity.y;
|
12784 | input.overallVelocity = (abs(overallVelocity.x) > abs(overallVelocity.y)) ? overallVelocity.x : overallVelocity.y;
|
12785 |
|
12786 | input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
|
12787 | input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
|
12788 |
|
12789 | input.maxPointers = !session.prevInput ? input.pointers.length : ((input.pointers.length >
|
12790 | session.prevInput.maxPointers) ? input.pointers.length : session.prevInput.maxPointers);
|
12791 |
|
12792 | computeIntervalInputData(session, input);
|
12793 |
|
12794 |
|
12795 | var target = manager.element;
|
12796 | if (hasParent(input.srcEvent.target, target)) {
|
12797 | target = input.srcEvent.target;
|
12798 | }
|
12799 | input.target = target;
|
12800 | }
|
12801 |
|
12802 | function computeDeltaXY(session, input) {
|
12803 | var center = input.center;
|
12804 | var offset = session.offsetDelta || {};
|
12805 | var prevDelta = session.prevDelta || {};
|
12806 | var prevInput = session.prevInput || {};
|
12807 |
|
12808 | if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
|
12809 | prevDelta = session.prevDelta = {
|
12810 | x: prevInput.deltaX || 0,
|
12811 | y: prevInput.deltaY || 0
|
12812 | };
|
12813 |
|
12814 | offset = session.offsetDelta = {
|
12815 | x: center.x,
|
12816 | y: center.y
|
12817 | };
|
12818 | }
|
12819 |
|
12820 | input.deltaX = prevDelta.x + (center.x - offset.x);
|
12821 | input.deltaY = prevDelta.y + (center.y - offset.y);
|
12822 | }
|
12823 |
|
12824 |
|
12825 |
|
12826 |
|
12827 |
|
12828 |
|
12829 | function computeIntervalInputData(session, input) {
|
12830 | var last = session.lastInterval || input,
|
12831 | deltaTime = input.timeStamp - last.timeStamp,
|
12832 | velocity, velocityX, velocityY, direction;
|
12833 |
|
12834 | if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
|
12835 | var deltaX = input.deltaX - last.deltaX;
|
12836 | var deltaY = input.deltaY - last.deltaY;
|
12837 |
|
12838 | var v = getVelocity(deltaTime, deltaX, deltaY);
|
12839 | velocityX = v.x;
|
12840 | velocityY = v.y;
|
12841 | velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
|
12842 | direction = getDirection(deltaX, deltaY);
|
12843 |
|
12844 | session.lastInterval = input;
|
12845 | } else {
|
12846 |
|
12847 | velocity = last.velocity;
|
12848 | velocityX = last.velocityX;
|
12849 | velocityY = last.velocityY;
|
12850 | direction = last.direction;
|
12851 | }
|
12852 |
|
12853 | input.velocity = velocity;
|
12854 | input.velocityX = velocityX;
|
12855 | input.velocityY = velocityY;
|
12856 | input.direction = direction;
|
12857 | }
|
12858 |
|
12859 |
|
12860 |
|
12861 |
|
12862 |
|
12863 |
|
12864 | function simpleCloneInputData(input) {
|
12865 |
|
12866 |
|
12867 | var pointers = [];
|
12868 | var i = 0;
|
12869 | while (i < input.pointers.length) {
|
12870 | pointers[i] = {
|
12871 | clientX: round(input.pointers[i].clientX),
|
12872 | clientY: round(input.pointers[i].clientY)
|
12873 | };
|
12874 | i++;
|
12875 | }
|
12876 |
|
12877 | return {
|
12878 | timeStamp: now(),
|
12879 | pointers: pointers,
|
12880 | center: getCenter(pointers),
|
12881 | deltaX: input.deltaX,
|
12882 | deltaY: input.deltaY
|
12883 | };
|
12884 | }
|
12885 |
|
12886 |
|
12887 |
|
12888 |
|
12889 |
|
12890 |
|
12891 | function getCenter(pointers) {
|
12892 | var pointersLength = pointers.length;
|
12893 |
|
12894 |
|
12895 | if (pointersLength === 1) {
|
12896 | return {
|
12897 | x: round(pointers[0].clientX),
|
12898 | y: round(pointers[0].clientY)
|
12899 | };
|
12900 | }
|
12901 |
|
12902 | var x = 0, y = 0, i = 0;
|
12903 | while (i < pointersLength) {
|
12904 | x += pointers[i].clientX;
|
12905 | y += pointers[i].clientY;
|
12906 | i++;
|
12907 | }
|
12908 |
|
12909 | return {
|
12910 | x: round(x / pointersLength),
|
12911 | y: round(y / pointersLength)
|
12912 | };
|
12913 | }
|
12914 |
|
12915 |
|
12916 |
|
12917 |
|
12918 |
|
12919 |
|
12920 |
|
12921 |
|
12922 | function getVelocity(deltaTime, x, y) {
|
12923 | return {
|
12924 | x: x / deltaTime || 0,
|
12925 | y: y / deltaTime || 0
|
12926 | };
|
12927 | }
|
12928 |
|
12929 |
|
12930 |
|
12931 |
|
12932 |
|
12933 |
|
12934 |
|
12935 | function getDirection(x, y) {
|
12936 | if (x === y) {
|
12937 | return DIRECTION_NONE;
|
12938 | }
|
12939 |
|
12940 | if (abs(x) >= abs(y)) {
|
12941 | return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
12942 | }
|
12943 | return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
12944 | }
|
12945 |
|
12946 |
|
12947 |
|
12948 |
|
12949 |
|
12950 |
|
12951 |
|
12952 |
|
12953 | function getDistance(p1, p2, props) {
|
12954 | if (!props) {
|
12955 | props = PROPS_XY;
|
12956 | }
|
12957 | var x = p2[props[0]] - p1[props[0]],
|
12958 | y = p2[props[1]] - p1[props[1]];
|
12959 |
|
12960 | return Math.sqrt((x * x) + (y * y));
|
12961 | }
|
12962 |
|
12963 |
|
12964 |
|
12965 |
|
12966 |
|
12967 |
|
12968 |
|
12969 |
|
12970 | function getAngle(p1, p2, props) {
|
12971 | if (!props) {
|
12972 | props = PROPS_XY;
|
12973 | }
|
12974 | var x = p2[props[0]] - p1[props[0]],
|
12975 | y = p2[props[1]] - p1[props[1]];
|
12976 | return Math.atan2(y, x) * 180 / Math.PI;
|
12977 | }
|
12978 |
|
12979 |
|
12980 |
|
12981 |
|
12982 |
|
12983 |
|
12984 |
|
12985 | function getRotation(start, end) {
|
12986 | return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
12987 | }
|
12988 |
|
12989 |
|
12990 |
|
12991 |
|
12992 |
|
12993 |
|
12994 |
|
12995 |
|
12996 | function getScale(start, end) {
|
12997 | return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
12998 | }
|
12999 |
|
13000 | var MOUSE_INPUT_MAP = {
|
13001 | mousedown: INPUT_START,
|
13002 | mousemove: INPUT_MOVE,
|
13003 | mouseup: INPUT_END
|
13004 | };
|
13005 |
|
13006 | var MOUSE_ELEMENT_EVENTS = 'mousedown';
|
13007 | var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
|
13008 |
|
13009 |
|
13010 |
|
13011 |
|
13012 |
|
13013 |
|
13014 | function MouseInput() {
|
13015 | this.evEl = MOUSE_ELEMENT_EVENTS;
|
13016 | this.evWin = MOUSE_WINDOW_EVENTS;
|
13017 |
|
13018 | this.pressed = false;
|
13019 |
|
13020 | Input.apply(this, arguments);
|
13021 | }
|
13022 |
|
13023 | inherit(MouseInput, Input, {
|
13024 | |
13025 |
|
13026 |
|
13027 |
|
13028 | handler: function MEhandler(ev) {
|
13029 | var eventType = MOUSE_INPUT_MAP[ev.type];
|
13030 |
|
13031 |
|
13032 | if (eventType & INPUT_START && ev.button === 0) {
|
13033 | this.pressed = true;
|
13034 | }
|
13035 |
|
13036 | if (eventType & INPUT_MOVE && ev.which !== 1) {
|
13037 | eventType = INPUT_END;
|
13038 | }
|
13039 |
|
13040 |
|
13041 | if (!this.pressed) {
|
13042 | return;
|
13043 | }
|
13044 |
|
13045 | if (eventType & INPUT_END) {
|
13046 | this.pressed = false;
|
13047 | }
|
13048 |
|
13049 | this.callback(this.manager, eventType, {
|
13050 | pointers: [ev],
|
13051 | changedPointers: [ev],
|
13052 | pointerType: INPUT_TYPE_MOUSE,
|
13053 | srcEvent: ev
|
13054 | });
|
13055 | }
|
13056 | });
|
13057 |
|
13058 | var POINTER_INPUT_MAP = {
|
13059 | pointerdown: INPUT_START,
|
13060 | pointermove: INPUT_MOVE,
|
13061 | pointerup: INPUT_END,
|
13062 | pointercancel: INPUT_CANCEL,
|
13063 | pointerout: INPUT_CANCEL
|
13064 | };
|
13065 |
|
13066 |
|
13067 | var IE10_POINTER_TYPE_ENUM = {
|
13068 | 2: INPUT_TYPE_TOUCH,
|
13069 | 3: INPUT_TYPE_PEN,
|
13070 | 4: INPUT_TYPE_MOUSE,
|
13071 | 5: INPUT_TYPE_KINECT
|
13072 | };
|
13073 |
|
13074 | var POINTER_ELEMENT_EVENTS = 'pointerdown';
|
13075 | var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
|
13076 |
|
13077 |
|
13078 | if (window.MSPointerEvent && !window.PointerEvent) {
|
13079 | POINTER_ELEMENT_EVENTS = 'MSPointerDown';
|
13080 | POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
|
13081 | }
|
13082 |
|
13083 |
|
13084 |
|
13085 |
|
13086 |
|
13087 |
|
13088 | function PointerEventInput() {
|
13089 | this.evEl = POINTER_ELEMENT_EVENTS;
|
13090 | this.evWin = POINTER_WINDOW_EVENTS;
|
13091 |
|
13092 | Input.apply(this, arguments);
|
13093 |
|
13094 | this.store = (this.manager.session.pointerEvents = []);
|
13095 | }
|
13096 |
|
13097 | inherit(PointerEventInput, Input, {
|
13098 | |
13099 |
|
13100 |
|
13101 |
|
13102 | handler: function PEhandler(ev) {
|
13103 | var store = this.store;
|
13104 | var removePointer = false;
|
13105 |
|
13106 | var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
|
13107 | var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
|
13108 | var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
|
13109 |
|
13110 | var isTouch = (pointerType == INPUT_TYPE_TOUCH);
|
13111 |
|
13112 |
|
13113 | var storeIndex = inArray(store, ev.pointerId, 'pointerId');
|
13114 |
|
13115 |
|
13116 | if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
|
13117 | if (storeIndex < 0) {
|
13118 | store.push(ev);
|
13119 | storeIndex = store.length - 1;
|
13120 | }
|
13121 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
13122 | removePointer = true;
|
13123 | }
|
13124 |
|
13125 |
|
13126 | if (storeIndex < 0) {
|
13127 | return;
|
13128 | }
|
13129 |
|
13130 |
|
13131 | store[storeIndex] = ev;
|
13132 |
|
13133 | this.callback(this.manager, eventType, {
|
13134 | pointers: store,
|
13135 | changedPointers: [ev],
|
13136 | pointerType: pointerType,
|
13137 | srcEvent: ev
|
13138 | });
|
13139 |
|
13140 | if (removePointer) {
|
13141 |
|
13142 | store.splice(storeIndex, 1);
|
13143 | }
|
13144 | }
|
13145 | });
|
13146 |
|
13147 | var SINGLE_TOUCH_INPUT_MAP = {
|
13148 | touchstart: INPUT_START,
|
13149 | touchmove: INPUT_MOVE,
|
13150 | touchend: INPUT_END,
|
13151 | touchcancel: INPUT_CANCEL
|
13152 | };
|
13153 |
|
13154 | var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
|
13155 | var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
|
13156 |
|
13157 |
|
13158 |
|
13159 |
|
13160 |
|
13161 |
|
13162 | function SingleTouchInput() {
|
13163 | this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
13164 | this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
13165 | this.started = false;
|
13166 |
|
13167 | Input.apply(this, arguments);
|
13168 | }
|
13169 |
|
13170 | inherit(SingleTouchInput, Input, {
|
13171 | handler: function TEhandler(ev) {
|
13172 | var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
13173 |
|
13174 |
|
13175 | if (type === INPUT_START) {
|
13176 | this.started = true;
|
13177 | }
|
13178 |
|
13179 | if (!this.started) {
|
13180 | return;
|
13181 | }
|
13182 |
|
13183 | var touches = normalizeSingleTouches.call(this, ev, type);
|
13184 |
|
13185 |
|
13186 | if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
|
13187 | this.started = false;
|
13188 | }
|
13189 |
|
13190 | this.callback(this.manager, type, {
|
13191 | pointers: touches[0],
|
13192 | changedPointers: touches[1],
|
13193 | pointerType: INPUT_TYPE_TOUCH,
|
13194 | srcEvent: ev
|
13195 | });
|
13196 | }
|
13197 | });
|
13198 |
|
13199 |
|
13200 |
|
13201 |
|
13202 |
|
13203 |
|
13204 |
|
13205 | function normalizeSingleTouches(ev, type) {
|
13206 | var all = toArray(ev.touches);
|
13207 | var changed = toArray(ev.changedTouches);
|
13208 |
|
13209 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
13210 | all = uniqueArray(all.concat(changed), 'identifier', true);
|
13211 | }
|
13212 |
|
13213 | return [all, changed];
|
13214 | }
|
13215 |
|
13216 | var TOUCH_INPUT_MAP = {
|
13217 | touchstart: INPUT_START,
|
13218 | touchmove: INPUT_MOVE,
|
13219 | touchend: INPUT_END,
|
13220 | touchcancel: INPUT_CANCEL
|
13221 | };
|
13222 |
|
13223 | var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
13224 |
|
13225 |
|
13226 |
|
13227 |
|
13228 |
|
13229 |
|
13230 | function TouchInput() {
|
13231 | this.evTarget = TOUCH_TARGET_EVENTS;
|
13232 | this.targetIds = {};
|
13233 |
|
13234 | Input.apply(this, arguments);
|
13235 | }
|
13236 |
|
13237 | inherit(TouchInput, Input, {
|
13238 | handler: function MTEhandler(ev) {
|
13239 | var type = TOUCH_INPUT_MAP[ev.type];
|
13240 | var touches = getTouches.call(this, ev, type);
|
13241 | if (!touches) {
|
13242 | return;
|
13243 | }
|
13244 |
|
13245 | this.callback(this.manager, type, {
|
13246 | pointers: touches[0],
|
13247 | changedPointers: touches[1],
|
13248 | pointerType: INPUT_TYPE_TOUCH,
|
13249 | srcEvent: ev
|
13250 | });
|
13251 | }
|
13252 | });
|
13253 |
|
13254 |
|
13255 |
|
13256 |
|
13257 |
|
13258 |
|
13259 |
|
13260 | function getTouches(ev, type) {
|
13261 | var allTouches = toArray(ev.touches);
|
13262 | var targetIds = this.targetIds;
|
13263 |
|
13264 |
|
13265 | if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
|
13266 | targetIds[allTouches[0].identifier] = true;
|
13267 | return [allTouches, allTouches];
|
13268 | }
|
13269 |
|
13270 | var i,
|
13271 | targetTouches,
|
13272 | changedTouches = toArray(ev.changedTouches),
|
13273 | changedTargetTouches = [],
|
13274 | target = this.target;
|
13275 |
|
13276 |
|
13277 | targetTouches = allTouches.filter(function(touch) {
|
13278 | return hasParent(touch.target, target);
|
13279 | });
|
13280 |
|
13281 |
|
13282 | if (type === INPUT_START) {
|
13283 | i = 0;
|
13284 | while (i < targetTouches.length) {
|
13285 | targetIds[targetTouches[i].identifier] = true;
|
13286 | i++;
|
13287 | }
|
13288 | }
|
13289 |
|
13290 |
|
13291 | i = 0;
|
13292 | while (i < changedTouches.length) {
|
13293 | if (targetIds[changedTouches[i].identifier]) {
|
13294 | changedTargetTouches.push(changedTouches[i]);
|
13295 | }
|
13296 |
|
13297 |
|
13298 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
13299 | delete targetIds[changedTouches[i].identifier];
|
13300 | }
|
13301 | i++;
|
13302 | }
|
13303 |
|
13304 | if (!changedTargetTouches.length) {
|
13305 | return;
|
13306 | }
|
13307 |
|
13308 | return [
|
13309 |
|
13310 | uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
|
13311 | changedTargetTouches
|
13312 | ];
|
13313 | }
|
13314 |
|
13315 |
|
13316 |
|
13317 |
|
13318 |
|
13319 |
|
13320 |
|
13321 |
|
13322 |
|
13323 |
|
13324 |
|
13325 | var DEDUP_TIMEOUT = 2500;
|
13326 | var DEDUP_DISTANCE = 25;
|
13327 |
|
13328 | function TouchMouseInput() {
|
13329 | Input.apply(this, arguments);
|
13330 |
|
13331 | var handler = bindFn(this.handler, this);
|
13332 | this.touch = new TouchInput(this.manager, handler);
|
13333 | this.mouse = new MouseInput(this.manager, handler);
|
13334 |
|
13335 | this.primaryTouch = null;
|
13336 | this.lastTouches = [];
|
13337 | }
|
13338 |
|
13339 | inherit(TouchMouseInput, Input, {
|
13340 | |
13341 |
|
13342 |
|
13343 |
|
13344 |
|
13345 |
|
13346 | handler: function TMEhandler(manager, inputEvent, inputData) {
|
13347 | var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
|
13348 | isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
|
13349 |
|
13350 | if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
|
13351 | return;
|
13352 | }
|
13353 |
|
13354 |
|
13355 | if (isTouch) {
|
13356 | recordTouches.call(this, inputEvent, inputData);
|
13357 | } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
|
13358 | return;
|
13359 | }
|
13360 |
|
13361 | this.callback(manager, inputEvent, inputData);
|
13362 | },
|
13363 |
|
13364 | |
13365 |
|
13366 |
|
13367 | destroy: function destroy() {
|
13368 | this.touch.destroy();
|
13369 | this.mouse.destroy();
|
13370 | }
|
13371 | });
|
13372 |
|
13373 | function recordTouches(eventType, eventData) {
|
13374 | if (eventType & INPUT_START) {
|
13375 | this.primaryTouch = eventData.changedPointers[0].identifier;
|
13376 | setLastTouch.call(this, eventData);
|
13377 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
13378 | setLastTouch.call(this, eventData);
|
13379 | }
|
13380 | }
|
13381 |
|
13382 | function setLastTouch(eventData) {
|
13383 | var touch = eventData.changedPointers[0];
|
13384 |
|
13385 | if (touch.identifier === this.primaryTouch) {
|
13386 | var lastTouch = {x: touch.clientX, y: touch.clientY};
|
13387 | this.lastTouches.push(lastTouch);
|
13388 | var lts = this.lastTouches;
|
13389 | var removeLastTouch = function() {
|
13390 | var i = lts.indexOf(lastTouch);
|
13391 | if (i > -1) {
|
13392 | lts.splice(i, 1);
|
13393 | }
|
13394 | };
|
13395 | setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
13396 | }
|
13397 | }
|
13398 |
|
13399 | function isSyntheticEvent(eventData) {
|
13400 | var x = eventData.srcEvent.clientX, y = eventData.srcEvent.clientY;
|
13401 | for (var i = 0; i < this.lastTouches.length; i++) {
|
13402 | var t = this.lastTouches[i];
|
13403 | var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y);
|
13404 | if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
|
13405 | return true;
|
13406 | }
|
13407 | }
|
13408 | return false;
|
13409 | }
|
13410 |
|
13411 | var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
|
13412 | var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
|
13413 |
|
13414 |
|
13415 | var TOUCH_ACTION_COMPUTE = 'compute';
|
13416 | var TOUCH_ACTION_AUTO = 'auto';
|
13417 | var TOUCH_ACTION_MANIPULATION = 'manipulation';
|
13418 | var TOUCH_ACTION_NONE = 'none';
|
13419 | var TOUCH_ACTION_PAN_X = 'pan-x';
|
13420 | var TOUCH_ACTION_PAN_Y = 'pan-y';
|
13421 | var TOUCH_ACTION_MAP = getTouchActionProps();
|
13422 |
|
13423 |
|
13424 |
|
13425 |
|
13426 |
|
13427 |
|
13428 |
|
13429 |
|
13430 | function TouchAction(manager, value) {
|
13431 | this.manager = manager;
|
13432 | this.set(value);
|
13433 | }
|
13434 |
|
13435 | TouchAction.prototype = {
|
13436 | |
13437 |
|
13438 |
|
13439 |
|
13440 | set: function(value) {
|
13441 |
|
13442 | if (value == TOUCH_ACTION_COMPUTE) {
|
13443 | value = this.compute();
|
13444 | }
|
13445 |
|
13446 | if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
|
13447 | this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
|
13448 | }
|
13449 | this.actions = value.toLowerCase().trim();
|
13450 | },
|
13451 |
|
13452 | |
13453 |
|
13454 |
|
13455 | update: function() {
|
13456 | this.set(this.manager.options.touchAction);
|
13457 | },
|
13458 |
|
13459 | |
13460 |
|
13461 |
|
13462 |
|
13463 | compute: function() {
|
13464 | var actions = [];
|
13465 | each(this.manager.recognizers, function(recognizer) {
|
13466 | if (boolOrFn(recognizer.options.enable, [recognizer])) {
|
13467 | actions = actions.concat(recognizer.getTouchAction());
|
13468 | }
|
13469 | });
|
13470 | return cleanTouchActions(actions.join(' '));
|
13471 | },
|
13472 |
|
13473 | |
13474 |
|
13475 |
|
13476 |
|
13477 | preventDefaults: function(input) {
|
13478 | var srcEvent = input.srcEvent;
|
13479 | var direction = input.offsetDirection;
|
13480 |
|
13481 |
|
13482 | if (this.manager.session.prevented) {
|
13483 | srcEvent.preventDefault();
|
13484 | return;
|
13485 | }
|
13486 |
|
13487 | var actions = this.actions;
|
13488 | var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
|
13489 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
|
13490 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
|
13491 |
|
13492 | if (hasNone) {
|
13493 |
|
13494 |
|
13495 | var isTapPointer = input.pointers.length === 1;
|
13496 | var isTapMovement = input.distance < 2;
|
13497 | var isTapTouchTime = input.deltaTime < 250;
|
13498 |
|
13499 | if (isTapPointer && isTapMovement && isTapTouchTime) {
|
13500 | return;
|
13501 | }
|
13502 | }
|
13503 |
|
13504 | if (hasPanX && hasPanY) {
|
13505 |
|
13506 | return;
|
13507 | }
|
13508 |
|
13509 | if (hasNone ||
|
13510 | (hasPanY && direction & DIRECTION_HORIZONTAL) ||
|
13511 | (hasPanX && direction & DIRECTION_VERTICAL)) {
|
13512 | return this.preventSrc(srcEvent);
|
13513 | }
|
13514 | },
|
13515 |
|
13516 | |
13517 |
|
13518 |
|
13519 |
|
13520 | preventSrc: function(srcEvent) {
|
13521 | this.manager.session.prevented = true;
|
13522 | srcEvent.preventDefault();
|
13523 | }
|
13524 | };
|
13525 |
|
13526 |
|
13527 |
|
13528 |
|
13529 |
|
13530 |
|
13531 | function cleanTouchActions(actions) {
|
13532 |
|
13533 | if (inStr(actions, TOUCH_ACTION_NONE)) {
|
13534 | return TOUCH_ACTION_NONE;
|
13535 | }
|
13536 |
|
13537 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
|
13538 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
|
13539 |
|
13540 |
|
13541 |
|
13542 |
|
13543 |
|
13544 | if (hasPanX && hasPanY) {
|
13545 | return TOUCH_ACTION_NONE;
|
13546 | }
|
13547 |
|
13548 |
|
13549 | if (hasPanX || hasPanY) {
|
13550 | return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
|
13551 | }
|
13552 |
|
13553 |
|
13554 | if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
|
13555 | return TOUCH_ACTION_MANIPULATION;
|
13556 | }
|
13557 |
|
13558 | return TOUCH_ACTION_AUTO;
|
13559 | }
|
13560 |
|
13561 | function getTouchActionProps() {
|
13562 | if (!NATIVE_TOUCH_ACTION) {
|
13563 | return false;
|
13564 | }
|
13565 | var touchMap = {};
|
13566 | var cssSupports = window.CSS && window.CSS.supports;
|
13567 | ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function(val) {
|
13568 |
|
13569 |
|
13570 |
|
13571 | touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
|
13572 | });
|
13573 | return touchMap;
|
13574 | }
|
13575 |
|
13576 |
|
13577 |
|
13578 |
|
13579 |
|
13580 |
|
13581 |
|
13582 |
|
13583 |
|
13584 |
|
13585 |
|
13586 |
|
13587 |
|
13588 |
|
13589 |
|
13590 |
|
13591 |
|
13592 |
|
13593 |
|
13594 |
|
13595 |
|
13596 |
|
13597 |
|
13598 |
|
13599 |
|
13600 |
|
13601 |
|
13602 |
|
13603 | var STATE_POSSIBLE = 1;
|
13604 | var STATE_BEGAN = 2;
|
13605 | var STATE_CHANGED = 4;
|
13606 | var STATE_ENDED = 8;
|
13607 | var STATE_RECOGNIZED = STATE_ENDED;
|
13608 | var STATE_CANCELLED = 16;
|
13609 | var STATE_FAILED = 32;
|
13610 |
|
13611 |
|
13612 |
|
13613 |
|
13614 |
|
13615 |
|
13616 |
|
13617 | function Recognizer(options) {
|
13618 | this.options = assign({}, this.defaults, options || {});
|
13619 |
|
13620 | this.id = uniqueId();
|
13621 |
|
13622 | this.manager = null;
|
13623 |
|
13624 |
|
13625 | this.options.enable = ifUndefined(this.options.enable, true);
|
13626 |
|
13627 | this.state = STATE_POSSIBLE;
|
13628 |
|
13629 | this.simultaneous = {};
|
13630 | this.requireFail = [];
|
13631 | }
|
13632 |
|
13633 | Recognizer.prototype = {
|
13634 | |
13635 |
|
13636 |
|
13637 |
|
13638 | defaults: {},
|
13639 |
|
13640 | |
13641 |
|
13642 |
|
13643 |
|
13644 |
|
13645 | set: function(options) {
|
13646 | assign(this.options, options);
|
13647 |
|
13648 |
|
13649 | this.manager && this.manager.touchAction.update();
|
13650 | return this;
|
13651 | },
|
13652 |
|
13653 | |
13654 |
|
13655 |
|
13656 |
|
13657 |
|
13658 | recognizeWith: function(otherRecognizer) {
|
13659 | if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
|
13660 | return this;
|
13661 | }
|
13662 |
|
13663 | var simultaneous = this.simultaneous;
|
13664 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
13665 | if (!simultaneous[otherRecognizer.id]) {
|
13666 | simultaneous[otherRecognizer.id] = otherRecognizer;
|
13667 | otherRecognizer.recognizeWith(this);
|
13668 | }
|
13669 | return this;
|
13670 | },
|
13671 |
|
13672 | |
13673 |
|
13674 |
|
13675 |
|
13676 |
|
13677 | dropRecognizeWith: function(otherRecognizer) {
|
13678 | if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
|
13679 | return this;
|
13680 | }
|
13681 |
|
13682 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
13683 | delete this.simultaneous[otherRecognizer.id];
|
13684 | return this;
|
13685 | },
|
13686 |
|
13687 | |
13688 |
|
13689 |
|
13690 |
|
13691 |
|
13692 | requireFailure: function(otherRecognizer) {
|
13693 | if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
|
13694 | return this;
|
13695 | }
|
13696 |
|
13697 | var requireFail = this.requireFail;
|
13698 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
13699 | if (inArray(requireFail, otherRecognizer) === -1) {
|
13700 | requireFail.push(otherRecognizer);
|
13701 | otherRecognizer.requireFailure(this);
|
13702 | }
|
13703 | return this;
|
13704 | },
|
13705 |
|
13706 | |
13707 |
|
13708 |
|
13709 |
|
13710 |
|
13711 | dropRequireFailure: function(otherRecognizer) {
|
13712 | if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
|
13713 | return this;
|
13714 | }
|
13715 |
|
13716 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
13717 | var index = inArray(this.requireFail, otherRecognizer);
|
13718 | if (index > -1) {
|
13719 | this.requireFail.splice(index, 1);
|
13720 | }
|
13721 | return this;
|
13722 | },
|
13723 |
|
13724 | |
13725 |
|
13726 |
|
13727 |
|
13728 | hasRequireFailures: function() {
|
13729 | return this.requireFail.length > 0;
|
13730 | },
|
13731 |
|
13732 | |
13733 |
|
13734 |
|
13735 |
|
13736 |
|
13737 | canRecognizeWith: function(otherRecognizer) {
|
13738 | return !!this.simultaneous[otherRecognizer.id];
|
13739 | },
|
13740 |
|
13741 | |
13742 |
|
13743 |
|
13744 |
|
13745 |
|
13746 | emit: function(input) {
|
13747 | var self = this;
|
13748 | var state = this.state;
|
13749 |
|
13750 | function emit(event) {
|
13751 | self.manager.emit(event, input);
|
13752 | }
|
13753 |
|
13754 |
|
13755 | if (state < STATE_ENDED) {
|
13756 | emit(self.options.event + stateStr(state));
|
13757 | }
|
13758 |
|
13759 | emit(self.options.event);
|
13760 |
|
13761 | if (input.additionalEvent) {
|
13762 | emit(input.additionalEvent);
|
13763 | }
|
13764 |
|
13765 |
|
13766 | if (state >= STATE_ENDED) {
|
13767 | emit(self.options.event + stateStr(state));
|
13768 | }
|
13769 | },
|
13770 |
|
13771 | |
13772 |
|
13773 |
|
13774 |
|
13775 |
|
13776 |
|
13777 | tryEmit: function(input) {
|
13778 | if (this.canEmit()) {
|
13779 | return this.emit(input);
|
13780 | }
|
13781 |
|
13782 | this.state = STATE_FAILED;
|
13783 | },
|
13784 |
|
13785 | |
13786 |
|
13787 |
|
13788 |
|
13789 | canEmit: function() {
|
13790 | var i = 0;
|
13791 | while (i < this.requireFail.length) {
|
13792 | if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
|
13793 | return false;
|
13794 | }
|
13795 | i++;
|
13796 | }
|
13797 | return true;
|
13798 | },
|
13799 |
|
13800 | |
13801 |
|
13802 |
|
13803 |
|
13804 | recognize: function(inputData) {
|
13805 |
|
13806 |
|
13807 | var inputDataClone = assign({}, inputData);
|
13808 |
|
13809 |
|
13810 | if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
|
13811 | this.reset();
|
13812 | this.state = STATE_FAILED;
|
13813 | return;
|
13814 | }
|
13815 |
|
13816 |
|
13817 | if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
|
13818 | this.state = STATE_POSSIBLE;
|
13819 | }
|
13820 |
|
13821 | this.state = this.process(inputDataClone);
|
13822 |
|
13823 |
|
13824 |
|
13825 | if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
|
13826 | this.tryEmit(inputDataClone);
|
13827 | }
|
13828 | },
|
13829 |
|
13830 | |
13831 |
|
13832 |
|
13833 |
|
13834 |
|
13835 |
|
13836 |
|
13837 | process: function(inputData) { },
|
13838 |
|
13839 | |
13840 |
|
13841 |
|
13842 |
|
13843 |
|
13844 | getTouchAction: function() { },
|
13845 |
|
13846 | |
13847 |
|
13848 |
|
13849 |
|
13850 |
|
13851 | reset: function() { }
|
13852 | };
|
13853 |
|
13854 |
|
13855 |
|
13856 |
|
13857 |
|
13858 |
|
13859 | function stateStr(state) {
|
13860 | if (state & STATE_CANCELLED) {
|
13861 | return 'cancel';
|
13862 | } else if (state & STATE_ENDED) {
|
13863 | return 'end';
|
13864 | } else if (state & STATE_CHANGED) {
|
13865 | return 'move';
|
13866 | } else if (state & STATE_BEGAN) {
|
13867 | return 'start';
|
13868 | }
|
13869 | return '';
|
13870 | }
|
13871 |
|
13872 |
|
13873 |
|
13874 |
|
13875 |
|
13876 |
|
13877 | function directionStr(direction) {
|
13878 | if (direction == DIRECTION_DOWN) {
|
13879 | return 'down';
|
13880 | } else if (direction == DIRECTION_UP) {
|
13881 | return 'up';
|
13882 | } else if (direction == DIRECTION_LEFT) {
|
13883 | return 'left';
|
13884 | } else if (direction == DIRECTION_RIGHT) {
|
13885 | return 'right';
|
13886 | }
|
13887 | return '';
|
13888 | }
|
13889 |
|
13890 |
|
13891 |
|
13892 |
|
13893 |
|
13894 |
|
13895 |
|
13896 | function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
13897 | var manager = recognizer.manager;
|
13898 | if (manager) {
|
13899 | return manager.get(otherRecognizer);
|
13900 | }
|
13901 | return otherRecognizer;
|
13902 | }
|
13903 |
|
13904 |
|
13905 |
|
13906 |
|
13907 |
|
13908 |
|
13909 | function AttrRecognizer() {
|
13910 | Recognizer.apply(this, arguments);
|
13911 | }
|
13912 |
|
13913 | inherit(AttrRecognizer, Recognizer, {
|
13914 | |
13915 |
|
13916 |
|
13917 |
|
13918 | defaults: {
|
13919 | |
13920 |
|
13921 |
|
13922 |
|
13923 | pointers: 1
|
13924 | },
|
13925 |
|
13926 | |
13927 |
|
13928 |
|
13929 |
|
13930 |
|
13931 |
|
13932 | attrTest: function(input) {
|
13933 | var optionPointers = this.options.pointers;
|
13934 | return optionPointers === 0 || input.pointers.length === optionPointers;
|
13935 | },
|
13936 |
|
13937 | |
13938 |
|
13939 |
|
13940 |
|
13941 |
|
13942 |
|
13943 | process: function(input) {
|
13944 | var state = this.state;
|
13945 | var eventType = input.eventType;
|
13946 |
|
13947 | var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
|
13948 | var isValid = this.attrTest(input);
|
13949 |
|
13950 |
|
13951 | if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
|
13952 | return state | STATE_CANCELLED;
|
13953 | } else if (isRecognized || isValid) {
|
13954 | if (eventType & INPUT_END) {
|
13955 | return state | STATE_ENDED;
|
13956 | } else if (!(state & STATE_BEGAN)) {
|
13957 | return STATE_BEGAN;
|
13958 | }
|
13959 | return state | STATE_CHANGED;
|
13960 | }
|
13961 | return STATE_FAILED;
|
13962 | }
|
13963 | });
|
13964 |
|
13965 |
|
13966 |
|
13967 |
|
13968 |
|
13969 |
|
13970 |
|
13971 | function PanRecognizer() {
|
13972 | AttrRecognizer.apply(this, arguments);
|
13973 |
|
13974 | this.pX = null;
|
13975 | this.pY = null;
|
13976 | }
|
13977 |
|
13978 | inherit(PanRecognizer, AttrRecognizer, {
|
13979 | |
13980 |
|
13981 |
|
13982 |
|
13983 | defaults: {
|
13984 | event: 'pan',
|
13985 | threshold: 10,
|
13986 | pointers: 1,
|
13987 | direction: DIRECTION_ALL
|
13988 | },
|
13989 |
|
13990 | getTouchAction: function() {
|
13991 | var direction = this.options.direction;
|
13992 | var actions = [];
|
13993 | if (direction & DIRECTION_HORIZONTAL) {
|
13994 | actions.push(TOUCH_ACTION_PAN_Y);
|
13995 | }
|
13996 | if (direction & DIRECTION_VERTICAL) {
|
13997 | actions.push(TOUCH_ACTION_PAN_X);
|
13998 | }
|
13999 | return actions;
|
14000 | },
|
14001 |
|
14002 | directionTest: function(input) {
|
14003 | var options = this.options;
|
14004 | var hasMoved = true;
|
14005 | var distance = input.distance;
|
14006 | var direction = input.direction;
|
14007 | var x = input.deltaX;
|
14008 | var y = input.deltaY;
|
14009 |
|
14010 |
|
14011 | if (!(direction & options.direction)) {
|
14012 | if (options.direction & DIRECTION_HORIZONTAL) {
|
14013 | direction = (x === 0) ? DIRECTION_NONE : (x < 0) ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
14014 | hasMoved = x != this.pX;
|
14015 | distance = Math.abs(input.deltaX);
|
14016 | } else {
|
14017 | direction = (y === 0) ? DIRECTION_NONE : (y < 0) ? DIRECTION_UP : DIRECTION_DOWN;
|
14018 | hasMoved = y != this.pY;
|
14019 | distance = Math.abs(input.deltaY);
|
14020 | }
|
14021 | }
|
14022 | input.direction = direction;
|
14023 | return hasMoved && distance > options.threshold && direction & options.direction;
|
14024 | },
|
14025 |
|
14026 | attrTest: function(input) {
|
14027 | return AttrRecognizer.prototype.attrTest.call(this, input) &&
|
14028 | (this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input)));
|
14029 | },
|
14030 |
|
14031 | emit: function(input) {
|
14032 |
|
14033 | this.pX = input.deltaX;
|
14034 | this.pY = input.deltaY;
|
14035 |
|
14036 | var direction = directionStr(input.direction);
|
14037 |
|
14038 | if (direction) {
|
14039 | input.additionalEvent = this.options.event + direction;
|
14040 | }
|
14041 | this._super.emit.call(this, input);
|
14042 | }
|
14043 | });
|
14044 |
|
14045 |
|
14046 |
|
14047 |
|
14048 |
|
14049 |
|
14050 |
|
14051 | function PinchRecognizer() {
|
14052 | AttrRecognizer.apply(this, arguments);
|
14053 | }
|
14054 |
|
14055 | inherit(PinchRecognizer, AttrRecognizer, {
|
14056 | |
14057 |
|
14058 |
|
14059 |
|
14060 | defaults: {
|
14061 | event: 'pinch',
|
14062 | threshold: 0,
|
14063 | pointers: 2
|
14064 | },
|
14065 |
|
14066 | getTouchAction: function() {
|
14067 | return [TOUCH_ACTION_NONE];
|
14068 | },
|
14069 |
|
14070 | attrTest: function(input) {
|
14071 | return this._super.attrTest.call(this, input) &&
|
14072 | (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
|
14073 | },
|
14074 |
|
14075 | emit: function(input) {
|
14076 | if (input.scale !== 1) {
|
14077 | var inOut = input.scale < 1 ? 'in' : 'out';
|
14078 | input.additionalEvent = this.options.event + inOut;
|
14079 | }
|
14080 | this._super.emit.call(this, input);
|
14081 | }
|
14082 | });
|
14083 |
|
14084 |
|
14085 |
|
14086 |
|
14087 |
|
14088 |
|
14089 |
|
14090 | function PressRecognizer() {
|
14091 | Recognizer.apply(this, arguments);
|
14092 |
|
14093 | this._timer = null;
|
14094 | this._input = null;
|
14095 | }
|
14096 |
|
14097 | inherit(PressRecognizer, Recognizer, {
|
14098 | |
14099 |
|
14100 |
|
14101 |
|
14102 | defaults: {
|
14103 | event: 'press',
|
14104 | pointers: 1,
|
14105 | time: 251,
|
14106 | threshold: 9
|
14107 | },
|
14108 |
|
14109 | getTouchAction: function() {
|
14110 | return [TOUCH_ACTION_AUTO];
|
14111 | },
|
14112 |
|
14113 | process: function(input) {
|
14114 | var options = this.options;
|
14115 | var validPointers = input.pointers.length === options.pointers;
|
14116 | var validMovement = input.distance < options.threshold;
|
14117 | var validTime = input.deltaTime > options.time;
|
14118 |
|
14119 | this._input = input;
|
14120 |
|
14121 |
|
14122 |
|
14123 | if (!validMovement || !validPointers || (input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime)) {
|
14124 | this.reset();
|
14125 | } else if (input.eventType & INPUT_START) {
|
14126 | this.reset();
|
14127 | this._timer = setTimeoutContext(function() {
|
14128 | this.state = STATE_RECOGNIZED;
|
14129 | this.tryEmit();
|
14130 | }, options.time, this);
|
14131 | } else if (input.eventType & INPUT_END) {
|
14132 | return STATE_RECOGNIZED;
|
14133 | }
|
14134 | return STATE_FAILED;
|
14135 | },
|
14136 |
|
14137 | reset: function() {
|
14138 | clearTimeout(this._timer);
|
14139 | },
|
14140 |
|
14141 | emit: function(input) {
|
14142 | if (this.state !== STATE_RECOGNIZED) {
|
14143 | return;
|
14144 | }
|
14145 |
|
14146 | if (input && (input.eventType & INPUT_END)) {
|
14147 | this.manager.emit(this.options.event + 'up', input);
|
14148 | } else {
|
14149 | this._input.timeStamp = now();
|
14150 | this.manager.emit(this.options.event, this._input);
|
14151 | }
|
14152 | }
|
14153 | });
|
14154 |
|
14155 |
|
14156 |
|
14157 |
|
14158 |
|
14159 |
|
14160 |
|
14161 | function RotateRecognizer() {
|
14162 | AttrRecognizer.apply(this, arguments);
|
14163 | }
|
14164 |
|
14165 | inherit(RotateRecognizer, AttrRecognizer, {
|
14166 | |
14167 |
|
14168 |
|
14169 |
|
14170 | defaults: {
|
14171 | event: 'rotate',
|
14172 | threshold: 0,
|
14173 | pointers: 2
|
14174 | },
|
14175 |
|
14176 | getTouchAction: function() {
|
14177 | return [TOUCH_ACTION_NONE];
|
14178 | },
|
14179 |
|
14180 | attrTest: function(input) {
|
14181 | return this._super.attrTest.call(this, input) &&
|
14182 | (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
14183 | }
|
14184 | });
|
14185 |
|
14186 |
|
14187 |
|
14188 |
|
14189 |
|
14190 |
|
14191 |
|
14192 | function SwipeRecognizer() {
|
14193 | AttrRecognizer.apply(this, arguments);
|
14194 | }
|
14195 |
|
14196 | inherit(SwipeRecognizer, AttrRecognizer, {
|
14197 | |
14198 |
|
14199 |
|
14200 |
|
14201 | defaults: {
|
14202 | event: 'swipe',
|
14203 | threshold: 10,
|
14204 | velocity: 0.3,
|
14205 | direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
|
14206 | pointers: 1
|
14207 | },
|
14208 |
|
14209 | getTouchAction: function() {
|
14210 | return PanRecognizer.prototype.getTouchAction.call(this);
|
14211 | },
|
14212 |
|
14213 | attrTest: function(input) {
|
14214 | var direction = this.options.direction;
|
14215 | var velocity;
|
14216 |
|
14217 | if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
14218 | velocity = input.overallVelocity;
|
14219 | } else if (direction & DIRECTION_HORIZONTAL) {
|
14220 | velocity = input.overallVelocityX;
|
14221 | } else if (direction & DIRECTION_VERTICAL) {
|
14222 | velocity = input.overallVelocityY;
|
14223 | }
|
14224 |
|
14225 | return this._super.attrTest.call(this, input) &&
|
14226 | direction & input.offsetDirection &&
|
14227 | input.distance > this.options.threshold &&
|
14228 | input.maxPointers == this.options.pointers &&
|
14229 | abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
|
14230 | },
|
14231 |
|
14232 | emit: function(input) {
|
14233 | var direction = directionStr(input.offsetDirection);
|
14234 | if (direction) {
|
14235 | this.manager.emit(this.options.event + direction, input);
|
14236 | }
|
14237 |
|
14238 | this.manager.emit(this.options.event, input);
|
14239 | }
|
14240 | });
|
14241 |
|
14242 |
|
14243 |
|
14244 |
|
14245 |
|
14246 |
|
14247 |
|
14248 |
|
14249 |
|
14250 |
|
14251 |
|
14252 | function TapRecognizer() {
|
14253 | Recognizer.apply(this, arguments);
|
14254 |
|
14255 |
|
14256 |
|
14257 | this.pTime = false;
|
14258 | this.pCenter = false;
|
14259 |
|
14260 | this._timer = null;
|
14261 | this._input = null;
|
14262 | this.count = 0;
|
14263 | }
|
14264 |
|
14265 | inherit(TapRecognizer, Recognizer, {
|
14266 | |
14267 |
|
14268 |
|
14269 |
|
14270 | defaults: {
|
14271 | event: 'tap',
|
14272 | pointers: 1,
|
14273 | taps: 1,
|
14274 | interval: 300,
|
14275 | time: 250,
|
14276 | threshold: 9,
|
14277 | posThreshold: 10
|
14278 | },
|
14279 |
|
14280 | getTouchAction: function() {
|
14281 | return [TOUCH_ACTION_MANIPULATION];
|
14282 | },
|
14283 |
|
14284 | process: function(input) {
|
14285 | var options = this.options;
|
14286 |
|
14287 | var validPointers = input.pointers.length === options.pointers;
|
14288 | var validMovement = input.distance < options.threshold;
|
14289 | var validTouchTime = input.deltaTime < options.time;
|
14290 |
|
14291 | this.reset();
|
14292 |
|
14293 | if ((input.eventType & INPUT_START) && (this.count === 0)) {
|
14294 | return this.failTimeout();
|
14295 | }
|
14296 |
|
14297 |
|
14298 |
|
14299 | if (validMovement && validTouchTime && validPointers) {
|
14300 | if (input.eventType != INPUT_END) {
|
14301 | return this.failTimeout();
|
14302 | }
|
14303 |
|
14304 | var validInterval = this.pTime ? (input.timeStamp - this.pTime < options.interval) : true;
|
14305 | var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
|
14306 |
|
14307 | this.pTime = input.timeStamp;
|
14308 | this.pCenter = input.center;
|
14309 |
|
14310 | if (!validMultiTap || !validInterval) {
|
14311 | this.count = 1;
|
14312 | } else {
|
14313 | this.count += 1;
|
14314 | }
|
14315 |
|
14316 | this._input = input;
|
14317 |
|
14318 |
|
14319 |
|
14320 | var tapCount = this.count % options.taps;
|
14321 | if (tapCount === 0) {
|
14322 |
|
14323 |
|
14324 | if (!this.hasRequireFailures()) {
|
14325 | return STATE_RECOGNIZED;
|
14326 | } else {
|
14327 | this._timer = setTimeoutContext(function() {
|
14328 | this.state = STATE_RECOGNIZED;
|
14329 | this.tryEmit();
|
14330 | }, options.interval, this);
|
14331 | return STATE_BEGAN;
|
14332 | }
|
14333 | }
|
14334 | }
|
14335 | return STATE_FAILED;
|
14336 | },
|
14337 |
|
14338 | failTimeout: function() {
|
14339 | this._timer = setTimeoutContext(function() {
|
14340 | this.state = STATE_FAILED;
|
14341 | }, this.options.interval, this);
|
14342 | return STATE_FAILED;
|
14343 | },
|
14344 |
|
14345 | reset: function() {
|
14346 | clearTimeout(this._timer);
|
14347 | },
|
14348 |
|
14349 | emit: function() {
|
14350 | if (this.state == STATE_RECOGNIZED) {
|
14351 | this._input.tapCount = this.count;
|
14352 | this.manager.emit(this.options.event, this._input);
|
14353 | }
|
14354 | }
|
14355 | });
|
14356 |
|
14357 |
|
14358 |
|
14359 |
|
14360 |
|
14361 |
|
14362 |
|
14363 | function NGHammer(element, options) {
|
14364 | options = options || {};
|
14365 | options.recognizers = ifUndefined(options.recognizers, NGHammer.defaults.preset);
|
14366 | return new Manager(element, options);
|
14367 | }
|
14368 |
|
14369 |
|
14370 |
|
14371 |
|
14372 | NGHammer.VERSION = '2.0.7';
|
14373 |
|
14374 |
|
14375 |
|
14376 |
|
14377 |
|
14378 | NGHammer.defaults = {
|
14379 | |
14380 |
|
14381 |
|
14382 |
|
14383 |
|
14384 |
|
14385 | domEvents: false,
|
14386 |
|
14387 | |
14388 |
|
14389 |
|
14390 |
|
14391 |
|
14392 |
|
14393 | touchAction: TOUCH_ACTION_COMPUTE,
|
14394 |
|
14395 | |
14396 |
|
14397 |
|
14398 |
|
14399 | enable: true,
|
14400 |
|
14401 | |
14402 |
|
14403 |
|
14404 |
|
14405 |
|
14406 |
|
14407 |
|
14408 | inputTarget: null,
|
14409 |
|
14410 | |
14411 |
|
14412 |
|
14413 |
|
14414 |
|
14415 | inputClass: null,
|
14416 |
|
14417 | |
14418 |
|
14419 |
|
14420 |
|
14421 |
|
14422 | preset: [
|
14423 |
|
14424 | [RotateRecognizer, {enable: false}],
|
14425 | [PinchRecognizer, {enable: false}, ['rotate']],
|
14426 | [SwipeRecognizer, {direction: DIRECTION_HORIZONTAL}],
|
14427 | [PanRecognizer, {direction: DIRECTION_HORIZONTAL}, ['swipe']],
|
14428 | [TapRecognizer],
|
14429 | [TapRecognizer, {event: 'doubletap', taps: 2}, ['tap']],
|
14430 | [PressRecognizer]
|
14431 | ],
|
14432 |
|
14433 | |
14434 |
|
14435 |
|
14436 |
|
14437 |
|
14438 | cssProps: {
|
14439 | |
14440 |
|
14441 |
|
14442 |
|
14443 |
|
14444 | userSelect: 'none',
|
14445 |
|
14446 | |
14447 |
|
14448 |
|
14449 |
|
14450 |
|
14451 | touchSelect: 'none',
|
14452 |
|
14453 | |
14454 |
|
14455 |
|
14456 |
|
14457 |
|
14458 |
|
14459 |
|
14460 | touchCallout: 'none',
|
14461 |
|
14462 | |
14463 |
|
14464 |
|
14465 |
|
14466 |
|
14467 | contentZooming: 'none',
|
14468 |
|
14469 | |
14470 |
|
14471 |
|
14472 |
|
14473 |
|
14474 | userDrag: 'none',
|
14475 |
|
14476 | |
14477 |
|
14478 |
|
14479 |
|
14480 |
|
14481 |
|
14482 | tapHighlightColor: 'rgba(0,0,0,0)'
|
14483 | }
|
14484 | };
|
14485 |
|
14486 | var STOP = 1;
|
14487 | var FORCED_STOP = 2;
|
14488 |
|
14489 |
|
14490 |
|
14491 |
|
14492 |
|
14493 |
|
14494 |
|
14495 | function Manager(element, options) {
|
14496 | this.options = assign({}, NGHammer.defaults, options || {});
|
14497 |
|
14498 | this.options.inputTarget = this.options.inputTarget || element;
|
14499 |
|
14500 | this.handlers = {};
|
14501 | this.session = {};
|
14502 | this.recognizers = [];
|
14503 | this.oldCssProps = {};
|
14504 |
|
14505 | this.element = element;
|
14506 | this.input = createInputInstance(this);
|
14507 | this.touchAction = new TouchAction(this, this.options.touchAction);
|
14508 |
|
14509 | toggleCssProps(this, true);
|
14510 |
|
14511 | each(this.options.recognizers, function(item) {
|
14512 | var recognizer = this.add(new (item[0])(item[1]));
|
14513 | item[2] && recognizer.recognizeWith(item[2]);
|
14514 | item[3] && recognizer.requireFailure(item[3]);
|
14515 | }, this);
|
14516 | }
|
14517 |
|
14518 | Manager.prototype = {
|
14519 | |
14520 |
|
14521 |
|
14522 |
|
14523 |
|
14524 | set: function(options) {
|
14525 | assign(this.options, options);
|
14526 |
|
14527 |
|
14528 | if (options.touchAction) {
|
14529 | this.touchAction.update();
|
14530 | }
|
14531 | if (options.inputTarget) {
|
14532 |
|
14533 | this.input.destroy();
|
14534 | this.input.target = options.inputTarget;
|
14535 | this.input.init();
|
14536 | }
|
14537 | return this;
|
14538 | },
|
14539 |
|
14540 | |
14541 |
|
14542 |
|
14543 |
|
14544 |
|
14545 |
|
14546 | stop: function(force) {
|
14547 | this.session.stopped = force ? FORCED_STOP : STOP;
|
14548 | },
|
14549 |
|
14550 | |
14551 |
|
14552 |
|
14553 |
|
14554 |
|
14555 |
|
14556 | recognize: function(inputData) {
|
14557 | var session = this.session;
|
14558 | if (session.stopped) {
|
14559 | return;
|
14560 | }
|
14561 |
|
14562 |
|
14563 | this.touchAction.preventDefaults(inputData);
|
14564 |
|
14565 | var recognizer;
|
14566 | var recognizers = this.recognizers;
|
14567 |
|
14568 |
|
14569 |
|
14570 |
|
14571 | var curRecognizer = session.curRecognizer;
|
14572 |
|
14573 |
|
14574 |
|
14575 | if (!curRecognizer || (curRecognizer && curRecognizer.state & STATE_RECOGNIZED)) {
|
14576 | curRecognizer = session.curRecognizer = null;
|
14577 | }
|
14578 |
|
14579 | var i = 0;
|
14580 | while (i < recognizers.length) {
|
14581 | recognizer = recognizers[i];
|
14582 |
|
14583 |
|
14584 |
|
14585 |
|
14586 |
|
14587 |
|
14588 |
|
14589 | if (session.stopped !== FORCED_STOP && (
|
14590 | !curRecognizer || recognizer == curRecognizer ||
|
14591 | recognizer.canRecognizeWith(curRecognizer))) {
|
14592 | recognizer.recognize(inputData);
|
14593 | } else {
|
14594 | recognizer.reset();
|
14595 | }
|
14596 |
|
14597 |
|
14598 |
|
14599 | if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
|
14600 | curRecognizer = session.curRecognizer = recognizer;
|
14601 | }
|
14602 | i++;
|
14603 | }
|
14604 | },
|
14605 |
|
14606 | |
14607 |
|
14608 |
|
14609 |
|
14610 |
|
14611 | get: function(recognizer) {
|
14612 | if (recognizer instanceof Recognizer) {
|
14613 | return recognizer;
|
14614 | }
|
14615 |
|
14616 | var recognizers = this.recognizers;
|
14617 | for (var i = 0; i < recognizers.length; i++) {
|
14618 | if (recognizers[i].options.event == recognizer) {
|
14619 | return recognizers[i];
|
14620 | }
|
14621 | }
|
14622 | return null;
|
14623 | },
|
14624 |
|
14625 | |
14626 |
|
14627 |
|
14628 |
|
14629 |
|
14630 |
|
14631 | add: function(recognizer) {
|
14632 | if (invokeArrayArg(recognizer, 'add', this)) {
|
14633 | return this;
|
14634 | }
|
14635 |
|
14636 |
|
14637 | var existing = this.get(recognizer.options.event);
|
14638 | if (existing) {
|
14639 | this.remove(existing);
|
14640 | }
|
14641 |
|
14642 | this.recognizers.push(recognizer);
|
14643 | recognizer.manager = this;
|
14644 |
|
14645 | this.touchAction.update();
|
14646 | return recognizer;
|
14647 | },
|
14648 |
|
14649 | |
14650 |
|
14651 |
|
14652 |
|
14653 |
|
14654 | remove: function(recognizer) {
|
14655 | if (invokeArrayArg(recognizer, 'remove', this)) {
|
14656 | return this;
|
14657 | }
|
14658 |
|
14659 | recognizer = this.get(recognizer);
|
14660 |
|
14661 |
|
14662 | if (recognizer) {
|
14663 | var recognizers = this.recognizers;
|
14664 | var index = inArray(recognizers, recognizer);
|
14665 |
|
14666 | if (index !== -1) {
|
14667 | recognizers.splice(index, 1);
|
14668 | this.touchAction.update();
|
14669 | }
|
14670 | }
|
14671 |
|
14672 | return this;
|
14673 | },
|
14674 |
|
14675 | |
14676 |
|
14677 |
|
14678 |
|
14679 |
|
14680 |
|
14681 | on: function(events, handler) {
|
14682 | if (events === undefined) {
|
14683 | return;
|
14684 | }
|
14685 | if (handler === undefined) {
|
14686 | return;
|
14687 | }
|
14688 |
|
14689 | var handlers = this.handlers;
|
14690 | each(splitStr(events), function(event) {
|
14691 | handlers[event] = handlers[event] || [];
|
14692 | handlers[event].push(handler);
|
14693 | });
|
14694 | return this;
|
14695 | },
|
14696 |
|
14697 | |
14698 |
|
14699 |
|
14700 |
|
14701 |
|
14702 |
|
14703 | off: function(events, handler) {
|
14704 | if (events === undefined) {
|
14705 | return;
|
14706 | }
|
14707 |
|
14708 | var handlers = this.handlers;
|
14709 | each(splitStr(events), function(event) {
|
14710 | if (!handler) {
|
14711 | delete handlers[event];
|
14712 | } else {
|
14713 | handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
|
14714 | }
|
14715 | });
|
14716 | return this;
|
14717 | },
|
14718 |
|
14719 | |
14720 |
|
14721 |
|
14722 |
|
14723 |
|
14724 | emit: function(event, data) {
|
14725 |
|
14726 | if (this.options.domEvents) {
|
14727 | triggerDomEvent(event, data);
|
14728 | }
|
14729 |
|
14730 |
|
14731 | var handlers = this.handlers[event] && this.handlers[event].slice();
|
14732 | if (!handlers || !handlers.length) {
|
14733 | return;
|
14734 | }
|
14735 |
|
14736 | data.type = event;
|
14737 | data.preventDefault = function() {
|
14738 | data.srcEvent.preventDefault();
|
14739 | };
|
14740 |
|
14741 | var i = 0;
|
14742 | while (i < handlers.length) {
|
14743 | handlers[i](data);
|
14744 | i++;
|
14745 | }
|
14746 | },
|
14747 |
|
14748 | |
14749 |
|
14750 |
|
14751 |
|
14752 | destroy: function() {
|
14753 | this.element && toggleCssProps(this, false);
|
14754 |
|
14755 | this.handlers = {};
|
14756 | this.session = {};
|
14757 | this.input.destroy();
|
14758 | this.element = null;
|
14759 | }
|
14760 | };
|
14761 |
|
14762 |
|
14763 |
|
14764 |
|
14765 |
|
14766 |
|
14767 | function toggleCssProps(manager, add) {
|
14768 | var element = manager.element;
|
14769 | if (!element.style) {
|
14770 | return;
|
14771 | }
|
14772 | var prop;
|
14773 | each(manager.options.cssProps, function(value, name) {
|
14774 | prop = prefixed(element.style, name);
|
14775 | if (add) {
|
14776 | manager.oldCssProps[prop] = element.style[prop];
|
14777 | element.style[prop] = value;
|
14778 | } else {
|
14779 | element.style[prop] = manager.oldCssProps[prop] || '';
|
14780 | }
|
14781 | });
|
14782 | if (!add) {
|
14783 | manager.oldCssProps = {};
|
14784 | }
|
14785 | }
|
14786 |
|
14787 |
|
14788 |
|
14789 |
|
14790 |
|
14791 |
|
14792 | function triggerDomEvent(event, data) {
|
14793 | var gestureEvent = document.createEvent('Event');
|
14794 | gestureEvent.initEvent(event, true, true);
|
14795 | gestureEvent.gesture = data;
|
14796 | data.target.dispatchEvent(gestureEvent);
|
14797 | }
|
14798 |
|
14799 | assign(NGHammer, {
|
14800 | INPUT_START: INPUT_START,
|
14801 | INPUT_MOVE: INPUT_MOVE,
|
14802 | INPUT_END: INPUT_END,
|
14803 | INPUT_CANCEL: INPUT_CANCEL,
|
14804 |
|
14805 | STATE_POSSIBLE: STATE_POSSIBLE,
|
14806 | STATE_BEGAN: STATE_BEGAN,
|
14807 | STATE_CHANGED: STATE_CHANGED,
|
14808 | STATE_ENDED: STATE_ENDED,
|
14809 | STATE_RECOGNIZED: STATE_RECOGNIZED,
|
14810 | STATE_CANCELLED: STATE_CANCELLED,
|
14811 | STATE_FAILED: STATE_FAILED,
|
14812 |
|
14813 | DIRECTION_NONE: DIRECTION_NONE,
|
14814 | DIRECTION_LEFT: DIRECTION_LEFT,
|
14815 | DIRECTION_RIGHT: DIRECTION_RIGHT,
|
14816 | DIRECTION_UP: DIRECTION_UP,
|
14817 | DIRECTION_DOWN: DIRECTION_DOWN,
|
14818 | DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
|
14819 | DIRECTION_VERTICAL: DIRECTION_VERTICAL,
|
14820 | DIRECTION_ALL: DIRECTION_ALL,
|
14821 |
|
14822 | Manager: Manager,
|
14823 | Input: Input,
|
14824 | TouchAction: TouchAction,
|
14825 |
|
14826 | TouchInput: TouchInput,
|
14827 | MouseInput: MouseInput,
|
14828 | PointerEventInput: PointerEventInput,
|
14829 | TouchMouseInput: TouchMouseInput,
|
14830 | SingleTouchInput: SingleTouchInput,
|
14831 |
|
14832 | Recognizer: Recognizer,
|
14833 | AttrRecognizer: AttrRecognizer,
|
14834 | Tap: TapRecognizer,
|
14835 | Pan: PanRecognizer,
|
14836 | Swipe: SwipeRecognizer,
|
14837 | Pinch: PinchRecognizer,
|
14838 | Rotate: RotateRecognizer,
|
14839 | Press: PressRecognizer,
|
14840 |
|
14841 | on: addEventListeners,
|
14842 | off: removeEventListeners,
|
14843 | each: each,
|
14844 | merge: merge,
|
14845 | extend: extend,
|
14846 | assign: assign,
|
14847 | inherit: inherit,
|
14848 | bindFn: bindFn,
|
14849 | prefixed: prefixed
|
14850 | });
|
14851 |
|
14852 |
|
14853 |
|
14854 | var freeGlobal = (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}));
|
14855 | freeGlobal.NGHammer = NGHammer;
|
14856 |
|
14857 | if (typeof define === 'function' && define.amdDISABLED) {
|
14858 | define(function() {
|
14859 | return NGHammer;
|
14860 | });
|
14861 | } else if (typeof module != 'undefined' && module.exports) {
|
14862 | module.exports = NGHammer;
|
14863 | } else {
|
14864 | window[exportName] = NGHammer;
|
14865 | }
|
14866 |
|
14867 | })(window, document, 'NGHammer');
|
14868 |
|
14869 |
|
14870 |
|
14871 |
|
14872 |
|
14873 |
|
14874 |
|
14875 |
|
14876 | }));
|
14877 |
|
14878 |
|
14879 |
|
14880 |
|
14881 |
|
14882 |
|
14883 |
|
14884 |
|
14885 |
|
14886 | (function(){
|
14887 | 'use strict';
|
14888 | jQuery(document).ready(function () {
|
14889 |
|
14890 |
|
14891 |
|
14892 |
|
14893 |
|
14894 |
|
14895 |
|
14896 |
|
14897 |
|
14898 |
|
14899 |
|
14900 |
|
14901 |
|
14902 |
|
14903 |
|
14904 |
|
14905 |
|
14906 | var t=document.querySelectorAll('[data-nanogallery2]');
|
14907 | for( var i=0; i < t.length; i++ ) {
|
14908 | jQuery( t[i] ).nanogallery2( jQuery(t[i]).data('nanogallery2') );
|
14909 | }
|
14910 |
|
14911 |
|
14912 | });
|
14913 | }).call(null);
|
14914 |
|