Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
315
Merge Requests
315
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
d0ec90ca
Commit
d0ec90ca
authored
Aug 26, 2012
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1684810
by nod_: JSHint states.js.
parent
54496aeb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
14 deletions
+22
-14
core/misc/states.js
core/misc/states.js
+22
-14
No files found.
core/misc/states.js
View file @
d0ec90ca
...
...
@@ -20,12 +20,16 @@ Drupal.behaviors.states = {
attach
:
function
(
context
,
settings
)
{
var
$context
=
$
(
context
);
for
(
var
selector
in
settings
.
states
)
{
for
(
var
state
in
settings
.
states
[
selector
])
{
new
states
.
Dependent
({
element
:
$context
.
find
(
selector
),
state
:
states
.
State
.
sanitize
(
state
),
constraints
:
settings
.
states
[
selector
][
state
]
});
if
(
settings
.
states
.
hasOwnProperty
(
selector
))
{
for
(
var
state
in
settings
.
states
[
selector
])
{
if
(
settings
.
states
[
selector
].
hasOwnProperty
(
state
))
{
new
states
.
Dependent
({
element
:
$context
.
find
(
selector
),
state
:
states
.
State
.
sanitize
(
state
),
constraints
:
settings
.
states
[
selector
][
state
]
});
}
}
}
}
...
...
@@ -52,7 +56,9 @@ states.Dependent = function (args) {
this
.
dependees
=
this
.
getDependees
();
for
(
var
selector
in
this
.
dependees
)
{
this
.
initializeDependee
(
selector
,
this
.
dependees
[
selector
]);
if
(
this
.
dependees
.
hasOwnProperty
(
selector
))
{
this
.
initializeDependee
(
selector
,
this
.
dependees
[
selector
]);
}
}
};
...
...
@@ -89,7 +95,11 @@ states.Dependent.prototype = {
* dependee's compliance status.
*/
initializeDependee
:
function
(
selector
,
dependeeStates
)
{
var
state
;
var
state
,
self
=
this
;
function
stateEventHandler
(
e
)
{
self
.
update
(
e
.
data
.
selector
,
e
.
data
.
state
,
e
.
value
);
}
// Cache for the states of this dependee.
this
.
values
[
selector
]
=
{};
...
...
@@ -108,9 +118,7 @@ states.Dependent.prototype = {
this
.
values
[
selector
][
state
.
name
]
=
null
;
// Monitor state changes of the specified state for this dependee.
$
(
selector
).
bind
(
'
state:
'
+
state
,
{
selector
:
selector
,
state
:
state
},
$
.
proxy
(
function
(
e
)
{
this
.
update
(
e
.
data
.
selector
,
e
.
data
.
state
,
e
.
value
);
},
this
));
$
(
selector
).
bind
(
'
state:
'
+
state
,
{
selector
:
selector
,
state
:
state
},
stateEventHandler
);
// Make sure the event we just bound ourselves to is actually fired.
new
states
.
Trigger
({
selector
:
selector
,
state
:
state
});
...
...
@@ -546,9 +554,9 @@ function ternary (a, b) {
return
typeof
a
===
'
undefined
'
?
b
:
(
typeof
b
===
'
undefined
'
?
a
:
a
&&
b
);
}
// Inverts a (if it's not undefined) when invert is true.
function
invert
(
a
,
invert
)
{
return
(
invert
&&
typeof
a
!==
'
undefined
'
)
?
!
a
:
a
;
// Inverts a (if it's not undefined) when invert
State
is true.
function
invert
(
a
,
invert
State
)
{
return
(
invert
State
&&
typeof
a
!==
'
undefined
'
)
?
!
a
:
a
;
}
// Compares two values while ignoring undefined values.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment