r64523 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64522‎ | r64523 | r64524 >
Date:18:03, 2 April 2010
Author:tparscal
Status:ok
Tags:
Comment:
Tons of fixes - added the CSS back in, got the JS working again... Coding at 2am has it's costs...
Modified paths:
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.classes.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.css (added) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/SpecialPrefSwitch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.classes.php
@@ -145,7 +145,7 @@
146146 "prefswitch-survey-{$question}",
147147 $answerId,
148148 "prefswitch-survey-{$question}-{$answerId}",
149 - $answer === $aid
 149+ $answer === $answerId
150150 );
151151 }
152152 if ( isset( $config['other'] ) ) {
@@ -228,12 +228,12 @@
229229 "prefswitch-survey-{$question}",
230230 'true',
231231 "prefswitch-survey-{$question}-true",
232 - $answer === 'yes',
 232+ $answer === 'true',
233233 array( 'class' => 'prefswitch-survey-true' )
234234 );
235235 $html .= Xml::element( 'br' );
236236 $html .= Xml::radioLabel(
237 - wfMsg( 'prefswitch-survey-no' ),
 237+ wfMsg( 'prefswitch-survey-false' ),
238238 "prefswitch-survey-{$question}",
239239 'false',
240240 "prefswitch-survey-{$question}-false",
@@ -244,7 +244,7 @@
245245 if ( isset( $config['iftrue'] ) ) {
246246 $html .= Xml::openElement(
247247 'blockquote',
248 - array( 'id' => "prefswitch-survey-{$question}-ifyes-row", 'class' => 'prefswitch-survey-iftrue' )
 248+ array( 'id' => "prefswitch-survey-{$question}-iftrue-row", 'class' => 'prefswitch-survey-iftrue' )
249249 );
250250 $html .= Xml::tags( 'dt', null, wfMsgWikiHtml( $config['iftrue'] ) );
251251 $html .= Xml::tags(
@@ -255,7 +255,7 @@
256256 if ( isset( $config['iffalse'] ) ) {
257257 $html .= Xml::openElement(
258258 'blockquote',
259 - array( 'id' => "prefswitch-survey-{$question}-iffalse-row", 'class' => 'prefswitch-survey-ifno' )
 259+ array( 'id' => "prefswitch-survey-{$question}-iffalse-row", 'class' => 'prefswitch-survey-iffalse' )
260260 );
261261 $html .= Xml::tags( 'dt', null, wfMsgWikiHtml( $config['iffalse'] ) );
262262 $html .= Xml::tags(
@@ -286,7 +286,7 @@
287287 );
288288 $html .= ' x ';
289289 $html .= Xml::input(
290 - "prefswitch-survey-{$question}-y", 5, $y, array( 'id' => "prefswitch-survey-{$question}-y", )
 290+ "prefswitch-survey-{$question}-y", 5, $y, array( 'id' => "prefswitch-survey-{$question}-y" )
291291 );
292292 $html .= Xml::closeElement( 'dd' );
293293 return $html;
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.i18n.php
@@ -14,8 +14,8 @@
1515 $messages['en'] = array(
1616 'prefswitch' => 'Usability Initiative Preference Switch',
1717 'prefswitch-desc' => 'Allow users to swtich sets of preferences',
18 - 'prefswitch-survey-yes' => 'Yes',
19 - 'prefswitch-survey-no' => 'No',
 18+ 'prefswitch-survey-true' => 'Yes',
 19+ 'prefswitch-survey-false' => 'No',
2020 'prefswitch-survey-question-likedislike' => 'What did you like about the new features? What did you dislike about the features?',
2121 'prefswitch-survey-question-whyoff' => 'Why are you turning off the new features? (Please select all that apply.)',
2222 'prefswitch-survey-answer-whyoff-hard' => 'It was too hard to use.',
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.php
@@ -103,12 +103,12 @@
104104 ),
105105 ),
106106 );
107 -$wgPrefSwitchSurveys['off'] = array_merge(
108 - $wgPrefSwitchSurveys['feedback'],
109 - array(
110 - 'submit-msg' => 'prefswitch-survey-submit-off',
111 - 'updatable' => false,
112 - 'questions' => array(
 107+$wgPrefSwitchSurveys['off'] = array(
 108+ 'submit-msg' => 'prefswitch-survey-submit-off',
 109+ 'updatable' => false,
 110+ 'questions' => array_merge(
 111+ $wgPrefSwitchSurveys['feedback']['questions'],
 112+ array(
113113 'whyrevert' => array(
114114 'question' => 'prefswitch-survey-question-whyoff',
115115 'type' => 'checks',
@@ -123,7 +123,7 @@
124124 'other' => 'prefswitch-survey-answer-whyoff-other',
125125 ),
126126 )
127 - )
 127+ ),
128128 );
129129
130130 /* Setup */
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.css
@@ -0,0 +1,58 @@
 2+div.prefswitch-intro {
 3+ font-size: large;
 4+ margin-bottom: 1em;
 5+}
 6+form.prefswitch-survey {
 7+ margin: 0;
 8+ padding: 0;
 9+}
 10+form.prefswitch-survey dl {
 11+ border-top: dashed 1px silver;
 12+ margin: 0;
 13+ padding: 0;
 14+ margin-top: 1em;
 15+ padding-top: 1em;
 16+ width: 32em;
 17+}
 18+form.prefswitch-survey dl dt,
 19+form.prefswitch-survey dl dd {
 20+ margin: 0;
 21+ margin-bottom: 0.5em;
 22+}
 23+form.prefswitch-survey dl dt {
 24+ margin-top: 1em;
 25+ font-size: 1.1em;
 26+}
 27+form.prefswitch-survey dl dd {
 28+ margin-left: 2em;
 29+}
 30+form.prefswitch-survey dl dt textarea {
 31+ width: 30em;
 32+ height: 4em;
 33+}
 34+form.prefswitch-survey dl blockquote {
 35+ padding: 0em;
 36+ margin: 0em;
 37+ margin-left: 2em;
 38+}
 39+form.prefswitch-survey dl blockquote dd {
 40+ margin-left: 2em;
 41+}
 42+form.prefswitch-survey dl blockquote dd textarea {
 43+ width: 28em;
 44+}
 45+form.prefswitch-survey dl dt p {
 46+ margin: 0;
 47+ padding: 0;
 48+}
 49+form.prefswitch-survey dl dd p {
 50+ margin: 0;
 51+ padding: 0;
 52+ line-height: 2em;
 53+}
 54+form.prefswitch-survey dl dt.prefswitch-survey-submit {
 55+ text-align: right;
 56+}
 57+form.prefswitch-survey input.prefswitch-need-other {
 58+ clear: both;
 59+}
\ No newline at end of file
Property changes on: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.css
___________________________________________________________________
Name: svn:eol-style
160 + native
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/SpecialPrefSwitch.php
@@ -98,6 +98,7 @@
9999 $this->setHeaders();
100100 UsabilityInitiativeHooks::initialize();
101101 UsabilityInitiativeHooks::addScript( 'PrefSwitch/PrefSwitch.js', $wgPrefSwitchStyleVersion );
 102+ UsabilityInitiativeHooks::addStyle( 'PrefSwitch/PrefSwitch.css', $wgPrefSwitchStyleVersion );
102103 /*
103104 // Set page title
104105 if ( self::isSwitchedOn( $wgUser ) ) {
@@ -193,8 +194,8 @@
194195 'form', array(
195196 'method' => 'post',
196197 'action' => $this->getTitle()->getLinkURL( $query ),
197 - 'class' => 'survey',
198 - 'id' => 'survey-{$name}',
 198+ 'class' => 'prefswitch-survey',
 199+ 'id' => 'prefswitch-survey-{$name}',
199200 )
200201 );
201202 $html .= Xml::hidden( 'mode', $mode );
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.js
@@ -1,102 +1,79 @@
22 /* JavaScript for PrefSwitch extension */
33
44 $j(document).ready( function() {
5 - $j( '.prefswitch-other-select' ).parent().hide();
6 - $j( 'select.prefswitch-need-other' ).change( function() {
7 - if( $j(this).val() == 'other' )
8 - $j( '#prefswitch-' + $j(this).attr( 'id' ) + '-other' ).parent().slideDown( 'fast' );
9 - else
10 - $j( '#prefswitch-' + $j(this).attr( 'id' ) + '-other' ).parent().slideUp( 'fast' );
11 - });
12 - $j( '.prefswitch-other-radios, .prefswitch-other-checks' ).click( function() {
13 - $j(this).prev().prev().attr( 'checked', true );
14 - });
15 - $j( '.survey-ifyes, .survey-ifno' ).hide();
16 - $j( '.survey-yes, .survey-no' ).change( function() {
17 - yesrow = $j( '#prefswitch-' + $j(this).attr( 'name' ) + '-ifyes-row' );
18 - norow = $j( '#prefswitch-' + $j(this).attr( 'name' ) + '-ifno-row' );
19 - if( $j(this).is( '.survey-yes:checked' ) ) {
20 - yesrow.slideDown( 'fast' );
21 - norow.slideUp( 'fast' );
22 - } else if( $j(this).is( '.survey-no:checked' ) ) {
23 - yesrow.slideUp( 'fast' );
24 - norow.slideDown( 'fast' );
25 - }
26 - });
27 - // Load initial state
28 - $j( '.survey-yes, .survey-no' ).change();
29 - var detected = function() {
 5+ function detect() {
306 // Detect browser
31 - var browserIndex = 'other';
 7+ var browser = 'other';
328 switch ( $j.browser.name ) {
339 case 'msie':
34 - if ( parseInt( $j.browser.versionNumber ) == 7 ) {
35 - // IE7 or IE8 compat mode
36 - if( document.documentMode ) {
37 - // IE8 supports Document mode
38 - browserIndex = 'ie8';
 10+ var v = parseInt( $j.browser.versionNumber );
 11+ // IE8 supports Document mode while IE7 does not support it - other versions don't lie about their age
 12+ browser = ( v == 7 ? ( document.documentMode ? 'ie8' : 'ie7' ) : 'ie' + v );
 13+ break;
 14+ case 'firefox': browser = 'ff' + parseInt( $j.browser.versionNumber ); break;
 15+ case 'chrome': browser = 'c' + parseInt( $j.browser.versionNumber ); break;
 16+ case 'safari': browser = 's' + parseInt( $j.browser.versionNumber ); break;
 17+ case 'opera':
 18+ if ( parseInt( $j.browser.versionNumber ) == 9 ) {
 19+ if ( $j.browser.version.substr( 0, 3 ) == '9.5' ) {
 20+ browser = 'o9.5';
3921 } else {
40 - // while IE7 does not support it
41 - browserIndex = 'ie7';
 22+ browser = 'o9';
4223 }
43 - } else {
44 - // other versions
45 - browserIndex = 'ie'+ parseInt( $j.browser.versionNumber );
 24+ } else if ( parseInt( $j.browser.versionNumber ) == 10 ) {
 25+ browser = 'o10';
4626 }
47 - break;
48 - case 'firefox':
49 - browserIndex = 'ff' + parseInt( $j.browser.versionNumber );
50 - break;
51 - case 'chrome':
52 - // FIXME: Chrome Alpha/Beta?
53 - browserIndex = 'c' + parseInt( $j.browser.versionNumber );
54 - break;
55 - case 'safari':
56 - browserIndex = 's' + parseInt( $j.browser.versionNumber );
57 - break;
58 - case 'opera':
59 - if ( parseInt( $j.browser.versionNumber ) == 9 ) {
60 - if ( $j.browser.version.substr( 0, 3 ) == '9.5' )
61 - browserIndex = 'o9.5';
62 - else
63 - browserIndex = 'o9';
64 - } else if ( parseInt( $j.browser.versionNumber ) == 10 )
65 - browserIndex = 'o10';
66 - break;
 27+ break;
6728 }
6829 // Detect operating system
69 - var osIndex = 'other';
 30+ var os = 'other';
7031 switch ( $j.os.name ) {
71 - case 'win':
72 - osIndex = 'windows';
73 - break;
74 - case 'mac':
75 - osIndex = 'macos';
76 - break;
77 - case 'linux':
78 - osIndex = 'linux';
79 - break;
 32+ case 'win': os = 'windows'; break;
 33+ case 'mac': os = 'macos'; break;
 34+ case 'linux': os = 'linux'; break;
8035 }
8136 switch ( $j.browser.name ) {
82 - case 'iemobile':
83 - osIndex = 'windowsmobile';
84 - break;
85 - case 'iphone':
86 - osIndex = 'iphoneos';
87 - break;
88 - case 'ipod':
89 - osIndex = 'iphoneos';
90 - break;
 37+ case 'iemobile': os = 'windowsmobile'; break;
 38+ case 'iphone': os = 'iphoneos'; break;
 39+ case 'ipod': os = 'iphoneos'; break;
9140 }
92 - return { 'survey-browser': browserIndex, 'survey-os': osIndex,
93 - 'survey-res-x': screen.width, 'survey-res-y': screen.height,
94 - 'opt': 'browser' };
95 - } )();
96 - $j( '.prefswitch-survey-browser' ).val( detected['survey-browser'] );
97 - $j( '.prefswitch-survey-os' ).val( detected['survey-os'] );
98 - // Detect screen dimensions
 41+ return {
 42+ 'survey-browser': browser, 'survey-os': os, 'survey-res-x': screen.width, 'survey-res-y': screen.height
 43+ };
 44+ }
 45+ // Auto-hide/show "other" explaination fields for selects
 46+ $j( '.prefswitch-survey-other-select' ).parent().hide();
 47+ $j( 'select.prefswitch-survey-need-other' ).change( function() {
 48+ if ( $j(this).val() == 'other' ) {
 49+ $j( '#' + $j(this).attr( 'id' ) + '-other' ).parent().slideDown( 'fast' );
 50+ } else {
 51+ $j( '#' + $j(this).attr( 'id' ) + '-other' ).parent().slideUp( 'fast' );
 52+ }
 53+ });
 54+ // Auto-select the check or radio next to an "other" explaination on click
 55+ $j( '.prefswitch-survey-other-radios, .prefswitch-survey-other-checks' ).click( function() {
 56+ $j(this).prev().prev().attr( 'checked', true );
 57+ });
 58+ // Auto-hide/show explaination fields for boolean
 59+ $j( '.prefswitch-survey-iftrue, .prefswitch-survey-iffalse' ).hide();
 60+ $j( '.prefswitch-survey-true, .prefswitch-survey-false' ).change( function() {
 61+ $ifTrueRow = $j( '#' + $j(this).attr( 'name' ) + '-iftrue-row' );
 62+ $ifFalseRow = $j( '#' + $j(this).attr( 'name' ) + '-iffalse-row' );
 63+ if ( $j(this).is( '.prefswitch-survey-true:checked' ) ) {
 64+ $ifTrueRow.slideDown( 'fast' );
 65+ $ifFalseRow.slideUp( 'fast' );
 66+ } else if ( $j(this).is( '.prefswitch-survey-false:checked' ) ) {
 67+ $ifTrueRow.slideUp( 'fast' );
 68+ $ifFalseRow.slideDown( 'fast' );
 69+ }
 70+ } );
 71+ $j( '.prefswitch-survey-yes, .prefswitch-survey-no' ).change();
 72+ // Auto-detect borwser, os and screen size
 73+ var detected = detect();
 74+ $j( '#prefswitch-survey-browser' ).val( detected['survey-browser'] );
 75+ $j( '#prefswitch-survey-os' ).val( detected['survey-os'] );
9976 if ( detected['survey-res-x'] && detected['survey-res-y'] ) {
100 - $j( '.prefswitch-survey-resolution-x' ).val( detected['survey-res-x'] );
101 - $j( '.prefswitch-survey-resolution-y' ).val( detected['survey-res-y'] );
 77+ $j( '#prefswitch-survey-res-x' ).val( detected['survey-res-x'] );
 78+ $j( '#prefswitch-survey-res-y' ).val( detected['survey-res-y'] );
10279 }
10380 });

Status & tagging log