diff --git a/src/bar.js b/src/bar.js index b853d67..06acbc3 100644 --- a/src/bar.js +++ b/src/bar.js @@ -31,8 +31,8 @@ export default class Bar { this.width = this.gantt.options.column_width * this.duration; this.progress_width = this.gantt.options.column_width * - this.duration * - (this.task.progress / 100) || 0; + this.duration * + (this.task.progress / 100) || 0; this.group = createSVG('g', { class: 'bar-wrapper' + @@ -72,8 +72,8 @@ export default class Bar { this.compute_expected_progress(); this.expected_progress_width = this.gantt.options.column_width * - this.duration * - (this.expected_progress / 100) || 0; + this.duration * + (this.expected_progress / 100) || 0; } draw() { @@ -92,7 +92,6 @@ export default class Bar { } draw_bar() { - this.$bar = createSVG('rect', { x: this.x, y: this.y, @@ -100,7 +99,12 @@ export default class Bar { height: this.height, rx: this.corner_radius, ry: this.corner_radius, - class: 'bar' + (/^((?!chrome|android).)*safari/i.test(navigator.userAgent) && !this.task.important ? ' safari' : ''), + class: + 'bar' + + (/^((?!chrome|android).)*safari/i.test(navigator.userAgent) && + !this.task.important + ? ' safari' + : ''), append_to: this.bar_group, }); @@ -249,14 +253,12 @@ export default class Bar { class: 'handle left', append_to: this.handle_group, }); - } if (!this.gantt.options.progress_readonly) { const bar_progress = this.$bar_progress; this.$handle_progress = createSVG('circle', { cx: bar_progress.getEndX(), - cy: bar_progress.getY() + - bar_progress.getHeight() / 2, + cy: bar_progress.getY() + bar_progress.getHeight() / 2, r: 5, class: 'handle progress', append_to: this.handle_group, @@ -285,12 +287,12 @@ export default class Bar { this.group, 'mouseenter', (e) => - (timeout = setTimeout(() => { - this.show_popup(e.offsetX || e.layerX); - document.getElementById( - `${task_id}-highlight`, - ).style.display = 'block'; - }, 200)), + (timeout = setTimeout(() => { + this.show_popup(e.offsetX || e.layerX); + document.getElementById( + `${task_id}-highlight`, + ).style.display = 'block'; + }, 200)), ); $.on(this.group, 'mouseleave', () => { @@ -300,7 +302,7 @@ export default class Bar { 'none'; }); - $.on(this.group, "click", () => { + $.on(this.group, 'click', () => { this.gantt.trigger_event('click', [this.task]); }); @@ -309,8 +311,9 @@ export default class Bar { // just finished a move action, wait for a few seconds return; } - this.group.classList.remove('active') - if (this.gantt.popup) this.gantt.popup.parent.classList.remove('hidden'); + this.group.classList.remove('active'); + if (this.gantt.popup) + this.gantt.popup.parent.classList.remove('hidden'); this.gantt.trigger_event('double_click', [this.task]); }); @@ -449,12 +452,14 @@ export default class Bar { x_in_units * this.gantt.options.step, 'hour', ); - const start_offset = this.gantt.gantt_start.getTimezoneOffset() - new_start_date.getTimezoneOffset(); + const start_offset = + this.gantt.gantt_start.getTimezoneOffset() - + new_start_date.getTimezoneOffset(); if (start_offset) { new_start_date = date_utils.add( new_start_date, start_offset, - 'minute' + 'minute', ); } @@ -562,8 +567,8 @@ export default class Bar { this.$expected_bar_progress.setAttribute( 'width', this.gantt.options.column_width * - this.duration * - (this.expected_progress / 100) || 0, + this.duration * + (this.expected_progress / 100) || 0, ); } diff --git a/src/index.js b/src/index.js index 7141917..e741597 100644 --- a/src/index.js +++ b/src/index.js @@ -78,7 +78,7 @@ export default class Gantt { } 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", + " HTML DOM element or SVG DOM element for the 'element' parameter", ); } @@ -144,7 +144,7 @@ export default class Gantt { if (diff < 0) { throw Error( "start of task can't be after end of task: in task #, " + - (i + 1), + (i + 1), ); } // make task invalid if duration too large @@ -390,7 +390,7 @@ export default class Gantt { this.options.header_height + this.options.padding + (this.options.bar_height + this.options.padding) * - this.tasks.length; + this.tasks.length; createSVG('rect', { x: 0, @@ -621,7 +621,7 @@ export default class Gantt { x + (date_utils.diff(today, this.gantt_start, 'hour') / this.options.step) * - this.options.column_width, + this.options.column_width, date: today, }; } @@ -776,10 +776,10 @@ export default class Gantt { date.getDate() !== last_date.getDate() ? date.getMonth() !== last_date.getMonth() ? date_utils.format( - date, - 'D MMM', - this.options.language, - ) + date, + 'D MMM', + this.options.language, + ) : date_utils.format(date, 'D', this.options.language) : '', Day_upper: @@ -801,7 +801,7 @@ export default class Gantt { }; let column_width = this.view_is(VIEW_MODE.MONTH) ? (date_utils.get_days_in_month(date) * this.options.column_width) / - 30 + 30 : this.options.column_width; const base_pos = { x: last_date_info @@ -833,17 +833,17 @@ export default class Gantt { base_pos_x: base_pos.x, upper_text: this.options.lower_text ? this.options.upper_text( - date, - this.options.view_mode, - date_text[`${this.options.view_mode}_upper`], - ) + date, + this.options.view_mode, + date_text[`${this.options.view_mode}_upper`], + ) : date_text[`${this.options.view_mode}_upper`], lower_text: this.options.lower_text ? this.options.lower_text( - date, - this.options.view_mode, - date_text[`${this.options.view_mode}_lower`], - ) + date, + this.options.view_mode, + date_text[`${this.options.view_mode}_lower`], + ) : date_text[`${this.options.view_mode}_lower`], upper_x: base_pos.x + x_pos[`${this.options.view_mode}_upper`], upper_y: base_pos.upper_y, @@ -919,7 +919,7 @@ export default class Gantt { const scroll_pos = (hours_before_first_task / this.options.step) * - this.options.column_width - + this.options.column_width - this.options.column_width; parent_element.scrollTo({ left: scroll_pos, behavior: 'smooth' }); } @@ -955,9 +955,9 @@ export default class Gantt { return is_dragging || is_resizing_left || is_resizing_right; } - this.$svg.onclick = e => { - if (e.target.classList.contains('grid-row')) this.unselect_all() - } + this.$svg.onclick = (e) => { + if (e.target.classList.contains('grid-row')) this.unselect_all(); + }; $.on(this.$svg, 'mousedown', '.bar-wrapper, .handle', (e, element) => { const bar_wrapper = $.closest('.bar-wrapper', element); @@ -1064,7 +1064,7 @@ export default class Gantt { $.on(this.$svg, 'mousemove', (e) => { if (!action_in_progress()) return; - console.log(e) + console.log(e); const dx = (e.offsetX || e.layerX) - x_on_start; bars.forEach((bar) => { @@ -1088,7 +1088,11 @@ export default class Gantt { width: $bar.owidth + $bar.finaldx, }); } - } else if (is_dragging && !this.options.readonly && !this.options.dates_readonly) { + } else if ( + is_dragging && + !this.options.readonly && + !this.options.dates_readonly + ) { bar.update_bar_position({ x: $bar.ox + $bar.finaldx }); } });