/**
* Configuration of Dialog module for wikiEditor
*
* @private
*/
var toolbarModule = require( './jquery.wikiEditor.toolbar.js' ),
InsertLinkTitleInputField = require( './insertlink/TitleInputField.js' ),
LinkTextField = require( './insertlink/LinkTextField.js' ),
LinkTypeField = require( './insertlink/LinkTypeField.js' ),
insertLinkTitleInputField = new InsertLinkTitleInputField(),
insertLinkLinkTextField = new LinkTextField(),
insertLinkLinkTypeField = new LinkTypeField(),
configData = require( './data.json' );
function triggerButtonClick( element ) {
// The dialog action should always be a DOMElement.
var dialogAction = $( element ).data( 'dialogaction' );
var $button = dialogAction ? $( dialogAction ) : $( element ).find( 'button' ).first();
// Since we're reading from data attribute, make sure we got an element before clicking.
// Note when closing a dialog this can be false leading to TypeError: $button.trigger is not a function
// (T261529)
if ( $button ) {
$button.trigger( 'click' );
}
}
module.exports = {
/**
* @param {jQuery} $textarea
* @memberof module:ext.wikiEditor
*/
replaceIcons: function ( $textarea ) {
$textarea
.wikiEditor( 'addToToolbar', {
section: 'main',
group: 'insert',
tools: {
link: {
label: mw.msg( 'wikieditor-toolbar-tool-link' ),
type: 'button',
oouiIcon: 'link',
action: {
type: 'dialog',
module: 'insert-link'
}
},
file: {
label: mw.msg( 'wikieditor-toolbar-tool-file' ),
type: 'button',
oouiIcon: 'image',
action: {
type: 'dialog',
module: 'insert-file'
}
}
}
} )
.wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
table: {
label: mw.msg( 'wikieditor-toolbar-tool-table' ),
type: 'button',
oouiIcon: 'table',
action: {
type: 'dialog',
module: 'insert-table'
}
}
}
} )
.wikiEditor( 'addToToolbar', {
section: 'advanced',
groups: {
search: {
tools: {
replace: {
label: mw.msg( 'wikieditor-toolbar-tool-replace' ),
type: 'button',
oouiIcon: 'articleSearch',
action: {
type: 'dialog',
module: 'search-and-replace'
}
}
}
}
}
} );
},
/**
* @return {Object}
* @memberof module:ext.wikiEditor
*/
getDefaultConfig: function () {
return { dialogs: {
'insert-link': {
title: mw.message( 'wikieditor-toolbar-tool-link-title' ).parse(),
id: 'wikieditor-toolbar-link-dialog',
html: $( '