From 0c39cc9b4ecf4a73d655a6eaf63148ebf41ffd6f Mon Sep 17 00:00:00 2001 From: Anto Christopher Date: Wed, 23 May 2018 12:36:43 +0530 Subject: [PATCH] Add feature to change popup trigger event (#77) * Add change-popup-mode * Add feature to change popup trigger event * Remove example of change_popup_mode from index * Revert back to the original build files * Make changes asked in review * Remove default to click from bind event as default already set * code formatting --- index.html | 1 - src/bar.js | 4 ++-- src/index.js | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 4a93205..2dc15b1 100644 --- a/index.html +++ b/index.html @@ -76,7 +76,6 @@ custom_class: 'bar-milestone' }, ] - var gantt_chart = new Gantt(".gantt-target", tasks, { on_click: function (task) { console.log(task); diff --git a/src/bar.js b/src/bar.js index 6befb8f..7c03ec3 100644 --- a/src/bar.js +++ b/src/bar.js @@ -175,7 +175,7 @@ export default class Bar { } setup_click_event() { - $.on(this.group, 'focus click', e => { + $.on(this.group, 'focus ' + this.gantt.options.popup_trigger, e => { if (this.action_completed) { // just finished a move action, wait for a few seconds return; @@ -184,7 +184,7 @@ export default class Bar { if (e.type === 'click') { this.gantt.trigger_event('click', [this.task]); } - + this.gantt.unselect_all(); this.group.classList.toggle('active'); diff --git a/src/index.js b/src/index.js index ee0929d..51bbb9d 100644 --- a/src/index.js +++ b/src/index.js @@ -54,6 +54,7 @@ export default class Gantt { padding: 18, view_mode: 'Day', date_format: 'YYYY-MM-DD', + popup_trigger: 'click', custom_popup_html: null }; this.options = Object.assign({}, default_options, options); @@ -571,7 +572,7 @@ export default class Gantt { } bind_grid_click() { - $.on(this.$svg, 'click', '.grid-row, .grid-header', () => { + $.on(this.$svg, this.options.popup_trigger, '.grid-row, .grid-header', () => { this.unselect_all(); this.hide_popup(); });