diff --git a/js/control/Profile.js b/js/control/Profile.js index b422c9d..9430abb 100644 --- a/js/control/Profile.js +++ b/js/control/Profile.js @@ -1,5 +1,6 @@ BR.Profile = L.Evented.extend({ cache: {}, + saveWarningShown: false, initialize: function() { var textArea = L.DomUtil.get('profile_upload'); @@ -80,15 +81,19 @@ BR.Profile = L.Evented.extend({ this.message.hide(); evt.preventDefault(); - var that = this; this.fire('update', { profileText: profile, - callback: function(err, profileId, profileText) { + callback: L.bind(function(err, profileId, profileText) { $(button).blur(); if (!err) { - that.cache[profileId] = profileText; + this.cache[profileId] = profileText; + + if (!this.saveWarningShown) { + this.message.showWarning(i18next.t('warning.temporary-profile')); + this.saveWarningShown = true; + } } - } + }, this) }); }, diff --git a/js/index.js b/js/index.js index e6a8256..d566af4 100644 --- a/js/index.js +++ b/js/index.js @@ -33,8 +33,7 @@ drawButton, deleteRouteButton, pois, - urlHash, - saveWarningShown = false; + urlHash; // By default bootstrap-select use glyphicons $('.selectpicker').selectpicker({ @@ -179,10 +178,6 @@ updateRoute({ options: routingOptions.getOptions() }); - if (!saveWarningShown) { - profile.message.showWarning(i18next.t('warning.temporary-profile')); - saveWarningShown = true; - } } else { profile.message.showError(err); if (profileId) {