2013-06-22 08:24:24 +02:00
|
|
|
'use strict';
|
2013-06-19 03:02:23 +02:00
|
|
|
define(function () {
|
|
|
|
return {
|
2013-05-12 01:39:32 +02:00
|
|
|
show: function (options) {
|
|
|
|
|
|
|
|
if (!options.type) {
|
|
|
|
options.type = 'info';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!options.hideAfter) {
|
|
|
|
switch (options.type) {
|
|
|
|
case 'info':
|
|
|
|
options.hideAfter = 5;
|
|
|
|
break;
|
2013-06-19 06:27:41 +02:00
|
|
|
|
|
|
|
default :
|
2013-05-12 01:39:32 +02:00
|
|
|
options.hideAfter = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return window.Messenger().post({
|
|
|
|
message : options.message,
|
|
|
|
type : options.type,
|
|
|
|
showCloseButton: true,
|
|
|
|
hideAfter : options.hideAfter
|
|
|
|
});
|
2013-06-19 06:27:41 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
};
|
2013-05-12 01:39:32 +02:00
|
|
|
});
|
2013-06-19 06:27:41 +02:00
|
|
|
|