r109785 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109784‎ | r109785 | r109786 >
Date:00:54, 23 January 2012
Author:krinkle
Status:ok (Comments)
Tags:
Comment:
[ApiSandbox] fix regression from r109726 in some browsers
* Use px with px instead of mixed with em. With table cell layout constrains and overflows peaking out of cells, better fix the dimensions with px
* Remove unneeded overflow:auto on <td>
* Make example/clear button not submit buttons, otherwise $form.submit() is triggered
* Use $.inArray instead of Array.proto.indexOf (not supported on older IE)
* nodeName case cross-browser (http://ejohn.org/blog/nodename-case-sensitivity/)
Modified paths:
  • /trunk/extensions/ApiSandbox/SpecialApiSandbox.php (modified) (history)
  • /trunk/extensions/ApiSandbox/ext.apiSandbox.css (modified) (history)
  • /trunk/extensions/ApiSandbox/ext.apiSandbox.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ApiSandbox/SpecialApiSandbox.php
@@ -30,7 +30,7 @@
3131 $out->addModules( 'ext.apiSandbox' );
3232
3333 $out->addHTML( '<noscript>' . wfMessage( 'apisb-no-js' )->parse() . '</noscript>
34 -<div id="api-sandbox-content" style="display: none">' );
 34+<div id="api-sandbox-content" style="display: none;">' );
3535 $out->addWikiMsg( 'apisb-intro' );
3636 $out->addHTML( '<form id="api-sandbox-form">'
3737 . $this->openFieldset( 'parameters' )
@@ -82,9 +82,9 @@
8383 $this->getQueryModules( 'meta' )
8484 );
8585
86 - $s = '<div id="api-sandbox-buttons"></div>';
87 - $s .= '<div id="api-sandbox-examples" style="display: none;"></div>';
88 - $s .= '
 86+ #$s = '<div id="api-sandbox-buttons"></div>';
 87+ #$s .= '<div id="api-sandbox-examples" style="display: none;"></div>';
 88+ $s = '
8989 <table class="api-sandbox-options">
9090 <tbody>
9191 <tr>
@@ -101,7 +101,9 @@
102102 </div>
103103 </td>
104104 <td class="api-sandbox-docs-col">
 105+ <div id="api-sandbox-buttons"></div>
105106 <span id="api-sandbox-help"></span>
 107+ <div id="api-sandbox-examples" style="display: none;"></div>
106108 </td>
107109 </tr>
108110 </tbody>
Index: trunk/extensions/ApiSandbox/ext.apiSandbox.js
@@ -124,27 +124,27 @@
125125 } else {
126126 key = pieces[0];
127127 value = decodeURIComponent( pieces.slice( 1 ).join( '=' ) );
128 - if ( [ 'action', 'format', 'list', 'prop', 'meta' ].indexOf( key ) !== -1 ) {
 128+ if ( $.inArray( key, [ 'action', 'format', 'list', 'prop', 'meta' ] ) !== -1 ) {
129129 continue;
130130 }
131131 $el = $( '#param-' + key );
132132 if ( !$el.length ) {
133133 continue;
134134 }
135 - switch ( $el[0].nodeName ) {
136 - case 'SELECT':
 135+ switch ( $el[0].nodeName.toLowerCase() ) {
 136+ case 'select':
137137 if ( $el.attr( 'multiple' ) ) {
138138 splitted = value.split( '|' );
139139 for ( j = 0; j < splitted.length; j++ ) {
140 - $el.children( 'option[value=' + mw.html.escape( splitted[j] ) + ']' )
 140+ $el.children( 'option[value="' + mw.html.escape( splitted[j] ) + '"]' )
141141 .prop( 'selected', true );
142142 }
143143 } else {
144 - $el.children( 'option[value=' + mw.html.escape( value ) + ']' )
 144+ $el.children( 'option[value="' + mw.html.escape( value ) + '"]' )
145145 .prop( 'selected', true );
146146 }
147147 break;
148 - case 'INPUT':
 148+ case 'input':
149149 if ( $el.attr( 'type' ) === 'checkbox' ) {
150150 $( '#param-' + key ).prop( 'checked', true );
151151 } else {
@@ -508,6 +508,7 @@
509509 $pageScroll = $( getScrollableElement( 'body', 'html' ) );
510510 $form = $( '#api-sandbox-form' );
511511 $submit = $( '<button>' )
 512+ .attr( 'type', 'submit' )
512513 .text( mw.msg( 'apisb-submit' ) )
513514 .appendTo( $buttonsContainer );
514515 $submit = $submit.clone( /*dataAndEvents=*/true, /*deep=*/true )
@@ -521,6 +522,7 @@
522523 .button({ disabled: true });
523524
524525 $examplesButton = $( '<button>' )
 526+ .attr( 'type', 'button' )
525527 .text( mw.msg( 'apisb-examples' ) )
526528 .click( function ( e ) {
527529 $examplesContent.slideToggle();
@@ -530,6 +532,7 @@
531533 .appendTo( $buttonsContainer );
532534
533535 $( '<button>' )
 536+ .attr( 'type', 'button' )
534537 .text( mw.msg( 'apisb-clear' ) )
535538 .click( function ( e ) {
536539 resetUI();
Index: trunk/extensions/ApiSandbox/ext.apiSandbox.css
@@ -22,11 +22,12 @@
2323 .api-sandbox-options td,
2424 .api-sandbox-options th {
2525 vertical-align: top;
26 - width: 13em;
 26+ padding: 3px 5px;
 27+ width: 160px;
2728 }
2829
2930 .api-sandbox-options select {
30 - width: 12em;
 31+ width: 140px;
3132 }
3233
3334 .api-sandbox-options .api-sandbox-docs-col {
@@ -42,25 +43,23 @@
4344
4445 .api-sandbox-params td,
4546 .api-sandbox-params th {
46 - padding: 5px 7px;
 47+ vertical-align: top;
 48+ padding: 5px 10px;
4749 }
4850
4951 .api-sandbox-params-label {
50 - vertical-align: top;
51 - width: 12em;
 52+ width: 150px;
5253 text-align: right;
5354 }
5455
5556 .api-sandbox-params-value {
56 - width: 20em;
57 - vertical-align: top;
58 - overflow: auto;
 57+ width: 260px;
5958 }
6059
6160 .api-sandbox-params input[type="text"],
6261 .api-sandbox-params select {
63 - padding: 2px 3px;
64 - width: 18em;
 62+ padding: 3px 5px;
 63+ width: 225px;
6564 }
6665
6766 th.api-sandbox-params-label,

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109726[ApiSandbox] front-end makeover...krinkle07:10, 22 January 2012

Comments

#Comment by Kaldari (talk | contribs)   19:53, 27 January 2012

+ #$s = '

'; + #$s .= '

';

Probably should just delete these since they've been moved elsewhere. Marking OK.

#Comment by Kaldari (talk | contribs)   19:54, 27 January 2012

Well, that got mangled. I meant:

+		#$s = '<div id="api-sandbox-buttons"></div>';
+		#$s .= '<div id="api-sandbox-examples" style="display: none;"></div>';

Status & tagging log