JSUtils

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):

  1. 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:

  1. Drupal.modules.init_dependencies() - initialises all dependencies that were present in Drupal.settings on load.
  2. 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.
  3. 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
  4. Drupal.modules.resolve_dependencyname - resolves a named dependency on all stacks.
  5. Drupal.modules.dependency_status(stack) - checks the status of a dependency stack
  6. Drupal.modules.get_dependants(name) - lists stacks that depend on the named module.

Hook handling functions

  1. Drupal.modules.attach(name, functions) - adds a module to the list of possible hook-implementors
  2. Drupal.modules.implements(hook) - lists modules that implement the named hook
  3. Drupal.modules.invoke(module, hook) - invokes a hook on a specific module
  4. Drupal.modules.invoke_all(hook, [arg1, [arg2...]]) - invokes a hook on all modules that implement it.
  5. Drupal.modules.alter(hook, data) - invokes a hook_alter on all modules that implement it.

Misc helper functions:

  1. Drupal.url(path, options) - an "as close as can be" clone of the Drupal url() function.