/**! * @preserve nanoGALLERY v5.10.3 * Plugin for jQuery by Christophe Brisbois * Demo: http://nanogallery.brisbois.fr * Sources: https://github.com/Kris-B/nanoGALLERY * * License: For personal, non-profit organizations, or open source projects (without any kind of fee), you may use nanoGALLERY for jQuery for free. * -------- ALL OTHER USES REQUIRE THE PURCHASE OF A PROFESSIONAL LICENSE. * * * Components: * - jQuery (http://www.jquery.com) - version >= 1.7.1 * - jQuery Color plugin - is embedded * - imagesloaded (https://github.com/desandro/imagesloaded) - is embebed * - screenfull.js (https://github.com/sindresorhus/screenfull.js) - is embeded * - shifty (https://github.com/jeremyckahn/shifty) - is embeded * - webfont generated by http://fontello.com - based on Font Awesome Copyright (C) 2012 by Dave Gandy (http://fortawesome.github.com/Font-Awesome/) * - javascript minifying: grunt-contrib-uglify (https://github.com/gruntjs/grunt-contrib-uglify) * - css minifying: grunt-contrib-cssmin (https://github.com/gruntjs/grunt-contrib-cssmin) */ /* nanoGALLERY v5.10.3 release notes. - nanoPhotosProvider : underscores are replaced with spaces in title an description - nanoPhotosProvider : remove leading @@NNNN in title **Visit nanoGALLERY homepage for usage details: [http://nanogallery.brisbois.fr](http://www.nanogallery.brisbois.fr/)** */ /*! * Shifty * By Jeremy Kahn - jeremyckahn@gmail.com */ // NG BUILD: // // rename "Tweenable" in "NGTweenable" // rename "define.amd" in "define.amdDISABLED" /*! shifty - v1.5.0 - 2015-05-31 - http://jeremyckahn.github.io/shifty */ (function(){var t=this,n=function(){"use strict";function n(){}function e(t,n){var e;for(e in t)Object.hasOwnProperty.call(t,e)&&n(e)}function i(t,n){return e(n,function(e){t[e]=n[e]}),t}function r(t,n){e(n,function(e){t[e]===void 0&&(t[e]=n[e])})}function o(t,n,e,i,r,o,u){var s,c,h,p=o>t?0:(t-o)/r;for(s in n)n.hasOwnProperty(s)&&(c=u[s],h="function"==typeof c?c:f[c],n[s]=a(e[s],i[s],h,p));return n}function a(t,n,e,i){return t+(n-t)*e(i)}function u(t,n){var i=h.prototype.filter,r=t._filterArgs;e(i,function(e){i[e][n]!==void 0&&i[e][n].apply(t,r)})}function s(t,n,e,i,r,a,s,c,h,f,p){g=n+e+i,y=Math.min(p||d(),g),v=y>=g,M=i-(g-y),t.isPlaying()&&!v?(t._scheduleId=f(t._timeoutHandler,m),u(t,"beforeTween"),n+e>y?o(1,r,a,s,1,1,c):o(y,r,a,s,i,n+e,c),u(t,"afterTween"),h(r,t._attachment,M)):t.isPlaying()&&v&&(h(s,t._attachment,M),t.stop(!0))}function c(t,n){var i={},r=typeof n;return"string"===r||"function"===r?e(t,function(t){i[t]=n}):e(t,function(t){i[t]||(i[t]=n[t]||l)}),i}function h(t,n){this._currentState=t||{},this._configured=!1,this._scheduleFunction=p,n!==void 0&&this.setConfig(n)}var f,p,l="linear",_=500,m=1e3/60,w=Date.now?Date.now:function(){return+new Date},d="undefined"!=typeof SHIFTY_DEBUG_NOW?SHIFTY_DEBUG_NOW:w;p="undefined"!=typeof window?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||window.mozCancelRequestAnimationFrame&&window.mozRequestAnimationFrame||setTimeout:setTimeout;var g,y,v,M;return h.prototype.tween=function(t){return this._isTweening?this:(void 0===t&&this._configured||this.setConfig(t),this._timestamp=d(),this._start(this.get(),this._attachment),this.resume())},h.prototype.setConfig=function(t){t=t||{},this._configured=!0,this._attachment=t.attachment,this._pausedAtTime=null,this._scheduleId=null,this._delay=t.delay||0,this._start=t.start||n,this._step=t.step||n,this._finish=t.finish||n,this._duration=t.duration||_,this._currentState=i({},t.from)||this.get(),this._originalState=this.get(),this._targetState=i({},t.to)||this.get();var e=this;this._timeoutHandler=function(){s(e,e._timestamp,e._delay,e._duration,e._currentState,e._originalState,e._targetState,e._easing,e._step,e._scheduleFunction)};var o=this._currentState,a=this._targetState;return r(a,o),this._easing=c(o,t.easing||l),this._filterArgs=[o,this._originalState,a,this._easing],u(this,"tweenCreated"),this},h.prototype.get=function(){return i({},this._currentState)},h.prototype.set=function(t){this._currentState=t},h.prototype.pause=function(){return this._pausedAtTime=d(),this._isPaused=!0,this},h.prototype.resume=function(){return this._isPaused&&(this._timestamp+=d()-this._pausedAtTime),this._isPaused=!1,this._isTweening=!0,this._timeoutHandler(),this},h.prototype.seek=function(t){t=Math.max(t,0);var n=d();return 0===this._timestamp+t?this:(this._timestamp=n-t,this.isPlaying()||(this._isTweening=!0,this._isPaused=!1,s(this,this._timestamp,this._delay,this._duration,this._currentState,this._originalState,this._targetState,this._easing,this._step,this._scheduleFunction,n),this.pause()),this)},h.prototype.stop=function(e){return this._isTweening=!1,this._isPaused=!1,this._timeoutHandler=n,(t.cancelAnimationFrame||t.webkitCancelAnimationFrame||t.oCancelAnimationFrame||t.msCancelAnimationFrame||t.mozCancelRequestAnimationFrame||t.clearTimeout)(this._scheduleId),e&&(u(this,"beforeTween"),o(1,this._currentState,this._originalState,this._targetState,1,0,this._easing),u(this,"afterTween"),u(this,"afterTweenEnd"),this._finish.call(this,this._currentState,this._attachment)),this},h.prototype.isPlaying=function(){return this._isTweening&&!this._isPaused},h.prototype.setScheduleFunction=function(t){this._scheduleFunction=t},h.prototype.dispose=function(){var t;for(t in this)this.hasOwnProperty(t)&&delete this[t]},h.prototype.filter={},h.prototype.formula={linear:function(t){return t}},f=h.prototype.formula,i(h,{now:d,each:e,tweenProps:o,tweenProp:a,applyFilter:u,shallowCopy:i,defaults:r,composeEasingObject:c}),"function"==typeof SHIFTY_DEBUG_NOW&&(t.timeoutHandler=s),"object"==typeof exports?module.exports=h:"function"==typeof define&&define.amd?define('ngTweenable', function(){return h}):t.NGTweenable===void 0&&(t.NGTweenable=h),h}();(function(){n.shallowCopy(n.prototype.formula,{easeInQuad:function(t){return Math.pow(t,2)},easeOutQuad:function(t){return-(Math.pow(t-1,2)-1)},easeInOutQuad:function(t){return 1>(t/=.5)?.5*Math.pow(t,2):-.5*((t-=2)*t-2)},easeInCubic:function(t){return Math.pow(t,3)},easeOutCubic:function(t){return Math.pow(t-1,3)+1},easeInOutCubic:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)},easeInQuart:function(t){return Math.pow(t,4)},easeOutQuart:function(t){return-(Math.pow(t-1,4)-1)},easeInOutQuart:function(t){return 1>(t/=.5)?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},easeInQuint:function(t){return Math.pow(t,5)},easeOutQuint:function(t){return Math.pow(t-1,5)+1},easeInOutQuint:function(t){return 1>(t/=.5)?.5*Math.pow(t,5):.5*(Math.pow(t-2,5)+2)},easeInSine:function(t){return-Math.cos(t*(Math.PI/2))+1},easeOutSine:function(t){return Math.sin(t*(Math.PI/2))},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t)-1)},easeInExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},easeOutExpo:function(t){return 1===t?1:-Math.pow(2,-10*t)+1},easeInOutExpo:function(t){return 0===t?0:1===t?1:1>(t/=.5)?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math.sqrt(1-Math.pow(t-1,2))},easeInOutCirc:function(t){return 1>(t/=.5)?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeOutBounce:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInBack:function(t){var n=1.70158;return t*t*((n+1)*t-n)},easeOutBack:function(t){var n=1.70158;return(t-=1)*t*((n+1)*t+n)+1},easeInOutBack:function(t){var n=1.70158;return 1>(t/=.5)?.5*t*t*(((n*=1.525)+1)*t-n):.5*((t-=2)*t*(((n*=1.525)+1)*t+n)+2)},elastic:function(t){return-1*Math.pow(4,-8*t)*Math.sin((6*t-1)*2*Math.PI/2)+1},swingFromTo:function(t){var n=1.70158;return 1>(t/=.5)?.5*t*t*(((n*=1.525)+1)*t-n):.5*((t-=2)*t*(((n*=1.525)+1)*t+n)+2)},swingFrom:function(t){var n=1.70158;return t*t*((n+1)*t-n)},swingTo:function(t){var n=1.70158;return(t-=1)*t*((n+1)*t+n)+1},bounce:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bouncePast:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?2-(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?2-(7.5625*(t-=2.25/2.75)*t+.9375):2-(7.5625*(t-=2.625/2.75)*t+.984375)},easeFromTo:function(t){return 1>(t/=.5)?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},easeFrom:function(t){return Math.pow(t,4)},easeTo:function(t){return Math.pow(t,.25)}})})(),function(){function t(t,n,e,i,r,o){function a(t){return((l*t+_)*t+m)*t}function u(t){return((w*t+d)*t+g)*t}function s(t){return(3*l*t+2*_)*t+m}function c(t){return 1/(200*t)}function h(t,n){return u(p(t,n))}function f(t){return t>=0?t:0-t}function p(t,n){var e,i,r,o,u,c;for(r=t,c=0;8>c;c++){if(o=a(r)-t,n>f(o))return r;if(u=s(r),1e-6>f(u))break;r-=o/u}if(e=0,i=1,r=t,e>r)return e;if(r>i)return i;for(;i>e;){if(o=a(r),n>f(o-t))return r;t>o?e=r:i=r,r=.5*(i-e)+e}return r}var l=0,_=0,m=0,w=0,d=0,g=0;return m=3*n,_=3*(i-n)-m,l=1-m-_,g=3*e,d=3*(r-e)-g,w=1-g-d,h(t,c(o))}function e(n,e,i,r){return function(o){return t(o,n,e,i,r,1)}}n.setBezierFunction=function(t,i,r,o,a){var u=e(i,r,o,a);return u.displayName=t,u.x1=i,u.y1=r,u.x2=o,u.y2=a,n.prototype.formula[t]=u},n.unsetBezierFunction=function(t){delete n.prototype.formula[t]}}(),function(){function t(t,e,i,r,o,a){return n.tweenProps(r,e,t,i,1,a,o)}var e=new n;e._filterArgs=[],n.interpolate=function(i,r,o,a,u){var s=n.shallowCopy({},i),c=u||0,h=n.composeEasingObject(i,a||"linear");e.set({});var f=e._filterArgs;f.length=0,f[0]=s,f[1]=i,f[2]=r,f[3]=h,n.applyFilter(e,"tweenCreated"),n.applyFilter(e,"beforeTween");var p=t(i,s,r,o,h,c);return n.applyFilter(e,"afterTween"),p}}(),function(t){function n(t,n){var e,i=[],r=t.length;for(e=0;r>e;e++)i.push("_"+n+"_"+e);return i}function e(t){var n=t.match(M);return n?(1===n.length||t[0].match(v))&&n.unshift(""):n=["",""],n.join(O)}function i(n){t.each(n,function(t){var e=n[t];"string"==typeof e&&e.match(S)&&(n[t]=r(e))})}function r(t){return s(S,t,o)}function o(t){var n=a(t);return"rgb("+n[0]+","+n[1]+","+n[2]+")"}function a(t){return t=t.replace(/#/,""),3===t.length&&(t=t.split(""),t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),b[0]=u(t.substr(0,2)),b[1]=u(t.substr(2,2)),b[2]=u(t.substr(4,2)),b}function u(t){return parseInt(t,16)}function s(t,n,e){var i=n.match(t),r=n.replace(t,O);if(i)for(var o,a=i.length,u=0;a>u;u++)o=i.shift(),r=r.replace(O,e(o));return r}function c(t){return s(T,t,h)}function h(t){for(var n=t.match(F),e=n.length,i=t.match(I)[0],r=0;e>r;r++)i+=parseInt(n[r],10)+",";return i=i.slice(0,-1)+")"}function f(i){var r={};return t.each(i,function(t){var o=i[t];if("string"==typeof o){var a=d(o);r[t]={formatString:e(o),chunkNames:n(a,t)}}}),r}function p(n,e){t.each(e,function(t){for(var i=n[t],r=d(i),o=r.length,a=0;o>a;a++)n[e[t].chunkNames[a]]=+r[a];delete n[t]})}function l(n,e){t.each(e,function(t){var i=n[t],r=_(n,e[t].chunkNames),o=m(r,e[t].chunkNames);i=w(e[t].formatString,o),n[t]=c(i)})}function _(t,n){for(var e,i={},r=n.length,o=0;r>o;o++)e=n[o],i[e]=t[e],delete t[e];return i}function m(t,n){k.length=0;for(var e=n.length,i=0;e>i;i++)k.push(t[n[i]]);return k}function w(t,n){for(var e=t,i=n.length,r=0;i>r;r++)e=e.replace(O,+n[r].toFixed(4));return e}function d(t){return t.match(F)}function g(n,e){t.each(e,function(t){var i,r=e[t],o=r.chunkNames,a=o.length,u=n[t];if("string"==typeof u){var s=u.split(" "),c=s[s.length-1];for(i=0;a>i;i++)n[o[i]]=s[i]||c}else for(i=0;a>i;i++)n[o[i]]=u;delete n[t]})}function y(n,e){t.each(e,function(t){var i=e[t],r=i.chunkNames,o=r.length,a=n[r[0]],u=typeof a;if("string"===u){for(var s="",c=0;o>c;c++)s+=" "+n[r[c]],delete n[r[c]];n[t]=s.substr(1)}else n[t]=a})}var v=/(\d|\-|\.)/,M=/([^\-0-9\.]+)/g,F=/[0-9.\-]+/g,T=RegExp("rgb\\("+F.source+/,\s*/.source+F.source+/,\s*/.source+F.source+"\\)","g"),I=/^.*\(/,S=/#([0-9]|[a-f]){3,6}/gi,O="VAL",b=[],k=[];t.prototype.filter.token={tweenCreated:function(t,n,e){i(t),i(n),i(e),this._tokenData=f(t)},beforeTween:function(t,n,e,i){g(i,this._tokenData),p(t,this._tokenData),p(n,this._tokenData),p(e,this._tokenData)},afterTween:function(t,n,e,i){l(t,this._tokenData),l(n,this._tokenData),l(e,this._tokenData),y(i,this._tokenData)}}}(n)}).call(null); // ########################################## // ##### nanoGALLERY as a JQUERY PLUGIN ##### // ########################################## //;(function ($) { ;(function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module depending on jQuery. define('jqueryNanoGallery', ['jquery', 'ngTweenable'], factory); } else { // No AMD. Register plugin with global jQuery object. factory(jQuery, window.NGTweenable); } })(function($, NGTweenable) { jQuery.nanoGallery = function(elt, options){ // To avoid scope issues, use '_this' instead of 'this' // to reference this class from internal events and functions. var _this = this; // Access to jQuery and DOM versions of element _this.$e = $(elt); _this.e = elt; // Add a reverse reference to the DOM object _this.$e.data('nanoGallery', _this); _this.init = function(){ _this.options = $.extend(true, {},$.nanoGallery.defaultOptions, options); // Initialization code _this.nG= new nanoGALLERY(); _this.nG.Initiate(_this.e, _this.options ); }; // PUBLIC EXPOSED METHODS _this.test = function() { //alert('test'); // console.dir(_this.nG.G.I.length); // console.dir(_this.nG); //privateTest(); } // Run initializer _this.init(); }; jQuery.nanoGallery.defaultOptions = { userID : '', kind : '', album : '', photoset : '', blackList : 'scrapbook|profil', whiteList : '', albumList : '', RTL : false, picasaUseUrlCrossDomain : true, flickrSkipOriginal : true, galleryToolbarWidthAligned : true, galleryToolbarHideIcons : false, galleryFullpageButton : false, galleryFullpageBgColor : '#111', galleryEnableKeyboard : false, galleryRenderStep : 10, breadcrumbAutoHideTopLevel : false, displayBreadcrumb : false, theme : 'default', colorScheme : 'none', colorSchemeViewer : 'default', items : null, itemsBaseURL : '', itemsSelectable : false, showCheckboxes: true, checkboxStyle : 'left:15px; top:15px;', keepSelection: false, jsonCharset: 'Latin', jsonProvider: '', paginationMaxLinesPerPage : 0, paginationDots : false, paginationSwipe : true, paginationVisiblePages : 10, maxWidth : 0, viewer : 'internal', viewerFullscreen: false, viewerDisplayLogo : false, fancyBoxOptions : null, imageTransition : 'slide', openOnStart : '', viewerToolbar : { display:true, position : 'bottom', style : 'innerImage', autoMinimize:800, standard:'minimizeButton , previousButton, pageCounter ,nextButton,playPauseButton,fullscreenButton,infoButton,linkOriginalButton,closeButton,label', minimized:'minimizeButton,label' }, thumbnailAlignment : 'center', thumbnailWidth : 230, thumbnailHeight : 154, thumbnailGutterWidth : 2, thumbnailGutterHeight : 2, thumbnailAdjustLastRowHeight : true, thumbnailFeatured : false, thumbnailAlbumDisplayImage : false, thumbnailHoverEffect : null, thumbnailLabel : { position : 'overImageOnBottom', display : true, displayDescription : true, titleMaxLength : 0, descriptionMaxLength : 0, hideIcons : false, title : '', itemsCount : '' }, thumbnailDisplayInterval : 5, thumbnailDisplayTransition : true, thumbnailLazyLoad : false, thumbnailLazyLoadTreshold : 100, thumbnailGlobalImageTitle : '', thumbnailGlobalAlbumTitle : '', thumbnailOpenImage: true, //thumbnailSizeSM : 480, thumbnailSizeME : 992, thumbnailSizeLA : 1200, thumbnailSizeXL : 1800, breakpointSizeSM : 480, breakpointSizeME : 992, breakpointSizeLA : 1200, breakpointSizeXL : 1800, fnThumbnailInit : null, fnThumbnailHoverInit : null, fnThumbnailHoverResize : null, fnThumbnailHover : null, fnThumbnailHoverOut : null, fnThumbnailDisplayEffect : null, fnThumbnailOpen : null, fnViewerInfo : null, fnImgToolbarCustInit : null, fnImgToolbarCustDisplay : null, fnImgToolbarCustClick : null, fnProcessData : null, fnChangeSelectMode : null, fnInitGallery : null, touchAnimation : true, touchAutoOpenDelay : 0, useTags : false, preset : 'none', locationHash : true, demoViewportWidth : 0, slideshowDelay : 3000, slideshowAutoStart : false, photoSorting : '', albumSorting : '', dataSorting : '', albumMax: 0, lazyBuild : 'none', lazyBuildTreshold : 150, debugMode: false, i18n : { 'breadcrumbHome' : 'Galleries', 'breadcrumbHome_FR' : 'Galeries', 'breadcrumbHome_ES' : 'Galerías', 'paginationPrevious' : 'Previous', 'paginationPrevious_FR' : 'Précédent', 'paginationPrevious_DE' : 'Zurück', 'paginationPrevious_IT' : 'Indietro',' paginationPrevious_ES' : 'Anterior', 'paginationNext' : 'Next', 'paginationNext_FR' : 'Suivant', 'paginationNext_DE' : 'Weiter', 'paginationNext_IT' : 'Avanti', 'paginationNext_ES' : 'Siguiente', 'thumbnailLabelItemsCountPart1' : '', //'| ', 'thumbnailLabelItemsCountPart2' : '', //' photos', 'thumbnailLabelItemsCountPart2_DE' : ' Fotos', 'thumbnailImageTitle' : '', 'thumbnailAlbumTitle' : '', 'thumbnailImageDescription' : '', 'thumbnailAlbumDescription' : '', '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', 'infoBoxPhoto_ES' : 'Foto', 'infoBoxDate_ES' : 'Fecha', 'infoBoxAlbum_ES' : 'Album', 'infoBoxDimensions_ES' : 'Dimensiones', 'infoBoxFilename_ES' : 'Nombre', 'infoBoxFileSize_ES' : 'Tamaño', 'infoBoxCamera_ES' : 'Cámara', 'infoBoxFocalLength_ES' : 'Longitud focal', 'infoBoxExposure_ES' : 'Exposición', 'infoBoxFNumber_ES' : 'Número F', 'infoBoxISO_ES' : 'ISO', 'infoBoxMake_ES' : 'Hacer', 'infoBoxFlash_ES' : 'Flash', 'infoBoxViews_ES' : 'Vistas', 'infoBoxComments_ES' : 'Comentarios' } }; jQuery.fn.nanoGallery = function (args, option, value) { // jQuery.fn.nanoGallery = function(options){ // if( typeof(options) !== 'undefined'){ if( typeof $(this).data('nanoGallery') === 'undefined'){ return this.each( function(){ (new $.nanoGallery(this, args)); }); } else { // no options --> // This function breaks the chain, but provides some API methods switch(args){ case 'reload': $(this).data('nanoGallery').nG.ReloadAlbum(); return $(this); break; case 'refreshSize': $(this).data('nanoGallery').nG.RefreshSize(); return $(this); break; case 'getSelectedItems': return $(this).data('nanoGallery').nG.GetSelectedItems(); break; case 'selectItems': $(this).data('nanoGallery').nG.SetSelectedItems(option); break; case 'unselectItems': $(this).data('nanoGallery').nG.SetUnselectedItems(option); break; case 'setSelectMode': if(option === true || option === false || option === 'image' || option === 'album'){ $(this).data('nanoGallery').nG.SetSelectMode(option); } break; case 'getSelectMode': return $(this).data('nanoGallery').nG.GetSelectMode(); break; case 'getItem': return $(this).data('nanoGallery').nG.GetItem(option); break; case 'getItems': return $(this).data('nanoGallery').nG.GetItems(); break; case 'getItemsIndex': return $(this).data('nanoGallery').nG.GetItemsIndex(option); break; case 'option': if(typeof value === 'undefined'){ return $(this).data('nanoGallery').nG.Get(option); }else{ $(this).data('nanoGallery').nG.Set(option,value); if( option == 'demoViewportWidth' ) { // force resize event -> for demo purposes $(window).trigger('resize'); } } break; case 'destroy': $(this).data('nanoGallery').nG.$E.base.text(''); $(this).removeData(); break; case 'closeViewer': $(this).data('nanoGallery').nG.closeViewer(); break; case 'minimizeToolbar': $(this).data('nanoGallery').nG.minimizeToolbar(); break; case 'maximizeToolbar': $(this).data('nanoGallery').nG.maximizeToolbar(); break; case 'displayItem': $(this).data('nanoGallery').nG.displayItem(option); break; case 'paginationPreviousPage': $(this).data('nanoGallery').nG.paginationPreviousPage(); break; case 'paginationNextPage': $(this).data('nanoGallery').nG.paginationNextPage(); break; case 'paginationGotoPage': $(this).data('nanoGallery').nG.paginationGotoPage(option); break; case 'paginationCountPages': return $(this).data('nanoGallery').nG.paginationCountPages(); break; case 'getCurrentViewedItem': return $(this).data('nanoGallery').nG.GetCurrentViewedItem(); break; case 'getCurrentViewedItemIdx': return $(this).data('nanoGallery').nG.GetCurrentViewedItemIdx(); break; case 'moveToNextAlbum': return $(this).data('nanoGallery').nG.moveToNextAlbum(); break; case 'moveToPreviousAlbum': return $(this).data('nanoGallery').nG.moveToPreviousAlbum(); break; case 'galleryCountImages': return $(this).data('nanoGallery').nG.galleryCountImages(); break; } return $(this); } }; // ############################## // ##### nanoGALLERY script ##### // ############################## function privateTest() { alert('privateTest'); console.dir(G); } function nanoGALLERY() { /** * Force reload the current album, if provided by Json */ this.ReloadAlbum = function(){ if( G.O.kind === '' ) { throw 'Not supported for this kind.'; } var l=G.I.length; var albumIdx =-1; // find current album index for( var j=0; j display one album // - albumID/imageID --> display one image this.displayItem = function( itemID ){ return OpenItem( false, itemID, true ); }; // manage gallery pagination // Pagination - goto previous page this.paginationPreviousPage = function () { paginationPreviousPage(); }; // Pagination - goto next page this.paginationNextPage = function () { paginationNextPage(); }; // Pagination - goto specific page this.paginationGotoPage = function ( page ) { var aIdx=G.$E.conPagin.data('galleryIdx'); if( !inViewportVert(G.$E.base, 0) ) { $('html, body').animate({scrollTop: G.$E.base.offset().top}, 200); } if( page > 1 ) { page--; } renderGallery(aIdx, page); }; // Pagination - count number of pages this.paginationCountPages = function () { var aIdx=G.$E.conPagin.data('galleryIdx'), n1=0; // pagination - max lines per page mode if( G.pgMaxLinesPerPage > 0 ) { n1=G.I[aIdx].contentLength / (G.pgMaxLinesPerPage * G.pgMaxNbThumbnailsPerRow); } n2=Math.ceil(n1); return n2; }; // Viewer - Count number of images this.galleryCountImages = function () { return galleryCountImages(); } /** * Get an item by its index * @param {int} index * @returns {object} */ this.GetItem = function(index){ if(isNaN(index)){ throw 'index must be a number'; } return G.I[index]; }; /** * Get an array of every items handled by nanoGallery * @returns {nanoGALLERY.G.I|Array} */ this.GetItems = function(){ return G.I; }; /** * Get the index of an item in the G.I array * @param {object} items * @returns {array} */ this.GetItemsIndex = function( items ){ var indexes = []; var l=items.length; for( var j=0; j 4; i--) { var div = document.createElement("div"); div.innerHTML = ""; if (div.getElementsByTagName("span").length) { div = null; return i; } } } return undefined; })(); // G.IOSversion = (function() { // if (/iP(hone|od|ad)/.test(navigator.platform)) { // var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); // return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)]; // } // })(); G.isIOS = /(iPad|iPhone|iPod)/g.test( navigator.userAgent ); G.isGingerbread= /Android 2\.3\.[3-7]/i.test(navigator.userAgent), G.openNoDelay= false, G.startDateTime= new Date(), G.toRender= []; // ### Picasa/Google+ // square format : 32, 48, 64, 72, 104, 144, 150, 160 (cropped) // details: https://developers.google.com/picasa-web/docs/2.0/reference G.picasa = { url: function() { // return (location.protocol=='https:' ? 'https://picasaweb.google.com/data/feed/api/' : 'https://picasaweb.google.com/data/feed/api/'); return ( G.O.picasaUseUrlCrossDomain ? 'https://photos.googleapis.com/data/feed/api/' : 'https://picasaweb.google.com/data/feed/api/'); }, thumbSize:64, thumbAvailableSizes : new Array(32, 48, 64, 72, 94, 104, 110, 128, 144, 150, 160, 200, 220, 288, 320, 400, 512, 576, 640, 720, 800, 912, 1024, 1152, 1280, 1440, 1600), thumbAvailableSizesCropped : ' 32 48 64 72 104 144 150 160 ' }; // ### Flickr // Details: http://www.flickr.com/services/api/misc.urls.html G.flickr = { url: function() { // Flickr API Going SSL-Only on June 27th, 2014 return 'https://api.flickr.com/services/rest/'; }, thumbSize:'sq', thumbSizeX2 : 'sq', thumbAvailableSizes : new Array(75,100,150,240,500,640), thumbAvailableSizesStr : new Array('sq','t','q','s','m','z'), photoSize : 'sq', photoAvailableSizes : new Array(75,100,150,240,500,640,1024,1024,1600,2048), photoAvailableSizesStr : new Array('sq','t','q','s','m','z','b','l','h','k'), ApiKey : "2f0e634b471fdb47446abcb9c5afebdc" }; // Color schemes - Gallery G.colorScheme_default = { navigationbar : { background:'none', borderTop:'1px solid #555', borderBottom:'1px solid #555', borderRight:'', borderLeft:'', color:'#ccc', colorHover:'#fff' }, thumbnail : { background:'#000', border:'1px solid #000', labelBackground:'rgba(34, 34, 34, 0.75)', titleColor:'#eee', titleShadow:'', descriptionColor:'#ccc', descriptionShadow:'', paginationDotBorder:'2px solid #fff', paginationDotBack:'#444', paginationDotSelBack:'#fff'} }; G.colorScheme_darkRed = { // #ffa3a3 #ff7373 #ff4040 #ff0000 #a60000 navigationbar : { background:'#a60000', border:'1px dotted #ff0000', color:'#ccc', colorHover:'#fff' }, thumbnail : { background:'#a60000', border:'1px solid #ff0000', labelBackground:'rgba(134, 0, 0, 0.75)', titleColor:'#eee', titleShadow:'', descriptionColor:'#ccc', descriptionShadow:'', paginationDotBorder:'2px solid #d00', paginationDotBack:'#400', paginationDotSelBack:'#d00'} }; G.colorScheme_darkGreen = { // #97e697 #67e667 #39e639 #00cc00 #008500 navigationbar : { background:'#008500', border:'1px dotted #00cc00', color:'#ccc', colorHover:'#fff' }, thumbnail : { background:'#008500', border:'1px solid #00cc00', labelBackground:'rgba(0, 105, 0, 0.75)', titleColor:'#eee', titleShadow:'', descriptionColor:'#ccc', descriptionShadow:'', paginationDotBorder:'2px solid #0c0', paginationDotBack:'#008500', paginationDotSelBack:'#0c0'} }; G.colorScheme_darkBlue = { // #a0b0d7 #7080d7 #4a60d7 #162ea2 #071871 navigationbar : { background:'#071871', border:'1px dotted #162ea2', color:'#ccc', colorHover:'#fff' }, thumbnail : { background:'#071871', border:'1px solid #162ea2', labelBackground:'rgba(7, 8, 81, 0.75)', titleColor:'#eee', titleShadow:'', descriptionColor:'#ccc', descriptionShadow:'', paginationDotBorder:'2px solid #162ea2', paginationDotBack:'#071871', paginationDotSelBack:'#162ea2'} }; G.colorScheme_darkOrange = { // #ffd7b7 #ffd773 #ffc840 #ffb600 #a67600 navigationbar : { background:'#a67600', border:'1px dotted #ffb600', color:'#ccc', colorHover:'#fff' }, thumbnail : { background:'#a67600', border:'1px solid #ffb600', labelBackground:'rgba(134, 86, 0, 0.75)', titleColor:'#eee', titleShadow:'', descriptionColor:'#ccc', descriptionShadow:'', paginationDotBorder:'2px solid #ffb600', paginationDotBack:'#a67600', paginationDotSelBack:'#ffb600'} }; G.colorScheme_light = { navigationbar : { background:'none', borderTop:'1px solid #ddd', borderBottom:'1px solid #ddd', borderRight:'', borderLeft:'', color:'#777', colorHover:'#eee' }, thumbnail : { background:'#fff', border:'1px solid #fff', labelBackground:'rgba(60, 60, 60, 0.75)', titleColor:'#fff', titleShadow:'none', descriptionColor:'#eee', descriptionShadow:'none', paginationDotBorder:'2px solid #555', paginationDotBack:'#888', paginationDotSelBack:'#555'} }; G.colorScheme_lightBackground = { navigationbar : { background:'none', border:'', color:'#000', colorHover:'#444' }, thumbnail : { background:'#000', border:'1px solid #000', labelBackground:'rgba(34, 34, 34, 0.85)', titleColor:'#fff', titleShadow:'', descriptionColor:'#eee', descriptionShadow:'', paginationDotBorder:'2px solid #555', paginationDotBack:'#888', paginationDotSelBack:'#555'} }; // Color schemes - lightbox G.colorSchemeViewer_default = { background:'#000', imageBorder:'4px solid #000', imageBoxShadow:'#888 0px 0px 0px', barBackground:'rgba(4, 4, 4, 0.7)', barBorder:'0px solid #111', barColor:'#eee', barDescriptionColor:'#aaa' //background:'rgba(1, 1, 1, 0.75)', imageBorder:'4px solid #f8f8f8', imageBoxShadow:'#888 0px 0px 20px', barBackground:'rgba(4, 4, 4, 0.7)', barBorder:'0px solid #111', barColor:'#eee', barDescriptionColor:'#aaa' }; G.colorSchemeViewer_dark = { background:'rgba(1, 1, 1, 0.75)', imageBorder:'4px solid #f8f8f8', imageBoxShadow:'#888 0px 0px 20px', barBackground:'rgba(4, 4, 4, 0.7)', barBorder:'0px solid #111', barColor:'#eee', barDescriptionColor:'#aaa' }; G.colorSchemeViewer_darkRed = { // #ffa3a3 #ff7373 #ff4040 #ff0000 #a60000 background:'rgba(1, 1, 1, 0.75)', imageBorder:'4px solid #ffa3a3', imageBoxShadow:'#ff0000 0px 0px 20px', barBackground:'#a60000', barBorder:'2px solid #111', barColor:'#eee', barDescriptionColor:'#aaa' }; G.colorSchemeViewer_darkGreen = { // #97e697 #67e667 #39e639 #00cc00 #008500 background:'rgba(1, 1, 1, 0.75)', imageBorder:'4px solid #97e697', imageBoxShadow:'#00cc00 0px 0px 20px', barBackground:'#008500', barBorder:'2px solid #111', barColor:'#eee', barDescriptionColor:'#aaa' }; G.colorSchemeViewer_darkBlue = { // #a0b0d7 #7080d7 #4a60d7 #162ea2 #071871 background:'rgba(1, 1, 1, 0.75)', imageBorder:'4px solid #a0b0d7', imageBoxShadow:'#162ea2 0px 0px 20px', barBackground:'#071871', barBorder:'2px solid #111', barColor:'#eee', barDescriptionColor:'#aaa' }; G.colorSchemeViewer_darkOrange = { // #ffd7b7 #ffd773 #ffc840 #ffb600 #a67600 background:'rgba(1, 1, 1, 0.75)', imageBorder:'4px solid #ffd7b7', imageBoxShadow:'#ffb600 0px 0px 20px', barBackground:'#a67600', barBorder:'2px solid #111', barColor:'#eee', barDescriptionColor:'#aaa' }; G.colorSchemeViewer_light = { background:'rgba(187, 187, 187, 0.75)', imageBorder:'none', imageBoxShadow:'#888 0px 0px 0px', barBackground:'rgba(4, 4, 4, 0.7)', barBorder:'0px solid #111', barColor:'#eee', barDescriptionColor:'#aaa' }; /* ##### THUMBNAIL ELEMENT STRUCTURE ##### +--------------------------+ -> G.tn.borderHeight/2 -+ | | | G.tn.outerHeight |+------------------------+| -> =0 (always) -+ | item.thumbFullHeight || subcontainer || | | || || | | || +--------------------+ || -> G.tn.imgcBorderHeight/2 || | imgContainer | || || |+-------------------+ || || || image | || || |+-------------------+ || || +--------------------+ || || || || +--------------------+ || -+ --> G.tn.labelBorderHeight || | labelImage | || | G.tn.labelHeight || |+------------------+| || | (=0 --> overImage) || || labelTitle || || | item.thumbLabelHeight || |+------------------+| || | || || labelDescription || || || |+------------------+| || || +--------------------+ || || || |+------------------------+| +--------------------------+ */ // ************************************************************************************** // Class to store one item (= one thumbnail) // ************************************************************************************** var NGItems = (function () { var nextId = 1; // private static --> all instances // constructor function NGItems( paramTitle, paramID ) { var ID = 0; // private // public (this instance only) if( paramID === undefined || paramID === null ) { ID = nextId++; } else { ID = paramID; } this.GetID = function () { return ID; }; // public this.title = paramTitle; // image title this.description = ''; // image description this.src = ''; // full sized image URL this.width = 0; // image width this.height = 0; // image height this.destinationURL = ''; // thumbnail destination URL --> open URL instead of displaying image this.kind = ''; // 'image' or 'album' this.author = ''; // image author this.thumbFullWidth = 0; // thumbnail full width this.thumbFullHeight = 0; // thumbnail full height this.thumbLabelWidth = 0; this.thumbLabelHeight = 0; this.thumbSizes = {}; // store URLs for all available thumbnail sizes (flickr) this.thumbs = { // URLs and sizes for user defined url: { l1 : { xs:'', sm:'', me:'', la:'', xl:'' }, lN : { xs:'', sm:'', me:'', la:'', xl:'' } }, width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } }, height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } } } this.picasaThumbs = null; // store URLs and sizes this.hovered = false; // is the thumbnail currently hovered? this.hoverInitDone = false; this.contentIsLoaded = false; // album: are items already loaded? this.contentLength = 0; // album: number of items this.imageNumber = 0; // image number in the album this.eltTransform = {}; this.albumID = 0; // ID of the parent album this.paginationLastPage = 0; this.paginationLastWidth = 0; this.customData = {}; this.selected = false; this.$elt = null; // pointer to the corresponding DOM element this.$Elts = []; // cached pointers to the thumbnail content -> to avoid jQuery().find() } // public static NGItems.get_nextId = function () { return nextId; }; // public (shared across instances) NGItems.prototype = { // cached sub elements $getElt: function( elt, forceRefresh ) { if( this.$Elts[elt] !== undefined && !forceRefresh == true ) { return this.$Elts[elt]; } else { this.$Elts[elt]=this.$elt.find(elt); return this.$Elts[elt]; } }, // set thumbnail image real height for current level/resolution, and for all others level/resolutions having the same settings thumbSetImgHeight: function(h) { var lst=['xs','sm','me','la','xl']; for( var i=0; i< lst.length; i++ ) { // check if settings are same if( G.tn.settings.height.l1[lst[i]] == G.tn.settings.getH() && G.tn.settings.width.l1[lst[i]] == G.tn.settings.getW() ) { this.thumbs.height.l1[lst[i]]=h; } } for( var i=0; i< lst.length; i++ ) { if( G.tn.settings.height.lN[lst[i]] == G.tn.settings.getH() && G.tn.settings.width.lN[lst[i]] == G.tn.settings.getW() ) { this.thumbs.height.lN[lst[i]]=h; } } }, // set thumbnail image real width for current level/resolution, and for all others level/resolutions having the same settings thumbSetImgWidth: function(w) { var lst=['xs','sm','me','la','xl']; for( var i=0; i< lst.length; i++ ) { if( G.tn.settings.height.l1[lst[i]] == G.tn.settings.getH() && G.tn.settings.width.l1[lst[i]] == G.tn.settings.getW() ) { this.thumbs.width.l1[lst[i]]=w; } } for( var i=0; i< lst.length; i++ ) { if( G.tn.settings.height.lN[lst[i]] == G.tn.settings.getH() && G.tn.settings.width.lN[lst[i]] == G.tn.settings.getW() ) { this.thumbs.width.lN[lst[i]]=w; } } }, // Returns Thumbnail image thumbImg: function () { var tnImg = { src:'', width:0, height:0 }; if( this.title == 'dummydummydummy' ) { tnImg.src=G.emptyGif; return tnImg; } tnImg.src=this.thumbs.url[G.curNavLevel][G.curWidth]; tnImg.width=this.thumbs.width[G.curNavLevel][G.curWidth]; tnImg.height=this.thumbs.height[G.curNavLevel][G.curWidth]; return tnImg; }, // for future use... responsiveURL: function () { var url = ''; switch(G.O.kind) { case '': url = this.src; break; case 'flickr': url = this.src; break; case 'picasa': default: url = this.src; break; } return url; } }; return NGItems; })(); // ########################## // ##### INITIALIZATION ##### // ########################## this.Initiate = function( element, params ) { "use strict"; G.O = params; // thumbnails - label G.O.thumbnailLabel.get = function( opt ) { if( G.curNavLevel == 'l1' && G.O.thumbnailL1Label !== undefined && G.O.thumbnailL1Label[opt] !== undefined ) { return G.O.thumbnailL1Label[opt]; } else { return G.O.thumbnailLabel[opt]; } }; G.O.thumbnailLabel.set = function( opt, value ) { if( G.curNavLevel == 'l1' && G.O.thumbnailL1Label !== undefined && G.O.thumbnailL1Label[opt] !== undefined ) { G.O.thumbnailL1Label[opt]=value; } else { G.O.thumbnailLabel[opt]=value; } }; G.$E.base = jQuery(element); G.baseEltID = G.$E.base.attr('id'); G.bodyOverflowInitial=jQuery('body').css('overflow'); // [TODO] deep linking support only once per page // if( G.O.locationHash ) { // alert(location.hash); // if( location.hash.length > 0 && location.hash.indexOf('#nanogallery/'+G.baseEltID) === 0 ) { // G.O.locationHash=false; // nanoConsoleLog('locationHash has been disabled in:' + G.baseEltID +'. This option can only be used for one nanoGALLERY per page.'); // } // } // POLYFILL FOR BIND function --> for older Safari mobile // found on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Compatibility if (!Function.prototype.bind) { Function.prototype.bind = function (oThis) { if (typeof this !== "function") { // closest thing possible to the ECMAScript 5 // internal IsCallable function throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); } var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function () {}, fBound = function () { return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); }; fNOP.prototype = this.prototype; fBound.prototype = new fNOP(); return fBound; }; } String.prototype.replaceAll = function(search, replace) { if (replace === undefined) { return this.toString(); } return this.split(search).join(replace); } // Detect the animation engine // default is jQuery if( toType(jQuery.velocity) == 'object' ) { // Velocity.js G.aengine='velocity'; } else // Transit.js // if( jQuery.support.transition ) { // conflict with bootstrap if( toType(jQuery.transit) == 'object' ) { G.aengine='transition'; } // Set theme and colorScheme jQuery(element).addClass('nanogallery_theme_'+G.O.theme); SetColorScheme(element); // Hide icons (thumbnails and breadcrumb) if( G.O.thumbnailLabel.get('hideIcons') ) { var s1 = '.nanogallery_thumbnails_icons_off ', s = s1+'.nanoGalleryContainer .nanoGalleryThumbnailContainer .labelImageTitle:before { display:none !important; }'+'\n'; s += s1+'.nanoGalleryContainer .nanoGalleryThumbnailContainer .labelFolderTitle:before { display:none !important; }'+'\n'; jQuery('head').append(''); jQuery(element).addClass('nanogallery_thumbnails_icons_off'); } if( G.O.galleryToolbarHideIcons ) { var s1 = '.nanogallery_breadcrumb_icons_off ', s=s1+'.nanoGalleryNavigationbar .folderHome:before { display:none !important; }'+'\n'; s += s1+'.nanoGalleryNavigationbar .folder:before { display:none !important; }'+'\n'; jQuery('head').append(''); jQuery(element).addClass('nanogallery_breadcrumb_icons_off'); } if( G.O.thumbnailLabel.get('align') == 'right' ) { var s1 = '.nanogallery_thumbnails_label_align_right ', s = s1+'.nanoGalleryContainer .nanoGalleryThumbnailContainer .labelImage { text-align : right !important; }'+'\n'; jQuery('head').append(''); jQuery(element).addClass('nanogallery_thumbnails_label_align_right'); } if( G.O.thumbnailLabel.get('align') == 'center' ) { var s1 = '.nanogallery_thumbnails_label_align_center ', s = s1+'.nanoGalleryContainer .nanoGalleryThumbnailContainer .labelImage { text-align : center !important; }'+'\n'; jQuery('head').append(''); jQuery(element).addClass('nanogallery_thumbnails_label_align_center'); } if( G.O.thumbnailLabel.get('align') == 'left' ) { var s1 = '.nanogallery_thumbnails_label_align_left ', s = s1+'.nanoGalleryContainer .nanoGalleryThumbnailContainer .labelImage { text-align : left !important; }'+'\n'; jQuery('head').append(''); jQuery(element).addClass('nanogallery_thumbnails_label_align_left'); } // Build the gallery structure - add the containers G.$E.conNavBCon=jQuery('
').appendTo(element); G.$E.conNavBCon.hide();//css('visibility','hidden'); G.$E.conNavB=jQuery('
').appendTo(G.$E.conNavBCon); var sRTL=''; if( G.O.RTL ) { sRTL='style="text-align:right;direction:rtl;"'; } G.$E.conBC=jQuery('
').appendTo(G.$E.conNavB); G.$E.conLoadingB=jQuery('
').appendTo(element); G.$E.conTnParent=jQuery('
').appendTo(element); G.$E.conTn=jQuery('
').appendTo(G.$E.conTnParent); G.$E.conConsole=jQuery('
').appendTo(element); switch( G.O.thumbnailAlignment ) { case 'left': G.$E.conTnParent.css({'text-align':'left'}); G.$E.conNavBCon.css({'margin-left':0 }); break; case 'right': G.$E.conTnParent.css({'text-align':'right'}); G.$E.conNavBCon.css({ 'margin-right':0}); break; } jQuery('head').append(''); var t1=jQuery('
').appendTo('body'), t2=jQuery('
').appendTo(t1); G.$E.conTnHid=jQuery('
').appendTo(t2); if( G.O.supportIE8 ) { // POLYFILL FOR addEventListener/removeEventListener function --> for IE8 // found on https://gist.github.com/jonathantneal/3748027 try { !window.addEventListener && (function (WindowPrototype, DocumentPrototype, ElementPrototype, addEventListener, removeEventListener, dispatchEvent, registry) { WindowPrototype[addEventListener] = DocumentPrototype[addEventListener] = ElementPrototype[addEventListener] = function (type, listener) { var target = this; registry.unshift([target, type, listener, function (event) { event.currentTarget = target; event.preventDefault = function () { event.returnValue = false }; event.stopPropagation = function () { event.cancelBubble = true }; event.target = event.srcElement || target; listener.call(target, event); }]); this.attachEvent("on" + type, registry[0][3]); }; WindowPrototype[removeEventListener] = DocumentPrototype[removeEventListener] = ElementPrototype[removeEventListener] = function (type, listener) { for (var index = 0, register; register = registry[index]; ++index) { if (register[0] == this && register[1] == type && register[2] == listener) { return this.detachEvent("on" + type, registry.splice(index, 1)[0][3]); } } }; WindowPrototype[dispatchEvent] = DocumentPrototype[dispatchEvent] = ElementPrototype[dispatchEvent] = function (eventObject) { return this.fireEvent("on" + eventObject.type, eventObject); }; })(Window.prototype, HTMLDocument.prototype, Element.prototype, "addEventListener", "removeEventListener", "dispatchEvent", []); } catch (e) { BrowserNotification(); return false; } } else { if( G.IE <= 8 ) { BrowserNotification(); return false; } } // check parameters consistency checkPluginParameters(); // pagination container var sRTL2=''; if( G.O.RTL ) { sRTL2='style="direction:rtl;"'; } G.$E.conPagin=jQuery('
').appendTo(G.$E.conTnParent); G.$E.conPagin.hide(); // attach events var t= new userEventsGallery(G.$E.conTn[0] ); // i18n translations i18n(); // fullscreen API support if( document.fullscreenEnabled || document.webkitFullscreenEnabled || document.msFullscreenEnabled || document.mozFullScreenEnabled) { G.supportFullscreenAPI=true; } else { nanoConsoleLog('Your browser does not support the fullscreen API. Fullscreen button will not be displayed.'); } // cache some thumbnails data (sizes, styles...) ThumbnailDefCaches(); G.L.nbMaxTnPerRow=NbThumbnailsPerRow(); // display an image on start and in fullscreen if( G.O.viewerFullscreen && G.O.openOnStart.indexOf('/') > 0 ) { ngscreenfull.request(); } // lazy build the gallery if( G.O.lazyBuild != 'loadData' ) { NGFinalize(); } // GLOBAL EVENT MANAGEMENT // Page resize var resizeTimeOut=0; jQuery(window).resize( function() { if( resizeTimeOut ) clearTimeout(resizeTimeOut); if( G.containerViewerDisplayed ) { ResizeInternalViewer(); } else { resizeTimeOut = setTimeout(function () { var nw=RetrieveCurWidth(); // if( G.curAlbumIdx != -1 && G.curWidth != nw ) { if( G.curAlbumIdx != -1 && ( G.tn.settings.getH() != G.tn.settings.height[G.curNavLevel][nw] || G.tn.settings.getW() != G.tn.settings.width[G.curNavLevel][nw] ) ) { // thumbnail size changed --> render the gallery with the new sizes G.curWidth=nw; renderGallery( G.curAlbumIdx, 0 ); } else { ResizeGallery(); } return; }, 50); } }); // Event page scrolled G.$E.base.on('scroll', function () { OnScroll(); }); jQuery(window).on('scroll', function () { OnScroll(); }); } function OnScroll() { if( G.scrollTimeOut ) clearTimeout(G.scrollTimeOut); G.scrollTimeOut = setTimeout(function () { if( !G.containerViewerDisplayed ) { if( G.O.lazyBuild == 'loadData' ) { if( inViewportVert(G.$E.conTnParent,G.O.lazyBuildTreshold) ){ G.O.lazyBuild='none'; NGFinalize(); } } if( G.delayedAlbumIdx != -1 && inViewportVert(G.$E.conTnParent,G.O.lazyBuildTreshold) ){ DisplayAlbumFinalize( G.delayedAlbumIdx, G.delayedSetLocationHash ); } thumbnailsLazySetSrc(); return; } }, 100); } function getSpecialKeysPressed(e){ G.isShiftPressed = e.shiftKey; G.isAltPressed = e.altKey; G.isCtrlPressed = e.ctrlKey; G.isMetaPressed = e.metaKey; } // exposed objects for callbacks function ExposedObjects() { return { animationEngine:G.aengine, t:'test' }; } // Message for unsupported browser function BrowserNotification() { var m='Your browser version is not supported anymore. The image gallery cannot be displayed.

