webservice MDL-17135 add disable javascript to the valid until fields
[moodle.git] / admin / webservice / script.js
CommitLineData
b5c6b61d 1capability_service = {
2 select: null,
3 input: null,
4 button: null,
5
6 cap_filter_init: function(strsearch) {
7 // Find the form controls.
8 capability_service.select = document.getElementById('menucapability');
9 capability_service.button = document.getElementById('settingssubmit');
10
11 // Create a div to hold the search UI.
12 var div = document.createElement('div');
13 div.id = 'capabilitysearchui';
14
15 // Find the capability search input.
16 var input = document.createElement('input');
17 input.type = 'text';
18 input.id = 'capabilitysearch';
19 capability_service.input = input;
20
21 // Create a label for the search input.
22 var label = document.createElement('label');
23 label.htmlFor = input.id;
24 label.appendChild(document.createTextNode(strsearch + ' '));
25
26 // Tie it all together
27 div.appendChild(label);
28 div.appendChild(input);
29 capability_service.select.parentNode.insertBefore(div, capability_service.select);
30 YAHOO.util.Event.addListener(input, 'keyup', capability_service.cap_filter_change);
31 YAHOO.util.Event.addListener(capability_service.select, 'change', capability_service.validate);
32 capability_service.select.options[0].style.display = 'none';
33 capability_service.validate();
34 },
35
36 cap_filter_change: function() {
37 var filtertext = capability_service.input.value;
38 var options = capability_service.select.options;
39 var onlycapability = -1;
40 for (var i = 1; i < options.length; i++) {
41 if (options[i].text.indexOf(filtertext) >= 0) {
42 options[i].disabled = false;
43 options[i].style.display = 'block';
44 if (onlycapability == -1) {
45 onlycapability = i;
46 } else {
47 onlycapability = -2;
48 }
49 } else {
50 options[i].disabled = true;
51 options[i].selected = false;
52 options[i].style.display = 'none';
53 }
54 }
55 if (onlycapability >= 0) {
56 options[onlycapability].selected = true;
57 }
58 if (onlycapability == -1) {
59 capability_service.input.className = "error";
60 } else {
61 capability_service.input.className = "";
62 }
63
64 capability_service.validate();
65 },
66
67 validate: function() {
68 capabilityname = document.getElementById('capabilityname');
69 capabilityname.value = capability_service.select.value;
70
71
72 }
472f56d9 73}
74
75/* This function disable the valid until field of a user into external_service_users.php*/
76function disablevaliduntil(event, userid) {
77 var disabled;
78 if (document.getElementById('enablevaliduntil'+userid).checked)
79 {
80 disabled = false;
81 }
82 else {
83 disabled = true;
84 }
85 document.getElementById('menufromday'+userid).disabled = disabled;
86 document.getElementById('menufromyear'+userid).disabled = disabled;
87 document.getElementById('menufrommonth'+userid).disabled = disabled;
b5c6b61d 88}