r105902 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105901‎ | r105902 | r105903 >
Date:17:10, 12 December 2011
Author:maxsem
Status:ok
Tags:
Comment:
ApiSandbox: made form submittable with enter
Modified paths:
  • /trunk/extensions/ApiSandbox/SpecialApiSandbox.php (modified) (history)
  • /trunk/extensions/ApiSandbox/ext.apiSandbox.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ApiSandbox/SpecialApiSandbox.php
@@ -32,7 +32,8 @@
3333 $out->addHTML( '<noscript>' . wfMessage( 'apisb-no-js' )->parse() . '</noscript>
3434 <div id="api-sandbox-content" style="display: none">' );
3535 $out->addWikiMsg( 'apisb-intro' );
36 - $out->addHTML( $this->openFieldset( 'parameters' )
 36+ $out->addHTML( '<form id="api-sandbox-form">'
 37+ . $this->openFieldset( 'parameters' )
3738 . $this->getInputs()
3839 . '</fieldset>'
3940 . $this->openFieldset( 'result' )
@@ -48,7 +49,7 @@
4950 '
5051 . '<tr><td colspan="2"><div id="api-sandbox-output"></div></td></tr>'
5152 . "\n</tbody></table>"
52 - . "\n</fieldset>" );
 53+ . "\n</fieldset>\n</form>" );
5354
5455 $out->addHTML( "\n</div>" ); # <div id="api-sandbox-content">
5556 }
@@ -103,7 +104,7 @@
104105
105106 $s .= Html::element( 'input',
106107 array(
107 - 'type' => 'button',
 108+ 'type' => 'submit',
108109 'id' => 'api-sandbox-submit',
109110 'value' => wfMessage( 'apisb-submit' )->text(),
110111 'disabled' => 'disabled',
Index: trunk/extensions/ApiSandbox/ext.apiSandbox.js
@@ -225,7 +225,12 @@
226226 }
227227 } );
228228
229 - $submit.click( function() {
 229+
 230+ $( '#api-sandbox-form' ).submit( function( e ) {
 231+ e.preventDefault();
 232+ if ( !$submit.is( ':enabled' ) ) {
 233+ return;
 234+ }
230235 var url = mw.util.wikiScript( 'api' ) + '?action=' + $action.val(),
231236 params = mainRequest.getRequestData(),
232237 mustBePosted = isset( mainRequest.info.mustbeposted );

Follow-up revisions

RevisionCommit summaryAuthorDate
r107976MFT r104971, r105275, r105902reedy00:44, 4 January 2012

Status & tagging log