r75645 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75644‎ | r75645 | r75646 >
Date:15:30, 29 October 2010
Author:krinkle
Status:ok
Tags:
Comment:
white-space cleanup throughout $.client and mw.util and mw.util.test (r75593)
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.client.js (modified) (history)
  • /trunk/phase3/resources/mediawiki.util/mediawiki.util.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.client.js
@@ -1,17 +1,17 @@
22 /*
3 - * User-agent detection
 3+ * User-agent detection
44 */
55 jQuery.client = new ( function() {
6 -
 6+
77 /* Private Members */
8 -
 8+
99 var profile;
10 -
 10+
1111 /* Public Functions */
12 -
 12+
1313 /**
1414 * Returns an object containing information about the browser
15 - *
 15+ *
1616 * The resulting client object will be in the following format:
1717 * {
1818 * 'name': 'firefox',
@@ -26,9 +26,9 @@
2727 this.profile = function() {
2828 // Use the cached version if possible
2929 if ( typeof profile === 'undefined' ) {
30 -
 30+
3131 /* Configuration */
32 -
 32+
3333 // Name of browsers or layout engines we don't recognize
3434 var uk = 'unknown';
3535 // Generic version digit
@@ -75,9 +75,9 @@
7676 var platforms = ['win', 'mac', 'linux', 'sunos', 'solaris', 'iphone'];
7777 // Translations for conforming operating system names
7878 var platformTranslations = [['sunos', 'solaris']];
79 -
 79+
8080 /* Methods */
81 -
 81+
8282 // Performs multiple replacements on a string
8383 function translate( source, translations ) {
8484 for ( var i = 0; i < translations.length; i++ ) {
@@ -85,9 +85,9 @@
8686 }
8787 return source;
8888 };
89 -
 89+
9090 /* Pre-processing */
91 -
 91+
9292 var userAgent = navigator.userAgent, match, name = uk, layout = uk, layoutversion = uk, platform = uk, version = x;
9393 if ( match = new RegExp( '(' + wildUserAgents.join( '|' ) + ')' ).exec( userAgent ) ) {
9494 // Takes a userAgent string and translates given text into something we can more easily work with
@@ -95,9 +95,9 @@
9696 }
9797 // Everything will be in lowercase from now on
9898 userAgent = userAgent.toLowerCase();
99 -
 99+
100100 /* Extraction */
101 -
 101+
102102 if ( match = new RegExp( '(' + names.join( '|' ) + ')' ).exec( userAgent ) ) {
103103 name = translate( match[1], nameTranslations );
104104 }
@@ -113,9 +113,9 @@
114114 if ( match = new RegExp( '(' + versionPrefixes.join( '|' ) + ')' + versionSuffix ).exec( userAgent ) ) {
115115 version = match[3];
116116 }
117 -
 117+
118118 /* Edge Cases -- did I mention about how user agent string lie? */
119 -
 119+
120120 // Decode Safari's crazy 400+ version numbers
121121 if ( name.match( /safari/ ) && version > 400 ) {
122122 version = '2.0';
@@ -124,9 +124,9 @@
125125 if ( name === 'opera' && version >= 9.8) {
126126 version = userAgent.match( /version\/([0-9\.]*)/i )[1] || 10;
127127 }
128 -
 128+
129129 /* Caching */
130 -
 130+
131131 profile = {
132132 'name': name,
133133 'layout': layout,
@@ -139,12 +139,12 @@
140140 }
141141 return profile;
142142 };
143 -
 143+
144144 /**
145145 * Checks the current browser against a support map object to determine if the browser has been black-listed or
146146 * not. If the browser was not configured specifically it is assumed to work. It is assumed that the body
147147 * element is classified as either "ltr" or "rtl". If neither is set, "ltr" is assumed.
148 - *
 148+ *
149149 * A browser map is in the following format:
150150 * {
151151 * 'ltr': {
@@ -160,9 +160,9 @@
161161 * 'iphone': false
162162 * }
163163 * }
164 - *
 164+ *
165165 * @param map Object of browser support map
166 - *
 166+ *
167167 * @return Boolean true if browser known or assumed to be supported, false if blacklisted
168168 */
169169 this.test = function( map ) {
Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js
@@ -14,33 +14,32 @@
1515
1616 // Any initialisation after the DOM is ready
1717 $(function () {
18 -
 18+
1919 // Populate clientProfile var
2020 mw.util.clientProfile = $.client.profile();
21 - var webkit = navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
2221
2322 // Set tooltipAccessKeyPrefix
24 -
 23+
2524 // Opera on any platform
2625 if ( mw.util.isBrowser('opera') ) {
2726 this.tooltipAccessKeyPrefix = 'shift-esc-';
28 -
 27+
2928 // Chrome on any platform
3029 } else if ( mw.util.isBrowser('chrome') ) {
3130 // Chrome on Mac or Chrome on other platform ?
3231 this.tooltipAccessKeyPrefix = mw.util.isPlatform('mac') ? 'ctrl-option-' : 'alt-';
33 -
 32+
3433 // Non-Windows Safari with webkit_version > 526
3534 } else if ( !mw.util.isPlatform('win') && mw.util.isBrowser('safari') && webkit_version > 526 ) {
3635 this.tooltipAccessKeyPrefix = 'ctrl-alt-';
37 -
 36+
3837 // Safari/Konqueror on any platform, or any browser on Mac (but not Safari on Windows)
3938 } else if ( !( mw.util.isPlatform('win') && mw.util.isBrowser('safari') )
4039 && ( mw.util.isBrowser('safari')
4140 || mw.util.isPlatform('mac')
4241 || mw.util.isBrowser('konqueror') ) ) {
4342 this.tooltipAccessKeyPrefix = 'ctrl-';
44 -
 43+
4544 // Firefox 2.x
4645 } else if ( mw.util.isBrowser('firefox') && mw.util.isBrowserVersion('2') ) {
4746 this.tooltipAccessKeyPrefix = 'alt-shift-';
@@ -56,7 +55,7 @@
5756 mw.util.$content = $('#article');
5857 } else {
5958 mw.util.$content = $('#content');
60 - }
 59+ }
6160 });
6261
6362

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75593porting is_opera, is_safari_win etc. to mw.util as isBrowser('..'), isPlatfor...krinkle23:19, 27 October 2010

Status & tagging log