JanStevens / angular-growl-2

growl-like notifications for angularJS projects
MIT License
285 stars 97 forks source link

Don't want to close message on double-click. #118

Open rajansiingh opened 7 years ago

rajansiingh commented 7 years ago

I have hidden the default close button in growl message but still when I double click on message it closes/hide. I want the message to display permanently not fade out/hide/close on double click. My growl message contains some links inside it, so I can't do "pointer-events:none" on open event .

Please suggest. How to do it?

blitzmann commented 7 years ago

Hi there,

We had need of this functionality as well, so I looked into it a bit. Take a look here:

https://github.com/JanStevens/angular-growl-2/blob/a910139d512c6611669dbfee09d341a82ea6c34f/build/angular-growl.js#L33

It seems that there is a check here introduced with a910139d that checks to see if there is a flag that disables click to close. However, this is the only instance of this property that I can see. It is not set anywhere that I can see.

I was able to get around this by tweaking a few things. I don't have a diff available to me right now (and I may make a pull request for this later), but I changed that line to look like:

if (!message.disableClickToClose) {

Then I added a default value to this line: https://github.com/JanStevens/angular-growl-2/blob/a910139d512c6611669dbfee09d341a82ea6c34f/build/angular-growl.js#L93

..., _disableCloseButton = false, ...

Finally I added the following to the message object on https://github.com/JanStevens/angular-growl-2/blob/a910139d512c6611669dbfee09d341a82ea6c34f/build/angular-growl.js#L193

disableClickToClose: _config.disableClickToClose === undefined ? _disableClickToClose : _config.disableClickToClose,

I was then able to call a growl with the following:

growl.error('This is an error.', { ttl: -1, disableCloseButton: true, disableClickToClose: true })

Again, I might make a pull request that introduces something like this. I'm thinking changing it to a permanent flag, which would disable TTL, the close button, and click to close.

blitzmann commented 7 years ago

I've added a pull request to address this issue. :)