mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Moved source code under src folder - massive change
This commit is contained in:
parent
2fc8123d6b
commit
5bf0e197ec
1499 changed files with 1054 additions and 1444 deletions
64
src/UI/Shared/Messenger.js
Normal file
64
src/UI/Shared/Messenger.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
'use strict';
|
||||
define(function () {
|
||||
return {
|
||||
|
||||
show: function (options) {
|
||||
|
||||
if (!options.type) {
|
||||
options.type = 'info';
|
||||
}
|
||||
|
||||
if (options.hideAfter === undefined) {
|
||||
switch (options.type) {
|
||||
case 'info':
|
||||
options.hideAfter = 5;
|
||||
break;
|
||||
|
||||
case 'success':
|
||||
options.hideAfter = 5;
|
||||
break;
|
||||
|
||||
default :
|
||||
options.hideAfter = 5;
|
||||
}
|
||||
}
|
||||
|
||||
return window.Messenger().post({
|
||||
message : options.message,
|
||||
type : options.type,
|
||||
showCloseButton: true,
|
||||
hideAfter : options.hideAfter,
|
||||
id : options.id
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
monitor: function (options) {
|
||||
|
||||
if (!options.promise) {
|
||||
throw 'promise is required';
|
||||
}
|
||||
|
||||
if (!options.successMessage) {
|
||||
throw 'success message is required';
|
||||
}
|
||||
|
||||
if (!options.errorMessage) {
|
||||
throw 'error message is required';
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
options.promise.done(function () {
|
||||
self.show({message: options.successMessage});
|
||||
});
|
||||
|
||||
options.promise.fail(function () {
|
||||
self.show({message: options.errorMessage, type: 'error'});
|
||||
});
|
||||
|
||||
return options.promise;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue