diff --git a/bower.json b/bower.json index 62159a5a..712fa1cb 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "gitgraph.js", - "version": "1.11.1", + "version": "1.11.2", "main": [ "./build/gitgraph.js", "./build/gitgraph.css" diff --git a/build/gitgraph.js b/build/gitgraph.js index 6eb9a6bc..7b32f002 100644 --- a/build/gitgraph.js +++ b/build/gitgraph.js @@ -1,5 +1,5 @@ /* ========================================================== - * GitGraph v1.11.1 + * GitGraph v1.11.2 * https://github.com/nicoespeon/gitgraph.js * ========================================================== * Copyright (c) 2017 Nicolas CARLO (@nicoespeon) ٩(^‿^)۶ @@ -385,14 +385,8 @@ return; } - // Fix firefox MouseEvent - if (typeof InstallTrigger !== "undefined") /* == (is Firefox) */ { - event.x = event.x ? event.x : event.clientX; - event.y = event.y ? event.y : event.clientY; - } - - self.tooltip.style.left = event.x + "px"; // TODO Scroll bug - self.tooltip.style.top = event.y + "px"; // TODO Scroll bug + self.tooltip.style.left = event.clientX + "px"; // TODO Scroll bug + self.tooltip.style.top = event.clientY + "px"; // TODO Scroll bug if (self.template.commit.tooltipHTMLFormatter !== null) { self.tooltip.innerHTML = self.template.commit.tooltipHTMLFormatter(commit); } else { diff --git a/build/gitgraph.min.js b/build/gitgraph.min.js index acf6f23d..6a55aacd 100644 --- a/build/gitgraph.min.js +++ b/build/gitgraph.min.js @@ -1,5 +1,5 @@ /* ========================================================== - * GitGraph v1.11.1 + * GitGraph v1.11.2 * https://github.com/nicoespeon/gitgraph.js * ========================================================== * Copyright (c) 2017 Nicolas CARLO (@nicoespeon) ٩(^‿^)۶ @@ -7,4 +7,4 @@ * * GitGraph.js may be freely distributed under the MIT Licence * ========================================================== */ -!function(){"use strict";function a(a){switch(a=q(a)?a:{},this.elementId="string"==typeof a.elementId?a.elementId:"gitGraph",this.author="string"==typeof a.author?a.author:"Sergio Flores ",this.reverseArrow=k(a.reverseArrow,!1),"string"==typeof a.template||q(a.template)?this.template=this.newTemplate(a.template):a.template instanceof e?this.template=a.template:this.template=this.newTemplate("metro"),this.mode=a.mode||null,"compact"===this.mode&&(this.template.commit.message.display=!1),a.orientation){case"vertical-reverse":this.template.commit.spacingY*=-1,this.orientation="vertical-reverse",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?0:a.template.branch.labelRotation,this.template.commit.tag.spacingY*=-1;break;case"horizontal":this.template.commit.message.display=!1,this.template.commit.spacingX=this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?-90:a.template.branch.labelRotation,this.template.commit.tag.spacingX=-this.template.commit.spacingX,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;case"horizontal-reverse":this.template.commit.message.display=!1,this.template.commit.spacingX=-this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal-reverse",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?90:a.template.branch.labelRotation,this.template.commit.tag.spacingX=-this.template.commit.spacingY,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;default:this.orientation="vertical",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?0:a.template.branch.labelRotation}this.marginX=this.template.branch.spacingX+2*this.template.commit.dot.size,this.marginY=this.template.branch.spacingY+2*this.template.commit.dot.size,this.offsetX=0,this.offsetY=0,this.canvas=document.getElementById(this.elementId)||a.canvas,this.context=this.canvas.getContext("2d"),this.context.textBaseline="center",this.tooltip=document.createElement("div"),this.tooltip.className="gitgraph-tooltip",this.tooltip.style.position="fixed",this.tooltip.style.display="none",(a.tooltipContainer||document.body).appendChild(this.tooltip),this.HEAD=null,this.branches=[],this.commits=[],this.columnMax=0,this.commitOffsetX=a.initCommitOffsetX||0,this.commitOffsetY=a.initCommitOffsetY||0,this.mouseMoveOptions={handleEvent:this.hover,gitgraph:this},this.canvas.addEventListener("mousemove",this.mouseMoveOptions,!1),this.mouseDownOptions={handleEvent:this.click,gitgraph:this},this.canvas.addEventListener("mousedown",this.mouseDownOptions,!1),window.onresize=this.render.bind(this)}function b(b){if(b.parent instanceof a!=!1){if(b=q(b)?b:{},this.parent=b.parent,b.parentCommit&&b.parentBranch){if(b.parentCommit.branch!==b.parentBranch)return;this.parentCommit=b.parentCommit,this.parentBranch=b.parentBranch}else b.parentCommit?(this.parentCommit=b.parentCommit,this.parentBranch=b.parentCommit.branch):b.parentBranch?(this.parentCommit=h(b.parentBranch),this.parentBranch=b.parentBranch):(this.parentCommit=null,this.parentBranch=null);this.name="string"==typeof b.name?b.name:"no-name",this.commitDefaultOptions=q(b.commitDefaultOptions)?b.commitDefaultOptions:{},this.context=this.parent.context,this.template=this.parent.template,this.lineWidth=b.lineWidth||this.template.branch.lineWidth,this.lineDash=b.lineDash||this.template.branch.lineDash,this.showLabel=k(b.showLabel,this.template.branch.showLabel),this.spacingX=this.template.branch.spacingX,this.spacingY=this.template.branch.spacingY,this.size=0,this.height=0,this.width=0,this.commits=[],this.path=[],"number"==typeof b.column?this.column=b.column:(this.column=0,this.calculColumn()),this.parent.columnMax=this.column>this.parent.columnMax?this.column:this.parent.columnMax,this.offsetX=this.column*this.spacingX,this.offsetY=this.column*this.spacingY,this.parentBranch&&this.parentCommit?this.parentCommit===h(this.parentBranch)&&this.commits.length>0?this.startPoint={x:this.parentBranch.offsetX-this.parent.commitOffsetX+this.template.commit.spacingX,y:this.parentBranch.offsetY-this.parent.commitOffsetY+this.template.commit.spacingY,type:"start"}:this.startPoint={x:this.parentCommit.x,y:this.parentCommit.y,type:"start"}:this.startPoint=null;var c=this.column%this.template.colors.length;this.color=b.color||this.template.branch.color||this.template.colors[c],this.checkout()}}function c(b){b.parent instanceof a!=!1&&(b=q(b)?b:{},this.parent=b.parent,this.template=this.parent.template,this.context=this.parent.context,this.branch=b.branch,this.author=b.author||this.parent.author,this.date=b.date||(new Date).toUTCString(),this.detail=b.detail||null,this.sha1=b.sha1||Math.random(100).toString(16).substring(3,10),this.message=b.message||"He doesn't like George Michael! Boooo!",this.arrowDisplay=b.arrowDisplay,this.messageDisplay=k(b.messageDisplay,this.template.commit.message.display),this.messageAuthorDisplay=k(b.messageAuthorDisplay,this.template.commit.message.displayAuthor),this.messageBranchDisplay=k(b.messageBranchDisplay,this.template.commit.message.displayBranch),this.messageHashDisplay=k(b.messageHashDisplay,this.template.commit.message.displayHash),this.messageColor=b.messageColor||b.color,this.messageFont=b.messageFont||this.template.commit.message.font,this.dotColor=b.dotColor||b.color,this.dotSize=b.dotSize||this.template.commit.dot.size,this.dotStrokeWidth=b.dotStrokeWidth||this.template.commit.dot.strokeWidth,this.dotStrokeColor=b.dotStrokeColor||this.template.commit.dot.strokeColor||b.color,this.lineDash=b.lineDash||this.template.commit.dot.lineDash,this.type=b.type||null,this.tooltipDisplay=k(b.tooltipDisplay,!0),this.onClick=b.onClick||null,this.representedObject=b.representedObject||null,this.parentCommit=b.parentCommit,this.x=b.x,this.y=b.y,this.showLabel=b.showLabel,this.labelColor=b.labelColor||b.color,this.labelFont=b.labelFont||this.template.branch.labelFont,g(this,b),this.parent.commits.push(this))}function d(a,b){if(!q(a))throw new Error("You can't tag a commit that doesn't exist");b=q(b)?b:{},this.color=b.color||a.color,this.font=b.font||a.template.commit.tag.font;var c=a.context.font;a.context.font=this.font;var d=a.context.measureText(a.tag).width;this.width=Math.max(a.template.commit.tag.spacingX,d);var e=0,f=0,g=a.parent.columnMax+1;return p(a.parent)?(e=a.x-a.dotSize/2,f=g*a.template.commit.tag.spacingY-a.template.commit.tag.spacingY/2):(e=g*a.template.commit.tag.spacingX-a.template.commit.tag.spacingX/2+d/2,f=a.y-a.dotSize/2),l(a.context,e,f,a.tag,this.color,this.font,0,a.displayTagBox),a.context.font=c,this}function e(a){a=q(a)?a:{},a.branch=a.branch||{},a.arrow=a.arrow||{},a.commit=a.commit||{},a.commit.dot=a.commit.dot||{},a.commit.tag=a.commit.tag||{},a.commit.message=a.commit.message||{},this.colors=a.colors||["#6963FF","#47E8D4","#6BDB52","#E84BA5","#FFA657"],this.branch={},this.branch.color=a.branch.color||null,this.branch.lineWidth=a.branch.lineWidth||2,this.branch.lineDash=a.branch.lineDash||[],this.branch.showLabel=a.branch.showLabel||!1,this.branch.labelColor=a.branch.labelColor||null,this.branch.labelFont=a.branch.labelFont||"normal 8pt Calibri",this.branch.labelRotation=void 0!==a.branch.labelRotation?a.branch.labelRotation:null,this.branch.mergeStyle=a.branch.mergeStyle||"bezier",this.branch.spacingX="number"==typeof a.branch.spacingX?a.branch.spacingX:20,this.branch.spacingY=a.branch.spacingY||0,this.arrow={},this.arrow.size=a.arrow.size||null,this.arrow.color=a.arrow.color||null,this.arrow.active="number"==typeof this.arrow.size,this.arrow.offset=a.arrow.offset||2,this.commit={},this.commit.spacingX=a.commit.spacingX||0,this.commit.spacingY="number"==typeof a.commit.spacingY?a.commit.spacingY:25,this.commit.widthExtension="number"==typeof a.commit.widthExtension?a.commit.widthExtension:0,this.commit.tooltipHTMLFormatter=a.commit.tooltipHTMLFormatter||null,this.commit.shouldDisplayTooltipsInCompactMode=k(a.commit.shouldDisplayTooltipsInCompactMode,!0),this.commit.color=a.commit.color||null,this.commit.dot={},this.commit.dot.color=a.commit.dot.color||null,this.commit.dot.size=a.commit.dot.size||3,this.commit.dot.strokeWidth=a.commit.dot.strokeWidth||null,this.commit.dot.strokeColor=a.commit.dot.strokeColor||null,this.commit.dot.lineDash=a.commit.dot.lineDash||this.branch.lineDash,this.commit.tag={},this.commit.tag.color=a.commit.tag.color||this.commit.dot.color,this.commit.tag.font=a.commit.tag.font||a.commit.message.font||"normal 10pt Calibri",this.commit.tag.spacingX=this.branch.spacingX,this.commit.tag.spacingY=this.commit.spacingY,this.commit.message={},this.commit.message.display=k(a.commit.message.display,!0),this.commit.message.displayAuthor=k(a.commit.message.displayAuthor,!0),this.commit.message.displayBranch=k(a.commit.message.displayBranch,!0),this.commit.message.displayHash=k(a.commit.message.displayHash,!0),this.commit.message.color=a.commit.message.color||null,this.commit.message.font=a.commit.message.font||"normal 12pt Calibri"}function f(a){return a.slice(-1)[0]}function g(a,b){a.tag=b.tag||null,a.tagColor=b.tagColor||a.messageColor,a.tagFont=b.tagFont||a.template.commit.tag.font,a.displayTagBox=k(b.displayTagBox,!0)}function h(a){return f(a.commits)?f(a.commits):a.parentBranch?h(a.parentBranch):null}function i(a){return JSON.parse(JSON.stringify(a))}function j(a){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d=document.createTextNode("Mg");c.appendChild(d),c.setAttribute("style","font: "+a+"; display: inline-block;"),b.appendChild(c);var e=c.offsetHeight;return b.removeChild(c),e}function k(a,b){return"boolean"==typeof a?a:b}function l(a,b,c,d,e,f,g,h){a.save(),a.translate(b,c),a.rotate(g*(Math.PI/180)),a.textAlign="center",a.font=f;var i=a.measureText(d).width,k=j(f);h?(a.beginPath(),a.rect(-(i/2)-4,2-k/2,i+8,k+2),a.fillStyle=e,a.fill(),a.lineWidth=2,a.strokeStyle="black",a.stroke(),a.fillStyle="black"):a.fillStyle=e,a.fillText(d,0,k/2),a.restore()}function m(a,b,c){var d;document.createEvent?(d=document.createEvent("HTMLEvents"),d.initEvent(b,!0,!0)):(d=document.createEventObject(),d.eventType=b),d.eventName=b,d.data=c||{},document.createEvent?a.dispatchEvent(d):a.fireEvent("on"+d.eventType,d)}function n(a){var b,c;return c=1,window.devicePixelRatio&&(b=a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1,c*=window.devicePixelRatio/b),c}function o(a){return"vertical"===a.orientation||"vertical-reverse"===a.orientation}function p(a){return"horizontal"===a.orientation||"horizontal-reverse"===a.orientation}function q(a){return"object"==typeof a}function r(a,b){return!b.split(".").every(function(b){return"object"==typeof a&&null!==a&&b in a&&(a=a[b],!0)})}a.prototype.dispose=function(){this.canvas.removeEventListener("mousemove",this.mouseMoveOptions,!1),this.canvas.removeEventListener("mousedown",this.mouseDownOptions,!1)},a.prototype.branch=function(a){if("string"==typeof a){var c=a;a={},a.name=c}a=q(a)?a:{},a.parent=this,a.parentBranch=a.parentBranch||this.HEAD;var d=new b(a);return this.branches.push(d),d},a.prototype.orphanBranch=function(a){if("string"==typeof a){var c=a;a={},a.name=c}a=q(a)?a:{},a.parent=this;var d=new b(a);return this.branches.push(d),d},a.prototype.commit=function(a){return this.HEAD.commit(a),this},a.prototype.tag=function(a){return this.HEAD.tag(a),this},a.prototype.newTemplate=function(a){return"string"==typeof a?(new e).get(a):new e(a)},a.prototype.render=function(){this.scalingFactor=n(this.context);var a={x:Math.abs((this.columnMax+1)*this.template.branch.spacingX)+Math.abs(this.commitOffsetX)+2*this.marginX,y:Math.abs((this.columnMax+1)*this.template.branch.spacingY)+Math.abs(this.commitOffsetY)+2*this.marginY};this.template.commit.message.display&&(a.x+=800),a.x+=this.template.commit.widthExtension,this.canvas.style.width=a.x+"px",this.canvas.style.height=a.y+"px",this.canvas.width=a.x*this.scalingFactor,this.canvas.height=a.y*this.scalingFactor,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.translate(this.marginX,this.marginY),this.template.commit.spacingY>0&&(this.context.translate(0,this.canvas.height-2*this.marginY),this.offsetY=this.canvas.height-2*this.marginY),this.template.commit.spacingX>0&&(this.context.translate(this.canvas.width-2*this.marginX,0),this.offsetX=this.canvas.width-2*this.marginX),this.context.scale(this.scalingFactor,this.scalingFactor);for(var b,c=this.branches.length-1;b=this.branches[c];c--)b.render();for(var d,e=0;d=this.commits[e];e++)d.render();m(this.canvas,"graph:render",{id:this.elementId})},a.prototype.applyCommits=function(a,b){function c(a){var b=document.getElementById(a),c=b.getBoundingClientRect();return{top:c.top+document.body.scrollTop,left:c.left+document.body.scrollLeft}}for(var d,e=a.offsetX||a.pageX-c(this.elementId).left,f=a.offsetY||a.pageY-c(this.elementId).top,g=0;d=this.commits[g];g++){var h=d.x+(this.offsetX+this.marginX)/this.scalingFactor-e,i=d.y+(this.offsetY+this.marginY)/this.scalingFactor-f;b(d,Math.sqrt(Math.pow(h,2)+Math.pow(i,2))Math.abs(this.template.commit.spacingY),k=this.x===this.parentCommit.x;o(this.parent)&&(j||k)&&(i=0);var l=this.template.branch.spacingY*g+this.template.commit.spacingY*h,m=(f||d)&&Math.abs(this.x-this.parentCommit.x)>Math.abs(this.template.commit.spacingX),n=this.y===this.parentCommit.y;p(this.parent)&&(m||n)&&(l=0),e=a(l,i),c=this.parentCommit.branch.color}var q=Math.PI/7,r=d?this.parentCommit.x:this.x,s=d?this.parentCommit.y:this.y,t=this.template.commit.dot.size+this.template.arrow.offset,u=t*Math.cos(e)+r,v=t*Math.sin(e)+s,w=(t+b)*Math.cos(e-q)+r,x=(t+b)*Math.sin(e-q)+s,y=(t+b/2)*Math.cos(e)+r,z=(t+b/2)*Math.sin(e)+s,A=(t+b)*Math.cos(e+q)+r,B=(t+b)*Math.sin(e+q)+s;this.context.beginPath(),this.context.fillStyle=c,this.context.moveTo(u,v),this.context.lineTo(w,x),this.context.quadraticCurveTo(y,z,A,B),this.context.lineTo(A,B),this.context.fill()},e.prototype.get=function(a){var b={};switch(a){case"blackarrow":b={branch:{color:"#000000",lineWidth:4,spacingX:50,mergeStyle:"straight",labelRotation:0},commit:{spacingY:-60,dot:{size:12,strokeColor:"#000000",strokeWidth:7},message:{color:"black"}},arrow:{size:16,offset:2.5}};break;case"metro":default:b={colors:["#979797","#008fb5","#f1c109"],branch:{lineWidth:10,spacingX:50,labelRotation:0},commit:{spacingY:-80,dot:{size:14},message:{font:"normal 14pt Arial"}}}}return new e(b)},Array.prototype.every||(Array.prototype.every=function(a,b){var c,d;if(null===this)throw new TypeError("this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError;for(arguments.length>1&&(c=b),d=0;d",this.reverseArrow=k(a.reverseArrow,!1),"string"==typeof a.template||q(a.template)?this.template=this.newTemplate(a.template):a.template instanceof e?this.template=a.template:this.template=this.newTemplate("metro"),this.mode=a.mode||null,"compact"===this.mode&&(this.template.commit.message.display=!1),a.orientation){case"vertical-reverse":this.template.commit.spacingY*=-1,this.orientation="vertical-reverse",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?0:a.template.branch.labelRotation,this.template.commit.tag.spacingY*=-1;break;case"horizontal":this.template.commit.message.display=!1,this.template.commit.spacingX=this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?-90:a.template.branch.labelRotation,this.template.commit.tag.spacingX=-this.template.commit.spacingX,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;case"horizontal-reverse":this.template.commit.message.display=!1,this.template.commit.spacingX=-this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal-reverse",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?90:a.template.branch.labelRotation,this.template.commit.tag.spacingX=-this.template.commit.spacingY,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;default:this.orientation="vertical",this.template.branch.labelRotation=r(a,"template.branch.labelRotation")?0:a.template.branch.labelRotation}this.marginX=this.template.branch.spacingX+2*this.template.commit.dot.size,this.marginY=this.template.branch.spacingY+2*this.template.commit.dot.size,this.offsetX=0,this.offsetY=0,this.canvas=document.getElementById(this.elementId)||a.canvas,this.context=this.canvas.getContext("2d"),this.context.textBaseline="center",this.tooltip=document.createElement("div"),this.tooltip.className="gitgraph-tooltip",this.tooltip.style.position="fixed",this.tooltip.style.display="none",(a.tooltipContainer||document.body).appendChild(this.tooltip),this.HEAD=null,this.branches=[],this.commits=[],this.columnMax=0,this.commitOffsetX=a.initCommitOffsetX||0,this.commitOffsetY=a.initCommitOffsetY||0,this.mouseMoveOptions={handleEvent:this.hover,gitgraph:this},this.canvas.addEventListener("mousemove",this.mouseMoveOptions,!1),this.mouseDownOptions={handleEvent:this.click,gitgraph:this},this.canvas.addEventListener("mousedown",this.mouseDownOptions,!1),window.onresize=this.render.bind(this)}function b(b){if(b.parent instanceof a!=!1){if(b=q(b)?b:{},this.parent=b.parent,b.parentCommit&&b.parentBranch){if(b.parentCommit.branch!==b.parentBranch)return;this.parentCommit=b.parentCommit,this.parentBranch=b.parentBranch}else b.parentCommit?(this.parentCommit=b.parentCommit,this.parentBranch=b.parentCommit.branch):b.parentBranch?(this.parentCommit=h(b.parentBranch),this.parentBranch=b.parentBranch):(this.parentCommit=null,this.parentBranch=null);this.name="string"==typeof b.name?b.name:"no-name",this.commitDefaultOptions=q(b.commitDefaultOptions)?b.commitDefaultOptions:{},this.context=this.parent.context,this.template=this.parent.template,this.lineWidth=b.lineWidth||this.template.branch.lineWidth,this.lineDash=b.lineDash||this.template.branch.lineDash,this.showLabel=k(b.showLabel,this.template.branch.showLabel),this.spacingX=this.template.branch.spacingX,this.spacingY=this.template.branch.spacingY,this.size=0,this.height=0,this.width=0,this.commits=[],this.path=[],"number"==typeof b.column?this.column=b.column:(this.column=0,this.calculColumn()),this.parent.columnMax=this.column>this.parent.columnMax?this.column:this.parent.columnMax,this.offsetX=this.column*this.spacingX,this.offsetY=this.column*this.spacingY,this.parentBranch&&this.parentCommit?this.parentCommit===h(this.parentBranch)&&this.commits.length>0?this.startPoint={x:this.parentBranch.offsetX-this.parent.commitOffsetX+this.template.commit.spacingX,y:this.parentBranch.offsetY-this.parent.commitOffsetY+this.template.commit.spacingY,type:"start"}:this.startPoint={x:this.parentCommit.x,y:this.parentCommit.y,type:"start"}:this.startPoint=null;var c=this.column%this.template.colors.length;this.color=b.color||this.template.branch.color||this.template.colors[c],this.checkout()}}function c(b){b.parent instanceof a!=!1&&(b=q(b)?b:{},this.parent=b.parent,this.template=this.parent.template,this.context=this.parent.context,this.branch=b.branch,this.author=b.author||this.parent.author,this.date=b.date||(new Date).toUTCString(),this.detail=b.detail||null,this.sha1=b.sha1||Math.random(100).toString(16).substring(3,10),this.message=b.message||"He doesn't like George Michael! Boooo!",this.arrowDisplay=b.arrowDisplay,this.messageDisplay=k(b.messageDisplay,this.template.commit.message.display),this.messageAuthorDisplay=k(b.messageAuthorDisplay,this.template.commit.message.displayAuthor),this.messageBranchDisplay=k(b.messageBranchDisplay,this.template.commit.message.displayBranch),this.messageHashDisplay=k(b.messageHashDisplay,this.template.commit.message.displayHash),this.messageColor=b.messageColor||b.color,this.messageFont=b.messageFont||this.template.commit.message.font,this.dotColor=b.dotColor||b.color,this.dotSize=b.dotSize||this.template.commit.dot.size,this.dotStrokeWidth=b.dotStrokeWidth||this.template.commit.dot.strokeWidth,this.dotStrokeColor=b.dotStrokeColor||this.template.commit.dot.strokeColor||b.color,this.lineDash=b.lineDash||this.template.commit.dot.lineDash,this.type=b.type||null,this.tooltipDisplay=k(b.tooltipDisplay,!0),this.onClick=b.onClick||null,this.representedObject=b.representedObject||null,this.parentCommit=b.parentCommit,this.x=b.x,this.y=b.y,this.showLabel=b.showLabel,this.labelColor=b.labelColor||b.color,this.labelFont=b.labelFont||this.template.branch.labelFont,g(this,b),this.parent.commits.push(this))}function d(a,b){if(!q(a))throw new Error("You can't tag a commit that doesn't exist");b=q(b)?b:{},this.color=b.color||a.color,this.font=b.font||a.template.commit.tag.font;var c=a.context.font;a.context.font=this.font;var d=a.context.measureText(a.tag).width;this.width=Math.max(a.template.commit.tag.spacingX,d);var e=0,f=0,g=a.parent.columnMax+1;return p(a.parent)?(e=a.x-a.dotSize/2,f=g*a.template.commit.tag.spacingY-a.template.commit.tag.spacingY/2):(e=g*a.template.commit.tag.spacingX-a.template.commit.tag.spacingX/2+d/2,f=a.y-a.dotSize/2),l(a.context,e,f,a.tag,this.color,this.font,0,a.displayTagBox),a.context.font=c,this}function e(a){a=q(a)?a:{},a.branch=a.branch||{},a.arrow=a.arrow||{},a.commit=a.commit||{},a.commit.dot=a.commit.dot||{},a.commit.tag=a.commit.tag||{},a.commit.message=a.commit.message||{},this.colors=a.colors||["#6963FF","#47E8D4","#6BDB52","#E84BA5","#FFA657"],this.branch={},this.branch.color=a.branch.color||null,this.branch.lineWidth=a.branch.lineWidth||2,this.branch.lineDash=a.branch.lineDash||[],this.branch.showLabel=a.branch.showLabel||!1,this.branch.labelColor=a.branch.labelColor||null,this.branch.labelFont=a.branch.labelFont||"normal 8pt Calibri",this.branch.labelRotation=void 0!==a.branch.labelRotation?a.branch.labelRotation:null,this.branch.mergeStyle=a.branch.mergeStyle||"bezier",this.branch.spacingX="number"==typeof a.branch.spacingX?a.branch.spacingX:20,this.branch.spacingY=a.branch.spacingY||0,this.arrow={},this.arrow.size=a.arrow.size||null,this.arrow.color=a.arrow.color||null,this.arrow.active="number"==typeof this.arrow.size,this.arrow.offset=a.arrow.offset||2,this.commit={},this.commit.spacingX=a.commit.spacingX||0,this.commit.spacingY="number"==typeof a.commit.spacingY?a.commit.spacingY:25,this.commit.widthExtension="number"==typeof a.commit.widthExtension?a.commit.widthExtension:0,this.commit.tooltipHTMLFormatter=a.commit.tooltipHTMLFormatter||null,this.commit.shouldDisplayTooltipsInCompactMode=k(a.commit.shouldDisplayTooltipsInCompactMode,!0),this.commit.color=a.commit.color||null,this.commit.dot={},this.commit.dot.color=a.commit.dot.color||null,this.commit.dot.size=a.commit.dot.size||3,this.commit.dot.strokeWidth=a.commit.dot.strokeWidth||null,this.commit.dot.strokeColor=a.commit.dot.strokeColor||null,this.commit.dot.lineDash=a.commit.dot.lineDash||this.branch.lineDash,this.commit.tag={},this.commit.tag.color=a.commit.tag.color||this.commit.dot.color,this.commit.tag.font=a.commit.tag.font||a.commit.message.font||"normal 10pt Calibri",this.commit.tag.spacingX=this.branch.spacingX,this.commit.tag.spacingY=this.commit.spacingY,this.commit.message={},this.commit.message.display=k(a.commit.message.display,!0),this.commit.message.displayAuthor=k(a.commit.message.displayAuthor,!0),this.commit.message.displayBranch=k(a.commit.message.displayBranch,!0),this.commit.message.displayHash=k(a.commit.message.displayHash,!0),this.commit.message.color=a.commit.message.color||null,this.commit.message.font=a.commit.message.font||"normal 12pt Calibri"}function f(a){return a.slice(-1)[0]}function g(a,b){a.tag=b.tag||null,a.tagColor=b.tagColor||a.messageColor,a.tagFont=b.tagFont||a.template.commit.tag.font,a.displayTagBox=k(b.displayTagBox,!0)}function h(a){return f(a.commits)?f(a.commits):a.parentBranch?h(a.parentBranch):null}function i(a){return JSON.parse(JSON.stringify(a))}function j(a){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d=document.createTextNode("Mg");c.appendChild(d),c.setAttribute("style","font: "+a+"; display: inline-block;"),b.appendChild(c);var e=c.offsetHeight;return b.removeChild(c),e}function k(a,b){return"boolean"==typeof a?a:b}function l(a,b,c,d,e,f,g,h){a.save(),a.translate(b,c),a.rotate(g*(Math.PI/180)),a.textAlign="center",a.font=f;var i=a.measureText(d).width,k=j(f);h?(a.beginPath(),a.rect(-(i/2)-4,2-k/2,i+8,k+2),a.fillStyle=e,a.fill(),a.lineWidth=2,a.strokeStyle="black",a.stroke(),a.fillStyle="black"):a.fillStyle=e,a.fillText(d,0,k/2),a.restore()}function m(a,b,c){var d;document.createEvent?(d=document.createEvent("HTMLEvents"),d.initEvent(b,!0,!0)):(d=document.createEventObject(),d.eventType=b),d.eventName=b,d.data=c||{},document.createEvent?a.dispatchEvent(d):a.fireEvent("on"+d.eventType,d)}function n(a){var b,c;return c=1,window.devicePixelRatio&&(b=a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1,c*=window.devicePixelRatio/b),c}function o(a){return"vertical"===a.orientation||"vertical-reverse"===a.orientation}function p(a){return"horizontal"===a.orientation||"horizontal-reverse"===a.orientation}function q(a){return"object"==typeof a}function r(a,b){return!b.split(".").every(function(b){return"object"==typeof a&&null!==a&&b in a&&(a=a[b],!0)})}a.prototype.dispose=function(){this.canvas.removeEventListener("mousemove",this.mouseMoveOptions,!1),this.canvas.removeEventListener("mousedown",this.mouseDownOptions,!1)},a.prototype.branch=function(a){if("string"==typeof a){var c=a;a={},a.name=c}a=q(a)?a:{},a.parent=this,a.parentBranch=a.parentBranch||this.HEAD;var d=new b(a);return this.branches.push(d),d},a.prototype.orphanBranch=function(a){if("string"==typeof a){var c=a;a={},a.name=c}a=q(a)?a:{},a.parent=this;var d=new b(a);return this.branches.push(d),d},a.prototype.commit=function(a){return this.HEAD.commit(a),this},a.prototype.tag=function(a){return this.HEAD.tag(a),this},a.prototype.newTemplate=function(a){return"string"==typeof a?(new e).get(a):new e(a)},a.prototype.render=function(){this.scalingFactor=n(this.context);var a={x:Math.abs((this.columnMax+1)*this.template.branch.spacingX)+Math.abs(this.commitOffsetX)+2*this.marginX,y:Math.abs((this.columnMax+1)*this.template.branch.spacingY)+Math.abs(this.commitOffsetY)+2*this.marginY};this.template.commit.message.display&&(a.x+=800),a.x+=this.template.commit.widthExtension,this.canvas.style.width=a.x+"px",this.canvas.style.height=a.y+"px",this.canvas.width=a.x*this.scalingFactor,this.canvas.height=a.y*this.scalingFactor,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.translate(this.marginX,this.marginY),this.template.commit.spacingY>0&&(this.context.translate(0,this.canvas.height-2*this.marginY),this.offsetY=this.canvas.height-2*this.marginY),this.template.commit.spacingX>0&&(this.context.translate(this.canvas.width-2*this.marginX,0),this.offsetX=this.canvas.width-2*this.marginX),this.context.scale(this.scalingFactor,this.scalingFactor);for(var b,c=this.branches.length-1;b=this.branches[c];c--)b.render();for(var d,e=0;d=this.commits[e];e++)d.render();m(this.canvas,"graph:render",{id:this.elementId})},a.prototype.applyCommits=function(a,b){function c(a){var b=document.getElementById(a),c=b.getBoundingClientRect();return{top:c.top+document.body.scrollTop,left:c.left+document.body.scrollLeft}}for(var d,e=a.offsetX||a.pageX-c(this.elementId).left,f=a.offsetY||a.pageY-c(this.elementId).top,g=0;d=this.commits[g];g++){var h=d.x+(this.offsetX+this.marginX)/this.scalingFactor-e,i=d.y+(this.offsetY+this.marginY)/this.scalingFactor-f;b(d,Math.sqrt(Math.pow(h,2)+Math.pow(i,2))Math.abs(this.template.commit.spacingY),k=this.x===this.parentCommit.x;o(this.parent)&&(j||k)&&(i=0);var l=this.template.branch.spacingY*g+this.template.commit.spacingY*h,m=(f||d)&&Math.abs(this.x-this.parentCommit.x)>Math.abs(this.template.commit.spacingX),n=this.y===this.parentCommit.y;p(this.parent)&&(m||n)&&(l=0),e=a(l,i),c=this.parentCommit.branch.color}var q=Math.PI/7,r=d?this.parentCommit.x:this.x,s=d?this.parentCommit.y:this.y,t=this.template.commit.dot.size+this.template.arrow.offset,u=t*Math.cos(e)+r,v=t*Math.sin(e)+s,w=(t+b)*Math.cos(e-q)+r,x=(t+b)*Math.sin(e-q)+s,y=(t+b/2)*Math.cos(e)+r,z=(t+b/2)*Math.sin(e)+s,A=(t+b)*Math.cos(e+q)+r,B=(t+b)*Math.sin(e+q)+s;this.context.beginPath(),this.context.fillStyle=c,this.context.moveTo(u,v),this.context.lineTo(w,x),this.context.quadraticCurveTo(y,z,A,B),this.context.lineTo(A,B),this.context.fill()},e.prototype.get=function(a){var b={};switch(a){case"blackarrow":b={branch:{color:"#000000",lineWidth:4,spacingX:50,mergeStyle:"straight",labelRotation:0},commit:{spacingY:-60,dot:{size:12,strokeColor:"#000000",strokeWidth:7},message:{color:"black"}},arrow:{size:16,offset:2.5}};break;case"metro":default:b={colors:["#979797","#008fb5","#f1c109"],branch:{lineWidth:10,spacingX:50,labelRotation:0},commit:{spacingY:-80,dot:{size:14},message:{font:"normal 14pt Arial"}}}}return new e(b)},Array.prototype.every||(Array.prototype.every=function(a,b){var c,d;if(null===this)throw new TypeError("this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError;for(arguments.length>1&&(c=b),d=0;dProperties
Source:
@@ -558,7 +558,7 @@
Parameters:
Source:
@@ -672,7 +672,7 @@
This:
Source:
@@ -757,7 +757,7 @@
This:
Source:
@@ -967,7 +967,7 @@
Properties
Source:
@@ -1059,7 +1059,7 @@
This:
Source:
@@ -1322,7 +1322,7 @@
Properties
Source:
@@ -1437,7 +1437,7 @@
This:
Source:
@@ -1522,7 +1522,7 @@
This:
Source:
@@ -1831,7 +1831,7 @@
Properties
Source:
@@ -1886,7 +1886,7 @@

Home

Classes

  • diff --git a/docs/Commit.html b/docs/Commit.html index 5b20a5a2..605ccc62 100644 --- a/docs/Commit.html +++ b/docs/Commit.html @@ -1387,7 +1387,7 @@
    Properties
    Source:
    @@ -1490,7 +1490,7 @@
    This:
    Source:
    @@ -1575,7 +1575,7 @@
    This:
    Source:
    @@ -1623,7 +1623,7 @@

    Home

    Classes

    • diff --git a/docs/GitGraph.html b/docs/GitGraph.html index 61c9b4f0..21074903 100644 --- a/docs/GitGraph.html +++ b/docs/GitGraph.html @@ -1052,7 +1052,7 @@
      Parameters:
      Source:
      @@ -2061,7 +2061,7 @@

      Home

      Classes

      • diff --git a/docs/Tag.html b/docs/Tag.html index 78bf15a1..6b91a8c2 100644 --- a/docs/Tag.html +++ b/docs/Tag.html @@ -294,7 +294,7 @@
        Properties
        Source:
        @@ -374,7 +374,7 @@

        Home

        Classes

        • diff --git a/docs/Template.html b/docs/Template.html index 26261f1b..1aaa7313 100644 --- a/docs/Template.html +++ b/docs/Template.html @@ -1180,7 +1180,7 @@
          Properties
          Source:
          @@ -1329,7 +1329,7 @@
          Parameters:
          Source:
          @@ -1399,7 +1399,7 @@

          Home

          Classes

          • diff --git a/docs/gitgraph.js.html b/docs/gitgraph.js.html index ca0e6e00..1dcd7526 100644 --- a/docs/gitgraph.js.html +++ b/docs/gitgraph.js.html @@ -403,14 +403,8 @@

            Source: gitgraph.js

            return; } - // Fix firefox MouseEvent - if (typeof InstallTrigger !== "undefined") /* == (is Firefox) */ { - event.x = event.x ? event.x : event.clientX; - event.y = event.y ? event.y : event.clientY; - } - - self.tooltip.style.left = event.x + "px"; // TODO Scroll bug - self.tooltip.style.top = event.y + "px"; // TODO Scroll bug + self.tooltip.style.left = event.clientX + "px"; // TODO Scroll bug + self.tooltip.style.top = event.clientY + "px"; // TODO Scroll bug if (self.template.commit.tooltipHTMLFormatter !== null) { self.tooltip.innerHTML = self.template.commit.tooltipHTMLFormatter(commit); } else { @@ -1876,7 +1870,7 @@

            Home

            Classes

            • diff --git a/docs/global.html b/docs/global.html index 0c2d0c2b..2fecc1ba 100644 --- a/docs/global.html +++ b/docs/global.html @@ -1170,7 +1170,7 @@
              Properties:
              Source:
              @@ -1514,7 +1514,7 @@

              Home

              Classes

              • diff --git a/docs/index.html b/docs/index.html index 4352c038..df93be28 100644 --- a/docs/index.html +++ b/docs/index.html @@ -115,7 +115,7 @@

                Home

                Classes

                • diff --git a/examples/gitflowsupport.js b/examples/gitflowsupport.js index c6035b33..d78c8316 100644 --- a/examples/gitflowsupport.js +++ b/examples/gitflowsupport.js @@ -1,4 +1,5 @@ var graphConfig = new GitGraph.Template({ + colors: [ "#9993FF", "#47E8D4", "#6BDB52", "#F85BB5", "#FFA657", "#F85BB5" ], branch: { color: "#000000", lineWidth: 3, @@ -58,6 +59,7 @@ var featureCol = 0; var developCol = 1; var releaseCol = 2; var supportCol = 3; +var support2Col = 5; var masterCol = 4; var gitgraph = new GitGraph(config); @@ -114,31 +116,34 @@ develop.commit({ messageDisplay: false }); release_100.commit(stabilizationCommit); -release_100.merge(develop).merge(master, { +release_100.merge(master, { dotStrokeWidth: 10, message: "Release v1.0.0 tagged", tag: "v1.0.0" }); +master.merge(develop); var support_10x = gitgraph.branch({ parentBranch: master, name: "support/v1.0.x", column: supportCol }); + support_10x.commit({ message: "Start v1.0.1-rc Release Candidate builds", tag: "v1.0.1-rc", tagColor: 'gray' }).commit(bugFixCommit); +develop.commit({ + messageDisplay: false +}); var feature3 = gitgraph.branch({ parentBranch: develop, name: "feature/3", column: featureCol }); -develop.commit({ - messageDisplay: false -}); + feature3.commit("A feature to go into v1.1.0").commit({ messageDisplay: false }); @@ -179,11 +184,12 @@ release_110.commit({ tagColor: 'gray' }) release_110.commit(stabilizationCommit); -release_110.merge(develop).merge(master, { +release_110.merge(master, { dotStrokeWidth: 10, message: "Release v1.1.0 tagged", tag: "v1.1.0" }); +master.merge(develop); var support_11x = gitgraph.branch({ parentBranch: master, @@ -213,7 +219,7 @@ var feature4 = gitgraph.branch({ develop.commit({ messageDisplay: false }); -feature4.commit("A feature to go into v1.2.0").commit({ +feature4.commit("A feature to go into v2.0.0").commit({ messageDisplay: false }); feature4.merge(develop); @@ -246,37 +252,82 @@ feature5.commit("Another feature to go into v1.2.0").commit({ }); feature5.merge(develop); -support_11x.commit({ - message: "Start v1.1.3-rc Release Candidate builds", - tag: "v1.1.3-rc", +develop.commit({ + messageDisplay: false +}); + +var release_200 = gitgraph.branch({ + parentBranch: develop, + name: "release/v2.0.0", + column: releaseCol +}); +release_200.commit({ + message: "Start v2.0.0-rc Release Candidate builds", + tag: "v2.0.0-rc", tagColor: 'gray' }) -support_11x.commit(bugFixCommit).commit({ +release_200.commit(stabilizationCommit); +release_200.merge(master, { dotStrokeWidth: 10, - message: "Release v1.1.3 tagged", - tag: "v1.1.3" + message: "Release v2.0.0 tagged", + tag: "v2.0.0" }); -support_11x.merge(develop); +master.merge(develop); develop.commit({ messageDisplay: false }); +support_11x.commit({ + message: "Release v1.1.3-rc tagged", + tag: "1.1.3-rc", + tagColor: 'gray' +}); -var release_120 = gitgraph.branch({ +var feature6 = gitgraph.branch({ parentBranch: develop, - name: "release/v1.2.0", + name: "feature/6", + column: featureCol +}); +feature6.commit("Feature to go into v2.0.0").commit({ + messageDisplay: false +}); +var support_20x = gitgraph.branch({ + parentBranch: master, + name: "support/v2.0.x", + column: support2Col +}); +support_20x.commit({ + message: "Release v2.0.1-rc tagged", + tag: "v2.0.1-rc", + tagColor: 'gray' +}); +support_20x.commit().commit({ + dotStrokeWidth: 10, + message: "Release v2.0.1 tagged", + tag: "v2.0.1" +}); +support_20x.merge(develop); +support_11x.commit(); +support_11x.commit({ + dotStrokeWidth: 10, + message: "Release v1.1.3 tagged", + tag: "v1.1.3" +}); +feature6.merge(develop); + +var release_210 = gitgraph.branch({ + parentBranch: develop, + name: "release/v2.1.0", column: releaseCol }); -release_120.commit({ - message: "Start v1.2.0-rc Release Candidate builds", - tag: "v1.2.0-rc", +release_210.commit({ + message: "Start v2.1.0-rc Release Candidate builds", + tag: "v2.1.0-rc", tagColor: 'gray' }) -release_120.commit(stabilizationCommit); -release_120.merge(develop).merge(master, { +release_210.commit(stabilizationCommit); +release_210.merge(master, { dotStrokeWidth: 10, - message: "Release v1.2.0 tagged", - tag: "v1.2.0" -}); -develop.commit({ - messageDisplay: false + message: "Release v2.1.0 tagged", + tag: "v2.1.0" }); +master.merge(develop); diff --git a/package.json b/package.json index 9ad76c74..087b1e1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitgraph.js", - "version": "1.11.1", + "version": "1.11.2", "author": "Nicolas Carlo ", "description": "A JavaScript library to draw pretty git graphs in the browser", "contributors": [ diff --git a/src/gitgraph.js b/src/gitgraph.js index 05d8354d..4616e5bf 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -375,14 +375,8 @@ return; } - // Fix firefox MouseEvent - if (typeof InstallTrigger !== "undefined") /* == (is Firefox) */ { - event.x = event.x ? event.x : event.clientX; - event.y = event.y ? event.y : event.clientY; - } - - self.tooltip.style.left = event.x + "px"; // TODO Scroll bug - self.tooltip.style.top = event.y + "px"; // TODO Scroll bug + self.tooltip.style.left = event.clientX + "px"; // TODO Scroll bug + self.tooltip.style.top = event.clientY + "px"; // TODO Scroll bug if (self.template.commit.tooltipHTMLFormatter !== null) { self.tooltip.innerHTML = self.template.commit.tooltipHTMLFormatter(commit); } else {