jenkins-bot has submitted this change and it was merged. 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, 84 insertions(+), 90 deletions(-) Approvals: Brion VIBBER: Looks good to me, approved Jforrester: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php index 94b6f82..d290bf7 100644 --- a/TimedMediaHandler.hooks.php +++ b/TimedMediaHandler.hooks.php @@ -102,14 +102,16 @@ 'styles' => 'resources/transcodeTable.css', 'dependencies' => array( 'mediawiki.api.edit', - 'mw.MwEmbedSupport', + 'oojs-ui', ), 'messages'=> array( - 'mwe-ok', - 'mwe-cancel', + 'timedmedia-reset-button-cancel', + 'timedmedia-reset-button-dismiss', + 'timedmedia-reset-button-reset', 'timedmedia-reset-error', 'timedmedia-reset', - 'timedmedia-reset-confirm' + 'timedmedia-reset-areyousure', + 'timedmedia-reset-explanation', ) ), 'ext.tmh.TimedTextSelector' => $baseExtensionResource + array( diff --git a/i18n/en.json b/i18n/en.json index 239276f..038260e 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -51,8 +51,12 @@ "timedmedia-minutes": "{{PLURAL:$1|1 minute|$1 minutes}}", "timedmedia-seconds": "{{PLURAL:$1|1 second|$1 seconds}}", "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-areyousure": "Are you sure you want to proceed?", + "timedmedia-reset-button-cancel": "Don't reset", + "timedmedia-reset-button-dismiss": "Dismiss", + "timedmedia-reset-button-reset": "Reset", "timedmedia-reset-error": "Error in resetting transcode job.", + "timedmedia-reset-explanation": "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.", "timedmedia-ogg": "Ogg", "timedmedia-webm": "WebM", "timedmedia-mp4": "MP4", diff --git a/i18n/qqq.json b/i18n/qqq.json index 86b0ce4..97454cf 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -68,9 +68,13 @@ "timedmedia-hours": "Used as the duration, as <code>$1</code> in the following messages:\n* {{msg-mw|Timedmedia-in-job-queue}}\n* {{msg-mw|Timedmedia-started-transcode}}\nParameters:\n* $1 - number of hours\n{{Related|Timedmedia-days}}\n{{Identical|Hour}}", "timedmedia-minutes": "Used as the duration, as <code>$1</code> in the following messages:\n* {{msg-mw|Timedmedia-in-job-queue}}\n* {{msg-mw|Timedmedia-started-transcode}}\nParameters:\n* $1 - minutes\n{{Related|Timedmedia-days}}\n{{Identical|Minute}}", "timedmedia-seconds": "Used as the duration, as <code>$1</code> in the following messages:\n* {{msg-mw|Timedmedia-in-job-queue}}\n* {{msg-mw|Timedmedia-started-transcode}}\nParameters:\n* $1 - number of seconds\n{{Related|Timedmedia-days}}\n{{Identical|Second}}", - "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": "Used as action link text and as dialog title.\n\nThe contents of the dialog are {{msg-mw|Timedmedia-reset-explanation}} and {{msg-mw|Timedmedia-reset-areyousure}}.", + "timedmedia-reset-areyousure": "Used as the last confirmation request in the dialog which has the title {{msg-mw|Timedmedia-reset}}.", + "timedmedia-reset-button-dismiss": "Dismiss button in error dialog presented when transcode request fails.", + "timedmedia-reset-button-reset": "Button in reset dialog to approve new transcode.", + "timedmedia-reset-button-cancel": "Button in reset dialog to cancel reset request to transcode.", "timedmedia-reset-error": "Used as generic error message.", + "timedmedia-reset-explanation": "Explains the consequence of resetting in the dialog which has the title {{msg-mw|Timedmedia-reset}}.", "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..d510041 100644 --- a/resources/ext.tmh.transcodetable.js +++ b/resources/ext.tmh.transcodetable.js @@ -1,90 +1,74 @@ -/** +/*! * 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: $( [ + document.createTextNode( mw.msg( 'timedmedia-reset-explanation' ) ), + document.createElement( 'br' ), + document.createElement( 'br' ), + document.createTextNode( mw.msg( 'timedmedia-reset-areyousure' ) ) + ] ), + actions: [ + { + action: 'reset', + label: mw.msg( 'timedmedia-reset-button-reset' ), + flags: [ 'primary', 'destructive' ] + }, + { + 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 === 'reset' ) { + 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-dismiss' ), + 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: merged Gerrit-Change-Id: I34db07da2173123b43c7168e390925f59a864ff2 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: TheDJ <hartman.w...@gmail.com> Gerrit-Reviewer: Bartosz DziewoĆski <matma....@gmail.com> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: TheDJ <hartman.w...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits