r53023 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53022‎ | r53023 | r53024 >
Date:00:03, 10 July 2009
Author:tparscal
Status:deferred
Tags:
Comment:
Made the form so sweet you could put it in a bowl of cheerios!
Modified paths:
  • /trunk/extensions/UsabilityInitiative/OptIn/OptIn.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/OptIn.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.css
@@ -125,20 +125,35 @@
126126 margin: 0;
127127 padding: 0;
128128 }
129 -form#optin-survey table {
 129+form#optin-survey dl {
130130 margin: 0;
131131 padding: 0;
132132 }
133 -form#optin-survey table td {
 133+form#optin-survey dl dt,
 134+form#optin-survey dl dd {
134135 margin: 0;
135 - padding: 0.5em;
 136+ margin-bottom: 0.5em;
136137 line-height: 2em;
137138 }
138 -form#optin-survey table td p {
 139+form#optin-survey dl dt {
 140+ font-size: large;
 141+}
 142+form#optin-survey dl dd {
 143+ margin-left: 2em;
 144+}
 145+form#optin-survey dl dd textarea {
 146+ width: 30em;
 147+ height: 4em;
 148+}
 149+form#optin-survey dl dt p,
 150+form#optin-survey dl dd p {
139151 margin: 0;
140152 padding: 0;
141153 line-height: 2em;
142154 }
143 -form#optin-survey table td.optin-survey-submit {
 155+form#optin-survey dl dt.optin-survey-submit {
144156 text-align: right;
 157+}
 158+form#optin-survey input.optin-need-other {
 159+ clear: both;
145160 }
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php
@@ -185,17 +185,17 @@
186186 $wgOptInStyleVersion );
187187 UsabilityInitiativeHooks::addStyle( 'OptIn/OptIn.css',
188188 $wgOptInStyleVersion );
189 - $retval = Xml::openElement( 'table' );
 189+ $retval = Xml::openElement( 'dl' );
