Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We need to have some code run when the popup is opened or closed, so patch to follow that will trigger an event at the end of the relevant animations (our particular case is for visual purposes so it needs to be after the animation).
Comment | File | Size | Author |
---|---|---|---|
#11 | eu-cookie-compliance-add-events-open-close-2423649-4.patch | 1.84 KB | jcmiller09 |
#3 | eu-cookie-compliance-add-events-open-close-2423649-3.patch | 2.1 KB | svenryen |
Comments
Comment #1
stevetweeddale CreditAttribution: stevetweeddale commentedPatch attached. A small amount of refactoring was required to avoid having to trigger the events in multiple code paths.
Comment #2
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedHi @stevetweeddale! A lot has changed since you contributed your patch. I tried to implement the same behavior in the latest -dev. Can you have a look at the attached patch and see whether the events trigger correctly?
Comment #3
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedI had a problem with the variable names. Ignore #2, here's a patch that should work properly.
Comment #5
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedI tested the triggers and found that they all fired, so I'm adding this to -dev. Thanks, stevetweeddale!
Comment #6
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedComment #9
jcmiller09 CreditAttribution: jcmiller09 commentedFor the lines removing the popup and triggering the custom event
$('#sliding-popup').remove().trigger('eu_cookie_compliance_popup_close');
the remove() method is happening first and not triggering the event since everything is dumped from that element. Putting the trigger() before the remove() allows the event to fire.
Comment #10
jcmiller09 CreditAttribution: jcmiller09 commentedPatch for 7.x-1.23
Comment #11
jcmiller09 CreditAttribution: jcmiller09 commentedComment #12
jcmiller09 CreditAttribution: jcmiller09 commentedIt might also be better to move the event triggers to before the .animate() calls, in case one needs to synchronize other elements on the page. The way it fires now, it has to wait for the animation to complete before the callback fires.
Comment #13
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedNice catch, @jcmiller09 ! I'll take a look at the patch!
Comment #16
svenryen CreditAttribution: svenryen at Ramsalt Lab commented