Просмотр исходного кода

Made toastings configurable and less obstructing for testrunner

Rafał Pitoń 10 лет назад
Родитель
Сommit
30856455e9

+ 5 - 4
misago/emberapp/app/services/toast-message.js

@@ -1,8 +1,6 @@
 import Ember from 'ember';
 import ENV from '../config/environment';
 
-var HIDE_ANIMATION_LENGTH = 200;
-
 export default Ember.Service.extend({
   id: null,
   type: null,
@@ -20,12 +18,15 @@ export default Ember.Service.extend({
     this.set('message', message);
     this.set('isVisible', true);
 
+    var displayTime = ENV.APP.TOAST_BASE_DISPLAY_TIME;
+    displayTime += message.length * ENV.APP.TOAST_LENGTH_FACTOR;
+
     var self = this;
     Ember.run.later(function () {
       if (self.get('id') === toastId) {
         self.set('isVisible', false);
       }
-    }, ENV.APP.TOAST_BASE_DISPLAY_TIME + (message.length * 110));
+    }, displayTime);
   },
 
   _setToast: function(type, message) {
@@ -35,7 +36,7 @@ export default Ember.Service.extend({
       this.set('isVisible', false);
       Ember.run.later(function () {
         self._showToast(type, message);
-      }, HIDE_ANIMATION_LENGTH);
+      }, ENV.APP.TOAST_HIDE_ANIMATION_LENGTH);
     } else {
       this._showToast(type, message);
     }

+ 7 - 5
misago/emberapp/config/environment.js

@@ -26,9 +26,10 @@ module.exports = function(environment) {
       // Misago ticks frequency (in ms, used for refreshing timestamps)
       TICK_FREQUENCY: 15000,
 
-      // Base time toast is displayed for (in ms)
-      // This time is increased by message length
-      TOAST_BASE_DISPLAY_TIME: 4000
+      // Toastings time
+      TOAST_BASE_DISPLAY_TIME: 4000,
+      TOAST_LENGTH_FACTOR: 110,
+      TOAST_HIDE_ANIMATION_LENGTH: 200
     }
   };
 
@@ -63,8 +64,9 @@ module.exports = function(environment) {
 
     ENV.APP.rootElement = '#ember-testing';
 
-    // Reduce base toast display time for test runner
-    ENV.APP.TOAST_BASE_DISPLAY_TIME = 500;
+    // Reduce toast display times for test runner
+    ENV.APP.TOAST_BASE_DISPLAY_TIME = 200;
+    ENV.APP.TOAST_LENGTH_FACTOR = 0;
   }
 
   if (environment === 'production') {