novicell/premium_tools

Premium Tools

1.3.9 2025-06-24 13:20 UTC

README

The module has no special installation steps. This document will explain what features it provides and how you can use them.

What are the features of this module?

  • Each developer who adds code to this module is responsible for adding a feature description in this file, or providing an example in an example file in the module.

Ajax Commands

The 'ScrollTo' Ajax Command

  • Purpose:

With this command you can make an ajax form scroll on an action. This is useful when removing/showing new content in an Ajax form.

  • Usage:
  1. Add the library to your form, like so $form['#attached']['library'][] = 'dds_tools/scroll_to_command';
  2. Use the command in your Ajax callback function, like so:
    $response = new JsonResponse();
    $response->addCommand(new ScrollToCommand([
          'selector' => '#selector',
          'header_selectors' => ['.js-header', '.js-main-navigation'],
          'offsetOrPosition' => 'offset',
        ]));
    return $response;

The parameters for the command are as follows: The parameters for the command are as follows:

  • selector: string
    • The selector to scroll to.
  • header_selector: array
    • If the site has a fixed header, give the header class(es) to offset it.
  • offsetOrPosition: string
    • If the scroll should be relative to the document or to the selector.
      • 'offset' is relative to the document
      • '' will default to using jQuery position, relative to the selector.