Skip to content

Commit

Permalink
Preventing toasts to override global options
Browse files Browse the repository at this point in the history
Fixes #54
  • Loading branch information
Foxandxss committed Mar 24, 2015
1 parent 9a87e11 commit 2ac9255
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 5 deletions.
12 changes: 11 additions & 1 deletion dist/angular-toastr.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
};
newToast.iconClass = map.iconClass;
if (map.optionsOverride) {
options = angular.extend(options, map.optionsOverride);
options = angular.extend(options, cleanOptionsOverride(map.optionsOverride));
newToast.iconClass = map.optionsOverride.iconClass || newToast.iconClass;
}

Expand All @@ -210,6 +210,16 @@
newToast.el = createToastEl(newToast.scope);

return newToast;

function cleanOptionsOverride(options) {
var badOptions = ['containerId', 'iconClasses', 'maxOpened', 'newestOnTop',
'positionClass', 'preventDuplicates'];
for (var i = 0, l = badOptions.length; i < l; i++) {
delete options[badOptions[i]];
}

return options;
}
}

function createToastEl(scope) {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-toastr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion dist/angular-toastr.tpls.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
};
newToast.iconClass = map.iconClass;
if (map.optionsOverride) {
options = angular.extend(options, map.optionsOverride);
options = angular.extend(options, cleanOptionsOverride(map.optionsOverride));
newToast.iconClass = map.optionsOverride.iconClass || newToast.iconClass;
}

Expand All @@ -210,6 +210,16 @@
newToast.el = createToastEl(newToast.scope);

return newToast;

function cleanOptionsOverride(options) {
var badOptions = ['containerId', 'iconClasses', 'maxOpened', 'newestOnTop',
'positionClass', 'preventDuplicates'];
for (var i = 0, l = badOptions.length; i < l; i++) {
delete options[badOptions[i]];
}

return options;
}
}

function createToastEl(scope) {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-toastr.tpls.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2ac9255

Please sign in to comment.