From c2cbff2282cbdaa8611cbbed0f407724aca87927 Mon Sep 17 00:00:00 2001 From: cmolinaAlicante Date: Fri, 3 Feb 2017 10:06:07 +0100 Subject: [PATCH] feat(timeline): Change setCustomTimeTitle title parameter to be a string or a function (#2611) * change setCustomTimeTitle title parameter, Now could be an string or a function * Fixed indent and spacing --- docs/timeline/index.html | 2 +- .../timeline/other/customTimeBarsTooltip.html | 95 +++++++++++++++++++ lib/timeline/component/CustomTime.js | 2 + 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 examples/timeline/other/customTimeBarsTooltip.html diff --git a/docs/timeline/index.html b/docs/timeline/index.html index 351bb919..edc0f56f 100644 --- a/docs/timeline/index.html +++ b/docs/timeline/index.html @@ -1367,7 +1367,7 @@ document.getElementById('myTimeline').onclick = function (event) { setCustomTimeTitle(title [, id]) none Adjust the title attribute of a custom time bar. - Parameter title is the string to be set as title. Use empty string to hide the title completely. + Parameter title is the string or function to be set as title. Use empty string to hide the title completely. Parameter id is the id of the custom time bar, and is undefined by default. diff --git a/examples/timeline/other/customTimeBarsTooltip.html b/examples/timeline/other/customTimeBarsTooltip.html new file mode 100644 index 00000000..0fe62f36 --- /dev/null +++ b/examples/timeline/other/customTimeBarsTooltip.html @@ -0,0 +1,95 @@ + + + + Timeline | Show current and custom time bars + + + + + + + + + +

+ The Timeline has functions to add multiple custom time bars which can be dragged by the user. +

+

+ + +

+

+ + +

+

+ timechange event, index: , time: +

+

+ timechanged event, index: , time: +


+ +
+ + + + \ No newline at end of file diff --git a/lib/timeline/component/CustomTime.js b/lib/timeline/component/CustomTime.js index 6a94b2ac..6aa6502a 100644 --- a/lib/timeline/component/CustomTime.js +++ b/lib/timeline/component/CustomTime.js @@ -143,6 +143,8 @@ CustomTime.prototype.redraw = function () { if (title === undefined) { title = locale.time + ': ' + this.options.moment(this.customTime).format('dddd, MMMM Do YYYY, H:mm:ss'); title = title.charAt(0).toUpperCase() + title.substring(1); + } else if (typeof title === "function") { + title = title.call(this.customTime); } this.bar.style.left = x + 'px';