r90908 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90907‎ | r90908 | r90909 >
Date:21:21, 27 June 2011
Author:krinkle
Status:deferred
Tags:
Comment:
StyleGuideDemo
Continue implementation of the style guide for forms:
- Replacing plain <div class="error"> with the error box as mocked up at http://commons.wikimedia.org/wiki/File:MW-StyleGuide-Error-Banner.png
- Adding "(Required)" note inside the mw-label after the <label> as mocked up at http://www.mediawiki.org/wiki/File:MW-StyleGuide-Input-Required.png
- Implemented the submit button (namely the normal state and active-green state. The disabled state and special-red state aren't implemented yet)

For now visually tested in Safari 5, Firefox 4 and 5, Chrome and Opera 10 and 11 (Mac OS X).
Modified paths:
  • /trunk/extensions/StyleGuideDemo/HTMLStyleForm.php (modified) (history)
  • /trunk/extensions/StyleGuideDemo/StyleGuideDemo.i18n.php (modified) (history)
  • /trunk/extensions/StyleGuideDemo/modules/ext.styleguidedemo/ext.styleguidedemo.css (modified) (history)
  • /trunk/extensions/StyleGuideDemo/modules/ext.styleguidedemo/ext.styleguidedemo.js (modified) (history)

Diff [purge]

Index: trunk/extensions/StyleGuideDemo/HTMLStyleForm.php
@@ -509,7 +509,7 @@
510510 }
511511
512512 /**
513 - * Format and display an error message stack.
 513+ * Format and display an error message stack on top of the form.
514514 * @param $errors String|Array|Status
515515 * @return String
516516 */
@@ -525,10 +525,19 @@
526526 } else {
527527 $errorstr = $errors;
528528 }
529 -
530 - return $errorstr
531 - ? Html::rawElement( 'div', array( 'class' => 'error' ), $errorstr )
532 - : '';
 529+ // Build errors
 530+ if ( $errorstr ) {
 531+ $errorTitle = Html::element( 'strong', array(
 532+ 'class' => 'mw-htmlform-errors-title',
 533+ ), wfMsg( 'htmlform-errors-title' ) );
 534+ $errorContent = Html::rawElement( 'div', array(
 535+ ), $errorstr );
 536+ return Html::rawElement( 'div', array(
 537+ 'class' => 'mw-htmlform-errors'
 538+ ), $errorTitle . $errorContent );
 539+ } else {
 540+ return '';
 541+ }
533542 }
534543
535544 /**
@@ -948,6 +957,7 @@
949958 # Hint / Tip
950959 $hinttext = null;
951960 $hinthtml = '';
 961+ $afterLabelHtml = ''; // inserted into mw-label after the <label>
952962
953963 if ( isset( $this->mParams['hint-message'] ) ) {
954964 $msg = call_user_func_array( 'wfMessage', (array)$this->mParams['hint-message'] );
@@ -965,8 +975,15 @@
966976 "</div>\n";
967977 }
968978
 979+ # Required ?
 980+ if ( isset( $this->mParams['required'] ) ) {
 981+ $afterLabelHtml .= Html::element( 'span', array(
 982+ 'class' => 'mw-htmlform-required-tip',
 983+ ), wfMsg( 'parentheses', wfMsg( 'htmlform-required-tip' ) ) );
 984+ }
 985+
969986 # Label
970 - $label = $this->getLabelHtml( $attributes, $hinthtml );
 987+ $label = $this->getLabelHtml( $attributes, $hinthtml, $afterLabelHtml );
971988
972989 # Help message (optional)
973990 $helptext = null;
@@ -991,8 +1008,10 @@
9921009 $helptext = $this->mParams['help'];
9931010 }
9941011
995 - if ( !is_null( $helptext ) ) {
996 - $helphtml = Html::rawElement( 'div', array( 'class' => 'mw-htmlform-tip' ), $helptext );
 1012+ if ( !is_null( $helptext ) && $helptext != '' ) {
 1013+ $helphtml = Html::rawElement( 'div', array(
 1014+ 'class' => 'mw-htmlform-tip',
 1015+ ), $helptext );
9971016 }
9981017
9991018 # Input
@@ -1014,7 +1033,7 @@
10151034 function getLabel() {
10161035 return $this->mLabel;
10171036 }
1018 - function getLabelHtml( $attributes = array(), $hintHtml = '' ) {
 1037+ function getLabelHtml( $attributes = array(), $beforeLabelHtml = '', $afterLabelHtml = '' ) {
10191038 $labelAttrs = array();
10201039
10211040 if ( $this->needsLabel() ) {
@@ -1022,7 +1041,7 @@
10231042 }
10241043
10251044 return Html::rawElement( 'div', array( 'class' => 'mw-label' ) + $attributes,
1026 - $hintHtml . Html::rawElement( 'label', $labelAttrs, $this->getLabel() )
 1045+ $beforeLabelHtml . Html::rawElement( 'label', $labelAttrs, $this->getLabel() ) . $afterLabelHtml
10271046 );
10281047 }
10291048
Index: trunk/extensions/StyleGuideDemo/StyleGuideDemo.i18n.php
@@ -7,6 +7,9 @@
88 $messages['en'] = array(
99 'styleguidedemo' => 'Style guide demonstration',
1010 'styleguidedemo-desc' => 'An extension to demonstrate and find out how the [[mediawikiwiki:Style guide|style guide]] should be used. Visible on [[Special:StyleGuideDemo]].',
 11+ /* HTMLStyleForm */
 12+ 'htmlform-errors-title' => 'There has been a problem.',
 13+ 'htmlform-required-tip' => 'Required',
1114 /* Special:StyleGuideDemo */
1215 'styleguidedemo-head-createform' => 'Create Account',
1316 'styleguidedemo-username' => 'Username',
Index: trunk/extensions/StyleGuideDemo/modules/ext.styleguidedemo/ext.styleguidedemo.css
@@ -7,8 +7,21 @@
88
99 .mw-htmlform-form {
1010 padding: 10px;
 11+ float: left;
 12+ max-width: 70%;
1113 }
1214
 15+.mw-htmlform-errors {
 16+ background: #ffffff url(images/MW-StyleGuide-Icon-AlertMark2.png) 6px 6px no-repeat;
 17+ border: 2px solid #cc0000;
 18+ padding: 8px 12px 8px 60px;
 19+ margin: 0px 0px 21px 0px;
 20+}
 21+
 22+.mw-htmlform-errors-title {
 23+ font-weight: bold;
 24+}
 25+
1326 .mw-htmlform-field {
1427 margin: 0px 0px 21px 0px;
1528 }
@@ -29,11 +42,17 @@
3043 width: 12px;
3144 }
3245
 46+.mw-htmlform-required-tip {
 47+ color: #cc0000;
 48+ font-size: 10px;
 49+ line-height: 14px;
 50+}
 51+
3352 .mw-htmlform-tip {
3453 margin: 0px 0px 0px 30px;
3554 font-size: 10px;
3655 line-height: 14px;
37 - color: #777777;
 56+ color: #6c6c6c;
3857 }
3958
4059 .mw-htmlform-field-HTMLTextField .mw-input {
@@ -48,5 +67,37 @@
4968 width: 200px; /* width: 214px; */
5069 }
5170
 71+/* no-js */
5272 .mw-htmlform-submit {
 73+ float: right;
5374 }
 75+
 76+/* js-only */
 77+.mw-htmlform-button,
 78+.mw-htmlform-button-wrap {
 79+ -webkit-border-radius: 4px;
 80+ -moz-border-radius: 4px;
 81+ border-radius: 4px;
 82+}
 83+.mw-htmlform-button-wrap {
 84+ float: right;
 85+ border: 1px solid #9d9d9d;
 86+}
 87+.mw-htmlform-button {
 88+ padding: 5px 10px;
 89+ background: #edecef url(images/MW-StyleGuide-Form-Button-BGShade.png) center center repeat-x;
 90+ border: 1px solid #ffffff;
 91+ font-size: 14px;
 92+ font-weight: bold;
 93+ color: #6c6c6c;
 94+}
 95+
 96+.mw-htmlform-button:hover {
 97+ cursor: pointer;
 98+ background: #3cb878 url(images/MW-StyleGuide-Form-Button-BGShadeHover.png) center center repeat-x;
 99+ color: #ffffff;
 100+ border-color: #5ac084;
 101+}
 102+.mw-htmlform-button:active {
 103+ background-image: url(images/MW-StyleGuide-Form-Button-BGShadeActive.png);
 104+}
Index: trunk/extensions/StyleGuideDemo/modules/ext.styleguidedemo/ext.styleguidedemo.js
@@ -1,7 +1,7 @@
22 /**
33 * Script for the Style guide demo extension.
44 */
5 -jQuery( document ).ready(function( $ ) {
 5+jQuery( document ).ready( function( $ ) {
66
77 // Set up the help system
88 $( '.mw-help-field-data' )
@@ -16,4 +16,19 @@
1717 .slideToggle( 'fast' );
1818 } );
1919
20 -});
 20+ // Set up buttons
 21+ $( '.mw-htmlform-submit' ).each( function( i, button ) {
 22+ var $realButton = $( button ),
 23+ $styleButton = $( '<div>', {
 24+ 'class': 'mw-htmlform-button',
 25+ text: 'Share Mood'//$realButton.val()
 26+ })
 27+ .insertAfter( $realButton.hide() )
 28+ .wrap(
 29+ $( '<div>' ).addClass( 'mw-htmlform-button-wrap' )
 30+ )
 31+ .click( function( e ) {
 32+ $realButton.click();
 33+ } );
 34+ });
 35+} );

Follow-up revisions

RevisionCommit summaryAuthorDate
r90909images! FolUp r90908krinkle21:31, 27 June 2011
r90912StyleGuideDemo...krinkle21:56, 27 June 2011
r90914StyleGuideDemo...krinkle22:19, 27 June 2011

Status & tagging log