Skip to content

Commit

Permalink
refactor(notifications): use local config instead global
Browse files Browse the repository at this point in the history
  • Loading branch information
SashaSkywalker committed Jan 20, 2016
1 parent 5a0c78e commit bd5f2cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 2 additions & 17 deletions src/app/pages/ui/notifications/NotificationsPageCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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();
Expand All @@ -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) + ")";
Expand Down

0 comments on commit bd5f2cc

Please sign in to comment.