mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-27 15:50:29 +00:00
Replace mediawiki.Uri with native URL (easy cases)
Replacing one-off uses in various auxiliary features: only used in function scope (or narrower), nothing else depends on them. Some of them didn't even need to do any URL parsing or formatting. Bug: T325249 Change-Id: Ia9a18656f67cb0a204c87605459abb9f5bbdc347
This commit is contained in:
parent
8f1e9b6089
commit
fd80fae57f
|
@ -308,8 +308,8 @@
|
|||
onImportChange();
|
||||
|
||||
if ( pageTitle ) {
|
||||
var uri = new mw.Uri( location.href ),
|
||||
importTitleText = uri.query.import,
|
||||
var url = new URL( location.href ),
|
||||
importTitleText = url.searchParams.get( 'import' ),
|
||||
importTitleParam = ( importTitleText ? mw.Title.newFromText( importTitleText ) : null );
|
||||
showPage( pageTitle, importTitleParam );
|
||||
} else {
|
||||
|
|
|
@ -167,12 +167,7 @@ ve.ui.MWExportWikitextDialog.prototype.getTeardownProcess = function ( data ) {
|
|||
ve.ui.MWExportWikitextDialog.prototype.export = function () {
|
||||
var wikitext = this.wikitextLayout.textInput.getValue(),
|
||||
title = this.titleInput.getMWTitle(),
|
||||
importTitle = ve.init.target.getImportTitle(),
|
||||
submitUrl = ( new mw.Uri( title.getUrl() ) )
|
||||
.extend( {
|
||||
action: 'submit',
|
||||
veswitched: 1
|
||||
} );
|
||||
importTitle = ve.init.target.getImportTitle();
|
||||
|
||||
var $form = $( '<form>' ).attr( { method: 'post', enctype: 'multipart/form-data' } ).addClass( 'oo-ui-element-hidden' );
|
||||
var params = {
|
||||
|
@ -202,6 +197,10 @@ ve.ui.MWExportWikitextDialog.prototype.export = function () {
|
|||
}
|
||||
// Submit the form, mimicking a traditional edit
|
||||
// Firefox requires the form to be attached
|
||||
var submitUrl = title.getUrl( {
|
||||
action: 'submit',
|
||||
veswitched: '1'
|
||||
} );
|
||||
$form.attr( 'action', submitUrl ).appendTo( 'body' ).trigger( 'submit' );
|
||||
};
|
||||
|
||||
|
|
|
@ -81,11 +81,6 @@ ve.init.mw.ArticleTarget = function VeInitMwArticleTarget( config ) {
|
|||
this.edited = false;
|
||||
this.restoring = !!this.requestedRevId && this.requestedRevId !== this.currentRevisionId;
|
||||
this.pageDeletedWarning = false;
|
||||
this.submitUrl = ( new mw.Uri( mw.util.getUrl( this.getPageName() ) ) )
|
||||
.extend( {
|
||||
action: 'submit',
|
||||
veswitched: 1
|
||||
} );
|
||||
this.events = {
|
||||
track: function () {},
|
||||
trackActivationStart: function () {},
|
||||
|
@ -1637,7 +1632,11 @@ ve.init.mw.ArticleTarget.prototype.submit = function ( wikitext, fields ) {
|
|||
}
|
||||
// Submit the form, mimicking a traditional edit
|
||||
// Firefox requires the form to be attached
|
||||
$form.attr( 'action', this.submitUrl ).appendTo( 'body' ).trigger( 'submit' );
|
||||
var submitUrl = mw.util.getUrl( this.getPageName(), {
|
||||
action: 'submit',
|
||||
veswitched: '1'
|
||||
} );
|
||||
$form.attr( 'action', submitUrl ).appendTo( 'body' ).trigger( 'submit' );
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
saveSuccess: 'save_success',
|
||||
saveFailure: 'save_failure'
|
||||
},
|
||||
trackdebug = !!mw.Uri().query.trackdebug,
|
||||
trackdebug = new URL( location.href ).searchParams.has( 'trackdebug' ),
|
||||
firstInitDone = false;
|
||||
|
||||
function getEditingSessionIdFromRequest() {
|
||||
return mw.config.get( 'wgWMESchemaEditAttemptStepSessionId' ) ||
|
||||
mw.Uri().query.editingStatsId;
|
||||
new URL( location.href ).searchParams.get( 'editingStatsId' );
|
||||
}
|
||||
|
||||
var timing = {};
|
||||
|
|
|
@ -24,20 +24,13 @@
|
|||
// Add modules from $wgVisualEditorPluginModules
|
||||
.concat( conf.pluginModules.filter( mw.loader.getState ) );
|
||||
|
||||
var uri;
|
||||
try {
|
||||
uri = new mw.Uri();
|
||||
} catch ( e ) {
|
||||
// URI may not be parseable (T106244)
|
||||
uri = false;
|
||||
}
|
||||
var url = new URL( location.href );
|
||||
// Provide the new wikitext editor
|
||||
if (
|
||||
uri &&
|
||||
conf.enableWikitext &&
|
||||
(
|
||||
mw.user.options.get( 'visualeditor-newwikitext' ) ||
|
||||
uri.query.veaction === 'editsource'
|
||||
url.searchParams.get( 'veaction' ) === 'editsource'
|
||||
) &&
|
||||
mw.loader.getState( 'ext.visualEditor.mwwikitext' )
|
||||
) {
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
$visualDiffContainer = $( '<div>' ),
|
||||
$visualDiff = $( '<div>' ),
|
||||
progress = new OO.ui.ProgressBarWidget( { classes: [ 've-init-mw-diffPage-loading' ] } ),
|
||||
originalUri = new mw.Uri(),
|
||||
initMode = originalUri.query.diffmode || mw.user.options.get( 'visualeditor-diffmode-historical' ) || 'source',
|
||||
originalUrl = new URL( location.href ),
|
||||
initMode = originalUrl.searchParams.get( 'diffmode' ) || mw.user.options.get( 'visualeditor-diffmode-historical' ) || 'source',
|
||||
conf = mw.config.get( 'wgVisualEditorConfig' ),
|
||||
pluginModules = conf.pluginModules.filter( mw.loader.getState );
|
||||
|
||||
|
@ -29,14 +29,14 @@
|
|||
);
|
||||
|
||||
function onReviewModeButtonSelectSelect( item ) {
|
||||
var uri = new mw.Uri();
|
||||
var url = new URL( location.href );
|
||||
|
||||
var oldPageName, newPageName;
|
||||
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'ComparePages' ) {
|
||||
oldPageName = newPageName = mw.config.get( 'wgRelevantPageName' );
|
||||
} else {
|
||||
oldPageName = uri.query.page1;
|
||||
newPageName = uri.query.page2;
|
||||
oldPageName = url.searchParams.get( 'page1' );
|
||||
newPageName = url.searchParams.get( 'page2' );
|
||||
}
|
||||
|
||||
var mode = item.getData();
|
||||
|
@ -94,8 +94,8 @@
|
|||
} );
|
||||
}
|
||||
|
||||
uri.query.diffmode = mode;
|
||||
history.replaceState( history.state, '', uri );
|
||||
url.searchParams.set( 'diffmode', mode );
|
||||
history.replaceState( history.state, '', url );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ mw.libs.ve.fixFragmentLinks = function ( container, docTitle, prefix ) {
|
|||
Array.prototype.forEach.call( container.querySelectorAll( 'a[href*="#"]' ), function ( el ) {
|
||||
var fragment = null;
|
||||
if ( el.getAttribute( 'href' )[ 0 ] === '#' ) {
|
||||
// Leagcy parser
|
||||
// Legacy parser
|
||||
fragment = el.getAttribute( 'href' ).slice( 1 );
|
||||
} else {
|
||||
// Parsoid HTML
|
||||
|
@ -225,7 +225,7 @@ mw.libs.ve.fixFragmentLinks = function ( container, docTitle, prefix ) {
|
|||
if ( targetData.isInternal ) {
|
||||
var title = mw.Title.newFromText( targetData.title );
|
||||
if ( title && title.getPrefixedText() === docTitleText ) {
|
||||
fragment = new mw.Uri( el.href ).fragment;
|
||||
fragment = new URL( el.href ).hash.slice( 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ ve.ui.MWTocWidget.prototype.build = function () {
|
|||
documentView = surfaceView.getDocument(),
|
||||
lastLevel = 0,
|
||||
stack = [],
|
||||
uri = new mw.Uri();
|
||||
url = new URL( location.href );
|
||||
|
||||
function getItemIndex( $el, n ) {
|
||||
return $el.children( 'li' ).length + ( n === stack.length - 1 ? 1 : 0 );
|
||||
|
@ -194,12 +194,12 @@ ve.ui.MWTocWidget.prototype.build = function () {
|
|||
|
||||
var tocNumber = stack.map( getItemIndex ).join( '.' );
|
||||
var viewNode = documentView.getBranchNodeFromOffset( modelNode.getRange().start );
|
||||
uri.query.section = ( i + 1 ).toString();
|
||||
url.searchParams.set( 'section', ( i + 1 ).toString() );
|
||||
// The following classes are used here:
|
||||
// * toclevel-1, toclevel-2, ...
|
||||
// * tocsection-1, tocsection-2, ...
|
||||
var $item = $( '<li>' ).addClass( 'toclevel-' + stack.length ).addClass( 'tocsection-' + ( i + 1 ) );
|
||||
var $link = $( '<a>' ).attr( 'href', uri ).append(
|
||||
var $link = $( '<a>' ).attr( 'href', url.toString() ).append(
|
||||
$( '<span>' ).addClass( 'tocnumber' ).text( tocNumber )
|
||||
);
|
||||
var $text = $( '<span>' ).addClass( 'toctext' );
|
||||
|
|
Loading…
Reference in a new issue