mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
import { t } from '../util/locale';
|
|
import { svgIcon } from '../svg';
|
|
import { tooltip } from '../util/tooltip';
|
|
|
|
|
|
// these are module variables so they are preserved through a ui.restart()
|
|
var sawVersion = null,
|
|
isNewVersion = false,
|
|
isNewUser = false;
|
|
|
|
|
|
export function uiVersion(context) {
|
|
|
|
var currVersion = context.version,
|
|
matchedVersion = currVersion.match(/\d\.\d\.\d.*/);
|
|
|
|
if (sawVersion === null && matchedVersion !== null) {
|
|
isNewVersion = (context.storage('sawVersion') !== currVersion);
|
|
isNewUser = !context.storage('sawSplash');
|
|
context.storage('sawVersion', currVersion);
|
|
sawVersion = currVersion;
|
|
}
|
|
|
|
return function(selection) {
|
|
selection
|
|
.append('a')
|
|
.attr('target', '_blank')
|
|
.attr('tabindex', -1)
|
|
.attr('href', 'https://github.com/openstreetmap/iD')
|
|
.text(currVersion);
|
|
|
|
// only show new version indicator to users that have used iD before
|
|
if (isNewVersion && !isNewUser) {
|
|
selection
|
|
.append('div')
|
|
.attr('class', 'badge')
|
|
.append('a')
|
|
.attr('target', '_blank')
|
|
.attr('tabindex', -1)
|
|
.attr('href', 'https://github.com/openstreetmap/iD/blob/master/CHANGELOG.md#whats-new')
|
|
.call(svgIcon('#gift-11'))
|
|
.call(tooltip()
|
|
.title(t('version.whats_new', { version: currVersion }))
|
|
.placement('top')
|
|
);
|
|
}
|
|
};
|
|
}
|