jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/340168 )
Change subject: Converted alerts, and confirms to OOJSUI ...................................................................... Converted alerts, and confirms to OOJSUI T156304 will need a little bigger refactorisation, so will implement it in parts. Bug: T156304 Change-Id: Id0a2251836d169120fc4bf8ea69c9a91c002056d --- M extension.json M resources/js/Poll.js 2 files changed, 80 insertions(+), 71 deletions(-) Approvals: SamanthaNguyen: Looks good to me, approved jenkins-bot: Verified diff --git a/extension.json b/extension.json index 9d80880..d1f2d85 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "PollNY", - "version": "3.4.2", + "version": "3.4.3", "author": [ "Aaron Wright", "David Pean", @@ -105,7 +105,9 @@ ], "dependencies": [ "ext.socialprofile.flash", - "ext.socialprofile.LightBox" + "ext.socialprofile.LightBox", + "oojs-ui-core", + "oojs-ui-windows" ], "position": "bottom" }, diff --git a/resources/js/Poll.js b/resources/js/Poll.js index fc40518..57800e4 100644 --- a/resources/js/Poll.js +++ b/resources/js/Poll.js @@ -147,7 +147,7 @@ mw.config.get( 'wgCanonicalSpecialPageName' ) == 'CreatePoll' ) { - alert( mw.msg( 'poll-createpoll-error-nomore' ) ); + OO.ui.alert( mw.msg( 'poll-createpoll-error-nomore' ) ); } else { // We have run out of polls to show // Show a lightbox prompting the user to create more polls @@ -169,32 +169,35 @@ */ toggleStatus: function( status ) { var msg; - if( status === 0 ) { - msg = mw.msg( 'poll-close-message' ); - } - if( status == 1 ) { - msg = mw.msg( 'poll-open-message' ); - } - if( status == 2 ) { - msg = mw.msg( 'poll-flagged-message' ); - } - var ask = confirm( msg ); + switch ( status ) { + case 0: + msg = mw.msg( 'poll-close-message' ); + break; + case 1: + msg = mw.msg( 'poll-open-message' ); + break; + case 2: + msg = mw.msg( 'poll-flagged-message' ); + break; + } - if( ask ) { - jQuery.ajax({ - type: 'POST', - url: mw.util.wikiScript( 'api' ), - data: { - action: 'pollny', - what: 'updateStatus', - pollID: document.getElementById( 'poll_id' ).value, - status: status, - format: 'json' - } - } ).done( function() { - window.location.reload(); - } ); - } + OO.ui.confirm( msg ).done( function ( confirmed ) { + if ( confirmed ) { + jQuery.ajax({ + type: 'POST', + url: mw.util.wikiScript( 'api' ), + data: { + action: 'pollny', + what: 'updateStatus', + pollID: document.getElementById( 'poll_id' ).value, + status: status, + format: 'json' + } + } ).done( function() { + window.location.reload(); + } ); + } + } ); }, // Embed poll stuff @@ -275,32 +278,35 @@ */ poll_admin_status: function( id, status ) { var msg; - if( status === 0 ) { - msg = mw.msg( 'poll-close-message' ); + switch ( status ) { + case 0: + msg = mw.msg( 'poll-close-message' ); + break; + case 1: + msg = mw.msg( 'poll-open-message' ); + break; + case 2: + msg = mw.msg( 'poll-flagged-message' ); + break; } - if( status == 1 ) { - msg = mw.msg( 'poll-open-message' ); - } - if( status == 2 ) { - msg = mw.msg( 'poll-flagged-message' ); - } - var ask = confirm( msg ); - if ( ask ) { - jQuery.ajax({ - type: 'POST', - url: mw.util.wikiScript( 'api' ), - data: { - action: 'pollny', - what: 'updateStatus', - pollID: id, - status: status, - format: 'json' - } - } ).done( function() { - jQuery( '#poll-' + id + '-controls' ).html( mw.msg( 'poll-js-action-complete' ) ); - } ); - } + OO.ui.confirm( msg ).done( function ( confirmed ) { + if ( confirmed ) { + jQuery.ajax({ + type: 'POST', + url: mw.util.wikiScript( 'api' ), + data: { + action: 'pollny', + what: 'updateStatus', + pollID: id, + status: status, + format: 'json' + } + } ).done( function() { + jQuery( '#poll-' + id + '-controls' ).html( mw.msg( 'poll-js-action-complete' ) ); + } ); + } + } ); }, /** @@ -310,22 +316,23 @@ */ poll_delete: function( id ) { var msg = mw.msg( 'poll-delete-message' ); - var ask = confirm( msg ); - if ( ask ) { - jQuery.ajax({ - type: 'POST', - url: mw.util.wikiScript( 'api' ), - data: { - action: 'pollny', - what: 'delete', - pollID: id, - format: 'json' - } - } ).done( function() { - jQuery( '#poll-' + id + '-controls' ).html( mw.msg( 'poll-js-action-complete' ) ); - } ); - } + OO.ui.confirm( msg ).done( function ( confirmed ) { + if ( confirmed ) { + jQuery.ajax({ + type: 'POST', + url: mw.util.wikiScript( 'api' ), + data: { + action: 'pollny', + what: 'delete', + pollID: id, + format: 'json' + } + } ).done( function() { + jQuery( '#poll-' + id + '-controls' ).html( mw.msg( 'poll-js-action-complete' ) ); + } ); + } + } ); }, // from Special:CreatePoll UI template @@ -403,18 +410,18 @@ } if( answers < 2 ) { - alert( mw.msg( 'poll-atleast' ) ); + OO.ui.alert( mw.msg( 'poll-atleast' ) ); return ''; } var val = document.getElementById( 'poll_question' ).value; if( !val ) { - alert( mw.msg( 'poll-enterquestion' ) ); + OO.ui.alert( mw.msg( 'poll-enterquestion' ) ); return ''; } if( val.indexOf( '#' ) > -1 ) { - alert( mw.msg( 'poll-hash' ) ); + OO.ui.alert( mw.msg( 'poll-hash' ) ); return ''; } @@ -436,7 +443,7 @@ if ( data.pollny.result == 'OK' ) { document.form1.submit(); } else { - alert( mw.msg( 'poll-pleasechoose' ) ); + OO.ui.alert( mw.msg( 'poll-pleasechoose' ) ); } } ); } -- To view, visit https://gerrit.wikimedia.org/r/340168 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id0a2251836d169120fc4bf8ea69c9a91c002056d Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/extensions/PollNY Gerrit-Branch: master Gerrit-Owner: Filip <r...@protonmail.com> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: SamanthaNguyen <samanthanguyen1...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits