Index: trunk/extensions/Translate/resources/ext.translate.special.translate.js |
— | — | @@ -0,0 +1,47 @@ |
| 2 | +jQuery( document ).ready( function( $ ) { |
| 3 | + var $submit = $( "input#mw-translate-workflowset" ); |
| 4 | + var $select = $( "#mw-sp-translate-workflow select" ); |
| 5 | + $select.find( "option[value=]" ).attr( "disabled", "disabled" ); |
| 6 | + |
| 7 | + var submitFunction = function( event ) { |
| 8 | + var successFunction = function( data, textStatus ) { |
| 9 | + if ( data.error ) { |
| 10 | + $submit.val( mw.msg( "translate-workflow-set-do" ) ); |
| 11 | + $submit.attr( "disabled", false ); |
| 12 | + alert( data.error.info ); |
| 13 | + } else { |
| 14 | + $submit.val( mw.msg( "translate-workflow-set-done" ) ); |
| 15 | + $select.find( "option[selected]" ).attr( "selected", false ); |
| 16 | + $select.find( "option[value=" + event.data.newstate +"]" ).attr( "selected", "selected" ); |
| 17 | + } |
| 18 | + } |
| 19 | + |
| 20 | + $submit.attr( "disabled", "disable" ); |
| 21 | + $submit.val( mw.msg( "translate-workflow-set-doing" ) ); |
| 22 | + var params = { |
| 23 | + action: "groupreview", |
| 24 | + token: $submit.data( "token" ), |
| 25 | + group: $submit.data( "group" ), |
| 26 | + language: $submit.data( "language" ), |
| 27 | + state: event.data.newstate, |
| 28 | + format: "json" |
| 29 | + }; |
| 30 | + $.post( mw.util.wikiScript( "api" ), params, successFunction ); |
| 31 | + }; |
| 32 | + |
| 33 | + $select.change( function( event ) { |
| 34 | + var current = $(this).find( "option[selected]" ).val(); |
| 35 | + var tobe = event.target.value; |
| 36 | + |
| 37 | + $submit.val( mw.msg( "translate-workflow-set-do" ) ); |
| 38 | + if ( current !== tobe ) { |
| 39 | + $submit.css( "visibility", "visible" ); |
| 40 | + $submit.attr( "disabled", false ); |
| 41 | + $submit.click( { newstate: tobe }, submitFunction ); |
| 42 | + } else { |
| 43 | + $submit.attr( "disabled", "disabled" ); |
| 44 | + $submit.unbind( "click" ); |
| 45 | + } |
| 46 | + |
| 47 | + } ); |
| 48 | +} ); |
Property changes on: trunk/extensions/Translate/resources/ext.translate.special.translate.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 49 | + native |