Please update to a more recent one. Download:
'; m+='    Chrome
'; m+='    Firefox
'; m+='    Internet Explorer
'; m+='    Safari'; nanoAlert(m, false); } // Original author : John Hrvatin, Lead Program Manager, Internet Explorer - http://blogs.msdn.com/b/ie/archive/2011/10/28/a-best-practice-for-programming-with-vendor-prefixes.aspx function FirstSupportedPropertyName(prefixedPropertyNames) { var tempDiv = document.createElement("div"); for (var i = 0; i < prefixedPropertyNames.length; ++i) { if (typeof tempDiv.style[prefixedPropertyNames[i]] != 'undefined') return prefixedPropertyNames[i]; } return null; } // ##### // Finalize initialization // ##### function NGFinalize() { var sizeImageMax=Math.max(window.screen.width, window.screen.height); if( window.devicePixelRatio != undefined ) { if( window.devicePixelRatio > 1 ) { sizeImageMax=sizeImageMax*window.devicePixelRatio; } } for( var j=0; j0 ) {G.O.itemsBaseURL+='/';} switch(G.O.kind) { // MARKUP / API case '': NGAddItem(G.i18nTranslations.breadcrumbHome, '', '', '', '', 'album', '', '0', '-1' ); if( G.O.items !== undefined && G.O.items !== null ) { ProcessItemOption(); if( !ProcessLocationHash(false) ) { DisplayAlbum(0,false); } } else { var elements=jQuery(G.$E.base).children('a'); if( elements.length > 0 ) { ProcessHREF(elements); if( !ProcessLocationHash(false) ) { DisplayAlbum(0,false); } } else nanoAlert('error: no image to process.'); } break; // FLICKR STORAGE case 'flickr': if( !G.O.flickrSkipOriginal ) { G.flickr.photoAvailableSizes.push(10000); G.flickr.photoAvailableSizesStr.push('o'); } for( i=0; i 0 ? G.O.photoset : '0', '-1' ); FlickrProcessItems(0,true,-1,false); break; // CUSTOM STORAGE case 'json': NGAddItem(G.i18nTranslations.breadcrumbHome, '', '', '', '', 'album', '', G.O.album.length > 0 ? encodeURIComponent(G.O.album) : '0', '-1' ); JsonProcessItems(0,true,-1,false); break; // PICASA/GOOGLE+ STORAGE case 'picasa': default: if( G.O.album.length > 0 ) { var p=G.O.album.indexOf('&authkey='); if( p >= 0 ) { var albumId=G.O.album.substring(0,p), opt=G.O.album.substring(p); if( opt.indexOf('Gv1sRg') == -1 ) { opt='&authkey=Gv1sRg'+opt.substring(9); } var newItem=NGAddItem(G.i18nTranslations.breadcrumbHome, '', '', '', '', 'album', '', albumId, '-1' ); newItem.customData.authkey=opt; } else { NGAddItem(G.i18nTranslations.breadcrumbHome, '', '', '', '', 'album', '', G.O.album, '-1' ); } } else { NGAddItem(G.i18nTranslations.breadcrumbHome, '', '', '', '', 'album', '', '0', '-1' ); } PicasaProcessItems(0,true,-1,false); break; } // Keyboard management --> Image Viewer // Keyboard management --> Album Viewer (Else section) jQuery(document).keyup(function(e) { getSpecialKeysPressed(e); if( G.containerViewerDisplayed ) { switch( e.keyCode) { case 27: // Esc key CloseInternalViewer(true); break; case 32: // SPACE case 13: // ENTER SlideshowToggle(); break; case 38: // UP case 39: // RIGHT case 33: // PAGE UP DisplayNextImagePart1(); break; case 40: // DOWN case 37: // LEFT case 34: // PAGE DOWN DisplayPreviousImage(); break; case 35: // END case 36: // BEGIN } } else if ( !G.containerViewerDisplayed && G.curAlbumIdx > 0 && G.O.galleryEnableKeyboard ) { switch( e.keyCode) { case 27: // Esc key DisplayAlbum(0, 'false'); break; case 38: // UP case 39: // RIGHT case 33: // PAGE UP DisplayNextAlbum(); break; case 40: // DOWN case 37: // LEFT case 34: // PAGE DOWN DisplayPreviousAlbum(); break; case 32: // SPACE case 13: // ENTER case 35: // END case 36: // BEGIN } } }); // TODO: jQuery(window).click(getSpecialKeysPressed); jQuery(window).mousemove(getSpecialKeysPressed); // browser back-button to close the image currently displayed if( G.O.locationHash ) { jQuery(window).bind( 'hashchange', function() { ProcessLocationHash(true); }); } // gallery fullpage if( G.O.galleryFullpageButton ) { if( G.O.RTL ) { G.$E.conNavBFullpage =jQuery('
').prependTo(G.$E.conNavB); } else { G.$E.conNavBFullpage =jQuery('
').appendTo(G.$E.conNavB); } G.$E.conNavBFullpage.on('click', function(e){ if( G.$E.conNavBFullpage.hasClass('setFullPageButton') ) { // switch to fullpage display mode if( G.containerViewerDisplayed ) { return; } if( G.O.maxWidth > 0 ) { jQuery(G.$E.base).css({'maxWidth':''}); } G.$E.conNavBFullpage.removeClass('setFullPageButton').addClass('removeFullPageButton'); setElementOnTop('', G.$E.base); for( j=0; j 0 ) { jQuery(G.$E.base).css({'maxWidth':G.O.maxWidth}); } G.$E.base.removeClass('fullpage'); for( j=0; j0 ) { window.location = G.I[n].destinationURL; //window.open(G.I[n].destinationURL, '_blank'); return; } G.openNoDelay=false; if( G.I[n].kind == 'album' ) { OpenAlbum(n, false, -1, true); } else { // Display image DisplayImage(n,false); } } // Handle the start of gestures --> click event this.handleGestureStartNoDelay = function(e) { // delay to ignore click event after touchstart event var eType=(jQuery(e.target).get(0).tagName).toUpperCase(); // class customEventHandler --> disable standard event handler if( G.containerViewerDisplayed || eType == 'A' || eType == 'INPUT' || jQuery(e.target).hasClass('customEventHandler') ) { // detect click on custom element // selection checkbox clicked if( jQuery(e.target).hasClass('ngChekbox') ) { var n=jQuery(e.target).parent().data('index'); if( n != undefined ) { thumbnailSelection(G.I[n], undefined, false); } } e.stopPropagation(); //e.eventDefault(); return false; } getSpecialKeysPressed(e); // if items are selectable, cannot limit on user speed if( (new Date().getTime()) - G.timeLastTouchStart < 400 && G.O.itemsSelectable !== true ) { return; } G.openNoDelay=true; this.handleGestureStart(e); }.bind(this); // Handle the start of gestures this.handleGestureStart = function(e) { var eType=(jQuery(e.target).get(0).tagName).toUpperCase(); // class customEventHandler --> disable standard event handler if( G.containerViewerDisplayed || eType == 'A' || eType == 'INPUT' || jQuery(e.target).hasClass('customEventHandler') ) { // detect click on custom element e.stopPropagation(); //e.eventDefault(); return false; } if( (new Date().getTime()) - G.timeImgChanged < 400 && G.O.itemsSelectable !== true ) { return; } if( (new Date().getTime()) - G.timeLastTouchStart < 400 && G.O.itemsSelectable !== true ) { return; } G.timeLastTouchStart=new Date().getTime(); var target = e.target || e.srcElement; var found=false; while( target != G.$E.conTn[0] ) { // go element parent up to find the thumbnail element // if( target.getAttribute('class') == 'nanoGalleryThumbnailContainer' ) { if( jQuery(target).hasClass('nanoGalleryThumbnailContainer') ) { if( G.$currentTouchedThumbnail != null && !G.$currentTouchedThumbnail.is(jQuery(target)) ) { ThumbnailHoverOutAll(); } G.$currentTouchedThumbnail=jQuery(target); found=true; } target = target.parentNode; } if( !found ) { return; } // handle thumbnail selection if(G.O.itemsSelectable === true){ if(G.isShiftPressed || G.isCtrlPressed || G.isMetaPressed || e.target.nodeName.toLowerCase() === 'input'){ thumbnailSelection( G.I[G.$currentTouchedThumbnail.data('index')] ); return false; } if (G.selectMode === true) { thumbnailSelection( G.I[G.$currentTouchedThumbnail.data('index')] ); return false; } if (G.I[G.$currentTouchedThumbnail.data('index')].kind === G.selectMode) { thumbnailSelection( G.I[G.$currentTouchedThumbnail.data('index')] ); return false; } var idxctt = G.$currentTouchedThumbnail.data('index'); G.touchSelectTO = setTimeout(function(){ thumbnailSelection( G.I[idxctt] ); },500); } initialViewport=getViewport(); //if(e.touches && e.touches.length > 1) { return; } initialTouchPos = getGesturePointFromEvent(e); initialOffsetTop=getViewport().t; //if( G.gallerySwipeInitDone ) { return; } // Add the move and end listeners if (window.navigator.msPointerEnabled) { // Pointer events are supported. document.addEventListener('MSPointerMove', this.handleGestureMove, true); document.addEventListener('MSPointerUp', this.handleGestureEnd, true); } else { // Add Touch Listeners document.addEventListener('touchmove', this.handleGestureMove, true); document.addEventListener('touchend', this.handleGestureEnd, true); document.addEventListener('touchcancel', this.handleGestureEnd, true); // Add Mouse Listeners document.addEventListener('mousemove', this.handleGestureMove, true); document.addEventListener('mouseup', this.handleGestureEnd, true); } // makes content unselectable --> avoid image drag during 'mouse swipe' G.$E.base.addClass('unselectable').find('*').attr('draggable', 'false').attr('unselectable', 'on'); G.gallerySwipeInitDone=true; }.bind(this); // Handle move gestures this.handleGestureMove = function (e) { //e.preventDefault(); // --> uncomment this to avoid viewport scrolling on touchscreen lastTouchPos = getGesturePointFromEvent(e); if( isAnimating ) { return; } if( G.O.paginationSwipe ) { if( G.pgMaxLinesPerPage > 0 && G.tn.settings.getH() != 'auto' && G.tn.settings.getW() != 'auto' ) { if( Math.abs(initialTouchPos.x - lastTouchPos.x) > 15 || onlyX ) { e.preventDefault(); // if swipe horizontaly the gallery, avoid moving page also onlyX=true; isAnimating = true; window.requestAnimationFrame(onAnimFrame); } } } }.bind(this); // Handle end gestures this.handleGestureEnd = function(e) { if( e.cancelable ) { e.preventDefault(); } e.stopPropagation(); // if(e.touches && e.touches.length > 0) { // return; // } isAnimating = false; onlyX=false; // Remove Event Listeners if (window.navigator.msPointerEnabled) { // Remove Pointer Event Listeners document.removeEventListener('MSPointerMove', this.handleGestureMove, true); document.removeEventListener('MSPointerUp', this.handleGestureEnd, true); } else { // Remove Touch Listeners document.removeEventListener('touchmove', this.handleGestureMove, true); document.removeEventListener('touchend', this.handleGestureEnd, true); document.removeEventListener('touchcancel', this.handleGestureEnd, true); // Remove Mouse Listeners document.removeEventListener('mousemove', this.handleGestureMove, true); document.removeEventListener('mouseup', this.handleGestureEnd, true); } if(G.O.itemsSelectable === true){ if((new Date().getTime() - G.timeLastTouchStart) > 500 ){ return false; }else{ clearTimeout(G.touchSelectTO); } } // allow text + image selection again G.$E.base.addClass('unselectable').find('*').attr('draggable', 'true').attr('unselectable', 'off'); updateSwipeRestPosition(); initialTouchPos=null; lastTouchPos=null; currentXPosition=0; onlyX=false; startViewport=null; }.bind(this); function OpenTouchedThumbnail() { currentXPosition=0; initialTouchPos=null; lastTouchPos=null; ElementTranslateX(G.$E.conTn[0],0); if( G.containerViewerDisplayed ) { G.$currentTouchedThumbnail=null; G.openNoDelay=false; } else { if( G.$currentTouchedThumbnail != null ) { if( Math.abs(initialViewport.t-getViewport().t) > 10 ) { // viewport has been scrolled (touchscreen)--> open is cancelled ThumbnailHoverOut(G.$currentTouchedThumbnail); G.$currentTouchedThumbnail=null; G.openNoDelay=false; return; } var $t=G.$currentTouchedThumbnail; var n=$t.data('index'); if( n == undefined ) { return; } if( ( G.curNavLevel == 'l1' && G.O.touchAnimationL1 !== undefined ? G.O.touchAnimationL1: G.O.touchAnimation) && !G.openNoDelay ) { // automatically opens the touched thumbnail (to disply an image or to open an album) if( G.O.touchAutoOpenDelay > 0 ) { ThumbnailHoverOutAll(); ThumbnailHover($t); window.clearInterval(G.touchAutoOpenDelayTimerID); G.touchAutoOpenDelayTimerID=window.setInterval(function(){ window.clearInterval(G.touchAutoOpenDelayTimerID); if( Math.abs(initialViewport.t-getViewport().t) > 10 ) { // viewport has been scrolled after hover effect delay (touchscreen)--> open is cancelled G.openNoDelay=false; G.$currentTouchedThumbnail=null; ThumbnailHoverOut($t); } else { OpenThumbnail(n); } }, G.O.touchAutoOpenDelay); } else { // 2 touch scenario if( !G.I[n].hovered ) { // first touch ThumbnailHoverOutAll(); ThumbnailHover($t); } else { // second touch OpenThumbnail(n); } } } else { OpenThumbnail(n); } } else { G.openNoDelay=false; } } return; } function updateSwipeRestPosition() { if( lastTouchPos == null || initialTouchPos == null ) { // touchend without touchmove // currentXPosition=0; // initialTouchPos=null; OpenTouchedThumbnail(); return; } var differenceInX = initialTouchPos.x - lastTouchPos.x; var differenceInY = initialTouchPos.y - lastTouchPos.y; currentXPosition = currentXPosition - differenceInX; if( G.pgMaxLinesPerPage > 0 && G.tn.settings.getH() != 'auto' && G.tn.settings.getW() != 'auto' ) { // pagination // if( Math.abs(differenceInX) > 30) { if( G.O.paginationSwipe && (Math.abs(differenceInX) > 40 && Math.abs(initialViewport.t-getViewport().t) <= 10) ) { G.$currentTouchedThumbnail=null; currentXPosition=0; initialTouchPos=null; lastTouchPos=null; ThumbnailHoverOutAll(); if( differenceInX < -40 ) { paginationPreviousPage(); } else { paginationNextPage(); } } else { OpenTouchedThumbnail(); } } else { // no pagination OpenTouchedThumbnail(); } return; } function getGesturePointFromEvent(e) { var point = {}; if(e.targetTouches) { point.x = e.targetTouches[0].clientX; point.y = e.targetTouches[0].clientY; } else { // Either Mouse event or Pointer Event point.x = e.clientX; point.y = e.clientY; } return point; } function onAnimFrame() { if(!isAnimating) { return; } if( G.pgMaxLinesPerPage > 0 && G.tn.settings.getH() != 'auto' && G.tn.settings.getW() != 'auto' ) { var differenceInX = initialTouchPos.x - lastTouchPos.x; ElementTranslateX(elementToSwipe,currentXPosition - differenceInX); } isAnimating = false; } function ThumbnailOnMouseenter(e) { if( G.containerViewerDisplayed ) { return; } var target = e.target || e.srcElement; // if( target.getAttribute('class') == 'nanoGalleryThumbnailContainer' ) { if( jQuery(target).hasClass('nanoGalleryThumbnailContainer') ) { //if( G.$currentTouchedThumbnail == null ) { ThumbnailHover(jQuery(target)); //} } } function ThumbnailOnMouseleave(e) { var target = e.target || e.srcElement; if( jQuery(target).hasClass('nanoGalleryThumbnailContainer') ) { // if( target.getAttribute('class') == 'nanoGalleryThumbnailContainer' ) { ThumbnailHoverOut(jQuery(target)); } } // Check if MS pointer events are supported. if (window.navigator.msPointerEnabled) { // Add Pointer Event Listener elementToSwipe.addEventListener('MSPointerDown', this.handleGestureStartNoDelay, true); } else { // Add Touch Listener elementToSwipe.addEventListener('touchstart', this.handleGestureStart, true); // Add Mouse Listener if( !G.isIOS ) { var thatObject = this; elementToSwipe.addEventListener('mousedown', function(e){ // filter : if the user uses the right click, // do not do anything if(e.button != 2){ thatObject.handleGestureStartNoDelay(e); } }, true); } } // MOUSE OVER elementToSwipe.addEventListener('mouseenter', ThumbnailOnMouseenter, true); elementToSwipe.addEventListener('mouseleave', ThumbnailOnMouseleave, true); } // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating // MIT license (function() { var lastTime = 0; var vendors = ['ms', 'moz', 'webkit', 'o']; for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; } if (!window.requestAnimationFrame) window.requestAnimationFrame = function(callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; }; if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function(id) { clearTimeout(id); }; }()); // ##### CHECK PLUGIN PARAMETERS CONSISTENCY function checkPluginParameters() { if( G.O.viewer == 'fancybox' ) { if( typeof(jQuery.fancybox) === 'undefined' ) { G.O.viewer = 'internal'; nanoConsoleLog('Fancybox could not be found. Fallback to internal viewer. Please check the files included in the HTML page.'); } } if( G.O.userID.toUpperCase() == 'CBRISBOIS@GMAIL.COM' || G.O.userID == '111186676244625461692' ) { if( G.O.blackList == '' || G.O.blackList.toUpperCase() == 'SCRAPBOOK|PROFIL' ) { G.O.blackList='profil|scrapbook|forhomepage'; } } if( G.O.blackList != '' ) { G.blackList=G.O.blackList.toUpperCase().split('|'); } if( G.O.whiteList != '' ) { G.whiteList=G.O.whiteList.toUpperCase().split('|'); } if( G.O.albumList != '' ) { G.albumList=G.O.albumList.toUpperCase().split('|'); } if( G.O.kind == 'picasa' || G.O.kind == 'flickr' || G.O.kind == 'json' ) { G.O.displayBreadcrumb=true; } // flickr if( G.O.photoset !== undefined ) { if( G.O.photoset.length > 0) { G.O.displayBreadcrumb=false; } } else { G.O.photoset=''; } // picasa if( G.O.album !== undefined ) { if( G.O.album.length > 0 ) { G.O.displayBreadcrumb=false; } } else { G.O.album=''; } if( G.O.maxWidth > 0 ) { jQuery(G.$E.base).css({'maxWidth':G.O.maxWidth}); jQuery(G.$E.base).css({'margin-left':'auto'}); jQuery(G.$E.base).css({'margin-right':'auto'}); } if( toType(G.O.slideshowDelay) == 'number' && G.O.slideshowDelay >= 2000 ) { G.slideshowDelay=G.O.slideshowDelay; } else { nanoConsoleLog('Parameter "slideshowDelay" must be an integer >= 2000 ms.'); } if( toType(G.O.thumbnailDisplayInterval) == 'number' && G.O.thumbnailDisplayInterval >= 0 ) { G.tn.displayInterval=G.O.thumbnailDisplayInterval; } else { nanoConsoleLog('Parameter "thumbnailDisplayInterval" must be an integer.'); } if( toType(G.O.thumbnailLazyLoadTreshold) == 'number' && G.O.thumbnailLazyLoadTreshold >= 0 ) { G.tn.lazyLoadTreshold=G.O.thumbnailLazyLoadTreshold; } else { nanoConsoleLog('Parameter "thumbnailLazyLoadTreshold" must be an integer.'); } if( toType(G.O.paginationMaxLinesPerPage) == 'number' && G.O.paginationMaxLinesPerPage >= 0 ) { G.pgMaxLinesPerPage=G.O.paginationMaxLinesPerPage; } else { nanoConsoleLog('Parameter "paginationMaxLinesPerPage" must be an integer.'); } // resolution breakpoints --> convert old syntax to new one if( G.O.thumbnailSizeSM !== undefined ) { G.O.breakpointSizeSM=G.O.thumbnailSizeSM; } if( G.O.thumbnailSizeME !== undefined ) { G.O.breakpointSizeME=G.O.thumbnailSizeME; } if( G.O.thumbnailSizeLA !== undefined ) { G.O.breakpointSizeLA=G.O.thumbnailSizeLA; } if( G.O.thumbnailSizeXL !== undefined ) { G.O.breakpointSizeXL=G.O.thumbnailSizeXL; } /* if( G.tn.settings.getH() == 'auto' || G.tn.settings.getW() == 'auto' ) { if( G.O.paginationMaxLinesPerPage >0 ) { nanoConsoleLog('Parameters "paginationMaxLinesPerPage" and "thumbnailWidth/thumbnailHeight" value "auto" are not compatible.'); } G.pgMaxLinesPerPage=0; } */ // random sorting var s1=G.O.albumSorting.toUpperCase(); if( s1.indexOf('RANDOM') == 0 && s1.length > 6 ) { n= parseInt(s1.substring(6)); if( n > 0 ) { G.maxAlbums=n; } G.O.albumSorting='random'; } var s2=G.O.photoSorting.toUpperCase(); if( s2.indexOf('RANDOM') == 0 && s2.length > 6 ) { n= parseInt(s2.substring(6)); if( n > 0 ) { G.maxPhotos=n; } G.O.photoSorting='random'; } var mA=parseInt(G.O.albumMax); if( mA > 0 ) { G.maxAlbums=n; } // thumbnails hover effects - Level1 var tL1HE=G.O.thumbnailL1HoverEffect; if( tL1HE !== undefined ) { switch( toType(tL1HE) ) { case 'string': var tmp=tL1HE.split(','); for(var i=0; i 0 && vpW < G.O.breakpointSizeSM) { return 'xs'; } if( G.O.breakpointSizeME > 0 && vpW < G.O.breakpointSizeME) { return 'sm'; } if( G.O.breakpointSizeLA > 0 && vpW < G.O.breakpointSizeLA) { return 'me'; } if( G.O.breakpointSizeXL > 0 && vpW < G.O.breakpointSizeXL) { return 'la'; } return 'xl'; } function RetrieveMaxWidth() { var vpW= Math.max(getViewport().w, getViewport().h); if( G.O.breakpointSizeSM > 0 && vpW < G.O.breakpointSizeSM) { return 'xs'; } if( G.O.breakpointSizeME > 0 && vpW < G.O.breakpointSizeME) { return 'sm'; } if( G.O.breakpointSizeLA > 0 && vpW < G.O.breakpointSizeLA) { return 'me'; } if( G.O.breakpointSizeXL > 0 && vpW < G.O.breakpointSizeXL) { return 'la'; } return 'xl'; } // HOVER EFFECTS function NewTHoverEffect() { // easing : jQuery supports only 'swing' and 'linear' var oDef={'delay':0, 'delayBack':0, 'duration':400, 'durationBack':200, 'easing':'swing', 'easingBack': 'swing', 'animParam':null }; if( G.aengine != 'animate' ) { oDef.easing='ease'; oDef.easingBack='ease'; } return oDef; } // check if effect is compatible with the used animation engine // check also consistency of thumbnail configuration with hover effect function isAEngineSupported( effect ) { // var isBasic = /labelOpacity50|borderLighter|borderDarker/i.test(effect), var isBasic = /labelOpacity50|borderLighter|borderDarker/i.test(effect), // isStd = /imageFlipVertical|imageFlipHorizontal|imageRotateCornerBR|imageRotateCornerBL|rotateCornerBL|rotateCornerBR|imageScale150|overScale|overScaleOutside|imageScaleIn80|imageScale150Outside|scale120|scaleLabelOverImage|slideUp|slideDown|slideLeft|slideRight|imageSlideUp|imageSlideDown|imageSlideLeft|imageSlideRight|labelAppear|labelAppear75|descriptionAppear|labelSlideDown|labelSlideUp|labelSlideUpTop|imageInvisible|imageOpacity50|descriptionSlideUp|labelSplitVert|labelSplit4|labelAppearSplitVert|labelAppearSplit4|imageSplitVert|imageSplit4|imageSlide2Up|imageSlide2Down|imageSlide2Left|imageSlide2Right|imageSlide2Random|imageSlide2UpRight|imageSlide2UpLeft|imageSlide2DownRight|imageSlide2DownLeft/i.test(effect), isStd = /imageFlipVertical|imageFlipHorizontal|imageRotateCornerBR|imageRotateCornerBL|rotateCornerBL|rotateCornerBR|imageScale150|overScale|overScaleOutside|imageScaleIn80|imageScale150Outside|scale120|scaleLabelOverImage|slideUp|slideDown|slideLeft|slideRight|imageSlideUp|imageSlideDown|imageSlideLeft|imageSlideRight|labelAppear|labelAppear75|descriptionAppear|labelSlideDown|labelSlideUp|labelSlideUpTop|imageInvisible|imageOpacity50|descriptionSlideUp|labelSplitVert|labelSplit4|labelAppearSplitVert|labelAppearSplit4|imageSplitVert|imageSplit4/i.test(effect), // isAdv = /imageScaleIn80|imageScale150|imageScale150Outside|scale120|overScale|overScaleOutside|scaleLabelOverImage|imageFlipHorizontal|imageFlipVertical|rotateCornerBR|rotateCornerBL|imageRotateCornerBR|imageRotateCornerBL|imageExplode/i.test(effect); isAdv = /imageExplode/i.test(effect); G.O.touchAutoOpenDelay= parseInt(G.O.touchAutoOpenDelay); if( G.O.touchAutoOpenDelay == 0 ) { G.O.touchAutoOpenDelay=1000; } if( !isBasic && !isStd && !isAdv ) { nanoAlert('Unknow parameter value: thumbnailHoverEffect="'+effect+'".'); return false; } if( G.O.thumbnailLabel.get('position') == 'onBottom' && !/borderLighter|borderDarker|imageOpacity50|imageScale150|imageScaleIn80|imageSlide2Up|imageSlide2Down|imageSlide2Left|imageSlide2Right|imageSlide2Random|imageSlide2UpRight|imageSlide2UpLeft|imageSlide2DownRight|imageSlide2DownLeft|imageScale150Outside|scale120/i.test(effect) ) { nanoAlert('The parameter combination thumbnailHoverEffect="'+effect+'" and thumbnailLabel.position="onBottom" is not supported.'); return false; } if( (isAdv && (G.aengine == 'animate' || G.CSStransformName == null) ) ) { nanoConsoleLog('Parameter thumbnailHoverEffect="'+effect+'" requires one of the additionals jQuery plugins "Velocity" or "Transit".'); return false; } return true; } // I18N : define text translations function i18n() { // browser language G.i18nLang = (navigator.language || navigator.userLanguage).toUpperCase(); if( G.i18nLang === 'UNDEFINED') { G.i18nLang=''; } var llang=-('_'+G.i18nLang).length; if( toType(G.O.i18n) == 'object' ){ for( var key in G.O.i18n ) { //var value = G.O.i18n[key]; var s=key.substr(llang); if( s == ('_'+G.i18nLang) ) { G.i18nTranslations[key.substr(0,key.length-s.length)]=G.O.i18n[key]; } else { G.i18nTranslations[key]=G.O.i18n[key]; } } } } // Location Hash function ProcessLocationHash(isTriggeredByEvent) { // special use case -> openOnStart can be processed like location hash, only once (on start) if( G.O.openOnStart != '' ) { var ID=G.O.openOnStart; G.O.openOnStart=''; return OpenItem( false, ID, true ); } // standard use case -> location hash processing if( !G.O.locationHash ) { return false; } var albumID=null, imageID=null, curGal='#nanogallery/'+G.baseEltID+'/', hash=location.hash; if( hash == G.lastLocationHash ) { return; } if( hash == '' ) { if( G.lastOpenAlbumID != -1 ) { // back button and no hash --> display first album G.lastLocationHash=''; OpenAlbum(0,false,-1,false); return true; } } if( hash.indexOf(curGal) == 0 ) { var ID=hash.substring(curGal.length); return OpenItem( isTriggeredByEvent, ID, !isTriggeredByEvent ); } //return {albumID:albID, imageID:imgID}; } function OpenItem( isTriggeredByEvent, ID, openAlbumOnViewerClose ) { var albumID=null, imageID=null, p=ID.indexOf('/'), albumIdx=-1, imageIdx=-1, l=G.I.length; if( p > 0 ) { albumID=ID.substring(0,p); imageID=ID.substring(p+1); for(var i=0; i0 ) { s=item[property+'_'+G.i18nLang]; return s; } } s=item[property]; return s; } // #################################### // ##### LIST OF ITEMS IN OPTIONS ##### // #################################### function GetImageTitle( imageSRC ) { if( G.O.thumbnailLabel.get('title') == '%filename' ) { return (imageSRC.split('/').pop()).replace('_',' '); } if( G.O.thumbnailLabel.get('title') == '%filenameNoExt' ) { var s=imageSRC.split('/').pop(); return (s.split('.').shift()).replace('_',' '); } return imageSRC; } function ProcessItemOption() { var foundAlbumID=false; if( typeof G.O.dataSorting !== 'undefined' ) { if( G.O.dataSorting == 'random' ) { G.O.items=AreaShuffle(G.O.items); }else if( G.O.dataSorting == 'reversed' ) { G.O.items=G.O.items.reverse(); } } jQuery.each(G.O.items, function(i,item){ var title=''; title=GetI18nItem(item,'title'); if( title === undefined ) { title=''; } var src=G.O.itemsBaseURL; if( item['src'+RetrieveMaxWidth().toUpperCase()] !== undefined ) { src+=item['src'+RetrieveMaxWidth().toUpperCase()]; } else { src+=item.src; } var thumbsrc=''; if( item.srct !== undefined && item.srct.length>0 ) { thumbsrc=G.O.itemsBaseURL+item.srct; } else { thumbsrc=src; } var thumbsrcX2=''; if( item.srct2x !== undefined && item.srct2x.length>0 ) { thumbsrcX2=G.O.itemsBaseURL+item.srct2x; } else { if( thumbsrc != '' ) { thumbsrcX2=thumbsrc; } else { thumbsrcX2=src; } } if( G.O.thumbnailLabel.get('title') != '' ) { title=GetImageTitle(src); } var description=''; //' '; description=GetI18nItem(item,'description'); if( description === undefined ) { description=''; } //if( toType(item.description) == 'string' ) { // description=item.description; //} var destinationURL=''; if( item.destURL !== undefined && item.destURL.length>0 ) { destinationURL=item.destURL; } //if( item.tags !== undefined && item.tags.length>0 ) { // tags=item.tags; //} var tags=GetI18nItem(item,'tags'); if( tags === undefined ) { tags=''; } var albumID=0; if( item.albumID !== undefined ) { albumID=item.albumID; foundAlbumID=true; } var ID=null; if( item.ID !== undefined ) { ID=item.ID; } var kind='image'; if( item.kind !== undefined && item.kind.length>0 ) { kind=item.kind; } var newItem=NGAddItem(title, thumbsrc, src, description, destinationURL, kind, tags, ID, albumID ); // thumbnail image size var tw=0; if( item.imgtWidth !== undefined && item.imgtWidth>0 ) { tw=item.imgtWidth; //newItem.thumbImgWidth=tw; } var th=0; if( item.imgtHeight !== undefined && item.imgtHeight>0 ) { th=item.imgtHeight; //newItem.thumbImgHeight=th; } newItem.thumbs = { url: { l1 : { xs:thumbsrc, sm:thumbsrc, me:thumbsrc, la:thumbsrc, xl:thumbsrc }, lN : { xs:thumbsrc, sm:thumbsrc, me:thumbsrc, la:thumbsrc, xl:thumbsrc } }, width: { l1 : { xs:tw, sm:tw, me:tw, la:tw, xl:tw }, lN : { xs:tw, sm:tw, me:tw, la:tw, xl:tw } }, height: { l1 : { xs:th, sm:th, me:th, la:th, xl:th }, lN : { xs:th, sm:th, me:th, la:th, xl:th } } }; // custom data if( item.customData !== null ) { newItem.customData=cloneJSObject(item.customData); } if( typeof G.O.fnProcessData == 'function' ) { G.O.fnProcessData(newItem, 'api', null); } }); if( foundAlbumID ) { G.O.displayBreadcrumb=true; } // get the number of images per album for all the items var l=G.I.length, nb=0, nbImages=0; for( var i=0; i0 ) { thumbsrc=G.O.itemsBaseURL+jQuery(item).attr('data-ngthumb'); } if( jQuery(item).attr('data-ngThumb') !== undefined && jQuery(item).attr('data-ngThumb').length>0 ) { thumbsrc=G.O.itemsBaseURL+jQuery(item).attr('data-ngThumb'); } var thumbsrcX2=''; if( jQuery(item).attr('data-ngthumb2x') !== undefined && jQuery(item).attr('data-ngthumb2x').length>0 ) { thumbsrcX2=G.O.itemsBaseURL+jQuery(item).attr('data-ngthumb2x'); } if( jQuery(item).attr('data-ngThumb2x') !== undefined && jQuery(item).attr('data-ngThumb2x').length>0 ) { thumbsrcX2=G.O.itemsBaseURL+jQuery(item).attr('data-ngThumb2x'); } // responsive image source var src='', st=RetrieveMaxWidth().toUpperCase(); if( jQuery(item).attr('data-ngsrc'+st) !== undefined && jQuery(item).attr('data-ngsrc'+st).length>0 ) { src=G.O.itemsBaseURL+jQuery(item).attr('data-ngsrc'+st); } if( jQuery(item).attr('data-ngSrc'+st) !== undefined && jQuery(item).attr('data-ngSrc'+st).length>0 ) { src=G.O.itemsBaseURL+jQuery(item).attr('data-ngSrc'+st); } if( src == '' ) { src=G.O.itemsBaseURL+jQuery(item).attr('href'); } //newObj.description=jQuery(item).attr('data-ngdesc'); var description=''; if( jQuery(item).attr('data-ngdesc') !== undefined && jQuery(item).attr('data-ngdesc').length>0 ) { description=jQuery(item).attr('data-ngdesc'); } if( jQuery(item).attr('data-ngDesc') !== undefined && jQuery(item).attr('data-ngDesc').length>0 ) { description=jQuery(item).attr('data-ngDesc'); } var destURL=''; if( jQuery(item).attr('data-ngdest') !== undefined && jQuery(item).attr('data-ngdest').length>0 ) { destURL=jQuery(item).attr('data-ngdest'); } if( jQuery(item).attr('data-ngDest') !== undefined && jQuery(item).attr('data-ngDest').length>0 ) { destURL=jQuery(item).attr('data-ngDest'); } var albumID=0; if( jQuery(item).attr('data-ngalbumid') !== undefined ) { albumID=jQuery(item).attr('data-ngalbumid'); foundAlbumID=true; } if( jQuery(item).attr('data-ngAlbumID') !== undefined ) { albumID=jQuery(item).attr('data-ngAlbumID'); foundAlbumID=true; } var ID=null; if( jQuery(item).attr('data-ngid') !== undefined ) { ID=jQuery(item).attr('data-ngid'); } if( jQuery(item).attr('data-ngID') !== undefined ) { ID=jQuery(item).attr('data-ngID'); } var kind='image'; if( jQuery(item).attr('data-ngkind') !== undefined && jQuery(item).attr('data-ngkind').length>0 ) { kind=jQuery(item).attr('data-ngkind'); } if( jQuery(item).attr('data-ngKind') !== undefined && jQuery(item).attr('data-ngKind').length>0 ) { kind=jQuery(item).attr('data-ngKind'); } var title=jQuery(item).text(); if( !(G.O.thumbnailLabel.get('title') == '' || G.O.thumbnailLabel.get('title') == undefined) ) { title=GetImageTitle(src); } var newItem=NGAddItem(title, thumbsrc, src, description, destURL, kind, '', ID, albumID ); // thumbnail image size var tw=0; if( jQuery(item).attr('data-ngthumbImgWidth') !== undefined && jQuery(item).attr('data-ngthumbImgWidth').length>0 ) { tw=jQuery(item).attr('data-ngthumbImgWidth'); //newItem.thumbImgWidth=tw; } var th=0; if( jQuery(item).attr('data-ngthumbImgHeight') !== undefined && jQuery(item).attr('data-ngthumbImgHeight').length>0 ) { th=jQuery(item).attr('data-ngthumbImgHeight'); //newItem.thumbImgHeight=th; } newItem.thumbs = { url: { l1 : { xs:thumbsrc, sm:thumbsrc, me:thumbsrc, la:thumbsrc, xl:thumbsrc }, lN : { xs:thumbsrc, sm:thumbsrc, me:thumbsrc, la:thumbsrc, xl:thumbsrc } }, width: { l1 : { xs:tw, sm:tw, me:tw, la:tw, xl:tw }, lN : { xs:tw, sm:tw, me:tw, la:tw, xl:tw } }, height: { l1 : { xs:th, sm:th, me:th, la:th, xl:th }, lN : { xs:th, sm:th, me:th, la:th, xl:th } } }; // custom data if( jQuery(item).data('customdata') !== undefined ) { newItem.customData=cloneJSObject(jQuery(item).data('customdata')); } if( typeof G.O.fnProcessData == 'function' ) { G.O.fnProcessData(newItem, 'markup', null); } }); jQuery.each(elements, function(i,item){ jQuery(item).remove(); }); if( foundAlbumID ) { G.O.displayBreadcrumb=true; } // get the number of images per album for all the items var l=G.I.length, nb=0, nbImages=0; for( var i=0; i %E9 // in UTF-8: \u00e9=\xe9 (e9 = hex value) switch( G.O.jsonCharset.toUpperCase() ) { case 'UTF-8': // Apache Windows return decodeURI(str); // do not use decodeURIComponent (would convert slash also) break; case 'Latin': // Apache Linux default : return escape(str); break; } } function JsonParseData(albumIdx, data) { var foundAlbumID=false; var nb=0; jQuery.each(data, function(i,item){ var title=''; title=GetI18nItem(item,'title'); if( title === undefined ) { title=''; } var baseURL=G.O.jsonProvider.substring(0, G.O.jsonProvider.indexOf('nanoPhotosProvider.php')); var src=baseURL+JsonConvertCharset(item.src); var thumbsrc=baseURL+JsonConvertCharset(item.srct); if( G.O.thumbnailLabel.get('title') != '' ) { title=GetImageTitle((item.src)); } // replace underscores qith spaces title=title.replaceAll('_',' '); // remove leading @@NNNN (used to sort manually the albums) if( title.search(/@@\d\d\d\d/) == 0 ) { title=title.substring(6); // Trim trailing/leading whitespace title = title.replace(/^\s*|\s*$/, ''); } var description=''; //' '; description=GetI18nItem(item,'description'); if( description === undefined ) { description=''; } description=description.replaceAll('_',' '); var destinationURL=''; var kind='image'; if( item.kind !== undefined && item.kind.length>0 ) { kind=item.kind; } var ID=null; if( item.ID !== undefined ) { ID=(item.ID); } var ok=true; if( kind == 'album' ) { if( !CheckAlbumName(title, ID) ) { ok=false; } } if( ok ) { var albumID=0; if( item.albumID !== undefined ) { albumID=(item.albumID); foundAlbumID=true; } var newItem=NGAddItem(title, thumbsrc, src, description, destinationURL, kind, '', ID, albumID ); // thumbnail image size var tw=item.imgtWidth; var th=item.imgtHeight; newItem.thumbs = { url: { l1 : { xs:thumbsrc, sm:thumbsrc, me:thumbsrc, la:thumbsrc, xl:thumbsrc }, lN : { xs:thumbsrc, sm:thumbsrc, me:thumbsrc, la:thumbsrc, xl:thumbsrc } }, width: { l1 : { xs:tw, sm:tw, me:tw, la:tw, xl:tw }, lN : { xs:tw, sm:tw, me:tw, la:tw, xl:tw } }, height: { l1 : { xs:th, sm:th, me:th, la:th, xl:th }, lN : { xs:th, sm:th, me:th, la:th, xl:th } } }; if( typeof G.O.fnProcessData == 'function' ) { G.O.fnProcessData(newItem, 'api', null); } if( kind == 'image' ) { newItem.imageNumber=nb; nb++; if( nb >= G.maxAlbums ) { return false; } } } }); if( foundAlbumID ) { // G.O.displayBreadcrumb=true; } G.I[albumIdx].contentIsLoaded=true; G.I[albumIdx].contentLength=nb; } // ########################## // ##### FLICKR STORAGE ##### // ########################## function FlickrProcessItems( albumIdx, processLocationHash, imageID, setLocationHash) { manageGalleryToolbar(albumIdx); if( G.I[albumIdx].contentIsLoaded ) { // already loaded? DisplayAlbum(albumIdx,setLocationHash); return; } var url = '', kind='album'; if( G.I[albumIdx].GetID() == 0 ) { // albums //url = G.flickr.url() + "?&method=flickr.photosets.getList&api_key=" + G.flickr.ApiKey + "&user_id="+G.O.userID+"&primary_photo_extras=url_"+G.flickr.thumbSize+"&format=json&jsoncallback=?"; url = G.flickr.url() + "?&method=flickr.photosets.getList&api_key=" + G.flickr.ApiKey + "&user_id="+G.O.userID+"&per_page=500&primary_photo_extras=url_o,url_sq,url_t,url_q,url_s,url_m,url_l,url_z,url_b,url_h,url_k&format=json&jsoncallback=?"; } else { // photos if( G.I[albumIdx].GetID() == 'none' ) { // get photos from full photostream url = G.flickr.url() + "?&method=flickr.people.getPublicPhotos&api_key=" + G.flickr.ApiKey + "&user_id="+G.O.userID+"&extras=description,views,url_o,url_sq,url_t,url_q,url_s,url_m,url_z,url_b,url_h,url_k&per_page=500&format=json&jsoncallback=?"; } else { // photos from one specific photoset //url = G.flickr.url() + "?&method=flickr.photosets.getPhotos&api_key=" + G.flickr.ApiKey + "&photoset_id="+G.I[albumIdx].GetID()+"&extras=description,views,url_o,url_z,url_"+G.flickr.photoSize+",url_"+G.flickr.thumbSize+"&format=json&jsoncallback=?"; url = G.flickr.url() + "?&method=flickr.photosets.getPhotos&api_key=" + G.flickr.ApiKey + "&photoset_id="+G.I[albumIdx].GetID()+"&extras=description,views,url_o,url_sq,url_t,url_q,url_s,url_m,url_l,url_z,url_b,url_h,url_k&format=json&jsoncallback=?"; } kind='image'; } PreloaderShow(); jQuery.ajaxSetup({ cache: false }); jQuery.support.cors = true; var tId = setTimeout( function() { // workaround to handle JSONP (cross-domain) errors PreloaderHide(); nanoAlert('Could not retrieve Flickr data...'); }, 60000 ); jQuery.getJSON(url, function(data, status, xhr) { clearTimeout(tId); PreloaderHide(); if( kind == 'album' ) { FlickrParsePhotoSets(albumIdx, data); } else { FlickrParsePhotos(albumIdx, data); } if( processLocationHash || G.O.openOnStart != '' ) { if( !ProcessLocationHash(false) ) { DisplayAlbum(albumIdx,setLocationHash); } } else { if( imageID != -1 ) { var imageIdx=-1, l=G.I.length; for(var i=0; i y) ? 1 : 0) ); }); break; case 'titleDesc': source.sort(function (a, b) { var x = a.title._content.toUpperCase(); var y = b.title._content.toUpperCase(); return( (x > y) ? -1 : ((x < y) ? 1 : 0) ); }); } jQuery.each(source, function(i,item){ //Get the title itemTitle = item.title._content; if( CheckAlbumName(itemTitle, item.id) ) { itemID=item.id; //Get the description itemDescription=''; if (item.description._content != undefined) { itemDescription=item.description._content; } var sizes = {}; for (var p in item.primary_photo_extras) { sizes[p]=item.primary_photo_extras[p]; } tags=''; if( item.primary_photo_extras !== undefined ) { if( item.primary_photo_extras.tags !== undefined ) { tags=item.primary_photo_extras.tags; } } var newItem=NGAddItem(itemTitle, '', '', itemDescription, '', 'album', tags, itemID, G.I[albumIdx].GetID() ); //newItem.thumbImgWidth=item.primary_photo_extras['width_'+G.flickr.thumbSize]; //newItem.thumbImgHeight=item.primary_photo_extras['height_'+G.flickr.thumbSize]; newItem.contentLength=item.photos; newItem.thumbSizes=sizes; var tn = { url: { l1 : { xs:'', sm:'', me:'', la:'', xl:'' }, lN : { xs:'', sm:'', me:'', la:'', xl:'' } }, width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } }, height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } } }; tn=FlickrRetrieveImages(tn, item.primary_photo_extras, 'l1' ); tn=FlickrRetrieveImages(tn, item.primary_photo_extras, 'lN' ); newItem.thumbs=tn; nb++; if( nb >= G.maxAlbums ) { return false; } } }); G.I[albumIdx].contentIsLoaded=true; G.I[albumIdx].contentLength=nb; } } function FlickrRetrieveImages(tn, item, level ) { var sizes=['xs','sm','me','la','xl']; for(var i=0; i G.tn.settings.height[level][sizes[i]] ) { sdir='width_'; tsize=Math.ceil(G.tn.settings.width[level][sizes[i]]*G.tn.scale); } var one=FlickrRetrieveOneImage(sdir, tsize, item ); tn.url[level][sizes[i]]=one.url; tn.width[level][sizes[i]]=one.width; tn.height[level][sizes[i]]=one.height; } } return tn; } function FlickrRetrieveOneImage(sdir, tsize, item ) { var one={ url:'', width:0, height:0 }; var tnIndex=0; for(var j=0; j= tsize ) { break; } } } var fSize=G.flickr.photoAvailableSizesStr[tnIndex]; one.url= item['url_'+fSize]; one.width= parseInt(item['width_'+fSize]); one.height=parseInt(item['height_'+fSize]); return one; } function FlickrParsePhotos( albumIdx, data ) { var source = ''; if( G.I[albumIdx].GetID() == 'none' ) { source = data.photos.photo; } else { source = data.photoset.photo; } switch( G.O.photoSorting ) { case 'random': source = AreaShuffle(source); break; case 'reversed': source = source.reverse(); break; case 'titleAsc': source.sort(function (a, b) { // var x = a.title.toUpperCase(); // var y = b.title.toUpperCase(); var x='', y=''; if( G.O.thumbnailLabel.get('title') != '' ) { x=GetImageTitle(a.url_sq); y=GetImageTitle(b.url_sq); } else { x = a.title.toUpperCase(); y = b.title.toUpperCase(); } return( (x < y) ? -1 : ((x > y) ? 1 : 0) ); }); break; case 'titleDesc': source.sort(function (a, b) { // var x = a.title.toUpperCase(); // var y = b.title.toUpperCase(); var x='', y=''; if( G.O.thumbnailLabel.get('title') != '' ) { x=GetImageTitle(a.url_sq); y=GetImageTitle(b.url_sq); } else { x = a.title.toUpperCase(); y = b.title.toUpperCase(); } return( (x > y) ? -1 : ((x < y) ? 1 : 0) ); }); break; } var albumID=G.I[albumIdx].GetID(), nb=0; jQuery.each(source, function(i,item){ //Get the title var itemTitle = item.title, itemID=item.id, itemDescription=item.description._content; // Get the description var imgUrl=item.url_sq; //fallback size for(var i=G.flickr.photoSize; i>=0; i-- ) { if( item['url_'+G.flickr.photoAvailableSizesStr[i]] != undefined ) { imgUrl=item['url_'+G.flickr.photoAvailableSizesStr[i]]; break; } } var sizes = {}; for (var p in item) { if( p.indexOf('height_') == 0 || p.indexOf('width_') == 0 || p.indexOf('url_') == 0 ) { sizes[p]=item[p]; } } if( G.O.thumbnailLabel.get('title') != '' ) { itemTitle=GetImageTitle(imgUrl); } var newItem=NGAddItem(itemTitle, '', imgUrl, itemDescription, '', 'image', '', itemID, albumID ); newItem.imageNumber=nb; if( item.url_o !== undefined ) { newItem.width=item.width_o; newItem.height=item.height_o; } else { newItem.width=item.width_z; newItem.height=item.height_z; } //newItem.thumbImgWidth=item['width_'+G.flickr.photoAvailableSizesStr[tnIndex]]; //newItem.thumbImgHeight=item['height_'+G.flickr.photoAvailableSizesStr[tnIndex]]; // newItem.thumbSizes=sizes; var tn = { url: { l1 : { xs:'', sm:'', me:'', la:'', xl:'' }, lN : { xs:'', sm:'', me:'', la:'', xl:'' } }, width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } }, height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } } }; tn=FlickrRetrieveImages(tn, item, 'l1' ); tn=FlickrRetrieveImages(tn, item, 'lN' ); newItem.thumbs=tn; nb++; if( nb >= G.maxPhotos ) { return false; } }); G.I[albumIdx].contentIsLoaded=true; G.I[albumIdx].contentLength=nb; } // ########################## // ##### PICASA STORAGE ##### // ########################## function AddOneThumbSize(thumbSizes, v1, v2, c1, c2 ) { var v=Math.ceil(v2*G.tn.scale)+c2; if( v1 == 'auto' ) { v=Math.ceil(v2*G.tn.scale)+c2; } else if( v2 == 'auto' ) { v=Math.ceil(v1*G.tn.scale)+c1; } else if( v1 > v2 ) { v=Math.ceil(v1*G.tn.scale)+c1; } if( thumbSizes.length > 0 ) { thumbSizes+=','; } thumbSizes+=v; return thumbSizes; } function PicasaProcessItems( albumIdx, processLocationHash, imageID, setLocationHash ) { manageGalleryToolbar(albumIdx); if( G.I[albumIdx].contentIsLoaded ) { // already loaded? //renderGallery(albumIdx,0); DisplayAlbum(albumIdx,setLocationHash); return; } var url='', kind='album'; var thumbSizes=''; thumbSizes=AddOneThumbSize(thumbSizes, G.tn.settings.width.l1.xs, G.tn.settings.height.l1.xs, G.tn.settings.width.l1.xsc, G.tn.settings.height.l1.xsc ); thumbSizes=AddOneThumbSize(thumbSizes, G.tn.settings.width.l1.sm, G.tn.settings.height.l1.sm, G.tn.settings.width.l1.smc, G.tn.settings.height.l1.smc ); thumbSizes=AddOneThumbSize(thumbSizes, G.tn.settings.width.l1.me, G.tn.settings.height.l1.me, G.tn.settings.width.l1.mec, G.tn.settings.height.l1.mec ); thumbSizes=AddOneThumbSize(thumbSizes, G.tn.settings.width.l1.la, G.tn.settings.height.l1.la, G.tn.settings.width.l1.lac, G.tn.settings.height.l1.lac ); thumbSizes=AddOneThumbSize(thumbSizes, G.tn.settings.width.l1.xl, G.tn.settings.height.l1.xl, G.tn.settings.width.l1.xlc, G.tn.settings.height.l1.xlc ); thumbSizes=AddOneThumbSize(thumbSizes, G.tn.settings.width.lN.xs, G.tn.settings.height.lN.xs, G.tn.settings.width.lN.xsc, G.tn.settings.height.lN.xsc ); thumbSizes=AddOneThumbSize(thumbSizes, G.tn.settings.width.lN.sm, G.tn.settings.height.lN.sm, G.tn.settings.width.lN.smc, G.tn.settings.height.lN.smc ); thumbSizes=AddOneThumbSize(thumbSizes, G.tn.settings.width.lN.me, G.tn.settings.height.lN.me, G.tn.settings.width.lN.mec, G.tn.settings.height.lN.mec ); thumbSizes=AddOneThumbSize(thumbSizes, G.tn.settings.width.lN.la, G.tn.settings.height.lN.la, G.tn.settings.width.lN.lac, G.tn.settings.height.lN.lac ); thumbSizes=AddOneThumbSize(thumbSizes, G.tn.settings.width.lN.xl, G.tn.settings.height.lN.xl, G.tn.settings.width.lN.xlc, G.tn.settings.height.lN.xlc ); if( G.I[albumIdx].GetID() == 0 ) { // albums //url = G.picasa.url() + 'user/'+G.O.userID+'?alt=json&kind=album&imgmax=d&thumbsize='+G.picasa.thumbSize; // url = G.picasa.url() + 'user/'+G.O.userID+'?alt=json&kind=album&imgmax=d&thumbsize=320'; // url = G.picasa.url() + 'user/'+G.O.userID+'?alt=json&kind=album&imgmax=d&thumbsize='+thumbSizes; // url = G.picasa.url() + 'user/'+G.O.userID+'?alt=json&kind=album&access=public&thumbsize='+thumbSizes+'&rnd=' + (new Date().getTime()); url = G.picasa.url() + 'user/'+G.O.userID+'?alt=json&kind=album&thumbsize='+thumbSizes+'&rnd=' + (new Date().getTime()); } else { // photos var opt=''; if( typeof G.I[albumIdx].customData.authkey !== 'undefined' ) { opt=G.I[albumIdx].customData.authkey; } // url = G.picasa.url() + 'user/'+G.O.userID+'/albumid/'+G.I[albumIdx].GetID()+'?alt=json&kind=photo'+opt+'&thumbsize='+G.picasa.thumbSize+'&imgmax=d'; url = G.picasa.url() + 'user/'+G.O.userID+'/albumid/'+G.I[albumIdx].GetID()+'?alt=json&kind=photo'+opt+'&thumbsize='+thumbSizes+'&imgmax=d'; // url = G.picasa.url() + 'user/'+G.O.userID+'/albumid/'+G.I[albumIdx].GetID()+'?alt=json&kind=photo'+opt+'&thumbsize=320&imgmax=d'; kind='image'; } //A url = url + "&callback=?"; PreloaderShow(); // get the content and display it jQuery.ajaxSetup({ cache: false }); jQuery.support.cors = true; var tId = setTimeout( function() { // workaround to handle JSONP (cross-domain) errors PreloaderHide(); nanoAlert('Could not retrieve Picasa/Google+ data...'); }, 60000 ); // jQuery.getJSON(url, 'callback=?', function(data) { var gi_getJSONfinished = function(data){ clearTimeout(tId); PreloaderHide(); PicasaParseData(albumIdx,data,kind); //renderGallery(albumIdx,0); if( processLocationHash || G.O.openOnStart != '' ) { if( !ProcessLocationHash(false) ) { DisplayAlbum(albumIdx,setLocationHash); } } else { if( imageID != -1 ) { var imageIdx=-1, l=G.I.length; for(var i=0; i'; // } // var err = textStatus + ', ' + error + ' ' + k + '

