Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7425919
ve.ce.CheckListItemNode.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ve.ce.CheckListItemNode.js
View Options
/*!
* VisualEditor ContentEditable CheckListItemNode class.
*
* @copyright See AUTHORS.txt
*/
/**
* ContentEditable list item node.
*
* @class
* @extends ve.ce.BranchNode
* @constructor
* @param {ve.dm.CheckListItemNode} model Model to observe
* @param {Object} [config] Configuration options
*/
ve
.
ce
.
CheckListItemNode
=
function
VeCeCheckListItemNode
()
{
// Parent constructor
ve
.
ce
.
CheckListItemNode
.
super
.
apply
(
this
,
arguments
);
this
.
$element
.
addClass
(
've-ce-checkListItemNode'
);
// Events
this
.
model
.
connect
(
this
,
{
attributeChange
:
'onAttributeChange'
}
);
this
.
$element
.
on
(
'click'
,
this
.
onClick
.
bind
(
this
)
);
this
.
updateChecked
();
};
/* Inheritance */
OO
.
inheritClass
(
ve
.
ce
.
CheckListItemNode
,
ve
.
ce
.
BranchNode
);
/* Static Properties */
ve
.
ce
.
CheckListItemNode
.
static
.
name
=
'checkListItem'
;
ve
.
ce
.
CheckListItemNode
.
static
.
tagName
=
'li'
;
ve
.
ce
.
CheckListItemNode
.
static
.
splitOnEnter
=
true
;
/* Methods */
/**
* Handle click events on the checkbox
*
* @param {jQuery.Event} e Click event
*/
ve
.
ce
.
CheckListItemNode
.
prototype
.
onClick
=
function
(
e
)
{
if
(
e
.
target
===
this
.
$element
[
0
]
)
{
// TODO: This should probably live in ui.Actions.
const
fragment
=
this
.
getRoot
().
getSurface
().
getModel
().
getLinearFragment
(
this
.
getOuterRange
(),
true
);
fragment
.
changeAttributes
(
{
checked
:
!
this
.
getModel
().
getAttribute
(
'checked'
)
}
);
}
};
/**
* @param {string} key Attribute key
* @param {string} from Old value
* @param {string} to New value
*/
ve
.
ce
.
CheckListItemNode
.
prototype
.
onAttributeChange
=
function
(
key
)
{
if
(
key
===
'checked'
)
{
this
.
updateChecked
();
}
};
ve
.
ce
.
CheckListItemNode
.
prototype
.
updateChecked
=
function
()
{
this
.
$element
.
toggleClass
(
've-ce-checkListItemNode-checked'
,
!!
this
.
getModel
().
getAttribute
(
'checked'
)
);
};
/* Registration */
ve
.
ce
.
nodeFactory
.
register
(
ve
.
ce
.
CheckListItemNode
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 22, 08:09 (19 h, 10 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
42/cf/241468d3a7dddda1fbe7f1b638ce
Default Alt Text
ve.ce.CheckListItemNode.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment