Problem/Motivation
Many websites have internal pages that can take a few seconds to load. These pages are not accessed through form submits but through internal links. As noted in the README for this module, there are issues with adding the page load progress indicator to all <a> elements.
If you must, assign the behavior to
<a>elements carefully.<a>
elements can be opened in a new browser tab or window, which would leave the
original window locked waiting for reload. Also,<a>elements are sometimes
used with modals, so make sure that you identify what classes trigger modal
windows and you use:not()to avoid them, or use specific classes when
assigning the behavior (examplea.not-modal).
Despite these challenges, I did run into the use case where I need this functionality across a site. The challenges being documented in the README suggested that this use case was universal enough to warrant a feature request and a patch.
Proposed resolution
The basic idea would be this:
- Create a checkbox on the settings form for this functionality.
- Write a check in the JQuery for the setting.
- Execute the page load progress indicator on
<a>elements with internal links that are opened in the same tab and not from modals.
Attached is my first stab at the patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | interdiff_4-7.txt | 3.69 KB | isaiah nixon |
| #7 | internal_links_7.patch | 7.27 KB | isaiah nixon |
| #5 | interdiff_1-4.txt | 4.79 KB | anavarre |
| #4 | internal_links_4.patch | 4.14 KB | isaiah nixon |
Comments
Comment #2
anavarreThanks for your contribution! I'll provide a review soon but it looks like it's working nicely at first glance.
Comment #3
anavarrePlease put this before
page_load_progress_esc_key. Explanation below.Please wrap the comment at 80 cols.
'Return' is for programmers, but if we have a comment it's also for non-programmers to understand what the code is doing IMO. Instead, what about saying "Do not lock the screen if the user is attempting to open in a new tab."?
Same here: "Do not lock the screen if the link is within a modal".
Same here: "Do not lock the screen if the user is attempting to open in a new tab.".
Thanks for adding the source, very helpful!
Please put this before
'esc_key'. Explanation below.I think this checkbox should live within the VISIBILITY CONDITIONS fieldset because it's also one. Use
$form['visibility_conditions']['page_load_progress_internal_links']The
#titlealready takes care of explaining what this checkbox is for so I think we could drop 'On some sites you may want internal links to use the image lock for internal links.' entirely.Please put this above
'page_load_progress_esc_key'as per the above remark.Comment #4
isaiah nixon commentedThanks @anavarre for getting back to me so quickly. Here is the patch with your feedback incorporated.
Comment #5
anavarreFor readability, please always keep all patches submitted in the issue queue so that it's easier to see changes. Also, creating an interdiff is best.
Here's the interdiff.
Comment #6
anavarreThis should be wrapped at 80 cols. Can be fixed on commit.
Otherwise it looks great, thank you. The only remaining bits I can think of ATM are:
page_load_progress.schema.ymlto add the missingpage_load_progress_internal_linksComment #7
isaiah nixon commentedThanks for your patience and helping me with the process. I went ahead and updated the schema and incorporated the internal links configuration into the functional tests. Let me know if this is what you were looking for and how it should be formatted.
Comment #8
anavarreLet's run tests.
Comment #11
anavarreAdded a few other nitpicks (like consistently naming the 'screen lock' a throbber).
This looks great to me. Committed, thanks!