rate-it/public/js/jquery/colorbox/colorbox-rateit.min.js

7 lines
12 KiB
JavaScript

/*!
Colorbox v1.4.31 - 2013-09-25
jQuery lightbox and modal window plugin
(c) 2013 Jack Moore - http://www.jacklmoore.com/colorbox
license: http://www.opensource.org/licenses/mit-license.php
*/
(function(e,t,n){function rt(n,r,i){var o=t.createElement(n);if(r){o.id=s+r}if(i){o.style.cssText=i}return e(o)}function it(){return n.innerHeight?n.innerHeight:e(n).height()}function st(e){var t=E.length,n=(X+e)%t;return n<0?t+n:n}function ot(e,t){return Math.round((/%/.test(e)?(t==="x"?S.width():it())/100:1)*parseInt(e,10))}function ut(e,t){return e.photo||e.photoRegex.test(t)}function at(e,t){return e.retinaUrl&&n.devicePixelRatio>1?t.replace(e.photoRegex,e.retinaSuffix):t}function ft(e){if("contains"in d[0]&&!d[0].contains(e.target)){e.stopPropagation();d.focus()}}function lt(){var t,n=e.data(W,i);if(n==null){I=e.extend({},r);if(console&&console.log){console.log("Error: cboxElement missing settings object")}}else{I=e.extend({},n)}for(t in I){if(e.isFunction(I[t])&&t.slice(0,2)!=="on"){I[t]=I[t].call(W)}}I.rel=I.rel||W.rel||e(W).data("rel")||"nofollow";I.href=I.href||e(W).attr("href");I.title=I.title||W.title;if(typeof I.href==="string"){I.href=e.trim(I.href)}}function ct(n,r){e(t).trigger(n);F.trigger(n);if(e.isFunction(r)){r.call(W)}}function pt(n){if(!K){W=n;lt();E=e(W);X=0;if(I.rel!=="nofollow"){E=e("."+o).filter(function(){var t=e.data(this,i),n;if(t){n=e(this).data("rel")||t.rel||this.rel}return n===I.rel});X=E.index(W);if(X===-1){E=E.add(W);X=E.length-1}}p.css({opacity:parseFloat(I.opacity),cursor:I.overlayClose?"pointer":"auto",visibility:"visible"}).show();if(Z){d.add(p).removeClass(Z)}if(I.className){d.add(p).addClass(I.className)}Z=I.className;if(I.closeButton){M.html(I.close).appendTo(m)}else{M.appendTo("<div/>")}if(!$){$=J=true;d.css({visibility:"hidden",display:"block"});x=rt(Y,"LoadedContent","width:0; height:0; overflow:hidden");m.css({width:"",height:""}).append(x);q=g.height()+w.height()+m.outerHeight(true)-m.height();R=y.width()+b.width()+m.outerWidth(true)-m.width();U=x.outerHeight(true);z=x.outerWidth(true);I.w=ot(I.initialWidth,"x");I.h=ot(I.initialHeight,"y");x.css({width:"",height:I.h});G.position();ct(u,I.onOpen);j.add(C).hide();d.focus();if(I.trapFocus){if(t.addEventListener){t.addEventListener("focus",ft,true);F.one(c,function(){t.removeEventListener("focus",ft,true)})}}if(I.returnFocus){F.one(c,function(){e(W).focus()})}}mt()}}function dt(){if(!d&&t.body){nt=false;S=e(n);d=rt(Y).attr({id:i,"class":e.support.opacity===false?s+"IE":"",role:"dialog",tabindex:"-1"}).hide();p=rt(Y,"Overlay").hide();N=e([rt(Y,"LoadingOverlay")[0],rt(Y,"LoadingGraphic")[0]]);v=rt(Y,"Wrapper");m=rt(Y,"Content").append(C=rt(Y,"Title"),_=rt(Y,"mbRating").attr({"class":"mbrateItRating"}).css({bottom:"-20px",position:"absolute"}).append(D=rt(Y,"mbrateItRating").attr({"class":"wrapper"}).append(P=rt(Y).attr({"class":"rateItRating-selected",display:"block"}),H=rt(Y).attr({"class":"rateItRating-hover"})),B=rt(Y,"mbRatingDescription").attr({"class":"mbratingText ratingText"}).css({"margin-left":"10px"})),k=rt(Y,"Current"),O=e('<button type="button"/>').attr({id:s+"Previous"}),A=e('<button type="button"/>').attr({id:s+"Next"}),L=rt("button","Slideshow"),N).css({"margin-bottom":"20px"});M=e('<button type="button"/>').attr({id:s+"Close"});v.append(rt(Y).append(rt(Y,"TopLeft"),g=rt(Y,"TopCenter"),rt(Y,"TopRight")),rt(Y,false,"clear:left").append(y=rt(Y,"MiddleLeft"),m,b=rt(Y,"MiddleRight")),rt(Y,false,"clear:left").append(rt(Y,"BottomLeft"),w=rt(Y,"BottomCenter"),rt(Y,"BottomRight"))).find("div div").css({"float":"left"});T=rt(Y,false,"position:absolute; width:9999px; visibility:hidden; display:none");j=A.add(O).add(k).add(L);e(t.body).append(p,d.append(v,T))}}function vt(){function n(e){if(!(e.which>1||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey)){e.preventDefault();pt(this)}}if(d){if(!nt){nt=true;A.click(function(){G.next()});O.click(function(){G.prev()});M.click(function(){G.close()});p.click(function(){if(I.overlayClose){G.close()}});e(t).bind("keydown."+s,function(e){var t=e.keyCode;if($&&I.escKey&&t===27){e.preventDefault();G.close()}if($&&I.arrowKey&&E[1]&&!e.altKey){if(t===37){e.preventDefault();O.click()}else if(t===39){e.preventDefault();A.click()}}});if(e.isFunction(e.fn.on)){e(t).on("click."+s,"."+o,n)}else{e("."+o).live("click."+s,n)}}return true}return false}function mt(){var r,i,o=G.prep,u,f=++et;J=true;V=false;W=E[X];lt();ct(h);ct(a,I.onLoad);I.h=I.height?ot(I.height,"y")-U-q:I.innerHeight&&ot(I.innerHeight,"y");I.w=I.width?ot(I.width,"x")-z-R:I.innerWidth&&ot(I.innerWidth,"x");I.mw=I.w;I.mh=I.h;if(I.maxWidth){I.mw=ot(I.maxWidth,"x")-z-R;I.mw=I.w&&I.w<I.mw?I.w:I.mw}if(I.maxHeight){I.mh=ot(I.maxHeight,"y")-U-q;I.mh=I.h&&I.h<I.mh?I.h:I.mh}r=I.href;Q=setTimeout(function(){N.show()},100);if(I.inline){u=rt(Y).hide().insertBefore(e(r)[0]);F.one(h,function(){u.replaceWith(x.children())});o(e(r))}else if(I.iframe){o(" ")}else if(I.html){o(I.html)}else if(ut(I,r)){r=at(I,r);V=t.createElement("img");e(V).addClass(s+"Photo").bind("error",function(){I.title=false;o(rt(Y,"Error").html(I.imgError))}).one("load",function(){var t;if(f!==et){return}e.each(["alt","longdesc","aria-describedby"],function(t,n){var r=e(W).attr(n)||e(W).attr("data-"+n);if(r){V.setAttribute(n,r)}});if(I.retinaImage&&n.devicePixelRatio>1){V.height=V.height/n.devicePixelRatio;V.width=V.width/n.devicePixelRatio}if(I.scalePhotos){i=function(){V.height-=V.height*t;V.width-=V.width*t};if(I.mw&&V.width>I.mw){t=(V.width-I.mw)/V.width;i()}if(I.mh&&V.height>I.mh){t=(V.height-I.mh)/V.height;i()}}if(I.h){V.style.marginTop=Math.max(I.mh-V.height,0)/2+"px"}if(E[1]&&(I.loop||E[X+1])){V.style.cursor="pointer";V.onclick=function(){G.next()}}V.style.width=V.width+"px";V.style.height=V.height+"px";setTimeout(function(){o(V)},1)});setTimeout(function(){V.src=r},1)}else if(r){T.load(r,I.data,function(t,n){if(f===et){o(n==="error"?rt(Y,"Error").html(I.xhrError):e(this).contents())}})}}var r={html:false,photo:false,iframe:false,inline:false,transition:"elastic",speed:300,fadeOut:300,width:false,initialWidth:"600",innerWidth:false,maxWidth:false,height:false,initialHeight:"450",innerHeight:false,maxHeight:false,scalePhotos:true,scrolling:true,href:false,title:false,rel:false,opacity:.9,preloading:true,className:false,overlayClose:true,escKey:true,arrowKey:true,top:false,bottom:false,left:false,right:false,fixed:false,data:undefined,closeButton:true,fastIframe:true,open:false,reposition:true,loop:true,slideshow:false,slideshowAuto:true,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",photoRegex:/\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i,retinaImage:false,retinaUrl:false,retinaSuffix:"@2x.$1",current:"image {current} of {total}",previous:"previous",next:"next",close:"close",xhrError:"This content failed to load.",imgError:"This image failed to load.",returnFocus:true,trapFocus:true,onOpen:false,onLoad:false,onComplete:false,onCleanup:false,onClosed:false},i="colorbox",s="cbox",o=s+"Element",u=s+"_open",a=s+"_load",f=s+"_complete",l=s+"_cleanup",c=s+"_closed",h=s+"_purge",p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D,P,H,B,j,F=e("<a/>"),I,q,R,U,z,W,X,V,$,J,K,Q,G,Y="div",Z,et=0,tt={},nt;var ht=function(){function i(){clearTimeout(r)}function o(){if(I.loop||E[X+1]){i();r=setTimeout(G.next,I.slideshowSpeed)}}function u(){L.html(I.slideshowStop).unbind(n).one(n,c);F.bind(f,o).bind(a,i);d.removeClass(t+"off").addClass(t+"on")}function c(){i();F.unbind(f,o).unbind(a,i);L.html(I.slideshowStart).unbind(n).one(n,function(){G.next();u()});d.removeClass(t+"on").addClass(t+"off")}function h(){e=false;L.hide();i();F.unbind(f,o).unbind(a,i);d.removeClass(t+"off "+t+"on")}var e,t=s+"Slideshow_",n="click."+s,r;return function(){if(e){if(!I.slideshow){F.unbind(l,h);h()}}else{if(I.slideshow&&E[1]){e=true;F.one(l,h);if(I.slideshowAuto){u()}else{c()}L.show()}}}}();if(e.colorbox){return}e(dt);G=e.fn[i]=e[i]=function(t,n){var s=this;t=t||{};dt();if(vt()){if(e.isFunction(s)){s=e("<a/>");t.open=true}else if(!s[0]){return s}if(n){t.onComplete=n}s.each(function(){e.data(this,i,e.extend({},e.data(this,i)||r,t))}).addClass(o);if(e.isFunction(t.open)&&t.open.call(s)||t.open){pt(s[0])}}return s};G.position=function(t,n){function l(){g[0].style.width=w[0].style.width=m[0].style.width=parseInt(d[0].style.width,10)-R+"px";m[0].style.height=y[0].style.height=b[0].style.height=parseInt(d[0].style.height,10)-q+"px"}var r,i=0,o=0,u=d.offset(),a,f;S.unbind("resize."+s);d.css({top:-9e4,left:-9e4});a=S.scrollTop();f=S.scrollLeft();if(I.fixed){u.top-=a;u.left-=f;d.css({position:"fixed"})}else{i=a;o=f;d.css({position:"absolute"})}if(I.right!==false){o+=Math.max(S.width()-I.w-z-R-ot(I.right,"x"),0)}else if(I.left!==false){o+=ot(I.left,"x")}else{o+=Math.round(Math.max(S.width()-I.w-z-R,0)/2)}if(I.bottom!==false){i+=Math.max(it()-I.h-U-q-ot(I.bottom,"y"),0)}else if(I.top!==false){i+=ot(I.top,"y")}else{i+=Math.round(Math.max(it()-I.h-U-q,0)/2)}d.css({top:u.top,left:u.left,visibility:"visible"});v[0].style.width=v[0].style.height="9999px";r={width:I.w+z+R,height:I.h+U+q,top:i,left:o};if(t){var c=0;e.each(r,function(e){if(r[e]!==tt[e]){c=t;return}});t=c}tt=r;if(!t){d.css(r)}d.dequeue().animate(r,{duration:t||0,complete:function(){l();J=false;v[0].style.width=I.w+z+R+"px";v[0].style.height=I.h+U+q+"px";if(I.reposition){setTimeout(function(){S.bind("resize."+s,G.position)},1)}if(n){n()}},step:l})};G.resize=function(e){var t;if($){e=e||{};if(e.width){I.w=ot(e.width,"x")-z-R}if(e.innerWidth){I.w=ot(e.innerWidth,"x")}x.css({width:I.w});if(e.height){I.h=ot(e.height,"y")-U-q}if(e.innerHeight){I.h=ot(e.innerHeight,"y")}if(!e.innerHeight&&!e.height){t=x.scrollTop();x.css({height:"auto"});I.h=x.height()}x.css({height:I.h});if(t){x.scrollTop(t)}G.position(I.transition==="none"?0:I.speed)}};G.prep=function(n){function a(){I.w=I.w||x.width();I.w=I.mw&&I.mw<I.w?I.mw:I.w;return I.w}function l(){I.h=I.h||x.height();I.h=I.mh&&I.mh<I.h?I.mh:I.h;return I.h}if(!$){return}var r,o=I.transition==="none"?0:I.speed;x.empty().remove();x=rt(Y,"LoadedContent").append(n);_.css("display","none");if(typeof arrRatings=="object"){for(var u=0;u<arrRatings.length;u++){if(decodeURIComponent(n.src).endsWith(arrRatings[u].URL)){_.css("display","block");if(arrRatings[u].rated){_.attr("id","mb"+arrRatings[u].rateItID);RateItRating.initMe(_);D.unbind();P.css("display","none");H.css("width",arrRatings[u].width);H.css("display","block");B.text(arrRatings[u].description)}else{_.attr("id","mb"+arrRatings[u].rateItID);P.css("display","block");H.css("display","none");B.text(arrRatings[u].description);RateItRating.initMe(_)}break}}}x.hide().appendTo(T.show()).css({width:a(),overflow:I.scrolling?"auto":"hidden"}).css({height:l()}).prependTo(m);T.hide();e(V).css({"float":"none"});r=function(){function c(){if(e.support.opacity===false){d[0].style.removeAttribute("filter")}}var n=E.length,r,u="frameBorder",a="allowTransparency",l;if(!$){return}l=function(){clearTimeout(Q);N.hide();ct(f,I.onComplete)};C.html(I.title).add(x).show();if(n>1){if(typeof I.current==="string"){k.html(I.current.replace("{current}",X+1).replace("{total}",n)).show()}A[I.loop||X<n-1?"show":"hide"]().html(I.next);O[I.loop||X?"show":"hide"]().html(I.previous);ht();if(I.preloading){e.each([st(-1),st(1)],function(){var n,r,s=E[this],o=e.data(s,i);if(o&&o.href){n=o.href;if(e.isFunction(n)){n=n.call(s)}}else{n=e(s).attr("href")}if(n&&ut(o,n)){n=at(o,n);r=t.createElement("img");r.src=n}})}}else{j.hide()}if(I.iframe){r=rt("iframe")[0];if(u in r){r[u]=0}if(a in r){r[a]="true"}if(!I.scrolling){r.scrolling="no"}e(r).attr({src:I.href,name:(new Date).getTime(),"class":s+"Iframe",allowFullScreen:true,webkitAllowFullScreen:true,mozallowfullscreen:true}).one("load",l).appendTo(x);F.one(h,function(){r.src="//about:blank"});if(I.fastIframe){e(r).trigger("load")}}else{l()}if(I.transition==="fade"){d.fadeTo(o,1,c)}else{c()}};if(I.transition==="fade"){d.fadeTo(o,0,function(){G.position(0,r)})}else{G.position(o,r)}};G.next=function(){if(!J&&E[1]&&(I.loop||E[X+1])){X=st(1);pt(E[X])}};G.prev=function(){if(!J&&E[1]&&(I.loop||X)){X=st(-1);pt(E[X])}};G.close=function(){if($&&!K){K=true;$=false;ct(l,I.onCleanup);S.unbind("."+s);p.fadeTo(I.fadeOut||0,0);d.stop().fadeTo(I.fadeOut||0,0,function(){d.add(p).css({opacity:1,cursor:"auto"}).hide();ct(h);x.empty().remove();setTimeout(function(){K=false;ct(c,I.onClosed)},1)})}};G.remove=function(){if(!d){return}d.stop();e.colorbox.close();d.stop().remove();p.remove();K=false;d=null;e("."+o).removeData(i).removeClass(o);e(t).unbind("click."+s)};G.element=function(){return e(W)};G.settings=r})(jQuery,document,window)