Index: trunk/phase3/resources/jquery/jquery.client.js |
— | — | @@ -1,17 +1,17 @@ |
2 | 2 | /* |
3 | | - * User-agent detection |
| 3 | + * User-agent detection |
4 | 4 | */ |
5 | 5 | jQuery.client = new ( function() { |
6 | | - |
| 6 | + |
7 | 7 | /* Private Members */ |
8 | | - |
| 8 | + |
9 | 9 | var profile; |
10 | | - |
| 10 | + |
11 | 11 | /* Public Functions */ |
12 | | - |
| 12 | + |
13 | 13 | /** |
14 | 14 | * Returns an object containing information about the browser |
15 | | - * |
| 15 | + * |
16 | 16 | * The resulting client object will be in the following format: |
17 | 17 | * { |
18 | 18 | * 'name': 'firefox', |
— | — | @@ -26,9 +26,9 @@ |
27 | 27 | this.profile = function() { |
28 | 28 | // Use the cached version if possible |
29 | 29 | if ( typeof profile === 'undefined' ) { |
30 | | - |
| 30 | + |
31 | 31 | /* Configuration */ |
32 | | - |
| 32 | + |
33 | 33 | // Name of browsers or layout engines we don't recognize |
34 | 34 | var uk = 'unknown'; |
35 | 35 | // Generic version digit |
— | — | @@ -75,9 +75,9 @@ |
76 | 76 | var platforms = ['win', 'mac', 'linux', 'sunos', 'solaris', 'iphone']; |
77 | 77 | // Translations for conforming operating system names |
78 | 78 | var platformTranslations = [['sunos', 'solaris']]; |
79 | | - |
| 79 | + |
80 | 80 | /* Methods */ |
81 | | - |
| 81 | + |
82 | 82 | // Performs multiple replacements on a string |
83 | 83 | function translate( source, translations ) { |
84 | 84 | for ( var i = 0; i < translations.length; i++ ) { |
— | — | @@ -85,9 +85,9 @@ |
86 | 86 | } |
87 | 87 | return source; |
88 | 88 | }; |
89 | | - |
| 89 | + |
90 | 90 | /* Pre-processing */ |
91 | | - |
| 91 | + |
92 | 92 | var userAgent = navigator.userAgent, match, name = uk, layout = uk, layoutversion = uk, platform = uk, version = x; |
93 | 93 | if ( match = new RegExp( '(' + wildUserAgents.join( '|' ) + ')' ).exec( userAgent ) ) { |
94 | 94 | // Takes a userAgent string and translates given text into something we can more easily work with |
— | — | @@ -95,9 +95,9 @@ |
96 | 96 | } |
97 | 97 | // Everything will be in lowercase from now on |
98 | 98 | userAgent = userAgent.toLowerCase(); |
99 | | - |
| 99 | + |
100 | 100 | /* Extraction */ |
101 | | - |
| 101 | + |
102 | 102 | if ( match = new RegExp( '(' + names.join( '|' ) + ')' ).exec( userAgent ) ) { |
103 | 103 | name = translate( match[1], nameTranslations ); |
104 | 104 | } |
— | — | @@ -113,9 +113,9 @@ |
114 | 114 | if ( match = new RegExp( '(' + versionPrefixes.join( '|' ) + ')' + versionSuffix ).exec( userAgent ) ) { |
115 | 115 | version = match[3]; |
116 | 116 | } |
117 | | - |
| 117 | + |
118 | 118 | /* Edge Cases -- did I mention about how user agent string lie? */ |
119 | | - |
| 119 | + |
120 | 120 | // Decode Safari's crazy 400+ version numbers |
121 | 121 | if ( name.match( /safari/ ) && version > 400 ) { |
122 | 122 | version = '2.0'; |
— | — | @@ -124,9 +124,9 @@ |
125 | 125 | if ( name === 'opera' && version >= 9.8) { |
126 | 126 | version = userAgent.match( /version\/([0-9\.]*)/i )[1] || 10; |
127 | 127 | } |
128 | | - |
| 128 | + |
129 | 129 | /* Caching */ |
130 | | - |
| 130 | + |
131 | 131 | profile = { |
132 | 132 | 'name': name, |
133 | 133 | 'layout': layout, |
— | — | @@ -139,12 +139,12 @@ |
140 | 140 | } |
141 | 141 | return profile; |
142 | 142 | }; |
143 | | - |
| 143 | + |
144 | 144 | /** |
145 | 145 | * Checks the current browser against a support map object to determine if the browser has been black-listed or |
146 | 146 | * not. If the browser was not configured specifically it is assumed to work. It is assumed that the body |
147 | 147 | * element is classified as either "ltr" or "rtl". If neither is set, "ltr" is assumed. |
148 | | - * |
| 148 | + * |
149 | 149 | * A browser map is in the following format: |
150 | 150 | * { |
151 | 151 | * 'ltr': { |
— | — | @@ -160,9 +160,9 @@ |
161 | 161 | * 'iphone': false |
162 | 162 | * } |
163 | 163 | * } |
164 | | - * |
| 164 | + * |
165 | 165 | * @param map Object of browser support map |
166 | | - * |
| 166 | + * |
167 | 167 | * @return Boolean true if browser known or assumed to be supported, false if blacklisted |
168 | 168 | */ |
169 | 169 | this.test = function( map ) { |
Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -14,33 +14,32 @@ |
15 | 15 | |
16 | 16 | // Any initialisation after the DOM is ready |
17 | 17 | $(function () { |
18 | | - |
| 18 | + |
19 | 19 | // Populate clientProfile var |
20 | 20 | mw.util.clientProfile = $.client.profile(); |
21 | | - var webkit = navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); |
22 | 21 | |
23 | 22 | // Set tooltipAccessKeyPrefix |
24 | | - |
| 23 | + |
25 | 24 | // Opera on any platform |
26 | 25 | if ( mw.util.isBrowser('opera') ) { |
27 | 26 | this.tooltipAccessKeyPrefix = 'shift-esc-'; |
28 | | - |
| 27 | + |
29 | 28 | // Chrome on any platform |
30 | 29 | } else if ( mw.util.isBrowser('chrome') ) { |
31 | 30 | // Chrome on Mac or Chrome on other platform ? |
32 | 31 | this.tooltipAccessKeyPrefix = mw.util.isPlatform('mac') ? 'ctrl-option-' : 'alt-'; |
33 | | - |
| 32 | + |
34 | 33 | // Non-Windows Safari with webkit_version > 526 |
35 | 34 | } else if ( !mw.util.isPlatform('win') && mw.util.isBrowser('safari') && webkit_version > 526 ) { |
36 | 35 | this.tooltipAccessKeyPrefix = 'ctrl-alt-'; |
37 | | - |
| 36 | + |
38 | 37 | // Safari/Konqueror on any platform, or any browser on Mac (but not Safari on Windows) |
39 | 38 | } else if ( !( mw.util.isPlatform('win') && mw.util.isBrowser('safari') ) |
40 | 39 | && ( mw.util.isBrowser('safari') |
41 | 40 | || mw.util.isPlatform('mac') |
42 | 41 | || mw.util.isBrowser('konqueror') ) ) { |
43 | 42 | this.tooltipAccessKeyPrefix = 'ctrl-'; |
44 | | - |
| 43 | + |
45 | 44 | // Firefox 2.x |
46 | 45 | } else if ( mw.util.isBrowser('firefox') && mw.util.isBrowserVersion('2') ) { |
47 | 46 | this.tooltipAccessKeyPrefix = 'alt-shift-'; |
— | — | @@ -56,7 +55,7 @@ |
57 | 56 | mw.util.$content = $('#article'); |
58 | 57 | } else { |
59 | 58 | mw.util.$content = $('#content'); |
60 | | - } |
| 59 | + } |
61 | 60 | }); |
62 | 61 | |
63 | 62 | |