Skip to content
Extraits de code Groupes Projets
Valider 812ed47b rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Refs #6452, move remove existing notification fix to angular directive.

parent 6aa12a40
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -43,7 +43,11 @@ ...@@ -43,7 +43,11 @@
templateUrl: 'plugins/CoreHome/angularjs/notification/notification.directive.html?cb=' + piwik.cacheBuster, templateUrl: 'plugins/CoreHome/angularjs/notification/notification.directive.html?cb=' + piwik.cacheBuster,
controller: 'NotificationController', controller: 'NotificationController',
controllerAs: 'notification', controllerAs: 'notification',
link: function (scope, element, attrs) { link: function (scope, element) {
if (scope.notificationId) {
closeExistingNotificationHavingSameIdIfNeeded(scope.notificationId, element);
}
if (scope.context) { if (scope.context) {
element.children('.notification').addClass('notification-' + scope.context); element.children('.notification').addClass('notification-' + scope.context);
} }
...@@ -53,10 +57,6 @@ ...@@ -53,10 +57,6 @@
scope.noclear = false; scope.noclear = false;
} }
if (scope.notificationId) {
closeExistingNotificationHavingSameIdIfNeeded();
}
if ('toast' == scope.type) { if ('toast' == scope.type) {
addToastEvent(); addToastEvent();
} }
...@@ -65,15 +65,6 @@ ...@@ -65,15 +65,6 @@
addCloseEvent(); addCloseEvent();
} }
function closeExistingNotificationHavingSameIdIfNeeded() {
// TODO: instead of doing a global query for notification, there should be a notification-container
// directive that manages notifications.
var existingNode = angular.element('.system.notification[notification-id=' + attrs.id + ']');
if (existingNode && existingNode.length) {
existingNode.remove();
}
}
function addToastEvent() { function addToastEvent() {
$timeout(function () { $timeout(function () {
element.fadeOut('slow', function() { element.fadeOut('slow', function() {
...@@ -89,6 +80,15 @@ ...@@ -89,6 +80,15 @@
} }
}); });
} }
function closeExistingNotificationHavingSameIdIfNeeded(id, notificationElement) {
// TODO: instead of doing a global query for notification, there should be a notification-container
// directive that manages notifications.
var existingNode = angular.element('[notification-id=' + id + ']').not(notificationElement);
if (existingNode && existingNode.length) {
existingNode.remove();
}
}
} }
}; };
} }
......
...@@ -50,8 +50,6 @@ ...@@ -50,8 +50,6 @@
options = {}; options = {};
} }
closeExistingNotificationHavingSameIdIfNeeded(options);
var template = generateNotificationHtmlMarkup(options, message); var template = generateNotificationHtmlMarkup(options, message);
this.$node = placeNotification(template, options); this.$node = placeNotification(template, options);
}; };
...@@ -111,16 +109,4 @@ ...@@ -111,16 +109,4 @@
return $notificationNode; return $notificationNode;
} }
function closeExistingNotificationHavingSameIdIfNeeded(options)
{
if (!options.id) {
return;
}
var $existingNode = $('[notification-id=' + options.id + ']');
if ($existingNode && $existingNode.length) {
$existingNode.remove();
}
}
})(jQuery, require); })(jQuery, require);
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter