From 28fc990661f2d6d01b21956de9085c1bb4a6d589 Mon Sep 17 00:00:00 2001 From: Cameron Kloot Date: Sat, 20 May 2017 13:45:13 -0400 Subject: [PATCH] Timeline 'showTooltips' option (#3046) * Add 'showTooltips' timeline option * Only show timeline popup if option showTooltips is true * Add 'showTooltips' option to timeline docs * Add tooltips disabled timeline example --- docs/timeline/index.html | 7 +++++++ examples/timeline/items/tooltip.html | 17 ++++++++++++++++- lib/timeline/component/ItemSet.js | 8 +++++--- lib/timeline/optionsTimeline.js | 2 ++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/docs/timeline/index.html b/docs/timeline/index.html index da2084f9..293f4cca 100644 --- a/docs/timeline/index.html +++ b/docs/timeline/index.html @@ -1026,6 +1026,13 @@ function (option, path) { visible. + + showTooltips + boolean + true + If true, items with titles will display a tooltip. If false, item tooltips are prevented from showing. + + stack boolean diff --git a/examples/timeline/items/tooltip.html b/examples/timeline/items/tooltip.html index ad2c8723..8908241a 100644 --- a/examples/timeline/items/tooltip.html +++ b/examples/timeline/items/tooltip.html @@ -12,7 +12,7 @@ - + @@ -38,6 +38,12 @@
+

+ Disable item tooltips. +

+ +
+ diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index 230e8781..362d4320 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -95,6 +95,8 @@ function ItemSet(body, options) { axis: 20 }, + showTooltips: true, + tooltip: { followMouse: false, overflowMethod: 'flip' @@ -336,7 +338,7 @@ ItemSet.prototype.setOptions = function(options) { var fields = [ 'type', 'rtl', 'align', 'order', 'stack', 'stackSubgroups', 'selectable', 'multiselect', 'itemsAlwaysDraggable', 'multiselectPerGroup', 'groupOrder', 'dataAttributes', 'template', 'groupTemplate', 'visibleFrameTemplate', - 'hide', 'snap', 'groupOrderSwap', 'tooltip', 'tooltipOnItemUpdateTime' + 'hide', 'snap', 'groupOrderSwap', 'showTooltips', 'tooltip', 'tooltipOnItemUpdateTime' ]; util.selectiveExtend(fields, this.options, options); @@ -1881,7 +1883,7 @@ ItemSet.prototype._onMouseOver = function (event) { } var title = item.getTitle(); - if (title) { + if (this.options.showTooltips && title) { if (this.popup == null) { this.popup = new Popup(this.body.dom.root, this.options.tooltip.overflowMethod || 'flip'); @@ -1931,7 +1933,7 @@ ItemSet.prototype._onMouseMove = function (event) { var item = this.itemFromTarget(event); if (!item) return; - if (this.options.tooltip.followMouse) { + if (this.options.showTooltips && this.options.tooltip.followMouse) { if (this.popup) { if (!this.popup.hidden) { var container = this.body.dom.centerContainer; diff --git a/lib/timeline/optionsTimeline.js b/lib/timeline/optionsTimeline.js index fb6f3c3d..56df9c63 100644 --- a/lib/timeline/optionsTimeline.js +++ b/lib/timeline/optionsTimeline.js @@ -137,6 +137,7 @@ let allOptions = { template: {'function': 'function'}, groupTemplate: {'function': 'function'}, visibleFrameTemplate: {string, 'function': 'function'}, + showTooltips: { 'boolean': bool}, tooltip: { followMouse: { 'boolean': bool }, overflowMethod: { 'string': ['cap', 'flip'] }, @@ -243,6 +244,7 @@ let configureOptions = { // scale: ['millisecond', 'second', 'minute', 'hour', 'weekday', 'day', 'week', 'month', 'year'], // step: [1, 1, 10, 1] //}, + showTooltips: true, tooltip: { followMouse: false, overflowMethod: 'flip'