X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.special%2Fmediawiki.special.apisandbox.js;h=0df51f4d71dcfae27a18d57ae1af6b2f2e2930f2;hb=8fd5a99f4e261d37cd7237a1992b1bcf03a764d3;hp=ff4335ae5274cea196a2bc50cb405cc9a29e0a19;hpb=b063a5bce2fd8e97e11fc1359d4e624d3fa5f480;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js index ff4335ae52..0df51f4d71 100644 --- a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js +++ b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js @@ -121,9 +121,9 @@ } }, - capsuleWidget: { + tagWidget: { getApiValue: function () { - var items = this.getItemsData(); + var items = this.getValue(); if ( items.join( '' ).indexOf( '|' ) === -1 ) { return items.join( '|' ); } else { @@ -132,13 +132,13 @@ }, setApiValue: function ( v ) { if ( v === undefined || v === '' || v === '\x1f' ) { - this.setItemsFromData( [] ); + this.setValue( [] ); } else { v = String( v ); if ( v.indexOf( '\x1f' ) !== 0 ) { - this.setItemsFromData( v.split( '|' ) ); + this.setValue( v.split( '|' ) ); } else { - this.setItemsFromData( v.substr( 1 ).split( '\x1f' ) ); + this.setValue( v.substr( 1 ).split( '\x1f' ) ); } } }, @@ -149,8 +149,8 @@ if ( !suppressErrors ) { ok = this.getApiValue() !== undefined && !( pi.allspecifier !== undefined && - this.getItemsData().length > 1 && - this.getItemsData().indexOf( pi.allspecifier ) !== -1 + this.getValue().length > 1 && + this.getValue().indexOf( pi.allspecifier ) !== -1 ); } @@ -158,8 +158,8 @@ this.setIconTitle( ok ? '' : mw.message( 'apisandbox-alert-field' ).plain() ); return $.Deferred().resolve( ok ).promise(); }, - createItemWidget: function ( data, label ) { - var item = OO.ui.CapsuleMultiselectWidget.prototype.createItemWidget.call( this, data, label ); + createTagItemWidget: function ( data, label ) { + var item = OO.ui.TagMultiselectWidget.prototype.createTagItemWidget.call( this, data, label ); if ( this.paramInfo.deprecatedvalues && this.paramInfo.deprecatedvalues.indexOf( data ) >= 0 ) { @@ -336,13 +336,13 @@ case 'string': case 'user': if ( Util.apiBool( pi.multi ) ) { - widget = new OO.ui.CapsuleMultiselectWidget( { + widget = new OO.ui.TagMultiselectWidget( { allowArbitrary: true, allowDuplicates: Util.apiBool( pi.allowsduplicates ), - $overlay: $( '#mw-apisandbox-ui' ) + $overlay: true } ); widget.paramInfo = pi; - $.extend( widget, WidgetMethods.capsuleWidget ); + $.extend( widget, WidgetMethods.tagWidget ); } else { widget = new OO.ui.TextInputWidget( { required: Util.apiBool( pi.required ) @@ -457,16 +457,16 @@ } ) ); } - widget = new OO.ui.CapsuleMultiselectWidget( { + widget = new OO.ui.MenuTagMultiselectWidget( { menu: { items: items }, - $overlay: $( '#mw-apisandbox-ui' ) + $overlay: true } ); widget.paramInfo = pi; - $.extend( widget, WidgetMethods.capsuleWidget ); + $.extend( widget, WidgetMethods.tagWidget ); } else { widget = new OO.ui.DropdownWidget( { menu: { items: items }, - $overlay: $( '#mw-apisandbox-ui' ) + $overlay: true } ); widget.paramInfo = pi; $.extend( widget, WidgetMethods.dropdownWidget ); @@ -497,12 +497,12 @@ } ) ); } - widget = new OO.ui.CapsuleMultiselectWidget( { + widget = new OO.ui.MenuTagMultiselectWidget( { menu: { items: items }, - $overlay: $( '#mw-apisandbox-ui' ) + $overlay: true } ); widget.paramInfo = pi; - $.extend( widget, WidgetMethods.capsuleWidget ); + $.extend( widget, WidgetMethods.tagWidget ); if ( Util.apiBool( pi.submodules ) ) { widget.getSubmodules = WidgetMethods.submoduleWidget.multi; widget.on( 'change', ApiSandbox.updateUI ); @@ -510,7 +510,7 @@ } else { widget = new OO.ui.DropdownWidget( { menu: { items: items }, - $overlay: $( '#mw-apisandbox-ui' ) + $overlay: true } ); widget.paramInfo = pi; $.extend( widget, WidgetMethods.dropdownWidget ); @@ -551,23 +551,23 @@ throw new Error( 'Unknown multiMode "' + multiMode + '"' ); } - widget = new OO.ui.CapsuleMultiselectWidget( { + widget = new OO.ui.PopupTagMultiselectWidget( { allowArbitrary: true, allowDuplicates: Util.apiBool( pi.allowsduplicates ), - $overlay: $( '#mw-apisandbox-ui' ), + $overlay: true, popup: { classes: [ 'mw-apisandbox-popup' ], $content: $content } } ); widget.paramInfo = pi; - $.extend( widget, WidgetMethods.capsuleWidget ); + $.extend( widget, WidgetMethods.tagWidget ); func = function () { if ( !innerWidget.isDisabled() ) { innerWidget.apiCheckValid().done( function ( ok ) { if ( ok ) { - widget.addItemsFromData( [ innerWidget.getApiValue() ] ); + widget.addTag( innerWidget.getApiValue() ); innerWidget.setApiValue( undefined ); } } ); @@ -817,7 +817,7 @@ if ( ApiSandbox.isFullscreen ) { fullscreenButton.setLabel( mw.message( 'apisandbox-unfullscreen' ).text() ); fullscreenButton.setTitle( mw.message( 'apisandbox-unfullscreen-tooltip' ).text() ); - $body.append( $ui ); + OO.ui.getDefaultOverlay().prepend( $ui ); } else { fullscreenButton.setLabel( mw.message( 'apisandbox-fullscreen' ).text() ); fullscreenButton.setTitle( mw.message( 'apisandbox-fullscreen-tooltip' ).text() ); @@ -1051,7 +1051,7 @@ if ( !formatDropdown ) { formatDropdown = new OO.ui.DropdownWidget( { menu: { items: [] }, - $overlay: $( '#mw-apisandbox-ui' ) + $overlay: true } ); formatDropdown.getMenu().on( 'select', Util.onFormatDropdownChange ); } @@ -1074,7 +1074,7 @@ label: Util.parseMsg( 'apisandbox-request-selectformat-label' ) } ).$element, - $.map( formatItems, function ( item ) { + formatItems.map( function ( item ) { return item.getData().$element; } ), $result @@ -1112,7 +1112,7 @@ return xhr; } } ) - .then( null, function ( code, data, result, jqXHR ) { + .catch( function ( code, data, result, jqXHR ) { var deferred = $.Deferred(); if ( code !== 'http' ) { @@ -1176,7 +1176,7 @@ booklet.setPage( '|results|' ); } ).setDisabled( !paramsAreForced ) ).$element, new OO.ui.PopupButtonWidget( { - $overlay: $( '#mw-apisandbox-ui' ), + $overlay: true, framed: false, icon: 'info', popup: { @@ -1420,7 +1420,7 @@ for ( j = 0; j < tmp.length; j++ ) { availableFormats[ tmp[ j ] ] = true; } - pi.parameters[ i ].type = $.grep( tmp, filterFmModules ); + pi.parameters[ i ].type = tmp.filter( filterFmModules ); pi.parameters[ i ][ 'default' ] = 'json'; pi.parameters[ i ].required = true; } @@ -1429,7 +1429,7 @@ // Hide the 'wrappedhtml' parameter on format modules if ( pi.group === 'format' ) { - pi.parameters = $.grep( pi.parameters, function ( p ) { + pi.parameters = pi.parameters.filter( function ( p ) { return p.name !== 'wrappedhtml'; } ); } @@ -1445,13 +1445,13 @@ if ( pi.helpurls.length ) { buttons.push( new OO.ui.PopupButtonWidget( { - $overlay: $( '#mw-apisandbox-ui' ), + $overlay: true, label: mw.message( 'apisandbox-helpurls' ).text(), icon: 'help', popup: { width: 'auto', padded: true, - $content: $( '