diff --git a/frontend/src/Metamaps/Router.js b/frontend/src/Metamaps/Router.js index 0ad88efd..c5f1c9a7 100644 --- a/frontend/src/Metamaps/Router.js +++ b/frontend/src/Metamaps/Router.js @@ -21,6 +21,9 @@ import Visualize from './Visualize' */ const _Router = Backbone.Router.extend({ + currentPage: '', + currentSection: '', + timeoutId: undefined, routes: { '': 'home', // #home 'explore/:section': 'explore', // #explore/active @@ -28,6 +31,7 @@ const _Router = Backbone.Router.extend({ 'maps/:id': 'maps' // #maps/7 }, home: function () { + let self = this clearTimeout(this.timeoutId) if (Active.Mapper) document.title = 'Explore Active Maps | Metamaps' @@ -41,8 +45,8 @@ const _Router = Backbone.Router.extend({ $('.wrapper').addClass(classes) var navigate = function () { - this.timeoutId = setTimeout(function () { - this.navigate('') + self.timeoutId = setTimeout(function () { + self.navigate('') }, 300) } @@ -74,6 +78,7 @@ const _Router = Backbone.Router.extend({ Active.Topic = null }, explore: function (section, id) { + var self = this clearTimeout(this.timeoutId) // just capitalize the variable section @@ -115,17 +120,17 @@ const _Router = Backbone.Router.extend({ Views.ExploreMaps.setCollection(Metamaps.Maps[capitalize]) var navigate = function () { - var path = '/explore/' + this.currentPage + var path = '/explore/' + self.currentPage // alter url if for mapper profile page - if (this.currentPage === 'mapper') { + if (self.currentPage === 'mapper') { path += '/' + Metamaps.Maps.Mapper.mapperId } - this.navigate(path) + self.navigate(path) } var navigateTimeout = function () { - this.timeoutId = setTimeout(navigate, 300) + self.timeoutId = setTimeout(navigate, 300) } if (Metamaps.Maps[capitalize].length === 0) { Metamaps.Loading.show() @@ -209,9 +214,6 @@ const _Router = Backbone.Router.extend({ }) const Router = new _Router() -Router.currentPage = '' -Router.currentSection = undefined -Router.timeoutId = undefined Router.intercept = function (evt) { var segments diff --git a/frontend/src/Metamaps/Views/ChatView.js b/frontend/src/Metamaps/Views/ChatView.js index 9f800c4e..cdcda4e5 100644 --- a/frontend/src/Metamaps/Views/ChatView.js +++ b/frontend/src/Metamaps/Views/ChatView.js @@ -147,7 +147,7 @@ var Private = { message: this.$messageInput.val(), }; this.$messageInput.val(''); - $(document).trigger(chatView.events.message + '-' + this.room, [message]); + $(document).trigger(ChatView.events.message + '-' + this.room, [message]); }, addParticipant: function(participant) { var p = _.clone(participant.attributes); @@ -174,12 +174,12 @@ var Handlers = { videoToggleClick: function() { this.$videoToggle.toggleClass('active'); this.videosShowing = !this.videosShowing; - $(document).trigger(this.videosShowing ? chatView.events.videosOn : chatView.events.videosOff); + $(document).trigger(this.videosShowing ? ChatView.events.videosOn : ChatView.events.videosOff); }, cursorToggleClick: function() { this.$cursorToggle.toggleClass('active'); this.cursorsShowing = !this.cursorsShowing; - $(document).trigger(this.cursorsShowing ? chatView.events.cursorsOn : chatView.events.cursorsOff); + $(document).trigger(this.cursorsShowing ? ChatView.events.cursorsOn : ChatView.events.cursorsOff); }, soundToggleClick: function() { this.alertSound = !this.alertSound; @@ -193,10 +193,10 @@ var Handlers = { } }, inputFocus: function() { - $(document).trigger(chatView.events.inputFocus); + $(document).trigger(ChatView.events.inputFocus); }, inputBlur: function() { - $(document).trigger(chatView.events.inputBlur); + $(document).trigger(ChatView.events.inputBlur); } };