Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/233406
Change subject: Move MWReferenceSourceSelectWidget into Citoid
......................................................................
Move MWReferenceSourceSelectWidget into Citoid
Bug: T109988
Change-Id: Iaca69f178e5abe1e6923dfc97a05fa0839dae3be
---
M extension.json
M modules/ve.ui.CiteFromIdInspector.js
A modules/ve.ui.CiteSourceSelectWidget.css
A modules/ve.ui.CiteSourceSelectWidget.js
4 files changed, 114 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Citoid
refs/changes/06/233406/1
diff --git a/extension.json b/extension.json
index 1759c57..11a502f 100644
--- a/extension.json
+++ b/extension.json
@@ -21,6 +21,7 @@
"ResourceModules": {
"ext.citoid.visualEditor": {
"scripts": [
+ "modules/ve.ui.CiteSourceSelectWidget.js",
"modules/ve.ui.CiteFromIdInspectorTool.js",
"modules/ve.ui.CiteFromIdGroupWidget.js",
"modules/ve.ui.CiteFromIdReferenceWidget.js",
@@ -28,6 +29,7 @@
"modules/ve.ui.CitoidAction.js"
],
"styles": [
+ "modules/ve.ui.CiteSourceSelectWidget.css",
"modules/ve.ui.CiteFromIdInspector.css"
],
"dependencies": [
diff --git a/modules/ve.ui.CiteFromIdInspector.js
b/modules/ve.ui.CiteFromIdInspector.js
index b974491..24ebe28 100644
--- a/modules/ve.ui.CiteFromIdInspector.js
+++ b/modules/ve.ui.CiteFromIdInspector.js
@@ -194,7 +194,7 @@
this.autoProcessPanels.result.$element.append(
this.previewSelectWidget.$element );
// Manual mode
- this.sourceSelect = new ve.ui.MWReferenceSourceSelectWidget( {
+ this.sourceSelect = new ve.ui.CiteSourceSelectWidget( {
classes: [ 've-ui-citeFromIdInspector-sourceSelect' ]
} );
this.modePanels.manual.$element.append( this.sourceSelect.$element );
diff --git a/modules/ve.ui.CiteSourceSelectWidget.css
b/modules/ve.ui.CiteSourceSelectWidget.css
new file mode 100644
index 0000000..94f1daa
--- /dev/null
+++ b/modules/ve.ui.CiteSourceSelectWidget.css
@@ -0,0 +1,7 @@
+/*!
+ * VisualEditor UserInterface CiteSourceSelectWidget styles.
+ */
+
+.ve-ui-citeSourceSelectWidget-separator {
+ border-top: 1px solid #ccc;
+}
diff --git a/modules/ve.ui.CiteSourceSelectWidget.js
b/modules/ve.ui.CiteSourceSelectWidget.js
new file mode 100644
index 0000000..a9ef66a
--- /dev/null
+++ b/modules/ve.ui.CiteSourceSelectWidget.js
@@ -0,0 +1,104 @@
+/*!
+ * VisualEditor UserInterface CiteSourceSelectWidget class
+ * Originally from VisualEditor MediaWiki UserInterface
+ *
+ * @copyright 2011-2015 VisualEditor Team and others
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/**
+ * Creates an ve.ui.CiteSourceSelectWidget object.
+ *
+ * @class
+ * @extends OO.ui.SearchWidget
+ *
+ * @constructor
+ * @param {Object} [config] Configuration options
+ * @cfg {boolean} [showExisting] Show 're-use existing reference' as an option
+ */
+ve.ui.CiteSourceSelectWidget = function VeUiCiteSourceSelectWidget( config ) {
+ var i, len, tools, item, limit,
+ items = [];
+
+ config = config || {};
+
+ // Parent constructor
+ ve.ui.CiteSourceSelectWidget.super.call( this, config );
+
+ limit = ve.init.target.constructor.static.citationToolsLimit;
+
+ try {
+ // Must use mw.message to avoid JSON being parsed as Wikitext
+ tools = JSON.parse( mw.message(
'visualeditor-cite-tool-definition.json' ).plain() );
+ } catch ( e ) {
+ tools = [];
+ }
+
+ // Go over available tools
+ for ( i = 0, len = Math.min( limit, tools.length ); i < len; i++ ) {
+ item = tools[ i ];
+ items.push( new OO.ui.DecoratedOptionWidget( {
+ icon: item.icon,
+ label: item.title,
+ data: {
+ windowName: 'cite-' + item.name,
+ dialogData: { template: item.template }
+ }
+ } ) );
+ }
+
+ // Basic tools
+ this.refBasic = new OO.ui.DecoratedOptionWidget( {
+ icon: 'reference',
+ label: ve.msg( 'visualeditor-dialogbutton-reference-full-label'
),
+ data: { windowName: 'reference' },
+ classes: [ 've-ui-citeSourceSelectWidget-basic' ]
+ } );
+ items.push( this.refBasic );
+
+ if ( config.showExisting ) {
+ this.refExisting = new OO.ui.DecoratedOptionWidget( {
+ icon: 'reference-existing',
+ label: ve.msg(
'visualeditor-dialog-reference-useexisting-full-label' ),
+ data: {
+ windowName: 'reference',
+ dialogData: { useExisting: true }
+ },
+ classes: [ 've-ui-citeSourceSelectWidget-reuse' ]
+ } );
+ items.push( this.refExisting );
+ }
+
+ this.addItems( items );
+
+ $( '<div>' )
+ .addClass( 've-ui-citeSourceSelectWidget-separator' )
+ .insertBefore( this.refBasic.$element );
+
+ // Initialization
+ this.$element.addClass( 've-ui-citeSourceSelectWidget' );
+};
+
+/* Inheritance */
+
+OO.inheritClass( ve.ui.CiteSourceSelectWidget, OO.ui.SelectWidget );
+
+/* Methods */
+
+/**
+ * Get the basic reference option
+ *
+ * @return {OO.ui.OptionWidget} Basic reference option
+ */
+ve.ui.CiteSourceSelectWidget.prototype.getRefBasic = function () {
+ return this.refBasic;
+};
+
+/**
+ * Get the existing reference option
+ *
+ * @return {OO.ui.OptionWidget} Existing reference option
+ */
+ve.ui.CiteSourceSelectWidget.prototype.getRefExisting = function () {
+ return this.refExisting;
+};
--
To view, visit https://gerrit.wikimedia.org/r/233406
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaca69f178e5abe1e6923dfc97a05fa0839dae3be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Citoid
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits