mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-09-23 10:26:26 +00:00
Allow tool.element to be a function
This adds support for the new 'element' tool type to be a function which returns the HTML for the toolbar widget. It means that it's possible for the element to access the WikiEditor context object. Bug: T286759 Change-Id: I6af12075b96d480639f2fc0d97333a6142480c02
This commit is contained in:
parent
fc768ba3c4
commit
fff7cd6ba1
|
@ -429,11 +429,13 @@
|
|||
$select.append( $( '<div>' ).addClass( 'menu' ).append( $options ) );
|
||||
return $select;
|
||||
case 'element':
|
||||
// A raw 'element' type can be {htmlString|Element|Text|Array|jQuery|OO.ui.HTMLSnippet}.
|
||||
// A raw 'element' type can be {htmlString|Element|Text|Array|jQuery|OO.ui.HTMLSnippet|function}.
|
||||
var $element = $( '<div>' )
|
||||
.attr( { rel: id, class: 'tool tool-element' } );
|
||||
if ( tool.element instanceof OO.ui.HtmlSnippet ) {
|
||||
$element.append( tool.element.toString() );
|
||||
} else if ( typeof tool.element === 'function' ) {
|
||||
$element.append( tool.element( context ) );
|
||||
} else {
|
||||
$element.append( tool.element );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue