JSUtils
Categories
Component ID
1682686
Component name
JSUtils
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
An attempt to add helper functions, depedencies, and modularity to frontend Drupal code.
Adds the following function (backend):
- drupal_add_js_dependency(stack, name) - ensures a dependency is in effect before pages load to sidestep race conditions.
Adds the following function sets (frontend):
Dependency functions:
- Drupal.modules.init_dependencies() - initialises all dependencies that were present in Drupal.settings on load.
- Drupal.modules.init_dependency(stack, fallback = true) - create a dependency stack, optionally making it resolve after page load. May switch to a timeout in future.
- Drupal.modules.add_dependency(stack, name) - adds a dependency to a dependency stack, which must be marked as resolved before the stack marks as resolved
- Drupal.modules.resolve_dependencyname - resolves a named dependency on all stacks.
- Drupal.modules.dependency_status(stack) - checks the status of a dependency stack
- Drupal.modules.get_dependants(name) - lists stacks that depend on the named module.
Hook handling functions
- Drupal.modules.attach(name, functions) - adds a module to the list of possible hook-implementors
- Drupal.modules.implements(hook) - lists modules that implement the named hook
- Drupal.modules.invoke(module, hook) - invokes a hook on a specific module
- Drupal.modules.invoke_all(hook, [arg1, [arg2...]]) - invokes a hook on all modules that implement it.
- Drupal.modules.alter(hook, data) - invokes a hook_alter on all modules that implement it.
Misc helper functions:
- Drupal.url(path, options) - an "as close as can be" clone of the Drupal url() function.
