aboutsummaryrefslogtreecommitdiffstats
path: root/resources/src
diff options
context:
space:
mode:
Diffstat (limited to 'resources/src')
-rw-r--r--resources/src/mediawiki.special/mediawiki.special.apisandbox.css14
-rw-r--r--resources/src/mediawiki.special/mediawiki.special.apisandbox.js60
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js3
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.base.css2
-rw-r--r--resources/src/mediawiki/mediawiki.jqueryMsg.js27
5 files changed, 51 insertions, 55 deletions
diff --git a/resources/src/mediawiki.special/mediawiki.special.apisandbox.css b/resources/src/mediawiki.special/mediawiki.special.apisandbox.css
index 7ef026338514..60f83ad97c8a 100644
--- a/resources/src/mediawiki.special/mediawiki.special.apisandbox.css
+++ b/resources/src/mediawiki.special/mediawiki.special.apisandbox.css
@@ -21,6 +21,20 @@
overflow: visible;
}
+/* Display contents of the popup on a single line */
+.mw-apisandbox-popup > .oo-ui-popupWidget-popup > .oo-ui-popupWidget-body {
+ display: table;
+}
+
+.mw-apisandbox-popup > .oo-ui-popupWidget-popup > .oo-ui-popupWidget-body > * {
+ display: table-cell;
+}
+
+.mw-apisandbox-popup > .oo-ui-popupWidget-popup > .oo-ui-popupWidget-body > .oo-ui-buttonWidget {
+ padding-left: 0.5em;
+ width: 1%;
+}
+
.mw-apisandbox-fullscreen #mw-apisandbox-ui {
position: fixed;
top: 0;
diff --git a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js
index df87c9cc9ff3..516551c1c7f7 100644
--- a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js
+++ b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js
@@ -384,8 +384,10 @@
* @return {OO.ui.Widget}
*/
createWidgetForParameter: function ( pi, opts ) {
- var widget, innerWidget, finalWidget, items, $button, $content, func,
- multiMode = 'none';
+ var widget, innerWidget, finalWidget, items, $content, func,
+ multiModeButton = null,
+ multiModeInput = null,
+ multiModeAllowed = false;
opts = opts || {};
@@ -442,7 +444,8 @@
$.extend( widget, WidgetMethods.textInputWidget );
$.extend( widget, WidgetMethods.passwordWidget );
widget.setValidation( Validators.generic );
- multiMode = 'enter';
+ multiModeAllowed = true;
+ multiModeInput = widget;
break;
case 'integer':
@@ -458,7 +461,8 @@
if ( Util.apiBool( pi.enforcerange ) ) {
widget.setRange( pi.min || -Infinity, pi.max || Infinity );
}
- multiMode = 'enter';
+ multiModeAllowed = true;
+ multiModeInput = widget;
break;
case 'limit':
@@ -481,7 +485,8 @@
pi.apiSandboxMax = mw.config.get( 'apihighlimits' ) ? pi.highmax : pi.max;
widget.paramInfo = pi;
$.extend( widget, WidgetMethods.textInputWidget );
- multiMode = 'enter';
+ multiModeAllowed = true;
+ multiModeInput = widget;
break;
case 'timestamp':
@@ -495,7 +500,7 @@
widget.paramInfo = pi;
$.extend( widget, WidgetMethods.textInputWidget );
$.extend( widget, WidgetMethods.dateTimeInputWidget );
- multiMode = 'indicator';
+ multiModeAllowed = true;
break;
case 'upload':
@@ -595,25 +600,13 @@
break;
}
- if ( Util.apiBool( pi.multi ) && multiMode !== 'none' ) {
+ if ( Util.apiBool( pi.multi ) && multiModeAllowed ) {
innerWidget = widget;
- switch ( multiMode ) {
- case 'enter':
- $content = innerWidget.$element;
- break;
-
- case 'indicator':
- $button = innerWidget.$indicator;
- $button.css( 'cursor', 'pointer' );
- $button.attr( 'tabindex', 0 );
- $button.parent().append( $button );
- innerWidget.setIndicator( 'next' );
- $content = innerWidget.$element;
- break;
-
- default:
- throw new Error( 'Unknown multiMode "' + multiMode + '"' );
- }
+
+ multiModeButton = new OO.ui.ButtonWidget( {
+ label: mw.message( 'apisandbox-add-multi' ).text()
+ } );
+ $content = innerWidget.$element.add( multiModeButton.$element );
widget = new OO.ui.PopupTagMultiselectWidget( {
allowArbitrary: true,
@@ -638,22 +631,11 @@
return false;
}
};
- switch ( multiMode ) {
- case 'enter':
- innerWidget.connect( null, { enter: func } );
- break;
-
- case 'indicator':
- $button.on( {
- click: func,
- keypress: function ( e ) {
- if ( e.which === OO.ui.Keys.SPACE || e.which === OO.ui.Keys.ENTER ) {
- func();
- }
- }
- } );
- break;
+
+ if ( multiModeInput ) {
+ multiModeInput.on( 'enter', func );
}
+ multiModeButton.on( 'click', func );
}
if ( Util.apiBool( pi.required ) || opts.nooptional ) {
diff --git a/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
index b3bcc0d07e44..354fcd94bd19 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
@@ -411,7 +411,4 @@
/** Search only parent categories */
ParentCategories: 4
};
-
- // For backwards compatibility. See T161285.
- mw.widgets.CategorySelector = mw.widgets.CategoryMultiselectWidget;
}( jQuery, mediaWiki ) );
diff --git a/resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.base.css b/resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.base.css
index 772add3488b0..4d9102797ec4 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.base.css
+++ b/resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.base.css
@@ -11,7 +11,7 @@
}
.mw-widget-sizeFilterWidget .oo-ui-textInputWidget {
- max-width: 29.5em;
+ max-width: 10em;
}
/* PHP widget */
diff --git a/resources/src/mediawiki/mediawiki.jqueryMsg.js b/resources/src/mediawiki/mediawiki.jqueryMsg.js
index ea91afe9601d..67d6e2c5f5d0 100644
--- a/resources/src/mediawiki/mediawiki.jqueryMsg.js
+++ b/resources/src/mediawiki/mediawiki.jqueryMsg.js
@@ -60,7 +60,7 @@
* Wrapper around jQuery append that converts all non-objects to TextNode so append will not
* convert what it detects as an htmlString to an element.
*
- * If our own htmlEmitter jQuery object is given, its children will be unwrapped and appended to
+ * If our own HtmlEmitter jQuery object is given, its children will be unwrapped and appended to
* new parent.
*
* Object elements of children (jQuery, HTMLElement, TextNode, etc.) will be left as is.
@@ -135,8 +135,7 @@
function getFailableParserFn( options ) {
return function ( args ) {
var fallback,
- // eslint-disable-next-line new-cap
- parser = new mw.jqueryMsg.parser( options ),
+ parser = new mw.jqueryMsg.Parser( options ),
key = args[ 0 ],
argsArray = Array.isArray( args[ 1 ] ) ? args[ 1 ] : slice.call( args, 1 );
try {
@@ -160,7 +159,7 @@
*
* ResourceLoaderJqueryMsgModule calls this to provide default values from
* Sanitizer.php for allowed HTML elements. To override this data for individual
- * parsers, pass the relevant options to mw.jqueryMsg.parser.
+ * parsers, pass the relevant options to mw.jqueryMsg.Parser.
*
* @private
* @param {Object} data New data to extend parser defaults with
@@ -274,16 +273,18 @@
* @private
* @param {Object} options
*/
- mw.jqueryMsg.parser = function ( options ) {
+ mw.jqueryMsg.Parser = function ( options ) {
this.settings = $.extend( {}, parserDefaults, options );
this.settings.onlyCurlyBraceTransform = ( this.settings.format === 'text' || this.settings.format === 'escaped' );
this.astCache = {};
- // eslint-disable-next-line new-cap
- this.emitter = new mw.jqueryMsg.htmlEmitter( this.settings.language, this.settings.magic );
+ this.emitter = new mw.jqueryMsg.HtmlEmitter( this.settings.language, this.settings.magic );
};
+ // Backwards-compatible alias
+ // @deprecated since 1.31
+ mw.jqueryMsg.parser = mw.jqueryMsg.Parser;
- mw.jqueryMsg.parser.prototype = {
+ mw.jqueryMsg.Parser.prototype = {
/**
* Where the magic happens.
* Parses a message from the key, and swaps in replacements as necessary, wraps in jQuery
@@ -943,12 +944,14 @@
};
/**
- * htmlEmitter - object which primarily exists to emit HTML from parser ASTs
+ * Class that primarily exists to emit HTML from parser ASTs.
*
+ * @private
+ * @class
* @param {Object} language
* @param {Object} magic
*/
- mw.jqueryMsg.htmlEmitter = function ( language, magic ) {
+ mw.jqueryMsg.HtmlEmitter = function ( language, magic ) {
var jmsg = this;
this.language = language;
$.each( magic, function ( key, val ) {
@@ -1005,7 +1008,7 @@
//
// An emitter method takes the parent node, the array of subnodes and the array of replacements (the values that $1, $2... should translate to).
// Note: all such functions must be pure, with the exception of referring to other pure functions via this.language (convertPlural and so on)
- mw.jqueryMsg.htmlEmitter.prototype = {
+ mw.jqueryMsg.HtmlEmitter.prototype = {
/**
* Parsing has been applied depth-first we can assume that all nodes here are single nodes
* Must return a single node to parents -- a jQuery with synthetic span
@@ -1125,7 +1128,7 @@
* The "href" can be:
* - a jQuery object, treat it as "enclosing" the link text.
* - a function, treat it as the click handler.
- * - a string, or our htmlEmitter jQuery object, treat it as a URI after stringifying.
+ * - a string, or our HtmlEmitter jQuery object, treat it as a URI after stringifying.
*
* TODO: throw an error if nodes.length > 2 ?
*