r54663 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54662‎ | r54663 | r54664 >
Date:15:00, 9 August 2009
Author:catrope
Status:ok
Tags:
Comment:
OptIn: Fix browser+OS registration that got borked by r53990 and was commented out in r54597
Modified paths:
  • /trunk/extensions/UsabilityInitiative/OptIn/OptIn.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/OptIn.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.php
@@ -28,7 +28,7 @@
2929 $wgOptInAlwaysShowPersonalLink = false;
3030 $wgOptInNeverShowPersonalLink = false;
3131
32 -$wgOptInStyleVersion = 8;
 32+$wgOptInStyleVersion = 9;
3333
3434 // Preferences to set when users opt in
3535 // array( prefname => value )
Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php
@@ -113,15 +113,12 @@
114114 UsabilityInitiativeHooks::initialize();
115115 UsabilityInitiativeHooks::addScript( 'OptIn/OptIn.js',
116116 $wgOptInStyleVersion );
117 - /*
118 - * What the hell does this do?
119 - *
 117+
120118 $url = $this->getTitle()->getLinkUrl();
121119 $wgOut->addHTML( Xml::tags( 'script',
122120 array( 'type' => $wgJsMimeType ),
123 - "js2AddOnloadHook(function() { \$j.post( \"$url\", optInGetPOSTData() ); } );"
 121+ "jQuery(document).ready(function() { jQuery.post( \"$url\", optInGetPOSTData() ); } );"
124122 ) );
125 - */
126123 } else if ( $wgRequest->getVal( 'opt' ) == 'feedback' ) {
127124 if ( $wgRequest->wasPosted() ) {
128125 $this->saveSurvey( $wgOptInFeedBackSurvey,
Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.js
@@ -1,30 +1,6 @@
22 /* JavaScript for OptIn extension */
33
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() {
295 // Detect browser
306 var browserIndex = 'other';
317 switch ( $j.browser.name ) {
@@ -63,7 +39,6 @@
6440 browserIndex = 'o10';
6541 break;
6642 }
67 - $j( '#survey-browser' ).val( browserIndex );
6843 // Detect operating system
6944 var osIndex = 'other';
7045 switch ( $j.os.name ) {
@@ -86,10 +61,43 @@
8762 osIndex = 'linux';
8863 break;
8964 }
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'] );
9199 // 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'] );
95103 }
96104 });

Follow-up revisions

RevisionCommit summaryAuthorDate
r54743Swtiched back to using js2AddOnloadHook from jQuery directly (in response to ...tparscal20:57, 10 August 2009
r54752Merge a bunch of UsabilityInitiative fixes. This commit may mess up svn:merge...catrope22:12, 10 August 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53990Changed references to jQuery to be compatible with the upcoming switch to js2...tparscal00:18, 30 July 2009
r54597Commented out a piece of code that I believe to be a remnant of a now removed...tparscal19:03, 7 August 2009

Status & tagging log