Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F35337135
behavior-toggle-class.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
843 B
Subscribers
None
behavior-toggle-class.js
View Options
/**
* @provides javelin-behavior-toggle-class
* @requires javelin-behavior
* javelin-stratcom
* javelin-dom
*/
/**
* Toggle CSS classes when an element is clicked. This behavior is activated
* by adding the sigil `jx-toggle-class` to an element, and a key `map` to its
* data. The `map` should be a map from element IDs to the classes that should
* be toggled on them.
*
* Optionally, you may provide a `state` key to set the default state of the
* element.
*
* @group ui
*/
JX
.
behavior
(
'toggle-class'
,
function
()
{
JX
.
Stratcom
.
listen
(
[
'touchstart'
,
'mousedown'
],
'jx-toggle-class'
,
function
(
e
)
{
e
.
kill
();
var
t
=
e
.
getNodeData
(
'jx-toggle-class'
);
t
.
state
=
!
t
.
state
;
for
(
var
k
in
t
.
map
)
{
JX
.
DOM
.
alterClass
(
JX
.
$
(
k
),
t
.
map
[
k
],
t
.
state
);
}
});
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Feb 6, 8:14 AM (1 d, 8 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0b/27/48e4a9afb54906f7cdad5bc5a470
Attached To
rPHAB Phabricator
Event Timeline
Log In to Comment