Popup-Maker icon indicating copy to clipboard operation
Popup-Maker copied to clipboard

Store last open trigger per popup.

Open danieliser opened this issue 8 years ago • 6 comments

danieliser avatar Jul 06 '16 02:07 danieliser

@danieliser Isn't this one already implemented? We save the last open for many of our triggers here, like in this one: https://github.com/PopupMaker/Popup-Maker/blob/master/assets/js/src/site/plugins/pum-triggers.js#L35

Or, is this referring to something different?

fpcorso avatar Sep 30 '20 14:09 fpcorso

@fpcorso This would be different and I'd prefer to make it via an offical API of sorts going forward.

$.fn.popmake.last_open_trigger = 'Auto Open - Delay: ' + settings.delay;

^^ the above is setting a global variable. Each popup that opens overwrites its previous value.

This was intended to set that value on a per popup basis, in the simplest form the change would be:

$.fn.popmake.last_open_trigger[123] = 'Auto Open - Delay: ' + settings.delay;

Of course this would be for popup 123.

But making it an official method of either the .popmake() jQuery object or more likely the PUM. global JS object means we can change how that info is stored without breaking peoples integrated code.

So we need at least 2 new methods:

  • PUM.getLastOpenTrigger(123) returns null or trigger.
  • PUM.setLastOpenTrigger(123, trigger)

We could also discuss should it still be called "Last" open trigger, or just open trigger.

danieliser avatar Oct 02 '20 17:10 danieliser

@danieliser Ah, that makes sense. So, my follow-up question would be: what is the use-case for this? When would someone need to be able to get the last open trigger for a popup?

fpcorso avatar Oct 06 '20 13:10 fpcorso

@fpcorso it comes up primarily when using stackable popups and trying to do something when one closes. Terms & Conditions for example uses last trigger to reclick on agree, if another popup appeared stacked with that then agreeing might not do anything.

danieliser avatar Oct 07 '20 19:10 danieliser

@danieliser For that use case, do we just need this value stored within just the one page, maybe as a data-* value we check?

Or, would we need to be able to see the last trigger across page loads, and maybe store the value in sessionStorage?

fpcorso avatar Oct 16 '20 16:10 fpcorso

@fpcorso no it just needs to be stored for the current page load as it is now, no need to persist it that I can think of unless you have some ideas I'm not considering.

That said I'd probably leave it out of the DOM so data-* is out. I'd stick to some internal or scoped property/var along side this particular section of code. You could even make it a property of the same PUM object these new methods will be added too. Maybe a private one with a _ prefix if we only intend for it to be accessed via defined methods.

danieliser avatar Oct 16 '20 19:10 danieliser