HTMLGuyLLC / jTimeout

jQuery session timeout handler
https://htmlguyllc.github.io/jTimeout/
MIT License
16 stars 18 forks source link

Add a destructor #23

Closed Locutus83 closed 5 years ago

Locutus83 commented 5 years ago

I'm not sure how you feel about this... Our implementation allows the users to close the timeout notification (#jTimedoutAlert) and remain on the page after the server has terminated their session. In order to achieve this, I had to namespace the mousemove event so it could be removed if they closed the alert. this is done in our code by customizing the jAlert with 'closeBtn': true and providing an onClose function. Without this destructor, moving the mouse re-creates countdowns and it tries to keep tracking and updating a session that has terminated.

Do you feel there are other elements that should be destroyed by such a method?

If you don't like the destructor, can I at least get the namespaced mousemove event?

Locutus83 commented 5 years ago

@HTMLGuyLLC Any thoughts on this?

HTMLGuyLLC commented 5 years ago

Sorry, been tied up with lots of projects. I like the idea of adding a destructor, but I'm concerned about the namespaced mousemove event. How does it get triggered? You didn't add any other code related to mousemove in the plugin, so I assume it's something you have in your project.

Locutus83 commented 5 years ago

It gets triggered the same as any event using the string before the ".". The namespacing is just for specific referencing when using off(). A good explanation can be found here: https://css-tricks.com/namespaced-events-jquery/

HTMLGuyLLC commented 5 years ago

Love it. Thanks for the reference. I will merge your pull request shortly.

HTMLGuyLLC commented 5 years ago

I changed the method name to destroy() and minimized the JS. Please pull the latest version and test for me if you get a chance. Thank you for your contribution! I gave you credit on the version.

Locutus83 commented 5 years ago

I changed the name of that method 4 or 5 times before creating the pull request. I'm fine with you calling it destroy... that was the first name that I used. I'll have to test this tomorrow. I have too much going on this evening. I will let you know.

Locutus83 commented 5 years ago

Works like a charm! Thanks!

Locutus83 commented 5 years ago

I just realized that 3.1.0 didn't get released to https://www.npmjs.com/package/jtimeout. Can we get that updated?

HTMLGuyLLC commented 5 years ago

Done, sorry about that.