-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from openeuropa/EPIC-EWPP-2700-Contact-languages
EWPP-2700: Contact form language options.
- Loading branch information
Showing
39 changed files
with
1,028 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @file | ||
* "Related checkboxes" library file. | ||
*/ | ||
(function (Drupal, $) { | ||
'use strict'; | ||
|
||
/** | ||
* Sets state of "Alternative contact language" checkbox based on "Preferred contact language" state. | ||
* | ||
* @type {Drupal~behavior} | ||
* | ||
* @prop {Drupal~behaviorAttach} attach | ||
* Attaches the behavior for oeContactFormsRelatedCheckboxes. | ||
*/ | ||
Drupal.behaviors.oeContactFormsRelatedCheckboxes = { | ||
attach: function (context) { | ||
let prefered_language_checkbox = $(context).find('input[name="corporate_fields[optional_fields][oe_preferred_language]"]'); | ||
let alternative_language_checkbox = $(context).find('input[name="corporate_fields[optional_fields][oe_alternative_language]"]'); | ||
|
||
// Disable "Alternative contact language" if "Preferred contact language" is disabled after page load. | ||
if (prefered_language_checkbox.prop('checked') !== true) { | ||
alternative_language_checkbox.attr('disabled', true); | ||
} | ||
|
||
// Disable/enable "Alternative contact language" based on "Preferred contact language" state. | ||
prefered_language_checkbox.once().click({checkbox: alternative_language_checkbox}, function(e) { | ||
if (!$(this).prop('checked')) { | ||
e.data.checkbox.prop('checked', false); | ||
e.data.checkbox.change(); | ||
} | ||
e.data.checkbox.attr('disabled', !$(this).prop('checked')); | ||
}); | ||
}, | ||
}; | ||
|
||
})(Drupal, jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
related_checkboxes: | ||
js: | ||
js/related_checkboxes.js: {} | ||
dependencies: | ||
- core/drupal | ||
- core/jquery |
Oops, something went wrong.