This feature implements the request for: add the "Hide any element based on the selected value of a checkbox or radio select field" class type to work on thank you pages
It extends ShowHideRadioCheckoxes to save the state of each set of controls initialised by that class into sessionStorage. Then, a new class ThankYouPageConditionalContent handles applying that state on a thank you page.
Because of the fragile nature of handling input states this way, there are some defensive practises implemented in the handling such as:
Saving the page ID with each state item in session storage, and only applying those states on the thank you page if the page ID matches.
Using sessionStorage for automatic cleanup when a tab/window is closed.
Only applying changes on 1 page immediately after a donation is processed - when pageJson.giftProcess is true
Removing the session storage item after the conditional content script has ran 1 time.
This means this code will work for its intended purpose - displaying some conditional content on a thank you page - but would need further considerations if it were to be extended to generally allow conditional content to persist across chained pages.
The test page is set up to load a build of WWF's theme using this engird-scripts branch and has a block on the thank you page for various pieces of conditional content. This PR is only concerned with the final section of that block under the header of "Hide any element based on the selected value of a checkbox or radio select field".
Task: https://app.productive.io/2650-4site-interactive-studios-inc/tasks/6518937
This feature implements the request for: add the "Hide any element based on the selected value of a checkbox or radio select field" class type to work on thank you pages
It extends
ShowHideRadioCheckoxes
to save the state of each set of controls initialised by that class into sessionStorage. Then, a new classThankYouPageConditionalContent
handles applying that state on a thank you page.Because of the fragile nature of handling input states this way, there are some defensive practises implemented in the handling such as:
pageJson.giftProcess
istrue
This means this code will work for its intended purpose - displaying some conditional content on a thank you page - but would need further considerations if it were to be extended to generally allow conditional content to persist across chained pages.
Test page: https://protect.worldwildlife.org/page/66734/donate/1
The test page is set up to load a build of WWF's theme using this engird-scripts branch and has a block on the thank you page for various pieces of conditional content. This PR is only concerned with the final section of that block under the header of "Hide any element based on the selected value of a checkbox or radio select field".