frappe-gantt
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -89,2 +89,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
self.trigger_event = trigger_event; | ||
self.refresh = refresh; | ||
@@ -110,8 +111,14 @@ // initialize with default view mode | ||
view_mode: 'Day', | ||
date_format: 'YYYY-MM-DD' | ||
date_format: 'YYYY-MM-DD', | ||
custom_popup_html: null | ||
}; | ||
self.config = Object.assign({}, defaults, config); | ||
reset_variables(tasks); | ||
} | ||
function reset_variables(tasks) { | ||
self.element = element; | ||
self._tasks = tasks; | ||
self.config = Object.assign({}, defaults, config); | ||
@@ -123,2 +130,7 @@ self._bars = []; | ||
function refresh(updated_tasks) { | ||
reset_variables(updated_tasks); | ||
change_view_mode(self.config.view_mode); | ||
} | ||
function change_view_mode(mode) { | ||
@@ -180,2 +192,8 @@ set_scale(mode); | ||
} | ||
// uids | ||
if (!task.id) { | ||
task.id = generate_id(task); | ||
} | ||
return task; | ||
@@ -238,2 +256,4 @@ }); | ||
function prepare_dates() { | ||
self.gantt_start = self.gantt_end = null; | ||
var _iteratorNormalCompletion3 = true; | ||
@@ -244,3 +264,2 @@ var _didIteratorError3 = false; | ||
try { | ||
for (var _iterator3 = self.tasks[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
@@ -277,2 +296,3 @@ var task = _step3.value; | ||
function prepare_canvas() { | ||
if (self.canvas) return; | ||
self.canvas = Snap(self.element).addClass('gantt'); | ||
@@ -382,3 +402,3 @@ } | ||
var cur_width = self.canvas.node.getBoundingClientRect().width; | ||
var actual_width = self.canvas.getBBox().width; | ||
var actual_width = self.canvas.select('#grid .grid-row').attr('width'); | ||
if (cur_width < actual_width) { | ||
@@ -593,6 +613,6 @@ self.canvas.attr('width', actual_width); | ||
'Day_lower': date.date() !== last_date.date() ? date.format('D') : '', | ||
'Week_lower': 'Week ' + date.format('W'), | ||
'Week_lower': date.month() !== last_date.month() ? date.format('D MMM') : date.format('D'), | ||
'Month_lower': date.format('MMMM'), | ||
'Quarter Day_upper': date.date() !== last_date.date() ? date.format('D MMM') : '', | ||
'Half Day_upper': date.date() !== last_date.date() ? date.format('D MMM') : '', | ||
'Half Day_upper': date.date() !== last_date.date() ? date.month() !== last_date.month() ? date.format('D MMM') : date.format('D') : '', | ||
'Day_upper': date.month() !== last_date.month() ? date.format('MMMM') : '', | ||
@@ -616,5 +636,5 @@ 'Week_upper': date.month() !== last_date.month() ? date.format('MMMM') : '', | ||
'Day_upper': self.config.column_width * 30 / 2, | ||
'Week_lower': self.config.column_width / 2, | ||
'Week_lower': 0, | ||
'Week_upper': self.config.column_width * 4 / 2, | ||
'Month_lower': date.daysInMonth() * self.config.column_width / 30 / 2, | ||
'Month_lower': self.config.column_width / 2, | ||
'Month_upper': self.config.column_width * 12 / 2 | ||
@@ -779,2 +799,6 @@ }; | ||
function generate_id(task) { | ||
return task.name + '_' + Math.random().toString(36).slice(2, 12); | ||
} | ||
function trigger_event(event, args) { | ||
@@ -834,3 +858,3 @@ if (self.config['on_' + event]) { | ||
// module | ||
exports.push([module.id, ".gantt .grid-background {\n fill: none; }\n\n.gantt .grid-header {\n fill: #ffffff;\n stroke: #e0e0e0;\n stroke-width: 1.4; }\n\n.gantt .grid-row {\n fill: #ffffff; }\n\n.gantt .grid-row:nth-child(even) {\n fill: #f5f5f5; }\n\n.gantt .row-line {\n stroke: #ebeff2; }\n\n.gantt .tick {\n stroke: #e0e0e0;\n stroke-width: 0.2; }\n .gantt .tick.thick {\n stroke-width: 0.4; }\n\n.gantt .today-highlight {\n fill: #fcf8e3;\n opacity: 0.5; }\n\n.gantt #arrow {\n fill: none;\n stroke: #666;\n stroke-width: 1.4; }\n\n.gantt .bar {\n fill: #b8c2cc;\n stroke: #8D99A6;\n stroke-width: 0;\n transition: stroke-width .3s ease; }\n\n.gantt .bar-progress {\n fill: #a3a3ff; }\n\n.gantt .bar-invalid {\n fill: transparent;\n stroke: #8D99A6;\n stroke-width: 1;\n stroke-dasharray: 5; }\n .gantt .bar-invalid ~ .bar-label {\n fill: #555; }\n\n.gantt .bar-label {\n fill: #fff;\n dominant-baseline: central;\n text-anchor: middle;\n font-size: 12px;\n font-weight: lighter;\n letter-spacing: 0.8px; }\n .gantt .bar-label.big {\n fill: #555;\n text-anchor: start; }\n\n.gantt .handle {\n fill: #ddd;\n cursor: ew-resize;\n opacity: 0;\n visibility: hidden;\n transition: opacity .3s ease; }\n\n.gantt .bar-wrapper {\n cursor: pointer; }\n .gantt .bar-wrapper:hover .bar {\n stroke-width: 2; }\n .gantt .bar-wrapper:hover .handle {\n visibility: visible;\n opacity: 1; }\n .gantt .bar-wrapper.active .bar {\n stroke-width: 2; }\n\n.gantt .primary-text, .gantt .secondary-text {\n font-size: 12px;\n text-anchor: middle; }\n\n.gantt .primary-text {\n fill: #555; }\n\n.gantt .secondary-text {\n fill: #333; }\n\n.gantt #details {\n font-size: 14; }\n .gantt #details .details-container {\n stroke: #e0e0e0;\n stroke-width: 1.1;\n fill: #fff; }\n .gantt #details .details-heading {\n fill: #333;\n font-weight: 500; }\n .gantt #details .details-body {\n fill: #555; }\n\n.gantt .hide {\n display: none; }\n", "", {"version":3,"sources":["/./src/src/gantt.scss"],"names":[],"mappings":"AAYA;EAGE,WAAU,EACV;;AAJF;EAME,cAAa;EACb,gBAjBoB;EAkBpB,kBAAiB,EACjB;;AATF;EAWE,cAAa,EACb;;AAZF;EAcE,cAvBgB,EAwBhB;;AAfF;EAiBE,gBAzB0B,EA0B1B;;AAlBF;EAoBE,gBA9BoB;EA+BpB,kBAAiB,EAIjB;EAzBF;IAuBG,kBAAiB,EACjB;;AAxBH;EA2BE,cAlCoB;EAmCpB,aAAY,EACZ;;AA7BF;EAgCE,WAAU;EACV,aAvCe;EAwCf,kBAAiB,EACjB;;AAnCF;EAsCE,cAlDiB;EAmDjB,gBAlDkB;EAmDlB,gBAAe;EACf,kCAAiC,EACjC;;AA1CF;EA4CE,cA/CY,EAgDZ;;AA7CF;EA+CE,kBAAiB;EACjB,gBA3DkB;EA4DlB,gBAAe;EACf,oBAAmB,EAKnB;EAvDF;IAqDG,WA1Dc,EA2Dd;;AAtDH;EAyDE,WAAU;EACV,2BAA0B;EAC1B,oBAAmB;EACnB,gBAAe;EACf,qBAAoB;EACpB,sBAAqB,EAMrB;EApEF;IAiEG,WAtEc;IAuEd,mBAAkB,EAClB;;AAnEH;EAuEE,WAzEiB;EA0EjB,kBAAiB;EACjB,WAAU;EACV,mBAAkB;EAClB,6BAA4B,EAC5B;;AA5EF;EA+EE,gBAAe,EAkBf;EAjGF;IAmFI,gBAAe,EACf;EApFJ;IAuFI,oBAAmB;IACnB,WAAU,EACV;EAzFJ;IA8FI,gBAAe,EACf;;AA/FJ;EAoGE,gBAAe;EACf,oBAAmB,EACnB;;AAtGF;EAwGE,WA7Ge,EA8Gf;;AAzGF;EA2GE,WA/Ge,EAgHf;;AA5GF;EA+GE,cAAa,EAcb;EA7HF;IAkHG,gBA5HmB;IA6HnB,kBAAiB;IACjB,WAAU,EACV;EArHH;IAuHG,WA3Hc;IA4Hd,iBAAgB,EAChB;EAzHH;IA2HG,WAhIc,EAiId;;AA5HH;EAgIE,cAAa,EACb","file":"gantt.scss","sourcesContent":["$bar-color: #b8c2cc;\n$bar-stroke: #8D99A6;\n$border-color: #e0e0e0;\n$light-bg: #f5f5f5;\n$light-border-color: #ebeff2;\n$light-yellow: #fcf8e3;\n$text-muted: #666;\n$text-light: #555;\n$text-color: #333;\n$blue: #a3a3ff;\n$handle-color: #ddd;\n\n.gantt {\n\n\t.grid-background {\n\t\tfill: none;\n\t}\n\t.grid-header {\n\t\tfill: #ffffff;\n\t\tstroke: $border-color;\n\t\tstroke-width: 1.4;\n\t}\n\t.grid-row {\n\t\tfill: #ffffff;\n\t}\n\t.grid-row:nth-child(even) {\n\t\tfill: $light-bg;\n\t}\n\t.row-line {\n\t\tstroke: $light-border-color;\n\t}\n\t.tick {\n\t\tstroke: $border-color;\n\t\tstroke-width: 0.2;\n\t\t&.thick {\n\t\t\tstroke-width: 0.4;\n\t\t}\n\t}\n\t.today-highlight {\n\t\tfill: $light-yellow;\n\t\topacity: 0.5;\n\t}\n\n\t#arrow {\n\t\tfill: none;\n\t\tstroke: $text-muted;\n\t\tstroke-width: 1.4;\n\t}\n\n\t.bar {\n\t\tfill: $bar-color;\n\t\tstroke: $bar-stroke;\n\t\tstroke-width: 0;\n\t\ttransition: stroke-width .3s ease;\n\t}\n\t.bar-progress {\n\t\tfill: $blue;\n\t}\n\t.bar-invalid {\n\t\tfill: transparent;\n\t\tstroke: $bar-stroke;\n\t\tstroke-width: 1;\n\t\tstroke-dasharray: 5;\n\n\t\t&~.bar-label {\n\t\t\tfill: $text-light;\n\t\t}\n\t}\n\t.bar-label {\n\t\tfill: #fff;\n\t\tdominant-baseline: central;\n\t\ttext-anchor: middle;\n\t\tfont-size: 12px;\n\t\tfont-weight: lighter;\n\t\tletter-spacing: 0.8px;\n\n\t\t&.big {\n\t\t\tfill: $text-light;\n\t\t\ttext-anchor: start;\n\t\t}\n\t}\n\n\t.handle {\n\t\tfill: $handle-color;\n\t\tcursor: ew-resize;\n\t\topacity: 0;\n\t\tvisibility: hidden;\n\t\ttransition: opacity .3s ease;\n\t}\n\n\t.bar-wrapper {\n\t\tcursor: pointer;\n\n\t\t&:hover {\n\t\t\t.bar {\n\t\t\t\tstroke-width: 2;\n\t\t\t}\n\n\t\t\t.handle {\n\t\t\t\tvisibility: visible;\n\t\t\t\topacity: 1;\n\t\t\t}\n\t\t}\n\n\t\t&.active {\n\t\t\t.bar {\n\t\t\t\tstroke-width: 2;\n\t\t\t}\n\t\t}\n\t}\n\n\t.primary-text, .secondary-text {\n\t\tfont-size: 12px;\n\t\ttext-anchor: middle;\n\t}\n\t.primary-text {\n\t\tfill: $text-light;\n\t}\n\t.secondary-text {\n\t\tfill: $text-color;\n\t}\n\n\t#details {\n\t\tfont-size: 14;\n\n\t\t.details-container {\n\t\t\tstroke: $border-color;\n\t\t\tstroke-width: 1.1;\n\t\t\tfill: #fff;\n\t\t}\n\t\t.details-heading {\n\t\t\tfill: $text-color;\n\t\t\tfont-weight: 500;\n\t\t}\n\t\t.details-body {\n\t\t\tfill: $text-light;\n\t\t}\n\t}\n\n\t.hide {\n\t\tdisplay: none;\n\t}\n}"],"sourceRoot":"webpack://"}]); | ||
exports.push([module.id, ".gantt .grid-background {\n fill: none; }\n\n.gantt .grid-header {\n fill: #ffffff;\n stroke: #e0e0e0;\n stroke-width: 1.4; }\n\n.gantt .grid-row {\n fill: #ffffff; }\n\n.gantt .grid-row:nth-child(even) {\n fill: #f5f5f5; }\n\n.gantt .row-line {\n stroke: #ebeff2; }\n\n.gantt .tick {\n stroke: #e0e0e0;\n stroke-width: 0.2; }\n .gantt .tick.thick {\n stroke-width: 0.4; }\n\n.gantt .today-highlight {\n fill: #fcf8e3;\n opacity: 0.5; }\n\n.gantt #arrow {\n fill: none;\n stroke: #666;\n stroke-width: 1.4; }\n\n.gantt .bar {\n fill: #b8c2cc;\n stroke: #8D99A6;\n stroke-width: 0;\n transition: stroke-width .3s ease; }\n\n.gantt .bar-progress {\n fill: #a3a3ff; }\n\n.gantt .bar-invalid {\n fill: transparent;\n stroke: #8D99A6;\n stroke-width: 1;\n stroke-dasharray: 5; }\n .gantt .bar-invalid ~ .bar-label {\n fill: #555; }\n\n.gantt .bar-label {\n fill: #fff;\n dominant-baseline: central;\n text-anchor: middle;\n font-size: 12px;\n font-weight: lighter;\n letter-spacing: 0.8px; }\n .gantt .bar-label.big {\n fill: #555;\n text-anchor: start; }\n\n.gantt .handle {\n fill: #ddd;\n cursor: ew-resize;\n opacity: 0;\n visibility: hidden;\n transition: opacity .3s ease; }\n\n.gantt .bar-wrapper {\n cursor: pointer; }\n .gantt .bar-wrapper:hover .bar {\n stroke-width: 2; }\n .gantt .bar-wrapper:hover .handle {\n visibility: visible;\n opacity: 1; }\n .gantt .bar-wrapper.active .bar {\n stroke-width: 2; }\n\n.gantt .lower-text, .gantt .upper-text {\n font-size: 12px;\n text-anchor: middle; }\n\n.gantt .upper-text {\n fill: #555; }\n\n.gantt .lower-text {\n fill: #333; }\n\n.gantt #details .details-container {\n background: #fff;\n display: inline-block;\n padding: 12px; }\n .gantt #details .details-container h5, .gantt #details .details-container p {\n margin: 0; }\n .gantt #details .details-container h5 {\n font-size: 12px;\n font-weight: bold;\n margin-bottom: 10px;\n color: #555; }\n .gantt #details .details-container p {\n font-size: 12px;\n margin-bottom: 6px;\n color: #666; }\n .gantt #details .details-container p:last-child {\n margin-bottom: 0; }\n\n.gantt .hide {\n display: none; }\n", "", {"version":3,"sources":["/./src/src/gantt.scss"],"names":[],"mappings":"AAYA;EAGE,WAAU,EACV;;AAJF;EAME,cAAa;EACb,gBAjBoB;EAkBpB,kBAAiB,EACjB;;AATF;EAWE,cAAa,EACb;;AAZF;EAcE,cAvBgB,EAwBhB;;AAfF;EAiBE,gBAzB0B,EA0B1B;;AAlBF;EAoBE,gBA9BoB;EA+BpB,kBAAiB,EAIjB;EAzBF;IAuBG,kBAAiB,EACjB;;AAxBH;EA2BE,cAlCoB;EAmCpB,aAAY,EACZ;;AA7BF;EAgCE,WAAU;EACV,aAvCe;EAwCf,kBAAiB,EACjB;;AAnCF;EAsCE,cAlDiB;EAmDjB,gBAlDkB;EAmDlB,gBAAe;EACf,kCAAiC,EACjC;;AA1CF;EA4CE,cA/CY,EAgDZ;;AA7CF;EA+CE,kBAAiB;EACjB,gBA3DkB;EA4DlB,gBAAe;EACf,oBAAmB,EAKnB;EAvDF;IAqDG,WA1Dc,EA2Dd;;AAtDH;EAyDE,WAAU;EACV,2BAA0B;EAC1B,oBAAmB;EACnB,gBAAe;EACf,qBAAoB;EACpB,sBAAqB,EAMrB;EApEF;IAiEG,WAtEc;IAuEd,mBAAkB,EAClB;;AAnEH;EAuEE,WAzEiB;EA0EjB,kBAAiB;EACjB,WAAU;EACV,mBAAkB;EAClB,6BAA4B,EAC5B;;AA5EF;EA+EE,gBAAe,EAkBf;EAjGF;IAmFI,gBAAe,EACf;EApFJ;IAuFI,oBAAmB;IACnB,WAAU,EACV;EAzFJ;IA8FI,gBAAe,EACf;;AA/FJ;EAoGE,gBAAe;EACf,oBAAmB,EACnB;;AAtGF;EAwGE,WA7Ge,EA8Gf;;AAzGF;EA2GE,WA/Ge,EAgHf;;AA5GF;EA+GE,iBAAgB;EAChB,sBAAqB;EACrB,cAAa,EAsBb;EAvIF;IAoHG,UAAS,EACT;EArHH;IAwHG,gBAAe;IACf,kBAAiB;IACjB,oBAAmB;IACnB,YAhIc,EAiId;EA5HH;IA+HG,gBAAe;IACf,mBAAkB;IAClB,YAvIc,EAwId;EAlIH;IAqIG,iBAAgB,EAChB;;AAtIH;EA0IE,cAAa,EACb","file":"gantt.scss","sourcesContent":["$bar-color: #b8c2cc;\n$bar-stroke: #8D99A6;\n$border-color: #e0e0e0;\n$light-bg: #f5f5f5;\n$light-border-color: #ebeff2;\n$light-yellow: #fcf8e3;\n$text-muted: #666;\n$text-light: #555;\n$text-color: #333;\n$blue: #a3a3ff;\n$handle-color: #ddd;\n\n.gantt {\n\n\t.grid-background {\n\t\tfill: none;\n\t}\n\t.grid-header {\n\t\tfill: #ffffff;\n\t\tstroke: $border-color;\n\t\tstroke-width: 1.4;\n\t}\n\t.grid-row {\n\t\tfill: #ffffff;\n\t}\n\t.grid-row:nth-child(even) {\n\t\tfill: $light-bg;\n\t}\n\t.row-line {\n\t\tstroke: $light-border-color;\n\t}\n\t.tick {\n\t\tstroke: $border-color;\n\t\tstroke-width: 0.2;\n\t\t&.thick {\n\t\t\tstroke-width: 0.4;\n\t\t}\n\t}\n\t.today-highlight {\n\t\tfill: $light-yellow;\n\t\topacity: 0.5;\n\t}\n\n\t#arrow {\n\t\tfill: none;\n\t\tstroke: $text-muted;\n\t\tstroke-width: 1.4;\n\t}\n\n\t.bar {\n\t\tfill: $bar-color;\n\t\tstroke: $bar-stroke;\n\t\tstroke-width: 0;\n\t\ttransition: stroke-width .3s ease;\n\t}\n\t.bar-progress {\n\t\tfill: $blue;\n\t}\n\t.bar-invalid {\n\t\tfill: transparent;\n\t\tstroke: $bar-stroke;\n\t\tstroke-width: 1;\n\t\tstroke-dasharray: 5;\n\n\t\t&~.bar-label {\n\t\t\tfill: $text-light;\n\t\t}\n\t}\n\t.bar-label {\n\t\tfill: #fff;\n\t\tdominant-baseline: central;\n\t\ttext-anchor: middle;\n\t\tfont-size: 12px;\n\t\tfont-weight: lighter;\n\t\tletter-spacing: 0.8px;\n\n\t\t&.big {\n\t\t\tfill: $text-light;\n\t\t\ttext-anchor: start;\n\t\t}\n\t}\n\n\t.handle {\n\t\tfill: $handle-color;\n\t\tcursor: ew-resize;\n\t\topacity: 0;\n\t\tvisibility: hidden;\n\t\ttransition: opacity .3s ease;\n\t}\n\n\t.bar-wrapper {\n\t\tcursor: pointer;\n\n\t\t&:hover {\n\t\t\t.bar {\n\t\t\t\tstroke-width: 2;\n\t\t\t}\n\n\t\t\t.handle {\n\t\t\t\tvisibility: visible;\n\t\t\t\topacity: 1;\n\t\t\t}\n\t\t}\n\n\t\t&.active {\n\t\t\t.bar {\n\t\t\t\tstroke-width: 2;\n\t\t\t}\n\t\t}\n\t}\n\n\t.lower-text, .upper-text {\n\t\tfont-size: 12px;\n\t\ttext-anchor: middle;\n\t}\n\t.upper-text {\n\t\tfill: $text-light;\n\t}\n\t.lower-text {\n\t\tfill: $text-color;\n\t}\n\n\t#details .details-container {\n\t\tbackground: #fff;\n\t\tdisplay: inline-block;\n\t\tpadding: 12px;\n\n\t\th5, p {\n\t\t\tmargin: 0;\n\t\t}\n\n\t\th5 {\n\t\t\tfont-size: 12px;\n\t\t\tfont-weight: bold;\n\t\t\tmargin-bottom: 10px;\n\t\t\tcolor: $text-light;\n\t\t}\n\n\t\tp {\n\t\t\tfont-size: 12px;\n\t\t\tmargin-bottom: 6px;\n\t\t\tcolor: $text-muted;\n\t\t}\n\n\t\tp:last-child {\n\t\t\tmargin-bottom: 0;\n\t\t}\n\t}\n\n\t.hide {\n\t\tdisplay: none;\n\t}\n}"],"sourceRoot":"webpack://"}]); | ||
@@ -1280,6 +1304,5 @@ // exports | ||
self.details_box = gt.canvas.group().addClass('details-wrapper hide').attr('data-task', self.task.id).appendTo(popover_group); | ||
gt.canvas.rect(0, 0, 0, 110, 2, 2).addClass('details-container').appendTo(self.details_box); | ||
gt.canvas.text(0, 0, '').attr({ dx: 10, dy: 30 }).addClass('details-heading').appendTo(self.details_box); | ||
gt.canvas.text(0, 0, '').attr({ dx: 10, dy: 65 }).addClass('details-body').appendTo(self.details_box); | ||
gt.canvas.text(0, 0, '').attr({ dx: 10, dy: 90 }).addClass('details-body').appendTo(self.details_box); | ||
render_details(); | ||
var f = gt.canvas.filter(Snap.filter.shadow(0, 1, 1, '#666', 0.6)); | ||
@@ -1299,3 +1322,2 @@ self.details_box.attr({ | ||
}); | ||
render_details(); | ||
self.details_box.removeClass('hide'); | ||
@@ -1311,19 +1333,31 @@ }); | ||
self.details_box.transform('t' + x + ',' + y); | ||
self.details_box.clear(); | ||
var start_date = self.task._start.format('MMM D'), | ||
end_date = self.task._end.format('MMM D'), | ||
heading = self.task.name + ': ' + start_date + ' - ' + end_date; | ||
var html = get_details_html(); | ||
var foreign_object = Snap.parse('<foreignObject width="5000" height="2000">\n\t\t\t\t<body xmlns="http://www.w3.org/1999/xhtml">\n\t\t\t\t\t' + html + '\n\t\t\t\t</body>\n\t\t\t\t</foreignObject>'); | ||
self.details_box.append(foreign_object); | ||
} | ||
var $heading = self.details_box.select('.details-heading').attr('text', heading); | ||
function get_details_html() { | ||
var bbox = $heading.getBBox(); | ||
self.details_box.select('.details-container').attr({ width: bbox.width + 20 }); | ||
// custom html in config | ||
if (gt.config.custom_popup_html) { | ||
var _html = gt.config.custom_popup_html; | ||
if (typeof _html === 'string') { | ||
return _html; | ||
} | ||
if (isFunction(_html)) { | ||
return _html(task); | ||
} | ||
} | ||
var duration = self.task._end.diff(self.task._start, 'days'), | ||
body1 = 'Duration: ' + (duration + 1) + ' days', | ||
body2 = self.task.progress ? 'Progress: ' + self.task.progress : ''; | ||
var start_date = self.task._start.format('MMM D'); | ||
var end_date = self.task._end.format('MMM D'); | ||
var heading = self.task.name + ': ' + start_date + ' - ' + end_date; | ||
var $body = self.details_box.selectAll('.details-body'); | ||
$body[0].attr('text', body1); | ||
$body[1].attr('text', body2); | ||
var line_1 = 'Duration: ' + self.duration + ' days'; | ||
var line_2 = self.task.progress ? 'Progress: ' + self.task.progress : null; | ||
var html = '\n\t\t\t<div class="details-container">\n\t\t\t\t<h5>' + heading + '</h5>\n\t\t\t\t<p>' + line_1 + '</p>\n\t\t\t\t' + (line_2 ? '<p>' + line_2 + '</p>' : '') + '\n\t\t\t</div>\n\t\t'; | ||
return html; | ||
} | ||
@@ -1639,3 +1673,4 @@ | ||
}); | ||
self.group.select('.handle.progress').attr('points', get_progress_polygon_points()); | ||
var handle = self.group.select('.handle.progress'); | ||
handle && handle.attr('points', get_progress_polygon_points()); | ||
} | ||
@@ -1678,2 +1713,7 @@ | ||
function isFunction(functionToCheck) { | ||
var getType = {}; | ||
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; | ||
} | ||
init(); | ||
@@ -1680,0 +1720,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Gantt",[],e):"object"==typeof exports?exports.Gantt=e():t.Gantt=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return t[r].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function a(t,e,n){function r(){a(),O.change_view_mode=o,O.unselect_all=X,O.view_is=U,O.get_bar=j,O.trigger_event=G,o(O.config.view_mode)}function a(){var r={header_height:50,column_width:30,step:24,view_modes:["Quarter Day","Half Day","Day","Week","Month"],bar:{height:20},arrow:{curve:5},padding:18,view_mode:"Day",date_format:"YYYY-MM-DD"};O.element=t,O._tasks=e,O.config=Object.assign({},r,n),O._bars=[],O._arrows=[],O.element_groups={}}function o(t){y(t),d(),g(),G("view_change",[t])}function d(){c(),l(),f(),u()}function c(){O.tasks=O._tasks.map(function(t,e){if(t._start=moment(t.start,O.config.date_format),t._end=moment(t.end,O.config.date_format),t._index=e,t.start||t.end||(t._start=moment().startOf("day"),t._end=moment().startOf("day").add(2,"days")),!t.start&&t.end&&(t._start=t._end.clone().add(-2,"days")),t.start&&!t.end&&(t._end=t._start.clone().add(2,"days")),t.start&&t.end||(t.invalid=!0),"string"==typeof t.dependencies||!t.dependencies){var n=[];t.dependencies&&(n=t.dependencies.split(",").map(function(t){return t.trim()}).filter(function(t){return t})),t.dependencies=n}return t})}function l(){O.dependency_map={};var t=!0,e=!1,n=void 0;try{for(var r,a=O.tasks[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o=r.value,i=!0,d=!1,s=void 0;try{for(var c,l=o.dependencies[Symbol.iterator]();!(i=(c=l.next()).done);i=!0){var f=c.value;O.dependency_map[f]=O.dependency_map[f]||[],O.dependency_map[f].push(o.id)}}catch(u){d=!0,s=u}finally{try{!i&&l["return"]&&l["return"]()}finally{if(d)throw s}}}}catch(u){e=!0,n=u}finally{try{!t&&a["return"]&&a["return"]()}finally{if(e)throw n}}}function f(){var t=!0,e=!1,n=void 0;try{for(var r,a=O.tasks[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o=r.value;(!O.gantt_start||o._start<O.gantt_start)&&(O.gantt_start=o._start),(!O.gantt_end||o._end>O.gantt_end)&&(O.gantt_end=o._end)}}catch(i){e=!0,n=i}finally{try{!t&&a["return"]&&a["return"]()}finally{if(e)throw n}}p(),_()}function u(){O.canvas=Snap(O.element).addClass("gantt")}function g(){h(),v(),x(),M(),T(),S(),W(),m(),w(),Y()}function h(){O.canvas.clear(),O._bars=[],O._arrows=[]}function p(){U(["Quarter Day","Half Day"])?(O.gantt_start=O.gantt_start.clone().subtract(7,"day"),O.gantt_end=O.gantt_end.clone().add(7,"day")):U("Month")?(O.gantt_start=O.gantt_start.clone().startOf("year"),O.gantt_end=O.gantt_end.clone().endOf("month").add(1,"year")):(O.gantt_start=O.gantt_start.clone().startOf("month").subtract(1,"month"),O.gantt_end=O.gantt_end.clone().endOf("month").add(1,"month"))}function _(){O.dates=[];for(var t=null;null===t||t<O.gantt_end;)t=t?U("Month")?t.clone().add(1,"month"):t.clone().add(O.config.step,"hours"):O.gantt_start.clone(),O.dates.push(t)}function v(){var t=["grid","date","arrow","progress","bar","details"],e=!0,n=!1,r=void 0;try{for(var a,o=t[Symbol.iterator]();!(e=(a=o.next()).done);e=!0){var i=a.value;O.element_groups[i]=O.canvas.group().attr({id:i})}}catch(d){n=!0,r=d}finally{try{!e&&o["return"]&&o["return"]()}finally{if(n)throw r}}}function y(t){O.config.view_mode=t,"Day"===t?(O.config.step=24,O.config.column_width=38):"Half Day"===t?(O.config.step=12,O.config.column_width=38):"Quarter Day"===t?(O.config.step=6,O.config.column_width=38):"Week"===t?(O.config.step=168,O.config.column_width=140):"Month"===t&&(O.config.step=720,O.config.column_width=120)}function m(){var t=O.canvas.node.getBoundingClientRect().width,e=O.canvas.getBBox().width;t<e&&O.canvas.attr("width",e)}function w(){var t=document.querySelector(O.element).parentElement;if(t){var e=b().diff(O.gantt_start,"hours")/O.config.step*O.config.column_width-O.config.column_width;t.scrollLeft=e}}function b(){var t=O.tasks.reduce(function(t,e){return e._start.isSameOrBefore(t._start)?e:t});return t._start}function x(){A(),C(),k(),B(),$()}function A(){var t=O.dates.length*O.config.column_width,e=O.config.header_height+O.config.padding+(O.config.bar.height+O.config.padding)*O.tasks.length;O.canvas.rect(0,0,t,e).addClass("grid-background").appendTo(O.element_groups.grid),O.canvas.attr({height:e+O.config.padding,width:"100%"})}function k(){var t=O.dates.length*O.config.column_width,e=O.config.header_height+10;O.canvas.rect(0,0,t,e).addClass("grid-header").appendTo(O.element_groups.grid)}function C(){var t=O.canvas.group().appendTo(O.element_groups.grid),e=O.canvas.group().appendTo(O.element_groups.grid),n=O.dates.length*O.config.column_width,r=O.config.bar.height+O.config.padding,a=O.config.header_height+O.config.padding/2,o=!0,i=!1,d=void 0;try{for(var s,c=O.tasks[Symbol.iterator]();!(o=(s=c.next()).done);o=!0){s.value;O.canvas.rect(0,a,n,r).addClass("grid-row").appendTo(t),O.canvas.line(0,a+r,n,a+r).addClass("row-line").appendTo(e),a+=O.config.bar.height+O.config.padding}}catch(l){i=!0,d=l}finally{try{!o&&c["return"]&&c["return"]()}finally{if(i)throw d}}}function B(){var t=0,e=O.config.header_height+O.config.padding/2,n=(O.config.bar.height+O.config.padding)*O.tasks.length,r=!0,a=!1,o=void 0;try{for(var i,d=O.dates[Symbol.iterator]();!(r=(i=d.next()).done);r=!0){var s=i.value,c="tick";U("Day")&&1===s.day()&&(c+=" thick"),U("Week")&&s.date()>=1&&s.date()<8&&(c+=" thick"),U("Month")&&s.month()%3===0&&(c+=" thick"),O.canvas.path(Snap.format("M {x} {y} v {height}",{x:t,y:e,height:n})).addClass(c).appendTo(O.element_groups.grid),t+=U("Month")?s.daysInMonth()*O.config.column_width/30:O.config.column_width}}catch(l){a=!0,o=l}finally{try{!r&&d["return"]&&d["return"]()}finally{if(a)throw o}}}function $(){if(U("Day")){var t=moment().startOf("day").diff(O.gantt_start,"hours")/O.config.step*O.config.column_width,e=0,n=O.config.column_width,r=(O.config.bar.height+O.config.padding)*O.tasks.length+O.config.header_height+O.config.padding/2;O.canvas.rect(t,e,n,r).addClass("today-highlight").appendTo(O.element_groups.grid)}}function M(){var t=!0,e=!1,n=void 0;try{for(var r,a=E()[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o=r.value;if(O.canvas.text(o.lower_x,o.lower_y,o.lower_text).addClass("lower-text").appendTo(O.element_groups.date),o.upper_text){var i=O.canvas.text(o.upper_x,o.upper_y,o.upper_text).addClass("upper-text").appendTo(O.element_groups.date);i.getBBox().x2>O.element_groups.grid.getBBox().width&&i.remove()}}}catch(d){e=!0,n=d}finally{try{!t&&a["return"]&&a["return"]()}finally{if(e)throw n}}}function E(){var t=null,e=O.dates.map(function(e,n){var r=D(e,t,n);return t=e,r});return e}function D(t,e,n){e||(e=t.clone().add(1,"year"));var r={"Quarter Day_lower":t.format("HH"),"Half Day_lower":t.format("HH"),Day_lower:t.date()!==e.date()?t.format("D"):"",Week_lower:"Week "+t.format("W"),Month_lower:t.format("MMMM"),"Quarter Day_upper":t.date()!==e.date()?t.format("D MMM"):"","Half Day_upper":t.date()!==e.date()?t.format("D MMM"):"",Day_upper:t.month()!==e.month()?t.format("MMMM"):"",Week_upper:t.month()!==e.month()?t.format("MMMM"):"",Month_upper:t.year()!==e.year()?t.format("YYYY"):""},a={x:n*O.config.column_width,lower_y:O.config.header_height,upper_y:O.config.header_height-25},o={"Quarter Day_lower":4*O.config.column_width/2,"Quarter Day_upper":0,"Half Day_lower":2*O.config.column_width/2,"Half Day_upper":0,Day_lower:O.config.column_width/2,Day_upper:30*O.config.column_width/2,Week_lower:O.config.column_width/2,Week_upper:4*O.config.column_width/2,Month_lower:t.daysInMonth()*O.config.column_width/30/2,Month_upper:12*O.config.column_width/2};return{upper_text:r[O.config.view_mode+"_upper"],lower_text:r[O.config.view_mode+"_lower"],upper_x:a.x+o[O.config.view_mode+"_upper"],upper_y:a.upper_y,lower_x:a.x+o[O.config.view_mode+"_lower"],lower_y:a.lower_y}}function S(){O._arrows=[];var t=!0,e=!1,n=void 0;try{for(var r,a=function(){var t=r.value,e=[];e=t.dependencies.map(function(e){var n=H(e);if(n){var r=(0,s["default"])(O,O._bars[n._index],O._bars[t._index]);return O.element_groups.arrow.add(r.element),r}}),O._arrows=O._arrows.concat(e)},o=O.tasks[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)a()}catch(i){e=!0,n=i}finally{try{!t&&o["return"]&&o["return"]()}finally{if(e)throw n}}}function T(){O._bars=O.tasks.map(function(t){var e=(0,i["default"])(O,t);return O.element_groups.bar.add(e.group),e})}function W(){var t=!0,e=!1,n=void 0;try{for(var r,a=function(){var t=r.value;t.arrows=O._arrows.filter(function(e){return e.from_task.task.id===t.task.id||e.to_task.task.id===t.task.id})},o=O._bars[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)a()}catch(i){e=!0,n=i}finally{try{!t&&o["return"]&&o["return"]()}finally{if(e)throw n}}}function Y(){O.element_groups.grid.click(function(){X(),O.element_groups.details.selectAll(".details-wrapper").forEach(function(t){return t.addClass("hide")})})}function X(){O.canvas.selectAll(".bar-wrapper").forEach(function(t){t.removeClass("active")})}function U(t){if("string"==typeof t)return O.config.view_mode===t;if(Array.isArray(t)){var e=!0,n=!1,r=void 0;try{for(var a,o=t[Symbol.iterator]();!(e=(a=o.next()).done);e=!0){var i=a.value;if(O.config.view_mode===i)return!0}}catch(d){n=!0,r=d}finally{try{!e&&o["return"]&&o["return"]()}finally{if(n)throw r}}return!1}}function H(t){return O.tasks.find(function(e){return e.id===t})}function j(t){return O._bars.find(function(e){return e.task.id===t})}function G(t,e){O.config["on_"+t]&&O.config["on_"+t].apply(null,e)}var O={};return r(),O}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=a,n(1);var o=n(5),i=r(o),d=n(6),s=r(d);t.exports=e["default"]},function(t,e,n){var r=n(2);"string"==typeof r&&(r=[[t.id,r,""]]);n(4)(r,{});r.locals&&(t.exports=r.locals)},function(t,e,n){e=t.exports=n(3)(),e.push([t.id,".gantt .grid-background{fill:none}.gantt .grid-header{fill:#fff;stroke:#e0e0e0;stroke-width:1.4}.gantt .grid-row{fill:#fff}.gantt .grid-row:nth-child(2n){fill:#f5f5f5}.gantt .row-line{stroke:#ebeff2}.gantt .tick{stroke:#e0e0e0;stroke-width:.2}.gantt .tick.thick{stroke-width:.4}.gantt .today-highlight{fill:#fcf8e3;opacity:.5}.gantt #arrow{fill:none;stroke:#666;stroke-width:1.4}.gantt .bar{fill:#b8c2cc;stroke:#8d99a6;stroke-width:0;transition:stroke-width .3s ease}.gantt .bar-progress{fill:#a3a3ff}.gantt .bar-invalid{fill:transparent;stroke:#8d99a6;stroke-width:1;stroke-dasharray:5}.gantt .bar-invalid~.bar-label{fill:#555}.gantt .bar-label{fill:#fff;dominant-baseline:central;text-anchor:middle;font-size:12px;font-weight:lighter;letter-spacing:.8px}.gantt .bar-label.big{fill:#555;text-anchor:start}.gantt .handle{fill:#ddd;cursor:ew-resize;opacity:0;visibility:hidden;transition:opacity .3s ease}.gantt .bar-wrapper{cursor:pointer}.gantt .bar-wrapper:hover .bar{stroke-width:2}.gantt .bar-wrapper:hover .handle{visibility:visible;opacity:1}.gantt .bar-wrapper.active .bar{stroke-width:2}.gantt .primary-text,.gantt .secondary-text{font-size:12px;text-anchor:middle}.gantt .primary-text{fill:#555}.gantt .secondary-text{fill:#333}.gantt #details{font-size:14}.gantt #details .details-container{stroke:#e0e0e0;stroke-width:1.1;fill:#fff}.gantt #details .details-heading{fill:#333;font-weight:500}.gantt #details .details-body{fill:#555}.gantt .hide{display:none}","",{version:3,sources:["/./src/src/gantt.scss"],names:[],mappings:"AAYA,wBAGE,SAAU,CAHZ,oBAME,UACA,eACA,gBAAiB,CARnB,iBAWE,SAAa,CAXf,+BAcE,YAvBgB,CASlB,iBAiBE,cAzB0B,CAQ5B,aAoBE,eACA,eAAiB,CArBnB,mBAuBG,eAAiB,CAvBpB,wBA2BE,aACA,UAAY,CA5Bd,cAgCE,UACA,YACA,gBAAiB,CAlCnB,YAsCE,aACA,eACA,eACA,gCAAiC,CAzCnC,qBA4CE,YA/CY,CAGd,oBA+CE,iBACA,eACA,eACA,kBAAmB,CAlDrB,+BAqDG,SA1Dc,CAKjB,kBAyDE,UACA,0BACA,mBACA,eACA,oBACA,mBAAqB,CA9DvB,sBAiEG,UACA,iBAAkB,CAlErB,eAuEE,UACA,iBACA,UACA,kBACA,2BAA4B,CA3E9B,oBA+EE,cAAe,CA/EjB,+BAmFI,cAAe,CAnFnB,kCAuFI,mBACA,SAAU,CAxFd,gCA8FI,cAAe,CA9FnB,4CAoGE,eACA,kBAAmB,CArGrB,qBAwGE,SA7Ge,CAKjB,uBA2GE,SA/Ge,CAIjB,gBA+GE,YAAa,CA/Gf,mCAkHG,eACA,iBACA,SAAU,CApHb,iCAuHG,UACA,eAAgB,CAxHnB,8BA2HG,SAhIc,CAKjB,aAgIE,YAAa,CACb",file:"gantt.scss",sourcesContent:["$bar-color: #b8c2cc;\n$bar-stroke: #8D99A6;\n$border-color: #e0e0e0;\n$light-bg: #f5f5f5;\n$light-border-color: #ebeff2;\n$light-yellow: #fcf8e3;\n$text-muted: #666;\n$text-light: #555;\n$text-color: #333;\n$blue: #a3a3ff;\n$handle-color: #ddd;\n\n.gantt {\n\n\t.grid-background {\n\t\tfill: none;\n\t}\n\t.grid-header {\n\t\tfill: #ffffff;\n\t\tstroke: $border-color;\n\t\tstroke-width: 1.4;\n\t}\n\t.grid-row {\n\t\tfill: #ffffff;\n\t}\n\t.grid-row:nth-child(even) {\n\t\tfill: $light-bg;\n\t}\n\t.row-line {\n\t\tstroke: $light-border-color;\n\t}\n\t.tick {\n\t\tstroke: $border-color;\n\t\tstroke-width: 0.2;\n\t\t&.thick {\n\t\t\tstroke-width: 0.4;\n\t\t}\n\t}\n\t.today-highlight {\n\t\tfill: $light-yellow;\n\t\topacity: 0.5;\n\t}\n\n\t#arrow {\n\t\tfill: none;\n\t\tstroke: $text-muted;\n\t\tstroke-width: 1.4;\n\t}\n\n\t.bar {\n\t\tfill: $bar-color;\n\t\tstroke: $bar-stroke;\n\t\tstroke-width: 0;\n\t\ttransition: stroke-width .3s ease;\n\t}\n\t.bar-progress {\n\t\tfill: $blue;\n\t}\n\t.bar-invalid {\n\t\tfill: transparent;\n\t\tstroke: $bar-stroke;\n\t\tstroke-width: 1;\n\t\tstroke-dasharray: 5;\n\n\t\t&~.bar-label {\n\t\t\tfill: $text-light;\n\t\t}\n\t}\n\t.bar-label {\n\t\tfill: #fff;\n\t\tdominant-baseline: central;\n\t\ttext-anchor: middle;\n\t\tfont-size: 12px;\n\t\tfont-weight: lighter;\n\t\tletter-spacing: 0.8px;\n\n\t\t&.big {\n\t\t\tfill: $text-light;\n\t\t\ttext-anchor: start;\n\t\t}\n\t}\n\n\t.handle {\n\t\tfill: $handle-color;\n\t\tcursor: ew-resize;\n\t\topacity: 0;\n\t\tvisibility: hidden;\n\t\ttransition: opacity .3s ease;\n\t}\n\n\t.bar-wrapper {\n\t\tcursor: pointer;\n\n\t\t&:hover {\n\t\t\t.bar {\n\t\t\t\tstroke-width: 2;\n\t\t\t}\n\n\t\t\t.handle {\n\t\t\t\tvisibility: visible;\n\t\t\t\topacity: 1;\n\t\t\t}\n\t\t}\n\n\t\t&.active {\n\t\t\t.bar {\n\t\t\t\tstroke-width: 2;\n\t\t\t}\n\t\t}\n\t}\n\n\t.primary-text, .secondary-text {\n\t\tfont-size: 12px;\n\t\ttext-anchor: middle;\n\t}\n\t.primary-text {\n\t\tfill: $text-light;\n\t}\n\t.secondary-text {\n\t\tfill: $text-color;\n\t}\n\n\t#details {\n\t\tfont-size: 14;\n\n\t\t.details-container {\n\t\t\tstroke: $border-color;\n\t\t\tstroke-width: 1.1;\n\t\t\tfill: #fff;\n\t\t}\n\t\t.details-heading {\n\t\t\tfill: $text-color;\n\t\t\tfont-weight: 500;\n\t\t}\n\t\t.details-body {\n\t\t\tfill: $text-light;\n\t\t}\n\t}\n\n\t.hide {\n\t\tdisplay: none;\n\t}\n}"],sourceRoot:"webpack://"}])},function(t,e){t.exports=function(){var t=[];return t.toString=function(){for(var t=[],e=0;e<this.length;e++){var n=this[e];n[2]?t.push("@media "+n[2]+"{"+n[1]+"}"):t.push(n[1])}return t.join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},a=0;a<this.length;a++){var o=this[a][0];"number"==typeof o&&(r[o]=!0)}for(a=0;a<e.length;a++){var i=e[a];"number"==typeof i[0]&&r[i[0]]||(n&&!i[2]?i[2]=n:n&&(i[2]="("+i[2]+") and ("+n+")"),t.push(i))}},t}},function(t,e,n){function r(t,e){for(var n=0;n<t.length;n++){var r=t[n],a=g[r.id];if(a){a.refs++;for(var o=0;o<a.parts.length;o++)a.parts[o](r.parts[o]);for(;o<r.parts.length;o++)a.parts.push(c(r.parts[o],e))}else{for(var i=[],o=0;o<r.parts.length;o++)i.push(c(r.parts[o],e));g[r.id]={id:r.id,refs:1,parts:i}}}}function a(t){for(var e=[],n={},r=0;r<t.length;r++){var a=t[r],o=a[0],i=a[1],d=a[2],s=a[3],c={css:i,media:d,sourceMap:s};n[o]?n[o].parts.push(c):e.push(n[o]={id:o,parts:[c]})}return e}function o(t,e){var n=_(),r=m[m.length-1];if("top"===t.insertAt)r?r.nextSibling?n.insertBefore(e,r.nextSibling):n.appendChild(e):n.insertBefore(e,n.firstChild),m.push(e);else{if("bottom"!==t.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");n.appendChild(e)}}function i(t){t.parentNode.removeChild(t);var e=m.indexOf(t);e>=0&&m.splice(e,1)}function d(t){var e=document.createElement("style");return e.type="text/css",o(t,e),e}function s(t){var e=document.createElement("link");return e.rel="stylesheet",o(t,e),e}function c(t,e){var n,r,a;if(e.singleton){var o=y++;n=v||(v=d(e)),r=l.bind(null,n,o,!1),a=l.bind(null,n,o,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=s(e),r=u.bind(null,n),a=function(){i(n),n.href&&URL.revokeObjectURL(n.href)}):(n=d(e),r=f.bind(null,n),a=function(){i(n)});return r(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;r(t=e)}else a()}}function l(t,e,n,r){var a=n?"":r.css;if(t.styleSheet)t.styleSheet.cssText=w(e,a);else{var o=document.createTextNode(a),i=t.childNodes;i[e]&&t.removeChild(i[e]),i.length?t.insertBefore(o,i[e]):t.appendChild(o)}}function f(t,e){var n=e.css,r=e.media;if(r&&t.setAttribute("media",r),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}function u(t,e){var n=e.css,r=e.sourceMap;r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var a=new Blob([n],{type:"text/css"}),o=t.href;t.href=URL.createObjectURL(a),o&&URL.revokeObjectURL(o)}var g={},h=function(t){var e;return function(){return"undefined"==typeof e&&(e=t.apply(this,arguments)),e}},p=h(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),_=h(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,y=0,m=[];t.exports=function(t,e){e=e||{},"undefined"==typeof e.singleton&&(e.singleton=p()),"undefined"==typeof e.insertAt&&(e.insertAt="bottom");var n=a(t);return r(n,e),function(t){for(var o=[],i=0;i<n.length;i++){var d=n[i],s=g[d.id];s.refs--,o.push(s)}if(t){var c=a(t);r(c,e)}for(var i=0;i<o.length;i++){var s=o[i];if(0===s.refs){for(var l=0;l<s.parts.length;l++)s.parts[l]();delete g[s.id]}}}};var w=function(){var t=[];return function(e,n){return t[e]=n,t.filter(Boolean).join("\n")}}()},function(t,e){"use strict";function n(t,e){function n(){r(),a(),d(),g()}function r(){N.action_completed=!1,N.task=e}function a(){o(),i()}function o(){N.invalid=N.task.invalid,N.height=t.config.bar.height,N.x=U(),N.y=H(),N.corner_radius=3,N.duration=(N.task._end.diff(N.task._start,"hours")+24)/t.config.step,N.width=t.config.column_width*N.duration,N.progress_width=t.config.column_width*N.duration*(N.task.progress/100)||0,N.group=t.canvas.group().addClass("bar-wrapper"),N.bar_group=t.canvas.group().addClass("bar-group").appendTo(N.group),N.handle_group=t.canvas.group().addClass("handle-group").appendTo(N.group)}function i(){Snap.plugin(function(t,e,n,r,a){e.prototype.getX=function(){return+this.attr("x")},e.prototype.getY=function(){return+this.attr("y")},e.prototype.getWidth=function(){return+this.attr("width")},e.prototype.getHeight=function(){return+this.attr("height")},e.prototype.getEndX=function(){return this.getX()+this.getWidth()}})}function d(){s(),c(),l(),f()}function s(){N.$bar=t.canvas.rect(N.x,N.y,N.width,N.height,N.corner_radius,N.corner_radius).addClass("bar").appendTo(N.bar_group),N.invalid&&N.$bar.addClass("bar-invalid")}function c(){N.invalid||(N.$bar_progress=t.canvas.rect(N.x,N.y,N.progress_width,N.height,N.corner_radius,N.corner_radius).addClass("bar-progress").appendTo(N.bar_group))}function l(){t.canvas.text(N.x+N.width/2,N.y+N.height/2,N.task.name).addClass("bar-label").appendTo(N.bar_group),L()}function f(){if(!N.invalid){var e=N.$bar,n=8;t.canvas.rect(e.getX()+e.getWidth()-9,e.getY()+1,n,N.height-2,N.corner_radius,N.corner_radius).addClass("handle right").appendTo(N.handle_group),t.canvas.rect(e.getX()+1,e.getY()+1,n,N.height-2,N.corner_radius,N.corner_radius).addClass("handle left").appendTo(N.handle_group),N.task.progress&&N.task.progress<100&&t.canvas.polygon(u()).addClass("handle progress").appendTo(N.handle_group)}}function u(){var t=N.$bar_progress;return[t.getEndX()-5,t.getY()+t.getHeight(),t.getEndX()+5,t.getY()+t.getHeight(),t.getEndX(),t.getY()+t.getHeight()-8.66]}function g(){N.invalid||(D(),h(),v(),m(),w())}function h(){var e=t.element_groups.details;if(N.details_box=e.select(".details-wrapper[data-task='"+N.task.id+"']"),!N.details_box){N.details_box=t.canvas.group().addClass("details-wrapper hide").attr("data-task",N.task.id).appendTo(e),t.canvas.rect(0,0,0,110,2,2).addClass("details-container").appendTo(N.details_box),t.canvas.text(0,0,"").attr({dx:10,dy:30}).addClass("details-heading").appendTo(N.details_box),t.canvas.text(0,0,"").attr({dx:10,dy:65}).addClass("details-body").appendTo(N.details_box),t.canvas.text(0,0,"").attr({dx:10,dy:90}).addClass("details-body").appendTo(N.details_box);var n=t.canvas.filter(Snap.filter.shadow(0,1,1,"#666",.6));N.details_box.attr({filter:n})}N.group.click(function(t){N.action_completed||(e.selectAll(".details-wrapper").forEach(function(t){return t.addClass("hide")}),p(),N.details_box.removeClass("hide"))})}function p(){var t=_(),e=t.x,n=t.y;N.details_box.transform("t"+e+","+n);var r=N.task._start.format("MMM D"),a=N.task._end.format("MMM D"),o=N.task.name+": "+r+" - "+a,i=N.details_box.select(".details-heading").attr("text",o),d=i.getBBox();N.details_box.select(".details-container").attr({width:d.width+20});var s=N.task._end.diff(N.task._start,"days"),c="Duration: "+(s+1)+" days",l=N.task.progress?"Progress: "+N.task.progress:"",f=N.details_box.selectAll(".details-body");f[0].attr("text",c),f[1].attr("text",l)}function _(){return{x:N.$bar.getEndX()+2,y:N.$bar.getY()-10}}function v(){function t(t,e){$(t,e)}function e(){M()}function n(t,e){k(t,e)}function r(){C()}var a=y(),o=a.left,i=a.right;o.drag(n,b,r),i.drag(t,b,e)}function y(){return{left:N.handle_group.select(".handle.left"),right:N.handle_group.select(".handle.right")}}function m(){N.bar_group.drag(x,b,A)}function w(){function t(t,e){t>a.max_dx&&(t=a.max_dx),t<a.min_dx&&(t=a.min_dx),a.attr("width",a.owidth+t),o.attr("points",u()),a.finaldx=t}function e(){a.finaldx&&(T(),W())}function n(){a.finaldx=0,a.owidth=a.getWidth(),a.min_dx=-a.getWidth(),a.max_dx=r.getWidth()-a.getWidth()}var r=N.$bar,a=N.$bar_progress,o=N.group.select(".handle.progress");o&&o.drag(t,n,e)}function b(){var t=N.$bar;t.ox=t.getX(),t.oy=t.getY(),t.owidth=t.getWidth(),t.finaldx=0,B("onstart")}function x(t,e){var n=N.$bar;n.finaldx=j(t),E({x:n.ox+n.finaldx}),B("onmove",[t,e])}function A(){var t=N.$bar;t.finaldx&&(S(),W(),B("onstop"))}function k(t,e){var n=N.$bar;n.finaldx=j(t),E({x:n.ox+n.finaldx,width:n.owidth-n.finaldx}),B("onmove",[t,e])}function C(){var t=N.$bar;t.finaldx&&S(),W(),B("onstop")}function B(e,n){var r=t.dependency_map;if(r[N.task.id]){var a=!0,o=!1,i=void 0;try{for(var d,s=r[N.task.id][Symbol.iterator]();!(a=(d=s.next()).done);a=!0){var c=d.value,l=t.get_bar(c);l[e].apply(l,n)}}catch(f){o=!0,i=f}finally{try{!a&&s["return"]&&s["return"]()}finally{if(o)throw i}}}}function $(t,e){var n=N.$bar;n.finaldx=j(t),E({width:n.owidth+n.finaldx})}function M(){var t=N.$bar;t.finaldx&&S(),W()}function E(n){var r=n.x,a=void 0===r?null:r,o=n.width,i=void 0===o?null:o,d=N.$bar;if(a){var s=e.dependencies.map(function(e){return t.get_bar(e).$bar.getX()}),c=s.reduce(function(t,e){return a>=e},a);if(!c)return void(i=null);G(d,"x",a)}i&&i>=t.config.column_width&&G(d,"width",i),L(),R(),O(),I(),z()}function D(){N.group.click(function(){N.action_completed||(N.group.hasClass("active")&&t.trigger_event("click",[N.task]),t.unselect_all(),N.group.toggleClass("active"))})}function S(){var e=Y(),n=e.new_start_date,r=e.new_end_date;N.task._start=n,N.task._end=r,p(),t.trigger_event("date_change",[N.task,n,r])}function T(){var e=X();N.task.progress=e,p(),t.trigger_event("progress_change",[N.task,e])}function W(){N.action_completed=!0,setTimeout(function(){return N.action_completed=!1},2e3)}function Y(){var e=N.$bar,n=e.getX()/t.config.column_width,r=t.gantt_start.clone().add(n*t.config.step,"hours"),a=e.getWidth()/t.config.column_width,o=r.clone().add(a*t.config.step,"hours");return{new_start_date:r,new_end_date:o}}function X(){var t=N.$bar_progress.getWidth()/N.$bar.getWidth()*100;return parseInt(t,10)}function U(){var e=N.task._start.diff(t.gantt_start,"hours")/t.config.step*t.config.column_width;return t.view_is("Month")&&(e=N.task._start.diff(t.gantt_start,"days")*t.config.column_width/30),e}function H(){return t.config.header_height+t.config.padding+N.task._index*(N.height+t.config.padding)}function j(e){var n=e,r=void 0,a=void 0;return t.view_is("Week")?(r=e%(t.config.column_width/7),a=n-r+(r<t.config.column_width/14?0:t.config.column_width/7)):t.view_is("Month")?(r=e%(t.config.column_width/30),a=n-r+(r<t.config.column_width/60?0:t.config.column_width/30)):(r=e%t.config.column_width,a=n-r+(r<t.config.column_width/2?0:t.config.column_width)),a}function G(t,e,n){return n=+n,isNaN(n)||t.attr(e,n),t}function O(){N.$bar_progress.attr("x",N.$bar.getX()),N.$bar_progress.attr("width",N.$bar.getWidth()*(N.task.progress/100))}function L(){var t=N.$bar,e=N.group.select(".bar-label");e.getBBox().width>t.getWidth()?e.addClass("big").attr("x",t.getX()+t.getWidth()+5):e.removeClass("big").attr("x",t.getX()+t.getWidth()/2)}function R(){var t=N.$bar;N.handle_group.select(".handle.left").attr({x:t.getX()+1}),N.handle_group.select(".handle.right").attr({x:t.getEndX()-9}),N.group.select(".handle.progress").attr("points",u())}function I(){var t=!0,e=!1,n=void 0;try{for(var r,a=N.arrows[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o=r.value;o.update()}}catch(i){e=!0,n=i}finally{try{!t&&a["return"]&&a["return"]()}finally{if(e)throw n}}}function z(){var t=_(),e=t.x,n=t.y;N.details_box&&N.details_box.transform("t"+e+","+n)}var N={};return N.onstart=b,N.onmove=x,N.onstop=A,N.onmove_handle_left=k,N.onstop_handle_left=C,n(),N}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n,t.exports=e["default"]},function(t,e){"use strict";function n(t,e,n){function r(){d.from_task=e,d.to_task=n,a(),o()}function a(){d.start_x=e.$bar.getX()+e.$bar.getWidth()/2;for(var r=function(){return n.$bar.getX()<d.start_x+t.config.padding&&d.start_x>e.$bar.getX()+t.config.padding};r();)d.start_x-=10;d.start_y=t.config.header_height+t.config.bar.height+(t.config.padding+t.config.bar.height)*e.task._index+t.config.padding,d.end_x=n.$bar.getX()-t.config.padding/2,d.end_y=t.config.header_height+t.config.bar.height/2+(t.config.padding+t.config.bar.height)*n.task._index+t.config.padding;var a=e.task._index>n.task._index;d.curve=t.config.arrow.curve,d.clockwise=a?1:0,d.curve_y=a?-d.curve:d.curve,d.offset=a?d.end_y+t.config.arrow.curve:d.end_y-t.config.arrow.curve,d.path=Snap.format("M {start_x} {start_y} V {offset} a {curve} {curve} 0 0 {clockwise} {curve} {curve_y} L {end_x} {end_y} m -5 -5 l 5 5 l -5 5",{start_x:d.start_x,start_y:d.start_y,end_x:d.end_x,end_y:d.end_y,offset:d.offset,curve:d.curve,clockwise:d.clockwise,curve_y:d.curve_y}),n.$bar.getX()<e.$bar.getX()+t.config.padding&&(d.path=Snap.format("M {start_x} {start_y} v {down_1} a {curve} {curve} 0 0 1 -{curve} {curve} H {left} a {curve} {curve} 0 0 {clockwise} -{curve} {curve_y} V {down_2} a {curve} {curve} 0 0 {clockwise} {curve} {curve_y} L {end_x} {end_y} m -5 -5 l 5 5 l -5 5",{start_x:d.start_x,start_y:d.start_y,end_x:d.end_x,end_y:d.end_y,down_1:t.config.padding/2-d.curve,down_2:n.$bar.getY()+n.$bar.getHeight()/2-d.curve_y,left:n.$bar.getX()-t.config.padding,offset:d.offset,curve:d.curve,clockwise:d.clockwise,curve_y:d.curve_y}))}function o(){d.element=t.canvas.path(d.path).attr("data-from",d.from_task.task.id).attr("data-to",d.to_task.task.id)}function i(){a(),d.element.attr("d",d.path)}var d={};return d.update=i,r(),d}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n,t.exports=e["default"]}])}); | ||
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("Gantt",[],n):"object"==typeof exports?exports.Gantt=n():t.Gantt=n()}(this,function(){return function(t){function n(r){if(e[r])return e[r].exports;var a=e[r]={exports:{},id:r,loaded:!1};return t[r].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function a(t,n,e){function r(){a(),I.change_view_mode=c,I.unselect_all=U,I.view_is=H,I.get_bar=G,I.trigger_event=R,I.refresh=d,c(I.config.view_mode)}function a(){var t={header_height:50,column_width:30,step:24,view_modes:["Quarter Day","Half Day","Day","Week","Month"],bar:{height:20},arrow:{curve:5},padding:18,view_mode:"Day",date_format:"YYYY-MM-DD",custom_popup_html:null};I.config=Object.assign({},t,e),o(n)}function o(n){I.element=t,I._tasks=n,I._bars=[],I._arrows=[],I.element_groups={}}function d(t){o(t),c(I.config.view_mode)}function c(t){w(t),l(),h(),R("view_change",[t])}function l(){f(),u(),g(),p()}function f(){I.tasks=I._tasks.map(function(t,n){if(t._start=moment(t.start,I.config.date_format),t._end=moment(t.end,I.config.date_format),t._index=n,t.start||t.end||(t._start=moment().startOf("day"),t._end=moment().startOf("day").add(2,"days")),!t.start&&t.end&&(t._start=t._end.clone().add(-2,"days")),t.start&&!t.end&&(t._end=t._start.clone().add(2,"days")),t.start&&t.end||(t.invalid=!0),"string"==typeof t.dependencies||!t.dependencies){var e=[];t.dependencies&&(e=t.dependencies.split(",").map(function(t){return t.trim()}).filter(function(t){return t})),t.dependencies=e}return t.id||(t.id=L(t)),t})}function u(){I.dependency_map={};var t=!0,n=!1,e=void 0;try{for(var r,a=I.tasks[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o=r.value,i=!0,d=!1,s=void 0;try{for(var c,l=o.dependencies[Symbol.iterator]();!(i=(c=l.next()).done);i=!0){var f=c.value;I.dependency_map[f]=I.dependency_map[f]||[],I.dependency_map[f].push(o.id)}}catch(u){d=!0,s=u}finally{try{!i&&l["return"]&&l["return"]()}finally{if(d)throw s}}}}catch(u){n=!0,e=u}finally{try{!t&&a["return"]&&a["return"]()}finally{if(n)throw e}}}function g(){I.gantt_start=I.gantt_end=null;var t=!0,n=!1,e=void 0;try{for(var r,a=I.tasks[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o=r.value;(!I.gantt_start||o._start<I.gantt_start)&&(I.gantt_start=o._start),(!I.gantt_end||o._end>I.gantt_end)&&(I.gantt_end=o._end)}}catch(i){n=!0,e=i}finally{try{!t&&a["return"]&&a["return"]()}finally{if(n)throw e}}v(),m()}function p(){I.canvas||(I.canvas=Snap(I.element).addClass("gantt"))}function h(){_(),y(),k(),E(),T(),j(),W(),b(),A(),X()}function _(){I.canvas.clear(),I._bars=[],I._arrows=[]}function v(){H(["Quarter Day","Half Day"])?(I.gantt_start=I.gantt_start.clone().subtract(7,"day"),I.gantt_end=I.gantt_end.clone().add(7,"day")):H("Month")?(I.gantt_start=I.gantt_start.clone().startOf("year"),I.gantt_end=I.gantt_end.clone().endOf("month").add(1,"year")):(I.gantt_start=I.gantt_start.clone().startOf("month").subtract(1,"month"),I.gantt_end=I.gantt_end.clone().endOf("month").add(1,"month"))}function m(){I.dates=[];for(var t=null;null===t||t<I.gantt_end;)t=t?H("Month")?t.clone().add(1,"month"):t.clone().add(I.config.step,"hours"):I.gantt_start.clone(),I.dates.push(t)}function y(){var t=["grid","date","arrow","progress","bar","details"],n=!0,e=!1,r=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var i=a.value;I.element_groups[i]=I.canvas.group().attr({id:i})}}catch(d){e=!0,r=d}finally{try{!n&&o["return"]&&o["return"]()}finally{if(e)throw r}}}function w(t){I.config.view_mode=t,"Day"===t?(I.config.step=24,I.config.column_width=38):"Half Day"===t?(I.config.step=12,I.config.column_width=38):"Quarter Day"===t?(I.config.step=6,I.config.column_width=38):"Week"===t?(I.config.step=168,I.config.column_width=140):"Month"===t&&(I.config.step=720,I.config.column_width=120)}function b(){var t=I.canvas.node.getBoundingClientRect().width,n=I.canvas.select("#grid .grid-row").attr("width");t<n&&I.canvas.attr("width",n)}function A(){var t=document.querySelector(I.element).parentElement;if(t){var n=x().diff(I.gantt_start,"hours")/I.config.step*I.config.column_width-I.config.column_width;t.scrollLeft=n}}function x(){var t=I.tasks.reduce(function(t,n){return n._start.isSameOrBefore(t._start)?n:t});return t._start}function k(){C(),$(),B(),M(),D()}function C(){var t=I.dates.length*I.config.column_width,n=I.config.header_height+I.config.padding+(I.config.bar.height+I.config.padding)*I.tasks.length;I.canvas.rect(0,0,t,n).addClass("grid-background").appendTo(I.element_groups.grid),I.canvas.attr({height:n+I.config.padding,width:"100%"})}function B(){var t=I.dates.length*I.config.column_width,n=I.config.header_height+10;I.canvas.rect(0,0,t,n).addClass("grid-header").appendTo(I.element_groups.grid)}function $(){var t=I.canvas.group().appendTo(I.element_groups.grid),n=I.canvas.group().appendTo(I.element_groups.grid),e=I.dates.length*I.config.column_width,r=I.config.bar.height+I.config.padding,a=I.config.header_height+I.config.padding/2,o=!0,i=!1,d=void 0;try{for(var s,c=I.tasks[Symbol.iterator]();!(o=(s=c.next()).done);o=!0){s.value;I.canvas.rect(0,a,e,r).addClass("grid-row").appendTo(t),I.canvas.line(0,a+r,e,a+r).addClass("row-line").appendTo(n),a+=I.config.bar.height+I.config.padding}}catch(l){i=!0,d=l}finally{try{!o&&c["return"]&&c["return"]()}finally{if(i)throw d}}}function M(){var t=0,n=I.config.header_height+I.config.padding/2,e=(I.config.bar.height+I.config.padding)*I.tasks.length,r=!0,a=!1,o=void 0;try{for(var i,d=I.dates[Symbol.iterator]();!(r=(i=d.next()).done);r=!0){var s=i.value,c="tick";H("Day")&&1===s.day()&&(c+=" thick"),H("Week")&&s.date()>=1&&s.date()<8&&(c+=" thick"),H("Month")&&s.month()%3===0&&(c+=" thick"),I.canvas.path(Snap.format("M {x} {y} v {height}",{x:t,y:n,height:e})).addClass(c).appendTo(I.element_groups.grid),t+=H("Month")?s.daysInMonth()*I.config.column_width/30:I.config.column_width}}catch(l){a=!0,o=l}finally{try{!r&&d["return"]&&d["return"]()}finally{if(a)throw o}}}function D(){if(H("Day")){var t=moment().startOf("day").diff(I.gantt_start,"hours")/I.config.step*I.config.column_width,n=0,e=I.config.column_width,r=(I.config.bar.height+I.config.padding)*I.tasks.length+I.config.header_height+I.config.padding/2;I.canvas.rect(t,n,e,r).addClass("today-highlight").appendTo(I.element_groups.grid)}}function E(){var t=!0,n=!1,e=void 0;try{for(var r,a=S()[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o=r.value;if(I.canvas.text(o.lower_x,o.lower_y,o.lower_text).addClass("lower-text").appendTo(I.element_groups.date),o.upper_text){var i=I.canvas.text(o.upper_x,o.upper_y,o.upper_text).addClass("upper-text").appendTo(I.element_groups.date);i.getBBox().x2>I.element_groups.grid.getBBox().width&&i.remove()}}}catch(d){n=!0,e=d}finally{try{!t&&a["return"]&&a["return"]()}finally{if(n)throw e}}}function S(){var t=null,n=I.dates.map(function(n,e){var r=Y(n,t,e);return t=n,r});return n}function Y(t,n,e){n||(n=t.clone().add(1,"year"));var r={"Quarter Day_lower":t.format("HH"),"Half Day_lower":t.format("HH"),Day_lower:t.date()!==n.date()?t.format("D"):"",Week_lower:t.month()!==n.month()?t.format("D MMM"):t.format("D"),Month_lower:t.format("MMMM"),"Quarter Day_upper":t.date()!==n.date()?t.format("D MMM"):"","Half Day_upper":t.date()!==n.date()?t.month()!==n.month()?t.format("D MMM"):t.format("D"):"",Day_upper:t.month()!==n.month()?t.format("MMMM"):"",Week_upper:t.month()!==n.month()?t.format("MMMM"):"",Month_upper:t.year()!==n.year()?t.format("YYYY"):""},a={x:e*I.config.column_width,lower_y:I.config.header_height,upper_y:I.config.header_height-25},o={"Quarter Day_lower":4*I.config.column_width/2,"Quarter Day_upper":0,"Half Day_lower":2*I.config.column_width/2,"Half Day_upper":0,Day_lower:I.config.column_width/2,Day_upper:30*I.config.column_width/2,Week_lower:0,Week_upper:4*I.config.column_width/2,Month_lower:I.config.column_width/2,Month_upper:12*I.config.column_width/2};return{upper_text:r[I.config.view_mode+"_upper"],lower_text:r[I.config.view_mode+"_lower"],upper_x:a.x+o[I.config.view_mode+"_upper"],upper_y:a.upper_y,lower_x:a.x+o[I.config.view_mode+"_lower"],lower_y:a.lower_y}}function j(){I._arrows=[];var t=!0,n=!1,e=void 0;try{for(var r,a=function(){var t=r.value,n=[];n=t.dependencies.map(function(n){var e=O(n);if(e){var r=(0,s["default"])(I,I._bars[e._index],I._bars[t._index]);return I.element_groups.arrow.add(r.element),r}}),I._arrows=I._arrows.concat(n)},o=I.tasks[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)a()}catch(i){n=!0,e=i}finally{try{!t&&o["return"]&&o["return"]()}finally{if(n)throw e}}}function T(){I._bars=I.tasks.map(function(t){var n=(0,i["default"])(I,t);return I.element_groups.bar.add(n.group),n})}function W(){var t=!0,n=!1,e=void 0;try{for(var r,a=function(){var t=r.value;t.arrows=I._arrows.filter(function(n){return n.from_task.task.id===t.task.id||n.to_task.task.id===t.task.id})},o=I._bars[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)a()}catch(i){n=!0,e=i}finally{try{!t&&o["return"]&&o["return"]()}finally{if(n)throw e}}}function X(){I.element_groups.grid.click(function(){U(),I.element_groups.details.selectAll(".details-wrapper").forEach(function(t){return t.addClass("hide")})})}function U(){I.canvas.selectAll(".bar-wrapper").forEach(function(t){t.removeClass("active")})}function H(t){if("string"==typeof t)return I.config.view_mode===t;if(Array.isArray(t)){var n=!0,e=!1,r=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var i=a.value;if(I.config.view_mode===i)return!0}}catch(d){e=!0,r=d}finally{try{!n&&o["return"]&&o["return"]()}finally{if(e)throw r}}return!1}}function O(t){return I.tasks.find(function(n){return n.id===t})}function G(t){return I._bars.find(function(n){return n.task.id===t})}function L(t){return t.name+"_"+Math.random().toString(36).slice(2,12)}function R(t,n){I.config["on_"+t]&&I.config["on_"+t].apply(null,n)}var I={};return r(),I}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=a,e(1);var o=e(5),i=r(o),d=e(6),s=r(d);t.exports=n["default"]},function(t,n,e){var r=e(2);"string"==typeof r&&(r=[[t.id,r,""]]);e(4)(r,{});r.locals&&(t.exports=r.locals)},function(t,n,e){n=t.exports=e(3)(),n.push([t.id,".gantt .grid-background{fill:none}.gantt .grid-header{fill:#fff;stroke:#e0e0e0;stroke-width:1.4}.gantt .grid-row{fill:#fff}.gantt .grid-row:nth-child(2n){fill:#f5f5f5}.gantt .row-line{stroke:#ebeff2}.gantt .tick{stroke:#e0e0e0;stroke-width:.2}.gantt .tick.thick{stroke-width:.4}.gantt .today-highlight{fill:#fcf8e3;opacity:.5}.gantt #arrow{fill:none;stroke:#666;stroke-width:1.4}.gantt .bar{fill:#b8c2cc;stroke:#8d99a6;stroke-width:0;transition:stroke-width .3s ease}.gantt .bar-progress{fill:#a3a3ff}.gantt .bar-invalid{fill:transparent;stroke:#8d99a6;stroke-width:1;stroke-dasharray:5}.gantt .bar-invalid~.bar-label{fill:#555}.gantt .bar-label{fill:#fff;dominant-baseline:central;text-anchor:middle;font-size:12px;font-weight:lighter;letter-spacing:.8px}.gantt .bar-label.big{fill:#555;text-anchor:start}.gantt .handle{fill:#ddd;cursor:ew-resize;opacity:0;visibility:hidden;transition:opacity .3s ease}.gantt .bar-wrapper{cursor:pointer}.gantt .bar-wrapper:hover .bar{stroke-width:2}.gantt .bar-wrapper:hover .handle{visibility:visible;opacity:1}.gantt .bar-wrapper.active .bar{stroke-width:2}.gantt .lower-text,.gantt .upper-text{font-size:12px;text-anchor:middle}.gantt .upper-text{fill:#555}.gantt .lower-text{fill:#333}.gantt #details .details-container{background:#fff;display:inline-block;padding:12px}.gantt #details .details-container h5,.gantt #details .details-container p{margin:0}.gantt #details .details-container h5{font-size:12px;font-weight:700;margin-bottom:10px;color:#555}.gantt #details .details-container p{font-size:12px;margin-bottom:6px;color:#666}.gantt #details .details-container p:last-child{margin-bottom:0}.gantt .hide{display:none}","",{version:3,sources:["/./src/src/gantt.scss"],names:[],mappings:"AAYA,wBAGE,SAAU,CAHZ,oBAME,UACA,eACA,gBAAiB,CARnB,iBAWE,SAAa,CAXf,+BAcE,YAvBgB,CASlB,iBAiBE,cAzB0B,CAQ5B,aAoBE,eACA,eAAiB,CArBnB,mBAuBG,eAAiB,CAvBpB,wBA2BE,aACA,UAAY,CA5Bd,cAgCE,UACA,YACA,gBAAiB,CAlCnB,YAsCE,aACA,eACA,eACA,gCAAiC,CAzCnC,qBA4CE,YA/CY,CAGd,oBA+CE,iBACA,eACA,eACA,kBAAmB,CAlDrB,+BAqDG,SA1Dc,CAKjB,kBAyDE,UACA,0BACA,mBACA,eACA,oBACA,mBAAqB,CA9DvB,sBAiEG,UACA,iBAAkB,CAlErB,eAuEE,UACA,iBACA,UACA,kBACA,2BAA4B,CA3E9B,oBA+EE,cAAe,CA/EjB,+BAmFI,cAAe,CAnFnB,kCAuFI,mBACA,SAAU,CAxFd,gCA8FI,cAAe,CA9FnB,sCAoGE,eACA,kBAAmB,CArGrB,mBAwGE,SA7Ge,CAKjB,mBA2GE,SA/Ge,CAIjB,mCA+GE,gBACA,qBACA,YAAa,CAjHf,2EAoHG,QAAS,CApHZ,sCAwHG,eACA,gBACA,mBACA,UAhIc,CAKjB,qCA+HG,eACA,kBACA,UAvIc,CAMjB,gDAqIG,eAAgB,CArInB,aA0IE,YAAa,CACb",file:"gantt.scss",sourcesContent:["$bar-color: #b8c2cc;\n$bar-stroke: #8D99A6;\n$border-color: #e0e0e0;\n$light-bg: #f5f5f5;\n$light-border-color: #ebeff2;\n$light-yellow: #fcf8e3;\n$text-muted: #666;\n$text-light: #555;\n$text-color: #333;\n$blue: #a3a3ff;\n$handle-color: #ddd;\n\n.gantt {\n\n\t.grid-background {\n\t\tfill: none;\n\t}\n\t.grid-header {\n\t\tfill: #ffffff;\n\t\tstroke: $border-color;\n\t\tstroke-width: 1.4;\n\t}\n\t.grid-row {\n\t\tfill: #ffffff;\n\t}\n\t.grid-row:nth-child(even) {\n\t\tfill: $light-bg;\n\t}\n\t.row-line {\n\t\tstroke: $light-border-color;\n\t}\n\t.tick {\n\t\tstroke: $border-color;\n\t\tstroke-width: 0.2;\n\t\t&.thick {\n\t\t\tstroke-width: 0.4;\n\t\t}\n\t}\n\t.today-highlight {\n\t\tfill: $light-yellow;\n\t\topacity: 0.5;\n\t}\n\n\t#arrow {\n\t\tfill: none;\n\t\tstroke: $text-muted;\n\t\tstroke-width: 1.4;\n\t}\n\n\t.bar {\n\t\tfill: $bar-color;\n\t\tstroke: $bar-stroke;\n\t\tstroke-width: 0;\n\t\ttransition: stroke-width .3s ease;\n\t}\n\t.bar-progress {\n\t\tfill: $blue;\n\t}\n\t.bar-invalid {\n\t\tfill: transparent;\n\t\tstroke: $bar-stroke;\n\t\tstroke-width: 1;\n\t\tstroke-dasharray: 5;\n\n\t\t&~.bar-label {\n\t\t\tfill: $text-light;\n\t\t}\n\t}\n\t.bar-label {\n\t\tfill: #fff;\n\t\tdominant-baseline: central;\n\t\ttext-anchor: middle;\n\t\tfont-size: 12px;\n\t\tfont-weight: lighter;\n\t\tletter-spacing: 0.8px;\n\n\t\t&.big {\n\t\t\tfill: $text-light;\n\t\t\ttext-anchor: start;\n\t\t}\n\t}\n\n\t.handle {\n\t\tfill: $handle-color;\n\t\tcursor: ew-resize;\n\t\topacity: 0;\n\t\tvisibility: hidden;\n\t\ttransition: opacity .3s ease;\n\t}\n\n\t.bar-wrapper {\n\t\tcursor: pointer;\n\n\t\t&:hover {\n\t\t\t.bar {\n\t\t\t\tstroke-width: 2;\n\t\t\t}\n\n\t\t\t.handle {\n\t\t\t\tvisibility: visible;\n\t\t\t\topacity: 1;\n\t\t\t}\n\t\t}\n\n\t\t&.active {\n\t\t\t.bar {\n\t\t\t\tstroke-width: 2;\n\t\t\t}\n\t\t}\n\t}\n\n\t.lower-text, .upper-text {\n\t\tfont-size: 12px;\n\t\ttext-anchor: middle;\n\t}\n\t.upper-text {\n\t\tfill: $text-light;\n\t}\n\t.lower-text {\n\t\tfill: $text-color;\n\t}\n\n\t#details .details-container {\n\t\tbackground: #fff;\n\t\tdisplay: inline-block;\n\t\tpadding: 12px;\n\n\t\th5, p {\n\t\t\tmargin: 0;\n\t\t}\n\n\t\th5 {\n\t\t\tfont-size: 12px;\n\t\t\tfont-weight: bold;\n\t\t\tmargin-bottom: 10px;\n\t\t\tcolor: $text-light;\n\t\t}\n\n\t\tp {\n\t\t\tfont-size: 12px;\n\t\t\tmargin-bottom: 6px;\n\t\t\tcolor: $text-muted;\n\t\t}\n\n\t\tp:last-child {\n\t\t\tmargin-bottom: 0;\n\t\t}\n\t}\n\n\t.hide {\n\t\tdisplay: none;\n\t}\n}"],sourceRoot:"webpack://"}])},function(t,n){t.exports=function(){var t=[];return t.toString=function(){for(var t=[],n=0;n<this.length;n++){var e=this[n];e[2]?t.push("@media "+e[2]+"{"+e[1]+"}"):t.push(e[1])}return t.join("")},t.i=function(n,e){"string"==typeof n&&(n=[[null,n,""]]);for(var r={},a=0;a<this.length;a++){var o=this[a][0];"number"==typeof o&&(r[o]=!0)}for(a=0;a<n.length;a++){var i=n[a];"number"==typeof i[0]&&r[i[0]]||(e&&!i[2]?i[2]=e:e&&(i[2]="("+i[2]+") and ("+e+")"),t.push(i))}},t}},function(t,n,e){function r(t,n){for(var e=0;e<t.length;e++){var r=t[e],a=g[r.id];if(a){a.refs++;for(var o=0;o<a.parts.length;o++)a.parts[o](r.parts[o]);for(;o<r.parts.length;o++)a.parts.push(c(r.parts[o],n))}else{for(var i=[],o=0;o<r.parts.length;o++)i.push(c(r.parts[o],n));g[r.id]={id:r.id,refs:1,parts:i}}}}function a(t){for(var n=[],e={},r=0;r<t.length;r++){var a=t[r],o=a[0],i=a[1],d=a[2],s=a[3],c={css:i,media:d,sourceMap:s};e[o]?e[o].parts.push(c):n.push(e[o]={id:o,parts:[c]})}return n}function o(t,n){var e=_(),r=y[y.length-1];if("top"===t.insertAt)r?r.nextSibling?e.insertBefore(n,r.nextSibling):e.appendChild(n):e.insertBefore(n,e.firstChild),y.push(n);else{if("bottom"!==t.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");e.appendChild(n)}}function i(t){t.parentNode.removeChild(t);var n=y.indexOf(t);n>=0&&y.splice(n,1)}function d(t){var n=document.createElement("style");return n.type="text/css",o(t,n),n}function s(t){var n=document.createElement("link");return n.rel="stylesheet",o(t,n),n}function c(t,n){var e,r,a;if(n.singleton){var o=m++;e=v||(v=d(n)),r=l.bind(null,e,o,!1),a=l.bind(null,e,o,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(e=s(n),r=u.bind(null,e),a=function(){i(e),e.href&&URL.revokeObjectURL(e.href)}):(e=d(n),r=f.bind(null,e),a=function(){i(e)});return r(t),function(n){if(n){if(n.css===t.css&&n.media===t.media&&n.sourceMap===t.sourceMap)return;r(t=n)}else a()}}function l(t,n,e,r){var a=e?"":r.css;if(t.styleSheet)t.styleSheet.cssText=w(n,a);else{var o=document.createTextNode(a),i=t.childNodes;i[n]&&t.removeChild(i[n]),i.length?t.insertBefore(o,i[n]):t.appendChild(o)}}function f(t,n){var e=n.css,r=n.media;if(r&&t.setAttribute("media",r),t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}function u(t,n){var e=n.css,r=n.sourceMap;r&&(e+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var a=new Blob([e],{type:"text/css"}),o=t.href;t.href=URL.createObjectURL(a),o&&URL.revokeObjectURL(o)}var g={},p=function(t){var n;return function(){return"undefined"==typeof n&&(n=t.apply(this,arguments)),n}},h=p(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),_=p(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,m=0,y=[];t.exports=function(t,n){n=n||{},"undefined"==typeof n.singleton&&(n.singleton=h()),"undefined"==typeof n.insertAt&&(n.insertAt="bottom");var e=a(t);return r(e,n),function(t){for(var o=[],i=0;i<e.length;i++){var d=e[i],s=g[d.id];s.refs--,o.push(s)}if(t){var c=a(t);r(c,n)}for(var i=0;i<o.length;i++){var s=o[i];if(0===s.refs){for(var l=0;l<s.parts.length;l++)s.parts[l]();delete g[s.id]}}}};var w=function(){var t=[];return function(n,e){return t[n]=e,t.filter(Boolean).join("\n")}}()},function(t,n){"use strict";function e(t,n){function e(){r(),a(),d(),g()}function r(){q.action_completed=!1,q.task=n}function a(){o(),i()}function o(){q.invalid=q.task.invalid,q.height=t.config.bar.height,q.x=U(),q.y=H(),q.corner_radius=3,q.duration=(q.task._end.diff(q.task._start,"hours")+24)/t.config.step,q.width=t.config.column_width*q.duration,q.progress_width=t.config.column_width*q.duration*(q.task.progress/100)||0,q.group=t.canvas.group().addClass("bar-wrapper"),q.bar_group=t.canvas.group().addClass("bar-group").appendTo(q.group),q.handle_group=t.canvas.group().addClass("handle-group").appendTo(q.group)}function i(){Snap.plugin(function(t,n,e,r,a){n.prototype.getX=function(){return+this.attr("x")},n.prototype.getY=function(){return+this.attr("y")},n.prototype.getWidth=function(){return+this.attr("width")},n.prototype.getHeight=function(){return+this.attr("height")},n.prototype.getEndX=function(){return this.getX()+this.getWidth()}})}function d(){s(),c(),l(),f()}function s(){q.$bar=t.canvas.rect(q.x,q.y,q.width,q.height,q.corner_radius,q.corner_radius).addClass("bar").appendTo(q.bar_group),q.invalid&&q.$bar.addClass("bar-invalid")}function c(){q.invalid||(q.$bar_progress=t.canvas.rect(q.x,q.y,q.progress_width,q.height,q.corner_radius,q.corner_radius).addClass("bar-progress").appendTo(q.bar_group))}function l(){t.canvas.text(q.x+q.width/2,q.y+q.height/2,q.task.name).addClass("bar-label").appendTo(q.bar_group),R()}function f(){if(!q.invalid){var n=q.$bar,e=8;t.canvas.rect(n.getX()+n.getWidth()-9,n.getY()+1,e,q.height-2,q.corner_radius,q.corner_radius).addClass("handle right").appendTo(q.handle_group),t.canvas.rect(n.getX()+1,n.getY()+1,e,q.height-2,q.corner_radius,q.corner_radius).addClass("handle left").appendTo(q.handle_group),q.task.progress&&q.task.progress<100&&t.canvas.polygon(u()).addClass("handle progress").appendTo(q.handle_group)}}function u(){var t=q.$bar_progress;return[t.getEndX()-5,t.getY()+t.getHeight(),t.getEndX()+5,t.getY()+t.getHeight(),t.getEndX(),t.getY()+t.getHeight()-8.66]}function g(){q.invalid||(S(),p(),m(),w(),b())}function p(){var n=t.element_groups.details;if(q.details_box=n.select(".details-wrapper[data-task='"+q.task.id+"']"),!q.details_box){q.details_box=t.canvas.group().addClass("details-wrapper hide").attr("data-task",q.task.id).appendTo(n),h();var e=t.canvas.filter(Snap.filter.shadow(0,1,1,"#666",.6));q.details_box.attr({filter:e})}q.group.click(function(t){q.action_completed||(n.selectAll(".details-wrapper").forEach(function(t){return t.addClass("hide")}),q.details_box.removeClass("hide"))})}function h(){var t=v(),n=t.x,e=t.y;q.details_box.transform("t"+n+","+e),q.details_box.clear();var r=_(),a=Snap.parse('<foreignObject width="5000" height="2000">\n\t\t\t\t<body xmlns="http://www.w3.org/1999/xhtml">\n\t\t\t\t\t'+r+"\n\t\t\t\t</body>\n\t\t\t\t</foreignObject>");q.details_box.append(a)}function _(){if(t.config.custom_popup_html){var e=t.config.custom_popup_html;if("string"==typeof e)return e;if(N(e))return e(n)}var r=q.task._start.format("MMM D"),a=q.task._end.format("MMM D"),o=q.task.name+": "+r+" - "+a,i="Duration: "+q.duration+" days",d=q.task.progress?"Progress: "+q.task.progress:null,s='\n\t\t\t<div class="details-container">\n\t\t\t\t<h5>'+o+"</h5>\n\t\t\t\t<p>"+i+"</p>\n\t\t\t\t"+(d?"<p>"+d+"</p>":"")+"\n\t\t\t</div>\n\t\t";return s}function v(){return{x:q.$bar.getEndX()+2,y:q.$bar.getY()-10}}function m(){function t(t,n){M(t,n)}function n(){D()}function e(t,n){C(t,n)}function r(){B()}var a=y(),o=a.left,i=a.right;o.drag(e,A,r),i.drag(t,A,n)}function y(){return{left:q.handle_group.select(".handle.left"),right:q.handle_group.select(".handle.right")}}function w(){q.bar_group.drag(x,A,k)}function b(){function t(t,n){t>a.max_dx&&(t=a.max_dx),t<a.min_dx&&(t=a.min_dx),a.attr("width",a.owidth+t),o.attr("points",u()),a.finaldx=t}function n(){a.finaldx&&(j(),T())}function e(){a.finaldx=0,a.owidth=a.getWidth(),a.min_dx=-a.getWidth(),a.max_dx=r.getWidth()-a.getWidth()}var r=q.$bar,a=q.$bar_progress,o=q.group.select(".handle.progress");o&&o.drag(t,e,n)}function A(){var t=q.$bar;t.ox=t.getX(),t.oy=t.getY(),t.owidth=t.getWidth(),t.finaldx=0,$("onstart")}function x(t,n){var e=q.$bar;e.finaldx=O(t),E({x:e.ox+e.finaldx}),$("onmove",[t,n])}function k(){var t=q.$bar;t.finaldx&&(Y(),T(),$("onstop"))}function C(t,n){var e=q.$bar;e.finaldx=O(t),E({x:e.ox+e.finaldx,width:e.owidth-e.finaldx}),$("onmove",[t,n])}function B(){var t=q.$bar;t.finaldx&&Y(),T(),$("onstop")}function $(n,e){var r=t.dependency_map;if(r[q.task.id]){var a=!0,o=!1,i=void 0;try{for(var d,s=r[q.task.id][Symbol.iterator]();!(a=(d=s.next()).done);a=!0){var c=d.value,l=t.get_bar(c);l[n].apply(l,e)}}catch(f){o=!0,i=f}finally{try{!a&&s["return"]&&s["return"]()}finally{if(o)throw i}}}}function M(t,n){var e=q.$bar;e.finaldx=O(t),E({width:e.owidth+e.finaldx})}function D(){var t=q.$bar;t.finaldx&&Y(),T()}function E(e){var r=e.x,a=void 0===r?null:r,o=e.width,i=void 0===o?null:o,d=q.$bar;if(a){var s=n.dependencies.map(function(n){return t.get_bar(n).$bar.getX()}),c=s.reduce(function(t,n){return a>=n},a);if(!c)return void(i=null);G(d,"x",a)}i&&i>=t.config.column_width&&G(d,"width",i),R(),I(),L(),z(),Q()}function S(){q.group.click(function(){q.action_completed||(q.group.hasClass("active")&&t.trigger_event("click",[q.task]),t.unselect_all(),q.group.toggleClass("active"))})}function Y(){var n=W(),e=n.new_start_date,r=n.new_end_date;q.task._start=e,q.task._end=r,h(),t.trigger_event("date_change",[q.task,e,r])}function j(){var n=X();q.task.progress=n,h(),t.trigger_event("progress_change",[q.task,n])}function T(){q.action_completed=!0,setTimeout(function(){return q.action_completed=!1},2e3)}function W(){var n=q.$bar,e=n.getX()/t.config.column_width,r=t.gantt_start.clone().add(e*t.config.step,"hours"),a=n.getWidth()/t.config.column_width,o=r.clone().add(a*t.config.step,"hours");return{new_start_date:r,new_end_date:o}}function X(){var t=q.$bar_progress.getWidth()/q.$bar.getWidth()*100;return parseInt(t,10)}function U(){var n=q.task._start.diff(t.gantt_start,"hours")/t.config.step*t.config.column_width;return t.view_is("Month")&&(n=q.task._start.diff(t.gantt_start,"days")*t.config.column_width/30),n}function H(){return t.config.header_height+t.config.padding+q.task._index*(q.height+t.config.padding)}function O(n){var e=n,r=void 0,a=void 0;return t.view_is("Week")?(r=n%(t.config.column_width/7),a=e-r+(r<t.config.column_width/14?0:t.config.column_width/7)):t.view_is("Month")?(r=n%(t.config.column_width/30),a=e-r+(r<t.config.column_width/60?0:t.config.column_width/30)):(r=n%t.config.column_width,a=e-r+(r<t.config.column_width/2?0:t.config.column_width)),a}function G(t,n,e){return e=+e,isNaN(e)||t.attr(n,e),t}function L(){q.$bar_progress.attr("x",q.$bar.getX()),q.$bar_progress.attr("width",q.$bar.getWidth()*(q.task.progress/100))}function R(){var t=q.$bar,n=q.group.select(".bar-label");n.getBBox().width>t.getWidth()?n.addClass("big").attr("x",t.getX()+t.getWidth()+5):n.removeClass("big").attr("x",t.getX()+t.getWidth()/2)}function I(){var t=q.$bar;q.handle_group.select(".handle.left").attr({x:t.getX()+1}),q.handle_group.select(".handle.right").attr({x:t.getEndX()-9});var n=q.group.select(".handle.progress");n&&n.attr("points",u())}function z(){var t=!0,n=!1,e=void 0;try{for(var r,a=q.arrows[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o=r.value;o.update()}}catch(i){n=!0,e=i}finally{try{!t&&a["return"]&&a["return"]()}finally{if(n)throw e}}}function Q(){var t=v(),n=t.x,e=t.y;q.details_box&&q.details_box.transform("t"+n+","+e)}function N(t){var n={};return t&&"[object Function]"===n.toString.call(t)}var q={};return q.onstart=A,q.onmove=x,q.onstop=k,q.onmove_handle_left=C,q.onstop_handle_left=B,e(),q}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=e,t.exports=n["default"]},function(t,n){"use strict";function e(t,n,e){function r(){d.from_task=n,d.to_task=e,a(),o()}function a(){d.start_x=n.$bar.getX()+n.$bar.getWidth()/2;for(var r=function(){return e.$bar.getX()<d.start_x+t.config.padding&&d.start_x>n.$bar.getX()+t.config.padding};r();)d.start_x-=10;d.start_y=t.config.header_height+t.config.bar.height+(t.config.padding+t.config.bar.height)*n.task._index+t.config.padding,d.end_x=e.$bar.getX()-t.config.padding/2,d.end_y=t.config.header_height+t.config.bar.height/2+(t.config.padding+t.config.bar.height)*e.task._index+t.config.padding;var a=n.task._index>e.task._index;d.curve=t.config.arrow.curve,d.clockwise=a?1:0,d.curve_y=a?-d.curve:d.curve,d.offset=a?d.end_y+t.config.arrow.curve:d.end_y-t.config.arrow.curve,d.path=Snap.format("M {start_x} {start_y} V {offset} a {curve} {curve} 0 0 {clockwise} {curve} {curve_y} L {end_x} {end_y} m -5 -5 l 5 5 l -5 5",{start_x:d.start_x,start_y:d.start_y,end_x:d.end_x,end_y:d.end_y,offset:d.offset,curve:d.curve,clockwise:d.clockwise,curve_y:d.curve_y}),e.$bar.getX()<n.$bar.getX()+t.config.padding&&(d.path=Snap.format("M {start_x} {start_y} v {down_1} a {curve} {curve} 0 0 1 -{curve} {curve} H {left} a {curve} {curve} 0 0 {clockwise} -{curve} {curve_y} V {down_2} a {curve} {curve} 0 0 {clockwise} {curve} {curve_y} L {end_x} {end_y} m -5 -5 l 5 5 l -5 5",{start_x:d.start_x,start_y:d.start_y,end_x:d.end_x,end_y:d.end_y,down_1:t.config.padding/2-d.curve,down_2:e.$bar.getY()+e.$bar.getHeight()/2-d.curve_y,left:e.$bar.getX()-t.config.padding,offset:d.offset,curve:d.curve,clockwise:d.clockwise,curve_y:d.curve_y}))}function o(){d.element=t.canvas.path(d.path).attr("data-from",d.from_task.task.id).attr("data-to",d.to_task.task.id)}function i(){a(),d.element.attr("d",d.path)}var d={};return d.update=i,r(),d}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=e,t.exports=n["default"]}])}); | ||
//# sourceMappingURL=frappe-gantt.min.js.map |
{ | ||
"name": "frappe-gantt", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A simple, modern, interactive gantt library for the web", | ||
@@ -5,0 +5,0 @@ "main": "dist/frappe-gantt.js", |
@@ -151,17 +151,5 @@ /* global Snap */ | ||
.appendTo(popover_group); | ||
gt.canvas.rect(0, 0, 0, 110, 2, 2) | ||
.addClass('details-container') | ||
.appendTo(self.details_box); | ||
gt.canvas.text(0, 0, '') | ||
.attr({ dx: 10, dy: 30 }) | ||
.addClass('details-heading') | ||
.appendTo(self.details_box); | ||
gt.canvas.text(0, 0, '') | ||
.attr({ dx: 10, dy: 65 }) | ||
.addClass('details-body') | ||
.appendTo(self.details_box); | ||
gt.canvas.text(0, 0, '') | ||
.attr({ dx: 10, dy: 90 }) | ||
.addClass('details-body') | ||
.appendTo(self.details_box); | ||
render_details(); | ||
const f = gt.canvas.filter( | ||
@@ -181,3 +169,2 @@ Snap.filter.shadow(0, 1, 1, '#666', 0.6)); | ||
.forEach(el => el.addClass('hide')); | ||
render_details(); | ||
self.details_box.removeClass('hide'); | ||
@@ -190,23 +177,44 @@ }); | ||
self.details_box.transform(`t${x},${y}`); | ||
self.details_box.clear(); | ||
const start_date = self.task._start.format('MMM D'), | ||
end_date = self.task._end.format('MMM D'), | ||
heading = `${self.task.name}: ${start_date} - ${end_date}`; | ||
const html = get_details_html(); | ||
const foreign_object = | ||
Snap.parse(`<foreignObject width="5000" height="2000"> | ||
<body xmlns="http://www.w3.org/1999/xhtml"> | ||
${html} | ||
</body> | ||
</foreignObject>`); | ||
self.details_box.append(foreign_object); | ||
} | ||
const $heading = self.details_box | ||
.select('.details-heading') | ||
.attr('text', heading); | ||
function get_details_html() { | ||
const bbox = $heading.getBBox(); | ||
self.details_box.select('.details-container') | ||
.attr({ width: bbox.width + 20 }); | ||
// custom html in config | ||
if(gt.config.custom_popup_html) { | ||
const html = gt.config.custom_popup_html; | ||
if(typeof html === 'string') { | ||
return html; | ||
} | ||
if(isFunction(html)) { | ||
return html(task); | ||
} | ||
} | ||
const duration = self.task._end.diff(self.task._start, 'days'), | ||
body1 = `Duration: ${duration + 1} days`, | ||
body2 = self.task.progress ? | ||
`Progress: ${self.task.progress}` : ''; | ||
const start_date = self.task._start.format('MMM D'); | ||
const end_date = self.task._end.format('MMM D'); | ||
const heading = `${self.task.name}: ${start_date} - ${end_date}`; | ||
const $body = self.details_box.selectAll('.details-body'); | ||
$body[0].attr('text', body1); | ||
$body[1].attr('text', body2); | ||
const line_1 = `Duration: ${self.duration} days`; | ||
const line_2 = self.task.progress ? `Progress: ${self.task.progress}` : null; | ||
const html = ` | ||
<div class="details-container"> | ||
<h5>${heading}</h5> | ||
<p>${line_1}</p> | ||
${ | ||
line_2 ? `<p>${line_2}</p>` : '' | ||
} | ||
</div> | ||
`; | ||
return html; | ||
} | ||
@@ -495,5 +503,4 @@ | ||
}); | ||
self.group.select('.handle.progress').attr( | ||
'points', get_progress_polygon_points() | ||
); | ||
const handle = self.group.select('.handle.progress'); | ||
handle && handle.attr('points', get_progress_polygon_points()); | ||
} | ||
@@ -512,2 +519,7 @@ | ||
function isFunction(functionToCheck) { | ||
var getType = {}; | ||
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; | ||
} | ||
init(); | ||
@@ -514,0 +526,0 @@ |
@@ -27,2 +27,3 @@ /* global moment, Snap */ | ||
self.trigger_event = trigger_event; | ||
self.refresh = refresh; | ||
@@ -54,8 +55,14 @@ // initialize with default view mode | ||
view_mode: 'Day', | ||
date_format: 'YYYY-MM-DD' | ||
date_format: 'YYYY-MM-DD', | ||
custom_popup_html: null | ||
}; | ||
self.config = Object.assign({}, defaults, config); | ||
reset_variables(tasks); | ||
} | ||
function reset_variables(tasks) { | ||
self.element = element; | ||
self._tasks = tasks; | ||
self.config = Object.assign({}, defaults, config); | ||
@@ -67,2 +74,7 @@ self._bars = []; | ||
function refresh(updated_tasks) { | ||
reset_variables(updated_tasks); | ||
change_view_mode(self.config.view_mode); | ||
} | ||
function change_view_mode(mode) { | ||
@@ -123,2 +135,8 @@ set_scale(mode); | ||
} | ||
// uids | ||
if(!task.id) { | ||
task.id = generate_id(task); | ||
} | ||
return task; | ||
@@ -141,2 +159,3 @@ }); | ||
self.gantt_start = self.gantt_end = null; | ||
for(let task of self.tasks) { | ||
@@ -156,2 +175,3 @@ // set global start and end date | ||
function prepare_canvas() { | ||
if(self.canvas) return; | ||
self.canvas = Snap(self.element).addClass('gantt'); | ||
@@ -242,3 +262,3 @@ } | ||
const cur_width = self.canvas.node.getBoundingClientRect().width; | ||
const actual_width = self.canvas.getBBox().width; | ||
const actual_width = self.canvas.select('#grid .grid-row').attr('width'); | ||
if(cur_width < actual_width) { | ||
@@ -410,6 +430,9 @@ self.canvas.attr('width', actual_width); | ||
'Day_lower': date.date() !== last_date.date() ? date.format('D') : '', | ||
'Week_lower': 'Week ' + date.format('W'), | ||
'Week_lower': date.month() !== last_date.month() ? | ||
date.format('D MMM') : date.format('D'), | ||
'Month_lower': date.format('MMMM'), | ||
'Quarter Day_upper': date.date() !== last_date.date() ? date.format('D MMM') : '', | ||
'Half Day_upper': date.date() !== last_date.date() ? date.format('D MMM') : '', | ||
'Half Day_upper': date.date() !== last_date.date() ? | ||
date.month() !== last_date.month() ? | ||
date.format('D MMM') : date.format('D') : '', | ||
'Day_upper': date.month() !== last_date.month() ? date.format('MMMM') : '', | ||
@@ -433,5 +456,5 @@ 'Week_upper': date.month() !== last_date.month() ? date.format('MMMM') : '', | ||
'Day_upper': (self.config.column_width * 30) / 2, | ||
'Week_lower': self.config.column_width / 2, | ||
'Week_lower': 0, | ||
'Week_upper': (self.config.column_width * 4) / 2, | ||
'Month_lower': (date.daysInMonth() * self.config.column_width / 30) / 2, | ||
'Month_lower': self.config.column_width / 2, | ||
'Month_upper': (self.config.column_width * 12) / 2 | ||
@@ -526,2 +549,6 @@ }; | ||
function generate_id(task) { | ||
return task.name + '_' + Math.random().toString(36).slice(2, 12); | ||
} | ||
function trigger_event(event, args) { | ||
@@ -528,0 +555,0 @@ if(self.config['on_' + event]) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
377495
2736
3