Index: trunk/phase3/resources/jquery/jquery.client.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /** |
3 | 3 | * User-agent detection |
4 | 4 | */ |
5 | | -( function( $ ) { |
| 5 | +( function ( $ ) { |
6 | 6 | |
7 | 7 | /* Private Members */ |
8 | 8 | |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | /** |
20 | 20 | * Get an object containing information about the client. |
21 | 21 | * |
22 | | - * @param nav {Object} An object with atleast a 'userAgent' and 'platform' key.= |
| 22 | + * @param nav {Object} An object with atleast a 'userAgent' and 'platform' key. |
23 | 23 | * Defaults to the global Navigator object. |
24 | 24 | * @return {Object} The resulting client object will be in the following format: |
25 | 25 | * { |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | * 'versionNumber': 3.5, |
33 | 33 | * } |
34 | 34 | */ |
35 | | - profile: function( nav ) { |
| 35 | + profile: function ( nav ) { |
36 | 36 | if ( nav === undefined ) { |
37 | 37 | nav = window.navigator; |
38 | 38 | } |
— | — | @@ -64,15 +64,15 @@ |
65 | 65 | // Strings which precede a version number in a user agent string - combined and used as match 1 in |
66 | 66 | // version detectection |
67 | 67 | var versionPrefixes = [ |
68 | | - 'camino', 'chrome', 'firefox', 'netscape', 'netscape6', 'opera', 'version', 'konqueror', 'lynx', |
69 | | - 'msie', 'safari', 'ps3' |
| 68 | + 'camino', 'chrome', 'firefox', 'netscape', 'netscape6', 'opera', 'version', 'konqueror', |
| 69 | + 'lynx', 'msie', 'safari', 'ps3' |
70 | 70 | ]; |
71 | 71 | // Used as matches 2, 3 and 4 in version extraction - 3 is used as actual version number |
72 | 72 | var versionSuffix = '(\\/|\\;?\\s|)([a-z0-9\\.\\+]*?)(\\;|dev|rel|\\)|\\s|$)'; |
73 | 73 | // Names of known browsers |
74 | 74 | var names = [ |
75 | | - 'camino', 'chrome', 'firefox', 'netscape', 'konqueror', 'lynx', 'msie', 'opera', 'safari', 'ipod', |
76 | | - 'iphone', 'blackberry', 'ps3', 'rekonq' |
| 75 | + 'camino', 'chrome', 'firefox', 'netscape', 'konqueror', 'lynx', 'msie', 'opera', |
| 76 | + 'safari', 'ipod', 'iphone', 'blackberry', 'ps3', 'rekonq' |
77 | 77 | ]; |
78 | 78 | // Tanslations for conforming browser names |
79 | 79 | var nameTranslations = []; |
— | — | @@ -89,9 +89,12 @@ |
90 | 90 | |
91 | 91 | /* Methods */ |
92 | 92 | |
93 | | - // Performs multiple replacements on a string |
94 | | - var translate = function( source, translations ) { |
95 | | - for ( var i = 0; i < translations.length; i++ ) { |
| 93 | + /** |
| 94 | + * Performs multiple replacements on a string |
| 95 | + */ |
| 96 | + var translate = function ( source, translations ) { |
| 97 | + var i; |
| 98 | + for ( i = 0; i < translations.length; i++ ) { |
96 | 99 | source = source.replace( translations[i][0], translations[i][1] ); |
97 | 100 | } |
98 | 101 | return source; |
— | — | @@ -147,13 +150,13 @@ |
148 | 151 | /* Caching */ |
149 | 152 | |
150 | 153 | profileCache[nav.userAgent] = { |
151 | | - 'name': name, |
152 | | - 'layout': layout, |
153 | | - 'layoutVersion': layoutversion, |
154 | | - 'platform': platform, |
155 | | - 'version': version, |
156 | | - 'versionBase': ( version !== x ? Math.floor( versionNumber ).toString() : x ), |
157 | | - 'versionNumber': versionNumber |
| 154 | + name: name, |
| 155 | + layout: layout, |
| 156 | + layoutVersion: layoutversion, |
| 157 | + platform: platform, |
| 158 | + version: version, |
| 159 | + versionBase: ( version !== x ? Math.floor( versionNumber ).toString() : x ), |
| 160 | + versionNumber: versionNumber |
158 | 161 | }; |
159 | 162 | } |
160 | 163 | return profileCache[nav.userAgent]; |
— | — | @@ -185,26 +188,28 @@ |
186 | 189 | * |
187 | 190 | * @return Boolean true if browser known or assumed to be supported, false if blacklisted |
188 | 191 | */ |
189 | | - test: function( map, profile ) { |
| 192 | + test: function ( map, profile ) { |
| 193 | + var conditions, dir, i, op, val; |
190 | 194 | profile = $.isPlainObject( profile ) ? profile : $.client.profile(); |
191 | 195 | |
192 | | - var dir = $( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'; |
| 196 | + dir = $( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'; |
193 | 197 | // Check over each browser condition to determine if we are running in a compatible client |
194 | | - if ( typeof map[dir] !== 'object' || typeof map[dir][profile.name] === 'undefined' ) { |
| 198 | + if ( typeof map[dir] !== 'object' || map[dir][profile.name] === undefined ) { |
195 | 199 | // Unknown, so we assume it's working |
196 | 200 | return true; |
197 | 201 | } |
198 | | - var conditions = map[dir][profile.name]; |
199 | | - for ( var i = 0; i < conditions.length; i++ ) { |
200 | | - var op = conditions[i][0]; |
201 | | - var val = conditions[i][1]; |
| 202 | + conditions = map[dir][profile.name]; |
| 203 | + for ( i = 0; i < conditions.length; i++ ) { |
| 204 | + op = conditions[i][0]; |
| 205 | + val = conditions[i][1]; |
202 | 206 | if ( val === false ) { |
203 | 207 | return false; |
204 | | - } else if ( typeof val == 'string' ) { |
| 208 | + } |
| 209 | + if ( typeof val === 'string' ) { |
205 | 210 | if ( !( eval( 'profile.version' + op + '"' + val + '"' ) ) ) { |
206 | 211 | return false; |
207 | 212 | } |
208 | | - } else if ( typeof val == 'number' ) { |
| 213 | + } else if ( typeof val === 'number' ) { |
209 | 214 | if ( !( eval( 'profile.versionNumber' + op + val ) ) ) { |
210 | 215 | return false; |
211 | 216 | } |
— | — | @@ -213,4 +218,4 @@ |
214 | 219 | return true; |
215 | 220 | } |
216 | 221 | }; |
217 | | -} )( jQuery ); |
| 222 | +}( jQuery ) ); |