dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ApiSandbox: Use CopyTextLayouts for snippets
[lhc/web/wiklou.git]
/
resources
/
src
/
mediawiki.special.apisandbox
/
apisandbox.js
diff --git
a/resources/src/mediawiki.special.apisandbox/apisandbox.js
b/resources/src/mediawiki.special.apisandbox/apisandbox.js
index
19eac98
..
d31a109
100644
(file)
--- a/
resources/src/mediawiki.special.apisandbox/apisandbox.js
+++ b/
resources/src/mediawiki.special.apisandbox/apisandbox.js
@@
-524,7
+524,7
@@
break;
case 'namespace':
break;
case 'namespace':
- // eslint-disable-next-line jquery/no-map-util
+ // eslint-disable-next-line
no-
jquery/no-map-util
items = $.map( mw.config.get( 'wgFormattedNamespaces' ), function ( name, ns ) {
if ( ns === '0' ) {
name = mw.message( 'blanknamespace' ).text();
items = $.map( mw.config.get( 'wgFormattedNamespaces' ), function ( name, ns ) {
if ( ns === '0' ) {
name = mw.message( 'blanknamespace' ).text();
@@
-724,37
+724,32
@@
* @return {OO.ui.MenuOptionWidget[]} Each item's data should be an OO.ui.FieldLayout
*/
formatRequest: function ( displayParams, rawParams ) {
* @return {OO.ui.MenuOptionWidget[]} Each item's data should be an OO.ui.FieldLayout
*/
formatRequest: function ( displayParams, rawParams ) {
- var json
Inp
ut,
+ var json
Layo
ut,
items = [
new OO.ui.MenuOptionWidget( {
label: Util.parseMsg( 'apisandbox-request-format-url-label' ),
items = [
new OO.ui.MenuOptionWidget( {
label: Util.parseMsg( 'apisandbox-request-format-url-label' ),
- data: new OO.ui.FieldLayout(
- new OO.ui.TextInputWidget( {
- readOnly: true,
- value: mw.util.wikiScript( 'api' ) + '?' + $.param( displayParams )
- } ), {
- label: Util.parseMsg( 'apisandbox-request-url-label' )
- }
- )
+ data: new mw.widgets.CopyTextLayout( {
+ label: Util.parseMsg( 'apisandbox-request-url-label' ),
+ copyText: mw.util.wikiScript( 'api' ) + '?' + $.param( displayParams )
+ } )
} ),
new OO.ui.MenuOptionWidget( {
label: Util.parseMsg( 'apisandbox-request-format-json-label' ),
} ),
new OO.ui.MenuOptionWidget( {
label: Util.parseMsg( 'apisandbox-request-format-json-label' ),
- data: new OO.ui.FieldLayout(
- jsonInput = new OO.ui.MultilineTextInputWidget( {
+ data: jsonLayout = new mw.widgets.CopyTextLayout( {
+ label: Util.parseMsg( 'apisandbox-request-json-label' ),
+ copyText: JSON.stringify( displayParams, null, '\t' ),
+ multiline: true,
+ textInput: {
classes: [ 'mw-apisandbox-textInputCode' ],
classes: [ 'mw-apisandbox-textInputCode' ],
- readOnly: true,
autosize: true,
autosize: true,
- maxRows: 6,
- value: JSON.stringify( displayParams, null, '\t' )
- } ), {
- label: Util.parseMsg( 'apisandbox-request-json-label' )
+ maxRows: 6
}
}
- ).on( 'toggle', function ( visible ) {
+
}
).on( 'toggle', function ( visible ) {
if ( visible ) {
// Call updatePosition instead of adjustSize
// because the latter has weird caching
// behavior and the former bypasses it.
if ( visible ) {
// Call updatePosition instead of adjustSize
// because the latter has weird caching
// behavior and the former bypasses it.
- jsonInput.updatePosition();
+ json
Layout.text
Input.updatePosition();
}
} )
} )
}
} )
} )
@@
-977,7
+972,6
@@
// OO.ui.ButtonWidget doesn't take focus itself (T128054)
$focus = $( '#mw-apisandbox-ui' ).find( document.activeElement );
if ( $focus.length ) {
// OO.ui.ButtonWidget doesn't take focus itself (T128054)
$focus = $( '#mw-apisandbox-ui' ).find( document.activeElement );
if ( $focus.length ) {
- // eslint-disable-next-line jquery/no-event-shorthand
$focus[ 0 ].blur();
}
$focus[ 0 ].blur();
}
@@
-1600,7
+1594,7
@@
}
toRemove = {};
}
toRemove = {};
- // eslint-disable-next-line jquery/no-each-util
+ // eslint-disable-next-line
no-
jquery/no-each-util
$.each( this.templatedItemsCache, function ( k, el ) {
if ( el.widget.isElementAttached() ) {
toRemove[ k ] = el;
$.each( this.templatedItemsCache, function ( k, el ) {
if ( el.widget.isElementAttached() ) {
toRemove[ k ] = el;
@@
-1689,7
+1683,7
@@
}
} else {
newVars = {};
}
} else {
newVars = {};
- // eslint-disable-next-line jquery/no-each-util
+ // eslint-disable-next-line
no-
jquery/no-each-util
$.each( p.vars, function ( k, v ) {
newVars[ k ] = v.replace( placeholder, value );
} );
$.each( p.vars, function ( k, v ) {
newVars[ k ] = v.replace( placeholder, value );
} );
@@
-1705,11
+1699,11
@@
};
while ( toProcess.length ) {
p = toProcess.shift();
};
while ( toProcess.length ) {
p = toProcess.shift();
- // eslint-disable-next-line jquery/no-each-util
+ // eslint-disable-next-line
no-
jquery/no-each-util
$.each( p.vars, doProcess );
}
$.each( p.vars, doProcess );
}
- // eslint-disable-next-line jquery/no-map-util
+ // eslint-disable-next-line
no-
jquery/no-map-util
toRemove = $.map( toRemove, function ( el, name ) {
delete that.widgets[ name ];
return [ el.widgetField, el.helpField ];
toRemove = $.map( toRemove, function ( el, name ) {
delete that.widgets[ name ];
return [ el.widgetField, el.helpField ];
@@
-1944,7
+1938,6
@@
}
that.deprecatedItemsFieldset = new OO.ui.FieldsetLayout().addItems( deprecatedItems ).toggle( false );
}
that.deprecatedItemsFieldset = new OO.ui.FieldsetLayout().addItems( deprecatedItems ).toggle( false );
- // eslint-disable-next-line jquery/no-animate-toggle
tmp = $( '<fieldset>' )
.toggle( !that.deprecatedItemsFieldset.isEmpty() )
.append(
tmp = $( '<fieldset>' )
.toggle( !that.deprecatedItemsFieldset.isEmpty() )
.append(
@@
-2002,7
+1995,7
@@
if ( this.paramInfo === null ) {
return [];
} else {
if ( this.paramInfo === null ) {
return [];
} else {
- // eslint-disable-next-line jquery/no-map-util
+ // eslint-disable-next-line
no-
jquery/no-map-util
promises = $.map( this.widgets, function ( widget ) {
return widget.apiCheckValid();
} );
promises = $.map( this.widgets, function ( widget ) {
return widget.apiCheckValid();
} );
@@
-2028,7
+2021,7
@@
if ( this.paramInfo === null ) {
this.loadFromQueryParams = params;
} else {
if ( this.paramInfo === null ) {
this.loadFromQueryParams = params;
} else {
- // eslint-disable-next-line jquery/no-each-util
+ // eslint-disable-next-line
no-
jquery/no-each-util
$.each( this.widgets, function ( name, widget ) {
var v = Object.prototype.hasOwnProperty.call( params, name ) ? params[ name ] : undefined;
widget.setApiValue( v );
$.each( this.widgets, function ( name, widget ) {
var v = Object.prototype.hasOwnProperty.call( params, name ) ? params[ name ] : undefined;
widget.setApiValue( v );
@@
-2044,7
+2037,7
@@
* @param {Object} displayParams Write query parameters for display into this object
*/
ApiSandbox.PageLayout.prototype.getQueryParams = function ( params, displayParams ) {
* @param {Object} displayParams Write query parameters for display into this object
*/
ApiSandbox.PageLayout.prototype.getQueryParams = function ( params, displayParams ) {
- // eslint-disable-next-line jquery/no-each-util
+ // eslint-disable-next-line
no-
jquery/no-each-util
$.each( this.widgets, function ( name, widget ) {
var value = widget.getApiValue();
if ( value !== undefined ) {
$.each( this.widgets, function ( name, widget ) {
var value = widget.getApiValue();
if ( value !== undefined ) {
@@
-2064,7
+2057,7
@@
*/
ApiSandbox.PageLayout.prototype.getSubpages = function () {
var ret = [];
*/
ApiSandbox.PageLayout.prototype.getSubpages = function () {
var ret = [];
- // eslint-disable-next-line jquery/no-each-util
+ // eslint-disable-next-line
no-
jquery/no-each-util
$.each( this.widgets, function ( name, widget ) {
var submodules, i;
if ( typeof widget.getSubmodules === 'function' ) {
$.each( this.widgets, function ( name, widget ) {
var submodules, i;
if ( typeof widget.getSubmodules === 'function' ) {