refactor(notifications): use local config instead global

pull/3/head
alex 2016-01-20 12:56:24 +03:00
parent 5a0c78e8a6
commit bd5f2cc120
2 changed files with 3 additions and 18 deletions

View File

@ -24,7 +24,7 @@
"angular-route": "~1.4.6", "angular-route": "~1.4.6",
"angular-slimscroll": "~1.1.5", "angular-slimscroll": "~1.1.5",
"angular-smart-table": "~2.1.3", "angular-smart-table": "~2.1.3",
"angular-toastr": "~1.5.0", "angular-toastr": "~1.6.0",
"angular-touch": "~1.4.6", "angular-touch": "~1.4.6",
"angular-ui-sortable": "~0.13.4", "angular-ui-sortable": "~0.13.4",
"animate.css": "~3.4.0", "animate.css": "~3.4.0",

View File

@ -9,7 +9,7 @@
.controller('NotificationsPageCtrl', NotificationsPageCtrl); .controller('NotificationsPageCtrl', NotificationsPageCtrl);
/** @ngInject */ /** @ngInject */
function NotificationsPageCtrl($scope, toastr, toastrConfig) { function NotificationsPageCtrl($scope, toastr) {
$scope.types = ['success', 'error', 'info', 'warning']; $scope.types = ['success', 'error', 'info', 'warning'];
$scope.quotes = [ $scope.quotes = [
@ -75,21 +75,6 @@
msg: "Type your message here" 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 () { $scope.clearLastToast = function () {
var toast = openedToasts.pop(); var toast = openedToasts.pop();
@ -110,7 +95,7 @@
}; };
$scope.openToast = function () { $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 = {}; var strOptions = {};
for (var o in $scope.options) if (o != 'msg' && o != 'title')strOptions[o] = $scope.options[o]; 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) + ")"; $scope.optionsStr = "toastr." + $scope.options.type + "(\'" + $scope.options.msg + "\', \'" + $scope.options.title + "\', " + JSON.stringify(strOptions, null, 2) + ")";