Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | $wgOptInAlwaysShowPersonalLink = false; |
30 | 30 | $wgOptInNeverShowPersonalLink = false; |
31 | 31 | |
32 | | -$wgOptInStyleVersion = 8; |
| 32 | +$wgOptInStyleVersion = 9; |
33 | 33 | |
34 | 34 | // Preferences to set when users opt in |
35 | 35 | // array( prefname => value ) |
Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php |
— | — | @@ -113,15 +113,12 @@ |
114 | 114 | UsabilityInitiativeHooks::initialize(); |
115 | 115 | UsabilityInitiativeHooks::addScript( 'OptIn/OptIn.js', |
116 | 116 | $wgOptInStyleVersion ); |
117 | | - /* |
118 | | - * What the hell does this do? |
119 | | - * |
| 117 | + |
120 | 118 | $url = $this->getTitle()->getLinkUrl(); |
121 | 119 | $wgOut->addHTML( Xml::tags( 'script', |
122 | 120 | array( 'type' => $wgJsMimeType ), |
123 | | - "js2AddOnloadHook(function() { \$j.post( \"$url\", optInGetPOSTData() ); } );" |
| 121 | + "jQuery(document).ready(function() { jQuery.post( \"$url\", optInGetPOSTData() ); } );" |
124 | 122 | ) ); |
125 | | - */ |
126 | 123 | } else if ( $wgRequest->getVal( 'opt' ) == 'feedback' ) { |
127 | 124 | if ( $wgRequest->wasPosted() ) { |
128 | 125 | $this->saveSurvey( $wgOptInFeedBackSurvey, |
Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.js |
— | — | @@ -1,30 +1,6 @@ |
2 | 2 | /* JavaScript for OptIn extension */ |
3 | 3 | |
4 | | -js2AddOnloadHook( function() { |
5 | | - $j( '.optin-other-select' ).parent().hide(); |
6 | | - $j( 'select.optin-need-other' ).change( function() { |
7 | | - if( $j(this).val() == 'other' ) |
8 | | - $j( '#' + $j(this).attr( 'id' ) + '-other' ).parent().slideDown( 'fast' ); |
9 | | - else |
10 | | - $j( '#' + $j(this).attr( 'id' ) + '-other' ).parent().slideUp( 'fast' ); |
11 | | - }); |
12 | | - $j( '.optin-other-radios, .optin-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( '#' + $j(this).attr( 'name' ) + '-ifyes-row' ); |
18 | | - norow = $j( '#' + $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(); |
| 4 | +function optInGetPOSTData() { |
29 | 5 | // Detect browser |
30 | 6 | var browserIndex = 'other'; |
31 | 7 | switch ( $j.browser.name ) { |
— | — | @@ -63,7 +39,6 @@ |
64 | 40 | browserIndex = 'o10'; |
65 | 41 | break; |
66 | 42 | } |
67 | | - $j( '#survey-browser' ).val( browserIndex ); |
68 | 43 | // Detect operating system |
69 | 44 | var osIndex = 'other'; |
70 | 45 | switch ( $j.os.name ) { |
— | — | @@ -86,10 +61,43 @@ |
87 | 62 | osIndex = 'linux'; |
88 | 63 | break; |
89 | 64 | } |
90 | | - $j( '#survey-os' ).val( osIndex ); |
| 65 | + return { 'survey-browser': browserIndex, 'survey-os': osIndex, |
| 66 | + 'survey-res-x': screen.width, 'survey-res-y': screen.height, |
| 67 | + 'opt': 'browser' }; |
| 68 | +} |
| 69 | + |
| 70 | +js2AddOnloadHook( function() { |
| 71 | + $j( '.optin-other-select' ).parent().hide(); |
| 72 | + $j( 'select.optin-need-other' ).change( function() { |
| 73 | + if( $j(this).val() == 'other' ) |
| 74 | + $j( '#' + $j(this).attr( 'id' ) + '-other' ).parent().slideDown( 'fast' ); |
| 75 | + else |
| 76 | + $j( '#' + $j(this).attr( 'id' ) + '-other' ).parent().slideUp( 'fast' ); |
| 77 | + }); |
| 78 | + $j( '.optin-other-radios, .optin-other-checks' ).click( function() { |
| 79 | + $j(this).prev().prev().attr( 'checked', true ); |
| 80 | + }); |
| 81 | + $j( '.survey-ifyes, .survey-ifno' ).hide(); |
| 82 | + $j( '.survey-yes, .survey-no' ).change( function() { |
| 83 | + yesrow = $j( '#' + $j(this).attr( 'name' ) + '-ifyes-row' ); |
| 84 | + norow = $j( '#' + $j(this).attr( 'name' ) + '-ifno-row' ); |
| 85 | + if( $j(this).is( '.survey-yes:checked' ) ) { |
| 86 | + yesrow.slideDown( 'fast' ); |
| 87 | + norow.slideUp( 'fast' ); |
| 88 | + } else if( $j(this).is( '.survey-no:checked' ) ) { |
| 89 | + yesrow.slideUp( 'fast' ); |
| 90 | + norow.slideDown( 'fast' ); |
| 91 | + } |
| 92 | + }); |
| 93 | + // Load initial state |
| 94 | + $j( '.survey-yes, .survey-no' ).change(); |
| 95 | + |
| 96 | + var detected = optInGetPOSTData(); |
| 97 | + $j( '#survey-browser' ).val( detected['survey-browser'] ); |
| 98 | + $j( '#survey-os' ).val( detected['survey-os'] ); |
91 | 99 | // Detect screen dimensions |
92 | | - if ( screen.width && screen.height ) { |
93 | | - $j( '.optin-resolution-x' ).val( screen.width ); |
94 | | - $j( '.optin-resolution-y' ).val( screen.height ); |
| 100 | + if ( detected['survey-res-x'] && detected['survey-res-y'] ) { |
| 101 | + $j( '.optin-resolution-x' ).val( detected['survey-res-x'] ); |
| 102 | + $j( '.optin-resolution-y' ).val( detected['survey-res-y'] ); |
95 | 103 | } |
96 | 104 | }); |