190190 foreach ( $wgOptInSurvey as $id => $question ) {
191191 switch ( $question['type'] ) {
192192 case 'dropdown':
193 - $retval .= Xml::openElement( 'tr' );
194 - $retval .= Xml::tags( 'td', array( 'valign' => 'top' ),
195 - wfMsgWikiHtml( $question['question'] ) );
196 - $retval .= Xml::openElement( 'td',
197 - array( 'valign' => 'top' ) );
198 - $attrs = array( 'id' => "survey-$id",
199 - 'name' => "survey-$id" );
 193+ $retval .= Xml::tags(
 194+ 'dt', null, wfMsgWikiHtml( $question['question'] )
 195+ );
 196+ $retval .= Xml::openElement( 'dd' );
 197+ $attrs = array(
 198+ 'id' => "survey-$id", 'name' => "survey-$id"
 199+ );
200200 if ( isset( $question['other'] ) ) {
201201 $attrs['class'] = 'optin-need-other';
202202 }
@@ -205,153 +205,184 @@
206206 $retval .= Xml::option( wfMsg( $answer ), $aid );
207207 }
208208 if ( isset( $question['other'] ) ) {
209 - $retval .= Xml::option( wfMsg( $question['other'] ),
210 - 'other' );
 209+ $retval .= Xml::option(
 210+ wfMsg( $question['other'] ), 'other'
 211+ );
211212 }
212213 $retval .= Xml::closeElement( 'select' );
213214 if ( isset( $question['other'] ) ) {
214215 $retval .= ' ';
215 - $retval .= Xml::input( "survey-$id-other",
216 - false, false,
217 - array( 'class' => 'optin-other-select',
218 - 'id' => "survey-$id-other" ) );
 216+ $retval .= Xml::input(
 217+ "survey-$id-other",
 218+ false,
 219+ false,
 220+ array(
 221+ 'class' => 'optin-other-select',
 222+ 'id' => "survey-$id-other"
 223+ )
 224+ );
219225 }
220 - $retval .= Xml::closeElement( 'td' );
221 - $retval .= Xml::closeElement( 'tr' );
 226+ $retval .= Xml::closeElement( 'dd' );
222227 break;
223228 case 'radios':
224 - $retval .= Xml::openElement( 'tr' );
225 - $retval .= Xml::tags( 'td',
226 - array( 'valign' => 'top' ),
227 - wfMsgWikiHtml( $question['question'] ) );
228 - $retval .= Xml::openElement( 'td',
229 - array( 'valign' => 'top' ) );
 229+ $retval .= Xml::tags(
 230+ 'dt', null, wfMsgWikiHtml( $question['question'] )
 231+ );
 232+ $retval .= Xml::openElement( 'dd' );
230233 $radios = array();
231234 foreach ( $question['answers'] as $aid => $answer ) {
232 - $radios[] = Xml::radioLabel( wfMsg( $answer ),
233 - "survey-$id", $aid, "survey-$id-$aid" );
 235+ $radios[] = Xml::radioLabel(
 236+ wfMsg( $answer ), "survey-$id", $aid, "survey-$id-$aid"
 237+ );
234238 }
235239 if ( isset( $question['other'] ) ) {
236 - $radios[] = Xml::radioLabel( wfMsg( $question['other'] ),
237 - "survey-$id", 'other', "survey-$id-other-radio" ) .
238 - ' ' .
239 - Xml::input( "survey-$id-other",
240 - false, false,
241 - array( 'class' => 'optin-other-radios' ) );
 240+ $radios[] = Xml::radioLabel(
 241+ wfMsg( $question['other'] ),
 242+ "survey-$id",
 243+ 'other',
 244+ "survey-$id-other-radio"
 245+ ) .
 246+ ' ' .
 247+ Xml::input(
 248+ "survey-$id-other",
 249+ false,
 250+ false,
 251+ array( 'class' => 'optin-other-radios' )
 252+ );
242253 }
243254 $retval .= implode( Xml::element( 'br' ), $radios );
244 - $retval .= Xml::closeElement( 'td' );
245 - $retval .= Xml::closeElement( 'tr' );
 255+ $retval .= Xml::closeElement( 'dd' );
246256 break;
247257 case 'checkboxes':
248 - $retval .= Xml::openElement( 'tr' );
249 - $retval .= Xml::tags( 'td',
250 - array( 'valign' => 'top' ),
251 - wfMsgWikiHtml( $question['question'] ) );
252 - $retval .= Xml::openElement( 'td',
253 - array( 'valign' => 'top' ) );
 258+ $retval .= Xml::tags(
 259+ 'dt', null, wfMsgWikiHtml( $question['question'] )
 260+ );
 261+ $retval .= Xml::openElement( 'dd' );
254262 $checkboxes = array();
255263 foreach ( $question['answers'] as $aid => $answer ) {
256 - $checkboxes[] = Xml::checkLabel( wfMsg( $answer ),
257 - "survey-{$id}[]", "survey-$id-$aid", false,
258 - array( 'value' => $aid ) );
 264+ $checkboxes[] = Xml::checkLabel(
 265+ wfMsg( $answer ),
 266+ "survey-{$id}[]",
 267+ "survey-$id-$aid",
 268+ false,
 269+ array( 'value' => $aid )
 270+ );
259271 }
260272 if ( isset( $question['other'] ) ) {
261 - $checkboxes[] = Xml::checkLabel( wfMsg( $question['other'] ),
262 - "survey-{$id}[]", "survey-$id-other-check", false,
263 - array( 'value' => 'other' ) ) .
264 - ' ' .
265 - Xml::input( "survey-$id-other",
266 - false, false,
267 - array( 'class' => 'optin-other-checks' ) );
 273+ $checkboxes[] = Xml::checkLabel(
 274+ wfMsg( $question['other'] ),
 275+ "survey-{$id}[]",
 276+ "survey-$id-other-check",
 277+ false,
 278+ array( 'value' => 'other' )
 279+ ) .
 280+ ' ' .
 281+ Xml::input(
 282+ "survey-$id-other",
 283+ false,
 284+ false,
 285+ array( 'class' => 'optin-other-checks' )
 286+ );
268287 }
269288 $retval .= implode( Xml::element( 'br' ), $checkboxes );
270 - $retval .= Xml::closeElement( 'td' );
271 - $retval .= Xml::closeElement( 'tr' );
 289+ $retval .= Xml::closeElement( 'dd' );
272290 break;
273291 case 'yesno':
274 - $retval .= Xml::openElement( 'tr' );
275 - $retval .= Xml::tags( 'td',
276 - array( 'valign' => 'top' ),
277 - wfMsgWikiHtml( $question['question'] ) );
278 - $retval .= Xml::openElement( 'td',
279 - array( 'valign' => 'top' ) );
280 - $retval .= Xml::radioLabel( wfMsg( 'optin-survey-yes' ),
281 - "survey-$id", 'yes', "survey-$id-yes",
282 - false, array( 'class' => 'survey-yes' ) );
 292+ $retval .= Xml::tags(
 293+ 'dt', null, wfMsgWikiHtml( $question['question'] )
 294+ );
 295+ $retval .= Xml::openElement( 'dd' );
 296+ $retval .= Xml::radioLabel(
 297+ wfMsg( 'optin-survey-yes' ),
 298+ "survey-$id",
 299+ 'yes',
 300+ "survey-$id-yes",
 301+ false,
 302+ array( 'class' => 'survey-yes' )
 303+ );
283304 $retval .= Xml::element( 'br' );
284 - $retval .= Xml::radioLabel( wfMsg( 'optin-survey-no' ),
285 - "survey-$id", 'no', "survey-$id-no",
286 - false, array( 'class' => 'survey-no' ) );
287 - $retval .= Xml::closeElement( 'td' );
288 - $retval .= Xml::closeElement( 'tr' );
289 -
 305+ $retval .= Xml::radioLabel(
 306+ wfMsg( 'optin-survey-no' ),
 307+ "survey-$id",
 308+ 'no',
 309+ "survey-$id-no",
 310+ false,
 311+ array( 'class' => 'survey-no' )
 312+ );
 313+ $retval .= Xml::closeElement( 'dd' );
290314 if ( isset( $question['ifyes'] ) ) {
291 - $retval .= Xml::openElement( 'tr',
292 - array( 'class' => 'survey-ifno',
293 - 'id' => "survey-$id-ifyes-row" ) );
294 - $retval .= Xml::tags( 'td',
295 - array( 'valign' => 'top' ),
296 - wfMsgWikiHtml( $question['ifyes'] ) );
297 - $retval .= Xml::openElement( 'td',
298 - array( 'valign' => 'top' ) );
299 - $retval .= Xml::textarea( "survey-$id-ifyes", '' );
300 - $retval .= Xml::closeElement( 'td' );
301 - $retval .= Xml::closeElement( 'tr' );
 315+ $retval .= Xml::openElement(
 316+ 'blockquote', array(
 317+ 'id' => "survey-$id-ifyes-row",
 318+ 'class' => 'survey-ifyes',
 319+ )
 320+ );
 321+ $retval .= Xml::tags(
 322+ 'dt', null, wfMsgWikiHtml( $question['ifyes'] )
 323+ );
 324+ $retval .= Xml::tags(
 325+ 'dd', null, Xml::textarea( "survey-$id-ifyes", '' )
 326+ );
 327+ $retval .= Xml::closeElement( 'blockquote' );
302328 }
303329 if ( isset( $question['ifno'] ) ) {
304 - $retval .= Xml::openElement( 'tr',
305 - array( 'class' => 'survey-ifno',
306 - 'id' => "survey-$id-ifno-row" ) );
307 - $retval .= Xml::tags( 'td',
308 - array( 'valign' => 'top' ),
309 - wfMsgWikiHtml( $question['ifno'] ) );
310 - $retval .= Xml::openElement( 'td',
311 - array( 'valign' => 'top' ) );
312 - $retval .= Xml::textarea( "survey-$id-ifno", '' );
313 - $retval .= Xml::closeElement( 'td' );
314 - $retval .= Xml::closeElement( 'tr' );
 330+ $retval .= Xml::openElement(
 331+ 'blockquote', array(
 332+ 'id' => "survey-$id-ifno-row",
 333+ 'class' => 'survey-ifyes',
 334+ )
 335+ );
 336+ $retval .= Xml::tags(
 337+ 'dt', null, wfMsgWikiHtml( $question['ifno'] )
 338+ );
 339+ $retval .= Xml::tags(
 340+ 'dd', null, Xml::textarea( "survey-$id-ifno", '' )
 341+ );
 342+ $retval .= Xml::closeElement( 'blockquote' );
315343 }
316344 break;
317345 case 'resolution':
318 - $retval .= Xml::openElement( 'tr' );
319 - $retval .= Xml::tags( 'td',
320 - array( 'valign' => 'top' ),
321 - wfMsgWikiHtml( $question['question'] ) );
322 - $retval .= Xml::openElement( 'td',
323 - array( 'valign' => 'top' ) );
324 - $retval .= Xml::input( "survey-$id-x",
325 - 5, false, array(
326 - 'class' => 'optin-resolution-x',
327 - 'id' => "survey-$id-x",
328 - )
 346+ $retval .= Xml::tags(
 347+ 'dt', null, wfMsgWikiHtml( $question['question'] )
329348 );
 349+ $retval .= Xml::openElement( 'dd' );
 350+ $retval .= Xml::input(
 351+ "survey-$id-x",
 352+ 5,
 353+ false,
 354+ array(
 355+ 'class' => 'optin-resolution-x',
 356+ 'id' => "survey-$id-x",
 357+ )
 358+ );
330359 $retval .= ' x ';
331 - $retval .= Xml::input( "survey-$id-y",
332 - 5, false, array(
333 - 'class' => 'optin-resolution-y',
334 - 'id' => "survey-$id-y",
335 - )
 360+ $retval .= Xml::input(
 361+ "survey-$id-y",
 362+ 5,
 363+ false,
 364+ array(
 365+ 'class' => 'optin-resolution-y',
 366+ 'id' => "survey-$id-y",
 367+ )
336368 );
337 - $retval .= Xml::closeElement( 'td' );
338 - $retval .= Xml::closeElement( 'tr' );
 369+ $retval .= Xml::closeElement( 'dd' );
339370 break;
340371 case 'textarea':
341 - $retval .= Xml::openElement( 'tr' );
342 - $retval .= Xml::tags( 'td',
343 - array( 'valign' => 'top' ),
344 - wfMsgWikiHtml( $question['question'] ) );
345 - $retval .= Xml::tags( 'td',
346 - array( 'valign' => 'top' ),
347 - Xml::textarea( "survey-$id", '' ) );
348 - $retval .= Xml::closeElement( 'tr' );
 372+ $retval .= Xml::tags(
 373+ 'dt', null, wfMsgWikiHtml( $question['question'] )
 374+ );
 375+ $retval .= Xml::tags(
 376+ 'dd', null, Xml::textarea( "survey-$id", '' )
 377+ );
349378 break;
350379 }
351380 }
352 - $retval .= Xml::tags( 'tr', array(),
353 - Xml::tags( 'td', array( 'colspan' => 2, 'class' => 'optin-survey-submit' ),
354 - Xml::submitButton( wfMsg( 'optin-submit-out' ) ) ) );
355 - $retval .= Xml::closeElement( 'table' );
 381+ $retval .= Xml::tags(
 382+ 'dt',
 383+ array( 'class' => 'optin-survey-submit' ),
 384+ Xml::submitButton( wfMsg( 'optin-submit-out' ) )
 385+ );
 386+ $retval .= Xml::closeElement( 'dl' );
356387 $wgOut->addHTML( $retval );
357388 }
358389
Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.js
@@ -4,9 +4,9 @@
55 $( '.optin-other-select' ).hide();
66 $( 'select.optin-need-other' ).change( function() {
77 if( $(this).val() == 'other' )
8 - $( '#' + $(this).attr( 'id' ) + '-other' ).show();
 8+ $( '#' + $(this).attr( 'id' ) + '-other' ).slideDown( 'fast' );
99 else
10 - $( '#' + $(this).attr( 'id' ) + '-other' ).hide();
 10+ $( '#' + $(this).attr( 'id' ) + '-other' ).slideUp( 'fast' );
1111 });
1212
1313 $( '.optin-other-radios, .optin-other-checks' ).click( function() {
@@ -18,11 +18,11 @@
1919 yesrow = $( '#' + $(this).attr( 'name' ) + '-ifyes-row' );
2020 norow = $( '#' + $(this).attr( 'name' ) + '-ifno-row' );
2121 if( $(this).is( '.survey-yes:checked' ) ) {
22 - yesrow.show();
23 - norow.hide();
 22+ yesrow.slideDown( 'fast' );
 23+ norow.slideUp( 'fast' );
2424 } else if( $(this).is( '.survey-no:checked' ) ) {
25 - yesrow.hide();
26 - norow.show();
 25+ yesrow.slideUp( 'fast' );
 26+ norow.slideDown( 'fast' );
2727 }
2828 });
2929

Status & tagging log