Module: Admin/Libs/button_dropdown

Button Dropdown Library

This library contains helper functions that make the manipulation of a button dropdown widget easier.

You will need to provide the full URL in order to load this library as a dependency to a module:

gx.controller.module(
  'my_custom_page',

  [
     jse.core.config.get('shopUrl') + '/admin/html/assets/javascript/engine/libs/button_dropdown'
  ],

  function(data) {
     // Module code ... 
  });

Example

var $buttonDropdown = $('#my.js-button-dropdown');

// Map an action to a dropdown item.
jse.libs.button_dropdown.mapAction($buttonDropdown, action, section, callback, $targetRecentButton);

// Change recent button.
jse.libs.button_dropdown.changeDefualtButton($buttonDropdown, text, callback, $targetRecentButton);

// Add a separator in a dropdown list.
jse.libs.button_dropdown.addDropdownSeperator($buttonDropdown);
Source:
To Do:
  • Further improve the code and the comments of this library.

Methods

(static) addSeparator($dropdown)

Adds a separator to the dropdown list.

The separator will be added at the end of the list.

Parameters:
Name Type Description
$dropdown object
Source:

(static) changeDefaultAction($button, title, callback, $targetDefaultButton)

Changes the default action of the button.

Parameters:
Name Type Description
$button object

The affected button dropdown widget.

title string

Text of the new button.

callback string

The callback

$targetDefaultButton object

A custom element for which button should be changed.

Source:

(static) mapAction(translationPhrase, translationSection, customCallback, $targetDefaultButton)

Adds a new item to the dropdown.

Parameters:
Name Type Description
translationPhrase string

Translation phrase key.

translationSection string

Translation section of the phrase.

customCallback function

Define a custom callback.

$targetDefaultButton object

(optional) A custom selector which dropdown buttons should be changed.

Source: