2013-07-17 19:09:30 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MediaWiki MWReferenceDialog class.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-07-17 19:09:30 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dialog for editing MediaWiki references.
|
|
|
|
*
|
|
|
|
* @class
|
2014-04-24 00:22:45 +00:00
|
|
|
* @extends ve.ui.NodeDialog
|
2013-07-17 19:09:30 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-07-17 19:09:30 +00:00
|
|
|
*/
|
2014-08-21 00:50:54 +00:00
|
|
|
ve.ui.MWReferenceDialog = function VeUiMWReferenceDialog( config ) {
|
2013-07-17 19:09:30 +00:00
|
|
|
// Parent constructor
|
2014-08-21 00:50:54 +00:00
|
|
|
ve.ui.MWReferenceDialog.super.call( this, config );
|
2013-07-17 19:09:30 +00:00
|
|
|
|
|
|
|
// Properties
|
2014-04-01 23:15:47 +00:00
|
|
|
this.referenceModel = null;
|
2013-07-17 19:09:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2014-04-24 00:22:45 +00:00
|
|
|
OO.inheritClass( ve.ui.MWReferenceDialog, ve.ui.NodeDialog );
|
2013-07-17 19:09:30 +00:00
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
2013-08-27 23:28:29 +00:00
|
|
|
ve.ui.MWReferenceDialog.static.name = 'reference';
|
|
|
|
|
2014-02-12 21:45:37 +00:00
|
|
|
ve.ui.MWReferenceDialog.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-dialog-reference-title' );
|
2013-07-17 19:09:30 +00:00
|
|
|
|
|
|
|
ve.ui.MWReferenceDialog.static.icon = 'reference';
|
|
|
|
|
2014-07-14 21:32:49 +00:00
|
|
|
ve.ui.MWReferenceDialog.static.actions = [
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
action: 'apply',
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-dialog-action-apply' ),
|
|
|
|
flags: 'primary',
|
|
|
|
modes: 'edit'
|
2014-07-14 21:32:49 +00:00
|
|
|
},
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
action: 'insert',
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-dialog-action-insert' ),
|
|
|
|
flags: [ 'primary', 'constructive' ],
|
|
|
|
modes: 'insert'
|
2014-07-14 21:32:49 +00:00
|
|
|
},
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
label: OO.ui.deferMsg( 'visualeditor-dialog-action-cancel' ),
|
|
|
|
flags: 'safe',
|
|
|
|
modes: [ 'insert', 'edit', 'insert-select' ]
|
2014-07-14 21:32:49 +00:00
|
|
|
},
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
action: 'select',
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-dialog-reference-useexisting-label' ),
|
|
|
|
modes: [ 'insert', 'edit' ]
|
2014-07-14 21:32:49 +00:00
|
|
|
},
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
action: 'back',
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-dialog-action-goback' ),
|
|
|
|
flags: 'safe',
|
|
|
|
modes: 'select'
|
2014-07-14 21:32:49 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2014-04-24 00:22:45 +00:00
|
|
|
ve.ui.MWReferenceDialog.static.modelClasses = [ ve.dm.MWReferenceNode ];
|
|
|
|
|
2013-08-09 18:29:09 +00:00
|
|
|
ve.ui.MWReferenceDialog.static.toolbarGroups = [
|
2013-12-12 19:04:15 +00:00
|
|
|
// History
|
2014-08-22 20:50:48 +00:00
|
|
|
{ include: [ 'undo', 'redo' ] },
|
2013-12-12 19:04:15 +00:00
|
|
|
// No formatting
|
|
|
|
/* {
|
2014-08-22 20:50:48 +00:00
|
|
|
type: 'menu',
|
|
|
|
indicator: 'down',
|
|
|
|
title: OO.ui.deferMsg( 'visualeditor-toolbar-format-tooltip' ),
|
|
|
|
include: [ { group: 'format' } ],
|
|
|
|
promote: [ 'paragraph' ],
|
|
|
|
demote: [ 'preformatted', 'heading1' ]
|
2013-12-12 19:04:15 +00:00
|
|
|
},*/
|
|
|
|
// Style
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
type: 'list',
|
|
|
|
icon: 'text-style',
|
|
|
|
indicator: 'down',
|
|
|
|
title: OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ),
|
|
|
|
include: [ { group: 'textStyle' }, 'language', 'clear' ],
|
2014-10-30 19:22:20 +00:00
|
|
|
forceExpand: [ 'bold', 'italic', 'clear' ],
|
2014-08-22 20:50:48 +00:00
|
|
|
promote: [ 'bold', 'italic' ],
|
|
|
|
demote: [ 'strikethrough', 'code', 'underline', 'language', 'clear' ]
|
2013-12-12 19:04:15 +00:00
|
|
|
},
|
|
|
|
// Link
|
2014-08-22 20:50:48 +00:00
|
|
|
{ include: [ 'link' ] },
|
2014-10-30 19:22:20 +00:00
|
|
|
// Cite-transclusion but not reference
|
Ultra-mega-hyper-citation editing on crack
Objectives:
* Allow users on-wiki to create tools and dialogs for citation templates
of their choosing
* Allow editing of citation templates directly, without having to go
through the reference dialog
* Provide citation template tools within reference editing that use the
same titles and icons as the citation tools do, but don't wrap the
inserted content in a ref tag
Changes:
* Reference list was cloning the DOM element it was inserting into its
view before the generated content node could finish rendering, so it
never ended up showing the finished rendering in the reference list
* Documenting hack about use of reference list node's destroy method,
and how we are depending on destroy not canceling generated content
rendering
* Introduced reference model
* Added saving/updating method to transclusion model
* Added getPartsList method to dm transclusion node, which caches the
result and invalidates the cache on update
* Added citation dialog, which extends transclusion dialog
* Added cite group to toolbars, cite-template in reference dialog toolbar
* Factored out getting the node to edit and saving changes procedures in
transclusion dialog so they could be extended in citation dialog
* Updated uses of autoAdd as per changes in oojs-ui (Ic353f91)
* Renamed MWDialogTool file since there was only one tool in it
* Expanded TransclusionDialogTool file out since there is now more logic
to it
* Switched to using ve.dm.MWReferenceModel instead of plain objects in
reference search widget
Configuration:
If you add to MediaWiki:Visualeditor-cite-tool-definition.json the
following code you will magically be presented with a delightful array
of citation options:
[
{ "name": "web", "icon": "ref-cite-web", "template": "Cite web" },
{ "name": "book", "icon": "ref-cite-book", "template": "Cite book" },
{ "name": "news", "icon": "ref-cite-news", "template": "Cite news" },
{ "name": "journal", "icon": "ref-cite-journal", "template": "Cite journal" }
]
...or...
[
{
"name": "any-name",
"icon": "any-ooui-icon",
"template": "Any template",
"title": "Any title text"
}
]
The title text is derived either from the title property or from the name
property by pre-pending the string 'visualeditor-cite-tool-name-' to
generate a message key. Titles for 'web', 'book', 'news' and 'journal' are
provided. The icon is a normal oo-ui-icon name, and more icons can be
added, as usual, by adding a class called .oo-ui-icon-{icon name} to
MediaWiki:Common.css. 'ref-cite-web', 'ref-cite-book', 'ref-cite-news'
and 'ref-cite-journal' are provided. The template name is simply the name
of the template without its namespace prefix.
Depends on Ic353f91 in oojs-ui
Bug: 50110
Bug: 50768
Change-Id: Id401d973b8d5fe2faec481cc777c17a24fd19dd4
2014-03-21 18:56:46 +00:00
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
type: 'list',
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-toolbar-cite-label' ),
|
|
|
|
indicator: 'down',
|
|
|
|
include: [ { group: 'cite-transclusion' }/*, 'reference', 'reference/existing'*/ ]
|
|
|
|
/*demote: [ 'reference', 'reference/existing' ]*/
|
Ultra-mega-hyper-citation editing on crack
Objectives:
* Allow users on-wiki to create tools and dialogs for citation templates
of their choosing
* Allow editing of citation templates directly, without having to go
through the reference dialog
* Provide citation template tools within reference editing that use the
same titles and icons as the citation tools do, but don't wrap the
inserted content in a ref tag
Changes:
* Reference list was cloning the DOM element it was inserting into its
view before the generated content node could finish rendering, so it
never ended up showing the finished rendering in the reference list
* Documenting hack about use of reference list node's destroy method,
and how we are depending on destroy not canceling generated content
rendering
* Introduced reference model
* Added saving/updating method to transclusion model
* Added getPartsList method to dm transclusion node, which caches the
result and invalidates the cache on update
* Added citation dialog, which extends transclusion dialog
* Added cite group to toolbars, cite-template in reference dialog toolbar
* Factored out getting the node to edit and saving changes procedures in
transclusion dialog so they could be extended in citation dialog
* Updated uses of autoAdd as per changes in oojs-ui (Ic353f91)
* Renamed MWDialogTool file since there was only one tool in it
* Expanded TransclusionDialogTool file out since there is now more logic
to it
* Switched to using ve.dm.MWReferenceModel instead of plain objects in
reference search widget
Configuration:
If you add to MediaWiki:Visualeditor-cite-tool-definition.json the
following code you will magically be presented with a delightful array
of citation options:
[
{ "name": "web", "icon": "ref-cite-web", "template": "Cite web" },
{ "name": "book", "icon": "ref-cite-book", "template": "Cite book" },
{ "name": "news", "icon": "ref-cite-news", "template": "Cite news" },
{ "name": "journal", "icon": "ref-cite-journal", "template": "Cite journal" }
]
...or...
[
{
"name": "any-name",
"icon": "any-ooui-icon",
"template": "Any template",
"title": "Any title text"
}
]
The title text is derived either from the title property or from the name
property by pre-pending the string 'visualeditor-cite-tool-name-' to
generate a message key. Titles for 'web', 'book', 'news' and 'journal' are
provided. The icon is a normal oo-ui-icon name, and more icons can be
added, as usual, by adding a class called .oo-ui-icon-{icon name} to
MediaWiki:Common.css. 'ref-cite-web', 'ref-cite-book', 'ref-cite-news'
and 'ref-cite-journal' are provided. The template name is simply the name
of the template without its namespace prefix.
Depends on Ic353f91 in oojs-ui
Bug: 50110
Bug: 50768
Change-Id: Id401d973b8d5fe2faec481cc777c17a24fd19dd4
2014-03-21 18:56:46 +00:00
|
|
|
},
|
2014-03-25 00:13:59 +00:00
|
|
|
// No structure
|
|
|
|
/* {
|
2014-08-22 20:50:48 +00:00
|
|
|
type: 'list',
|
|
|
|
icon: 'bullet-list',
|
|
|
|
indicator: 'down',
|
|
|
|
include: [ { group: 'structure' } ],
|
|
|
|
demote: [ 'outdent', 'indent' ]
|
2014-03-25 00:13:59 +00:00
|
|
|
},*/
|
2013-12-12 19:04:15 +00:00
|
|
|
// Insert
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
label: OO.ui.deferMsg( 'visualeditor-toolbar-insert' ),
|
|
|
|
indicator: 'down',
|
|
|
|
include: '*',
|
|
|
|
exclude: [
|
|
|
|
{ group: 'format' },
|
|
|
|
{ group: 'structure' },
|
2014-03-15 00:01:44 +00:00
|
|
|
'reference',
|
2014-08-19 18:32:46 +00:00
|
|
|
'referencesList',
|
2014-02-05 19:45:56 +00:00
|
|
|
'gallery'
|
|
|
|
],
|
2014-10-30 19:22:20 +00:00
|
|
|
forceExpand: [ 'media', 'transclusion', 'insertTable' ],
|
2014-08-22 20:50:48 +00:00
|
|
|
promote: [ 'media', 'transclusion' ],
|
|
|
|
demote: [ 'specialcharacter' ]
|
2014-10-30 19:22:20 +00:00
|
|
|
},
|
|
|
|
// Table
|
|
|
|
{
|
|
|
|
header: OO.ui.deferMsg( 'visualeditor-toolbar-table' ),
|
|
|
|
type: 'list',
|
|
|
|
icon: 'table-insert',
|
|
|
|
indicator: 'down',
|
|
|
|
include: [ { group: 'table' } ],
|
|
|
|
demote: [ 'deleteTable' ]
|
2013-12-12 19:04:15 +00:00
|
|
|
}
|
2013-07-17 19:09:30 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
ve.ui.MWReferenceDialog.static.surfaceCommands = [
|
2013-12-12 19:04:15 +00:00
|
|
|
'undo',
|
|
|
|
'redo',
|
|
|
|
'bold',
|
|
|
|
'italic',
|
|
|
|
'link',
|
|
|
|
'clear',
|
|
|
|
'underline',
|
|
|
|
'subscript',
|
|
|
|
'superscript',
|
|
|
|
'pasteSpecial'
|
2013-07-17 19:09:30 +00:00
|
|
|
];
|
|
|
|
|
2014-05-23 09:57:58 +00:00
|
|
|
/**
|
|
|
|
* Get the paste rules for the surface widget in the dialog
|
|
|
|
*
|
|
|
|
* @see ve.dm.ElementLinearData#sanitize
|
|
|
|
* @return {Object} Paste rules
|
|
|
|
*/
|
|
|
|
ve.ui.MWReferenceDialog.static.getPasteRules = function () {
|
|
|
|
return ve.extendObject(
|
|
|
|
ve.copy( ve.init.target.constructor.static.pasteRules ),
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
all: {
|
|
|
|
blacklist: OO.simpleArrayUnion(
|
2014-05-23 09:57:58 +00:00
|
|
|
ve.getProp( ve.init.target.constructor.static.pasteRules, 'all', 'blacklist' ) || [],
|
|
|
|
[
|
|
|
|
// Nested references are impossible
|
2014-08-19 18:32:46 +00:00
|
|
|
'mwReference', 'mwReferencesList',
|
2014-07-19 02:14:30 +00:00
|
|
|
// Lists and tables are actually possible in wikitext with a leading
|
2014-05-23 09:57:58 +00:00
|
|
|
// line break but we prevent creating these with the UI
|
|
|
|
'list', 'listItem', 'definitionList', 'definitionListItem',
|
|
|
|
'table', 'tableCaption', 'tableSection', 'tableRow', 'tableCell'
|
|
|
|
]
|
|
|
|
),
|
|
|
|
// Headings are not possible in wikitext without HTML
|
2014-08-22 20:50:48 +00:00
|
|
|
conversions: {
|
|
|
|
mwHeading: 'paragraph'
|
2014-05-23 09:57:58 +00:00
|
|
|
}
|
2014-02-03 15:08:52 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-23 09:57:58 +00:00
|
|
|
);
|
|
|
|
};
|
2014-02-03 15:08:52 +00:00
|
|
|
|
2013-07-17 19:09:30 +00:00
|
|
|
/* Methods */
|
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
/**
|
|
|
|
* Handle reference surface change events
|
|
|
|
*/
|
|
|
|
ve.ui.MWReferenceDialog.prototype.onDocumentTransact = function () {
|
2014-05-31 00:05:04 +00:00
|
|
|
var data = this.referenceModel.getDocument().data,
|
2013-11-05 00:29:50 +00:00
|
|
|
// TODO: Check for other types of empty, e.g. only whitespace?
|
2014-07-30 00:12:55 +00:00
|
|
|
hasContent = data.countNonInternalElements() > 2;
|
2013-11-05 00:29:50 +00:00
|
|
|
|
2014-07-14 21:32:49 +00:00
|
|
|
this.actions.setAbilities( {
|
2014-08-22 20:50:48 +00:00
|
|
|
apply: hasContent,
|
|
|
|
insert: hasContent,
|
|
|
|
select: !hasContent && !this.search.isIndexEmpty()
|
2014-07-14 21:32:49 +00:00
|
|
|
} );
|
2013-11-05 00:29:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle search select events.
|
|
|
|
*
|
Ultra-mega-hyper-citation editing on crack
Objectives:
* Allow users on-wiki to create tools and dialogs for citation templates
of their choosing
* Allow editing of citation templates directly, without having to go
through the reference dialog
* Provide citation template tools within reference editing that use the
same titles and icons as the citation tools do, but don't wrap the
inserted content in a ref tag
Changes:
* Reference list was cloning the DOM element it was inserting into its
view before the generated content node could finish rendering, so it
never ended up showing the finished rendering in the reference list
* Documenting hack about use of reference list node's destroy method,
and how we are depending on destroy not canceling generated content
rendering
* Introduced reference model
* Added saving/updating method to transclusion model
* Added getPartsList method to dm transclusion node, which caches the
result and invalidates the cache on update
* Added citation dialog, which extends transclusion dialog
* Added cite group to toolbars, cite-template in reference dialog toolbar
* Factored out getting the node to edit and saving changes procedures in
transclusion dialog so they could be extended in citation dialog
* Updated uses of autoAdd as per changes in oojs-ui (Ic353f91)
* Renamed MWDialogTool file since there was only one tool in it
* Expanded TransclusionDialogTool file out since there is now more logic
to it
* Switched to using ve.dm.MWReferenceModel instead of plain objects in
reference search widget
Configuration:
If you add to MediaWiki:Visualeditor-cite-tool-definition.json the
following code you will magically be presented with a delightful array
of citation options:
[
{ "name": "web", "icon": "ref-cite-web", "template": "Cite web" },
{ "name": "book", "icon": "ref-cite-book", "template": "Cite book" },
{ "name": "news", "icon": "ref-cite-news", "template": "Cite news" },
{ "name": "journal", "icon": "ref-cite-journal", "template": "Cite journal" }
]
...or...
[
{
"name": "any-name",
"icon": "any-ooui-icon",
"template": "Any template",
"title": "Any title text"
}
]
The title text is derived either from the title property or from the name
property by pre-pending the string 'visualeditor-cite-tool-name-' to
generate a message key. Titles for 'web', 'book', 'news' and 'journal' are
provided. The icon is a normal oo-ui-icon name, and more icons can be
added, as usual, by adding a class called .oo-ui-icon-{icon name} to
MediaWiki:Common.css. 'ref-cite-web', 'ref-cite-book', 'ref-cite-news'
and 'ref-cite-journal' are provided. The template name is simply the name
of the template without its namespace prefix.
Depends on Ic353f91 in oojs-ui
Bug: 50110
Bug: 50768
Change-Id: Id401d973b8d5fe2faec481cc777c17a24fd19dd4
2014-03-21 18:56:46 +00:00
|
|
|
* @param {ve.dm.MWReferenceModel|null} ref Reference model or null if no item is selected
|
2013-11-05 00:29:50 +00:00
|
|
|
*/
|
Ultra-mega-hyper-citation editing on crack
Objectives:
* Allow users on-wiki to create tools and dialogs for citation templates
of their choosing
* Allow editing of citation templates directly, without having to go
through the reference dialog
* Provide citation template tools within reference editing that use the
same titles and icons as the citation tools do, but don't wrap the
inserted content in a ref tag
Changes:
* Reference list was cloning the DOM element it was inserting into its
view before the generated content node could finish rendering, so it
never ended up showing the finished rendering in the reference list
* Documenting hack about use of reference list node's destroy method,
and how we are depending on destroy not canceling generated content
rendering
* Introduced reference model
* Added saving/updating method to transclusion model
* Added getPartsList method to dm transclusion node, which caches the
result and invalidates the cache on update
* Added citation dialog, which extends transclusion dialog
* Added cite group to toolbars, cite-template in reference dialog toolbar
* Factored out getting the node to edit and saving changes procedures in
transclusion dialog so they could be extended in citation dialog
* Updated uses of autoAdd as per changes in oojs-ui (Ic353f91)
* Renamed MWDialogTool file since there was only one tool in it
* Expanded TransclusionDialogTool file out since there is now more logic
to it
* Switched to using ve.dm.MWReferenceModel instead of plain objects in
reference search widget
Configuration:
If you add to MediaWiki:Visualeditor-cite-tool-definition.json the
following code you will magically be presented with a delightful array
of citation options:
[
{ "name": "web", "icon": "ref-cite-web", "template": "Cite web" },
{ "name": "book", "icon": "ref-cite-book", "template": "Cite book" },
{ "name": "news", "icon": "ref-cite-news", "template": "Cite news" },
{ "name": "journal", "icon": "ref-cite-journal", "template": "Cite journal" }
]
...or...
[
{
"name": "any-name",
"icon": "any-ooui-icon",
"template": "Any template",
"title": "Any title text"
}
]
The title text is derived either from the title property or from the name
property by pre-pending the string 'visualeditor-cite-tool-name-' to
generate a message key. Titles for 'web', 'book', 'news' and 'journal' are
provided. The icon is a normal oo-ui-icon name, and more icons can be
added, as usual, by adding a class called .oo-ui-icon-{icon name} to
MediaWiki:Common.css. 'ref-cite-web', 'ref-cite-book', 'ref-cite-news'
and 'ref-cite-journal' are provided. The template name is simply the name
of the template without its namespace prefix.
Depends on Ic353f91 in oojs-ui
Bug: 50110
Bug: 50768
Change-Id: Id401d973b8d5fe2faec481cc777c17a24fd19dd4
2014-03-21 18:56:46 +00:00
|
|
|
ve.ui.MWReferenceDialog.prototype.onSearchSelect = function ( ref ) {
|
|
|
|
if ( ref instanceof ve.dm.MWReferenceModel ) {
|
2014-05-31 19:09:07 +00:00
|
|
|
if ( this.selectedNode instanceof ve.dm.MWReferenceNode ) {
|
|
|
|
this.getFragment().removeContent();
|
|
|
|
this.selectedNode = null;
|
|
|
|
}
|
Ultra-mega-hyper-citation editing on crack
Objectives:
* Allow users on-wiki to create tools and dialogs for citation templates
of their choosing
* Allow editing of citation templates directly, without having to go
through the reference dialog
* Provide citation template tools within reference editing that use the
same titles and icons as the citation tools do, but don't wrap the
inserted content in a ref tag
Changes:
* Reference list was cloning the DOM element it was inserting into its
view before the generated content node could finish rendering, so it
never ended up showing the finished rendering in the reference list
* Documenting hack about use of reference list node's destroy method,
and how we are depending on destroy not canceling generated content
rendering
* Introduced reference model
* Added saving/updating method to transclusion model
* Added getPartsList method to dm transclusion node, which caches the
result and invalidates the cache on update
* Added citation dialog, which extends transclusion dialog
* Added cite group to toolbars, cite-template in reference dialog toolbar
* Factored out getting the node to edit and saving changes procedures in
transclusion dialog so they could be extended in citation dialog
* Updated uses of autoAdd as per changes in oojs-ui (Ic353f91)
* Renamed MWDialogTool file since there was only one tool in it
* Expanded TransclusionDialogTool file out since there is now more logic
to it
* Switched to using ve.dm.MWReferenceModel instead of plain objects in
reference search widget
Configuration:
If you add to MediaWiki:Visualeditor-cite-tool-definition.json the
following code you will magically be presented with a delightful array
of citation options:
[
{ "name": "web", "icon": "ref-cite-web", "template": "Cite web" },
{ "name": "book", "icon": "ref-cite-book", "template": "Cite book" },
{ "name": "news", "icon": "ref-cite-news", "template": "Cite news" },
{ "name": "journal", "icon": "ref-cite-journal", "template": "Cite journal" }
]
...or...
[
{
"name": "any-name",
"icon": "any-ooui-icon",
"template": "Any template",
"title": "Any title text"
}
]
The title text is derived either from the title property or from the name
property by pre-pending the string 'visualeditor-cite-tool-name-' to
generate a message key. Titles for 'web', 'book', 'news' and 'journal' are
provided. The icon is a normal oo-ui-icon name, and more icons can be
added, as usual, by adding a class called .oo-ui-icon-{icon name} to
MediaWiki:Common.css. 'ref-cite-web', 'ref-cite-book', 'ref-cite-news'
and 'ref-cite-journal' are provided. The template name is simply the name
of the template without its namespace prefix.
Depends on Ic353f91 in oojs-ui
Bug: 50110
Bug: 50768
Change-Id: Id401d973b8d5fe2faec481cc777c17a24fd19dd4
2014-03-21 18:56:46 +00:00
|
|
|
this.useReference( ref );
|
2014-07-14 21:32:49 +00:00
|
|
|
this.executeAction( 'insert' );
|
2013-11-05 00:29:50 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-04-01 23:15:47 +00:00
|
|
|
/**
|
2014-07-21 12:58:48 +00:00
|
|
|
* @inheritdoc
|
2014-04-01 23:15:47 +00:00
|
|
|
*/
|
2014-07-21 12:58:48 +00:00
|
|
|
ve.ui.MWReferenceDialog.prototype.getReadyProcess = function ( data ) {
|
|
|
|
return ve.ui.MWReferenceDialog.super.prototype.getReadyProcess.call( this, data )
|
|
|
|
.next( function () {
|
|
|
|
this.referenceSurface.focus();
|
|
|
|
}, this );
|
2014-04-01 23:15:47 +00:00
|
|
|
};
|
|
|
|
|
2014-07-14 21:32:49 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWReferenceDialog.prototype.getBodyHeight = function () {
|
2014-07-23 01:57:39 +00:00
|
|
|
// Clamp value to between 300 and 400px height, preferring the actual height if available
|
|
|
|
return Math.min(
|
|
|
|
400,
|
|
|
|
Math.max(
|
|
|
|
300,
|
|
|
|
Math.ceil( this.panels.getCurrentItem().$element[0].scrollHeight )
|
|
|
|
)
|
|
|
|
);
|
2014-07-14 21:32:49 +00:00
|
|
|
};
|
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
/**
|
|
|
|
* Work on a specific reference.
|
|
|
|
*
|
Ultra-mega-hyper-citation editing on crack
Objectives:
* Allow users on-wiki to create tools and dialogs for citation templates
of their choosing
* Allow editing of citation templates directly, without having to go
through the reference dialog
* Provide citation template tools within reference editing that use the
same titles and icons as the citation tools do, but don't wrap the
inserted content in a ref tag
Changes:
* Reference list was cloning the DOM element it was inserting into its
view before the generated content node could finish rendering, so it
never ended up showing the finished rendering in the reference list
* Documenting hack about use of reference list node's destroy method,
and how we are depending on destroy not canceling generated content
rendering
* Introduced reference model
* Added saving/updating method to transclusion model
* Added getPartsList method to dm transclusion node, which caches the
result and invalidates the cache on update
* Added citation dialog, which extends transclusion dialog
* Added cite group to toolbars, cite-template in reference dialog toolbar
* Factored out getting the node to edit and saving changes procedures in
transclusion dialog so they could be extended in citation dialog
* Updated uses of autoAdd as per changes in oojs-ui (Ic353f91)
* Renamed MWDialogTool file since there was only one tool in it
* Expanded TransclusionDialogTool file out since there is now more logic
to it
* Switched to using ve.dm.MWReferenceModel instead of plain objects in
reference search widget
Configuration:
If you add to MediaWiki:Visualeditor-cite-tool-definition.json the
following code you will magically be presented with a delightful array
of citation options:
[
{ "name": "web", "icon": "ref-cite-web", "template": "Cite web" },
{ "name": "book", "icon": "ref-cite-book", "template": "Cite book" },
{ "name": "news", "icon": "ref-cite-news", "template": "Cite news" },
{ "name": "journal", "icon": "ref-cite-journal", "template": "Cite journal" }
]
...or...
[
{
"name": "any-name",
"icon": "any-ooui-icon",
"template": "Any template",
"title": "Any title text"
}
]
The title text is derived either from the title property or from the name
property by pre-pending the string 'visualeditor-cite-tool-name-' to
generate a message key. Titles for 'web', 'book', 'news' and 'journal' are
provided. The icon is a normal oo-ui-icon name, and more icons can be
added, as usual, by adding a class called .oo-ui-icon-{icon name} to
MediaWiki:Common.css. 'ref-cite-web', 'ref-cite-book', 'ref-cite-news'
and 'ref-cite-journal' are provided. The template name is simply the name
of the template without its namespace prefix.
Depends on Ic353f91 in oojs-ui
Bug: 50110
Bug: 50768
Change-Id: Id401d973b8d5fe2faec481cc777c17a24fd19dd4
2014-03-21 18:56:46 +00:00
|
|
|
* @param {ve.dm.MWReferenceModel} [ref] Reference model, omit to work on a new reference
|
2013-11-05 00:29:50 +00:00
|
|
|
* @chainable
|
|
|
|
*/
|
|
|
|
ve.ui.MWReferenceDialog.prototype.useReference = function ( ref ) {
|
2014-10-27 22:36:26 +00:00
|
|
|
var group;
|
Ultra-mega-hyper-citation editing on crack
Objectives:
* Allow users on-wiki to create tools and dialogs for citation templates
of their choosing
* Allow editing of citation templates directly, without having to go
through the reference dialog
* Provide citation template tools within reference editing that use the
same titles and icons as the citation tools do, but don't wrap the
inserted content in a ref tag
Changes:
* Reference list was cloning the DOM element it was inserting into its
view before the generated content node could finish rendering, so it
never ended up showing the finished rendering in the reference list
* Documenting hack about use of reference list node's destroy method,
and how we are depending on destroy not canceling generated content
rendering
* Introduced reference model
* Added saving/updating method to transclusion model
* Added getPartsList method to dm transclusion node, which caches the
result and invalidates the cache on update
* Added citation dialog, which extends transclusion dialog
* Added cite group to toolbars, cite-template in reference dialog toolbar
* Factored out getting the node to edit and saving changes procedures in
transclusion dialog so they could be extended in citation dialog
* Updated uses of autoAdd as per changes in oojs-ui (Ic353f91)
* Renamed MWDialogTool file since there was only one tool in it
* Expanded TransclusionDialogTool file out since there is now more logic
to it
* Switched to using ve.dm.MWReferenceModel instead of plain objects in
reference search widget
Configuration:
If you add to MediaWiki:Visualeditor-cite-tool-definition.json the
following code you will magically be presented with a delightful array
of citation options:
[
{ "name": "web", "icon": "ref-cite-web", "template": "Cite web" },
{ "name": "book", "icon": "ref-cite-book", "template": "Cite book" },
{ "name": "news", "icon": "ref-cite-news", "template": "Cite news" },
{ "name": "journal", "icon": "ref-cite-journal", "template": "Cite journal" }
]
...or...
[
{
"name": "any-name",
"icon": "any-ooui-icon",
"template": "Any template",
"title": "Any title text"
}
]
The title text is derived either from the title property or from the name
property by pre-pending the string 'visualeditor-cite-tool-name-' to
generate a message key. Titles for 'web', 'book', 'news' and 'journal' are
provided. The icon is a normal oo-ui-icon name, and more icons can be
added, as usual, by adding a class called .oo-ui-icon-{icon name} to
MediaWiki:Common.css. 'ref-cite-web', 'ref-cite-book', 'ref-cite-news'
and 'ref-cite-journal' are provided. The template name is simply the name
of the template without its namespace prefix.
Depends on Ic353f91 in oojs-ui
Bug: 50110
Bug: 50768
Change-Id: Id401d973b8d5fe2faec481cc777c17a24fd19dd4
2014-03-21 18:56:46 +00:00
|
|
|
// Properties
|
|
|
|
if ( ref instanceof ve.dm.MWReferenceModel ) {
|
2013-11-05 00:29:50 +00:00
|
|
|
// Use an existing reference
|
2014-04-01 23:15:47 +00:00
|
|
|
this.referenceModel = ref;
|
2013-11-05 00:29:50 +00:00
|
|
|
} else {
|
|
|
|
// Create a new reference
|
2014-04-01 23:15:47 +00:00
|
|
|
this.referenceModel = new ve.dm.MWReferenceModel();
|
2013-11-05 00:29:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
if ( this.referenceSurface ) {
|
|
|
|
this.referenceSurface.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Properties
|
2014-10-15 23:56:44 +00:00
|
|
|
this.referenceSurface = new ve.ui.MWSurfaceWidget(
|
2014-04-01 23:15:47 +00:00
|
|
|
this.referenceModel.getDocument(),
|
2013-11-05 00:29:50 +00:00
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
$: this.$,
|
|
|
|
tools: this.constructor.static.toolbarGroups,
|
|
|
|
commands: this.constructor.static.surfaceCommands,
|
|
|
|
pasteRules: this.constructor.static.getPasteRules()
|
2013-11-05 00:29:50 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
Ultra-mega-hyper-citation editing on crack
Objectives:
* Allow users on-wiki to create tools and dialogs for citation templates
of their choosing
* Allow editing of citation templates directly, without having to go
through the reference dialog
* Provide citation template tools within reference editing that use the
same titles and icons as the citation tools do, but don't wrap the
inserted content in a ref tag
Changes:
* Reference list was cloning the DOM element it was inserting into its
view before the generated content node could finish rendering, so it
never ended up showing the finished rendering in the reference list
* Documenting hack about use of reference list node's destroy method,
and how we are depending on destroy not canceling generated content
rendering
* Introduced reference model
* Added saving/updating method to transclusion model
* Added getPartsList method to dm transclusion node, which caches the
result and invalidates the cache on update
* Added citation dialog, which extends transclusion dialog
* Added cite group to toolbars, cite-template in reference dialog toolbar
* Factored out getting the node to edit and saving changes procedures in
transclusion dialog so they could be extended in citation dialog
* Updated uses of autoAdd as per changes in oojs-ui (Ic353f91)
* Renamed MWDialogTool file since there was only one tool in it
* Expanded TransclusionDialogTool file out since there is now more logic
to it
* Switched to using ve.dm.MWReferenceModel instead of plain objects in
reference search widget
Configuration:
If you add to MediaWiki:Visualeditor-cite-tool-definition.json the
following code you will magically be presented with a delightful array
of citation options:
[
{ "name": "web", "icon": "ref-cite-web", "template": "Cite web" },
{ "name": "book", "icon": "ref-cite-book", "template": "Cite book" },
{ "name": "news", "icon": "ref-cite-news", "template": "Cite news" },
{ "name": "journal", "icon": "ref-cite-journal", "template": "Cite journal" }
]
...or...
[
{
"name": "any-name",
"icon": "any-ooui-icon",
"template": "Any template",
"title": "Any title text"
}
]
The title text is derived either from the title property or from the name
property by pre-pending the string 'visualeditor-cite-tool-name-' to
generate a message key. Titles for 'web', 'book', 'news' and 'journal' are
provided. The icon is a normal oo-ui-icon name, and more icons can be
added, as usual, by adding a class called .oo-ui-icon-{icon name} to
MediaWiki:Common.css. 'ref-cite-web', 'ref-cite-book', 'ref-cite-news'
and 'ref-cite-journal' are provided. The template name is simply the name
of the template without its namespace prefix.
Depends on Ic353f91 in oojs-ui
Bug: 50110
Bug: 50768
Change-Id: Id401d973b8d5fe2faec481cc777c17a24fd19dd4
2014-03-21 18:56:46 +00:00
|
|
|
// Events
|
2014-08-22 20:50:48 +00:00
|
|
|
this.referenceModel.getDocument().connect( this, { transact: 'onDocumentTransact' } );
|
2014-06-10 21:19:03 +00:00
|
|
|
this.referenceSurface.getSurface().getModel().connect( this, {
|
2014-08-22 20:50:48 +00:00
|
|
|
documentUpdate: function () {
|
2014-08-29 20:11:11 +00:00
|
|
|
mw.loader.using( 'mediawiki.notification' ).then( function () {
|
|
|
|
this.wikitextWarning = ve.init.mw.ViewPageTarget.static.checkForWikitextWarning(
|
|
|
|
this.referenceSurface.getSurface(),
|
|
|
|
this.wikitextWarning
|
|
|
|
);
|
|
|
|
}.bind( this ) );
|
2014-06-10 21:19:03 +00:00
|
|
|
}
|
|
|
|
} );
|
2013-11-05 00:29:50 +00:00
|
|
|
|
|
|
|
// Initialization
|
2014-08-23 02:36:39 +00:00
|
|
|
this.referenceGroupInput.input.setValue( this.referenceModel.getGroup() );
|
2013-11-05 00:29:50 +00:00
|
|
|
this.contentFieldset.$element.append( this.referenceSurface.$element );
|
|
|
|
this.referenceSurface.initialize();
|
|
|
|
|
2014-10-27 22:36:26 +00:00
|
|
|
group = this.getFragment().getDocument().getInternalList()
|
|
|
|
.getNodeGroup( this.referenceModel.getListGroup() );
|
|
|
|
if ( group && group.keyedNodes[this.referenceModel.getListKey()].length > 1 ) {
|
|
|
|
this.$reuseWarning.show();
|
|
|
|
this.$reuseWarningText.text( mw.msg(
|
|
|
|
'visualeditor-dialog-reference-editing-reused',
|
|
|
|
group.keyedNodes[this.referenceModel.getListKey()].length
|
|
|
|
) );
|
|
|
|
} else {
|
|
|
|
this.$reuseWarning.hide();
|
|
|
|
}
|
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
2013-07-17 19:09:30 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWReferenceDialog.prototype.initialize = function () {
|
|
|
|
// Parent method
|
2014-04-24 00:22:45 +00:00
|
|
|
ve.ui.MWReferenceDialog.super.prototype.initialize.call( this );
|
2013-07-17 19:09:30 +00:00
|
|
|
|
|
|
|
// Properties
|
2014-08-22 20:50:48 +00:00
|
|
|
this.panels = new OO.ui.StackLayout( { $: this.$ } );
|
2013-10-09 20:09:59 +00:00
|
|
|
this.editPanel = new OO.ui.PanelLayout( {
|
2014-08-22 20:50:48 +00:00
|
|
|
$: this.$, scrollable: true, padded: true
|
2013-07-17 19:09:30 +00:00
|
|
|
} );
|
2014-08-22 20:50:48 +00:00
|
|
|
this.searchPanel = new OO.ui.PanelLayout( { $: this.$ } );
|
2014-10-27 22:36:26 +00:00
|
|
|
|
|
|
|
this.reuseWarningIcon = new OO.ui.IconWidget( { icon: 'alert' } );
|
|
|
|
this.$reuseWarningText = this.$( '<span>' );
|
|
|
|
this.$reuseWarning = this.$( '<span>' ).append( this.reuseWarningIcon.$element, this.$reuseWarningText );
|
|
|
|
|
2014-08-22 20:50:48 +00:00
|
|
|
this.contentFieldset = new OO.ui.FieldsetLayout( { $: this.$ } );
|
2013-10-09 20:09:59 +00:00
|
|
|
this.optionsFieldset = new OO.ui.FieldsetLayout( {
|
2014-08-22 20:50:48 +00:00
|
|
|
$: this.$,
|
|
|
|
label: ve.msg( 'visualeditor-dialog-reference-options-section' ),
|
|
|
|
icon: 'settings'
|
2013-07-17 19:09:30 +00:00
|
|
|
} );
|
2014-08-23 02:36:39 +00:00
|
|
|
this.referenceGroupInput = new ve.ui.MWReferenceGroupInputWidget( {
|
2014-08-22 20:50:48 +00:00
|
|
|
$: this.$,
|
2014-10-30 21:50:10 +00:00
|
|
|
$overlay: this.$overlay,
|
2014-08-23 02:36:39 +00:00
|
|
|
emptyGroupName: ve.msg( 'visualeditor-dialog-reference-options-group-placeholder' )
|
2014-02-20 01:33:35 +00:00
|
|
|
} );
|
2014-01-22 20:13:59 +00:00
|
|
|
this.referenceGroupField = new OO.ui.FieldLayout( this.referenceGroupInput, {
|
2014-08-22 20:50:48 +00:00
|
|
|
$: this.$,
|
|
|
|
align: 'top',
|
|
|
|
label: ve.msg( 'visualeditor-dialog-reference-options-group-label' )
|
2013-07-17 19:09:30 +00:00
|
|
|
} );
|
2014-08-22 20:50:48 +00:00
|
|
|
this.search = new ve.ui.MWReferenceSearchWidget( { $: this.$ } );
|
2013-07-17 19:09:30 +00:00
|
|
|
|
|
|
|
// Events
|
2014-08-22 20:50:48 +00:00
|
|
|
this.search.connect( this, { select: 'onSearchSelect' } );
|
2013-07-17 19:09:30 +00:00
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.panels.addItems( [ this.editPanel, this.searchPanel ] );
|
2014-10-27 22:36:26 +00:00
|
|
|
this.editPanel.$element.append( this.$reuseWarning, this.contentFieldset.$element, this.optionsFieldset.$element );
|
2014-01-22 20:13:59 +00:00
|
|
|
this.optionsFieldset.addItems( [ this.referenceGroupField ] );
|
2013-11-01 19:45:59 +00:00
|
|
|
this.searchPanel.$element.append( this.search.$element );
|
2014-07-14 21:32:49 +00:00
|
|
|
this.$body.append( this.panels.$element );
|
2013-07-17 19:09:30 +00:00
|
|
|
};
|
|
|
|
|
2014-05-30 21:28:41 +00:00
|
|
|
/**
|
|
|
|
* Switches dialog to use existing reference mode
|
2014-07-03 20:42:54 +00:00
|
|
|
*
|
|
|
|
* @param {string} [action='select'] Symbolic name of action, either 'select' or 'insert-select'
|
2014-05-30 21:28:41 +00:00
|
|
|
*/
|
2014-07-03 20:42:54 +00:00
|
|
|
ve.ui.MWReferenceDialog.prototype.useExistingReference = function ( action ) {
|
|
|
|
action = action || 'select';
|
|
|
|
if ( action === 'insert-select' || action === 'select' ) {
|
|
|
|
this.actions.setMode( action );
|
|
|
|
}
|
2014-07-21 14:27:25 +00:00
|
|
|
this.search.buildIndex();
|
2014-05-30 21:28:41 +00:00
|
|
|
this.panels.setItem( this.searchPanel );
|
|
|
|
this.search.getQuery().focus().select();
|
|
|
|
};
|
|
|
|
|
2014-07-14 21:32:49 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWReferenceDialog.prototype.getActionProcess = function ( action ) {
|
|
|
|
if ( action === 'insert' || action === 'apply' ) {
|
|
|
|
return new OO.ui.Process( function () {
|
|
|
|
var surfaceModel = this.getFragment().getSurface();
|
|
|
|
|
2014-08-23 02:36:39 +00:00
|
|
|
this.referenceModel.setGroup( this.referenceGroupInput.input.getValue() );
|
2014-07-14 21:32:49 +00:00
|
|
|
|
|
|
|
// Insert reference (will auto-create an internal item if needed)
|
|
|
|
if ( !( this.selectedNode instanceof ve.dm.MWReferenceNode ) ) {
|
|
|
|
if ( !this.referenceModel.findInternalItem( surfaceModel ) ) {
|
|
|
|
this.referenceModel.insertInternalItem( surfaceModel );
|
|
|
|
}
|
|
|
|
// Collapse returns a new fragment, so update this.fragment
|
2014-09-30 16:34:33 +00:00
|
|
|
this.fragment = this.getFragment().collapseToEnd();
|
2014-07-14 21:32:49 +00:00
|
|
|
this.referenceModel.insertReferenceNode( this.getFragment() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update internal item
|
|
|
|
this.referenceModel.updateInternalItem( surfaceModel );
|
|
|
|
|
2014-08-22 20:50:48 +00:00
|
|
|
this.close( { action: action } );
|
2014-07-14 21:32:49 +00:00
|
|
|
}, this );
|
|
|
|
} else if ( action === 'back' ) {
|
|
|
|
this.actions.setMode( this.selectedNode ? 'edit' : 'insert' );
|
|
|
|
this.panels.setItem( this.editPanel );
|
2014-07-21 12:29:42 +00:00
|
|
|
this.editPanel.$element.find( '.ve-ce-documentNode' )[0].focus();
|
2014-07-03 20:42:54 +00:00
|
|
|
} else if ( action === 'select' || action === 'insert-select' ) {
|
|
|
|
this.useExistingReference( action );
|
2014-07-14 21:32:49 +00:00
|
|
|
}
|
|
|
|
return ve.ui.MWReferenceDialog.super.prototype.getActionProcess.call( this, action );
|
|
|
|
};
|
|
|
|
|
2013-07-17 19:09:30 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
2014-05-30 21:28:41 +00:00
|
|
|
* @param {Object} [data] Setup data
|
|
|
|
* @param {boolean} [data.useExistingReference] Open the dialog in "use existing reference" mode
|
2013-07-17 19:09:30 +00:00
|
|
|
*/
|
2014-05-31 04:47:08 +00:00
|
|
|
ve.ui.MWReferenceDialog.prototype.getSetupProcess = function ( data ) {
|
2014-07-15 22:49:51 +00:00
|
|
|
data = data || {};
|
2014-05-31 04:47:08 +00:00
|
|
|
return ve.ui.MWReferenceDialog.super.prototype.getSetupProcess.call( this, data )
|
|
|
|
.next( function () {
|
|
|
|
this.panels.setItem( this.editPanel );
|
|
|
|
if ( this.selectedNode instanceof ve.dm.MWReferenceNode ) {
|
|
|
|
this.useReference(
|
|
|
|
ve.dm.MWReferenceModel.static.newFromReferenceNode( this.selectedNode )
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.useReference( null );
|
2014-08-22 20:50:48 +00:00
|
|
|
this.actions.setAbilities( { apply: false, insert: false } );
|
2014-05-31 04:47:08 +00:00
|
|
|
}
|
2014-07-14 21:32:49 +00:00
|
|
|
|
|
|
|
this.actions.setMode( this.selectedNode ? 'edit' : 'insert' );
|
2014-07-21 14:27:25 +00:00
|
|
|
this.search.setInternalList( this.getFragment().getDocument().getInternalList() );
|
2014-05-30 21:28:41 +00:00
|
|
|
|
|
|
|
if ( data.useExisting ) {
|
2014-07-03 20:42:54 +00:00
|
|
|
this.useExistingReference( 'insert-select' );
|
2014-05-30 21:28:41 +00:00
|
|
|
}
|
2014-05-31 19:09:07 +00:00
|
|
|
|
|
|
|
// If we're using an existing reference, start off disabled
|
|
|
|
// If not, set disabled based on whether or not there are any existing ones.
|
2014-07-14 21:32:49 +00:00
|
|
|
this.actions.setAbilities( {
|
2014-08-22 20:50:48 +00:00
|
|
|
select: !( this.selectedNode instanceof ve.dm.MWReferenceNode ) &&
|
2014-07-14 21:32:49 +00:00
|
|
|
!this.search.isIndexEmpty()
|
|
|
|
} );
|
2014-08-23 02:36:39 +00:00
|
|
|
|
|
|
|
this.referenceGroupInput.populateMenu( this.getFragment().getDocument().getInternalList() );
|
2014-05-31 04:47:08 +00:00
|
|
|
}, this );
|
2013-07-17 19:09:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2014-05-31 04:47:08 +00:00
|
|
|
ve.ui.MWReferenceDialog.prototype.getTeardownProcess = function ( data ) {
|
|
|
|
return ve.ui.MWReferenceDialog.super.prototype.getTeardownProcess.call( this, data )
|
|
|
|
.first( function () {
|
|
|
|
this.search.getQuery().setValue( '' );
|
2014-06-10 21:19:03 +00:00
|
|
|
if ( this.wikitextWarning ) {
|
|
|
|
this.wikitextWarning.close();
|
|
|
|
}
|
2014-05-31 04:47:08 +00:00
|
|
|
this.referenceSurface.destroy();
|
|
|
|
this.referenceSurface = null;
|
|
|
|
this.referenceModel = null;
|
|
|
|
}, this );
|
2013-08-27 23:29:55 +00:00
|
|
|
};
|
|
|
|
|
2013-07-17 19:09:30 +00:00
|
|
|
/* Registration */
|
|
|
|
|
2014-04-21 22:31:21 +00:00
|
|
|
ve.ui.windowFactory.register( ve.ui.MWReferenceDialog );
|