From 04cf441c5ae18400c6b4865b0b37a71718dc9d46 Mon Sep 17 00:00:00 2001 From: Ola Bini Date: Thu, 31 Jul 2014 19:29:33 -0300 Subject: Add web-ui based on previous code --- web-ui/app/js/user_alerts/ui/user_alerts.js | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 web-ui/app/js/user_alerts/ui/user_alerts.js (limited to 'web-ui/app/js/user_alerts') diff --git a/web-ui/app/js/user_alerts/ui/user_alerts.js b/web-ui/app/js/user_alerts/ui/user_alerts.js new file mode 100644 index 00000000..308ccfc7 --- /dev/null +++ b/web-ui/app/js/user_alerts/ui/user_alerts.js @@ -0,0 +1,35 @@ +define( + [ + 'flight/lib/component', + 'views/templates', + 'mixins/with_hide_and_show', + 'page/events' + ], + + function(defineComponent, templates, withHideAndShow, events) { + 'use strict'; + + return defineComponent(userAlerts, withHideAndShow); + + function userAlerts() { + this.defaultAttrs({ + dismissTimeout: 3000 + }); + + this.render = function (message) { + this.$node.html(templates.userAlerts.message(message)); + this.show(); + setTimeout(this.hide.bind(this), this.attr.dismissTimeout); + }; + + + this.displayMessage = function (ev, data) { + this.render({ message: data.message}); + }; + + this.after('initialize', function () { + this.on(document, events.ui.userAlerts.displayMessage, this.displayMessage); + }); + } + } +); -- cgit v1.2.3