Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration to disable user close (implements #118) #119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Thanks Marco Rinck for the original code, the following people have contributed
* [soumya92](https://github.com/soumya92)
* [willjk](https://github.com/willjk)
* [wardvijf](https://github.com/wardvijf)
* [blitzmann](https://github.com/blitzmann)

# License
Copyright (C) 2015 Marco Rinck
Expand Down
11 changes: 6 additions & 5 deletions src/growlDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ angular.module("angular-growl").directive("growl", [

//Cancels all promises within message upon deleting message or stop deleting.
$scope.stopTimeoutClose = function (message) {
if (!message.clickToClose) {
angular.forEach(message.promises, function (promise) {
$interval.cancel(promise);
});
angular.forEach(message.promises, function (promise) {
$interval.cancel(promise);
});

if (!message.disableUserClose){
if (message.close) {
growlMessages.deleteMessage(message);
} else {
Expand Down Expand Up @@ -84,7 +85,7 @@ angular.module("angular-growl").run(['$templateCache', function ($templateCache)
$templateCache.put("templates/growl/growl.html",
'<div class="growl-container" ng-class="wrapperClasses()">' +
'<div class="growl-item alert" ng-repeat="message in growlMessages.directives[referenceId].messages" ng-class="alertClasses(message)" ng-click="stopTimeoutClose(message)">' +
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true" ng-click="growlMessages.deleteMessage(message)" ng-if="!message.disableCloseButton">&times;</button>' +
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true" ng-click="growlMessages.deleteMessage(message)" ng-if="!message.disableCloseButton && !message.disableUserClose">&times;</button>' +
'<button type="button" class="close" aria-hidden="true" ng-if="showCountDown(message)">{{message.countdown}}</button>' +
'<h4 class="growl-title" ng-if="message.title" ng-bind="message.title"></h4>' +
'<div class="growl-message" ng-bind-html="message.text"></div>' +
Expand Down
2 changes: 2 additions & 0 deletions src/growlFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ angular.module("angular-growl").provider("growl", function () {
_inline = false,
_position = 'top-right',
_disableCloseButton = false,
_disableUserClose = false,
_disableIcons = false,
_reverseOrder = false,
_disableCountDown = false,
Expand Down Expand Up @@ -250,6 +251,7 @@ angular.module("angular-growl").provider("growl", function () {
disableCloseButton: _config.disableCloseButton === undefined ? _disableCloseButton : _config.disableCloseButton,
disableIcons: _config.disableIcons === undefined ? _disableIcons : _config.disableIcons,
disableCountDown: _config.disableCountDown === undefined ? _disableCountDown : _config.disableCountDown,
disableUserClose: _config.disableUserClose === undefined ? _disableUserClose : _config.disableUserClose,
position: _config.position || _position,
referenceId: _config.referenceId || _referenceId,
translateMessage: _config.translateMessage === undefined ? _translateMessages : _config.translateMessage,
Expand Down