From 67a67b927c8aa24270dec2f9edfde3896d87a84b Mon Sep 17 00:00:00 2001 From: Dhaifallah Alwadani Date: Wed, 21 Jun 2017 17:36:16 +0300 Subject: [PATCH 1/2] Remove letter-spacing to display Arabic properly --- src/gantt.scss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gantt.scss b/src/gantt.scss index c158682..02bc5d2 100644 --- a/src/gantt.scss +++ b/src/gantt.scss @@ -72,7 +72,6 @@ $handle-color: #ddd; text-anchor: middle; font-size: 12px; font-weight: lighter; - letter-spacing: 0.8px; &.big { fill: $text-light; @@ -150,4 +149,4 @@ $handle-color: #ddd; .hide { display: none; } -} \ No newline at end of file +} From 241c65db697475a3a17324f4c613d28353f89a8c Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 31 Jul 2017 14:46:10 +0530 Subject: [PATCH 2/2] Element parameter support for HTML Element, SVG Element or CSS selector (#25) * * adjusted the library to support both string css selectors and a raw svg element when resetting its internal variables * * changes parent_element to use const again instead of let * * updated the element selection logic to include checking for an html element and finding a child svg object * * updated parameter comment and exception message to mention both html and svg dom element support * Code formatting --- src/Gantt.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Gantt.js b/src/Gantt.js index cf0af59..97d3f65 100644 --- a/src/Gantt.js +++ b/src/Gantt.js @@ -1,7 +1,7 @@ /* global moment, Snap */ /** * Gantt: - * element: querySelector string, required + * element: querySelector string, HTML DOM or SVG DOM element, required * tasks: array of tasks, required * task: { id, name, start, end, progress, dependencies, custom_class } * config: configuration options, optional @@ -60,8 +60,17 @@ export default function Gantt(element, tasks, config) { } function reset_variables(tasks) { + if(typeof element === 'string') { + self.element = document.querySelector(element); + } else if (element instanceof SVGElement) { + self.element = element; + } else if (element instanceof HTMLElement) { + self.element = element.querySelector('svg'); + } else { + throw new TypeError('Frappé Gantt only supports usage of a string CSS selector,' + + ' HTML DOM element or SVG DOM element for the \'element\' parameter'); + } - self.element = element; self._tasks = tasks; self._bars = []; @@ -260,7 +269,8 @@ export default function Gantt(element, tasks, config) { } function set_scroll_position() { - const parent_element = document.querySelector(self.element).parentElement; + const parent_element = self.element.parentElement; + if(!parent_element) return; const scroll_pos = get_min_date().diff(self.gantt_start, 'hours') /