diff --git a/src/web/themes/custom/ouatminimal_theme/js/boussole.js b/src/web/themes/custom/ouatminimal_theme/js/boussole.js new file mode 100644 index 0000000..fd7a731 --- /dev/null +++ b/src/web/themes/custom/ouatminimal_theme/js/boussole.js @@ -0,0 +1,15 @@ +Drupal.behaviors.boussole = { + attach: function (context, settings) { + console.log("Hello boussole", context); + // Use context to filter the DOM to only the elements of interest, + // and use once() to guarantee that our callback function processes + // any given element one time at most, regardless of how many times + // the behaviour itself is called (it is not sufficient in general + // to assume an element will only ever appear in a single context). + // once('boussoleForm', 'input.myCustomBehavior', context).forEach( + // function (element) { + // element.classList.add('processed'); + // } + // ); + } +}; \ No newline at end of file diff --git a/src/web/themes/custom/ouatminimal_theme/ouatminimal.libraries.yml b/src/web/themes/custom/ouatminimal_theme/ouatminimal.libraries.yml index 2d8a202..dae064e 100644 --- a/src/web/themes/custom/ouatminimal_theme/ouatminimal.libraries.yml +++ b/src/web/themes/custom/ouatminimal_theme/ouatminimal.libraries.yml @@ -3,3 +3,9 @@ global-styling: css: theme: css/ouatminimal.css: {} +boussole: + version: VERSION + js: + js/boussole.js: {} + dependencies: + - core/jquery \ No newline at end of file diff --git a/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme b/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme index ec286e7..d745941 100644 --- a/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme +++ b/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme @@ -79,7 +79,7 @@ function ouatminimal_theme_suggestions_field_multiple_value_form_alter(array &$s function ouatminimal_preprocess_field_multiple_value_form__field_entite__node_concernement(&$variables) { // $element = $variables['element']; $attributes = $variables['attributes']; - + $variables['#attached']['library'][] = 'ouatminimal/boussole'; } // template_preprocess_field_multiple_value_form // function ouatminimal_preprocess_field_multiple_value_form(&$variables) {