-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontactinfo.admin.js
41 lines (40 loc) · 1.3 KB
/
contactinfo.admin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* @file
* JS for the Contact Information module settings form.
*/
(function ($, Drupal) {
"use strict";
Drupal.behaviors.contactinfo = {
attach: function () {
var contactInfoProperties = {
org: {
$checkbox: $('#edit-contactinfo-use-site-name'),
$textField: $('#edit-contactinfo-org'),
siteSettingsVal: Drupal.settings.siteName
},
tagline: {
$checkbox: $('#edit-contactinfo-use-site-slogan'),
$textField: $('#edit-contactinfo-tagline'),
siteSettingsVal: Drupal.settings.siteSlogan
}
};
$.each(contactInfoProperties, function (i, v) {
// Store user-entered value.
var userEnteredVal = v.$textField.val();
if (v.$checkbox.is(':checked')) {
v.$textField.attr('disabled', 'disabled').val(v.siteSettingsVal);
}
v.$checkbox.change(function () {
if ($(this).is(':checked')) {
// Store latest user-entered value in case the checkbox gets unchecked.
userEnteredVal = v.$textField.val();
v.$textField.attr('disabled', 'disabled').val(v.siteSettingsVal);
}
else {
v.$textField.removeAttr('disabled').val(userEnteredVal);
}
});
});
}
};
})(jQuery, Drupal);