Index: trunk/phase3/resources/jquery/jquery.client.js |
— | — | @@ -1,8 +1,14 @@ |
2 | 2 | /* |
3 | 3 | * User-agent detection |
4 | 4 | */ |
5 | | - |
6 | | -jQuery.client = { |
| 5 | +jQuery.client = new ( function() { |
| 6 | + |
| 7 | + /* Private Members */ |
| 8 | + |
| 9 | + var profile; |
| 10 | + |
| 11 | + /* Public Functions */ |
| 12 | + |
7 | 13 | /** |
8 | 14 | * Returns an object containing information about the browser |
9 | 15 | * |
— | — | @@ -16,9 +22,9 @@ |
17 | 23 | * 'versionNumber': 3.5, |
18 | 24 | * } |
19 | 25 | */ |
20 | | - 'profile': function() { |
| 26 | + this.profile = function() { |
21 | 27 | // Use the cached version if possible |
22 | | - if ( typeof this.profile === 'undefined' ) { |
| 28 | + if ( typeof profile === 'undefined' ) { |
23 | 29 | |
24 | 30 | /* Configuration */ |
25 | 31 | |
— | — | @@ -115,7 +121,7 @@ |
116 | 122 | |
117 | 123 | /* Caching */ |
118 | 124 | |
119 | | - this.profile = { |
| 125 | + profile = { |
120 | 126 | 'browser': browser, |
121 | 127 | 'layout': layout, |
122 | 128 | 'os': os, |
— | — | @@ -124,8 +130,9 @@ |
125 | 131 | 'versionNumber': ( parseFloat( version, 10 ) || 0.0 ) |
126 | 132 | }; |
127 | 133 | } |
128 | | - return this.profile; |
129 | | - }, |
| 134 | + return profile; |
| 135 | + }; |
| 136 | + |
130 | 137 | /** |
131 | 138 | * Checks the current browser against a support map object to determine if the browser has been black-listed or |
132 | 139 | * not. If the browser was not configured specifically it is assumed to work. It is assumed that the body |
— | — | @@ -151,14 +158,15 @@ |
152 | 159 | * |
153 | 160 | * @return Boolean true if browser known or assumed to be supported, false if blacklisted |
154 | 161 | */ |
155 | | - 'test': function( map ) { |
156 | | - var profile = $.client.profile(); |
| 162 | + this.test = function( map ) { |
| 163 | + var profile = jQuery.client.profile(); |
| 164 | + var dir = jQuery( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'; |
157 | 165 | // Check over each browser condition to determine if we are running in a compatible client |
158 | | - var browser = map[$( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'][profile.browser]; |
159 | | - if ( typeof browser !== 'object' ) { |
| 166 | + if ( typeof map[dir] !== 'object' || map[dir][profile.browser] !== 'object' ) { |
160 | 167 | // Unknown, so we assume it's working |
161 | 168 | return true; |
162 | 169 | } |
| 170 | + var browser = map[dir][profile.browser]; |
163 | 171 | for ( var condition in browser ) { |
164 | 172 | var op = browser[condition][0]; |
165 | 173 | var val = browser[condition][1]; |
— | — | @@ -176,4 +184,4 @@ |
177 | 185 | } |
178 | 186 | return true; |
179 | 187 | } |
180 | | -}; |
\ No newline at end of file |
| 188 | +} )(); |
\ No newline at end of file |