The current functionality loads any active library on every page, but a common use case is JS inside a block referencing a library where the block only appears on one or a few pages. In order to conditionally load JS, one would have to use PHP in the block to call drupal_add_js(), or hard-code the link to the JS in the markup (losing the advantage of e.g. loading the JS in the page footer).
The suggested feature is to allow within each block config page the selection of one or more of the libraries that is otherwise inactive (i.e. not loaded on every page).
As far as implementation, this module could use hook_block_view_alter() to add the JS for each configured block.
Note there would probably need to be some method for resolving conflicting config (one block nees the libread in the HEAD, another in the footer), or perhaps we could enforce some simplifying assumptions such as putting all block-level JS in the footer?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | Screen_shot-js-lb-custom-admin.png | 69.97 KB | pwolanin |
| #4 | 1351622-verttabs-4.patch | 5.77 KB | pwolanin |
| #3 | js-lib-block-verttabs.png | 64.46 KB | pwolanin |
| #3 | 1351622-verttabs-3.patch | 3.43 KB | pwolanin |
| #2 | 1351622-2.patch | 3.42 KB | pwolanin |
Comments
Comment #1
pwolanin commentedThis does most of what we need.
Comment #2
pwolanin commentedThis patch put the settings in a separate fieldset. Here's a screen shot too.
Comment #3
pwolanin commentedAlternative version + screenshot putting this into the vertical tabs with for visibility. There is some logic grouping them together since no JS library should be enabled here unless you have configured one of the other visibility settings.
Comment #4
pwolanin commentedAlso tweak the admin page to indicate a library is enabled for certain blocks.
Comment #5
pwolanin commentedHere's a screen shot of the admin page
Comment #6
pwolanin commentedcommitted this patch. open a new issue for follow-ups