Browse Source

Fixed #782: Contents of items created from a template being unnecessary recreated on click, causing mouse events to get lost.

v3_develop
jos 9 years ago
parent
commit
bc3e4a26d1
5 changed files with 130 additions and 101 deletions
  1. +2
    -0
      HISTORY.md
  2. +98
    -83
      dist/vis.js
  3. +1
    -1
      dist/vis.map
  4. +15
    -16
      dist/vis.min.js
  5. +14
    -1
      lib/timeline/component/item/Item.js

+ 2
- 0
HISTORY.md View File

@ -8,6 +8,8 @@ http://visjs.org
- Fixed #761: Timeline and Graph2d throwing an error when locale is not found.
Gives a warning message instead.
- Fixed #782: Contents of items created from a template being unnecessary
recreated on click, causing mouse events to get lost.
### Network

+ 98
- 83
dist/vis.js View File

@ -5,7 +5,7 @@
* A dynamic, browser-based visualization library.
*
* @version 3.12.1-SNAPSHOT
* @date 2015-04-07
* @date 2015-04-17
*
* @license
* Copyright (C) 2011-2014 Almende B.V, http://almende.com
@ -9531,7 +9531,8 @@ return /******/ (function(modules) { // webpackBootstrap
content = this.data.content;
}
if(content !== this.content) {
var changed = this._contentToString(this.content) !== this._contentToString(content);
if (changed) {
// only replace the content when changed
if (content instanceof Element) {
element.innerHTML = '';
@ -9616,6 +9617,18 @@ return /******/ (function(modules) { // webpackBootstrap
}
};
/**
* Stringify the items contents
* @param {string | Element | undefined} content
* @returns {string | undefined}
* @private
*/
Item.prototype._contentToString = function (content) {
if (typeof content === 'string') return content;
if (content && 'outerHTML' in content) return content.outerHTML;
return content;
};
module.exports = Item;
@ -13563,12 +13576,13 @@ return /******/ (function(modules) { // webpackBootstrap
*/
ItemSet.prototype._updateItem = function(item, itemData) {
var oldGroupId = item.data.group;
var oldSubGroupId = item.data.subgroup;
// update the items data (will redraw the item when displayed)
item.setData(itemData);
// update group
if (oldGroupId != item.data.group) {
if (oldGroupId != item.data.group || oldSubGroupId != item.data.subgroup) {
var oldGroup = this.groups[oldGroupId];
if (oldGroup) oldGroup.remove(item);
@ -17279,7 +17293,7 @@ return /******/ (function(modules) { // webpackBootstrap
};
var id;
var previousPopupObjId = this.popupObj === undefined ? "" : this.popupObj.id;
var previousPopupObjId = this.popupObj === undefined ? undefined : this.popupObj.id;
var nodeUnderCursor = false;
var popupType = "node";
@ -25315,7 +25329,7 @@ return /******/ (function(modules) { // webpackBootstrap
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module) {//! moment.js
//! version : 2.10.0
//! version : 2.10.2
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
@ -25328,7 +25342,7 @@ return /******/ (function(modules) { // webpackBootstrap
var hookCallback;
function hooks__hooks () {
function utils_hooks__hooks () {
return hookCallback.apply(null, arguments);
}
@ -25392,7 +25406,7 @@ return /******/ (function(modules) { // webpackBootstrap
return a;
}
function utc__createUTC (input, format, locale, strict) {
function create_utc__createUTC (input, format, locale, strict) {
return createLocalOrUTC(input, format, locale, strict, true).utc();
}
@ -25417,7 +25431,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
function valid__createInvalid (flags) {
var m = utc__createUTC(NaN);
var m = create_utc__createUTC(NaN);
if (flags != null) {
extend(m._pf, flags);
}
@ -25428,7 +25442,7 @@ return /******/ (function(modules) { // webpackBootstrap
return m;
}
var momentProperties = hooks__hooks.momentProperties = [];
var momentProperties = utils_hooks__hooks.momentProperties = [];
function copyConfig(to, from) {
var i, prop, val;
@ -25487,7 +25501,7 @@ return /******/ (function(modules) { // webpackBootstrap
// objects.
if (updateInProgress === false) {
updateInProgress = true;
hooks__hooks.updateOffset(this);
utils_hooks__hooks.updateOffset(this);
updateInProgress = false;
}
}
@ -25572,7 +25586,7 @@ return /******/ (function(modules) { // webpackBootstrap
!(function webpackMissingModule() { var e = new Error("Cannot find module \"./locale\""); e.code = 'MODULE_NOT_FOUND'; throw e; }());
// because defineLocale currently also sets the global locale, we
// want to undo that for lazy loaded locales
locales__getSetGlobalLocale(oldLocale);
locale_locales__getSetGlobalLocale(oldLocale);
} catch (e) { }
}
return locales[name];
@ -25581,11 +25595,11 @@ return /******/ (function(modules) { // webpackBootstrap
// This function will load locale and then set the global locale. If
// no arguments are passed in, it will simply return the current global
// locale key.
function locales__getSetGlobalLocale (key, values) {
function locale_locales__getSetGlobalLocale (key, values) {
var data;
if (key) {
if (typeof values === 'undefined') {
data = locales__getLocale(key);
data = locale_locales__getLocale(key);
}
else {
data = defineLocale(key, values);
@ -25609,7 +25623,7 @@ return /******/ (function(modules) { // webpackBootstrap
locales[name].set(values);
// backwards compat for now: also set the locale
locales__getSetGlobalLocale(name);
locale_locales__getSetGlobalLocale(name);
return locales[name];
} else {
@ -25620,7 +25634,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
// returns locale data
function locales__getLocale (key) {
function locale_locales__getLocale (key) {
var locale;
if (key && key._locale && key._locale._abbr) {
@ -25675,7 +25689,7 @@ return /******/ (function(modules) { // webpackBootstrap
return function (value) {
if (value != null) {
get_set__set(this, unit, value);
hooks__hooks.updateOffset(this, keepTime);
utils_hooks__hooks.updateOffset(this, keepTime);
return this;
} else {
return get_set__get(this, unit);
@ -25958,7 +25972,7 @@ return /******/ (function(modules) { // webpackBootstrap
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = utc__createUTC([2000, i]);
mom = create_utc__createUTC([2000, i]);
if (strict && !this._longMonthsParse[i]) {
this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
@ -26000,7 +26014,7 @@ return /******/ (function(modules) { // webpackBootstrap
function getSetMonth (value) {
if (value != null) {
setMonth(this, value);
hooks__hooks.updateOffset(this, true);
utils_hooks__hooks.updateOffset(this, true);
return this;
} else {
return get_set__get(this, 'Month');
@ -26036,7 +26050,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
function warn(msg) {
if (hooks__hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
if (utils_hooks__hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
console.warn('Deprecation warning: ' + msg);
}
}
@ -26061,7 +26075,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
}
hooks__hooks.suppressDeprecationWarnings = false;
utils_hooks__hooks.suppressDeprecationWarnings = false;
var from_string__isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
@ -26125,11 +26139,11 @@ return /******/ (function(modules) { // webpackBootstrap
configFromISO(config);
if (config._isValid === false) {
delete config._isValid;
hooks__hooks.createFromInputFallback(config);
utils_hooks__hooks.createFromInputFallback(config);
}
}
hooks__hooks.createFromInputFallback = deprecate(
utils_hooks__hooks.createFromInputFallback = deprecate(
'moment construction falls back to js Date. This is ' +
'discouraged and will be removed in upcoming major ' +
'release. Please refer to ' +
@ -26181,7 +26195,7 @@ return /******/ (function(modules) { // webpackBootstrap
addParseToken(['YYYY', 'YYYYY', 'YYYYYY'], YEAR);
addParseToken('YY', function (input, array) {
array[YEAR] = hooks__hooks.parseTwoDigitYear(input);
array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
});
// HELPERS
@ -26196,7 +26210,7 @@ return /******/ (function(modules) { // webpackBootstrap
// HOOKS
hooks__hooks.parseTwoDigitYear = function (input) {
utils_hooks__hooks.parseTwoDigitYear = function (input) {
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
};
@ -26455,12 +26469,12 @@ return /******/ (function(modules) { // webpackBootstrap
config._dayOfYear = temp.dayOfYear;
}
hooks__hooks.ISO_8601 = function () {};
utils_hooks__hooks.ISO_8601 = function () {};
// date from string and format string
function configFromStringAndFormat(config) {
// TODO: Move this to another part of the creation flow to prevent circular deps
if (config._f === hooks__hooks.ISO_8601) {
if (config._f === utils_hooks__hooks.ISO_8601) {
configFromISO(config);
return;
}
@ -26606,7 +26620,7 @@ return /******/ (function(modules) { // webpackBootstrap
format = config._f,
res;
config._locale = config._locale || locales__getLocale(config._l);
config._locale = config._locale || locale_locales__getLocale(config._l);
if (input === null || (format === undefined && input === '')) {
return valid__createInvalid({nullInput: true});
@ -26655,7 +26669,7 @@ return /******/ (function(modules) { // webpackBootstrap
// from milliseconds
config._d = new Date(input);
} else {
hooks__hooks.createFromInputFallback(config);
utils_hooks__hooks.createFromInputFallback(config);
}
}
@ -26764,7 +26778,7 @@ return /******/ (function(modules) { // webpackBootstrap
this._data = {};
this._locale = locales__getLocale();
this._locale = locale_locales__getLocale();
this._bubble();
}
@ -26821,7 +26835,7 @@ return /******/ (function(modules) { // webpackBootstrap
diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
// Use low-level api, because this fn is low-level api.
res._d.setTime(+res._d + diff);
hooks__hooks.updateOffset(res, false);
utils_hooks__hooks.updateOffset(res, false);
return res;
} else {
return local__createLocal(input).local();
@ -26839,7 +26853,7 @@ return /******/ (function(modules) { // webpackBootstrap
// This function will be called whenever a moment is mutated.
// It is intended to keep the offset in sync with the timezone.
hooks__hooks.updateOffset = function () {};
utils_hooks__hooks.updateOffset = function () {};
// MOMENTS
@ -26876,7 +26890,7 @@ return /******/ (function(modules) { // webpackBootstrap
add_subtract__addSubtract(this, create__createDuration(input - offset, 'm'), 1, false);
} else if (!this._changeInProgress) {
this._changeInProgress = true;
hooks__hooks.updateOffset(this, true);
utils_hooks__hooks.updateOffset(this, true);
this._changeInProgress = null;
}
}
@ -26945,7 +26959,7 @@ return /******/ (function(modules) { // webpackBootstrap
function isDaylightSavingTimeShifted () {
if (this._a) {
var other = this._isUTC ? utc__createUTC(this._a) : local__createLocal(this._a);
var other = this._isUTC ? create_utc__createUTC(this._a) : local__createLocal(this._a);
return this.isValid() && compareArrays(this._a, other.toArray()) > 0;
}
@ -27031,6 +27045,8 @@ return /******/ (function(modules) { // webpackBootstrap
return ret;
}
create__createDuration.fn = Duration.prototype;
function parseIso (inp, sign) {
// We'd normally use ~~inp for this, but unfortunately it also
// converts floats to ints.
@ -27100,14 +27116,14 @@ return /******/ (function(modules) { // webpackBootstrap
setMonth(mom, get_set__get(mom, 'Month') + months * isAdding);
}
if (updateOffset) {
hooks__hooks.updateOffset(mom, days || months);
utils_hooks__hooks.updateOffset(mom, days || months);
}
}
var add_subtract__add = createAdder(1, 'add');
var add_subtract__subtract = createAdder(-1, 'subtract');
function calendar__calendar (time) {
function moment_calendar__calendar (time) {
// We want to compare the start of today, vs this.
// Getting start-of-today depends on whether we're local/utc/offset or not.
var now = time || local__createLocal(),
@ -27220,7 +27236,7 @@ return /******/ (function(modules) { // webpackBootstrap
return -(wholeMonthDiff + adjust);
}
hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
function toString () {
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
@ -27241,7 +27257,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
function format (inputString) {
var output = formatMoment(this, inputString || hooks__hooks.defaultFormat);
var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
return this.localeData().postformat(output);
}
@ -27259,7 +27275,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (key === undefined) {
return this._locale._abbr;
} else {
newLocaleData = locales__getLocale(key);
newLocaleData = locale_locales__getLocale(key);
if (newLocaleData != null) {
this._locale = newLocaleData;
}
@ -27307,7 +27323,6 @@ return /******/ (function(modules) { // webpackBootstrap
/* falls through */
case 'second':
this.milliseconds(0);
/* falls through */
}
// weeks are a special case
@ -27401,7 +27416,7 @@ return /******/ (function(modules) { // webpackBootstrap
});
addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
week[token] = hooks__hooks.parseTwoDigitYear(input);
week[token] = utils_hooks__hooks.parseTwoDigitYear(input);
});
// HELPERS
@ -27746,7 +27761,7 @@ return /******/ (function(modules) { // webpackBootstrap
var momentPrototype__proto = Moment.prototype;
momentPrototype__proto.add = add_subtract__add;
momentPrototype__proto.calendar = calendar__calendar;
momentPrototype__proto.calendar = moment_calendar__calendar;
momentPrototype__proto.clone = clone;
momentPrototype__proto.diff = diff;
momentPrototype__proto.endOf = endOf;
@ -27929,7 +27944,7 @@ return /******/ (function(modules) { // webpackBootstrap
return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
}
function set__set (config) {
function locale_set__set (config) {
var prop, i;
for (i in config) {
prop = config[i];
@ -27960,7 +27975,7 @@ return /******/ (function(modules) { // webpackBootstrap
prototype__proto._relativeTime = defaultRelativeTime;
prototype__proto.relativeTime = relative__relativeTime;
prototype__proto.pastFuture = pastFuture;
prototype__proto.set = set__set;
prototype__proto.set = locale_set__set;
// Month
prototype__proto.months = localeMonths;
@ -27990,8 +28005,8 @@ return /******/ (function(modules) { // webpackBootstrap
prototype__proto.meridiem = localeMeridiem;
function lists__get (format, index, field, setter) {
var locale = locales__getLocale();
var utc = utc__createUTC().set(setter, index);
var locale = locale_locales__getLocale();
var utc = create_utc__createUTC().set(setter, index);
return locale[field](utc, format);
}
@ -28035,7 +28050,7 @@ return /******/ (function(modules) { // webpackBootstrap
return list(format, index, 'weekdaysMin', 7, 'day');
}
locales__getSetGlobalLocale('en', {
locale_locales__getSetGlobalLocale('en', {
ordinalParse: /\d{1,2}(th|st|nd|rd)/,
ordinal : function (number) {
var b = number % 10,
@ -28048,12 +28063,12 @@ return /******/ (function(modules) { // webpackBootstrap
});
// Side effect imports
hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locales__getSetGlobalLocale);
hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locales__getLocale);
utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale);
utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale);
var mathAbs = Math.abs;
function abs__abs () {
function duration_abs__abs () {
var data = this._data;
this._milliseconds = mathAbs(this._milliseconds);
@ -28171,7 +28186,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
// TODO: Use this.as('ms')?
function as__valueOf () {
function duration_as__valueOf () {
return (
this._milliseconds +
this._days * 864e5 +
@ -28195,7 +28210,7 @@ return /******/ (function(modules) { // webpackBootstrap
var asMonths = makeAs('M');
var asYears = makeAs('y');
function get__get (units) {
function duration_get__get (units) {
units = normalizeUnits(units);
return this[units + 's']();
}
@ -28206,7 +28221,7 @@ return /******/ (function(modules) { // webpackBootstrap
};
}
var get__milliseconds = makeGetter('milliseconds');
var duration_get__milliseconds = makeGetter('milliseconds');
var seconds = makeGetter('seconds');
var minutes = makeGetter('minutes');
var hours = makeGetter('hours');
@ -28232,7 +28247,7 @@ return /******/ (function(modules) { // webpackBootstrap
return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
}
function humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
var duration = create__createDuration(posNegDuration).abs();
var seconds = round(duration.as('s'));
var minutes = round(duration.as('m'));
@ -28259,7 +28274,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
// This function allows you to set a threshold for relative time strings
function humanize__getSetRelativeTimeThreshold (threshold, limit) {
function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
if (thresholds[threshold] === undefined) {
return false;
}
@ -28272,7 +28287,7 @@ return /******/ (function(modules) { // webpackBootstrap
function humanize (withSuffix) {
var locale = this.localeData();
var output = humanize__relativeTime(this, !withSuffix, locale);
var output = duration_humanize__relativeTime(this, !withSuffix, locale);
if (withSuffix) {
output = locale.pastFuture(+this, output);
@ -28312,7 +28327,7 @@ return /******/ (function(modules) { // webpackBootstrap
var duration_prototype__proto = Duration.prototype;
duration_prototype__proto.abs = abs__abs;
duration_prototype__proto.abs = duration_abs__abs;
duration_prototype__proto.add = duration_add_subtract__add;
duration_prototype__proto.subtract = duration_add_subtract__subtract;
duration_prototype__proto.as = as;
@ -28324,10 +28339,10 @@ return /******/ (function(modules) { // webpackBootstrap
duration_prototype__proto.asWeeks = asWeeks;
duration_prototype__proto.asMonths = asMonths;
duration_prototype__proto.asYears = asYears;
duration_prototype__proto.valueOf = as__valueOf;
duration_prototype__proto.valueOf = duration_as__valueOf;
duration_prototype__proto._bubble = bubble;
duration_prototype__proto.get = get__get;
duration_prototype__proto.milliseconds = get__milliseconds;
duration_prototype__proto.get = duration_get__get;
duration_prototype__proto.milliseconds = duration_get__milliseconds;
duration_prototype__proto.seconds = seconds;
duration_prototype__proto.minutes = minutes;
duration_prototype__proto.hours = hours;
@ -28365,33 +28380,33 @@ return /******/ (function(modules) { // webpackBootstrap
// Side effect imports
hooks__hooks.version = '2.10.0';
utils_hooks__hooks.version = '2.10.2';
setHookCallback(local__createLocal);
hooks__hooks.fn = momentPrototype;
hooks__hooks.min = min;
hooks__hooks.max = max;
hooks__hooks.utc = utc__createUTC;
hooks__hooks.unix = moment__createUnix;
hooks__hooks.months = lists__listMonths;
hooks__hooks.isDate = isDate;
hooks__hooks.locale = locales__getSetGlobalLocale;
hooks__hooks.invalid = valid__createInvalid;
hooks__hooks.duration = create__createDuration;
hooks__hooks.isMoment = isMoment;
hooks__hooks.weekdays = lists__listWeekdays;
hooks__hooks.parseZone = moment__createInZone;
hooks__hooks.localeData = locales__getLocale;
hooks__hooks.isDuration = isDuration;
hooks__hooks.monthsShort = lists__listMonthsShort;
hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
hooks__hooks.defineLocale = defineLocale;
hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
hooks__hooks.normalizeUnits = normalizeUnits;
hooks__hooks.relativeTimeThreshold = humanize__getSetRelativeTimeThreshold;
var _moment = hooks__hooks;
utils_hooks__hooks.fn = momentPrototype;
utils_hooks__hooks.min = min;
utils_hooks__hooks.max = max;
utils_hooks__hooks.utc = create_utc__createUTC;
utils_hooks__hooks.unix = moment__createUnix;
utils_hooks__hooks.months = lists__listMonths;
utils_hooks__hooks.isDate = isDate;
utils_hooks__hooks.locale = locale_locales__getSetGlobalLocale;
utils_hooks__hooks.invalid = valid__createInvalid;
utils_hooks__hooks.duration = create__createDuration;
utils_hooks__hooks.isMoment = isMoment;
utils_hooks__hooks.weekdays = lists__listWeekdays;
utils_hooks__hooks.parseZone = moment__createInZone;
utils_hooks__hooks.localeData = locale_locales__getLocale;
utils_hooks__hooks.isDuration = isDuration;
utils_hooks__hooks.monthsShort = lists__listMonthsShort;
utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
utils_hooks__hooks.defineLocale = defineLocale;
utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
utils_hooks__hooks.normalizeUnits = normalizeUnits;
utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
var _moment = utils_hooks__hooks;
return _moment;

+ 1
- 1
dist/vis.map
File diff suppressed because it is too large
View File


+ 15
- 16
dist/vis.min.js
File diff suppressed because it is too large
View File


+ 14
- 1
lib/timeline/component/item/Item.js View File

@ -177,7 +177,8 @@ Item.prototype._updateContents = function (element) {
content = this.data.content;
}
if(content !== this.content) {
var changed = this._contentToString(this.content) !== this._contentToString(content);
if (changed) {
// only replace the content when changed
if (content instanceof Element) {
element.innerHTML = '';
@ -262,4 +263,16 @@ Item.prototype._updateStyle = function(element) {
}
};
/**
* Stringify the items contents
* @param {string | Element | undefined} content
* @returns {string | undefined}
* @private
*/
Item.prototype._contentToString = function (content) {
if (typeof content === 'string') return content;
if (content && 'outerHTML' in content) return content.outerHTML;
return content;
};
module.exports = Item;

Loading…
Cancel
Save