Samwilson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/405252 )
Change subject: Remove deprecated call, and simplify loading ...................................................................... Remove deprecated call, and simplify loading Remove the use of mw.toolbar, which is deprecated, and replace it with a new method in MsUpload (that does only what it needs to in this situation). Also remove second redundant mw.loader.using( 'ext.wikiEditor' ) and fix up that module's name to the new form. Bug: T185290 Change-Id: I3d99b7ca11173a9aa289359928ae4a44411a8b05 --- M MsUpload.js M extension.json 2 files changed, 22 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MsUpload refs/changes/52/405252/1 diff --git a/MsUpload.js b/MsUpload.js index 8da7a87..2c7d837 100644 --- a/MsUpload.js +++ b/MsUpload.js @@ -17,20 +17,28 @@ galleryArray: [], insertGallery: function () { var galleryText = 'File:' + MsUpload.galleryArray.join( '\nFile:' ); - mw.toolbar.insertTags( '<gallery>\n' + galleryText + '\n</gallery>\n', '', '', '' ); + MsUpload.insertText( '<gallery>\n' + galleryText + '\n</gallery>\n' ); }, filesArray: [], insertFiles: function () { - mw.toolbar.insertTags( '[[File:' + MsUpload.filesArray.join( ']]\n[[File:' ) + ']]\n', '', '', '' ); + MsUpload.insertText( '[[File:' + MsUpload.filesArray.join( ']]\n[[File:' ) + ']]\n' ); }, insertLinks: function () { if ( msuVars.useMsLinks === true ) { - mw.toolbar.insertTags( '*{{#l:' + MsUpload.filesArray.join( '}}\n*{{#l:' ) + '}}\n', '', '', '' ); + MsUpload.insertText( '*{{#l:' + MsUpload.filesArray.join( '}}\n*{{#l:' ) + '}}\n' ); } else { - mw.toolbar.insertTags( '*[[:File:' + MsUpload.filesArray.join( ']]\n*[[:File:' ) + ']]\n', '', '', '' ); + MsUpload.insertText( '*[[:File:' + MsUpload.filesArray.join( ']]\n*[[:File:' ) + ']]\n' ); } + }, + + /** + * Add text to selection in the main textarea. + * @param {string} text + */ + insertText: function ( text ) { + $( '#wpTextbox1' ).textSelection( 'encapsulateSelection', { pre: text } ); }, unconfirmedReplacements: 0, @@ -408,9 +416,9 @@ } $( '<a>' ).text( mw.msg( 'msu-insert-link' ) ).click( function () { if ( msuVars.useMsLinks === true ) { - mw.toolbar.insertTags( '{{#l:' + file.name + '}}', '', '', '' ); // Insert link + MsUpload.insertText( '{{#l:' + file.name + '}}' ); // Insert link } else { - mw.toolbar.insertTags( '[[:File:' + file.name + ']]', '', '', '' ); // Insert link + MsUpload.insertText( '[[:File:' + file.name + ']]' ); // Insert link } } ).appendTo( file.li ); if ( file.group === 'image' ) { @@ -420,12 +428,12 @@ } $( '<span>' ).text( ' | ' ).appendTo( file.li ); $( '<a>' ).text( mw.msg( 'msu-insert-image' ) ).click( function () { - mw.toolbar.insertTags( '[[File:' + file.name + msuVars.imgParams + ']]', '', '', '' ); + MsUpload.insertText( '[[File:' + file.name + msuVars.imgParams + ']]' ); } ).appendTo( file.li ); } else if ( file.group === 'video' ) { $( '<span>' ).text( ' | ' ).appendTo( file.li ); $( '<a>' ).text( mw.msg( 'msu-insert-video' ) ).click( function () { - mw.toolbar.insertTags( '[[File:' + file.name + ']]', '', '', '' ); + MsUpload.insertText( '[[File:' + file.name + ']]' ); } ).appendTo( file.li ); } MsUpload.filesArray.push( file.name ); @@ -489,11 +497,8 @@ if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) { mw.loader.using( 'user.options', function () { if ( mw.user.options.get( 'usebetatoolbar' ) ) { - mw.loader.using( 'ext.wikiEditor.toolbar', function () { - $.when( - mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready - ).then( MsUpload.createUploader ); - } ); + $.when( mw.loader.using( 'ext.wikiEditor' ), $.ready ) + .then( MsUpload.createUploader ); } } ); } diff --git a/extension.json b/extension.json index 6bae05b..dfd4440 100644 --- a/extension.json +++ b/extension.json @@ -24,7 +24,10 @@ "plupload/plupload.full.min.js", "MsUpload.js" ], - "dependencies": "jquery.ui.progressbar", + "dependencies": [ + "jquery.ui.progressbar", + "ext.wikiEditor" + ], "styles": "MsUpload.css", "messages": [ "msu-button-title", -- To view, visit https://gerrit.wikimedia.org/r/405252 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3d99b7ca11173a9aa289359928ae4a44411a8b05 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MsUpload Gerrit-Branch: master Gerrit-Owner: Samwilson <s...@samwilson.id.au> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits