|
|
@ -23,16 +23,17 @@ function CustomTime (body, options) { |
|
|
|
moment: moment, |
|
|
|
locales: locales, |
|
|
|
locale: 'en', |
|
|
|
id: undefined |
|
|
|
id: undefined, |
|
|
|
title: undefined |
|
|
|
}; |
|
|
|
this.options = util.extend({}, this.defaultOptions); |
|
|
|
|
|
|
|
if (options && options.time) { |
|
|
|
this.customTime = options.time; |
|
|
|
} else { |
|
|
|
this.customTime = new Date(); |
|
|
|
this.customTime = new Date(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.eventParams = {}; // stores state parameters while dragging the bar
|
|
|
|
|
|
|
|
this.setOptions(options); |
|
|
@ -123,8 +124,12 @@ CustomTime.prototype.redraw = function () { |
|
|
|
locale = this.options.locales['en']; // fall back on english when not available
|
|
|
|
} |
|
|
|
|
|
|
|
var title = locale.time + ': ' + this.options.moment(this.customTime).format('dddd, MMMM Do YYYY, H:mm:ss'); |
|
|
|
title = title.charAt(0).toUpperCase() + title.substring(1); |
|
|
|
var title = this.options.title; |
|
|
|
// To hide the title completely use empty string ''.
|
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
this.bar.style.left = x + 'px'; |
|
|
|
this.bar.title = title; |
|
|
@ -159,6 +164,14 @@ CustomTime.prototype.getCustomTime = function() { |
|
|
|
return new Date(this.customTime.valueOf()); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Set custom title. |
|
|
|
* @param {Date | number | string} title |
|
|
|
*/ |
|
|
|
CustomTime.prototype.setCustomTitle = function(title) { |
|
|
|
this.options.title = title; |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Start moving horizontally |
|
|
|
* @param {Event} event |
|
|
|