TheDJ has uploaded a new change for review.
https://gerrit.wikimedia.org/r/249397
Change subject: Convert ext.tmh.transcodetable to OOjs UI
......................................................................
Convert ext.tmh.transcodetable to OOjs UI
Bug: T116867
Change-Id: I34db07da2173123b43c7168e390925f59a864ff2
---
M TimedMediaHandler.hooks.php
M i18n/en.json
M i18n/qqq.json
M resources/ext.tmh.transcodetable.js
4 files changed, 69 insertions(+), 86 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler
refs/changes/97/249397/1
diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php
index 94b6f82..ac0846f 100644
--- a/TimedMediaHandler.hooks.php
+++ b/TimedMediaHandler.hooks.php
@@ -102,11 +102,11 @@
'styles' => 'resources/transcodeTable.css',
'dependencies' => array(
'mediawiki.api.edit',
- 'mw.MwEmbedSupport',
+ 'oojs-ui',
),
'messages'=> array(
- 'mwe-ok',
- 'mwe-cancel',
+ 'timedmedia-reset-button-confirm',
+ 'timedmedia-reset-button-cancel',
'timedmedia-reset-error',
'timedmedia-reset',
'timedmedia-reset-confirm'
diff --git a/i18n/en.json b/i18n/en.json
index 239276f..199b81e 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -53,6 +53,8 @@
"timedmedia-reset": "Reset transcode",
"timedmedia-reset-confirm": "Resetting this transcode will remove any
existing file (if present), and it will re-add the transcode to the job queue.
It will take some time to re-transcode.<br /><br />\nAre you sure you want to
proceed?",
"timedmedia-reset-error": "Error in resetting transcode job.",
+ "timedmedia-reset-button-ok": "OK",
+ "timedmedia-reset-button-cancel": "Cancel",
"timedmedia-ogg": "Ogg",
"timedmedia-webm": "WebM",
"timedmedia-mp4": "MP4",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 86b0ce4..eba232e 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -71,6 +71,8 @@
"timedmedia-reset": "Used as action link text and as dialog
title.\n\nThe contents of the dialog is {{msg-mw|Timedmedia-reset-confirm}}.",
"timedmedia-reset-confirm": "Used as confirmation message in the dialog
which has the title {{msg-mw|Timedmedia-reset}}.",
"timedmedia-reset-error": "Used as generic error message.",
+ "timedmedia-reset-button-ok": "OK button in dialog to start transcode.",
+ "timedmedia-reset-button-cancel": "Cancel button in dialog to start
transcode.",
"timedmedia-ogg": "{{optional}}\nUsed as <code>$1</code> in the
following messages:\n* {{msg-mw|Timedmedia-source-audio-file-desc}}\n*
{{msg-mw|Timedmedia-source-file-desc}}\n* {{msg-mw|Timedmedia-source-file}}",
"timedmedia-webm": "{{optional}}\nUsed as <code>$1</code> in the
following messages:\n* {{msg-mw|Timedmedia-source-audio-file-desc}}\n*
{{msg-mw|Timedmedia-source-file-desc}}\n* {{msg-mw|Timedmedia-source-file}}",
"timedmedia-mp4": "{{Optional}}\nUsed as <code>$1</code> in the
following messages:\n* {{msg-mw|Timedmedia-source-audio-file-desc}}\n*
{{msg-mw|Timedmedia-source-file-desc}}\n* {{msg-mw|Timedmedia-source-file}}",
diff --git a/resources/ext.tmh.transcodetable.js
b/resources/ext.tmh.transcodetable.js
index a8c8f98..ed43adf 100644
--- a/resources/ext.tmh.transcodetable.js
+++ b/resources/ext.tmh.transcodetable.js
@@ -1,90 +1,69 @@
-/**
+/*!
* Javascript to support transcode table on image page
*/
-( function ( mw, $ ) {
+/*global OO*/
+( function ( mw, $, OO ) {
$( document ).ready( function () {
- var errorPopup, $errorLink;
+ function errorPopup( event ) {
+ var tKey = $( event.target ).attr( 'data-transcodekey'
),
+ messageDialog = new OO.ui.MessageDialog(),
+ windowManager = new OO.ui.WindowManager();
- errorPopup = function () {
- // pop up dialog
- mw.addDialog( {
- 'width': '640',
- 'height': '480',
- 'title': $(this).attr( 'title' ),
- 'content': $('<textarea />')
- .css( {
- 'width':'99%',
- 'height':'99%'
- } )
- .text( $(this).attr('data-error') )
- } )
- .css( 'overflow', 'hidden' );
- return false;
- };
+ event.preventDefault();
+ $( 'body' ).append( windowManager.$element );
+ windowManager.addWindows( [ messageDialog ] );
- // Old version. Need to keep for a little while in case of
cached pages.
- $( '.mw-filepage-transcodestatus .errorlink' ).click(
errorPopup );
- // New version.
- $errorLink = $( '.mw-filepage-transcodestatus
.mw-tmh-pseudo-error-link' );
- $errorLink.wrapInner( function () {
- var $this = $( this );
- return $( '<a />' ).attr( {
- href: '#',
- title: $this.text(),
- 'data-error': $this.attr( 'data-error' )
- } ).click( errorPopup );
- } );
-
- // Reset transcode action:
- $( '.mw-filepage-transcodereset a' ).click( function () {
- var tKey = $( this ).attr( 'data-transcodekey' ),
- buttons = {};
-
- buttons[ mw.msg( 'mwe-ok' ) ] = function () {
- var api,
- _thisDialog = this,
- cancelBtn = {};
-
- // Only show cancel button while loading:
- cancelBtn[ mw.msg( 'mwe-cancel' ) ] = function
() {
- $(this).dialog( 'close' );
- };
- $( _thisDialog ).dialog( 'option', 'buttons',
cancelBtn );
-
- $( this ).loadingSpinner();
-
- api = new mw.Api();
- api.postWithEditToken( {
- 'action' : 'transcodereset',
- 'transcodekey' : tKey,
- 'title' : mw.config.get('wgPageName')
- } ).done( function () {
- // Refresh the page
- location.reload();
- } ).fail( function ( code, data ) {
- if( data.error && data.error.info ){
- $( _thisDialog ).text(
data.error.info );
- } else {
- $( _thisDialog ).text( mw.msg(
'timedmedia-reset-error' ) );
+ // Configure the message dialog when it is opened with
the window manager's openWindow() method.
+ windowManager.openWindow( messageDialog, {
+ title: mw.msg( 'timedmedia-reset' ),
+ message: mw.message( 'timedmedia-reset-confirm'
).plain(),
+ actions: [
+ {
+ action: 'ok',
+ label: mw.msg(
'timedmedia-reset-button-ok' ),
+ flags: 'primary'
+ },
+ {
+ action: 'cancel',
+ label: mw.msg(
'timedmedia-reset-button-cancel' ),
+ flags: 'safe'
}
- var okBtn = {};
- okBtn[ mw.msg('mwe-ok') ] = function()
{ $(this).dialog( 'close' ); };
- $( _thisDialog ).dialog( 'option',
'buttons', okBtn );
+ ]
+ } ).then( function ( opened ) {
+ opened.then( function ( closing, data ) {
+ var api;
+ if ( data && data.action === 'ok' ) {
+ api = new mw.Api();
+ api.postWithEditToken( {
+ action:
'transcodereset',
+ transcodekey: tKey,
+ title: mw.config.get(
'wgPageName' )
+ } ).done( function () {
+ // Refresh the page
+ location.reload();
+ } ).fail( function ( code, data
) {
+ var errorText;
+ if ( data.error &&
data.error.info ) {
+ errorText =
data.error.info;
+ } else {
+ errorText =
mw.msg( 'timedmedia-reset-error' );
+ }
+
windowManager.openWindow( messageDialog, {
+ message:
errorText,
+ actions: [
+ {
+
action: 'ok',
+
label: mw.msg( 'timedmedia-reset-button-cancel' ),
+
flags: 'safe'
+ }
+ ]
+ } );
+ } );
+ }
} );
- };
- buttons[ mw.msg( 'mwe-cancel' ) ] = function () {
- $( this ).dialog( 'close' );
- };
- // pop up dialog
- mw.addDialog( {
- 'width': '400',
- 'height': '200',
- 'title': mw.msg( 'timedmedia-reset' ),
- 'content': mw.msg( 'timedmedia-reset-confirm' ),
- 'buttons': buttons
- } )
- .css( 'overflow', 'hidden' );
- return false;
- });
- });
-} )( mediaWiki, jQuery );
+ } );
+ }
+
+ $( '.mw-filepage-transcodereset a' ).click( errorPopup );
+ } );
+} )( mediaWiki, jQuery, OO );
--
To view, visit https://gerrit.wikimedia.org/r/249397
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I34db07da2173123b43c7168e390925f59a864ff2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: TheDJ <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits