From 471e09662e1dba6a07997fd4e952a47147f1729b Mon Sep 17 00:00:00 2001 From: Sean Lip Date: Tue, 15 Nov 2016 17:37:38 -0800 Subject: [PATCH] Hide notification messages after a short time interval. --- accessible/notifications.service.js | 12 ++++++++++-- accessible/sidebar.component.js | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/accessible/notifications.service.js b/accessible/notifications.service.js index b3c9f4f2c..9e2b1d709 100644 --- a/accessible/notifications.service.js +++ b/accessible/notifications.service.js @@ -26,6 +26,7 @@ blocklyApp.NotificationsService = ng.core.Class({ constructor: [function() { this.statusMessage_ = ''; + this.timeouts = []; }], getStatusMessage: function() { return this.statusMessage_; @@ -34,12 +35,19 @@ blocklyApp.NotificationsService = ng.core.Class({ // Introduce a temporary status message, so that if, e.g., two "copy" // operations are done in succession, both messages will be read. this.statusMessage_ = ''; + // Clear all existing timeouts. + this.timeouts.forEach(function(timeout) { + clearTimeout(timeout); + }); // We need a non-zero timeout here, otherwise NVDA does not read the // notification messages properly. var that = this; - setTimeout(function() { + this.timeouts.push(setTimeout(function() { that.statusMessage_ = newMessage; - }, 20); + }, 20)); + this.timeouts.push(setTimeout(function() { + that.statusMessage_ = ''; + }, 2000)); } }); diff --git a/accessible/sidebar.component.js b/accessible/sidebar.component.js index e8890fe30..2c259ea70 100644 --- a/accessible/sidebar.component.js +++ b/accessible/sidebar.component.js @@ -33,13 +33,13 @@ blocklyApp.SidebarComponent = ng.core.Component({