27
27
* http://stackoverflow.com/questions/6787383/what-is-the-solution-to-remove-add-a-class-in-pure-javascript.
28
28
* */
29
29
30
- function addClass ( el , aclass ) {
30
+ /**
31
+ * @param {HTMLElement } el
32
+ * @param {string } aclass
33
+ */
34
+ function addClass ( el , aclass ) {
31
35
el . className += ' ' + aclass ;
32
36
}
33
37
34
- function removeClass ( el , aclass ) {
38
+ /**
39
+ * @param {HTMLElement } el
40
+ * @param {string } aclass
41
+ */
42
+ function removeClass ( el , aclass ) {
35
43
var elClass = ' ' + el . className + ' ' ;
36
- while ( elClass . indexOf ( ' ' + aclass + ' ' ) != - 1 ) {
44
+ while ( elClass . indexOf ( ' ' + aclass + ' ' ) != - 1 ) {
37
45
elClass = elClass . replace ( ' ' + aclass + ' ' , '' ) ;
38
46
}
39
47
el . className = elClass ;
@@ -44,7 +52,6 @@ function removeClass(el, aclass){
44
52
* Javascript for hiding/displaying children questions on preview page of
45
53
* questionnaire with conditional branching.
46
54
*/
47
-
48
55
function depend ( children , choices ) {
49
56
children = children . split ( ',' ) ;
50
57
choices = choices . split ( ',' ) ;
@@ -82,7 +89,7 @@ function depend(children, choices) {
82
89
droplist . disabled = false ;
83
90
}
84
91
delete children [ i ] ;
85
- } else if ( children [ i ] ) {
92
+ } else if ( children [ i ] ) {
86
93
if ( typeof document !== "undefined" && ( "classList" in document . createElement ( "a" ) ) ) {
87
94
q . classList . remove ( 'qn-container' ) ;
88
95
q . classList . add ( 'hidedependquestion' ) ;
@@ -114,6 +121,10 @@ function depend(children, choices) {
114
121
115
122
/* exported dependdrop */
116
123
124
+ /**
125
+ * @param {string } qId
126
+ * @param {* } children
127
+ */
117
128
function dependdrop ( qId , children ) {
118
129
var e = document . getElementById ( qId ) ;
119
130
var choice = e . options [ e . selectedIndex ] . value ;
@@ -124,9 +135,12 @@ function dependdrop(qId, children) {
124
135
// When respondent enters text in !other field, corresponding
125
136
// radio button OR check box is automatically checked.
126
137
/* exported other_check */
138
+ /**
139
+ * @param {string | void } name
140
+ */
127
141
function other_check ( name ) {
128
142
var other = name . split ( "_" ) ;
129
- var other = name . slice ( name . indexOf ( "o" ) + 1 ) ;
143
+ var other = name . slice ( name . indexOf ( "o" ) + 1 ) ;
130
144
if ( other . indexOf ( "]" ) != - 1 ) {
131
145
other = other . slice ( 0 , other . indexOf ( "]" ) ) ;
132
146
}
@@ -141,6 +155,9 @@ function other_check(name) {
141
155
142
156
// Automatically empty an !other text input field if another Radio button is clicked.
143
157
/* exported other_check_empty */
158
+ /**
159
+ * @param {string } name
160
+ */
144
161
function other_check_empty ( name , value ) {
145
162
var f = document . getElementById ( "phpesp_response" ) ;
146
163
var i ;
@@ -149,7 +166,7 @@ function other_check_empty(name, value) {
149
166
f . elements [ i ] . checked = true ;
150
167
var otherid = f . elements [ i ] . name + "_" + f . elements [ i ] . value . substring ( 6 ) ;
151
168
var other = document . getElementsByName ( otherid ) ;
152
- if ( value . substr ( 0 , 6 ) != "other_" ) {
169
+ if ( value . substr ( 0 , 6 ) != "other_" ) {
153
170
other [ 0 ] . value = "" ;
154
171
} else {
155
172
other [ 0 ] . focus ( ) ;
@@ -169,6 +186,10 @@ function other_check_empty(name, value) {
169
186
// In a Rate question type of sub-type Order : automatically uncheck a Radio button
170
187
// when another radio button in the same column is clicked.
171
188
/* exported other_rate_uncheck */
189
+ /**
190
+ * @param {string } name
191
+ * @param {string } value
192
+ */
172
193
function other_rate_uncheck ( name , value ) {
173
194
var col_name = name . substr ( 0 , name . indexOf ( "_" ) ) ;
174
195
var inputbuttons = document . getElementsByTagName ( "input" ) ;
@@ -183,6 +204,9 @@ function other_rate_uncheck(name, value) {
183
204
184
205
// Empty an !other text input when corresponding Check Box is clicked (supposedly to empty it).
185
206
/* exported checkbox_empty */
207
+ /**
208
+ * @param {string } name
209
+ */
186
210
function checkbox_empty ( name ) {
187
211
var actualbuttons = document . getElementsByName ( name ) ;
188
212
for ( var i = 0 ; i <= actualbuttons . length ; i ++ ) {
@@ -204,24 +228,24 @@ M.mod_questionnaire = M.mod_questionnaire || {};
204
228
205
229
/* exported Y */
206
230
/* exported e */
207
- M . mod_questionnaire . init_attempt_form = function ( Y ) {
231
+ M . mod_questionnaire . init_attempt_form = function ( ) {
208
232
M . core_formchangechecker . init ( { formid : 'phpesp_response' } ) ;
209
233
} ;
210
234
211
235
M . mod_questionnaire . init_sendmessage = function ( Y ) {
212
- Y . on ( 'click' , function ( e ) {
236
+ Y . on ( 'click' , function ( ) {
213
237
Y . all ( 'input.usercheckbox' ) . each ( function ( ) {
214
238
this . set ( 'checked' , 'checked' ) ;
215
239
} ) ;
216
240
} , '#checkall' ) ;
217
241
218
- Y . on ( 'click' , function ( e ) {
242
+ Y . on ( 'click' , function ( ) {
219
243
Y . all ( 'input.usercheckbox' ) . each ( function ( ) {
220
244
this . set ( 'checked' , '' ) ;
221
245
} ) ;
222
246
} , '#checknone' ) ;
223
247
224
- Y . on ( 'click' , function ( e ) {
248
+ Y . on ( 'click' , function ( ) {
225
249
Y . all ( 'input.usercheckbox' ) . each ( function ( ) {
226
250
if ( this . get ( 'alt' ) == 0 ) {
227
251
this . set ( 'checked' , 'checked' ) ;
@@ -231,7 +255,7 @@ M.mod_questionnaire.init_sendmessage = function(Y) {
231
255
} ) ;
232
256
} , '#checknotstarted' ) ;
233
257
234
- Y . on ( 'click' , function ( e ) {
258
+ Y . on ( 'click' , function ( ) {
235
259
Y . all ( 'input.usercheckbox' ) . each ( function ( ) {
236
260
if ( this . get ( 'alt' ) == 1 ) {
237
261
this . set ( 'checked' , 'checked' ) ;
@@ -242,7 +266,7 @@ M.mod_questionnaire.init_sendmessage = function(Y) {
242
266
} , '#checkstarted' ) ;
243
267
244
268
} ;
245
- M . mod_questionnaire . init_slider = function ( Y ) {
269
+ M . mod_questionnaire . init_slider = function ( ) {
246
270
const allRanges = document . querySelectorAll ( ".slider" ) ;
247
271
allRanges . forEach ( wrap => {
248
272
const range = wrap . querySelector ( "input.questionnaire-slider" ) ;
0 commit comments