Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7396721
ve.dm.TableRowNode.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.dm.TableRowNode.js
View Options
/*!
* VisualEditor DataModel TableRowNode class.
*
* @copyright See AUTHORS.txt
*/
/**
* DataModel table row node.
*
* @class
* @extends ve.dm.BranchNode
*
* @constructor
* @param {Object} [element] Reference to element in linear model
* @param {ve.dm.Node[]} [children]
*/
ve
.
dm
.
TableRowNode
=
function
VeDmTableRowNode
()
{
// Parent constructor
ve
.
dm
.
TableRowNode
.
super
.
apply
(
this
,
arguments
);
// Events
this
.
connect
(
this
,
{
splice
:
'onSplice'
}
);
};
/* Inheritance */
OO
.
inheritClass
(
ve
.
dm
.
TableRowNode
,
ve
.
dm
.
BranchNode
);
/* Static Properties */
ve
.
dm
.
TableRowNode
.
static
.
name
=
'tableRow'
;
ve
.
dm
.
TableRowNode
.
static
.
childNodeTypes
=
[
'tableCell'
,
'alienTableCell'
];
ve
.
dm
.
TableRowNode
.
static
.
parentNodeTypes
=
[
'tableSection'
];
ve
.
dm
.
TableRowNode
.
static
.
matchTagNames
=
[
'tr'
];
/* Static Methods */
/**
* Creates data that can be inserted into the model to create a new table row.
*
* @param {Object} [options] Creation options
* @param {string|string[]} [options.style='data'] Cell style; 'data' or 'header', or array of styles
* @param {number} [options.cellCount=1] Number of cells to create
* @return {Array} Model data for a new table row
*/
ve
.
dm
.
TableRowNode
.
static
.
createData
=
function
(
options
)
{
options
=
options
||
{};
const
cellCount
=
options
.
cellCount
||
1
;
const
data
=
[];
data
.
push
(
{
type
:
'tableRow'
}
);
for
(
let
i
=
0
;
i
<
cellCount
;
i
++
)
{
ve
.
batchPush
(
data
,
ve
.
dm
.
TableCellNode
.
static
.
createData
(
{
style
:
Array
.
isArray
(
options
.
style
)
?
options
.
style
[
i
]
:
options
.
style
}
)
);
}
data
.
push
(
{
type
:
'/tableRow'
}
);
return
data
;
};
/* Methods */
/**
* Handle splicing of child nodes
*/
ve
.
dm
.
TableRowNode
.
prototype
.
onSplice
=
function
()
{
if
(
this
.
getRoot
()
)
{
this
.
getParent
().
getParent
().
getMatrix
().
invalidate
();
}
const
nodes
=
Array
.
prototype
.
slice
.
call
(
arguments
,
2
);
for
(
let
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
nodes
[
i
].
connect
(
this
,
{
attributeChange
:
[
'onCellAttributeChange'
,
nodes
[
i
]
]
}
);
}
};
/**
* Handle cell attribute changes
*
* @param {ve.dm.TableCellableNode} cell
* @fires ve.dm.TableNode#cellAttributeChange
*/
ve
.
dm
.
TableRowNode
.
prototype
.
onCellAttributeChange
=
function
(
cell
)
{
this
.
emit
(
'cellAttributeChange'
,
cell
);
};
/* Registration */
ve
.
dm
.
modelRegistry
.
register
(
ve
.
dm
.
TableRowNode
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 21, 14:19 (13 h, 28 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
87/54/b84517ceeea20d25da159dee1f37
Default Alt Text
ve.dm.TableRowNode.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment