From bd5f2cc1203dc65bee9b776c8c170490eccae4e4 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 20 Jan 2016 12:56:24 +0300 Subject: [PATCH] refactor(notifications): use local config instead global --- bower.json | 2 +- .../ui/notifications/NotificationsPageCtrl.js | 19 ++----------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/bower.json b/bower.json index 8ba70ea..e3115e6 100644 --- a/bower.json +++ b/bower.json @@ -24,7 +24,7 @@ "angular-route": "~1.4.6", "angular-slimscroll": "~1.1.5", "angular-smart-table": "~2.1.3", - "angular-toastr": "~1.5.0", + "angular-toastr": "~1.6.0", "angular-touch": "~1.4.6", "angular-ui-sortable": "~0.13.4", "animate.css": "~3.4.0", diff --git a/src/app/pages/ui/notifications/NotificationsPageCtrl.js b/src/app/pages/ui/notifications/NotificationsPageCtrl.js index 6e48567..de78e38 100644 --- a/src/app/pages/ui/notifications/NotificationsPageCtrl.js +++ b/src/app/pages/ui/notifications/NotificationsPageCtrl.js @@ -9,7 +9,7 @@ .controller('NotificationsPageCtrl', NotificationsPageCtrl); /** @ngInject */ - function NotificationsPageCtrl($scope, toastr, toastrConfig) { + function NotificationsPageCtrl($scope, toastr) { $scope.types = ['success', 'error', 'info', 'warning']; $scope.quotes = [ @@ -75,21 +75,6 @@ msg: "Type your message here" }; - $scope.$watchCollection('options', function (newValue) { - toastrConfig.autoDismiss = newValue.autoDismiss; - toastrConfig.allowHtml = newValue.html; - toastrConfig.extendedTimeOut = parseInt(newValue.extendedTimeout, 10); - toastrConfig.positionClass = newValue.position; - toastrConfig.timeOut = parseInt(newValue.timeout, 10); - toastrConfig.closeButton = newValue.closeButton; - toastrConfig.tapToDismiss = newValue.tapToDismiss; - toastrConfig.progressBar = newValue.progressBar; - toastrConfig.newestOnTop = newValue.newestOnTop; - toastrConfig.maxOpened = newValue.maxOpened; - toastrConfig.preventDuplicates = newValue.preventDuplicates; - toastrConfig.preventOpenDuplicates = newValue.preventOpenDuplicates; - }); - $scope.clearLastToast = function () { var toast = openedToasts.pop(); @@ -110,7 +95,7 @@ }; $scope.openToast = function () { - openedToasts.push(toastr[$scope.options.type]($scope.options.msg, $scope.options.title)); + openedToasts.push(toastr[$scope.options.type]($scope.options.msg, $scope.options.title, $scope.options)); var strOptions = {}; for (var o in $scope.options) if (o != 'msg' && o != 'title')strOptions[o] = $scope.options[o]; $scope.optionsStr = "toastr." + $scope.options.type + "(\'" + $scope.options.msg + "\', \'" + $scope.options.title + "\', " + JSON.stringify(strOptions, null, 2) + ")";