Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.classes.php |
— | — | @@ -145,7 +145,7 @@ |
146 | 146 | "prefswitch-survey-{$question}", |
147 | 147 | $answerId, |
148 | 148 | "prefswitch-survey-{$question}-{$answerId}", |
149 | | - $answer === $aid |
| 149 | + $answer === $answerId |
150 | 150 | ); |
151 | 151 | } |
152 | 152 | if ( isset( $config['other'] ) ) { |
— | — | @@ -228,12 +228,12 @@ |
229 | 229 | "prefswitch-survey-{$question}", |
230 | 230 | 'true', |
231 | 231 | "prefswitch-survey-{$question}-true", |
232 | | - $answer === 'yes', |
| 232 | + $answer === 'true', |
233 | 233 | array( 'class' => 'prefswitch-survey-true' ) |
234 | 234 | ); |
235 | 235 | $html .= Xml::element( 'br' ); |
236 | 236 | $html .= Xml::radioLabel( |
237 | | - wfMsg( 'prefswitch-survey-no' ), |
| 237 | + wfMsg( 'prefswitch-survey-false' ), |
238 | 238 | "prefswitch-survey-{$question}", |
239 | 239 | 'false', |
240 | 240 | "prefswitch-survey-{$question}-false", |
— | — | @@ -244,7 +244,7 @@ |
245 | 245 | if ( isset( $config['iftrue'] ) ) { |
246 | 246 | $html .= Xml::openElement( |
247 | 247 | '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' ) |
249 | 249 | ); |
250 | 250 | $html .= Xml::tags( 'dt', null, wfMsgWikiHtml( $config['iftrue'] ) ); |
251 | 251 | $html .= Xml::tags( |
— | — | @@ -255,7 +255,7 @@ |
256 | 256 | if ( isset( $config['iffalse'] ) ) { |
257 | 257 | $html .= Xml::openElement( |
258 | 258 | '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' ) |
260 | 260 | ); |
261 | 261 | $html .= Xml::tags( 'dt', null, wfMsgWikiHtml( $config['iffalse'] ) ); |
262 | 262 | $html .= Xml::tags( |
— | — | @@ -286,7 +286,7 @@ |
287 | 287 | ); |
288 | 288 | $html .= ' x '; |
289 | 289 | $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" ) |
291 | 291 | ); |
292 | 292 | $html .= Xml::closeElement( 'dd' ); |
293 | 293 | return $html; |
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.i18n.php |
— | — | @@ -14,8 +14,8 @@ |
15 | 15 | $messages['en'] = array( |
16 | 16 | 'prefswitch' => 'Usability Initiative Preference Switch', |
17 | 17 | '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', |
20 | 20 | 'prefswitch-survey-question-likedislike' => 'What did you like about the new features? What did you dislike about the features?', |
21 | 21 | 'prefswitch-survey-question-whyoff' => 'Why are you turning off the new features? (Please select all that apply.)', |
22 | 22 | 'prefswitch-survey-answer-whyoff-hard' => 'It was too hard to use.', |
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.php |
— | — | @@ -103,12 +103,12 @@ |
104 | 104 | ), |
105 | 105 | ), |
106 | 106 | ); |
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( |
113 | 113 | 'whyrevert' => array( |
114 | 114 | 'question' => 'prefswitch-survey-question-whyoff', |
115 | 115 | 'type' => 'checks', |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | 'other' => 'prefswitch-survey-answer-whyoff-other', |
125 | 125 | ), |
126 | 126 | ) |
127 | | - ) |
| 127 | + ), |
128 | 128 | ); |
129 | 129 | |
130 | 130 | /* 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 |
1 | 60 | + native |
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/SpecialPrefSwitch.php |
— | — | @@ -98,6 +98,7 @@ |
99 | 99 | $this->setHeaders(); |
100 | 100 | UsabilityInitiativeHooks::initialize(); |
101 | 101 | UsabilityInitiativeHooks::addScript( 'PrefSwitch/PrefSwitch.js', $wgPrefSwitchStyleVersion ); |
| 102 | + UsabilityInitiativeHooks::addStyle( 'PrefSwitch/PrefSwitch.css', $wgPrefSwitchStyleVersion ); |
102 | 103 | /* |
103 | 104 | // Set page title |
104 | 105 | if ( self::isSwitchedOn( $wgUser ) ) { |
— | — | @@ -193,8 +194,8 @@ |
194 | 195 | 'form', array( |
195 | 196 | 'method' => 'post', |
196 | 197 | 'action' => $this->getTitle()->getLinkURL( $query ), |
197 | | - 'class' => 'survey', |
198 | | - 'id' => 'survey-{$name}', |
| 198 | + 'class' => 'prefswitch-survey', |
| 199 | + 'id' => 'prefswitch-survey-{$name}', |
199 | 200 | ) |
200 | 201 | ); |
201 | 202 | $html .= Xml::hidden( 'mode', $mode ); |
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.js |
— | — | @@ -1,102 +1,79 @@ |
2 | 2 | /* JavaScript for PrefSwitch extension */ |
3 | 3 | |
4 | 4 | $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() { |
30 | 6 | // Detect browser |
31 | | - var browserIndex = 'other'; |
| 7 | + var browser = 'other'; |
32 | 8 | switch ( $j.browser.name ) { |
33 | 9 | 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'; |
39 | 21 | } else { |
40 | | - // while IE7 does not support it |
41 | | - browserIndex = 'ie7'; |
| 22 | + browser = 'o9'; |
42 | 23 | } |
43 | | - } else { |
44 | | - // other versions |
45 | | - browserIndex = 'ie'+ parseInt( $j.browser.versionNumber ); |
| 24 | + } else if ( parseInt( $j.browser.versionNumber ) == 10 ) { |
| 25 | + browser = 'o10'; |
46 | 26 | } |
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; |
67 | 28 | } |
68 | 29 | // Detect operating system |
69 | | - var osIndex = 'other'; |
| 30 | + var os = 'other'; |
70 | 31 | 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; |
80 | 35 | } |
81 | 36 | 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; |
91 | 40 | } |
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'] ); |
99 | 76 | 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'] ); |
102 | 79 | } |
103 | 80 | }); |