Browse Source

Refactored flash message controller

Rafał Pitoń 10 years ago
parent
commit
45cab921bb
1 changed files with 16 additions and 16 deletions
  1. 16 16
      misago/emberapp/app/controllers/flash-message.js

+ 16 - 16
misago/emberapp/app/controllers/flash-message.js

@@ -25,6 +25,20 @@ export default Ember.Controller.extend({
     return this.get('type') === 'error';
     return this.get('type') === 'error';
   }.property('type'),
   }.property('type'),
 
 
+  showFlash: function(type, message) {
+    var flashId = this.incrementProperty('id');
+    this.set('type', type);
+    this.set('message', message);
+    this.set('isVisible', true);
+
+    var self = this;
+    Ember.run.later(function () {
+      if (self.get('id') === flashId) {
+        self.set('isVisible', false);
+      }
+    }, this.get('VISIBLE_FOR'));
+  },
+
   actions: {
   actions: {
     setFlash: function(type, message) {
     setFlash: function(type, message) {
       var self = this;
       var self = this;
@@ -32,25 +46,11 @@ export default Ember.Controller.extend({
       if (this.get('isVisible')) {
       if (this.get('isVisible')) {
         this.set('isVisible', false);
         this.set('isVisible', false);
         Ember.run.later(function () {
         Ember.run.later(function () {
-          self.send('showFlash', type, message);
+          self.showFlash(type, message);
         }, this.get('HIDE_ANIMATION_LENGTH'));
         }, this.get('HIDE_ANIMATION_LENGTH'));
       } else {
       } else {
-        this.send('showFlash', type, message);
+        this.showFlash(type, message);
       }
       }
-    },
-
-    showFlash: function(type, message) {
-      var flashId = this.incrementProperty('id');
-      this.set('type', type);
-      this.set('message', message);
-      this.set('isVisible', true);
-
-      var self = this;
-      Ember.run.later(function () {
-        if (self.get('id') === flashId) {
-          self.set('isVisible', false);
-        }
-      }, this.get('VISIBLE_FOR'));
     }
     }
   }
   }
 });
 });