Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/apps/system/js/system_banner.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/system/js/system_banner.js')
-rw-r--r--apps/system/js/system_banner.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/apps/system/js/system_banner.js b/apps/system/js/system_banner.js
new file mode 100644
index 0000000..89028e2
--- /dev/null
+++ b/apps/system/js/system_banner.js
@@ -0,0 +1,33 @@
+'use strict';
+
+var SystemBanner = {
+ banner: document.getElementById('system-banner'),
+
+ // Shows a banner with a given message.
+ // Optionally shows a button with a given label/callback.
+ // buttonParams = { label: ..., callback: ... }
+ show: function sb_show(message, buttonParams) {
+ var banner = this.banner;
+ banner.firstElementChild.textContent = message;
+
+ var button = banner.querySelector('button');
+ if (buttonParams) {
+ banner.dataset.button = true;
+ button.textContent = buttonParams.label;
+ button.addEventListener('click', buttonParams.callback);
+ }
+
+ banner.addEventListener('animationend', function animationend() {
+ banner.removeEventListener('animationend', animationend);
+ banner.classList.remove('visible');
+
+ if (buttonParams) {
+ banner.dataset.button = false;
+ button.removeEventListener('click', buttonParams.callback);
+ button.classList.remove('visible');
+ }
+ });
+
+ banner.classList.add('visible');
+ }
+};