diff --git a/gulpfile.js b/gulpfile.js
index 503ca3b..b34c187 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -80,6 +80,7 @@ var paths = {
.concat('css/*.css'),
images: mainNpmFiles().filter((f) => RegExp('.*.+(png|gif|svg)', 'i').test(f)),
fonts: mainNpmFiles().filter((f) => RegExp('font-awesome/fonts/.*', 'i').test(f)),
+ changelog: 'CHANGELOG.md',
locales: 'locales/*.json',
layers: 'layers/**/*.geojson',
layersDestName: 'layers.js',
@@ -188,7 +189,7 @@ gulp.task('boundaries', function () {
});
gulp.task('changelog', function (cb) {
- var content = 'BR.changelog = `' + marked(fs.readFileSync('./CHANGELOG.md', 'utf-8')) + '`';
+ var content = 'BR.changelog = `' + marked(fs.readFileSync(paths.changelog, 'utf-8')) + '`';
content = content.replace(/
/i, '');
fs.writeFile(paths.dest + '/changelog.js', content, cb);
});
@@ -207,6 +208,7 @@ gulp.task('watch', function () {
remember.forget('scripts', event.path);
}
});
+ gulp.watch(paths.changelog, gulp.series('changelog', 'reload'));
gulp.watch(paths.locales, gulp.series('locales', 'reload'));
gulp.watch(paths.styles, gulp.series('styles', 'reload'));
gulp.watch(paths.layersConfig, gulp.series('layers_config', 'reload'));
diff --git a/js/WhatsNew.js b/js/WhatsNew.js
index afb2959..0e3b1b8 100644
--- a/js/WhatsNew.js
+++ b/js/WhatsNew.js
@@ -1,4 +1,6 @@
BR.WhatsNew = {
+ newOnly: undefined,
+
init: function () {
var self = this;
self.dismissableMessage = new BR.Message('whats_new_message', {
@@ -7,13 +9,15 @@ BR.WhatsNew = {
if (BR.Util.localStorageAvailable()) {
localStorage.setItem('changelogVersion', self.getLatestVersion());
}
- // next time popup is open, by default we will see everything
- self.prepare(false);
},
});
$('#whatsnew').on('shown.bs.modal', function () {
self.dismissableMessage.hide();
});
+ $('#whatsnew').on('hidden.bs.modal', function () {
+ // next time popup is open, by default we will see everything
+ self.prepare(false);
+ });
if (!self.getCurrentVersion() && BR.Util.localStorageAvailable()) {
localStorage.setItem('changelogVersion', self.getLatestVersion());
}
@@ -36,15 +40,21 @@ BR.WhatsNew = {
},
hasNewVersions: function () {
- return this.getCurrentVersion() && this.getCurrentVersion() < this.getLatestVersion();
+ return this.getCurrentVersion() && this.getCurrentVersion() !== this.getLatestVersion();
},
prepare: function (newOnly) {
+ if (newOnly === this.newOnly) {
+ // do not rebuild modal content unnecessarily
+ return;
+ }
+ this.newOnly = newOnly;
var container = document.querySelector('#whatsnew .modal-body');
var cl = BR.changelog;
if (newOnly && this.getCurrentVersion()) {
var head = '';
- cl = cl.substring(0, cl.indexOf(head));
+ var idx = cl.indexOf(head);
+ if (idx >= 0) cl = cl.substring(0, idx);
}
container.innerHTML = cl;
},