From e9409dd169b8a67422d24e4c2399ed50785e64f4 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Thu, 6 Apr 2017 11:50:42 +0200 Subject: [PATCH 1/4] Add types definition to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index f6275854..be96204e 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ } ], "main": "./src/gitgraph.js", + "types": "./build/gitgraph.d.ts", "repository": { "type": "git", "url": "https://github.com/nicoespeon/gitgraph.js" From a15a6751a9565a44e6713d71d28c5bd4befd60ae Mon Sep 17 00:00:00 2001 From: Gek Siong Low Date: Wed, 12 Apr 2017 00:12:51 +0800 Subject: [PATCH 2/4] Fix incorrect font height in labels and tags when percent width is used --- src/gitgraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index 231f299d..a2b0650a 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -1601,7 +1601,7 @@ var dummyText = document.createTextNode("Mg"); dummy.appendChild(dummyText); - dummy.setAttribute("style", "font: " + font + ";"); + dummy.setAttribute("style", "font: " + font + "; display: inline-block;"); body.appendChild(dummy); var fontHeight = dummy.offsetHeight; body.removeChild(dummy); From 3ac6bc213fbbe039b19dd5ab37381508bdc5cfcd Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Wed, 19 Apr 2017 08:14:27 +0200 Subject: [PATCH 3/4] Fix details left positionning Left offset should not depend on the x of the related commit. Give a better name to magic strings. Close #145 --- src/gitgraph.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index a2b0650a..af2a315b 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -622,9 +622,9 @@ /** * Branch commit options - * + * * @typedef {object} BranchCommitOptions - * + * * @property {string} [color] - Master color (dot & message) * @property {string} [author = this.parent.author] - Author name & email * @property {string} [date] - Date of commit, default is now @@ -1184,17 +1184,18 @@ } // Detail + var DETAIL_OFFSET_LEFT_IN_PX = 60; + var DETAIL_OFFSET_TOP_IN_PX = 30; + if (this.detail !== null && _isVertical(this.parent)) { - this.detail.width = 30; - this.detail.style.left = this.parent.canvas.offsetLeft + commitOffsetLeft + this.x + this.detail.width + "px"; + this.detail.style.left = this.parent.canvas.offsetLeft + commitOffsetLeft + DETAIL_OFFSET_LEFT_IN_PX + "px"; - var detailOffsetTop = (this.parent.canvas.offsetTop + this.y); - var detailHorizontalMargin = 30; + var detailPositionTop = (this.parent.canvas.offsetTop + this.y); if (this.parent.orientation === "vertical-reverse") { - var clientOffset = (this.parent.canvas.clientHeight - this.detail.clientHeight); - this.detail.style.top = detailOffsetTop + clientOffset - detailHorizontalMargin + "px"; + var clientHeight = (this.parent.canvas.clientHeight - this.detail.clientHeight); + this.detail.style.top = detailPositionTop + clientHeight - DETAIL_OFFSET_TOP_IN_PX + "px"; } else { - this.detail.style.top = detailOffsetTop + detailHorizontalMargin + "px"; + this.detail.style.top = detailPositionTop + DETAIL_OFFSET_TOP_IN_PX + "px"; } } From 4d9403c7e31cb90b8369744f02ffe1de5bff5cf9 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Wed, 19 Apr 2017 08:57:09 +0200 Subject: [PATCH 4/4] Bump version and compile --- bower.json | 2 +- build/gitgraph.js | 23 ++++++++++++----------- build/gitgraph.min.js | 4 ++-- docs/Branch.html | 2 +- docs/Commit.html | 4 ++-- docs/GitGraph.html | 2 +- docs/Tag.html | 4 ++-- docs/Template.html | 6 +++--- docs/gitgraph.js.html | 23 ++++++++++++----------- docs/global.html | 2 +- docs/index.html | 2 +- package.json | 2 +- 12 files changed, 39 insertions(+), 37 deletions(-) diff --git a/bower.json b/bower.json index 1c6a50b8..f8e5b80d 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "gitgraph.js", - "version": "1.10.0", + "version": "1.10.1", "main": [ "./build/gitgraph.js", "./build/gitgraph.css" diff --git a/build/gitgraph.js b/build/gitgraph.js index c07e7ff6..a478b73e 100644 --- a/build/gitgraph.js +++ b/build/gitgraph.js @@ -1,5 +1,5 @@ /* ========================================================== - * GitGraph v1.10.0 + * GitGraph v1.10.1 * https://github.com/nicoespeon/gitgraph.js * ========================================================== * Copyright (c) 2017 Nicolas CARLO (@nicoespeon) ٩(^‿^)۶ @@ -632,9 +632,9 @@ /** * Branch commit options - * + * * @typedef {object} BranchCommitOptions - * + * * @property {string} [color] - Master color (dot & message) * @property {string} [author = this.parent.author] - Author name & email * @property {string} [date] - Date of commit, default is now @@ -1194,17 +1194,18 @@ } // Detail + var DETAIL_OFFSET_LEFT_IN_PX = 60; + var DETAIL_OFFSET_TOP_IN_PX = 30; + if (this.detail !== null && _isVertical(this.parent)) { - this.detail.width = 30; - this.detail.style.left = this.parent.canvas.offsetLeft + commitOffsetLeft + this.x + this.detail.width + "px"; + this.detail.style.left = this.parent.canvas.offsetLeft + commitOffsetLeft + DETAIL_OFFSET_LEFT_IN_PX + "px"; - var detailOffsetTop = (this.parent.canvas.offsetTop + this.y); - var detailHorizontalMargin = 30; + var detailPositionTop = (this.parent.canvas.offsetTop + this.y); if (this.parent.orientation === "vertical-reverse") { - var clientOffset = (this.parent.canvas.clientHeight - this.detail.clientHeight); - this.detail.style.top = detailOffsetTop + clientOffset - detailHorizontalMargin + "px"; + var clientHeight = (this.parent.canvas.clientHeight - this.detail.clientHeight); + this.detail.style.top = detailPositionTop + clientHeight - DETAIL_OFFSET_TOP_IN_PX + "px"; } else { - this.detail.style.top = detailOffsetTop + detailHorizontalMargin + "px"; + this.detail.style.top = detailPositionTop + DETAIL_OFFSET_TOP_IN_PX + "px"; } } @@ -1611,7 +1612,7 @@ var dummyText = document.createTextNode("Mg"); dummy.appendChild(dummyText); - dummy.setAttribute("style", "font: " + font + ";"); + dummy.setAttribute("style", "font: " + font + "; display: inline-block;"); body.appendChild(dummy); var fontHeight = dummy.offsetHeight; body.removeChild(dummy); diff --git a/build/gitgraph.min.js b/build/gitgraph.min.js index e08efaf0..7ff42385 100644 --- a/build/gitgraph.min.js +++ b/build/gitgraph.min.js @@ -1,5 +1,5 @@ /* ========================================================== - * GitGraph v1.10.0 + * GitGraph v1.10.1 * 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.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.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+";"),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))0){this.pushPath({x:this.startPoint.x-this.parentBranch.offsetX+this.offsetX-this.template.commit.spacingX,y:this.startPoint.y-this.parentBranch.offsetY+this.offsetY-this.template.commit.spacingY,type:"join"});var n=i(this.startPoint);n.type="join",this.parentBranch.pushPath(n)}}else k&&(m.type="start");return this.pushPath(m),this.parent.commitOffsetX+=this.template.commit.spacingX*(a.showLabel?2:1),this.parent.commitOffsetY+=this.template.commit.spacingY*(a.showLabel?2:1),null!==l.detail&&o(this.parent)&&(l.detail.style.display="block","vertical-reverse"===this.parent.orientation?this.parent.commitOffsetY+=l.detail.clientHeight:this.parent.commitOffsetY-=l.detail.clientHeight),this.parent.render(),this},b.prototype.tag=function(a){"string"==typeof a&&(a={tag:a}),a=q(a)?a:{};var b=f(this.commits);return q(b)&&(g(b,a),this.parent.render()),this},b.prototype.checkout=function(){this.parent.HEAD=this},b.prototype.delete=function(){this.isDeleted=!0},b.prototype.merge=function(a,c){var d=a||this.parent.HEAD;if(d instanceof b==!1||d===this)return this;var e=this.commits[0];if(!e)return console.log(this.name+" is already up-to-date with "+d.name),this;var g="Merge branch `"+this.name+"` into `"+d.name+"`";if("object"!=typeof c){var j=c;c={},c.message="string"==typeof j?j:g}else c.message=c.message||g;c.type="mergeCommit",c.parentCommit=h(this);var k=e.parentCommit,l=h(d),m=k&&k.sha1===l.sha1;if(c.fastForward&&m){var n=p(this.parent);if(this.color=d.color,n){var o=d.path[1].y;this.path.forEach(function(a){a.y=o})}else{var q=d.path[1].x;this.path.forEach(function(a){a.x=q})}this.commits.forEach(function(a){n?a.y=k.y:a.x=k.x,a.labelColor=k.labelColor,a.messageColor=k.messageColor,a.dotColor=k.dotColor,a.dotStrokeColor=k.dotStrokeColor})}else{d.commit(c);var r=f(d.commits),s={x:this.offsetX+this.template.commit.spacingX*(r.showLabel?3:2)-this.parent.commitOffsetX,y:this.offsetY+this.template.commit.spacingY*(r.showLabel?3:2)-this.parent.commitOffsetY,type:"join"};this.pushPath(i(s));var t={x:r.x,y:r.y,type:"end"};this.pushPath(t),s.type="start",this.pushPath(s)}return this.parent.render(),this.parent.HEAD=d,this},b.prototype.calculColumn=function(){for(var a,b=[],c=0;a=this.parent.branches[c];c++)a.isDeleted||(a.column in b||(b[a.column]=0),b[a.column]++);for(this.column=0;this.column in b&&0!==b[this.column];this.column++);},b.prototype.pushPath=function(a){var b=f(this.path);b?b.x===a.x&&b.y===a.y?"start"!==b.type&&"end"===a.type?b.type="end":"join"===a.type||this.path.push(a):"join"===a.type?(a.x-b.x)*this.template.commit.spacingX<0?this.path.push(a):(a.y-b.y)*this.template.commit.spacingY<0&&this.path.push(a):this.path.push(a):this.path.push(a)},c.prototype.render=function(){var a=this.template.commit.tag.spacingX,b=(this.parent.columnMax+1)*this.template.branch.spacingX+a;if(this.showLabel)if(p(this.parent)&&this.template.branch.labelRotation%180==0){var e=this.y-this.dotSize-j(this.labelFont);l(this.context,this.x,e,this.branch.name,this.labelColor,this.labelFont,this.template.branch.labelRotation,!0)}else l(this.context,this.x+this.template.commit.spacingX,this.y+this.template.commit.spacingY,this.branch.name,this.labelColor,this.labelFont,this.template.branch.labelRotation,!0);if(this.context.beginPath(),this.context.arc(this.x,this.y,this.dotSize,0,2*Math.PI,!1),this.context.fillStyle=this.dotColor,this.context.strokeStyle=this.dotStrokeColor,this.context.lineWidth=this.dotStrokeWidth,"number"==typeof this.dotStrokeWidth&&this.context.stroke(),this.context.fill(),this.context.closePath(),this.arrowDisplay&&this.parentCommit instanceof c&&this.arrow(),null!==this.tag){b+=new d(this,{color:this.tagColor,font:this.tagFont}).width-a}if(null!==this.detail&&o(this.parent)){this.detail.width=30,this.detail.style.left=this.parent.canvas.offsetLeft+b+this.x+this.detail.width+"px";var f=this.parent.canvas.offsetTop+this.y,g=30;if("vertical-reverse"===this.parent.orientation){var h=this.parent.canvas.clientHeight-this.detail.clientHeight;this.detail.style.top=f+h-g+"px"}else this.detail.style.top=f+g+"px"}if(this.messageDisplay){var i=this.message;this.messageHashDisplay&&(i=this.sha1+" "+i),this.messageAuthorDisplay&&(i+=this.author?" - "+this.author:""),this.messageBranchDisplay&&(i=(this.branch.name?"["+this.branch.name+"] ":"")+i),this.context.font=this.messageFont,this.context.fillStyle=this.messageColor,this.context.fillText(i,b,this.y+this.dotSize/2)}},c.prototype.arrow=function(){function a(a,b){var c=d?-1:1;return Math.atan2(c*a,c*b)}var b=this.template.arrow.size,c=this.template.arrow.color||this.branch.color,d=this.parent.reverseArrow,e=a(this.parentCommit.y-this.y,this.parentCommit.x-this.x),f=this===this.branch.commits[0];if("mergeCommit"===this.type||f){var g=this.parentCommit.branch.column-this.branch.column,h=this.showLabel?2:1,i=this.template.branch.spacingX*g+this.template.commit.spacingX*h,j=(f||d)&&Math.abs(this.y-this.parentCommit.y)>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.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.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))0){this.pushPath({x:this.startPoint.x-this.parentBranch.offsetX+this.offsetX-this.template.commit.spacingX,y:this.startPoint.y-this.parentBranch.offsetY+this.offsetY-this.template.commit.spacingY,type:"join"});var n=i(this.startPoint);n.type="join",this.parentBranch.pushPath(n)}}else k&&(m.type="start");return this.pushPath(m),this.parent.commitOffsetX+=this.template.commit.spacingX*(a.showLabel?2:1),this.parent.commitOffsetY+=this.template.commit.spacingY*(a.showLabel?2:1),null!==l.detail&&o(this.parent)&&(l.detail.style.display="block","vertical-reverse"===this.parent.orientation?this.parent.commitOffsetY+=l.detail.clientHeight:this.parent.commitOffsetY-=l.detail.clientHeight),this.parent.render(),this},b.prototype.tag=function(a){"string"==typeof a&&(a={tag:a}),a=q(a)?a:{};var b=f(this.commits);return q(b)&&(g(b,a),this.parent.render()),this},b.prototype.checkout=function(){this.parent.HEAD=this},b.prototype.delete=function(){this.isDeleted=!0},b.prototype.merge=function(a,c){var d=a||this.parent.HEAD;if(d instanceof b==!1||d===this)return this;var e=this.commits[0];if(!e)return console.log(this.name+" is already up-to-date with "+d.name),this;var g="Merge branch `"+this.name+"` into `"+d.name+"`";if("object"!=typeof c){var j=c;c={},c.message="string"==typeof j?j:g}else c.message=c.message||g;c.type="mergeCommit",c.parentCommit=h(this);var k=e.parentCommit,l=h(d),m=k&&k.sha1===l.sha1;if(c.fastForward&&m){var n=p(this.parent);if(this.color=d.color,n){var o=d.path[1].y;this.path.forEach(function(a){a.y=o})}else{var q=d.path[1].x;this.path.forEach(function(a){a.x=q})}this.commits.forEach(function(a){n?a.y=k.y:a.x=k.x,a.labelColor=k.labelColor,a.messageColor=k.messageColor,a.dotColor=k.dotColor,a.dotStrokeColor=k.dotStrokeColor})}else{d.commit(c);var r=f(d.commits),s={x:this.offsetX+this.template.commit.spacingX*(r.showLabel?3:2)-this.parent.commitOffsetX,y:this.offsetY+this.template.commit.spacingY*(r.showLabel?3:2)-this.parent.commitOffsetY,type:"join"};this.pushPath(i(s));var t={x:r.x,y:r.y,type:"end"};this.pushPath(t),s.type="start",this.pushPath(s)}return this.parent.render(),this.parent.HEAD=d,this},b.prototype.calculColumn=function(){for(var a,b=[],c=0;a=this.parent.branches[c];c++)a.isDeleted||(a.column in b||(b[a.column]=0),b[a.column]++);for(this.column=0;this.column in b&&0!==b[this.column];this.column++);},b.prototype.pushPath=function(a){var b=f(this.path);b?b.x===a.x&&b.y===a.y?"start"!==b.type&&"end"===a.type?b.type="end":"join"===a.type||this.path.push(a):"join"===a.type?(a.x-b.x)*this.template.commit.spacingX<0?this.path.push(a):(a.y-b.y)*this.template.commit.spacingY<0&&this.path.push(a):this.path.push(a):this.path.push(a)},c.prototype.render=function(){var a=this.template.commit.tag.spacingX,b=(this.parent.columnMax+1)*this.template.branch.spacingX+a;if(this.showLabel)if(p(this.parent)&&this.template.branch.labelRotation%180==0){var e=this.y-this.dotSize-j(this.labelFont);l(this.context,this.x,e,this.branch.name,this.labelColor,this.labelFont,this.template.branch.labelRotation,!0)}else l(this.context,this.x+this.template.commit.spacingX,this.y+this.template.commit.spacingY,this.branch.name,this.labelColor,this.labelFont,this.template.branch.labelRotation,!0);if(this.context.beginPath(),this.context.arc(this.x,this.y,this.dotSize,0,2*Math.PI,!1),this.context.fillStyle=this.dotColor,this.context.strokeStyle=this.dotStrokeColor,this.context.lineWidth=this.dotStrokeWidth,"number"==typeof this.dotStrokeWidth&&this.context.stroke(),this.context.fill(),this.context.closePath(),this.arrowDisplay&&this.parentCommit instanceof c&&this.arrow(),null!==this.tag){b+=new d(this,{color:this.tagColor,font:this.tagFont}).width-a}var f=30;if(null!==this.detail&&o(this.parent)){this.detail.style.left=this.parent.canvas.offsetLeft+b+60+"px";var g=this.parent.canvas.offsetTop+this.y;if("vertical-reverse"===this.parent.orientation){var h=this.parent.canvas.clientHeight-this.detail.clientHeight;this.detail.style.top=g+h-f+"px"}else this.detail.style.top=g+f+"px"}if(this.messageDisplay){var i=this.message;this.messageHashDisplay&&(i=this.sha1+" "+i),this.messageAuthorDisplay&&(i+=this.author?" - "+this.author:""),this.messageBranchDisplay&&(i=(this.branch.name?"["+this.branch.name+"] ":"")+i),this.context.font=this.messageFont,this.context.fillStyle=this.messageColor,this.context.fillText(i,b,this.y+this.dotSize/2)}},c.prototype.arrow=function(){function a(a,b){var c=d?-1:1;return Math.atan2(c*a,c*b)}var b=this.template.arrow.size,c=this.template.arrow.color||this.branch.color,d=this.parent.reverseArrow,e=a(this.parentCommit.y-this.y,this.parentCommit.x-this.x),f=this===this.branch.commits[0];if("mergeCommit"===this.type||f){var g=this.parentCommit.branch.column-this.branch.column,h=this.showLabel?2:1,i=this.template.branch.spacingX*g+this.template.commit.spacingX*h,j=(f||d)&&Math.abs(this.y-this.parentCommit.y)>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;dHome

Classes

  • diff --git a/docs/Commit.html b/docs/Commit.html index 08aca191..e45486ae 100644 --- a/docs/Commit.html +++ b/docs/Commit.html @@ -1451,7 +1451,7 @@
    This:
    Source:
    @@ -1584,7 +1584,7 @@

    Home

    Classes

    • diff --git a/docs/GitGraph.html b/docs/GitGraph.html index d6fe2d70..422b0a2e 100644 --- a/docs/GitGraph.html +++ b/docs/GitGraph.html @@ -2061,7 +2061,7 @@

      Home

      Classes

      • diff --git a/docs/Tag.html b/docs/Tag.html index 17ec2c9d..7f8c1be0 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 aa67c33f..f7b99ac4 100644 --- a/docs/Template.html +++ b/docs/Template.html @@ -1106,7 +1106,7 @@
          Properties
          Source:
          @@ -1255,7 +1255,7 @@
          Parameters:
          Source:
          @@ -1325,7 +1325,7 @@

          Home

          Classes

          • diff --git a/docs/gitgraph.js.html b/docs/gitgraph.js.html index dc599444..7ce0e6e2 100644 --- a/docs/gitgraph.js.html +++ b/docs/gitgraph.js.html @@ -650,9 +650,9 @@

            Source: gitgraph.js

            /** * Branch commit options - * + * * @typedef {object} BranchCommitOptions - * + * * @property {string} [color] - Master color (dot & message) * @property {string} [author = this.parent.author] - Author name & email * @property {string} [date] - Date of commit, default is now @@ -1212,17 +1212,18 @@

            Source: gitgraph.js

            } // Detail + var DETAIL_OFFSET_LEFT_IN_PX = 60; + var DETAIL_OFFSET_TOP_IN_PX = 30; + if (this.detail !== null && _isVertical(this.parent)) { - this.detail.width = 30; - this.detail.style.left = this.parent.canvas.offsetLeft + commitOffsetLeft + this.x + this.detail.width + "px"; + this.detail.style.left = this.parent.canvas.offsetLeft + commitOffsetLeft + DETAIL_OFFSET_LEFT_IN_PX + "px"; - var detailOffsetTop = (this.parent.canvas.offsetTop + this.y); - var detailHorizontalMargin = 30; + var detailPositionTop = (this.parent.canvas.offsetTop + this.y); if (this.parent.orientation === "vertical-reverse") { - var clientOffset = (this.parent.canvas.clientHeight - this.detail.clientHeight); - this.detail.style.top = detailOffsetTop + clientOffset - detailHorizontalMargin + "px"; + var clientHeight = (this.parent.canvas.clientHeight - this.detail.clientHeight); + this.detail.style.top = detailPositionTop + clientHeight - DETAIL_OFFSET_TOP_IN_PX + "px"; } else { - this.detail.style.top = detailOffsetTop + detailHorizontalMargin + "px"; + this.detail.style.top = detailPositionTop + DETAIL_OFFSET_TOP_IN_PX + "px"; } } @@ -1629,7 +1630,7 @@

            Source: gitgraph.js

            var dummyText = document.createTextNode("Mg"); dummy.appendChild(dummyText); - dummy.setAttribute("style", "font: " + font + ";"); + dummy.setAttribute("style", "font: " + font + "; display: inline-block;"); body.appendChild(dummy); var fontHeight = dummy.offsetHeight; body.removeChild(dummy); @@ -1871,7 +1872,7 @@

            Home

            Classes

            • diff --git a/docs/global.html b/docs/global.html index 2eecd730..ed812544 100644 --- a/docs/global.html +++ b/docs/global.html @@ -1514,7 +1514,7 @@

              Home

              Classes

              • diff --git a/docs/index.html b/docs/index.html index b9e118f9..a16ce0de 100644 --- a/docs/index.html +++ b/docs/index.html @@ -115,7 +115,7 @@

                Home

                Classes

                • diff --git a/package.json b/package.json index be96204e..78b739c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitgraph.js", - "version": "1.10.0", + "version": "1.10.1", "author": "Nicolas Carlo ", "description": "A JavaScript library to draw pretty git graphs in the browser", "contributors": [