Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7396473
ve.ce.ContentEditableNode.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ve.ce.ContentEditableNode.js
View Options
/*!
* VisualEditor ContentEditable ContentEditableNode class.
*
* @copyright See AUTHORS.txt
*/
/**
* A ContentEditableNode maintains its own contentEditable property
*
* @class
* @abstract
*
* @constructor
*/
ve
.
ce
.
ContentEditableNode
=
function
VeCeContentEditableNode
()
{
this
.
ceSurface
=
null
;
this
.
setContentEditable
(
true
);
this
.
setReadOnly
(
false
);
this
.
connect
(
this
,
{
setup
:
'onContentEditableSetup'
,
teardown
:
'onContentEditableTeardown'
}
);
};
/* Inheritance */
OO
.
initClass
(
ve
.
ce
.
ContentEditableNode
);
// Assumes ve.ce.Node as a base class
/* Methods */
/**
* Handle setup events on the node
*/
ve
.
ce
.
ContentEditableNode
.
prototype
.
onContentEditableSetup
=
function
()
{
// Exit if already setup or not attached
if
(
this
.
ceSurface
||
!
this
.
root
)
{
return
;
}
this
.
ceSurface
=
this
.
root
.
getSurface
().
getSurface
();
this
.
ceSurface
.
connect
(
this
,
{
readOnly
:
'onSurfaceReadOnly'
}
);
// Set initial state
this
.
setReadOnly
(
this
.
ceSurface
.
isReadOnly
()
);
};
/**
* Handle teardown events on the node
*/
ve
.
ce
.
ContentEditableNode
.
prototype
.
onContentEditableTeardown
=
function
()
{
// Exit if not setup
if
(
!
this
.
ceSurface
)
{
return
;
}
this
.
ceSurface
.
disconnect
(
this
,
{
readOnly
:
'onSurfaceReadOnly'
}
);
this
.
ceSurface
=
null
;
};
/**
* Handle readOnly events from the surface
*
* @param {boolean} readOnly Surface is read-only
*/
ve
.
ce
.
ContentEditableNode
.
prototype
.
onSurfaceReadOnly
=
function
(
readOnly
)
{
this
.
setReadOnly
(
readOnly
);
};
/**
* Called when the surface read-only state changes
*
* @param {boolean} readOnly Surface is read-only
*/
ve
.
ce
.
ContentEditableNode
.
prototype
.
setReadOnly
=
function
(
readOnly
)
{
this
.
$element
.
prop
(
'spellcheck'
,
!
readOnly
);
};
/**
* Enable or disable editing on this node
*
* @param {boolean} enabled Whether to enable editing
*/
ve
.
ce
.
ContentEditableNode
.
prototype
.
setContentEditable
=
function
(
enabled
)
{
this
.
$element
.
prop
(
'contentEditable'
,
(
!!
enabled
).
toString
()
);
};
/**
* Check if the node is currently editable
*
* @return {boolean} Node is currently editable
*/
ve
.
ce
.
ContentEditableNode
.
prototype
.
isContentEditable
=
function
()
{
return
this
.
$element
.
prop
(
'contentEditable'
)
===
'true'
;
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 21, 14:12 (6 h, 4 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f0/90/b3c0f3e8b6dde9584ef6160c88bb
Default Alt Text
ve.ce.ContentEditableNode.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment