Prtksxna has uploaded a new change for review.
https://gerrit.wikimedia.org/r/246833
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
D modules/ext.urlShortener.popup.less
M modules/ext.urlShortener.toolbar.js
3 files changed, 15 insertions(+), 61 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UrlShortener
refs/changes/33/246833/1
diff --git a/extension.json b/extension.json
index fa28fd1..80820a3 100644
--- a/extension.json
+++ b/extension.json
@@ -71,12 +71,6 @@
"scripts": [
"modules/ext.urlShortener.toolbar.js"
],
- "styles": [
- "modules/ext.urlShortener.popup.less"
- ],
- "dependencies": [
- "oojs-ui"
- ],
"messages": [
"urlshortener-url-input-submitting",
"urlshortener-shortened-url-label",
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..318973a 100644
--- a/modules/ext.urlShortener.toolbar.js
+++ b/modules/ext.urlShortener.toolbar.js
@@ -1,65 +1,29 @@
-( 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' }
- );
+ shortenUrlListItem.empty().append(
+ $( '<input>' ).val(
data.shortenurl.shorturl )
+ );
+ } ).fail( function () {
+ link.text( 'Failed. Try again?' ); // TODO
- showWidget( widget );
- } ).fail( function ( code ) {
- // code will always be urlshortener-ratelimit
- showWidget( new OO.ui.LabelWidget( {
- label: mw.msg( code )
- } ) );
+ // Remove the click listner on the <li>
+ // The link inside points to Special:UrlShortner
+ shortenUrlListItem.off( 'click' );
} );
return false;
} );
-
- $( 'body' ).on( 'click', function () {
- popup.toggle( false );
- } );
} );
-} )( mediaWiki, jQuery, OO );
+} )( mediaWiki, jQuery );
--
To view, visit https://gerrit.wikimedia.org/r/246833
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I013bfc0fd8f69c154e9e42fd41139dad92ca18d5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UrlShortener
Gerrit-Branch: master
Gerrit-Owner: Prtksxna <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits