r52146 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52145‎ | r52146 | r52147 >
Date:22:11, 18 June 2009
Author:tparscal
Status:deferred
Tags:
Comment:
Added some browser, os and screen detection stuff
Modified paths:
  • /trunk/extensions/UsabilityInitiative/OptIn/OptIn.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/OptIn.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php
@@ -152,9 +152,19 @@
153153 wfMsgWikiHtml( $question['question'] ) );
154154 $retval .= Xml::openElement( 'td',
155155 array( 'valign' => 'top' ) );
156 - $retval .= Xml::input( "survey-$id-x", 5 );
 156+ $retval .= Xml::input( "survey-$id-x",
 157+ 5, false, array(
 158+ 'class' => 'optin-resolution-x',
 159+ 'id' => "survey-$id-x",
 160+ )
 161+ );
157162 $retval .= ' x ';
158 - $retval .= Xml::input( "survey-$id-y", 5 );
 163+ $retval .= Xml::input( "survey-$id-y",
 164+ 5, false, array(
 165+ 'class' => 'optin-resolution-y',
 166+ 'id' => "survey-$id-y",
 167+ )
 168+ );
159169 $retval .= Xml::closeElement( 'td' );
160170 $retval .= Xml::closeElement( 'tr' );
161171 break;
Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.js
@@ -1,3 +1,85 @@
 2+/*
 3+
 4+jQuery Browser Plugin
 5+ * Version 2.3
 6+ * 2008-09-17 19:27:05
 7+ * URL: http://jquery.thewikies.com/browser
 8+ * Description: jQuery Browser Plugin extends browser detection capabilities and can assign browser selectors to CSS classes.
 9+ * Author: Nate Cavanaugh, Minhchau Dang, & Jonathan Neal
 10+ * Copyright: Copyright (c) 2008 Jonathan Neal under dual MIT/GPL license.
 11+ * JSLint: This javascript file passes JSLint verification.
 12+*//*jslint
 13+ bitwise: true,
 14+ browser: true,
 15+ eqeqeq: true,
 16+ forin: true,
 17+ nomen: true,
 18+ plusplus: true,
 19+ undef: true,
 20+ white: true
 21+*//*global
 22+ jQuery
 23+*/
 24+
 25+(function ($) {
 26+ $.browserTest = function (a, z) {
 27+ var u = 'unknown', x = 'X', m = function (r, h) {
 28+ for (var i = 0; i < h.length; i = i + 1) {
 29+ r = r.replace(h[i][0], h[i][1]);
 30+ }
 31+
 32+ return r;
 33+ }, c = function (i, a, b, c) {
 34+ var r = {
 35+ name: m((a.exec(i) || [u, u])[1], b)
 36+ };
 37+
 38+ r[r.name] = true;
 39+
 40+ r.version = (c.exec(i) || [x, x, x, x])[3];
 41+
 42+ if (r.name.match(/safari/) && r.version > 400) {
 43+ r.version = '2.0';
 44+ }
 45+
 46+ if (r.name === 'presto') {
 47+ r.version = ($.browser.version > 9.27) ? 'futhark' : 'linear_b';
 48+ }
 49+ r.versionNumber = parseFloat(r.version, 10) || 0;
 50+ r.versionX = (r.version !== x) ? (r.version + '').substr(0, 1) : x;
 51+ r.className = r.name + r.versionX;
 52+
 53+ return r;
 54+ };
 55+
 56+ a = (a.match(/Opera|Navigator|Minefield|KHTML|Chrome/) ? m(a, [
 57+ [/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''],
 58+ ['Chrome Safari', 'Chrome'],
 59+ ['KHTML', 'Konqueror'],
 60+ ['Minefield', 'Firefox'],
 61+ ['Navigator', 'Netscape']
 62+ ]) : a).toLowerCase();
 63+
 64+ $.browser = $.extend((!z) ? $.browser : {}, c(a, /(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/, [], /(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));
 65+
 66+ $.layout = c(a, /(gecko|konqueror|msie|opera|webkit)/, [
 67+ ['konqueror', 'khtml'],
 68+ ['msie', 'trident'],
 69+ ['opera', 'presto']
 70+ ], /(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);
 71+
 72+ $.os = {
 73+ name: (/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase()) || [u])[0].replace('sunos', 'solaris')
 74+ };
 75+
 76+ if (!z) {
 77+ $('html').addClass([$.os.name, $.browser.name, $.browser.className, $.layout.name, $.layout.className].join(' '));
 78+ }
 79+ };
 80+
 81+ $.browserTest(navigator.userAgent);
 82+})(jQuery);
 83+
284 /* JavaScript for OptIn extension */
385
486 $( document ).ready( function() {
@@ -11,4 +93,17 @@
1294 $( '.optin-other-radios' ).click( function() {
1395 $(this).prev().prev().click();
1496 });
 97+ // Detect screen resolution
 98+ if ( screen.width && screen.height ) {
 99+ $( '.optin-resolution-x' ).val( screen.width );
 100+ $( '.optin-resolution-y' ).val( screen.height );
 101+ // Hide the fields?
 102+ }
 103+ /*
 104+ * We should probably refactor the code above and make it a jquery plugin
 105+ $.browser.name // String like "firefox"
 106+ $.browser.versionNumber // Floating point number like 3.5
 107+ $.os.name // String like "mac"
 108+ // More info about usage: http://jquery.thewikies.com/browser
 109+ */
15110 });
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/OptIn/OptIn.i18n.php
@@ -50,6 +50,6 @@
5151 'optin-survey-answer-os-macos' => 'Mac OS',
5252 'optin-survey-answer-os-linux' => 'Linux',
5353 'optin-survey-answer-os-other' => 'Other:',
54 - 'optin-survey-question-res' => 'What is the resolution of your screen?<br />If you don\'t know, [http://www.whatismyscreenresolution.com/ click here].',
 54+ 'optin-survey-question-res' => 'What is the resolution of your screen?',
5555 'optin-survey-question-feedback' => 'Please let us know your feedback:',
5656 );

Status & tagging log