Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
clientside_validation
Commits
e8f09eef
Commit
e8f09eef
authored
Sep 06, 2012
by
Jelle Sebreghts
Browse files
JSHint all javascript files
parent
ee02ea7e
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
clientside_validation.api.js
View file @
e8f09eef
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
/*global Drupal: true, jQuery: true*/
/**
* @file
* Javascript api documentation for Clientside Validation.
...
...
@@ -14,6 +16,7 @@
*/
//jQuery wrapper
(
function
(
$
)
{
"
use strict
"
;
//Define a Drupal behaviour with a custom name
Drupal
.
behaviors
.
myModuleBehavior
=
{
attach
:
function
(
context
)
{
...
...
@@ -24,7 +27,7 @@
//http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage
jQuery
.
validator
.
addMethod
(
"
myCustomMethod
"
,
function
(
value
,
element
,
param
)
{
//let an element match an exact value defined by the user
return
value
==
param
;
return
value
==
=
param
;
//Enter a default error message, numbers between {} will be replaced
//with the matching value of that key in the param array, enter {0} if
//param is a value and not an array.
...
...
@@ -36,7 +39,7 @@
// The declaration of this function needs to be within the attach of a Drupal behavior.
Drupal
.
clientsideValidation
.
prototype
.
mycustomerrorplacement
=
function
(
error
,
element
)
{
// error placement code here.
}
}
;
}
}
}
;
})(
jQuery
);
clientside_validation.ie8.js
View file @
e8f09eef
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
/**
* File: clientside_validation.ie8.js
* Version: 7.x-1.x
...
...
@@ -6,27 +7,26 @@
* Project: clientside_validation
* @module clientside_validation
*/
(
function
(){
"
use strict
"
;
'
use strict
'
;
/*
* Support for String.trim
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Trim#Compatibility
*/
*/
if
(
!
String
.
prototype
.
trim
)
{
String
.
prototype
.
trim
=
function
()
{
return
this
.
replace
(
/^
\s
+|
\s
+$/g
,
''
);
};
}
}
/*
* Support for Array.indexOf
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf#Compatibility
*/
*/
if
(
!
Array
.
prototype
.
indexOf
)
{
Array
.
prototype
.
indexOf
=
function
(
searchElement
/*, fromIndex */
)
{
"
use strict
"
;
if
(
this
==
null
)
{
if
(
this
===
null
)
{
throw
new
TypeError
();
}
var
t
=
Object
(
this
);
...
...
@@ -37,9 +37,9 @@ if (!Array.prototype.indexOf) {
var
n
=
0
;
if
(
arguments
.
length
>
0
)
{
n
=
Number
(
arguments
[
1
]);
if
(
n
!=
n
)
{
// shortcut for verifying if it's NaN
if
(
n
!=
=
n
)
{
// shortcut for verifying if it's NaN
n
=
0
;
}
else
if
(
n
!=
0
&&
n
!=
Infinity
&&
n
!=
-
Infinity
)
{
}
else
if
(
n
!=
=
0
&&
n
!=
=
Infinity
&&
n
!=
=
-
Infinity
)
{
n
=
(
n
>
0
||
-
1
)
*
Math
.
floor
(
Math
.
abs
(
n
));
}
}
...
...
@@ -53,8 +53,8 @@ if (!Array.prototype.indexOf) {
}
}
return
-
1
;
}
}
}
;
}
/*
* Support for Array.lastIndexOf
...
...
@@ -64,24 +64,27 @@ if (!Array.prototype.lastIndexOf)
{
Array
.
prototype
.
lastIndexOf
=
function
(
searchElement
/*, fromIndex*/
)
{
"
use strict
"
;
if
(
this
==
null
)
if
(
this
==
=
null
)
{
throw
new
TypeError
();
}
var
t
=
Object
(
this
);
var
len
=
t
.
length
>>>
0
;
if
(
len
===
0
)
if
(
len
===
0
)
{
return
-
1
;
}
var
n
=
len
;
if
(
arguments
.
length
>
1
)
{
n
=
Number
(
arguments
[
1
]);
if
(
n
!=
n
)
if
(
n
!=
=
n
)
{
n
=
0
;
else
if
(
n
!=
0
&&
n
!=
(
1
/
0
)
&&
n
!=
-
(
1
/
0
))
}
else
if
(
n
!==
0
&&
n
!==
Infinity
&&
n
!==
-
Infinity
)
{
n
=
(
n
>
0
||
-
1
)
*
Math
.
floor
(
Math
.
abs
(
n
));
}
}
var
k
=
n
>=
0
...
...
@@ -90,8 +93,9 @@ if (!Array.prototype.lastIndexOf)
for
(;
k
>=
0
;
k
--
)
{
if
(
k
in
t
&&
t
[
k
]
===
searchElement
)
if
(
k
in
t
&&
t
[
k
]
===
searchElement
)
{
return
k
;
}
}
return
-
1
;
};
...
...
@@ -105,15 +109,16 @@ if (!Array.prototype.filter)
{
Array
.
prototype
.
filter
=
function
(
fun
/*, thisp */
)
{
"
use strict
"
;
if
(
this
==
null
)
if
(
this
==
=
null
)
{
throw
new
TypeError
();
}
var
t
=
Object
(
this
);
var
len
=
t
.
length
>>>
0
;
if
(
typeof
fun
!=
"
function
"
)
if
(
typeof
fun
!=
=
"
function
"
)
{
throw
new
TypeError
();
}
var
res
=
[];
var
thisp
=
arguments
[
1
];
...
...
@@ -122,8 +127,9 @@ if (!Array.prototype.filter)
if
(
i
in
t
)
{
var
val
=
t
[
i
];
// in case fun mutates this
if
(
fun
.
call
(
thisp
,
val
,
i
,
t
))
if
(
fun
.
call
(
thisp
,
val
,
i
,
t
))
{
res
.
push
(
val
);
}
}
}
...
...
@@ -142,7 +148,7 @@ if (!Array.prototype.map) {
var
T
,
A
,
k
;
if
(
this
==
null
)
{
if
(
this
==
=
null
)
{
throw
new
TypeError
(
"
this is null or not defined
"
);
}
...
...
@@ -155,7 +161,7 @@ if (!Array.prototype.map) {
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if
({}.
toString
.
call
(
callback
)
!=
"
[object Function]
"
)
{
if
({}.
toString
.
call
(
callback
)
!=
=
"
[object Function]
"
)
{
throw
new
TypeError
(
callback
+
"
is not a function
"
);
}
...
...
@@ -206,5 +212,6 @@ if (!Array.prototype.map) {
// 9. return A
return
A
;
};
};
}
})();
\ No newline at end of file
clientside_validation.js
View file @
e8f09eef
This diff is collapsed.
Click to expand it.
clientside_validation_html5/clientside_validation_html5.js
View file @
e8f09eef
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
/*global Drupal: true, jQuery: true*/
/**
* File: clientside_validation_html5.js
* Version: 7.x-1.x
...
...
@@ -9,14 +11,15 @@
*/
(
/** @lends Drupal */
function
(
$
)
{
"
use strict
"
;
/**
* Drupal.behaviors.clientsideValidationHtml5.
*
* Attach clientside validation to the page for HTML5.
*/
Drupal
.
behaviors
.
clientsideValidationHtml5
=
{
attach
:
function
(
context
)
{
$
(
document
).
bind
(
'
clientsideValidationAddCustomRules
'
,
function
(
event
){
attach
:
function
()
{
$
(
document
).
bind
(
'
clientsideValidationAddCustomRules
'
,
function
(){
/**
* HTML5 specific rules.
* @name _bindHTML5Rules
...
...
@@ -25,16 +28,16 @@
* @private
*/
function
_getMultiplier
(
a
,
b
,
c
)
{
var
inta
=
Number
(
parseInt
(
a
));
var
inta
=
Number
(
parseInt
(
a
,
10
));
var
mula
=
a
.
length
-
inta
.
toString
().
length
-
1
;
var
intb
=
parseInt
(
b
);
var
intb
=
parseInt
(
b
,
10
);
var
mulb
=
b
.
toString
().
length
-
intb
.
toString
().
length
-
1
;
var
intc
=
parseInt
(
c
);
var
intc
=
parseInt
(
c
,
10
);
var
mulc
=
c
.
toString
().
length
-
intc
.
toString
().
length
-
1
;
var
multiplier
=
Math
.
pow
(
10
,
Math
.
max
(
c
,
Math
.
max
(
mula
,
mulb
)));
var
multiplier
=
Math
.
pow
(
10
,
Math
.
max
(
mul
c
,
Math
.
max
(
mula
,
mulb
)));
return
(
multiplier
>
1
)
?
multiplier
:
1
;
}
...
...
@@ -44,15 +47,15 @@
var
step
=
param
[
1
];
var
multiplier
=
_getMultiplier
(
value
,
min
,
step
);
value
=
parseInt
(
parseFloat
(
value
)
*
multiplier
);
min
=
parseInt
(
parseFloat
(
min
)
*
multiplier
);
value
=
parseInt
(
parseFloat
(
value
)
*
multiplier
,
10
);
min
=
parseInt
(
parseFloat
(
min
)
*
multiplier
,
10
);
var
mismatch
=
0
;
if
(
param
[
1
]
!=
'
any
'
)
{
var
step
=
parseInt
(
parseFloat
(
param
[
1
])
*
multiplier
);
mismatch
=
(
value
-
min
)
%
step
if
(
param
[
1
]
!=
=
'
any
'
)
{
step
=
parseInt
(
parseFloat
(
param
[
1
])
*
multiplier
,
10
);
mismatch
=
(
value
-
min
)
%
step
;
}
return
this
.
optional
(
element
)
||
(
mismatch
==
0
&&
value
>=
min
);
return
this
.
optional
(
element
)
||
(
mismatch
==
=
0
&&
value
>=
min
);
},
jQuery
.
format
(
'
Value must be greater than {0} with steps of {1}.
'
));
jQuery
.
validator
.
addMethod
(
"
Html5Max
"
,
function
(
value
,
element
,
param
)
{
...
...
@@ -61,40 +64,40 @@
var
step
=
param
[
1
];
var
multiplier
=
_getMultiplier
(
value
,
max
,
step
);
value
=
parseInt
(
parseFloat
(
value
)
*
multiplier
);
max
=
parseInt
(
parseFloat
(
max
)
*
multiplier
);
value
=
parseInt
(
parseFloat
(
value
)
*
multiplier
,
10
);
max
=
parseInt
(
parseFloat
(
max
)
*
multiplier
,
10
);
var
mismatch
=
0
;
if
(
param
[
1
]
!=
'
any
'
)
{
var
step
=
parseInt
(
parseFloat
(
param
[
1
])
*
multiplier
);
mismatch
=
(
max
-
value
)
%
step
if
(
param
[
1
]
!=
=
'
any
'
)
{
step
=
parseInt
(
parseFloat
(
param
[
1
])
*
multiplier
,
10
);
mismatch
=
(
max
-
value
)
%
step
;
}
return
this
.
optional
(
element
)
||
(
mismatch
==
0
&&
value
<=
max
);
return
this
.
optional
(
element
)
||
(
mismatch
==
=
0
&&
value
<=
max
);
},
jQuery
.
format
(
'
Value must be smaller than {0} and must be dividable by {1}.
'
));
jQuery
.
validator
.
addMethod
(
"
Html5Range
"
,
function
(
value
,
element
,
param
)
{
//param[0] = min, param[1] = max, param[2] = step;
var
min
=
param
[
0
];
var
max
=
param
[
1
];
var
step
=
param
[
2
]
var
step
=
param
[
2
]
;
var
multiplier
=
_getMultiplier
(
value
,
min
,
step
);
value
=
parseInt
(
parseFloat
(
value
)
*
multiplier
);
min
=
parseInt
(
parseFloat
(
min
)
*
multiplier
);
max
=
parseInt
(
parseFloat
(
max
)
*
multiplier
);
value
=
parseInt
(
parseFloat
(
value
)
*
multiplier
,
10
);
min
=
parseInt
(
parseFloat
(
min
)
*
multiplier
,
10
);
max
=
parseInt
(
parseFloat
(
max
)
*
multiplier
,
10
);
var
mismatch
=
0
;
if
(
param
[
2
]
!=
'
any
'
)
{
var
step
=
parseInt
(
parseFloat
(
param
[
2
])
*
multiplier
);
mismatch
=
(
value
-
min
)
%
step
if
(
param
[
2
]
!=
=
'
any
'
)
{
step
=
parseInt
(
parseFloat
(
param
[
2
])
*
multiplier
,
10
);
mismatch
=
(
value
-
min
)
%
step
;
}
return
this
.
optional
(
element
)
||
(
mismatch
==
0
&&
value
>=
min
&&
value
<=
max
);
return
this
.
optional
(
element
)
||
(
mismatch
==
=
0
&&
value
>=
min
&&
value
<=
max
);
},
jQuery
.
format
(
'
Value must be greater than {0} with steps of {2} and smaller than {1}.
'
));
jQuery
.
validator
.
addMethod
(
"
Html5Color
"
,
function
(
value
,
element
,
param
)
{
return
/^#
([
a-f
]
|
[
A-F
]
|
[
0-9
]){6}
$/
.
test
(
value
);
jQuery
.
validator
.
addMethod
(
"
Html5Color
"
,
function
(
value
)
{
return
(
/^#
([
a-f
]
|
[
A-F
]
|
[
0-9
]){6}
$/
)
.
test
(
value
);
},
jQuery
.
format
(
'
Value must be a valid color code
'
));
});
}
}
}
;
})(
jQuery
);
clientside_validation_ife/clientside_validation_ife.js
View file @
e8f09eef
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
/*global Drupal: true, jQuery: true*/
/**
* File: clientside_validation_ife.js
* Version: 7.x-1.x
...
...
@@ -9,14 +11,15 @@
*/
(
/** @lends Drupal */
function
(
$
)
{
"
use strict
"
;
/**
* Drupal.behaviors.clientsideValidationHtml5.
*
* Attach clientside validation to the page for HTML5.
*/
Drupal
.
behaviors
.
clientsideValidationIfe
=
{
attach
:
function
(
context
)
{
$
(
document
).
bind
(
'
clientsideValidationInitialized
'
,
function
(
event
,
formid
){
attach
:
function
()
{
$
(
document
).
bind
(
'
clientsideValidationInitialized
'
,
function
(){
/**
* IFE specific rules.
* @name _bindIfeRules
...
...
@@ -29,5 +32,5 @@
});
});
}
}
})(
jQuery
);
\ No newline at end of file
};
})(
jQuery
);
clientside_validation_states/clientside_validation_states.js
View file @
e8f09eef
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
/*global Drupal: true, jQuery: true*/
/**
* File: clientside_validation_states.js
* Version: 7.x-1.x
...
...
@@ -9,29 +11,30 @@
*/
(
/** @lends Drupal */
function
(
$
)
{
"
use strict
"
;
/**
* Drupal.behaviors.clientsideValidationStates.
*
* Attach clientside validation to the page for states.
*/
Drupal
.
behaviors
.
clientsideValidationStates
=
{
attach
:
function
(
context
)
{
attach
:
function
()
{
function
statesrequired
(
el
)
{
var
required
=
$
(
el
).
closest
(
'
.form-item, .form-wrapper
'
).
find
(
'
.form-required
'
).
length
return
required
!=
0
;
var
required
=
$
(
el
).
closest
(
'
.form-item, .form-wrapper
'
).
find
(
'
.form-required
'
).
length
;
return
required
!=
=
0
;
}
$
(
document
).
bind
(
'
state:required
'
,
function
(
e
)
{
if
(
e
.
trigger
)
{
$
(
e
.
target
).
valid
();
}
});
$
(
document
).
bind
(
'
clientsideValidationInitialized
'
,
function
(
event
){
$
(
document
).
bind
(
'
clientsideValidationInitialized
'
,
function
(){
for
(
var
formid
in
Drupal
.
myClientsideValidation
.
forms
)
{
if
(
Drupal
.
myClientsideValidation
.
forms
.
hasOwnProperty
(
formid
))
{
for
(
var
element
in
Drupal
.
myClientsideValidation
.
forms
[
formid
].
rules
)
{
if
(
Drupal
.
myClientsideValidation
.
forms
[
formid
].
rules
.
hasOwnProperty
(
element
))
{
for
(
var
rulename
in
Drupal
.
myClientsideValidation
.
forms
[
formid
].
rules
[
element
])
{
if
(
Drupal
.
myClientsideValidation
.
forms
[
formid
].
rules
[
element
].
hasOwnProperty
(
rulename
)
&&
rulename
==
'
statesrequired
'
)
{
if
(
Drupal
.
myClientsideValidation
.
forms
[
formid
].
rules
[
element
].
hasOwnProperty
(
rulename
)
&&
rulename
==
=
'
statesrequired
'
)
{
var
selector
=
'
:input[name="
'
+
element
+
'
"]
'
;
$
(
selector
).
rules
(
"
remove
"
,
"
statesrequired
"
);
$
(
selector
).
rules
(
"
add
"
,
{
...
...
@@ -45,5 +48,5 @@
}
});
}
}
}
;
})(
jQuery
);
clientside_validation_testswarm/tests/clientside_validation_fapi.test.js
View file @
e8f09eef
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
/*global Drupal: true, jQuery: true, QUnit:true*/
(
function
(
$
,
Drupal
,
window
,
document
,
undefined
)
{
"
use strict
"
;
/**
* Form API Elements.
*/
var
formid
=
'
clientside-validation-testswarm-fapi
'
;
var
validator
=
{};
$
(
document
).
bind
(
'
clientsideValidationInitialized
'
,
function
(
event
){
$
(
document
).
bind
(
'
clientsideValidationInitialized
'
,
function
(){
validator
=
Drupal
.
myClientsideValidation
.
validators
[
formid
];
});
Drupal
.
tests
.
cvfapi
=
{
...
...
@@ -17,9 +20,8 @@
},
tests
:
{
requiredTextfield
:
function
(
$
,
Drupal
,
window
,
document
,
undefined
)
{
var
self
=
this
;
return
function
()
{
expect
(
3
);
QUnit
.
expect
(
3
);
// Sometimes browsers autofill names, make sure it's empty.
$
(
'
#edit-yourname
'
).
val
(
''
);
...
...
@@ -27,7 +29,7 @@
validator
.
form
();
// Check for the "Your name" error.
equal
(
$
(
'
label[for=edit-yourname].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Your name"
'
));
QUnit
.
equal
(
$
(
'
label[for=edit-yourname].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Your name"
'
));
// Change the maxlength attribute so we can fill in an illegal value in the browsers that would prevent this.
$
(
'
#edit-yourname
'
).
attr
(
'
maxlength
'
,
'
25
'
);
...
...
@@ -39,7 +41,7 @@
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=edit-yourname].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Your name"
'
));
QUnit
.
equal
(
$
(
'
label[for=edit-yourname].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Your name"
'
));
// Fill in the "Your name textfield" with a legal value.
$
(
'
#edit-yourname
'
).
val
(
"
yourname
"
);
...
...
@@ -48,18 +50,18 @@
validator
.
form
();
// Check for the "Your name" error.
equal
(
$
(
'
label[for=edit-yourname].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label not found for "Your name"
'
));
}
QUnit
.
equal
(
$
(
'
label[for=edit-yourname].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label not found for "Your name"
'
));
}
;
},
requiredCheckboxes
:
function
(
$
,
Drupal
,
window
,
document
,
undefined
)
{
return
function
()
{
expect
(
2
);
QUnit
.
expect
(
2
);
// Validate the form.
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=copy_group].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Checkboxes" (Select at least one)
'
));
QUnit
.
equal
(
$
(
'
label[for=copy_group].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Checkboxes" (Select at least one)
'
));
// Check one checkbox, random.
var
checkboxes
=
[
'
#edit-copy-status
'
,
'
#edit-copy-moderate
'
,
'
#edit-copy-promote
'
,
'
#edit-copy-sticky
'
,
'
#edit-copy-revision
'
];
...
...
@@ -70,12 +72,12 @@
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=
'
+
$checkbox
.
attr
(
'
id
'
)
+
'
].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label found for "Checkboxes" (Select at least one)
'
));
}
QUnit
.
equal
(
$
(
'
label[for=
'
+
$checkbox
.
attr
(
'
id
'
)
+
'
].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label found for "Checkboxes" (Select at least one)
'
));
}
;
},
requiredPassword
:
function
(
$
,
Drupal
,
window
,
document
,
undefined
)
{
return
function
()
{
expect
(
3
);
QUnit
.
expect
(
3
);
// Sometimes browsers autofill passwords, make sure it's empty.
$
(
'
#edit-pass
'
).
val
(
''
);
...
...
@@ -84,7 +86,7 @@
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=edit-pass].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Password"
'
));
QUnit
.
equal
(
$
(
'
label[for=edit-pass].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Password"
'
));
// Change the maxlength attribute so we can fill in an illegal value in the browsers would prevent this.
$
(
'
#edit-pass
'
).
attr
(
'
maxlength
'
,
'
25
'
);
...
...
@@ -96,7 +98,7 @@
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=edit-pass].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Password"
'
));
QUnit
.
equal
(
$
(
'
label[for=edit-pass].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Password"
'
));
// Fill in an legal value.
$
(
'
#edit-pass
'
).
val
(
"
notsolongpassword
"
);
...
...
@@ -105,12 +107,12 @@
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=edit-pass].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label not found for "Password"
'
));
}
QUnit
.
equal
(
$
(
'
label[for=edit-pass].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label not found for "Password"
'
));
}
;
},
requiredRadios
:
function
(
$
,
Drupal
,
window
,
document
,
undefined
)
{
return
function
()
{
expect
(
2
);
QUnit
.
expect
(
2
);
// Deselect default value.
$
(
'
#edit-posting-settings-0
'
).
removeAttr
(
'
checked
'
);
...
...
@@ -119,7 +121,7 @@
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=posting_settings].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Preview comment"
'
));
QUnit
.
equal
(
$
(
'
label[for=posting_settings].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Preview comment"
'
));
// Select an option
$
(
'
#edit-posting-settings-0
'
).
attr
(
'
checked
'
,
'
checked
'
);
...
...
@@ -128,18 +130,18 @@
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=posting_settings].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label not found for "Preview comment"
'
));
}
QUnit
.
equal
(
$
(
'
label[for=posting_settings].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label not found for "Preview comment"
'
));
}
;
},
requiredSingleSelect
:
function
(
$
,
Drupal
,
window
,
document
,
undefined
)
{
return
function
()
{
expect
(
2
);
QUnit
.
expect
(
2
);
// Validate the empty form.
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=edit-feed].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Display of XML feed items"
'
));
QUnit
.
equal
(
$
(
'
label[for=edit-feed].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Display of XML feed items"
'
));
// Select an option.
$
(
'
#edit-feed
'
).
val
(
'
title
'
);
...
...
@@ -148,12 +150,12 @@
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=edit-feed].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label not found for "Display of XML feed items"
'
));
}
QUnit
.
equal
(
$
(
'
label[for=edit-feed].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label not found for "Display of XML feed items"
'
));
}
;
},
requiredMultipleSelect
:
function
(
$
,
Drupal
,
window
,
document
,
undefined
)
{
return
function
()
{
expect
(
2
);
QUnit
.
expect
(
2
);
// Deselect the default value.
$
(
'
#edit-feed2 option:first
'
).
removeAttr
(
'
selected
'
);
...
...
@@ -162,7 +164,7 @@
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=edit-feed2].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Multiple items"
'
));
QUnit
.
equal
(
$
(
'
label[for=edit-feed2].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Multiple items"
'
));
// Select multiple options.
$
(
'
#edit-feed2 option:even
'
).
attr
(
'
selected
'
,
'
selected
'
);
...
...
@@ -171,18 +173,18 @@
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=edit-feed2].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label not found for "Multiple items"
'
));
}
QUnit
.
equal
(
$
(
'
label[for=edit-feed2].error:visible
'
).
length
,
0
,
Drupal
.
t
(
'
Error label not found for "Multiple items"
'
));
}
;
},
requiredTextArea
:
function
(
$
,
Drupal
,
window
,
document
,
undefined
)
{
return
function
()
{
expect
(
3
);
QUnit
.
expect
(
3
);
// Validate the empty form.
validator
.
form
();
// Check for the error.
equal
(
$
(
'
label[for=edit-body].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Body"
'
));
QUnit
.
equal
(
$
(
'
label[for=edit-body].error:visible
'
).
length
,
1
,
Drupal
.
t
(
'
Error label found for "Body"
'
));
// Change the maxlength attribute so we can fill in an illegal value in the browsers would prevent this.
$
(
'
#edit-body
'
).
attr
(
'
maxlength
'
,
'
60
'
);
...
...
@@ -194,7 +196,7 @@
validator
.
form
();
// Check for the error.