2014-08-31 23:22:56 +02:00
|
|
|
var App = App || {};
|
|
|
|
App.Presenters = App.Presenters || {};
|
|
|
|
|
|
|
|
App.Presenters.MessagePresenter = function(jQuery) {
|
|
|
|
|
|
|
|
function showInfo($el, message) {
|
|
|
|
return showMessage($el, 'info', message);
|
2014-09-08 22:02:28 +02:00
|
|
|
}
|
2014-08-31 23:22:56 +02:00
|
|
|
|
|
|
|
function showError($el, message) {
|
|
|
|
return showMessage($el, 'error', message);
|
2014-09-08 22:02:28 +02:00
|
|
|
}
|
2014-08-31 23:22:56 +02:00
|
|
|
|
|
|
|
function hideMessages($el) {
|
|
|
|
$el.children('.message').each(function() {
|
2014-09-08 22:02:28 +02:00
|
|
|
jQuery(this).slideUp('fast', function() {
|
|
|
|
jQuery(this).remove();
|
2014-08-31 23:22:56 +02:00
|
|
|
});
|
|
|
|
});
|
2014-09-08 22:02:28 +02:00
|
|
|
}
|
2014-08-31 23:22:56 +02:00
|
|
|
|
|
|
|
function showMessage($el, className, message) {
|
2014-09-08 22:02:28 +02:00
|
|
|
var $messageDiv = jQuery('<div>');
|
2014-08-31 23:22:56 +02:00
|
|
|
$messageDiv.addClass('message');
|
|
|
|
$messageDiv.addClass(className);
|
|
|
|
$messageDiv.html(message);
|
|
|
|
$messageDiv.hide();
|
|
|
|
$el.append($messageDiv);
|
|
|
|
$messageDiv.slideDown('fast');
|
|
|
|
return $messageDiv;
|
2014-09-08 22:02:28 +02:00
|
|
|
}
|
2014-08-31 23:22:56 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
showInfo: showInfo,
|
|
|
|
showError: showError,
|
|
|
|
hideMessages: hideMessages,
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-09-11 12:33:44 +02:00
|
|
|
App.DI.register('messagePresenter', ['jQuery'], App.Presenters.MessagePresenter);
|