Skip to content

Commit 9249165

Browse files
committed
Merge branch '1.0.x' into 1-0-x/prevent-js-error-language-switcher-not-found
2 parents 2e1b6cc + 979b6cf commit 9249165

5 files changed

+9
-22
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
- init module with Cookies & Browser redirection on Homepage only
9-
- handling of language switcher not found preventing JS console error
109
- handling of missing common JS library
10+
- remove dependency on JQuery

README.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,8 @@ if (typeof Drupal.homeRedirectLang == "undefined") {
5050

5151
let links = document.querySelectorAll('.language-link');
5252

53-
// Don't process when standard language switcher not found.
54-
if (links.length === 0) {
55-
return;
56-
}
57-
58-
links.forEach(box => {
59-
box.addEventListener('click', function (event) {
53+
links.forEach(link => {
54+
link.addEventListener('click', function (event) {
6055
var hreflang = event.target.getAttribute('hreflang');
6156
Drupal.homeRedirectLang.setPreferredLanguage(hreflang);
6257
});

home_redirect_lang.libraries.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
common:
22
js:
33
js/home_redirect_lang.common.js: {}
4-
dependencies:
5-
- core/jquery
6-
- core/jquery.cookie
74

85
language_switcher:
96
js:

js/home_redirect_lang.common.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Common helper functions used by various parts of Homepage Redirect Language.
55
*/
66

7-
(function ($, Drupal, drupalSettings) {
7+
(function (Drupal) {
88

99
'use strict';
1010

@@ -22,4 +22,4 @@
2222
document.cookie = 'home_redirect_lang_preferred_langcode=' + langcode + '; expires=' + date.toUTCString() + '; path=/';
2323
};
2424

25-
}(jQuery, Drupal, drupalSettings));
25+
}(Drupal));

js/home_redirect_lang.language_switcher.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Defines the behavior of the language switcher cookie storage.
55
*/
66

7-
(function ($, Drupal, drupalSettings) {
7+
(function (Drupal) {
88

99
'use strict';
1010

@@ -23,13 +23,8 @@
2323

2424
let links = document.querySelectorAll('.language-switcher-language-url .language-link');
2525

26-
// Don't process when standard language switcher not found.
27-
if (links.length === 0) {
28-
return;
29-
}
30-
31-
links.forEach(box => {
32-
box.addEventListener('click', function (event) {
26+
links.forEach(link => {
27+
link.addEventListener('click', function (event) {
3328
var hreflang = event.target.getAttribute('hreflang');
3429
Drupal.homeRedirectLang.setPreferredLanguage(hreflang);
3530
});
@@ -39,4 +34,4 @@
3934
};
4035

4136

42-
}(jQuery, Drupal, drupalSettings));
37+
}(Drupal));

0 commit comments

Comments
 (0)