webui-aria2/js/services/alerts.js

22 lines
535 B
JavaScript
Raw Normal View History

angular.module('webui.services.alerts', ['webui.services.deps'])
.factory('$alerts', ['$_', function(_) {
var alerters = [];
return {
addAlert: function() {
var args = Array.prototype.slice.call(arguments, 0);
setTimeout(function() {
_.each(alerters, function(alt) {
alt.apply({}, args);
});
}, 0);
},
addAlerter: function(cb) {
alerters.push(cb);
2013-03-02 12:01:07 +01:00
},
// a simple function for debugging
log: function(msg) {
this.addAlert(msg, 'info');
}
};
}]);