|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/grandpre/Library/components/gallery/js/ |
Upload File : |
/*
* debouncedresize: special jQuery event that happens once after a window resize
*
* latest version and complete README available on Github:
* https://github.com/louisremi/jquery-smartresize/blob/master/jquery.debouncedresize.js
*
* Copyright 2011 @louis_remi
* Licensed under the MIT license.
*/
var $event=$.event,$special,resizeTimeout;$special=$event.special.debouncedresize={setup:function(){$(this).on("resize",$special.handler)},teardown:function(){$(this).off("resize",$special.handler)},handler:function(i,e){var t=this,n=arguments,s=function(){i.type="debouncedresize",$event.dispatch.apply(t,n)};resizeTimeout&&clearTimeout(resizeTimeout),e?s():resizeTimeout=setTimeout(s,$special.threshold)},threshold:250};var BLANK="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";$.fn.imagesLoaded=function(i){function e(){var e=$(h),t=$(d);s&&(d.length?s.reject(r,e,t):s.resolve(r)),$.isFunction(i)&&i.call(n,r,e,t)}function t(i,t){i.src!==BLANK&&-1===$.inArray(i,o)&&(o.push(i),t?d.push(i):h.push(i),$.data(i,"imagesLoaded",{isBroken:t,src:i.src}),a&&s.notifyWith($(i),[t,r,$(h),$(d)]),r.length===o.length&&(setTimeout(e),r.unbind(".imagesLoaded")))}var n=this,s=$.isFunction($.Deferred)?$.Deferred():0,a=$.isFunction(s.notify),r=n.find("img").add(n.filter("img")),o=[],h=[],d=[];return $.isPlainObject(i)&&$.each(i,function(e,t){"callback"===e?i=t:s&&s[e](t)}),r.length?r.bind("load.imagesLoaded error.imagesLoaded",function(i){t(i.target,"error"===i.type)}).each(function(i,e){var n=e.src,s=$.data(e,"imagesLoaded");return s&&s.src===n?void t(e,s.isBroken):e.complete&&void 0!==e.naturalWidth?void t(e,0===e.naturalWidth||0===e.naturalHeight):void((e.readyState||e.complete)&&(e.src=BLANK,e.src=n))}):e(),s?s.promise(n):n};var Grid=function(){function i(i){T=$.extend(!0,{},T,i),l.imagesLoaded(function(){t(!0),a(),n()})}function e(i){c=c.add(i),i.each(function(){var i=$(this);i.data({offsetTop:i.offset().top,height:i.height()})}),s(i)}function t(i){c.each(function(){var e=$(this);e.data("offsetTop",e.offset().top),i&&e.data("height",e.height())})}function n(){s(c),m.on("debouncedresize",function(){p=0,f=-1,t(),a();var i=$.data(this,"preview");"undefined"!=typeof i&&o()})}function s(i){i.on("click","span.gallery1-x",function(){return o(),!1}).children("a").on("click",function(){var i=$(this).parent();return g===i.index()?o():r(i),!1})}function a(){d={width:m.width(),height:m.height()}}function r(i){var e=$.data(this,"preview"),t=i.data("offsetTop");if(p=0,"undefined"!=typeof e){if(f===t)return e.update(i),!1;t>f&&(p=e.height),o()}f=t,e=$.data(this,"preview",new h(i)),e.open()}function o(){g=-1;var i=$.data(this,"preview");i.close(),$.removeData(this,"preview")}function h(i){this.$item=i,this.expandedIdx=this.$item.index(),this.create(),this.update()}var d,l=$("#gallery1-list"),c=l.children("li"),g=-1,f=-1,p=0,u=10,m=$(window),v=$("html, body"),w={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"MSTransitionEnd",transition:"transitionend"},y=w[Modernizr.prefixed("transition")],A=Modernizr.csstransitions,T={minHeight:500,speed:1000,easing:"ease"};return h.prototype={create:function(){this.$description=$("<div></div>"),this.$details=$('<div class="gallery1-list"></div>').append(this.$description),this.$loading=$('<div class="gallery1-loader"></div>'),this.$fullimage=$('<div class="gallery1-img-large"></div>').append(this.$loading),this.$closePreview=$('<span class="gallery1-x"></span>'),this.$previewInner=$('<div class="gallery1-inner"></div>').append(this.$closePreview,this.$fullimage,this.$details),this.$previewEl=$('<div class="gallery1-o"></div>').append(this.$previewInner),this.$item.append(this.getEl()),A&&this.setTransition()},update:function(i){if(i&&(this.$item=i),-1!==g){var e=c.eq(g);e.removeClass("gallery1-open"),this.$item.addClass("gallery1-open"),this.positionPreview()}g=this.$item.index();var t=this.$item.children("a"),n={largesrc:t.find("img").attr("src"),description:t.parent().find(".gallery1-content").html()};this.$description.html(n.description);var s=this;"undefined"!=typeof s.$largeImg&&s.$largeImg.remove(),s.$fullimage.is(":visible")&&(this.$loading.show(),$("<img/>").load(function(){var i=$(this);i.attr("src")===s.$item.children("a").data("largesrc")&&(s.$loading.hide(),s.$fullimage.find("img").remove(),s.$largeImg=i.fadeIn(1000),s.$fullimage.append(s.$largeImg))}).attr("src",n.largesrc))},open:function(){setTimeout($.proxy(function(){this.setHeights(),this.positionPreview()},this),25)},close:function(){var i=this,e=function(){A&&$(this).off(y),i.$item.removeClass("gallery1-open"),i.$previewEl.remove()};return setTimeout($.proxy(function(){"undefined"!=typeof this.$largeImg&&this.$largeImg.fadeOut("fast"),this.$previewEl.css("height",0);var i=c.eq(this.expandedIdx);i.css("height",i.data("height")).on(y,e),A||e.call()},this),25),!1},calcHeight:function(){var i=d.height-this.$item.data("height")-u,e=d.height;i<T.minHeight&&(i=T.minHeight,e=T.minHeight+this.$item.data("height")+u),this.height=i,this.itemHeight=e},setHeights:function(){var i=this,e=function(){A&&i.$item.off(y),i.$item.addClass("gallery1-open")};this.calcHeight(),this.$previewEl.css("height",this.height),this.$item.css("height",this.itemHeight).on(y,e),A||e.call()},positionPreview:function(){var i=this.$item.data("offsetTop"),e=this.$previewEl.offset().top-p,t=this.height+this.$item.data("height")+u<=d.height?i:this.height<d.height?e-(d.height-this.height):e;v.animate({scrollTop:t},T.speed)},setTransition:function(){this.$previewEl.css("transition","height "+T.speed+"ms "+T.easing),this.$item.css("transition","height "+T.speed+"ms "+T.easing)},getEl:function(){return this.$previewEl}},{init:i,addItems:e}}();