forked from conardcarroll/Gitgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gitgraph.min.js
executable file
·1 lines (1 loc) · 5.69 KB
/
Gitgraph.min.js
1
!function(t,e,o){function n(t,o){var n,i=e.createElement(t||"div");for(n in o)i[n]=o[n];return i}function i(t){for(var e=1,o=arguments.length;o>e;e++)t.appendChild(arguments[e]);return t}function r(t,e,o,n){var i=["opacity",e,~~(100*t),o,n].join("-"),r=.01+100*(o/n),a=Math.max(1-(1-t)/e*(100-r),t),s=c.substring(0,c.indexOf("Animation")).toLowerCase(),l=s&&"-"+s+"-"||"";return f[i]||(h.insertRule("@"+l+"keyframes "+i+"{"+"0%{opacity:"+a+"}"+r+"%{opacity:"+t+"}"+(r+.01)+"%{opacity:1}"+(r+e)%100+"%{opacity:"+t+"}"+"100%{opacity:"+a+"}"+"}",h.cssRules.length),f[i]=1),i}function a(t,e){var n,i,r=t.style;if(r[e]!==o)return e;for(e=e.charAt(0).toUpperCase()+e.slice(1),i=0;u.length>i;i++)if(n=u[i]+e,r[n]!==o)return n}function s(t,e){for(var o in e)t.style[a(t,o)||o]=e[o];return t}function l(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var i in n)t[i]===o&&(t[i]=n[i])}return t}function p(t){for(var e={x:t.offsetLeft,y:t.offsetTop};t=t.offsetParent;)e.x+=t.offsetLeft,e.y+=t.offsetTop;return e}function d(t){return this.spin?(this.opts=l(t||{},d.defaults,g),o):new d(t)}var c,u=["webkit","Moz","ms","O"],f={},h=function(){var t=n("style",{type:"text/css"});return i(e.getElementsByTagName("head")[0],t),t.sheet||t.styleSheet}(),g={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"auto",left:"auto",position:"relative"};d.defaults={},l(d.prototype,{spin:function(t){this.stop();var e,o,i=this,r=i.opts,a=i.el=s(n(0,{className:r.className}),{position:r.position,width:0,zIndex:r.zIndex}),l=r.radius+r.length+r.width;if(t&&(t.insertBefore(a,t.firstChild||null),o=p(t),e=p(a),s(a,{left:("auto"==r.left?o.x-e.x+(t.offsetWidth>>1):parseInt(r.left,10)+l)+"px",top:("auto"==r.top?o.y-e.y+(t.offsetHeight>>1):parseInt(r.top,10)+l)+"px"})),a.setAttribute("aria-role","progressbar"),i.lines(a,i.opts),!c){var d=0,u=r.fps,f=u/r.speed,h=(1-r.opacity)/(f*r.trail/100),g=f/r.lines;(function m(){d++;for(var t=r.lines;t;t--){var e=Math.max(1-(d+t*g)%f*h,r.opacity);i.opacity(a,r.lines-t,e,r)}i.timeout=i.el&&setTimeout(m,~~(1e3/u))})()}return i},stop:function(){var t=this.el;return t&&(clearTimeout(this.timeout),t.parentNode&&t.parentNode.removeChild(t),this.el=o),this},lines:function(t,e){function o(t,o){return s(n(),{position:"absolute",width:e.length+e.width+"px",height:e.width+"px",background:t,boxShadow:o,transformOrigin:"left",transform:"rotate("+~~(360/e.lines*l+e.rotate)+"deg) translate("+e.radius+"px"+",0)",borderRadius:(e.corners*e.width>>1)+"px"})}for(var a,l=0;e.lines>l;l++)a=s(n(),{position:"absolute",top:1+~(e.width/2)+"px",transform:e.hwaccel?"translate3d(0,0,0)":"",opacity:e.opacity,animation:c&&r(e.opacity,e.trail,l,e.lines)+" "+1/e.speed+"s linear infinite"}),e.shadow&&i(a,s(o("#000","0 0 4px #000"),{top:"2px"})),i(t,i(a,o(e.color,"0 0 1px rgba(0,0,0,.1)")));return t},opacity:function(t,e,o){t.childNodes.length>e&&(t.childNodes[e].style.opacity=o)}}),function(){function t(t,e){return n("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',e)}var e=s(n("group"),{behavior:"url(#default#VML)"});!a(e,"transform")&&e.adj?(h.addRule(".spin-vml","behavior:url(#default#VML)"),d.prototype.lines=function(e,o){function n(){return s(t("group",{coordsize:p+" "+p,coordorigin:-l+" "+-l}),{width:p,height:p})}function r(e,r,a){i(c,i(s(n(),{rotation:360/o.lines*e+"deg",left:~~r}),i(s(t("roundrect",{arcsize:o.corners}),{width:l,height:o.width,left:o.radius,top:-o.width>>1,filter:a}),t("fill",{color:o.color,opacity:o.opacity}),t("stroke",{opacity:0}))))}var a,l=o.length+o.width,p=2*l,d=2*-(o.width+o.length)+"px",c=s(n(),{position:"absolute",top:d,left:d});if(o.shadow)for(a=1;o.lines>=a;a++)r(a,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(a=1;o.lines>=a;a++)r(a);return i(e,c)},d.prototype.opacity=function(t,e,o,n){var i=t.firstChild;n=n.shadow&&n.lines||0,i&&i.childNodes.length>e+n&&(i=i.childNodes[e+n],i=i&&i.firstChild,i=i&&i.firstChild,i&&(i.opacity=o))}):c=a(e,"animation")}(),"function"==typeof define&&define.amd?define(function(){return d}):t.Spinner=d}(window,document);var Gitgraph=function(){var t=function(t){var e=document.createElement("div"),o=t.domNode||document.body,n=t.height||40,i=t.width||416,r=t.background||"white",a=t.userColor||"rgb(51, 102, 153)",s=t.allColor||"rgb(202, 202, 202)",l=t.hasOwnProperty("showName")?t.showName:!0,p=(new Spinner).spin(e);p.el.style.left="50%",p.el.style.top="50%";var d=e.style;d.padding="4px",d.borderRadius="4px",d.background=r,d.position="relative",d.height=n+"px",d.textAlign="center",d.width=i+"px",o.appendChild(e);var c="http://cdn.bitpshr.net/simple-proxy/simple-proxy.php",u="?url=https://github.com/"+t.user+"/"+t.repo+"/graphs/owner_participation",f=new XMLHttpRequest;f.open("GET",c+u,!0),f.onreadystatechange=function(){if(4==f.readyState&&200==f.status){var o=JSON.parse(f.responseText);if(o&&o.contents&&o.contents.all){var r=o.contents.all,p="https://github.com/"+t.user+"/"+t.repo+"/";e.innerHTML="";var d=document.createElement("canvas");d.width=i,d.height=n,d.style.position="relative";var c=document.createElement("a");if(c.href=p,c.appendChild(d),e.appendChild(c),l){var u=document.createElement("div");u.innerHTML=t.user+"/"+t.repo;var h=u.style;h.fontSize="12px",h.borderRadius="3px",h.color="#EEE",h.backgroundColor="rgba(0,0,0,0.5)",h.display="inline-block",h.padding="5px",h.position="absolute",h.top=h.right="5px",c.appendChild(u)}var g=d.getContext("2d"),m=i/r.length,y=Math.max.apply(Math,r),v=parseFloat(n-1)/y,x=function(t,e){t*=v,g.fillRect(e*m,n-t,m-1,t)};g.fillStyle=s;var w,b;for(w=0,b=r.length;b>w;w++)x(r[w],w);for(g.fillStyle=a,w=0,b=o.contents.owner.length;b>w;w++)x(o.contents.owner[w],w)}}},f.send(null)};return t.prototype={constructor:t},t}();