Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4133563
ve.TriggerListener.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.TriggerListener.js
View Options
/*!
* VisualEditor UserInterface TriggerListener class.
*
* @copyright See AUTHORS.txt
*/
/**
* Trigger listener
*
* @class
*
* @constructor
* @param {string[]} commands Commands to listen to triggers for
* @param {ve.ui.CommandRegistry} commandRegistry Command registry to get commands from
*/
ve
.
TriggerListener
=
function
VeTriggerListener
(
commands
,
commandRegistry
)
{
// Properties
this
.
commands
=
commands
;
this
.
commandsByTrigger
=
{};
this
.
triggers
=
{};
for
(
let
i
=
this
.
commands
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
command
=
this
.
commands
[
i
];
const
triggers
=
ve
.
ui
.
triggerRegistry
.
lookup
(
command
);
if
(
triggers
)
{
for
(
let
j
=
triggers
.
length
-
1
;
j
>=
0
;
j
--
)
{
this
.
commandsByTrigger
[
triggers
[
j
].
toString
()
]
=
commandRegistry
.
lookup
(
command
);
}
this
.
triggers
[
command
]
=
triggers
;
}
}
};
/* Inheritance */
OO
.
initClass
(
ve
.
TriggerListener
);
/* Methods */
/**
* Get list of commands.
*
* @return {string[]} Commands
*/
ve
.
TriggerListener
.
prototype
.
getCommands
=
function
()
{
return
this
.
commands
;
};
/**
* Get command associated with trigger string.
*
* @param {string} trigger
* @return {ve.ui.Command|undefined}
*/
ve
.
TriggerListener
.
prototype
.
getCommandByTrigger
=
function
(
trigger
)
{
return
this
.
commandsByTrigger
[
trigger
];
};
/**
* Get triggers for a specified name.
*
* @param {string} name Trigger name
* @return {ve.ui.Trigger[]|undefined}
*/
ve
.
TriggerListener
.
prototype
.
getTriggers
=
function
(
name
)
{
return
this
.
triggers
[
name
];
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 12:13 (3 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
95/bd/0658b7ca01e19c32320979f999ff
Default Alt Text
ve.TriggerListener.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment