diff --git a/js/client-chat-tournament.js b/js/client-chat-tournament.js index 0f6d5615d..8c01d08da 100644 --- a/js/client-chat-tournament.js +++ b/js/client-chat-tournament.js @@ -54,7 +54,6 @@ top: position.top }); - var isMouseDown = false; // Note: Origin starts from the top right instead of the top left here, // because when a battle room is opened, the left side moves but the right doesn't, // so we have to use the right side to keep the element in the same location. @@ -64,11 +63,8 @@ $element.on('mousedown', function (e) { innerX = e.pageX + ($element.parent().width() - $element.width() - this.offsetLeft); innerY = e.pageY - this.offsetTop; - isMouseDown = true; - }); - $(document).on('mousemove', function (e) { - if (isMouseDown) { + function mouseMoveCallback(e) { position.right = innerX - e.pageX; position.top = e.pageY - innerY; delete position.isDefault; @@ -78,8 +74,10 @@ top: position.top }); } - }).on('mouseup', function () { - isMouseDown = false; + $(document).on('mousemove', mouseMoveCallback) + .on('mouseup', function () { + $(document).off('mousemove', mouseMoveCallback); + }); }); } diff --git a/js/client-chat.js b/js/client-chat.js index 5af40a550..486a7cb85 100644 --- a/js/client-chat.js +++ b/js/client-chat.js @@ -963,6 +963,10 @@ if (autoscroll) { this.$chatFrame.scrollTop(this.$chat.height()); } + }, + destroy: function () { + app.user.off('change', this.updateUser, this); + Room.prototype.destroy.call(this); } }, { toggleFormatChar: function (textbox, formatChar) { @@ -1443,6 +1447,12 @@ } else if (message.substr(0, 10) === '/announce ' || message.substr(0, 1) !== '/') { Storage.logChat(this.id, '' + name + ': ' + message); } + }, + destroy: function () { + if (this.tournamentBox) { + app.user.off('saveteams', this.tournamentBox.updateTeams, this.tournamentBox); + } + ConsoleRoom.prototype.destroy.call(this); } }, { getTimestamp: function (section, msgTime) {