Welcome to mirror list, hosted at ThFree Co, Russian Federation.

redirect_behavior.js « listbox « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 38d9d84f88988c9c7f2275ca1d1a9c6917fd856f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { initListbox } from '~/listbox';
import { redirectTo } from '~/lib/utils/url_utility';

/**
 * Instantiates GlCollapsibleListbox components with redirect behavior for tags created
 * with the `gl_redirect_listbox_tag` HAML helper.
 *
 * NOTE: Do not import this script explicitly. Using `gl_redirect_listbox_tag`
 * automatically injects the `redirect_listbox` bundle, which calls this
 * function.
 */
export function initRedirectListboxBehavior() {
  const elements = Array.from(document.querySelectorAll('.js-redirect-listbox'));

  return elements.map((el) =>
    initListbox(el, {
      onChange({ href }) {
        redirectTo(href);
      },
    }),
  );
}