Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4057369
ve.ui.MWExpandableErrorElement.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
ve.ui.MWExpandableErrorElement.js
View Options
/*!
* VisualEditor UserInterface MWExpandableErrorElement class.
*
* @copyright See AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* MediaWiki expandable error element.
*
* @class
* @extends OO.ui.Element
* @mixes OO.EventEmitter
*
* @constructor
* @param {Object} [config] Configuration options
*/
ve
.
ui
.
MWExpandableErrorElement
=
function
VeUiMWExpandableErrorElement
(
config
)
{
// Parent constructor
ve
.
ui
.
MWExpandableErrorElement
.
super
.
call
(
this
,
config
);
// Mixin constructors
OO
.
EventEmitter
.
call
(
this
);
// Interaction
this
.
expanded
=
false
;
this
.
expandable
=
false
;
this
.
toggle
(
false
);
this
.
label
=
new
OO
.
ui
.
LabelWidget
(
{
classes
:
[
've-ui-mwExpandableErrorElement-label'
]
}
);
this
.
button
=
new
OO
.
ui
.
ButtonWidget
(
{
framed
:
false
,
classes
:
[
've-ui-mwExpandableErrorElement-button'
],
icon
:
'expand'
}
).
toggle
(
false
);
this
.
$element
.
append
(
this
.
button
.
$element
,
this
.
label
.
$element
).
addClass
(
've-ui-mwExpandableErrorElement'
);
};
/* Inheritance */
OO
.
inheritClass
(
ve
.
ui
.
MWExpandableErrorElement
,
OO
.
ui
.
Element
);
OO
.
mixinClass
(
ve
.
ui
.
MWExpandableErrorElement
,
OO
.
EventEmitter
);
/* Events */
/**
* @event ve.ui.MWExpandableErrorElement#update
*/
/* Methods */
/**
* Set the expandability of the error.
*
* @param {boolean} [expandable] Value to set the expandability to,
* determine based on label size if omitted
*/
ve
.
ui
.
MWExpandableErrorElement
.
prototype
.
setExpandable
=
function
(
expandable
)
{
if
(
expandable
!==
undefined
)
{
this
.
expandable
=
expandable
;
}
else
{
// Check if error fits when in not-expandable mode
this
.
label
.
$element
.
addClass
(
've-ui-mwExpandableErrorElement-label-not-expandable'
);
this
.
expandable
=
this
.
label
.
$element
.
prop
(
'scrollWidth'
)
>
this
.
label
.
$element
.
innerWidth
();
}
this
.
label
.
$element
.
toggleClass
(
've-ui-mwExpandableErrorElement-label-not-expandable'
,
!
this
.
expandable
);
};
/**
* Show the error and set the label to contain the error text.
*
* @param {jQuery} [$element] Element containing the error
*/
ve
.
ui
.
MWExpandableErrorElement
.
prototype
.
show
=
function
(
$element
)
{
this
.
label
.
setLabel
(
$element
||
null
);
this
.
toggle
(
true
);
this
.
setExpandable
();
if
(
this
.
expandable
)
{
this
.
label
.
$element
.
addClass
(
've-ui-mwExpandableErrorElement-label-collapsed'
);
this
.
button
.
toggle
(
true
);
this
.
button
.
connect
(
this
,
{
click
:
'toggleLabel'
}
);
}
this
.
emit
(
'update'
);
};
/**
* Hide and collapse the error element, remove the label, and set expandable
* to false.
*/
ve
.
ui
.
MWExpandableErrorElement
.
prototype
.
clear
=
function
()
{
this
.
label
.
setLabel
(
null
);
this
.
toggle
(
false
);
this
.
button
.
toggle
(
false
);
this
.
button
.
disconnect
(
this
);
this
.
toggleLabel
(
false
);
this
.
emit
(
'update'
);
};
/**
* Toggles the label between collapsed and expanded.
*
* @param {boolean} [expand] Expand if true, collapse if false, toggle if
* omitted
*/
ve
.
ui
.
MWExpandableErrorElement
.
prototype
.
toggleLabel
=
function
(
expand
)
{
// Set this.expanded to the new state
this
.
expanded
=
expand
===
undefined
?
!
this
.
expanded
:
expand
;
// Update DOM based on the new state of this.expanded
this
.
button
.
setIcon
(
this
.
expanded
?
'collapse'
:
'expand'
);
this
.
label
.
$element
.
toggleClass
(
've-ui-mwExpandableErrorElement-label-expanded'
,
this
.
expanded
)
.
toggleClass
(
've-ui-mwExpandableErrorElement-label-collapsed'
,
!
this
.
expanded
);
this
.
emit
(
'update'
);
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Aug 16 2026, 04:02 (12 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0f/fd/589142e0ac635c236673315dbb52
Default Alt Text
ve.ui.MWExpandableErrorElement.js (3 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment