You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 5 години
преди 5 години
преди 5 години
преди 5 години
123456789101112131415161718192021222324252627282930313233343536373839
  1. var appAlerts = new Vue({
  2. el: '#app-alerts',
  3. data: {
  4. alerts: [
  5. ]
  6. },
  7. mounted: function() {
  8. },
  9. methods: {
  10. alertResponse: function(response) {
  11. if(response.data.alert) {
  12. this.alert(response.data.alert.type, response.data.alert.message) ;
  13. }
  14. },
  15. alert: function(type, message, timeout) {
  16. var app = this ;
  17. var index = this.alerts.length ;
  18. this.alerts.splice(index, 0, {
  19. display: false,
  20. type: type,
  21. message: message
  22. });
  23. var functionDisplayAlert = function(app, index, display) {
  24. app.alerts[index].display = display ;
  25. } ;
  26. if(!timeout) {
  27. timeout = 3000 ;
  28. }
  29. setTimeout(functionDisplayAlert, 500, app, index, true) ;
  30. setTimeout(functionDisplayAlert, timeout, app, index, false) ;
  31. }
  32. }
  33. });