URL:'+url; // nanoAlert("Could not retrieve Picasa/Google+ data. Error: " + err); // }); } function PicasaParseData( albumIdx, data, kind ) { var nb=0, albumID=G.I[albumIdx].GetID(); var source = data.feed.entry; var sortOrder=G.O.albumSorting; if (kind =='image'){ sortOrder=G.O.photoSorting; } switch( sortOrder ) { case 'random': source = AreaShuffle(source); break; case 'reversed': source = source.reverse(); break; case 'titleAsc': source.sort(function (a, b) { // var x = kind == 'image' ? a.media$group.media$description.$t.toUpperCase() : a.media$group.media$title.$t.toUpperCase(); // var y = kind == 'image' ? b.media$group.media$description.$t.toUpperCase() : b.media$group.media$title.$t.toUpperCase(); var x='', y=''; if( kind == 'image' ) { if( G.O.thumbnailLabel.get('title') != '' ) { x=GetImageTitle(unescape(unescape(unescape(unescape(a.media$group.media$content[0].url))))); y=GetImageTitle(unescape(unescape(unescape(unescape(b.media$group.media$content[0].url))))); } else { x = a.media$group.media$description.$t.toUpperCase(); y = b.media$group.media$description.$t.toUpperCase(); } } else { x = a.media$group.media$title.$t.toUpperCase(); y = b.media$group.media$title.$t.toUpperCase(); } return( (x < y) ? -1 : ((x > y) ? 1 : 0) ); }); break; case 'titleDesc': source.sort(function (a, b) { // var x = kind == 'image' ? a.media$group.media$description.$t.toUpperCase() : a.media$group.media$title.$t.toUpperCase(); // var y = kind == 'image' ? b.media$group.media$description.$t.toUpperCase() : b.media$group.media$title.$t.toUpperCase(); var x='', y=''; if( kind == 'image' ) { if( G.O.thumbnailLabel.get('title') != '' ) { x=GetImageTitle(unescape(unescape(unescape(unescape(a.media$group.media$content[0].url))))); y=GetImageTitle(unescape(unescape(unescape(unescape(b.media$group.media$content[0].url))))); } else { x = a.media$group.media$description.$t.toUpperCase(); y = b.media$group.media$description.$t.toUpperCase(); } } else { x = a.media$group.media$title.$t.toUpperCase(); y = b.media$group.media$title.$t.toUpperCase(); } return( (x > y) ? -1 : ((x < y) ? 1 : 0) ); }); break; } jQuery.each(source, function(i,data){ //Get the title var itemTitle = data.media$group.media$title.$t; //Get the URL of the thumbnail var itemThumbURL = data.media$group.media$thumbnail[0].url; //Get the ID var itemID = data.gphoto$id.$t; //Get the description var filename=''; var itemDescription = data.media$group.media$description.$t; if( kind == 'image') { filename=itemTitle; itemTitle=itemDescription; itemDescription=''; } var imgUrl=data.media$group.media$content[0].url; if( kind == 'image') { if( G.O.thumbnailLabel.get('title') != '' ) { itemTitle=GetImageTitle(unescape(unescape(unescape(unescape(imgUrl))))); } } var ok=true; if( kind == 'album' ) { if( !CheckAlbumName(itemTitle, itemID) ) { ok=false; } } var tags=''; if( ok ) { var picasaThumbBaseURL=''; // var picasaThumbBaseURL=itemThumbURL.substring(0, itemThumbURL.lastIndexOf('/')); // picasaThumbBaseURL=picasaThumbBaseURL.substring(0, picasaThumbBaseURL.lastIndexOf('/')) + '/'; var src=''; if( kind == 'album' ) { src=itemID; } else { src=imgUrl; var s=imgUrl.substring(0, imgUrl.lastIndexOf('/')); s=s.substring(0, s.lastIndexOf('/')) + '/'; if( window.screen.width > window.screen.height ) { src=s+'w'+window.screen.width+'/'+filename; } else { src=s+'h'+window.screen.height+'/'+filename; } } var newItem= NGAddItem(itemTitle, itemThumbURL, src, itemDescription, '', kind, tags, itemID, albumID ); newItem.picasaThumbBaseURL=picasaThumbBaseURL; newItem.imageNumber=nb; if( kind == 'album' ) { newItem.author=data.author[0].name.$t; newItem.contentLength=data.gphoto$numphotos.$t; } // OLD METHOD /* if( kind == 'image' ) { newItem.width=data.gphoto$width.$t; newItem.height=data.gphoto$height.$t; newItem.thumbImgWidth=data.media$group.media$thumbnail[0].width; newItem.thumbImgHeight=data.media$group.media$thumbnail[0].height; } else { if( G.tn.settings.getH() == 'auto' ) { newItem.thumbImgWidth=G.picasa.thumbSize; } else if( G.tn.settings.getW() == 'auto' ) { newItem.thumbImgHeight=G.picasa.thumbSize; } else { newItem.thumbImgWidth=G.picasa.thumbSize; newItem.thumbImgHeight=G.picasa.thumbSize; } } */ // NEW METHOD var tn = { url: { l1 : { xs:'', sm:'', me:'', la:'', xl:'' }, lN : { xs:'', sm:'', me:'', la:'', xl:'' } }, width: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } }, height: { l1 : { xs:0, sm:0, me:0, la:0, xl:0 }, lN : { xs:0, sm:0, me:0, la:0, xl:0 } } }; tn=PicasaThumbSetSizes('l1', 0, tn, data, kind ); tn=PicasaThumbSetSizes('lN', 5, tn, data, kind ); /* for test purposes tn.width.l1.xs=0; tn.width.l1.sm=0; tn.width.l1.me=0; tn.width.l1.la=0; tn.width.l1.xl=0; tn.width.lN.xs=0; tn.width.lN.sm=0; tn.width.lN.me=0; tn.width.lN.la=0; tn.width.lN.xl=0; tn.height.l1.xs=0; tn.height.l1.sm=0; tn.height.l1.me=0; tn.height.l1.la=0; tn.height.l1.xl=0; tn.height.lN.xs=0; tn.height.lN.sm=0; tn.height.lN.me=0; tn.height.lN.la=0; tn.height.lN.xl=0; */ newItem.thumbs=tn; if( typeof G.O.fnProcessData == 'function' ) { G.O.fnProcessData(newItem, 'picasa', data); } nb++; if( nb >= (kind == 'album' ? G.maxAlbums : G.maxPhotos) ) { return false; } } }); G.I[albumIdx].contentIsLoaded=true; G.I[albumIdx].contentLength=nb; } function PicasaThumbSetSizes(level, startI, tn, data, kind ) { var sizes=['xs','sm','me','la','xl']; for(var i=0; i 0 && G.I[albumIdx].paginationLastWidth == G.$E.conTnParent.width()) { p=G.I[albumIdx].paginationLastPage; } renderGallery(albumIdx,p); } // Display next album function DisplayNextAlbum() { var newAlbumIdx=GetNextAlbumIdx(G.curAlbumIdx); var setLocationHash = newAlbumIdx > 0; // DisplayAlbum(newAlbumIdx, setLocationHash); OpenAlbum(newAlbumIdx, false, -1, setLocationHash); }; // Display previous album function DisplayPreviousAlbum() { var newAlbumIdx=GetPreviousAlbumIdx(G.curAlbumIdx); var setLocationHash = newAlbumIdx > 0; // DisplayAlbum(newAlbumIdx, setLocationHash); OpenAlbum(newAlbumIdx, false, -1, setLocationHash); }; function GetNextAlbumIdx( curAlbumIdx ) { var l=G.I.length; var newAlbumIdx=-1; for(var i=curAlbumIdx+1; i=0; i-- ){ if( G.I[i].albumID == G.I[curAlbumIdx].albumID && G.I[i].kind == 'album' ) { newAlbumIdx=i; break; } } if( newAlbumIdx == -1 ) { for(var i=G.I.length-1; i>=curAlbumIdx; i-- ){ if( G.I[i].albumID == G.I[curAlbumIdx].albumID && G.I[i].kind == 'album' ) { newAlbumIdx=i; break; } } } return newAlbumIdx; } // add album to breadcrumb function breadcrumbAdd( albumIdx ) { var cl="folder"; if(albumIdx == 0 ) { cl="folderHome"; } var $newDiv =jQuery('
'+G.I[albumIdx].title+'
').appendTo(G.$E.conBC); jQuery($newDiv).data('albumIdx',albumIdx); $newDiv.click(function() { var cAlbumIdx=jQuery(this).data('albumIdx'); jQuery(this).nextAll().remove(); OpenAlbum(cAlbumIdx, false, -1, true); return; }); } // add separator to breadcrumb function breadcrumbAddSeparator( lastAlbumID ) { var $newSep=jQuery('
').appendTo(G.$E.conBC); jQuery($newSep).data('albumIdx',lastAlbumID); $newSep.click(function() { var sepAlbumIdx=jQuery(this).data('albumIdx'); jQuery(this).nextAll().remove(); jQuery(this).remove(); OpenAlbum(sepAlbumIdx, false, -1, true); return; }); } function manageGalleryToolbar( albumIdx ) { var displayToolbar=false; // Breadcrumb if( G.O.displayBreadcrumb == true && !G.O.thumbnailAlbumDisplayImage ) { if( G.$E.conBC.children().length == 0 ) { G.$E.conNavBCon.css({opacity:0, 'max-height':'0px'}); } displayToolbar=true; // G.$E.conBC.children().not(':first').remove(); G.$E.conBC.children().remove(); breadcrumbAdd(0); if( albumIdx != 0 ) { var l=G.I.length, parentID=0, lstItems=[]; lstItems.push(albumIdx); var curIdx=albumIdx; while( G.I[curIdx].albumID != 0 && G.I[curIdx].albumID != -1) { for(i=1; i < l; i++ ) { if( G.I[i].GetID() == G.I[curIdx].albumID ) { curIdx=i; lstItems.push(curIdx); break; } } } breadcrumbAddSeparator(0); for( i=lstItems.length-1; i>=0 ; i-- ) { breadcrumbAdd(lstItems[i]); if( i > 0 ) { breadcrumbAddSeparator(lstItems[i-1]); } } } var bcItems=G.$E.conBC.children(), l1=bcItems.length; if( l1 == 0 ) { G.curNavLevel='l1'; if( G.O.breadcrumbAutoHideTopLevel ) { G.$E.conNavBCon.css({opacity:0, 'max-height':'0px'}); displayToolbar=false; } //breadcrumbAdd(0); } else { if( l1 == 1 ) { G.curNavLevel='l1'; } else { G.curNavLevel='lN'; } if( l1 == 1 && G.O.breadcrumbAutoHideTopLevel ) { //G.$E.conNavBCon.animate({'opacity':'0','max-height':'0px'}); var tweenable = new NGTweenable(); tweenable.tween({ from: {'opacity':G.$E.conNavBCon.css('opacity'),'max-height':G.$E.conNavBCon.css('max-height')}, to: {'opacity':'0','max-height':'0px'}, attachment: { $e:G.$E.conNavBCon }, duration: 200, step: function (state, att) { att.$e.css(state); }, finish: function (state, att) { att.$e.css({'opacity':'0','max-height':'0px'}); } }); } else { //G.$E.conNavBCon.animate({'opacity':'1','max-height':'50px'}); if( G.O.breadcrumbAutoHideTopLevel ) { var tweenable = new NGTweenable(); tweenable.tween({ from: {'opacity':G.$E.conNavBCon.css('opacity'),'max-height':G.$E.conNavBCon.css('max-height')}, to: {'opacity':'1','max-height':'50px'}, attachment: { $e:G.$E.conNavBCon }, duration: 200, step: function (state, att) { att.$e.css(state); }, finish: function (state, att) { att.$e.css({'opacity':'1','max-height':'50px'}); } }); } else { G.$E.conNavBCon.css({opacity:1, 'max-height':'50px'}); } //G.$E.conBC.children().not(':first').remove(); } } G.pgMaxNbThumbnailsPerRow=NbThumbnailsPerRow(); } // Tag-bar if( G.O.useTags ) { displayToolbar=true; if( G.containerTags == null ) { G.containerTags =jQuery('
').appendTo(G.$E.conNavB); } } if( G.O.galleryFullpageButton ) { displayToolbar=true; } if( !G.containerNavigationbarContDisplayed && displayToolbar ) { G.containerNavigationbarContDisplayed=true; G.$E.conNavBCon.show(); } } function PreloaderShow() { //if( G.O.displayBreadcrumb == true ) { G.$E.conBC.find('.oneFolder').last().addClass('loading'); } // G.$E.conLoadingB.css({visibility:'visible'}); G.$E.conLoadingB.addClass('nanoGalleryLBar').removeClass('nanoGalleryLBarOff'); } function PreloaderHide() { //if( G.O.displayBreadcrumb == true ) { G.$E.conBC.find('.oneFolder').last().removeClass('loading'); } // G.$E.conLoadingB.css({visibility:'hidden'}); G.$E.conLoadingB.removeClass('nanoGalleryLBar').addClass('nanoGalleryLBarOff'); } // ##### Open one album function OpenAlbum ( albumIdx, processLocationHash, imageID, setLocationHash ) { // unselect everything if( G.O.itemsSelectable && G.O.keepSelection === false ) { G.selectedItems=[]; var l=G.I.length; for( var i=0; i < l ; i++ ) { G.I[i].selected=false; } } switch(G.O.kind) { case '': //renderGallery(albumIdx,0); DisplayAlbum(albumIdx,setLocationHash); break; case 'flickr': FlickrProcessItems(albumIdx, processLocationHash, imageID, setLocationHash); break; case 'json': JsonProcessItems(albumIdx, processLocationHash, imageID, setLocationHash); break; case 'picasa': default: PicasaProcessItems(albumIdx, processLocationHash, imageID, setLocationHash); break; } } // ##### REPOSITION THUMBNAILS ON SCREEN RESIZE EVENT function ResizeGallery() { if( G.tn.settings.getH() == 'auto' ) { ResizeGalleryHeightAuto(); } else if ( G.tn.settings.getW() == 'auto' ) { ResizeGalleryWidthtAuto(); } else { ResizeGalleryGrid(); } thumbnailsLazySetSrc(); setGalleryToolbarWidth(0); } // CASCADING LAYOUT function ResizeGalleryHeightAuto() { var areaW=G.$E.conTnParent.width(), curCol=0, curRow=0, cnt=0, colHeight=[], maxCol=NbThumbnailsPerRow(), //parseInt(areaW/G.tn.defaultFullWidth); gutterWidth=0, gutterHeight=G.O.thumbnailGutterHeight, tnW=G.tn.outerWidth.get(), $thumbnails=G.$E.conTn.find('.nanoGalleryThumbnailContainer'); if( G.O.thumbnailAlignment == 'justified' ) { maxCol=Math.min(maxCol,$thumbnails.length); gutterWidth=(maxCol==1?0:(areaW-(maxCol*tnW))/(maxCol-1)); } else { gutterWidth=G.O.thumbnailGutterWidth; } var nbCol=0; // first loop to retrieve the width of the area $thumbnails.each(function() { var $this=jQuery(this), n=$this.data("index"); if( n !== undefined ) { var curPosX=0, curPosY=0; if( curRow == 0 ) { curPosX=curCol*(G.tn.outerWidth.get()+gutterWidth); colHeight[curCol]=G.I[n].thumbFullHeight+gutterHeight; curCol++; nbCol++; if( curCol >= maxCol ) { curCol=0; curRow++; } } else { return false; // exit loop after first row } cnt++; } }); var w=(((colHeight.length)*(tnW+gutterWidth))-gutterWidth); curRow=0; curCol=0; // second loop to position the thumbnails $thumbnails.each(function() { var $this=jQuery(this), n=$this.data("index"); if( n !== undefined ) { if( G.O.thumbnailLabel.get('position') == 'onBottom' ) { setThumbnailSize($this,G.I[n]); // [TODO] remove --> this should not be here but issue on labelHeight } var curPosX=0, curPosY=0; if( curRow == 0 ) { curPosX=curCol*(G.tn.outerWidth.get()+gutterWidth); colHeight[curCol]=G.I[n].thumbFullHeight+gutterHeight; curCol++; if( curCol >= maxCol ) { curCol=0; curRow++; } } else { var c=0, minColHeight=colHeight[0]; for( i=1; i threshold minColHeight=colHeight[i]; c=i; break; } } curPosY=colHeight[c]; curPosX=c*(G.tn.outerWidth.get()+gutterWidth); colHeight[c]=curPosY+G.I[n].thumbFullHeight+gutterHeight; } var x=curPosX; if( G.O.RTL) { x=w-curPosX-G.tn.outerWidth.get(); } $this.css({ top: curPosY, left: x }); ThumbnailAppear($this, G.I[n], cnt); cnt++; } }); var h=colHeight[0]; for(i=1;i 0 && G.I[n].thumbImg().height > 0 ) { var item=G.I[n], w=Math.floor(item.thumbImg().width/item.thumbImg().height*G.tn.settings.getH())+ G.tn.borderWidth+G.tn.imgcBorderWidth; // +gutterWidth; if( G.O.thumbnailFeatured && cnt == 0 ) { w=w*2; tnFeaturedW=w; } if( bNewRow ) { bNewRow=false; rowNum++; curWidth=0; rowHasVertical=false; rowHasHorizontal=false; if( rowNum == 1 && tnFeaturedW > 0 ) { curWidth=tnFeaturedW; tnFeaturedW=0; } } // by grief-of-these-days if( item.thumbImg().height > item.thumbImg().width ) { rowHasVertical = true; } else { rowHasHorizontal = true; } // down scale image resolution if( (curWidth + w + gutterWidth) < areaW ) { // last row curWidth+=w+gutterWidth; rowHeight[rowNum]=G.tn.settings.getH(); // rowHeight[rowNum]=item.thumbFullHeight; // prevent incomplete row from being heigher than the previous ones. // by grief-of-these-days var rowHeightLimit=Math.max(rowHasVertical ? maxRowHeightVertical : 0, rowHasHorizontal ? maxRowHeightHorizontal : 0); if( G.O.thumbnailAdjustLastRowHeight && rowHeightLimit > 0 ) { rowHeight[rowNum]=Math.min(rowHeight[rowNum],rowHeightLimit); } rowLastItem[rowNum]=n; } else { // new row after current item curWidth+=w; var rH=Math.floor(G.tn.settings.getH()*areaW/curWidth); // var rH=Math.floor(item.thumbFullHeight*areaW/curWidth); rowHeight[rowNum]=rH; // save the max row height for each thumb orientation. // by grief-of-these-days if( rowHasVertical ) { maxRowHeightVertical=Math.max(maxRowHeightVertical,rH); } if( rowHasHorizontal ) { maxRowHeightHorizontal=Math.max(maxRowHeightHorizontal,rH); } rowLastItem[rowNum]=n; bNewRow=true; } cnt++; } else { // exit to conserve display order, and avoid displaying thumbnail before an existing one return false; } } }); rowNum=0; curPosY=0; lastPosX=0; cnt=0; $thumbnails.each(function() { var $this=jQuery(this), n=$this.data("index"); if( n !== undefined && G.I[n] != undefined ) { if( G.I[n].thumbImg().width > 0 && G.I[n].thumbImg().height > 0 ) { var item=G.I[n], // w=Math.ceil(item.thumbImgWidth/item.thumbImg().height*rowHeight[rowNum]);//+G.tn.borderWidth+G.tn.imgContBorderWidth; w=Math.floor(item.thumbImg().width/item.thumbImg().height*rowHeight[rowNum]);//+G.tn.borderWidth+G.tn.imgContBorderWidth; if( cnt == 0 && G.O.thumbnailFeatured ) { w=w*2; if( rowHeight.length == 1 ) { // only 1 row tnFeaturedH=parseInt(rowHeight[0])*2; } else { tnFeaturedH=parseInt(rowHeight[0])+parseInt(rowHeight[1])+G.tn.borderHeight+G.tn.imgcBorderHeight; } } if( n == rowLastItem[rowNum] ) { // last row item if( rowLastItem.length != (rowNum+1) ) { w=areaW-lastPosX- G.tn.borderWidth-G.tn.imgcBorderWidth;//-gutterWidth; } else { // very last item if( (lastPosX+w + G.tn.borderWidth+G.tn.imgcBorderWidth +gutterWidth) > areaW ) { // reduce size w=areaW-lastPosX-G.tn.borderWidth-G.tn.imgcBorderWidth;//-gutterWidth; } } } var rh=0; if( cnt == 0 && G.O.thumbnailFeatured ) { // rh=tnFeaturedH; // tnFeaturedW2= w + G.tn.borderWidth + G.tn.imgcBorderWidth; // item.customData.featured=true; // $this.find('img').attr('src', item.thumbX2src); } else { rh=rowHeight[rowNum]; } rh=parseInt(rh); w=parseInt(w); $this.width(w+G.tn.imgcBorderWidth).height(rh+G.tn.imgcBorderHeight+G.tn.labelHeight.get()); item.$getElt('.imgContainer').height(rh).width(w); $this.find('img').css({'max-height':rh+2, 'max-width':w+2}); $this.find('.subcontainer').width(w+G.tn.imgcBorderWidth).height(rh+G.tn.imgcBorderHeight+G.tn.labelHeight.get()); //$this.find('.labelImage').css({left:0, right:0}); var x=lastPosX; if( G.O.RTL) { x=areaW - lastPosX - ( w + G.tn.borderWidth + G.tn.imgcBorderWidth ); } $this.css({ top: curPosY , left: x }); item.thumbFullWidth=w+G.tn.borderWidth+G.tn.imgcBorderWidth; item.thumbFullHeight=rh+G.tn.borderHeight+G.tn.imgcBorderHeight+G.tn.labelHeight.get(); ThumbnailOverResize($this); ThumbnailAppear($this, item, cnt); lastPosX+=w+G.tn.borderWidth+G.tn.imgcBorderWidth+gutterWidth; if( n == rowLastItem[rowNum] ) { // curPosY+=rowHeight[rowNum]+G.tn.outerHeight+G.tn.labelHeight.get()+gutterHeight; curPosY+=rowHeight[rowNum]+G.tn.labelHeight.get()+gutterHeight+G.tn.imgcBorderHeight+G.tn.borderHeight; rowNum++; lastPosX=0; if( rowNum == 1 && tnFeaturedW2 > 0 ) { lastPosX= tnFeaturedW2; tnFeaturedW2=0; } } cnt++; } else { return false; } } }); if( rowNum > 0 ) { curPosY-=gutterHeight; } tnFeaturedH=tnFeaturedH+G.tn.outerHeight.get()+G.tn.labelHeight.get(); G.$E.conTn.width(areaW).height(curPosY>tnFeaturedH?curPosY:tnFeaturedH); //+G.O.thumbnailHeight); } // Maximum number of thumbnails in one row function NbThumbnailsPerRow() { var tnW=G.tn.settings.getW()+G.tn.borderWidth+G.tn.imgcBorderWidth; var areaW=G.$E.conTnParent.width(); var nbMaxTn=0; if( G.O.thumbnailAlignment == 'justified' ) { nbMaxTn=Math.floor((areaW)/(tnW)); } else { nbMaxTn=Math.floor((areaW+G.O.thumbnailGutterWidth)/(tnW+G.O.thumbnailGutterWidth)); } if( G.O.maxItemsPerLine >0 && nbMaxTn > G.O.maxItemsPerLine ) { nbMaxTn=G.O.maxItemsPerLine; } if( nbMaxTn < 1 ) { nbMaxTn=1; } return nbMaxTn } // GRID LAYOUT function ResizeGalleryGrid() { var curPosX=0, curPosY=0, gutterWidth=0, gutterHeight=G.O.thumbnailGutterHeight, areaW=G.$E.conTnParent.width(), maxCol=NbThumbnailsPerRow(), cnt=0, h=0, w=0, cols=[], curCol=0; G.L.nbMaxTnPerRow=NbThumbnailsPerRow(); var d=new Date(); // pagination - max lines per page mode if( G.pgMaxLinesPerPage > 0 ) { if( G.tn.outerWidth.get() > 0 ) { if( maxCol != G.pgMaxNbThumbnailsPerRow ) { // max number of thumbnails per line has changed --> render the gallery again G.pgMaxNbThumbnailsPerRow=maxCol; var aIdx=G.$E.conPagin.data('galleryIdx'); renderGallery(aIdx,0); return; } } } var $thumbnails=G.$E.conTn.find('.nanoGalleryThumbnailContainer'), nbTn=$thumbnails.length; if( G.O.thumbnailAlignment == 'justified' ) { maxCol=Math.min(maxCol,nbTn); gutterWidth=(maxCol==1?0:(areaW-(maxCol*G.tn.outerWidth.get()))/(maxCol-1)); } else { gutterWidth=G.O.thumbnailGutterWidth; } if( G.O.RTL ) { // first loop to retrieve the width of the area $thumbnails.each(function() { var $this=jQuery(this); var n=$this.data("index"); if( n !== undefined ) { if( curPosY == 0 ) { curPosX=curCol*(G.tn.outerWidth.get()+gutterWidth); cols[curCol]=curPosX; w=curPosX; } else { return false; } curCol++; if( curCol >= maxCol ){ curCol=0; curPosY+=G.tn.outerHeight.get()+gutterHeight; } } }); areaW=w+G.tn.outerWidth.get(); curPosY=0; curCol=0; } var batch=[]; var lastN=0; $thumbnails.each(function() { var $this=jQuery(this); var n=$this.data("index"); if( n !== undefined ) { lastN=n; if( curPosY == 0 ) { curPosX=curCol*(G.tn.outerWidth.get()+gutterWidth) cols[curCol]=curPosX; w=curPosX; } else { curPosX=cols[curCol]; h=curPosY; } var x=curPosX; if( G.O.RTL ) { x=parseInt(areaW)-curPosX-G.tn.outerWidth.get(); } batch.push({$e:$this, t:curPosY, l:x, item:G.I[n]}); // $this.css({ top: curPosY , left: x }); // ThumbnailAppear($this, G.I[n], cnt); curCol++; if( curCol >= maxCol ){ curCol=0; curPosY+=G.tn.outerHeight.get()+gutterHeight; } cnt++; } }); // window.requestAnimationFrame( function(d,w) { var n=batch.length; var h=0 for( var i=0; i DO NOT USE / TOO SLOW if( $this.hasClass('nanogalleryHideElement') ) { $this.removeClass('nanogalleryHideElement'); if( G.O.thumbnailDisplayTransition ) { if( typeof G.O.fnThumbnailDisplayEffect == 'function' ) { G.O.fnThumbnailDisplayEffect($this, item, 0); } else { // $this.delay(n*G.tn.displayInterval).fadeTo(150, 1); // $this.fadeTo(200, 1); // FadeToAppear($this,1); setTimeout(function() { window.requestAnimationFrame( function() { FadeToAppear($this); }); }, n*G.tn.displayInterval); } } else { $this.css({opacity:1}); } } } function FadeToAppear( $elt ) { var tweenable = new NGTweenable(); tweenable.tween({ from: { 'o': 0 }, to: { 'o': 1 }, duration: 200, step: function (state) { $elt.css({opacity: state.o}); }, finish: function (state) { $elt.css({opacity: state.o}); } }); } function setGalleryToolbarWidth(pageNumber) { if( G.O.galleryToolbarWidthAligned ) { if( G.$E.conNavBCon !== undefined ) { var w=G.$E.conTn.outerWidth(true); //if( pageNumber > 0 ) { if( G.$E.conNavBCon.width() < w ) { G.$E.conNavBCon.width(w); } //} else { G.$E.conNavBCon.width(w); } } } } // thumbnail image lazy load function thumbnailsLazySetSrc() { var $eltInViewport=G.$E.conTn.find('.nanoGalleryThumbnailContainer').filter(function() { return inViewport(jQuery(this), G.tn.lazyLoadTreshold); }); jQuery($eltInViewport).each(function(){ var $image=jQuery(this).find('img'); if( $image.attr('src') == G.emptyGif ) { var idx=jQuery(this).data('index'); if( idx == undefined || G.I[idx] == undefined ) { return; } $image.attr('src',''); $image.attr('src',G.I[idx].thumbImg().src); } }); } // ################### // ##### GALLERY ##### // ################### // Display pagination function managePagination( albumIdx, pageNumber ) { if( G.$E.conPagin == undefined ) return; G.$E.conPagin.children().remove(); //if( G.tn.settings.getH() == 'auto' || G.tn.settings.getW() == 'auto' ) { return; } if( G.pgMaxLinesPerPage == 0 || G.tn.settings.getH() == 'auto' || G.tn.settings.getW() == 'auto' ) { // Hide pagination container, if not used. G.$E.conPagin.hide(); return; } // Must show the container for width calculation to work. G.$E.conPagin.show(); G.$E.conPagin.data('galleryIdx',albumIdx); G.$E.conPagin.data('currentPageNumber',pageNumber); var n2=0, w=0; if( !G.O.paginationDots && pageNumber > 0 ) { var eltPrev=jQuery('
'+(G.O.paginationDots? '':G.i18nTranslations.paginationPrevious)+'
').appendTo(G.$E.conPagin); w+=jQuery(eltPrev).outerWidth(true); eltPrev.click(function(e) { paginationPreviousPage(); }); } var firstPage=0; // pagination - max lines per page mode if( G.pgMaxLinesPerPage > 0 && G.tn.settings.getH() != 'auto' && G.tn.settings.getW() != 'auto' ) { // number of pages n2=Math.ceil(G.I[albumIdx].contentLength/(G.pgMaxLinesPerPage*G.pgMaxNbThumbnailsPerRow)); } var lastPage=n2; // no previous/next if( !G.O.paginationDots ) { var vp=G.O.paginationVisiblePages; if( vp >= n2 ) { firstPage=0; } else { // we have more pages than we want to display if( isOdd(vp) ) { firstPage=pageNumber-(vp-1)/2; lastPage=pageNumber+(vp-1)/2; } else { firstPage=pageNumber - vp/2; lastPage=pageNumber + Math.max((vp/2-1),1); } if( lastPage >= n2 ) { firstPage=n2-vp; } if( firstPage < 0 ) { firstPage=0; } } } // only one page -> do not display anything // if( n2==1 ) { return; } if( n2==1 ) { // Hide pagination container, if not used. G.$E.conPagin.hide (); return; } for(var i=firstPage; i < n2; i++ ) { var c=''; if( i == pageNumber ) { c=' currentPage'; } var elt$=jQuery('
'+(G.O.paginationDots? '':(i+1))+'
').appendTo(G.$E.conPagin); elt$.data('pageNumber',i); w+=elt$.outerWidth(true); elt$.click(function(e) { var aIdx=G.$E.conPagin.data('galleryIdx'), pn=jQuery(this).data('pageNumber'); if( !inViewportVert(G.$E.base, 0) ) { $('html, body').animate({scrollTop: G.$E.base.offset().top}, 200); } renderGallery(aIdx,pn); }); if( (i-firstPage) >= (vp-1) ) { break; } } if( !G.O.paginationDots && (pageNumber+1) < n2 ) { var $eltNext=jQuery('
'+(G.O.paginationDots? '':G.i18nTranslations.paginationNext)+'
').appendTo(G.$E.conPagin); w+=$eltNext.outerWidth(true); $eltNext.click(function(e) { paginationNextPage(); }); } G.$E.conPagin.width(w); } function isOdd(num) { return (num % 2) == 1;} function paginationNextPage() { var aIdx=G.$E.conPagin.data('galleryIdx'), n1=0; // pagination - max lines per page mode if( G.pgMaxLinesPerPage > 0 ) { n1=G.I[aIdx].contentLength / (G.pgMaxLinesPerPage * G.pgMaxNbThumbnailsPerRow); } n2=Math.ceil(n1); var pn=G.$E.conPagin.data('currentPageNumber'); if( pn < (n2-1) ) { pn++; } else { pn=0; } if( !inViewportVert(G.$E.base, 0) ) { $('html, body').animate({scrollTop: G.$E.base.offset().top }, 200); } renderGallery(aIdx,pn); } function paginationPreviousPage() { var aIdx=G.$E.conPagin.data('galleryIdx'), n1=0; // pagination - max lines per page mode if( G.pgMaxLinesPerPage > 0 ) { n1=G.I[aIdx].contentLength / (G.pgMaxLinesPerPage * G.pgMaxNbThumbnailsPerRow); } n2=Math.ceil(n1); var pn=G.$E.conPagin.data('currentPageNumber'); if( pn > 0 ) { pn--; } else { pn=n2-1; } if( !inViewportVert(G.$E.base, 0) ) { $('html, body').animate({scrollTop: G.$E.base.offset().top }, 250); } renderGallery(aIdx,pn); } function galleryCountImages (imageIdx) { var l=G.I.length; var images = 0; var currentItemIdx = imageIdx || G.GetCurrentViewedItemIdx(); if (currentItemIdx !== -1) { for( var i=0; i < l ; i++ ) { if( G.I[i].albumID == G.I[currentItemIdx].albumID && G.I[i].kind == 'image' ) { images++; } } return images; } else { return 0; } } function renderGallery( albumIdx, pageNumber ) { G.curAlbumIdx=-1; if( G.$E.conPagin == undefined ) { G.$E.conPagin.children().remove(); } var $elt=G.$E.conTn.parent(); var tweenable = new NGTweenable(); tweenable.tween({ to: {'opacity': 0 }, from: {'opacity': 1 }, attachment: { $e:$elt }, duration: 150, step: function (state, att) { att.$e.css(state); }, finish: function (state, att) { att.$e.css({'opacity': 0 }); G.containerThumbnailsDisplayed=false; // G.$E.conTn.off().empty(); G.$E.conTn.hide(0).off().show(0).html(''); var l=G.I.length; for( var i=0; i < l ; i++ ) { G.I[i].$Elts = []; G.I[i].$elt = null; G.I[i].hoverInitDone=false; G.I[i].hovered=false; } G.$E.conTnParent.css({ left:0, opacity:1 }); ElementTranslateX(G.$E.conTn[0],0); renderGallery2(albumIdx, pageNumber, renderGallery2Complete); } }); return; // TODO: remove following $elt.animate({opacity: 0}, 100).promise().done(function(){ // remove gallery elements G.containerThumbnailsDisplayed=false; // G.$E.conTn.off().empty(); G.$E.conTn.hide(0).off().show(0).html(''); var l=G.I.length; for( var i=0; i < l ; i++ ) { G.I[i].hovered=false; } G.$E.conTnParent.css({ left:0, opacity:1 }); ElementTranslateX(G.$E.conTn[0],0); renderGallery2(albumIdx, pageNumber, renderGallery2Complete); }); } function renderGallery2( albumIdx, pageNumber, onComplete ) { if( G.O.debugMode && console.timeline ) { console.timeline('nanoGALLERY'); } G.startDateTime= new Date(); if( albumIdx == -1 || G.I[albumIdx] == undefined) { return; } G.I[albumIdx].paginationLastPage=pageNumber; G.I[albumIdx].paginationLastWidth=G.$E.conTnParent.width(); var l=G.I.length; // if one description is defined then put a value to those without var foundDesc=false; /*if( G.O.thumbnailLabel.get('position') == 'onBottom' ) { for(var i=0; i 0 ) { foundDesc=true; } } }*/ // var G.galleryItemsCount=0; G.galleryItemsCount=0; var currentCounter=0, firstCounter=0, lastCounter=0; if( G.pgMaxLinesPerPage > 0 && G.tn.settings.getH() != 'auto' && G.tn.settings.getW() != 'auto' ) { firstCounter=pageNumber*G.pgMaxLinesPerPage*G.pgMaxNbThumbnailsPerRow; lastCounter=firstCounter+G.pgMaxLinesPerPage*G.pgMaxNbThumbnailsPerRow; } PreloaderHide(); var endInViewportTest=false, startInViewportTest=false, idx=0; (function(){ G.toRender=[]; for( var i=0; i= l ) { onComplete(albumIdx, pageNumber); return; } var item=G.I[idx]; if( item.albumID == G.I[albumIdx].GetID() ) { currentCounter++; // pagination - max lines per page mode if( G.pgMaxLinesPerPage > 0 && G.tn.settings.getH() != 'auto' && G.tn.settings.getW() != 'auto' ) { if( (G.galleryItemsCount+1) > (G.pgMaxLinesPerPage*G.pgMaxNbThumbnailsPerRow) ) { onComplete(albumIdx, pageNumber); return; } } if( currentCounter > firstCounter ) { G.galleryItemsCount++; // If the item is does not exists anymore var r=thumbnailBuild(item, idx, foundDesc); var $newDiv=r.e$; // image lazy load if( G.O.thumbnailLazyLoad && !r.cIS ) { if( !endInViewportTest ) { if( inViewport($newDiv, G.tn.lazyLoadTreshold) ) { item.$getElt('img').attr('src',''); // firefox bug workaround item.$getElt('img').attr('src',item.thumbImg().src); startInViewportTest=true; } else { if( startInViewportTest ) { endInViewportTest=true; } } } } } } idx++; } var n=G.toRender.length; if( n > 0 ) { for(var i=0; i
'; var checkImageSize=false, src=G.emptyGif; if( (G.tn.settings.getH() == 'auto' && G.I[idx].thumbImg().height == 0) || (G.tn.settings.getW() == 'auto' && G.I[idx].thumbImg().width == 0) ) { checkImageSize=true; } if( !G.O.thumbnailLazyLoad || checkImageSize) { src=item.thumbImg().src; } var sTitle=getThumbnailTitle(item), sDesc=getTumbnailDescription(item); if( G.tn.settings.getH() == 'auto' ) { newElt[newEltIdx++]='
'+sTitle+'
'; } else if( G.tn.settings.getW() == 'auto' ) { newElt[newEltIdx++]='
'+sTitle+'
'; } else { newElt[newEltIdx++]='
'+sTitle+'
'; } if( item.kind == 'album' ) { // ALBUM if( G.O.thumbnailLabel.get('display') == true ) { var imageCount=''; if( item.contentLength > 0 ) { // display content counter switch( G.O.thumbnailLabel.get('itemsCount') ) { case 'title': sTitle += ' ' + G.i18nTranslations.thumbnailLabelItemsCountPart1 + '' +item.contentLength + '' +G.i18nTranslations.thumbnailLabelItemsCountPart2; break; case 'description': sDesc += ' ' + G.i18nTranslations.thumbnailLabelItemsCountPart1 + '' + item.contentLength + '' + G.i18nTranslations.thumbnailLabelItemsCountPart2; break; } } newElt[newEltIdx++]='
'+sTitle+'
'+sDesc+'
'; } } else { // IMAGE if( G.O.thumbnailLabel.get('display') == true ) { if( foundDesc && sDesc.length == 0 && G.O.thumbnailLabel.get('position') == 'onBottom' ) { sDesc=' '; } newElt[newEltIdx++]='
'+sTitle+'
'+sDesc+'
'; } } newElt[newEltIdx++]='
'; // checkbox for selection if( G.O.itemsSelectable ){ item.selected = false; if(G.O.keepSelection === true){ for (it in G.selectedItems){ if(G.selectedItems[it].GetID() === item.GetID()){ item.selected = true; } } } if(G.O.showCheckboxes){ checked = ''; if(item.selected){ checked = 'checked'; } newElt[newEltIdx++]=''; } } newElt[newEltIdx++]=''; // var $newDiv =jQuery(newElt.join('')).appendTo(G.$E.conTnHid); //.animate({ opacity: 1},1000, 'swing'); //.show('slow'); //.fadeIn('slow').slideDown('slow'); var $newDiv =jQuery(newElt.join('')).appendTo(G.$E.conTnHid); //.animate({ opacity: 1},1000, 'swing'); //.show('slow'); //.fadeIn('slow').slideDown('slow'); if(typeof item.selected !== 'undefined' && item.selected === true){ $newDiv.find('.subcontainer').addClass('selected'); } item.$elt=$newDiv; $newDiv.data('index',idx); item.$getElt('img').data('index',idx); // Custom init function if( typeof G.O.fnThumbnailInit == 'function' ) { G.O.fnThumbnailInit($newDiv, item, ExposedObjects()); } var $p=$newDiv.detach(); $p.appendTo( G.$E.conTn ); if( checkImageSize ) { // ThumbnailOverInit($newDiv); // init hover effects var gi_imgLoad = ngimagesLoaded( $newDiv ); //$newDiv.ngimagesLoaded().always( function( instance ) { gi_imgLoad.on( 'always', function( instance ) { var item=G.I[jQuery(instance.images[0].img).data('index')]; if( item == undefined || instance.images[0].img.src == G.emptyGif ) { return; } // warning: also fired for blank image --> ignore var b=false; if( item.thumbImg().height != instance.images[0].img.naturalHeight ) { item.thumbSetImgHeight(instance.images[0].img.naturalHeight); item.thumbSetImgWidth(instance.images[0].img.naturalWidth); b=true; } if( item.thumbImg().width != instance.images[0].img.naturalWidth ) { item.thumbSetImgHeight(instance.images[0].img.naturalHeight); item.thumbSetImgWidth(instance.images[0].img.naturalWidth); b=true; } if( b ) { ThumbnailOverInit(item.$elt); // init hover effects setThumbnailSize(item.$elt, item); ThumbnailOverResize(item.$elt); ResizeGallery(); // [TODO] optimization to avoid too much resizing } }); } else { //G.toRender.push({ $e:$newDiv, i:item }); ThumbnailOverInit($newDiv); // init hover effects setThumbnailSize($newDiv, item); ThumbnailOverResize($newDiv); } return { e$:$newDiv, cIS:checkImageSize }; } function getThumbnailTitle( item ) { var sTitle=item.title; if( G.O.thumbnailLabel.get('display') == true ) { if( sTitle === undefined || sTitle.length == 0 ) { sTitle=' '; } if( G.i18nTranslations.thumbnailImageTitle != '' ) { sTitle=G.i18nTranslations.thumbnailImageTitle; } if( G.O.thumbnailLabel.get('titleMaxLength') > 3 && sTitle.length > G.O.thumbnailLabel.get('titleMaxLength') ){ sTitle=sTitle.substring(0,G.O.thumbnailLabel.get('titleMaxLength'))+'...'; } } return sTitle; } function getTumbnailDescription( item ) { var sDesc=''; if( G.O.thumbnailLabel.get('displayDescription') == true ) { if( item.kind == 'album' ) { if( G.i18nTranslations.thumbnailImageDescription != '' ) { sDesc=G.i18nTranslations.thumbnailAlbumDescription; } else { sDesc=item.description; } } else { if( G.i18nTranslations.thumbnailImageDescription != '' ) { sDesc=G.i18nTranslations.thumbnailImageDescription; } else { sDesc=item.description; } } if( G.O.thumbnailLabel.get('descriptionMaxLength') > 3 && sDesc.length > G.O.thumbnailLabel.get('descriptionMaxLength') ){ sDesc=sDesc.substring(0,G.O.thumbnailLabel.get('descriptionMaxLength'))+'...'; } } return sDesc; } function thumbnailSelection(item, forceValue, refrehElt){ var $e=item.$elt; var thumbnailCheckbox = $e.find('input[type=checkbox]'); if((G.selectMode === 'image' || G.selectMode === 'album') && item.kind !== G.selectMode ){ item.selected = false; thumbnailCheckbox.prop('checked',false ); item.$getElt('.subcontainer').removeClass('selected'); }else{ if( typeof forceValue === 'undefined' ){ item.selected=!item.selected; }else{ item.selected = forceValue; } if( refrehElt !== false ) { thumbnailCheckbox.prop('checked',item.selected ); } if( item.selected ) { item.$getElt('.subcontainer').addClass('selected'); } else { item.$getElt('.subcontainer').removeClass('selected'); } } thumbnailSelectionEnd(); if(typeof G.O.fnThumbnailSelection === 'function'){ G.O.fnThumbnailSelection($e, item); } } function thumbnailSelectionEnd(){ var oldSelection; if(G.O.keepSelection === true){ oldSelection = G.selectedItems.slice(0); } G.selectedItems = []; var l=G.I.length; for( var j=0; j 0 || G.selectModeForce == true) { G.I.forEach(function (it) { if(it.$elt !== null && !it.$elt.hasClass('selectable')){ if((G.selectModeForce == true && it.kind === G.selectMode) || G.selectMode == true){ it.$elt.addClass('selectable'); } } }); if(G.selectMode !== true && G.selectMode !== 'image' && G.selectMode !== 'album'){ G.selectMode = true; } }else { G.I.forEach(function (it) { if(it.$elt !== null){ it.$elt.removeClass('selectable'); } }); G.selectMode = false; } if (typeof G.O.fnChangeSelectMode === 'function'){ G.O.fnChangeSelectMode(G.selectMode); } } function setThumbnailSize( $elt, item ) { if( G.tn.settings.getH() == 'auto' ) { // CASCADING LAYOUT if( item.thumbImg().height > 0 ) { var ratio=item.thumbImg().height/item.thumbImg().width; item.$getElt('.imgContainer').height(G.tn.settings.getW()*ratio); //.css({'overflow':'hidden'}); if( G.O.thumbnailLabel.get('position') == 'onBottom' ) { item.thumbLabelHeight=item.$getElt('.labelImage').outerHeight(true); item.thumbFullHeight=G.tn.settings.getW()*ratio + item.thumbLabelHeight + G.tn.borderHeight+G.tn.imgcBorderHeight; $elt.width(G.tn.outerWidth.get()-G.tn.borderWidth).height(item.thumbFullHeight-G.tn.borderHeight); item.$getElt('.labelImage').css({'position':'absolute', 'top':'', 'bottom':'0px'}); } else { item.thumbFullHeight=G.tn.settings.getW()*ratio + item.thumbLabelHeight + G.tn.borderHeight+G.tn.imgcBorderHeight; $elt.width(G.tn.outerWidth.get() - G.tn.borderWidth).height(item.thumbFullHeight-G.tn.borderHeight); } } item.thumbFullWidth=G.tn.outerWidth.get(); item.$getElt('.subcontainer').width(G.tn.outerWidth.get()-G.tn.borderWidth).height(item.thumbFullHeight-G.tn.borderHeight); //.css({'overflow':'hidden'}); } else // JUSTIFIED LAYOUT if( G.tn.settings.getW() == 'auto' ) { return; // everything is done in ResizeGalleryWidthtAuto() if( item.thumbImg().width > 0 ) { // var ratio=item.thumbImg().height/item.thumbImg().width; var ratio=item.thumbImg().width/item.thumbImg().height; item.$getElt('.imgContainer').width(G.tn.settings.getH()*ratio).css({overflow:'hidden'}); if( G.O.thumbnailLabel.get('position') == 'onBottom' ) { item.thumbFullWidth=G.tn.settings.getH()*ratio + G.tn.borderWidth+G.tn.imgcBorderWidth ; $elt.width(item.thumbFullWidth).height(G.tn.outerHeight.get()+G.tn.labelHeight.get()-G.tn.outerHeight.get()); } else { } } item.thumbFullHeight=G.tn.outerHeight.get()+G.tn.labelHeight.get(); $elt.find('.subcontainer').width(item.thumbFullWidth-G.tn.borderWidth).height(G.tn.outerHeight.get()-G.tn.borderHeight); //.css({'overflow':'hidden'}); } else { // GRID LAYOUT item.thumbFullHeight=G.tn.outerHeight.get(); //+G.tn.labelHeight.get(); //G.tn.defaultFullHeight; item.thumbFullWidth=G.tn.outerWidth.get(); //G.tn.defaultFullWidth; if( G.O.thumbnailLabel.get('position') == 'onBottom' ) { $elt.width(item.thumbFullWidth-G.tn.borderWidth).height(item.thumbFullHeight-G.tn.borderHeight); //item.$getElt('.labelImage').height(G.tn.labelHeight.get()-G.tn.labelBorderHeight).css({overflow:'hidden'}); } else { $elt.width(item.thumbFullWidth-G.tn.borderWidth).height(item.thumbFullHeight-G.tn.borderHeight); } item.$getElt('.subcontainer').width(item.thumbFullWidth-G.tn.borderWidth).height(item.thumbFullHeight-G.tn.borderHeight); //.css({'overflow':'hidden'}); } } // TODO --> REMOVE function thumbnailPositionContentOLD( $e, item ) { if(G.O.itemsSelectable === true && G.O.showCheckboxes === true){ thumbnailCheckbox = $('') .attr('type', 'checkbox') .css({ 'position' : 'absolute', 'top' : G.O.checkboxPosition.top, 'left' : G.O.checkboxPosition.left, 'z-index' : 999 }).click(function(){ thumbnailSelection(item); }); $e.append(thumbnailCheckbox); $e.data('selected',false); } if( typeof G.O.fnThumbnailInit == 'function' ) { G.O.fnThumbnailInit($e, item, ExposedObjects()); return; } return; if( !G.O.thumbnailLabel.get('display') ) { return; } switch( G.O.thumbnailLabel.get('position') ){ case 'onBottom': item.$getElt('.labelImage').css({top:0, position:'relative', left:0, right:0}); if( G.tn.settings.getH() == 'auto' ) { // line break if( item.kind == 'album' ) { item.$getElt('.labelFolderTitle').css({'white-space':'normal'}); } else { item.$getElt('.labelImageTitle').css({'white-space':'normal'}); } item.$getElt('.labelDescription').css({'white-space':'normal'}); } else { // no line break if( item.kind == 'album' ) { item.$getElt('.labelFolderTitle').css({'white-space':'nowrap'}); } else { item.$getElt('.labelImageTitle').css({'white-space':'nowrap'}); } item.$getElt('.labelDescription').css({'white-space':'nowrap'}); } break; case 'overImageOnTop': item.$getElt('.labelImage').css({top:0, bottom:0, left:0, right:0 }); break; case 'overImageOnMiddle': item.$getElt('.labelImage').css({top:0, bottom:0, left:0, right:0}); if( item.kind == 'album' ) { item.$getElt('.labelFolderTitle').css({left:0, right:0, position:'absolute', bottom:'50%'}); } else { item.$getElt('.labelImageTitle').css({left:0, right:0, position:'absolute', bottom:'50%'}); } item.$getElt('.labelDescription').css({left:0, right:0, position:'absolute', top:'50%'}); break; case 'custom': // Don't apply any style break; case 'overImageOnBottom': default : G.O.thumbnailLabel.set('position', 'overImageOnBottom'); item.$getElt('.labelImage').css({bottom:0, left:0, right:0}); break; } } function ThumbnailHoverOutAll() { // [TODO] --> only check displayed items var l=G.I.length; for( var i=0; i < l ; i++ ) { if( G.I[i].hovered ) { ThumbnailHoverOut(G.I[i].$elt); } } } // init hover effects function ThumbnailOverInit( $e ) { var n=$e.data("index"); if( n == undefined ) { return; } // required because can be fired on ghost elements var item=G.I[n]; if( typeof G.O.fnThumbnailHoverInit == 'function' ) { G.O.fnThumbnailHoverInit($e, item, ExposedObjects() ); } removeCSSTransform(item); for( j=0; j hover issue // var n= Math.round(item.thumbFullHeight*1.2) + 'px'; // item.$getElt('.labelImage').css({ perspective: n, rotateX: '180deg', 'backface-visibility': 'hidden', 'opacity':'1', 'height':'100%' }); // break; // case 'flipVertical': // OONLY TO TEST --> hover issue // var n= Math.round(item.thumbFullWidth*1.2) + 'px'; // item.$getElt('.subcontainer').css({ perspective: n, rotateY: '0deg'}); // item.$getElt('.labelImage').css({ perspective: n, rotateY: '180deg', 'backface-visibility': 'hidden', 'opacity':'1', 'height':'100%' }); // break; case 'imageScale150': $e.css({overflow: 'hidden'}); newCSSTransform(item, 'img0', item.$getElt('img')); SetCSSTransform(item, 'img0'); break; case 'imageScaleIn80': $e.css({overflow: 'hidden'}); newCSSTransform(item, 'img0', item.$getElt('img')).scale=120; SetCSSTransform(item, 'img0'); break; case 'imageSlide2Up': case 'imageSlide2Down': case 'imageSlide2Left': case 'imageSlide2Right': case 'imageSlide2UpRight': case 'imageSlide2UpLeft': case 'imageSlide2DownRight': case 'imageSlide2DownLeft': $e.css({overflow:'hidden'}); item.customData.hoverEffectRDir=G.tn.getHE()[j].name; ThumbnailInitImageSlide($e, item); break; case 'imageSlide2Random': $e.css({overflow:'hidden'}); var dir= ['imageSlide2Up','imageSlide2Down','imageSlide2Left','imageSlide2Left','imageSlide2UpRight','imageSlide2UpLeft','imageSlide2DownRight','imageSlide2DownLeft']; item.customData.hoverEffectRDir=dir[Math.floor(Math.random()*dir.length)]; ThumbnailInitImageSlide($e, item); break; } } item.hoverInitDone=true; } function ThumbnailInitImageSlide( $e, item ) { // var w=item.thumbImgWidth; //$e.outerWidth(true), // h=item.thumbImg().height, //$e.outerHeight(true); var w=item.thumbFullWidth, //$e.outerWidth(true), h=item.thumbFullHeight, //$e.outerHeight(true); c=null; var t=newCSSTransform(item, 'img0', item.$getElt('img')); t.scale=140; switch( item.customData.hoverEffectRDir ){ case 'imageSlide2Up': // c={top:h*.1, left: -w*.1}; // t.translateY=h*.1; // t.translateX=-w*.1; t.translateY= item.thumbFullHeight < (item.thumbImg().height*1.4) ? ((item.thumbImg().height*1.4)-item.thumbFullHeight)/2 : 0; t.translateX= item.thumbFullWidth < (item.thumbImg().width*1.4) ? -((item.thumbImg().width*1.4)-item.thumbFullWidth)/2 : 0; break; case 'imageSlide2Down': // c={top:-h*.1, left: -w*.1}; // t.translateY=-h*.1; var tY=item.thumbFullHeight < (item.thumbImg().height*1.4) ? Math.min(((item.thumbImg().height*1.4)-item.thumbFullHeight)/2*.1,h*.1) : 0; t.translateY = -tY; var tX=item.thumbFullWidth < (item.thumbImg().width*1.4) ? Math.min(((item.thumbImg().width*1.4)-item.thumbFullWidth)/2*.1,w*.1) : 0; t.translateX = tX; break; case 'imageSlide2Left': // c={top:-h*.1, left: w*.1}; t.translateY=-h*.1; t.translateX=w*.1; break; case 'imageSlide2Right': // c={top:-h*.1, left: -w*.1}; t.translateY=-h*.1; t.translateX=-w*.1; break; case 'imageSlide2UpRight': // c={top:h*.05, left: -w*.05}; t.translateY=h*.05; t.translateX=-w*.05; break; case 'imageSlide2UpLeft': // c={top:h*.05, left: w*.05}; t.translateY=h*.05; t.translateX=w*.05; break; case 'imageSlide2DownRight': // c={top:-h*.05, left: -w*.05}; t.translateY=-h*.05; t.translateX=-w*.05; break; case 'imageSlide2DownLeft': // c={top:-h*.05, left: w*.05}; t.translateY=-h*.05; t.translateX=w*.05; break; } SetCSSTransform(item, 'img0'); //item.$getElt('.subcontainer').width(w).height(h); // $e.find('img').css({'max-width':w*1.5, 'max-height':h*1.5}); // $e.find('img')[0].style[G.CSStransformName] = 'scale(1.4)'; // $e.find('img').css(c); //.css({'width':w*1.5, 'height':h*1.5}); //item.$getElt('.imgContainer').css(c).css({'width':w*1.5, 'height':h*1.5}); } function ThumbnailOverResize( $e ) { var n=$e.data("index"); if( n == undefined ) { return; } // required because can be fired on ghost elements var item=G.I[n]; if( !item.hoverInitDone ) { ThumbnailOverInit($e); return; } if( typeof G.O.fnThumbnailHoverResize == 'function' ) { G.O.fnThumbnailHoverResize($e, item, ExposedObjects() ); } for( j=0; j 0 ) { // transit has a bug on queue --> we do not use it $e.delay(G.tn.getHE()[n].delay)[G.aengine](anime, G.tn.getHE()[n].duration , G.tn.getHE()[n].easing ); } else { // transit has a bug on queue --> we do not use it //anime.queue=false; //anime.duration=5000; $e[G.aengine](anime, G.tn.getHE()[n].duration, G.tn.getHE()[n].easing ); } } } function ThumbnailHover( $e ) { var n=$e.data('index'); if( n == undefined ) { return; } // required because can be fired on ghost elements if( G.aengine == 'velocity' ) { $e.find('*').velocity('stop', true); } else { $e.find('*').stop(true,false); } var item=G.I[n]; item.hovered=true; var dscale=(G.aengine == 'animate' ? 1 : 100); if( typeof G.O.fnThumbnailHover == 'function' ) { G.O.fnThumbnailHover($e, item, ExposedObjects()); } try { for( j=0; j 0 ) { // transit has a bug on queue --> we do not use it $e.delay(G.tn.getHE()[n].delay)[G.aengine](anime, G.tn.getHE()[n].durationBack , G.tn.getHE()[n].easingBack ); } else { // transit has a bug on queue --> we do not use it //anime.queue=false; //anime.duration=5000; $e[G.aengine](anime, G.tn.getHE()[n].durationBack, G.tn.getHE()[n].easingBack ); } } } function ThumbnailHoverOut( $e ) { if( G.containerViewerDisplayed ) { return; } var n=$e.data("index"); if( n == undefined ) { return; } // required because can be fired on ghost elements if( G.aengine == 'velocity' ) { $e.find('*').velocity('stop', true); } else { $e.find('*').filter(":animated").stop(true,false); } var item=G.I[n]; item.hovered=false; var dscale=(G.aengine == 'animate' ? 1 : 100); if( typeof G.O.fnThumbnailHoverOut == 'function' ) { G.O.fnThumbnailHoverOut($e, item, ExposedObjects()); } try { for( j=0; j').appendTo('body'); G.$E.conVwCon.addClass('nanogallery_theme_'+G.O.theme); SetColorSchemeViewer(G.$E.conVwCon); G.$E.conVw=jQuery('
').appendTo(G.$E.conVwCon); G.$E.conVw.css({ visibility:'visible', position: 'fixed' //"absolute", }); // avoid pinch zoom G.$E.conVw.css({msTouchAction:'none', touchAction:'none'}); var sImg='', l=G.I.length; sImg+=' '; sImg+=' '; sImg+=' '; // sImg+=' '; // sImg+=' '; // sImg+=' '; G.$E.vwContent=jQuery('
'+sImg+'
').appendTo(G.$E.conVw); G.$E.vwImgP=G.$E.conVw.find('.image').eq(0); G.$E.vwImgC=G.$E.conVw.find('.image').eq(1); G.$E.vwImgN=G.$E.conVw.find('.image').eq(2); // makes content unselectable --> avoid image drag effect during 'mouse swipe' G.$E.conVwCon.find('*').attr('draggable', 'false').attr('unselectable', 'on'); var $closeB=jQuery('
').appendTo(G.$E.conVw); $closeB.on("touchstart click",function(e){ // $closeB.on( (G.isIOS ? "touchstart" : "click") ,function(e){ // IPAD e.preventDefault(); e.stopPropagation(); if( (new Date().getTime()) - G.timeImgChanged < 400 ) { return; } CloseInternalViewer(true); return false; }); // build image toolbar var sTB='
'; var tstd = G.O.viewerToolbar.standard.split(','); for( var i=0, lstd=tstd.length; i 0 && G.O.viewerToolbar.autoMinimize >= getViewport().w) ) { ToolbarVisibilityMin(); } else { ToolbarVisibilityStd(); } if( G.O.viewerFullscreen ) { G.viewerIsFullscreen=true; G.$E.conVwTb.find('.fullscreenButton').removeClass('setFullscreenButton').addClass('removeFullscreenButton'); ngscreenfull.request(); } if( G.O.viewerDisplayLogo ) { G.$E.vwLogo=jQuery('').appendTo(G.$E.conVw); } setElementOnTop('',G.$E.conVw); setElementOnTop(G.$E.conVw,$closeB); ResizeInternalViewer(); G.timeImgChanged=new Date().getTime(); G.$E.conVwTb.find('.closeButton').on("touchstart click",function(e){ e.preventDefault(); e.stopPropagation(); if( (new Date().getTime()) - G.timeImgChanged < 400 ) { return; } CloseInternalViewer(true); }); G.$E.conVwTb.find('.playPauseButton').on("touchstart click",function(e){ e.stopPropagation(); SlideshowToggle(); }); G.$E.conVwTb.find('.minimizeButton').on("touchstart click",function(e){ e.stopPropagation(); ToolbarVisibilityToggle(); }); G.$E.conVwTb.find('.fullscreenButton').on("touchstart click",function(e){ e.stopPropagation(); ViewerFullscreenToggle(); }); G.$E.conVwTb.find('.infoButton').on("touchstart click",function(e){ e.stopPropagation(); if( typeof G.O.fnViewerInfo == 'function' ) { G.O.fnViewerInfo(G.I[G.viewerCurrentItemIdx], ExposedObjects()); } }); // custom button click G.$E.conVwTb.find('.ngCustomBtn').on("touchstart click",function(e){ e.stopPropagation(); if( typeof G.O.fnImgToolbarCustClick == 'function' ) { var target = e.target || e.srcElement; while( target == null || target.getAttribute('class') == null || target.getAttribute('class').indexOf('ngCustomBtn') == -1 ) { // go element parent up to find the custom element target = target.parentNode; } var v=target.getAttribute('class'); if( v.indexOf('ngCustomBtn') >=0 ) { var vs=v.split(' '); for( var i=0, l=vs.length; i' + (typeof G.O.fnImgToolbarCustInit == 'function' ? G.O.fnImgToolbarCustInit(e) : '') + '
'; } break; } return r; } // based on "Implement Custom Gestures" from Google // https://developers.google.com/web/fundamentals/input/touch-input/touchevents/ function ViewerSwipeSupport(element) { var elementToSwipe=element, isAnimating=false, initialTouchPos=null, lastTouchPos=null, currentXPosition=0, me=this; function handleGestureStart(e) { if( !G.containerViewerDisplayed ) { return; } G.timeLastTouchStart=new Date().getTime(); e.preventDefault(); if(e.touches && e.touches.length > 1) { return; } initialTouchPos = getGesturePointFromEvent(e); // Add the move and end listeners if (window.navigator.msPointerEnabled) { // Pointer events are supported. document.addEventListener('MSPointerMove', handleGestureMove, true); document.addEventListener('MSPointerUp', handleGestureEnd, true); } else { // Add Touch Listeners document.addEventListener('touchmove', handleGestureMove, true); document.addEventListener('touchend', handleGestureEnd, true); document.addEventListener('touchcancel', handleGestureEnd, true); // Add Mouse Listeners document.addEventListener('mousemove', handleGestureMove, true); document.addEventListener('mouseup', handleGestureEnd, true); } } function handleGestureMove(e) { e.preventDefault(); lastTouchPos = getGesturePointFromEvent(e); if(isAnimating) { return; } isAnimating = true; // window.requestAnimFrame(onAnimFrame); window.requestAnimationFrame(onAnimFrame); } // Handle end gestures function handleGestureEnd(e) { if( e.cancelable ) { e.preventDefault(); } if(e.touches && e.touches.length > 0) { return; } isAnimating = false; // Remove Event Listeners if (window.navigator.msPointerEnabled) { // Remove Pointer Event Listeners document.removeEventListener('MSPointerMove', handleGestureMove, true); document.removeEventListener('MSPointerUp', handleGestureEnd, true); } else { // Remove Touch Listeners document.removeEventListener('touchmove', handleGestureMove, true); document.removeEventListener('touchend', handleGestureEnd, true); document.removeEventListener('touchcancel', handleGestureEnd, true); // Remove Mouse Listeners document.removeEventListener('mousemove', handleGestureMove, true); document.removeEventListener('mouseup', handleGestureEnd, true); } updateSwipeRestPosition(); } // function updateSwipeRestPositionOLD(me) { function updateSwipeRestPosition() { if( lastTouchPos == null ) { // touchend without touchmove currentXPosition=0; initialTouchPos=null; return; } var differenceInX = initialTouchPos.x - lastTouchPos.x; currentXPosition = currentXPosition - differenceInX; if( differenceInX < -50 ) { DisplayPreviousImage(); } if( differenceInX > 50 ) { DisplayNextImagePart1(); } currentXPosition=0; initialTouchPos=null; lastTouchPos=null; if(Math.abs(differenceInX) < 50) { ImageSwipeTranslateX(currentXPosition); } return; } function getGesturePointFromEvent(e) { var point = {}; if(e.targetTouches) { point.x = e.targetTouches[0].clientX; point.y = e.targetTouches[0].clientY; } else { // Either Mouse event or Pointer Event point.x = e.clientX; point.y = e.clientY; } return point; } function onAnimFrame() { if(!isAnimating) { return; } var differenceInX = initialTouchPos.x - lastTouchPos.x; ImageSwipeTranslateX(currentXPosition - differenceInX); isAnimating = false; } this.removeEventListeners = function() { // we need to remove all the event listeners (becauase of an issue with the close button) if (window.navigator.msPointerEnabled) { elementToSwipe.removeEventListener('MSPointerDown', handleGestureStart, true); document.removeEventListener('MSPointerMove', handleGestureMove, true); document.removeEventListener('MSPointerUp', handleGestureEnd, true); } else { // Remove Touch Listeners elementToSwipe.removeEventListener('touchstart', handleGestureStart, true); document.removeEventListener('touchmove', handleGestureMove, true); document.removeEventListener('touchend', handleGestureEnd, true); document.removeEventListener('touchcancel', handleGestureEnd, true); // Remove Mouse Listeners document.removeEventListener('mousemove', handleGestureMove, true); document.removeEventListener('mouseup', handleGestureEnd, true); //elementToSwipe.removeEventListener('mousedown', this.handleGestureStart, true); } } // Check if pointer events are supported. if (window.navigator.msPointerEnabled) { // Add Pointer Event Listener // elementToSwipe.addEventListener('MSPointerDown', this.handleGestureStart, true); elementToSwipe.addEventListener('MSPointerDown', handleGestureStart, true); } else { // Add Touch Listener // elementToSwipe.addEventListener('touchstart', this.handleGestureStart, true); elementToSwipe.addEventListener('touchstart', handleGestureStart, true); // Add Mouse Listener //elementToSwipe.addEventListener('mousedown', this.handleGestureStart, true); } } function ImageSwipeTranslateX( posX ) { G.imageSwipePosX=posX; if( G.CSStransformName == null ) { G.$E.vwImgC.css({ left: posX }); } else { G.$E.vwImgC[0].style[G.CSStransformName]= 'translateX('+posX+'px)'; if( G.O.imageTransition == 'slide' ) { if( posX > 0 ) { var $new=G.$E.vwImgP; var dir=getViewport().w; G.$E.vwImgP.css({visibility:'visible', left:0, opacity:1}); G.$E.vwImgP[0].style[G.CSStransformName]= 'translateX('+(-dir+posX)+'px) ' G.$E.vwImgN[0].style[G.CSStransformName]= 'translateX('+(-dir)+'px) ' } else { var $new=G.$E.vwImgN; var dir=-getViewport().w; G.$E.vwImgN.css({visibility:'visible', left:0, opacity:1}); G.$E.vwImgN[0].style[G.CSStransformName]= 'translateX('+(-dir+posX)+'px) ' G.$E.vwImgP[0].style[G.CSStransformName]= 'translateX('+(-dir)+'px) ' } } } } // Toggle viewer fullscreen mode on/off function ViewerFullscreenToggle(){ if( ngscreenfull.enabled ) { // ngscreenfull.toggle(G.$E.conVwCon[0]); // --> issue on scrollbar visibility ngscreenfull.toggle(); if( G.viewerIsFullscreen ) { G.viewerIsFullscreen=false; G.$E.conVwTb.find('.fullscreenButton').removeClass('removeFullscreenButton').addClass('setFullscreenButton'); } else { G.viewerIsFullscreen=true; G.$E.conVwTb.find('.fullscreenButton').removeClass('setFullscreenButton').addClass('removeFullscreenButton'); } } } // toggle slideshow mode on/off function SlideshowToggle(){ if( G.playSlideshow ) { window.clearInterval(G.playSlideshowTimerID); G.playSlideshow=false; G.$E.conVwTb.find('.playPauseButton').removeClass('pauseButton').addClass('playButton'); } else { G.playSlideshow=true; G.$E.conVwTb.find('.playPauseButton').removeClass('playButton').addClass('pauseButton'); DisplayNextImage(); G.playSlideshowTimerID=window.setInterval(function(){DisplayNextImage();},G.slideshowDelay); } } // toggle toolbar visibility function ToolbarVisibilityToggle(){ if( G.toolbarMode == 'std' ) { ToolbarVisibilityMin(); } else { ToolbarVisibilityStd(); } } function ToolbarVisibilityStd() { G.toolbarMode='std'; G.$E.conVwTb.find('.minimizeButton').removeClass('viewToolbarButton').addClass('hideToolbarButton'); ToolbarSetItemsVisibility('std'); ResizeInternalViewer(); } function ToolbarVisibilityMin() { G.toolbarMode='min'; G.$E.conVwTb.find('.minimizeButton').removeClass('hideToolbarButton').addClass('viewToolbarButton'); ToolbarSetItemsVisibility('min'); ResizeInternalViewer(); } function ToolbarSetItemsVisibility( curMode ) { var t=G.O.viewerToolbar; var t= ( curMode == 'std' ? G.O.viewerToolbar.standard : G.O.viewerToolbar.minimized); // standard elements var v=['minimizeButton', 'previousButton', 'pageCounter', 'nextButton', 'playPauseButton', 'fullscreenButton', 'infoButton', 'linkOriginalButton', 'closeButton', 'label']; for( var i=0, l=v.length; i= 0 ? 'table-cell' : 'none') }); } } else { G.$E.conVwTb.find('.'+v[i]).css({ display:( t.indexOf(v[i]) >= 0 ? 'table-cell' : 'none') }); } } // custom elements G.$E.conVwTb.find('.ngCustomBtn').css({ display: 'none' }); var vC=t.split(','); for( var i=0, l=vC.length; i just appear / no slide animation G.$E.vwImgC.css({ opacity:0, left:0, visibility: 'visible'}).attr('src',G.emptyGif).attr('src',G.I[imageIdx].responsiveURL()); // G.$E.vwImgC.css({ opacity:0, left:0, visibility: 'visible', 'background-image':'url('+G.I[imageIdx].responsiveURL()+')'}).attr('src',G.emptyGif); var tweenable = new NGTweenable(); tweenable.tween({ from: { o: 0 }, to: { o: 1 }, attachment: { idx:imageIdx, dT:displayType }, duration: 400, step: function (state, att) { G.$E.vwImgC.css({ opacity: state.o }); }, finish: function (state, att) { G.$E.vwImgC.css({ opacity: 1}); DisplayInternalViewerComplete(att.idx, att.dT); } }); } else { // animate image change switch( G.O.imageTransition ) { case 'fade': var $new=(displayType == 'nextImage' ? G.$E.vwImgN : G.$E.vwImgP); $new.css({ opacity:0, left:0, visibility:'visible'}); var tweenable = new NGTweenable(); tweenable.tween({ from: { o: 0 }, to: { o: 1 }, attachment: { idx:imageIdx, dT:displayType, $e:$new }, duration: 300, step: function (state, att) { G.$E.vwImgC.css({ opacity: 1-state.o }); att.$e.css({ opacity: state.o }); }, finish: function (state, att) { G.$E.vwImgC.css({ opacity: 0 }); att.$e.css({ opacity: 1 }); DisplayInternalViewerComplete(att.idx, att.dT); } }); break; case 'slideBETA': var $new=(displayType == 'nextImage' ? G.$E.vwImgN : G.$E.vwImgP); $new.css({ opacity:1, left:0, visibility:'visible'}); if( G.CSStransformName == null ) { // animate LEFT jQuery.when( G.$E.vwImgC.animate({ left: (displayType == 'nextImage' ? -getViewport().w : getViewport().w)+'px', opacity: 0 }, 500), $new.animate({ opacity: 1 }, 300) ).done(function () { DisplayInternalViewerComplete(imageIdx, displayType); }); } else { // animate TRANSLATEX var dir=(displayType == 'nextImage' ? - getViewport().w : getViewport().w); $new[0].style[G.CSStransformName]= 'translateX('+(-dir)+'px) ' var from = {v: G.imageSwipePosX }; var to = {v: (displayType == 'nextImage' ? - getViewport().w : getViewport().w)}; jQuery(from).animate(to, { duration:500, step: function(currentValue) { G.$E.vwImgC[0].style[G.CSStransformName]= 'translateX('+currentValue+'px)'; G.$E.vwImgC.css({ opacity: (1-Math.abs(currentValue/dir)) }); $new[0].style[G.CSStransformName]= 'translateX('+(-dir+currentValue)+'px) ' }, complete: function() { G.$E.vwImgC[0].style[G.CSStransformName]= ''; G.$E.vwImgC.css({ opacity:0 }); DisplayInternalViewerComplete(imageIdx, displayType); } }); } break; case 'slideOLD': var $new=(displayType == 'nextImage' ? G.$E.vwImgN : G.$E.vwImgP); // if( G.CSStransformName == null || ( G.isIOS && G.IOSversion < 6 ) ) { if( G.CSStransformName == null ) { // animate LEFT $new.css({ opacity:0, left:0, visibility:'visible'}); jQuery.when( G.$E.vwImgC.animate({ left: (displayType == 'nextImage' ? -getViewport().w : getViewport().w)+'px' }, 500), $new.animate({ opacity: 1 }, 300) ).done(function () { DisplayInternalViewerComplete(imageIdx, displayType); }); } else { // animate using TRANSLATEX $new.css({ opacity:1, left:0, visibility:'visible'}); var dir=(displayType == 'nextImage' ? - getViewport().w : getViewport().w); $new[0].style[G.CSStransformName]= 'translateX('+(-dir)+'px) ' var from = {v: G.imageSwipePosX }; var to = {v: (displayType == 'nextImage' ? - getViewport().w : getViewport().w)}; jQuery(from).animate(to, { duration:400, easing:'linear', step: function(currentValue) { window.requestAnimationFrame( function() { G.$E.vwImgC[0].style[G.CSStransformName]= 'translateX('+currentValue+'px)'; //G.$E.vwImgC.css({ opacity: (1-Math.abs(currentValue/dir)) }); $new[0].style[G.CSStransformName]= 'translateX('+(-dir+currentValue)+'px) ' }); }, complete: function() { window.requestAnimationFrame( function() { G.$E.vwImgC[0].style[G.CSStransformName]= ''; //G.$E.vwImgC.css({ opacity:0 }); DisplayInternalViewerComplete(imageIdx, displayType); }); } }); } break; case 'slide': var $new=(displayType == 'nextImage' ? G.$E.vwImgN : G.$E.vwImgP); // if( G.CSStransformName == null || ( G.isIOS && G.IOSversion < 6 ) ) { if( G.CSStransformName == null ) { // animate LEFT $new.css({ opacity:0, left:0, visibility:'visible'}); jQuery.when( G.$E.vwImgC.animate({ left: ((displayType == 'nextImage' ? -getViewport().w : getViewport().w)*2)+'px' }, 500), $new.animate({ opacity: 1 }, 300) ).done(function () { DisplayInternalViewerComplete(imageIdx, displayType); }); } else { // animate using TRANSLATEX var dir=(displayType == 'nextImage' ? - getViewport().w : getViewport().w); $new.css({ opacity:1, left:0, visibility:'visible'}); $new[0].style[G.CSStransformName]= 'translateX('+(-dir)+'px) ' var tweenable = new NGTweenable(); tweenable.tween({ from: { t: G.imageSwipePosX }, to: { t: (displayType == 'nextImage' ? - getViewport().w : getViewport().w) }, attachment: { idx:imageIdx, dT:displayType, $e:$new, dir:dir }, duration: 300, step: function (state, att) { G.$E.vwImgC[0].style[G.CSStransformName]= 'translateX('+state.t+'px)'; att.$e[0].style[G.CSStransformName]= 'translateX('+(-att.dir+state.t)+'px) '; }, finish: function (state, att) { G.$E.vwImgC[0].style[G.CSStransformName]= ''; att.$e[0].style[G.CSStransformName]= ''; DisplayInternalViewerComplete(att.idx, att.dT); } }); } break; case 'slideAppear': default: var dir= getViewport().w+'px'; var $new=G.$E.vwImgP; if( displayType == 'nextImage' ) { dir='-'+dir; $new=G.$E.vwImgN; } $new.css({ opacity:0, left:0, visibility:'visible'}); jQuery.when( G.$E.vwImgC.animate({ left: dir, opacity: 0 }, 500), $new.animate({ opacity: 1 }, 300) ).done(function () { ImageSwipeTranslateX(0); DisplayInternalViewerComplete(imageIdx, displayType); }); break; } } } function DisplayInternalViewerComplete( imageIdx, displayType ) { DisplayInternalViewerToolbar(imageIdx); if( G.O.debugMode && console.timeline ) { console.timelineEnd('nanoGALLERYviewer'); } if( typeof G.O.fnImgDisplayed === 'function'){ if( !G.O.fnImgDisplayed(G.I[imageIdx].$elt, G.I[imageIdx]) ) { return; } } G.imageSwipePosX=0; G.$E.vwImgC.off("click"); G.$E.vwImgC.removeClass('imgCurrent'); var $tmp=G.$E.vwImgC; switch( displayType ) { case 'nextImage': G.$E.vwImgC=G.$E.vwImgN; G.$E.vwImgN=$tmp; break; case 'previousImage': G.$E.vwImgC=G.$E.vwImgP; G.$E.vwImgP=$tmp; break; } G.$E.vwImgC.addClass('imgCurrent'); G.$E.vwImgN.css({ opacity:0, left:0, visibility:'hidden' }).attr('src',G.emptyGif).attr('src',G.I[GetNextImageIdx(imageIdx)].responsiveURL()); // G.$E.vwImgN.css({ opacity:0, left:0, visibility:'hidden', 'background-image':'url('+G.I[GetNextImageIdx(imageIdx)].responsiveURL()+')' }).attr('src',G.emptyGif); G.$E.vwImgP.css({ opacity:0, left:0, visibility:'hidden'}).attr('src',G.emptyGif).attr('src',G.I[GetPreviousImageIdx(imageIdx)].responsiveURL()); // G.$E.vwImgP.css({ opacity:0, left:0, visibility:'hidden', 'background-image':'url('+G.I[GetPreviousImageIdx(imageIdx)].responsiveURL()+')'}).attr('src',G.emptyGif); G.$E.vwImgC.on("click",function(e){ e.stopPropagation(); if( e.pageX < (jQuery(window).width()/2) ) { DisplayPreviousImage(); } else { DisplayNextImagePart1(); } }); ResizeInternalViewer(); // TODO: this code does not work //jQuery(G.containerViewerContent).item.$getElt('img').on('resize', function(){ // ResizeInternalViewer('.imgCurrent'); // console.log('resized'); //}); G.viewerImageIsChanged=false; } function GetNextImageIdx( imageIdx ) { var l=G.I.length; var newImageIdx=-1; for(var i=imageIdx+1; i=0; i-- ){ if( G.I[i].albumID == G.I[imageIdx].albumID && G.I[i].kind == 'image' ) { newImageIdx=i; break; } } if( newImageIdx == -1 ) { for(var i=G.I.length-1; i>=imageIdx; i-- ){ if( G.I[i].albumID == G.I[imageIdx].albumID && G.I[i].kind == 'image' ) { newImageIdx=i; break; } } } return newImageIdx; } function HideInternalViewerToolbar() { G.$E.conVwTb.css({'visibility':'hidden'}); } function DisplayInternalViewerToolbar( imageIdx ) { if( !G.O.viewerToolbar.display ) { return; } G.$E.conVwTb.css({'visibility':'visible'}); var setTxt=false; // set title if( G.I[imageIdx].title !== undefined && G.I[imageIdx].title != '' ) { G.$E.conVwTb.find('.title').html(G.I[imageIdx].title); setTxt=true; } else { G.$E.conVwTb.find('.title').html(''); } // set description if( G.I[imageIdx].description !== undefined && G.I[imageIdx].description != '' ) { G.$E.conVwTb.find('.description').html(G.I[imageIdx].description); setTxt=true; } else { G.$E.conVwTb.find('.description').html(''); } // custom elements var $cu=G.$E.conVwTb.find('.ngCustomBtn'); if( $cu.length > 0 && typeof G.O.fnImgToolbarCustDisplay == 'function' ) { G.O.fnImgToolbarCustDisplay( $cu, G.I[imageIdx], ExposedObjects()); } // if( setTxt && (G.O.viewerToolbar.label == 'always' || G.O.viewerToolbar.label == G.toolbarMode) ) { if( setTxt && (G.toolbarMode == 'std' ? G.O.viewerToolbar.standard : G.O.viewerToolbar.minimized).indexOf('label') >= 0 ) { G.$E.conVwTb.find('.label').show(); } else { G.$E.conVwTb.find('.label').hide(); } // set page number var viewerMaxImages= galleryCountImages(); if( viewerMaxImages > 0 ) { G.$E.conVwTb.find('.pageCounter').html((G.I[imageIdx].imageNumber+1)+'/'+viewerMaxImages); } //ResizeInternalViewer(); } function CloseInternalViewer( setLocationHash ) { if( G.viewerImageIsChanged ) { G.$E.vwContent.find('*').stop(true,true); //return; } G.viewerImageIsChanged=false; if( G.containerViewerDisplayed ) { // window.clearInterval(G.viewerResizeTimerID); window.clearTimeout(G.viewerResizeTimerID); if( G.playSlideshow ) { window.clearInterval(G.playSlideshowTimerID); G.playSlideshow=false; } G.viewerSwipe.removeEventListeners(); G.viewerSwipe=null; if( !(G.O.galleryFullpageButton && G.$E.base.hasClass('fullpage')) ) { // avoid displaying scrollbar when gallery is in fullpage mode ScrollbarSetVisible(); } if( G.viewerIsFullscreen ) { G.viewerIsFullscreen=false; ngscreenfull.exit(); } G.$E.conVwCon.hide(0).off().show(0).html('').remove(); G.containerViewerDisplayed=false; if( G.albumIdxToOpenOnViewerClose != -1 ) { DisplayAlbum(G.albumIdxToOpenOnViewerClose,true); } else { if( G.O.locationHash && setLocationHash ) { var albumID=G.I[G.viewerCurrentItemIdx].albumID, s='nanogallery/'+G.baseEltID+'/'+albumID; G.lastLocationHash='#'+s; try { top.location.hash=s; } catch(e) { G.O.locationHash=false; } } ThumbnailHoverOutAll(); } G.timeImgChanged=new Date().getTime(); } }; function ResizeInternalViewer() { if( !G.containerViewerDisplayed ) { return; } if( (new Date().getTime()) - G.viewerResizeTimerLastRun < 100 ) { return; } //window.clearInterval(G.viewerResizeTimerID); //G.viewerResizeTimerID=window.setInterval(function(){ResizeInternalViewer()},200); window.requestAnimationFrame( function() { var windowsW=G.$E.conVw.width(); var windowsH=G.$E.conVw.height(); var $elt=G.$E.vwImgC, vwImgC_H=$elt.height(), vwImgC_W=$elt.width(), vwImgC_OHt=$elt.outerHeight(true), vwImgC_OHf=$elt.outerHeight(false); var $tb=G.$E.conVwTb.find('.toolbar'), tb_OHt=$tb.outerHeight(true); if( vwImgC_H <= 40 || !G.O.viewerToolbar.display ) { G.$E.conVwTb.css({visibility:'hidden'}); } else { G.$E.conVwTb.css({visibility:'visible'}); } var contentOuterWidthV=Math.abs(G.$E.vwContent.outerHeight(true)-G.$E.vwContent.height()), // vertical margin+border+padding contentOuterWidthH=Math.abs(G.$E.vwContent.outerWidth(true)-G.$E.vwContent.width()), // horizontal margin+border+padding imgBorderV=vwImgC_OHf-$elt.innerHeight(), imgBorderH=Math.abs($elt.outerWidth(false)-$elt.innerWidth()), imgPaddingV=Math.abs($elt.innerHeight()-vwImgC_H), imgPaddingH=Math.abs($elt.innerWidth()-vwImgC_W), tV=imgBorderV+imgPaddingV, //+tmargin; tH=imgBorderH+imgPaddingH, //+tmargin; toolbarH=0; if( G.O.viewerToolbar.style != 'innerImage' ) { toolbarH=tb_OHt; } var h=windowsH-toolbarH-contentOuterWidthV, w=windowsW-contentOuterWidthH; switch( G.O.viewerToolbar.position ) { case 'top': G.$E.vwContent.css({height:h, width:w, top:toolbarH }); var posY=0; if( G.O.viewerToolbar.style == 'innerImage' ) { posY= Math.abs(vwImgC_OHt-vwImgC_H)/2 +5; } if( G.O.viewerToolbar.style == 'stuckImage' ) { posY= Math.abs(vwImgC_OHt-vwImgC_H)/2 -tV; } G.$E.conVwTb.css({top: posY}); break; case 'bottom': default: G.$E.vwContent.css({height:h, width:w }); var posY=0; if( G.O.viewerToolbar.style == 'innerImage' ) { posY= Math.abs(vwImgC_OHt-vwImgC_H)/2 +5;//- G.$E.conVwTb.outerHeight(true) ; } if( G.O.viewerToolbar.style == 'stuckImage' ) { posY= Math.abs(vwImgC_OHt-vwImgC_H)/2 -tV; } G.$E.conVwTb.css({bottom: posY}); break; } if( G.O.viewerToolbar.style == 'innerImage' ) { $tb.css({'max-width': vwImgC_W}); } if( G.O.viewerToolbar.style == 'fullWidth' ) { $tb.css({width: w}); } G.$E.conVwTb.css({ height: tb_OHt }); // resize toolbar container to toolbar size G.$E.vwContent.children('img').css({'max-width':(w-tH), 'max-height':(h-tV) }); // G.$E.vwContent.children('img').css({'width':'100%', 'height':'100%' }); // G.$E.vwContent.children('img').css({'background-size':'contain', 'background-position':'center', 'background-repeat':'no-repeat' }); G.$E.vwContent.children('img').css({'object-fit':'contain' }); G.viewerResizeTimerID=window.setTimeout( ResizeInternalViewer, 100); G.viewerResizeTimerLastRun=new Date().getTime(); }); } function OpenImageCustomViewer( imageIdx ) { var n=imageIdx, items=[], current=0; items.push(G.I[n]); var l=G.I.length; for( var j=n+1; j .nanoGalleryThumbnailContainer { background:'+cs.thumbnail.background+' !important; border:'+cs.thumbnail.border+' !important; }'+'\n'; s+=s1+'.nanoGalleryContainer > .nanoGalleryThumbnailContainer .imgContainer { background:'+cs.thumbnail.background+' !important; }'+'\n'; // s+=s1+'.nanoGalleryContainer .nanoGalleryThumbnailContainer .labelImage { background:'+cs.thumbnail.labelBackground+' !important; }'+'\n'; s+=s1+'.nanoGalleryContainer > .nanoGalleryThumbnailContainer .labelImage{ background:'+cs.thumbnail.labelBackground+' ; }'+'\n'; s+=s1+'.nanoGalleryContainer > .nanoGalleryThumbnailContainer .labelImageTitle { color:'+cs.thumbnail.titleColor+' !important; Text-Shadow:'+cs.thumbnail.titleShadow+' !important; }'+'\n'; s+=s1+'.nanoGalleryContainer > .nanoGalleryThumbnailContainer .labelImageTitle:before { color:'+cs.thumbnail.titleColor+' !important; Text-Shadow:'+cs.thumbnail.titleShadow+' !important; }'+'\n'; s+=s1+'.nanoGalleryContainer > .nanoGalleryThumbnailContainer .labelFolderTitle { color:'+cs.thumbnail.titleColor+' !important; Text-Shadow:'+cs.thumbnail.titleShadow+' !important; }'+'\n'; var c=cs.thumbnail.labelBackground; if( c == 'transparent' ) { c=''; } s+=s1+'.nanoGalleryContainer > .nanoGalleryThumbnailContainer .labelFolderTitle > span { background-color:'+cs.thumbnail.titleColor+' !important; color:'+c+' !important; }'+'\n'; s+=s1+'.nanoGalleryContainer > .nanoGalleryThumbnailContainer .labelFolderTitle:before { color:'+cs.thumbnail.titleColor+' !important; Text-Shadow:'+cs.thumbnail.titleShadow+' !important; }'+'\n'; s+=s1+'.nanoGalleryContainer > .nanoGalleryThumbnailContainer .labelDescription { color:'+cs.thumbnail.descriptionColor+' !important; Text-Shadow:'+cs.thumbnail.descriptionShadow+' !important; }'+'\n'; s+=s1+'.nanoGalleryContainer > .nanoGalleryThumbnailContainer .labelDescription > span { background-color:'+cs.thumbnail.titleColor+' !important; color:'+c+' !important; }'+'\n'; // s+='.' + G.colorSchemeLabel +'.fullpage { background:'+G.O.galleryFullpageBgColor+' !important; }'+'\n'; // pagination dot based if( G.O.paginationDots ) { s+=s1+'.nanoGalleryPaginationDot > .paginationItem { border:'+cs.thumbnail.paginationDotBorder+' !important; background:'+cs.thumbnail.paginationDotBack+' !important;}'+'\n'; s+=s1+'.nanoGalleryPaginationDot > .currentPage { background:'+cs.thumbnail.paginationDotSelBack+' !important;}'+'\n'; } // gallery fullpage background color var gbg='nanogallery_galleryfullpage_bgcolor_'+G.baseEltID; s+='.' + gbg +'.fullpage { background:'+G.O.galleryFullpageBgColor+' !important; }'+'\n'; jQuery('head').append(''); jQuery(element).addClass(G.colorSchemeLabel); jQuery(element).addClass(gbg); }; // ##### VIEWER COLOR SCHEME ##### function SetColorSchemeViewer( element ) { var cs=null; switch(toType(G.O.colorSchemeViewer)) { case 'object': // user custom color scheme object cs=G.colorSchemeViewer_default; jQuery.extend(true,cs,G.O.colorSchemeViewer); G.colorSchemeLabel='nanogallery_colorschemeviewer_custom'; break; case 'string': // name of an internal defined color scheme switch( G.O.colorSchemeViewer ) { case 'none': return; break; case 'light': cs=G.colorSchemeViewer_light; G.colorSchemeLabel='nanogallery_colorschemeviewer_light'; break; case 'darkRed': cs=G.colorSchemeViewer_darkRed; G.colorSchemeLabel='nanogallery_colorschemeviewer_darkred'; break; case 'darkGreen': cs=G.colorSchemeViewer_darkGreen; G.colorSchemeLabel='nanogallery_colorschemeviewer_darkgreen'; break; case 'darkBlue': cs=G.colorSchemeViewer_darkBlue; G.colorSchemeLabel='nanogallery_colorschemeviewer_darkblue'; break; case 'darkOrange': cs=G.colorSchemeViewer_darkOrange; G.colorSchemeLabel='nanogallery_colorschemeviewer_darkorange'; break; case 'dark': cs=G.colorSchemeViewer_dark; G.colorSchemeLabel='nanogallery_colorschemeviewer_dark'; break; case 'default': default: cs=G.colorSchemeViewer_default; G.colorSchemeLabel='nanogallery_colorschemeviewer_default'; } break; default: nanoAlert('Error in colorSchemeViewer parameter.'); return; } //var s1='.nanogallery_theme_'+G.O.theme+' '; var s1='.' + G.colorSchemeLabel + ' '; var s=s1+'.nanoGalleryViewer { background:'+cs.background+' !important; }'+'\n'; //s+=s1+'.nanoGalleryViewer { background:'+cs.viewer.background+'; color:'+cs.viewer.color+'; }'+'\n'; s+=s1+'.nanoGalleryViewer .content img { border:'+cs.imageBorder+' !important; box-shadow:'+cs.imageBoxShadow+' !important; }'+'\n'; s+=s1+'.nanoGalleryViewer .toolbar { background:'+cs.barBackground+' !important; border:'+cs.barBorder+' !important; color:'+cs.barColor+' !important; }'+'\n'; s+=s1+'.nanoGalleryViewer .toolbar .previousButton:after { color:'+cs.barColor+' !important; }'+'\n'; s+=s1+'.nanoGalleryViewer .toolbar .nextButton:after { color:'+cs.barColor+' !important; }'+'\n'; s+=s1+'.nanoGalleryViewer .toolbar .closeButton:after { color:'+cs.barColor+' !important; }'+'\n'; //s+=s1+'.nanoGalleryViewer .toolbar .label { background:'+cs.barBackground+'; }'+'\n'; s+=s1+'.nanoGalleryViewer .toolbar .label .title { color:'+cs.barColor+' !important; }'+'\n'; s+=s1+'.nanoGalleryViewer .toolbar .label .description { color:'+cs.barDescriptionColor+' !important; }'+'\n'; jQuery('head').append(''); jQuery(element).addClass(G.colorSchemeLabel); }; // ################# // ##### TOOLS ##### // ################# // Display a message function nanoAlert( msg, verbose ) { nanoConsoleLog(msg); if( G.$E.conConsole != null ) { G.$E.conConsole.css({visibility:'visible', height:'auto'}); if( verbose == false ) { G.$E.conConsole.append('

'+ msg + '

'); } else { G.$E.conConsole.append('

nanoGALLERY: '+msg+ ' ['+G.baseEltID+']

'); } //alert('nanoGALLERY: ' + msg); } }; // write to console log function nanoConsoleLog( msg ) { if (window.console) { console.log('nanoGALLERY: ' + msg + ' ['+G.baseEltID+']'); } }; // get viewport coordinates and size function getViewport() { var $win = jQuery(window); // to simulate smaller device screen width vpW=$win.width(); if( G.O.demoViewportWidth > 0 ) { if( G.O.demoViewportWidth < vpW) { vpW=G.O.demoViewportWidth; } G.O.maxWidth=vpW; jQuery(G.$E.base).css({'width':G.O.maxWidth}); jQuery(G.$E.base).css({'margin-left':'auto'}); jQuery(G.$E.base).css({'margin-right':'auto'}); } return { l: $win.scrollLeft(), t: $win.scrollTop(), w: vpW, h: $win.height() } } function inViewport( $elt, threshold ) { var wp=getViewport(), eltOS=$elt.offset(), th=$elt.outerHeight(true), tw=$elt.outerWidth(true); if( eltOS.top >= (wp.t-threshold) && (eltOS.top+th) <= (wp.t+wp.h+threshold) && eltOS.left >= (wp.l-threshold) && (eltOS.left+tw) <= (wp.l+wp.w+threshold) ) { return true; } else { return false; } } function inViewportVert( $elt, threshold ) { var wp=getViewport(), eltOS=$elt.offset(), th=$elt.outerHeight(true), tw=$elt.outerWidth(true); if( wp.t == 0 && (eltOS.top) <= (wp.t+wp.h ) ) { return true; } if( eltOS.top >= (wp.t) && (eltOS.top+th) <= (wp.t+wp.h-threshold) ) { return true; } else { return false; } } // set z-index to display element on top of all others function setElementOnTop( start, elt ) { var highest_index = 0; if( start=='' ) { start= '*'; } jQuery(start).each(function() { var cur = parseInt(jQuery(this).css('z-index')); highest_index = cur > highest_index ? cur : highest_index; }); highest_index++; jQuery(elt).css('z-index',highest_index); }; // set z-index to display 2 elements on top of all others function set2ElementsOnTop( start, elt1, elt2 ) { var highest_index = 0; if( start=='' ) { start= '*'; } jQuery(start).each(function() { var cur = parseInt(jQuery(this).css('z-index')); highest_index = cur > highest_index ? cur : highest_index; }); highest_index++; jQuery(elt2).css('z-index',highest_index+1); jQuery(elt1).css('z-index',highest_index); }; // return the real type of the object var toType = function( obj ) { // by Angus Croll - http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/ return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() }; // return true if current jQuery version match the minimum required function jQueryMinVersion( version ) { var $vrs = window.jQuery.fn.jquery.split('.'), min = version.split('.'); for (var i=0, len=$vrs.length; i" )[ 0 ], // colors = jQuery.Color.names colors, // local aliases of functions called often each = jQuery.each; // determine rgba support immediately supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; // define cache name and alpha properties // for rgba and hsla spaces each( spaces, function( spaceName, space ) { space.cache = "_" + spaceName; space.props.alpha = { idx: 3, type: "percent", def: 1 }; }); function clamp( value, prop, allowEmpty ) { var type = propTypes[ prop.type ] || {}; if ( value == null ) { return (allowEmpty || !prop.def) ? null : prop.def; } // ~~ is an short way of doing floor for positive numbers value = type.floor ? ~~value : parseFloat( value ); // IE will pass in empty strings as value for alpha, // which will hit this case if ( isNaN( value ) ) { return prop.def; } if ( type.mod ) { // we add mod before modding to make sure that negatives values // get converted properly: -10 -> 350 return (value + type.mod) % type.mod; } // for now all property types without mod have min and max return 0 > value ? 0 : type.max < value ? type.max : value; } function stringParse( string ) { var inst = color(), rgba = inst._rgba = []; string = string.toLowerCase(); each( stringParsers, function( i, parser ) { var parsed, match = parser.re.exec( string ), values = match && parser.parse( match ), spaceName = parser.space || "rgba"; if ( values ) { parsed = inst[ spaceName ]( values ); // if this was an rgba parse the assignment might happen twice // oh well.... inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; rgba = inst._rgba = parsed._rgba; // exit each( stringParsers ) here because we matched return false; } }); // Found a stringParser that handled it if ( rgba.length ) { // if this came from a parsed string, force "transparent" when alpha is 0 // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) if ( rgba.join() === "0,0,0,0" ) { jQuery.extend( rgba, colors.transparent ); } return inst; } // named colors return colors[ string ]; } color.fn = jQuery.extend( color.prototype, { parse: function( red, green, blue, alpha ) { if ( red === undefined ) { this._rgba = [ null, null, null, null ]; return this; } if ( red.jquery || red.nodeType ) { red = jQuery( red ).css( green ); green = undefined; } var inst = this, type = jQuery.type( red ), rgba = this._rgba = []; // more than 1 argument specified - assume ( red, green, blue, alpha ) if ( green !== undefined ) { red = [ red, green, blue, alpha ]; type = "array"; } if ( type === "string" ) { return this.parse( stringParse( red ) || colors._default ); } if ( type === "array" ) { each( spaces.rgba.props, function( key, prop ) { rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); }); return this; } if ( type === "object" ) { if ( red instanceof color ) { each( spaces, function( spaceName, space ) { if ( red[ space.cache ] ) { inst[ space.cache ] = red[ space.cache ].slice(); } }); } else { each( spaces, function( spaceName, space ) { var cache = space.cache; each( space.props, function( key, prop ) { // if the cache doesn't exist, and we know how to convert if ( !inst[ cache ] && space.to ) { // if the value was null, we don't need to copy it // if the key was alpha, we don't need to copy it either if ( key === "alpha" || red[ key ] == null ) { return; } inst[ cache ] = space.to( inst._rgba ); } // this is the only case where we allow nulls for ALL properties. // call clamp with alwaysAllowEmpty inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); }); // everything defined but alpha? if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { // use the default of 1 inst[ cache ][ 3 ] = 1; if ( space.from ) { inst._rgba = space.from( inst[ cache ] ); } } }); } return this; } }, is: function( compare ) { var is = color( compare ), same = true, inst = this; each( spaces, function( _, space ) { var localCache, isCache = is[ space.cache ]; if (isCache) { localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; each( space.props, function( _, prop ) { if ( isCache[ prop.idx ] != null ) { same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); return same; } }); } return same; }); return same; }, _space: function() { var used = [], inst = this; each( spaces, function( spaceName, space ) { if ( inst[ space.cache ] ) { used.push( spaceName ); } }); return used.pop(); }, transition: function( other, distance ) { var end = color( other ), spaceName = end._space(), space = spaces[ spaceName ], startColor = this.alpha() === 0 ? color( "transparent" ) : this, start = startColor[ space.cache ] || space.to( startColor._rgba ), result = start.slice(); end = end[ space.cache ]; each( space.props, function( key, prop ) { var index = prop.idx, startValue = start[ index ], endValue = end[ index ], type = propTypes[ prop.type ] || {}; // if null, don't override start value if ( endValue === null ) { return; } // if null - use end if ( startValue === null ) { result[ index ] = endValue; } else { if ( type.mod ) { if ( endValue - startValue > type.mod / 2 ) { startValue += type.mod; } else if ( startValue - endValue > type.mod / 2 ) { startValue -= type.mod; } } result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); } }); return this[ spaceName ]( result ); }, blend: function( opaque ) { // if we are already opaque - return ourself if ( this._rgba[ 3 ] === 1 ) { return this; } var rgb = this._rgba.slice(), a = rgb.pop(), blend = color( opaque )._rgba; return color( jQuery.map( rgb, function( v, i ) { return ( 1 - a ) * blend[ i ] + a * v; })); }, toRgbaString: function() { var prefix = "rgba(", rgba = jQuery.map( this._rgba, function( v, i ) { return v == null ? ( i > 2 ? 1 : 0 ) : v; }); if ( rgba[ 3 ] === 1 ) { rgba.pop(); prefix = "rgb("; } return prefix + rgba.join() + ")"; }, toHslaString: function() { var prefix = "hsla(", hsla = jQuery.map( this.hsla(), function( v, i ) { if ( v == null ) { v = i > 2 ? 1 : 0; } // catch 1 and 2 if ( i && i < 3 ) { v = Math.round( v * 100 ) + "%"; } return v; }); if ( hsla[ 3 ] === 1 ) { hsla.pop(); prefix = "hsl("; } return prefix + hsla.join() + ")"; }, toHexString: function( includeAlpha ) { var rgba = this._rgba.slice(), alpha = rgba.pop(); if ( includeAlpha ) { rgba.push( ~~( alpha * 255 ) ); } return "#" + jQuery.map( rgba, function( v ) { // default to 0 when nulls exist v = ( v || 0 ).toString( 16 ); return v.length === 1 ? "0" + v : v; }).join(""); }, toString: function() { return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); } }); color.fn.parse.prototype = color.fn; // hsla conversions adapted from: // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 function hue2rgb( p, q, h ) { h = ( h + 1 ) % 1; if ( h * 6 < 1 ) { return p + (q - p) * h * 6; } if ( h * 2 < 1) { return q; } if ( h * 3 < 2 ) { return p + (q - p) * ((2/3) - h) * 6; } return p; } spaces.hsla.to = function ( rgba ) { if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { return [ null, null, null, rgba[ 3 ] ]; } var r = rgba[ 0 ] / 255, g = rgba[ 1 ] / 255, b = rgba[ 2 ] / 255, a = rgba[ 3 ], max = Math.max( r, g, b ), min = Math.min( r, g, b ), diff = max - min, add = max + min, l = add * 0.5, h, s; if ( min === max ) { h = 0; } else if ( r === max ) { h = ( 60 * ( g - b ) / diff ) + 360; } else if ( g === max ) { h = ( 60 * ( b - r ) / diff ) + 120; } else { h = ( 60 * ( r - g ) / diff ) + 240; } // chroma (diff) == 0 means greyscale which, by definition, saturation = 0% // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) if ( diff === 0 ) { s = 0; } else if ( l <= 0.5 ) { s = diff / add; } else { s = diff / ( 2 - add ); } return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; }; spaces.hsla.from = function ( hsla ) { if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { return [ null, null, null, hsla[ 3 ] ]; } var h = hsla[ 0 ] / 360, s = hsla[ 1 ], l = hsla[ 2 ], a = hsla[ 3 ], q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, p = 2 * l - q; return [ Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), Math.round( hue2rgb( p, q, h ) * 255 ), Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), a ]; }; each( spaces, function( spaceName, space ) { var props = space.props, cache = space.cache, to = space.to, from = space.from; // makes rgba() and hsla() color.fn[ spaceName ] = function( value ) { // generate a cache for this space if it doesn't exist if ( to && !this[ cache ] ) { this[ cache ] = to( this._rgba ); } if ( value === undefined ) { return this[ cache ].slice(); } var ret, type = jQuery.type( value ), arr = ( type === "array" || type === "object" ) ? value : arguments, local = this[ cache ].slice(); each( props, function( key, prop ) { var val = arr[ type === "object" ? key : prop.idx ]; if ( val == null ) { val = local[ prop.idx ]; } local[ prop.idx ] = clamp( val, prop ); }); if ( from ) { ret = color( from( local ) ); ret[ cache ] = local; return ret; } else { return color( local ); } }; // makes red() green() blue() alpha() hue() saturation() lightness() each( props, function( key, prop ) { // alpha is included in more than one space if ( color.fn[ key ] ) { return; } color.fn[ key ] = function( value ) { var vtype = jQuery.type( value ), fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), local = this[ fn ](), cur = local[ prop.idx ], match; if ( vtype === "undefined" ) { return cur; } if ( vtype === "function" ) { value = value.call( this, cur ); vtype = jQuery.type( value ); } if ( value == null && prop.empty ) { return this; } if ( vtype === "string" ) { match = rplusequals.exec( value ); if ( match ) { value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); } } local[ prop.idx ] = value; return this[ fn ]( local ); }; }); }); // add cssHook and .fx.step function for each named hook. // accept a space separated string of properties color.hook = function( hook ) { var hooks = hook.split( " " ); each( hooks, function( i, hook ) { jQuery.cssHooks[ hook ] = { set: function( elem, value ) { var parsed, curElem, backgroundColor = ""; if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) { value = color( parsed || value ); if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { curElem = hook === "backgroundColor" ? elem.parentNode : elem; while ( (backgroundColor === "" || backgroundColor === "transparent") && curElem && curElem.style ) { try { backgroundColor = jQuery.css( curElem, "backgroundColor" ); curElem = curElem.parentNode; } catch ( e ) { } } value = value.blend( backgroundColor && backgroundColor !== "transparent" ? backgroundColor : "_default" ); } value = value.toRgbaString(); } try { elem.style[ hook ] = value; } catch( e ) { // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' } } }; jQuery.fx.step[ hook ] = function( fx ) { if ( !fx.colorInit ) { fx.start = color( fx.elem, hook ); fx.end = color( fx.end ); fx.colorInit = true; } jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); }; }); }; color.hook( stepHooks ); jQuery.cssHooks.borderColor = { expand: function( value ) { var expanded = {}; each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { expanded[ "border" + part + "Color" ] = value; }); return expanded; } }; // Basic color names only. // Usage of any of the other color names requires adding yourself or including // jquery.color.svg-names.js. colors = jQuery.Color.names = { // 4.1. Basic color keywords aqua: "#00ffff", black: "#000000", blue: "#0000ff", fuchsia: "#ff00ff", gray: "#808080", green: "#008000", lime: "#00ff00", maroon: "#800000", navy: "#000080", olive: "#808000", purple: "#800080", red: "#ff0000", silver: "#c0c0c0", teal: "#008080", white: "#ffffff", yellow: "#ffff00", // 4.2.3. "transparent" color keyword transparent: [ null, null, null, 0 ], _default: "#ffffff" }; })( jQuery ); // ######################################################################################################### // ##### imagesLoaded // ##### // ##### rename 'imagesLoaded' to 'ngimagesLoaded' // ##### rename 'ImagesLoaded' to 'ngImagesLoaded' // ##### rename 'EvEmitter' to 'ngEvEmitter' // ######################################################################################################### /*! * imagesLoaded PACKAGED v4.1.0 * JavaScript is all like "You images are done yet or what?" * MIT License */ /** * ngEvEmitter v1.0.1 * Lil' event emitter * MIT License */ /* jshint unused: true, undef: true, strict: true */ ( function( global, factory ) { // universal module definition /* jshint strict: false */ /* globals define, module */ if ( typeof define == 'function' && define.amd ) { // AMD - RequireJS define( 'ev-emitter/ev-emitter',factory ); } else if ( typeof module == 'object' && module.exports ) { // CommonJS - Browserify, Webpack module.exports = factory(); } else { // Browser globals global.ngEvEmitter = factory(); } }( this, function() { function ngEvEmitter() {} var proto = ngEvEmitter.prototype; proto.on = function( eventName, listener ) { if ( !eventName || !listener ) { return; } // set events hash var events = this._events = this._events || {}; // set listeners array var listeners = events[ eventName ] = events[ eventName ] || []; // only add once if ( listeners.indexOf( listener ) == -1 ) { listeners.push( listener ); } return this; }; proto.once = function( eventName, listener ) { if ( !eventName || !listener ) { return; } // add event this.on( eventName, listener ); // set once flag // set onceEvents hash var onceEvents = this._onceEvents = this._onceEvents || {}; // set onceListeners array var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || []; // set flag onceListeners[ listener ] = true; return this; }; proto.off = function( eventName, listener ) { var listeners = this._events && this._events[ eventName ]; if ( !listeners || !listeners.length ) { return; } var index = listeners.indexOf( listener ); if ( index != -1 ) { listeners.splice( index, 1 ); } return this; }; proto.emitEvent = function( eventName, args ) { var listeners = this._events && this._events[ eventName ]; if ( !listeners || !listeners.length ) { return; } var i = 0; var listener = listeners[i]; args = args || []; // once stuff var onceListeners = this._onceEvents && this._onceEvents[ eventName ]; while ( listener ) { var isOnce = onceListeners && onceListeners[ listener ]; if ( isOnce ) { // remove listener // remove before trigger to prevent recursion this.off( eventName, listener ); // unset once flag delete onceListeners[ listener ]; } // trigger listener listener.apply( this, args ); // get next listener i += isOnce ? 0 : 1; listener = listeners[i]; } return this; }; return ngEvEmitter; })); /*! * imagesLoaded v4.1.0 * JavaScript is all like "You images are done yet or what?" * MIT License */ ( function( window, factory ) { 'use strict'; // universal module definition /*global define: false, module: false, require: false */ if ( typeof define == 'function' && define.amd ) { // AMD define( [ 'ev-emitter/ev-emitter' ], function( ngEvEmitter ) { return factory( window, ngEvEmitter ); }); } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( window, require('ev-emitter') ); } else { // browser global window.ngimagesLoaded = factory( window, window.ngEvEmitter ); } })( window, // -------------------------- factory -------------------------- // function factory( window, ngEvEmitter ) { var $ = window.jQuery; var console = window.console; // -------------------------- helpers -------------------------- // // extend objects function extend( a, b ) { for ( var prop in b ) { a[ prop ] = b[ prop ]; } return a; } // turn element or nodeList into an array function makeArray( obj ) { var ary = []; if ( Array.isArray( obj ) ) { // use object if already an array ary = obj; } else if ( typeof obj.length == 'number' ) { // convert nodeList to array for ( var i=0; i < obj.length; i++ ) { ary.push( obj[i] ); } } else { // array of single index ary.push( obj ); } return ary; } // -------------------------- imagesLoaded -------------------------- // /** * @param {Array, Element, NodeList, String} elem * @param {Object or Function} options - if function, use as callback * @param {Function} onAlways - callback function */ function ngImagesLoaded( elem, options, onAlways ) { // coerce ngImagesLoaded() without new, to be new ngImagesLoaded() if ( !( this instanceof ngImagesLoaded ) ) { return new ngImagesLoaded( elem, options, onAlways ); } // use elem as selector string if ( typeof elem == 'string' ) { elem = document.querySelectorAll( elem ); } this.elements = makeArray( elem ); this.options = extend( {}, this.options ); if ( typeof options == 'function' ) { onAlways = options; } else { extend( this.options, options ); } if ( onAlways ) { this.on( 'always', onAlways ); } this.getImages(); if ( $ ) { // add jQuery Deferred object this.jqDeferred = new $.Deferred(); } // HACK check async to allow time to bind listeners setTimeout( function() { this.check(); }.bind( this )); } ngImagesLoaded.prototype = Object.create( ngEvEmitter.prototype ); ngImagesLoaded.prototype.options = {}; ngImagesLoaded.prototype.getImages = function() { this.images = []; // filter & find items if we have an item selector this.elements.forEach( this.addElementImages, this ); }; /** * @param {Node} element */ ngImagesLoaded.prototype.addElementImages = function( elem ) { // filter siblings if ( elem.nodeName == 'IMG' ) { this.addImage( elem ); } // get background image on element if ( this.options.background === true ) { this.addElementBackgroundImages( elem ); } // find children // no non-element nodes, #143 var nodeType = elem.nodeType; if ( !nodeType || !elementNodeTypes[ nodeType ] ) { return; } var childImgs = elem.querySelectorAll('img'); // concat childElems to filterFound array for ( var i=0; i < childImgs.length; i++ ) { var img = childImgs[i]; this.addImage( img ); } // get child background images if ( typeof this.options.background == 'string' ) { var children = elem.querySelectorAll( this.options.background ); for ( i=0; i < children.length; i++ ) { var child = children[i]; this.addElementBackgroundImages( child ); } } }; var elementNodeTypes = { 1: true, 9: true, 11: true }; ngImagesLoaded.prototype.addElementBackgroundImages = function( elem ) { var style = getComputedStyle( elem ); if ( !style ) { // Firefox returns null if in a hidden iframe https://bugzil.la/548397 return; } // get url inside url("...") var reURL = /url\((['"])?(.*?)\1\)/gi; var matches = reURL.exec( style.backgroundImage ); while ( matches !== null ) { var url = matches && matches[2]; if ( url ) { this.addBackground( url, elem ); } matches = reURL.exec( style.backgroundImage ); } }; /** * @param {Image} img */ ngImagesLoaded.prototype.addImage = function( img ) { var loadingImage = new LoadingImage( img ); this.images.push( loadingImage ); }; ngImagesLoaded.prototype.addBackground = function( url, elem ) { var background = new Background( url, elem ); this.images.push( background ); }; ngImagesLoaded.prototype.check = function() { var _this = this; this.progressedCount = 0; this.hasAnyBroken = false; // complete if no images if ( !this.images.length ) { this.complete(); return; } function onProgress( image, elem, message ) { // HACK - Chrome triggers event before object properties have changed. #83 setTimeout( function() { _this.progress( image, elem, message ); }); } this.images.forEach( function( loadingImage ) { loadingImage.once( 'progress', onProgress ); loadingImage.check(); }); }; ngImagesLoaded.prototype.progress = function( image, elem, message ) { this.progressedCount++; this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded; // progress event this.emitEvent( 'progress', [ this, image, elem ] ); if ( this.jqDeferred && this.jqDeferred.notify ) { this.jqDeferred.notify( this, image ); } // check if completed if ( this.progressedCount == this.images.length ) { this.complete(); } if ( this.options.debug && console ) { console.log( 'progress: ' + message, image, elem ); } }; ngImagesLoaded.prototype.complete = function() { var eventName = this.hasAnyBroken ? 'fail' : 'done'; this.isComplete = true; this.emitEvent( eventName, [ this ] ); this.emitEvent( 'always', [ this ] ); if ( this.jqDeferred ) { var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve'; this.jqDeferred[ jqMethod ]( this ); } }; // -------------------------- -------------------------- // function LoadingImage( img ) { this.img = img; } LoadingImage.prototype = Object.create( ngEvEmitter.prototype ); LoadingImage.prototype.check = function() { // If complete is true and browser supports natural sizes, // try to check for image status manually. var isComplete = this.getIsImageComplete(); if ( isComplete ) { // report based on naturalWidth this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); return; } // If none of the checks above matched, simulate loading on detached element. this.proxyImage = new Image(); this.proxyImage.addEventListener( 'load', this ); this.proxyImage.addEventListener( 'error', this ); // bind to image as well for Firefox. #191 this.img.addEventListener( 'load', this ); this.img.addEventListener( 'error', this ); this.proxyImage.src = this.img.src; }; LoadingImage.prototype.getIsImageComplete = function() { return this.img.complete && this.img.naturalWidth !== undefined; }; LoadingImage.prototype.confirm = function( isLoaded, message ) { this.isLoaded = isLoaded; this.emitEvent( 'progress', [ this, this.img, message ] ); }; // ----- events ----- // // trigger specified handler for event type LoadingImage.prototype.handleEvent = function( event ) { var method = 'on' + event.type; if ( this[ method ] ) { this[ method ]( event ); } }; LoadingImage.prototype.onload = function() { this.confirm( true, 'onload' ); this.unbindEvents(); }; LoadingImage.prototype.onerror = function() { this.confirm( false, 'onerror' ); this.unbindEvents(); }; LoadingImage.prototype.unbindEvents = function() { this.proxyImage.removeEventListener( 'load', this ); this.proxyImage.removeEventListener( 'error', this ); this.img.removeEventListener( 'load', this ); this.img.removeEventListener( 'error', this ); }; // -------------------------- Background -------------------------- // function Background( url, element ) { this.url = url; this.element = element; this.img = new Image(); } // inherit LoadingImage prototype Background.prototype = Object.create( LoadingImage.prototype ); Background.prototype.check = function() { this.img.addEventListener( 'load', this ); this.img.addEventListener( 'error', this ); this.img.src = this.url; // check if image is already complete var isComplete = this.getIsImageComplete(); if ( isComplete ) { this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); this.unbindEvents(); } }; Background.prototype.unbindEvents = function() { this.img.removeEventListener( 'load', this ); this.img.removeEventListener( 'error', this ); }; Background.prototype.confirm = function( isLoaded, message ) { this.isLoaded = isLoaded; this.emitEvent( 'progress', [ this, this.element, message ] ); }; // -------------------------- jQuery -------------------------- // ngImagesLoaded.makeJQueryPlugin = function( jQuery ) { jQuery = jQuery || window.jQuery; if ( !jQuery ) { return; } // set local variable $ = jQuery; // $().ngimagesLoaded() $.fn.ngimagesLoaded = function( options, callback ) { var instance = new ngImagesLoaded( this, options, callback ); return instance.jqDeferred.promise( $(this) ); }; }; // try making plugin ngImagesLoaded.makeJQueryPlugin(); // -------------------------- -------------------------- // return ngImagesLoaded; }); // ######################################################################################################### // ##### imagesLoaded - end // ######################################################################################################### // ######################################################################################################### // ##### screenfull // ##### // ##### rename 'screenfull' to 'ngscreenfull' // ######################################################################################################### // screenfull.js // v1.1.0 // by sindresorhus - https://github.com/sindresorhus // from: https://github.com/sindresorhus/screenfull.js (function () { 'use strict'; var isCommonjs = typeof module !== 'undefined' && module.exports; var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element; var fn = (function () { var val; var valLength; var fnMap = [ [ 'requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror' ], // new WebKit [ 'webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror' ], // old WebKit (Safari 5.1) [ 'webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror' ], [ 'mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror' ], [ 'msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError' ] ]; var i = 0; var l = fnMap.length; var ret = {}; for (; i < l; i++) { val = fnMap[i]; if (val && val[1] in document) { for (i = 0, valLength = val.length; i < valLength; i++) { ret[fnMap[0][i]] = val[i]; } return ret; } } return false; })(); var ngscreenfull = { request: function (elem) { var request = fn.requestFullscreen; elem = elem || document.documentElement; // Work around Safari 5.1 bug: reports support for // keyboard in fullscreen even though it doesn't. // Browser sniffing, since the alternative with // setTimeout is even worse. if (/5\.1[\.\d]* Safari/.test(navigator.userAgent)) { elem[request](); } else { elem[request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT); } }, exit: function () { document[fn.exitFullscreen](); }, toggle: function (elem) { if (this.isFullscreen) { this.exit(); } else { this.request(elem); } }, onchange: function () {}, onerror: function () {}, raw: fn }; if (!fn) { if (isCommonjs) { module.exports = false; } else { window.ngscreenfull = false; } return; } Object.defineProperties(ngscreenfull, { isFullscreen: { get: function () { return !!document[fn.fullscreenElement]; } }, element: { enumerable: true, get: function () { return document[fn.fullscreenElement]; } }, enabled: { enumerable: true, get: function () { // Coerce to boolean in case of old WebKit return !!document[fn.fullscreenEnabled]; } } }); document.addEventListener(fn.fullscreenchange, function (e) { ngscreenfull.onchange.call(ngscreenfull, e); }); document.addEventListener(fn.fullscreenerror, function (e) { ngscreenfull.onerror.call(ngscreenfull, e); }); if (isCommonjs) { module.exports = ngscreenfull; } else { window.ngscreenfull = ngscreenfull; } })(); // ######################################################################################################### // ##### screenfull - end // #########################################################################################################