File "justifiedGallery.min.js"
Full Path: /home/ycoalition/public_html/blog/wp-content/themes/woodmart/js/libs/justifiedGallery.min.js
File size: 9.78 KB
MIME-type: text/plain
Charset: utf-8
!function(j){j.fn.justifiedGallery=function(c){var p={sizeRangeSuffixes:{lt100:"",lt240:"",lt320:"",lt500:"",lt640:"",lt1024:""},rowHeight:120,maxRowHeight:0,margins:1,border:-1,lastRow:"nojustify",justifyThreshold:.75,fixedHeight:!1,waitThumbnailsLoad:!0,captions:!0,cssAnimation:!1,imagesAnimationDuration:500,captionSettings:{animationDuration:500,visibleOpacity:.7,nonVisibleOpacity:0},rel:null,target:null,extension:/\.[^.\\/]+$/,refreshTime:100,randomize:!1};function f(t,i,e,n){var a,s,o=t.match(n.settings.extension),o=null!=o?o[0]:"",t=t.replace(n.settings.extension,"");return a=function(t,i){var e,n,a=!1;for(e in i.settings.sizeRangeSuffixes)if(0===i.settings.sizeRangeSuffixes[e].length)a=!0;else if(n=i.settings.sizeRangeSuffixes[e],-1!==t.indexOf(n,t.length-n.length))return i.settings.sizeRangeSuffixes[e];if(a)return"";throw"unknown suffix for "+t}(s=t,n),t=s.substring(0,s.length-a.length),t+=(s=n,((n=(a=e)<(n=i)?n:a)<=100?s.settings.sizeRangeSuffixes.lt100:n<=240?s.settings.sizeRangeSuffixes.lt240:n<=320?s.settings.sizeRangeSuffixes.lt320:n<=500?s.settings.sizeRangeSuffixes.lt500:n<=640?s.settings.sizeRangeSuffixes.lt640:s.settings.sizeRangeSuffixes.lt1024)+o)}function u(t){var i=j(t.currentTarget).find(".caption");t.data.settings.cssAnimation?i.addClass("caption-visible").removeClass("caption-hidden"):i.stop().fadeTo(t.data.settings.captionSettings.animationDuration,t.data.settings.captionSettings.visibleOpacity)}function h(t){var i=j(t.currentTarget).find(".caption");t.data.settings.cssAnimation?i.removeClass("caption-visible").removeClass("caption-hidden"):i.stop().fadeTo(t.data.settings.captionSettings.animationDuration,t.data.settings.captionSettings.nonVisibleOpacity)}function m(t,i,e){e.settings.cssAnimation?(t.addClass("entry-visible"),i()):t.stop().fadeTo(e.settings.imagesAnimationDuration,1,i)}function w(t){var i=t.find("> img");return i=0===i.length?t.find("> a > img"):i}function b(t){t.lastAnalyzedIndex=-1,t.buildingRow.entriesBuff=[],t.buildingRow.aspectRatio=0,t.buildingRow.width=0,t.offY=t.border}function d(t,i){var e,n,a=t.settings,s=t.border,o=function(t,i){var e,n,a,s,o,r=t.settings,g=!0,l=0,d=t.galleryWidth-2*t.border-(t.buildingRow.entriesBuff.length-1)*r.margins,f=d/t.buildingRow.aspectRatio,u=t.buildingRow.width/d>r.justifyThreshold;if(i&&"hide"===r.lastRow&&!u){for(e=0;e<t.buildingRow.entriesBuff.length;e++)n=t.buildingRow.entriesBuff[e],r.cssAnimation?n.removeClass("entry-visible"):n.stop().fadeTo(0,0);return-1}for(i&&!u&&"nojustify"===r.lastRow&&(g=!1),e=0;e<t.buildingRow.entriesBuff.length;e++)o=(a=w(t.buildingRow.entriesBuff[e])).data("jg.imgw")/a.data("jg.imgh"),o=g?(s=e===t.buildingRow.entriesBuff.length-1?d:f*o,f):(s=r.rowHeight*o,r.rowHeight),d-=Math.round(s),a.data("jg.jimgw",Math.round(s)),a.data("jg.jimgh",Math.ceil(o)),(0===e||o<l)&&(l=o);return{minHeight:l=r.fixedHeight&&l>r.rowHeight?r.rowHeight:l,justify:g}}(t,i),r=o.minHeight;if(i&&"hide"===a.lastRow&&-1===r)return t.buildingRow.entriesBuff=[],t.buildingRow.aspectRatio=0,void(t.buildingRow.width=0);0<a.maxRowHeight&&a.maxRowHeight<r?r=a.maxRowHeight:0===a.maxRowHeight&&1.5*a.rowHeight<r&&(r=1.5*a.rowHeight);for(var g=0;g<t.buildingRow.entriesBuff.length;g++)n=w(e=t.buildingRow.entriesBuff[g]),function(t,i,e,n,a,s,o){var r=w(t),g=(r.css("width",n),r.css("height",a),r.css("margin-left",-n/2),r.css("margin-top",-a/2),t.width(n),t.height(s),t.css("top",e),t.css("left",i),r.attr("src")),l=f(g,n,a,o);function d(){g!==l&&r.attr("src",l)}r.one("error",function(){r.attr("src",r.data("jg.originalSrc"))}),"skipped"===r.data("jg.loaded")?R(g,function(){m(t,d,o),r.data("jg.loaded",!0)}):m(t,d,o),s=t.data("jg.captionMouseEvents"),!0===o.settings.captions?(0===(e=t.find(".caption")).length&&void 0!==(i=void 0===(i=r.attr("alt"))?t.attr("title"):i)&&(e=j('<div class="caption">'+i+"</div>"),t.append(e)),0!==e.length&&(o.settings.cssAnimation||e.stop().fadeTo(o.settings.imagesAnimationDuration,o.settings.captionSettings.nonVisibleOpacity),void 0===s&&(t.on("mouseenter",void 0,o,(s={mouseenter:u,mouseleave:h}).mouseenter),t.on("mouseleave",void 0,o,s.mouseleave),t.data("jg.captionMouseEvents",s)))):void 0!==s&&(t.off("mouseenter",void 0,o,s.mouseenter),t.off("mouseleave",void 0,o,s.mouseleave),t.removeData("jg.captionMouseEvents"))}(e,s,t.offY,n.data("jg.jimgw"),n.data("jg.jimgh"),r,t),s+=n.data("jg.jimgw")+a.margins;t.$gallery.height(t.offY+r+t.border+(t.spinner.active?t.spinner.$el.innerHeight():0)),(!i||r<=t.settings.rowHeight&&o.justify)&&(t.offY+=r+t.settings.margins,t.buildingRow.entriesBuff=[],t.buildingRow.aspectRatio=0,t.buildingRow.width=0,t.$gallery.trigger("jg.rowflush"))}function v(t){t.yield.flushed=0,null!==t.imgAnalyzerTimeout&&clearTimeout(t.imgAnalyzerTimeout)}function y(t,i){v(t),t.imgAnalyzerTimeout=setTimeout(function(){e(t,i)},.001),e(t,i)}function e(t,i){for(var e,n=t.settings,a=t.lastAnalyzedIndex+1;a<t.entries.length;a++){var s=j(t.entries[a]),o=w(s);if(!0===o.data("jg.loaded")||"skipped"===o.data("jg.loaded")){var r=a>=t.entries.length-1,g=t.galleryWidth-2*t.border-(t.buildingRow.entriesBuff.length-1)*n.margins,l=o.data("jg.imgw")/o.data("jg.imgh");if(g/(t.buildingRow.aspectRatio+l)<n.rowHeight&&(d(t,r),++t.yield.flushed>=t.yield.every))return void y(t,i);t.buildingRow.entriesBuff.push(s),t.buildingRow.aspectRatio+=l,t.buildingRow.width+=l*n.rowHeight,t.lastAnalyzedIndex=a}else if("error"!==o.data("jg.loaded"))return}0<t.buildingRow.entriesBuff.length&&d(t,!0),t.spinner.active&&(t.spinner.active=!1,t.$gallery.height(t.$gallery.height()-t.spinner.$el.innerHeight()),t.spinner.$el.detach(),e=t.spinner,clearInterval(e.intervalId),e.intervalId=null),v(t),i?t.$gallery.trigger("jg.resize"):t.$gallery.trigger("jg.complete")}function R(t,i,e){var n,a;(i||e)&&(n=new Image,a=j(n),i&&a.one("load",function(){a.off("load error"),i(n)}),e&&a.one("error",function(){a.off("load error"),e(n)}),n.src=t)}return this.each(function(t,i){var e,o,r,n,g=j(i);if(g.addClass("justified-gallery"),void 0===(l=g.data("jg.context"))){if(null!=c&&"object"!=typeof c)throw"The argument must be an object";var i=j('<div class="spinner"><span></span><span></span><span></span></div>'),a=j.extend({},p,c),s=0<=a.border?a.border:a.margins,l={settings:a,imgAnalyzerTimeout:null,entries:null,buildingRow:{entriesBuff:[],width:0,aspectRatio:0},lastAnalyzedIndex:-1,yield:{every:2,flushed:0},border:s,offY:s,spinner:{active:!1,phase:0,timeslot:150,$el:i,$points:i.find("span"),intervalId:null},checkWidthIntervalId:null,galleryWidth:g.width(),$gallery:g};g.data("jg.context",l)}else if("norewind"===c)for(var d=0;d<l.buildingRow.entriesBuff.length;d++)e=l.buildingRow.entriesBuff[d],l.settings.cssAnimation?e.removeClass("entry-visible"):e.stop().fadeTo(0,0);else l.settings=j.extend({},l.settings,c),l.border=0<=l.settings.border?l.settings.border:l.settings.margins,b(l);var f=l.settings;function u(t){if("string"!=typeof f.sizeRangeSuffixes[t])throw"sizeRangeSuffixes."+t+" must be a string"}function h(t,i){if("string"==typeof t[i]){if(t[i]=parseFloat(t[i],10),isNaN(t[i]))throw"invalid number for "+i}else{if("number"!=typeof t[i])throw i+" must be a number";if(isNaN(t[i]))throw"invalid number for "+i}}if("object"!=typeof f.sizeRangeSuffixes)throw"sizeRangeSuffixes must be defined and must be an object";if(u("lt100"),u("lt240"),u("lt320"),u("lt500"),u("lt640"),u("lt1024"),h(f,"rowHeight"),h(f,"maxRowHeight"),0<f.maxRowHeight&&f.maxRowHeight<f.rowHeight&&(f.maxRowHeight=f.rowHeight),h(f,"margins"),h(f,"border"),"nojustify"!==f.lastRow&&"justify"!==f.lastRow&&"hide"!==f.lastRow)throw'lastRow must be "nojustify", "justify" or "hide"';if(h(f,"justifyThreshold"),f.justifyThreshold<0||1<f.justifyThreshold)throw"justifyThreshold must be in the interval [0,1]";if("boolean"!=typeof f.cssAnimation)throw"cssAnimation must be a boolean";if(h(f.captionSettings,"animationDuration"),h(f,"imagesAnimationDuration"),h(f.captionSettings,"visibleOpacity"),f.captionSettings.visibleOpacity<0||1<f.captionSettings.visibleOpacity)throw"captionSettings.visibleOpacity must be in the interval [0, 1]";if(h(f.captionSettings,"nonVisibleOpacity"),f.captionSettings.visibleOpacity<0||1<f.captionSettings.visibleOpacity)throw"captionSettings.nonVisibleOpacity must be in the interval [0, 1]";if("boolean"!=typeof f.fixedHeight)throw"fixedHeight must be a boolean";if("boolean"!=typeof f.captions)throw"captions must be a boolean";if(h(f,"refreshTime"),"boolean"!=typeof f.randomize)throw"randomize must be a boolean";l.entries=g.find("> a, > div:not(.spinner)").toArray(),0!==l.entries.length&&(l.settings.randomize&&(l.entries.sort(function(){return 2*Math.random()-1}),j.each(l.entries,function(){j(this).appendTo(g)})),r=o=!1,j.each(l.entries,function(t,i){var e,i=j(i),n=w(i);if(i.addClass("jg-entry"),!0!==n.data("jg.loaded")&&"skipped"!==n.data("jg.loaded")){null!==l.settings.rel&&i.attr("rel",l.settings.rel),null!==l.settings.target&&i.attr("target",l.settings.target);var i=void 0!==n.data("safe-src")?n.data("safe-src"):n.attr("src"),a=(n.data("jg.originalSrc",i),n.attr("src",i),parseInt(n.attr("width"),10)),s=parseInt(n.attr("height"),10);if(!0!==l.settings.waitThumbnailsLoad&&!isNaN(a)&&!isNaN(s))return n.data("jg.imgw",a),n.data("jg.imgh",s),n.data("jg.loaded","skipped"),y(l,!(r=!0)),!0;n.data("jg.loaded",!1),!(o=!0)===l.spinner.active&&(l.spinner.active=!0,g.append(l.spinner.$el),g.height(l.offY+l.spinner.$el.innerHeight()),e=l.spinner,clearInterval(e.intervalId),e.intervalId=setInterval(function(){e.phase<e.$points.length?e.$points.eq(e.phase).fadeTo(e.timeslot,1):e.$points.eq(e.phase-e.$points.length).fadeTo(e.timeslot,0),e.phase=(e.phase+1)%(2*e.$points.length)},e.timeslot)),R(i,function(t){n.data("jg.imgw",t.width),n.data("jg.imgh",t.height),n.data("jg.loaded",!0),y(l,!1)},function(){n.data("jg.loaded","error"),y(l,!1)})}}),o||r||y(l,!1),(n=l).checkWidthIntervalId=setInterval(function(){var t=parseInt(n.$gallery.width(),10);n.galleryWidth!==t&&(n.galleryWidth=t,b(n),y(n,!0))},n.settings.refreshTime))})}}(jQuery);