jenkins-bot has submitted this change and it was merged.
Change subject: ext.urlShortener.toolbar: Remove dependency on OOjs UI
......................................................................
ext.urlShortener.toolbar: Remove dependency on OOjs UI
Bug: T112680
Change-Id: I013bfc0fd8f69c154e9e42fd41139dad92ca18d5
---
M extension.json
M i18n/en.json
M i18n/qqq.json
D modules/ext.urlShortener.popup.less
M modules/ext.urlShortener.toolbar.js
A modules/ext.urlShortener.toolbar.less
6 files changed, 26 insertions(+), 62 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extension.json b/extension.json
index fa28fd1..78fef83 100644
--- a/extension.json
+++ b/extension.json
@@ -72,13 +72,11 @@
"modules/ext.urlShortener.toolbar.js"
],
"styles": [
- "modules/ext.urlShortener.popup.less"
- ],
- "dependencies": [
- "oojs-ui"
+ "modules/ext.urlShortener.toolbar.less"
],
"messages": [
"urlshortener-url-input-submitting",
+ "urlshortener-failed-try-again",
"urlshortener-shortened-url-label",
"urlshortener-ratelimit"
]
diff --git a/i18n/en.json b/i18n/en.json
index 84c7cda..240167d 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -19,5 +19,6 @@
"urlshortener-ratelimit": "Please wait some time before shortening more
URLs.",
"urlshortener-toolbox": "Get shortened URL",
"urlshortener-error-badports": "URLs that contain ports are not allowed
to be shortened",
- "urlshortener-error-nouserpass": "URLs that contain a username or
password are not allowed to be shortened"
+ "urlshortener-error-nouserpass": "URLs that contain a username or
password are not allowed to be shortened",
+ "urlshortener-failed-try-again": "Failed. Try again?"
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 39edd3e..9af1f88 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -20,5 +20,6 @@
"urlshortener-ratelimit": "Error message shown when a user shortens too
many urls in a short period of time",
"urlshortener-toolbox": "Text of link in toolbox to get shortened URL",
"urlshortener-error-badports": "Error message shown when the URL cannot
be shortened because it contains a port (e.g. http://example.org:90/path)",
- "urlshortener-error-nouserpass": "Error message shown when the URL
cannot be shortened because it contains a username or password (e.g.
http://user:[email protected]/)"
+ "urlshortener-error-nouserpass": "Error message shown when the URL
cannot be shortened because it contains a username or password (e.g.
http://user:[email protected]/)",
+ "urlshortener-failed-try-again": "Generic failure message with option
to try again"
}
diff --git a/modules/ext.urlShortener.popup.less
b/modules/ext.urlShortener.popup.less
deleted file mode 100644
index c674357..0000000
--- a/modules/ext.urlShortener.popup.less
+++ /dev/null
@@ -1,4 +0,0 @@
-.ext-urlshortener-popup {
- left: 100px;
- z-index: 3; // Monobook puts #content at 2
-}
\ No newline at end of file
diff --git a/modules/ext.urlShortener.toolbar.js
b/modules/ext.urlShortener.toolbar.js
index 07d921b..42bac98 100644
--- a/modules/ext.urlShortener.toolbar.js
+++ b/modules/ext.urlShortener.toolbar.js
@@ -1,65 +1,30 @@
-( function ( mw, $, OO ) {
+( function ( mw, $ ) {
$( function () {
- var popup,
- popupLink = $( '#t-urlshortener' ),
- POPUP_WIDTH = 300,
- POPUP_HEIGHT = 50,
- api = new mw.Api(),
- progress = new OO.ui.ProgressBarWidget(),
- fieldset = new OO.ui.FieldsetLayout();
+ var shortenUrlListItem = $( '#t-urlshortener' ),
+ api = new mw.Api();
- fieldset.addItems( [
- new OO.ui.FieldLayout( progress,
- { label: mw.msg(
'urlshortener-url-input-submitting' ), align: 'top' }
- )
- ] );
+ shortenUrlListItem.on( 'click', function () {
+ var link = $( this ).find( 'a' );
+ link.text( mw.msg( 'urlshortener-url-input-submitting'
) );
- /**
- * @param {OO.ui.Widget} widget
- */
- function showWidget( widget ) {
- popup.setSize( POPUP_WIDTH, POPUP_HEIGHT + 50, true );
- fieldset.clearItems();
- fieldset.addItems( [ widget ] );
- }
-
- popup = new OO.ui.PopupWidget( {
- $content: fieldset.$element,
- padded: true,
- height: POPUP_HEIGHT,
- width: POPUP_WIDTH,
- classes: [ 'ext-urlshortener-popup' ]
- } );
-
- popupLink.after( popup.$element );
- popupLink.on( 'click', function () {
- popup.toggle( true );
api.post( {
action: 'shortenurl',
url: window.location.href
} ).done( function ( data ) {
- var input = new OO.ui.TextInputWidget( {
- value: data.shortenurl.shorturl,
- autofocus: true
- } ),
- widget = new OO.ui.FieldLayout( input,
- { label: mw.msg(
'urlshortener-shortened-url-label' ), align: 'top' }
- );
-
- showWidget( widget );
- } ).fail( function ( code ) {
- // code will always be urlshortener-ratelimit
- showWidget( new OO.ui.LabelWidget( {
- label: mw.msg( code )
- } ) );
+ var $input = $( '<input>' ).val(
data.shortenurl.shorturl );
+ shortenUrlListItem.empty().append( $input );
+ $input.focus().select();
+ } ).fail( function () {
+ link.text( mw.msg(
'urlshortener-failed-try-again' ) );
+ } ).always( function () {
+ // Remove the click listner on the <li>
+ // On failure: the link inside points to
Special:UrlShortener
+ // On success: don't trigger the API request
every time the input is clicked
+ shortenUrlListItem.off( 'click' );
} );
return false;
} );
-
- $( 'body' ).on( 'click', function () {
- popup.toggle( false );
- } );
} );
-} )( mediaWiki, jQuery, OO );
+} )( mediaWiki, jQuery );
diff --git a/modules/ext.urlShortener.toolbar.less
b/modules/ext.urlShortener.toolbar.less
new file mode 100644
index 0000000..3606123
--- /dev/null
+++ b/modules/ext.urlShortener.toolbar.less
@@ -0,0 +1,3 @@
+#t-urlshortener input {
+ width: 100%;
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/246833
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I013bfc0fd8f69c154e9e42fd41139dad92ca18d5
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/UrlShortener
Gerrit-Branch: master
Gerrit-Owner: Prtksxna <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Prtksxna <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits