r98944 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98943‎ | r98944 | r98945 >
Date:22:35, 4 October 2011
Author:krinkle
Status:ok
Tags:
Comment:
[RL2] Revise gadget-id input visual
* Only use an inside-input-field icon for states 'available' and 'loading'.
* In other cases, put an error message underneath (this also allows better centering of the whole thing)
* Consider 'id already taken' an error message instead of some exceptional case. Wiping 'mw-gadgetmanager-id-taken' class from existence.
* Using or own loading class instead of the ad-hoc steal from ui-autocomplete-loading.
* Moving the gadget id out of the fieldset area for gadget settings and module properties, this is above all that.
* Instead of not showing the gadget-id area or making it 'locked' with an icon. Instead turning it (at least visually) into raw text.

New icons:
- Both in the public domain by the Tango project, from Wikimedia Commons
* input-ok.png: https://commons.wikimedia.org/wiki/File:Dialog-apply.svg
* input-error.png: https://commons.wikimedia.org/wiki/File:Dialog-error.svg
Modified paths:
  • /branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.css (modified) (history)
  • /branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.js (modified) (history)
  • /branches/RL2/extensions/Gadgets/modules/images/input-error.png (added) (history)
  • /branches/RL2/extensions/Gadgets/modules/images/input-loading.gif (added) (history)
  • /branches/RL2/extensions/Gadgets/modules/images/input-ok.png (added) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/modules/images/input-error.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/RL2/extensions/Gadgets/modules/images/input-error.png
___________________________________________________________________
Added: svn:mime-type
11 + application/octet-stream
Index: branches/RL2/extensions/Gadgets/modules/images/input-ok.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/RL2/extensions/Gadgets/modules/images/input-ok.png
___________________________________________________________________
Added: svn:mime-type
22 + application/octet-stream
Index: branches/RL2/extensions/Gadgets/modules/images/input-loading.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/RL2/extensions/Gadgets/modules/images/input-loading.gif
___________________________________________________________________
Added: svn:mime-type
33 + application/octet-stream
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.css
@@ -27,36 +27,39 @@
2828
2929 .mw-gadgetmanager-id-wrapper {
3030 width: 100%;
31 - margin-bottom: 12px;
 31+ margin: 10px 0;
3232 }
3333
3434 .mw-gadgetmanager-id-wrapper label {
35 - margin-left: 20%;
3635 display: inline-block;
 36+ width: 30%;
 37+ text-align: right;
3738 }
3839
3940 .mw-gadgetmanager-id {
4041 margin: 0 5px 0 0;
41 - padding: 3px;
 42+ padding: 3px 21px 3px 3px;
4243 border: 1px solid grey;
4344 background-color: white;
4445 }
4546
4647 .mw-gadgetmanager-id-available {
47 - background-color: #E5F6E5;
 48+ /* @embed */
 49+ background: #E5F6E5 url(images/input-ok.png) 98% 50% no-repeat;
4850 }
4951
50 -.mw-gadgetmanager-id-invalid {
 52+.mw-gadgetmanager-id-error {
5153 background-color: #F6E5E5;
5254 }
5355
54 -.mw-gadgetmanager-id-taken {
55 - background-color: #E5EFF6;
 56+.mw-gadgetmanager-id.disabled {
 57+ background-color: transparent;
 58+ border-color: transparent;
5659 }
5760
58 -.mw-gadgetmanager-id.disabled {
59 - background-color: #F6F6F6;
60 - border-color: lightgrey;
 61+.mw-gadgetmanager-id.loading {
 62+ /* @embed */
 63+ background: url(images/input-loading.gif) 98% 50% no-repeat;
6164 }
6265
6366 .mw-gadgetmanager-id input {
@@ -69,10 +72,14 @@
7073 background: transparent;
7174 }
7275
73 -.mw-gadgetmanager-id-error {
 76+.mw-gadgetmanager-id-errorbox {
7477 display: none;
75 - color: #FF4040;
76 - font-style: italic;
 78+ line-height: 24px;
 79+ margin: 1em 1em 0.5em 30%;
 80+ padding: 0 0 0 35px;
 81+ /* @embed */
 82+ background: url(images/input-error.png) 1% 50% no-repeat;
 83+ font-weight: bold;
7784 }
7885
7986 /**
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.js
@@ -17,12 +17,12 @@
1818 */
1919 tpl = {
2020 fancyForm: '<form class="mw-gadgetmanager-form">\
 21+ <div class="mw-gadgetmanager-id-wrapper">\
 22+ <label for="mw-gadgetmanager-input-id"><html:msg key="gadgetmanager-prop-id" /><html:msg key="colon-separator" /></label>\
 23+ <span class="mw-gadgetmanager-id"><input type="text" id="mw-gadgetmanager-input-id" /></span>\
 24+ <div class="mw-gadgetmanager-id-errorbox"></div>\
 25+ </div>\
2126 <fieldset>\
22 - <div class="mw-gadgetmanager-id-wrapper">\
23 - <label for="mw-gadgetmanager-input-id"><html:msg key="gadgetmanager-prop-id" /><html:msg key="colon-separator" /></label>\
24 - <span class="mw-gadgetmanager-id"><input type="text" id="mw-gadgetmanager-input-id" /></span>\
25 - <span class="mw-gadgetmanager-id-error"></span>\
26 - </div>\
2727 <legend><html:msg key="gadgetmanager-propsgroup-module" /></legend>\
2828 <table>\
2929 <tr>\
@@ -348,7 +348,7 @@
349349 metadata = gadget.metadata,
350350 $form = $( tpl.fancyForm ).localize(),
351351 $idSpan = $form.find( '.mw-gadgetmanager-id' ),
352 - $idErrMsg = $form.find( '.mw-gadgetmanager-id-error' );
 352+ $idErrMsg = $form.find( '.mw-gadgetmanager-id-errorbox' );
353353
354354 if ( mode === 'create' ) {
355355
@@ -358,7 +358,7 @@
359359
360360 // Reset
361361 toggleDialogButtons( $form, 'enable' );
362 - $idSpan.removeClass( 'mw-gadgetmanager-id-invalid mw-gadgetmanager-id-available mw-gadgetmanager-id-taken' );
 362+ $idSpan.removeClass( 'mw-gadgetmanager-id-error mw-gadgetmanager-id-available' );
363363
364364 // Abort if empty, don't warn when user is still typing,
365365 // The onblur event handler takes care of that
@@ -379,7 +379,7 @@
380380 $idErrMsg.hide();
381381 } else {
382382 toggleDialogButtons( $form, 'disable' );
383 - $idSpan.addClass( 'mw-gadgetmanager-id-invalid' );
 383+ $idSpan.addClass( 'mw-gadgetmanager-id-error' );
384384 $idErrMsg.text( mw.msg( 'gadgetmanager-prop-id-error-illegal' ) ).show();
385385 }
386386
@@ -388,26 +388,35 @@
389389 var val = $(this).val();
390390
391391 // Reset
392 - $idSpan.removeClass( 'mw-gadgetmanager-id-invalid mw-gadgetmanager-id-available mw-gadgetmanager-id-taken' );
 392+ $idSpan.removeClass( 'mw-gadgetmanager-id-error mw-gadgetmanager-id-available' );
393393 toggleDialogButtons( $form, 'enable' );
394394
395395 if ( !val.length ) {
396396 toggleDialogButtons( $form, 'disable' );
397 - $idSpan.addClass( 'mw-gadgetmanager-id-invalid' );
 397+ $idSpan.addClass( 'mw-gadgetmanager-id-error' );
398398 $idErrMsg.text( mw.msg( 'gadgetmanager-prop-id-error-blank' ) ).show();
399399 return;
400400 }
401401
 402+ // Validity check here as well to avoid
 403+ // saying 'available' to an invalid id.
 404+ if ( !validateGadgetId( val ) ) {
 405+ toggleDialogButtons( $form, 'disable' );
 406+ $idSpan.addClass( 'mw-gadgetmanager-id-error' );
 407+ $idErrMsg.text( mw.msg( 'gadgetmanager-prop-id-error-illegal' ) ).show();
 408+ return;
 409+ }
 410+
402411 ga.api.clearGadgetCache();
403412
404413 // asynchronous from here, show loading
405 - $idSpan.addClass( 'ui-autocomplete-loading' );
 414+ $idSpan.addClass( 'loading' );
406415
407416 ga.api.getGadgetData( null, function( data ) {
408 - $idSpan.removeClass( 'ui-autocomplete-loading' );
 417+ $idSpan.removeClass( 'loading' );
409418 if ( val in data ) {
410419 toggleDialogButtons( $form, 'disable' );
411 - $idSpan.addClass( 'mw-gadgetmanager-id-taken' );
 420+ $idSpan.addClass( 'mw-gadgetmanager-id-error' );
412421 $idErrMsg.text( mw.msg( 'gadgetmanager-prop-id-error-taken' ) ).show();
413422 } else {
414423 $idSpan.addClass( 'mw-gadgetmanager-id-available' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r98996[RL2] Fix MIME types for images added in r98944catrope12:43, 5 October 2011

Status & tagging log