Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Refactor $log decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinBressan committed May 30, 2014
1 parent 3781c1f commit cfbd8a2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 45 deletions.
5 changes: 5 additions & 0 deletions sass/phpcr-browser/toaster.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ $animation-duration: 200;
#toast-container > div {
@include border-radius(0);
@include box-shadow(none);

&:hover {
@include border-radius(0);
@include box-shadow(none);
}
}
2 changes: 1 addition & 1 deletion web/assets/css/screen.css

Large diffs are not rendered by default.

62 changes: 18 additions & 44 deletions web/assets/js/browser/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,50 +144,24 @@ define([
.run(['$rootScope', '$log', '$translate', 'toaster', 'editableOptions', 'mbEventBridge', 'mbMenu', 'mbMenuBuilderFactory', function($rootScope, $log, $translate, toaster, editableOptions, EventBridge, Menu, MenuBuilderFactory) {
editableOptions.theme = 'bs3';

$log.before('error', function(message, toast, display) {
display = display === undefined ? true : display;
if (display) {
if (toast) { message = toast; }
$translate('ERROR').then(function(translation) {
toaster.pop('error', translation, message);
}, function(err) {
toaster.pop('error', err, message);
});
}
});
$log.before('log', function(message, toast, display) {
display = display === undefined ? true : display;
if (display) {
if (toast) { message = toast; }
$translate('SUCCESS').then(function(translation) {
toaster.pop('success', translation, message);
}, function(err) {
toaster.pop('success', err, message);
});
}
});
$log.before('info', function(message, toast, display) {
display = display === undefined ? true : display;
if (display) {
if (toast) { message = toast; }
$translate('NOTE').then(function(translation) {
toaster.pop('note', translation, message);
}, function(err) {
toaster.pop('note', err, message);
});
}
});
$log.before('warn', function(message, toast, display) {
display = display === undefined ? true : display;
if (display) {
if (toast) { message = toast; }
$translate('WARNING').then(function(translation) {
toaster.pop('warning', translation, message);
}, function(err) {
toaster.pop('warning', err, message);
});
}
});
var logListenerFactory = function(title, toastType) {
return function(message, toast, display) {
display = display === undefined ? true : display;
if (display) {
if (toast) { message = toast; }
$translate(title).then(function(translation) {
toaster.pop(toastType, translation, message);
}, function(err) {
toaster.pop(toastType, err, message);
});
}
};
};

$log.before('error', logListenerFactory('ERROR', 'error'));
$log.before('log', logListenerFactory('SUCCESS', 'success'));
$log.before('info', logListenerFactory('NOTE', 'note'));
$log.before('warn', logListenerFactory('WARNING', 'warning'));

$log.decorate(function(message) {
return [message]; // To remove toast in the log
Expand Down

0 comments on commit cfbd8a2

Please sign in to comment.