http://www.mediawiki.org/wiki/Special:Code/MediaWiki/75644

Revision: 75644
Author:   krinkle
Date:     2010-10-29 15:27:53 +0000 (Fri, 29 Oct 2010)
Log Message:
-----------
adding layoutversion to $.client and isLayoutVersion to mw.util. Follow-up of 
r75593

Modified Paths:
--------------
    trunk/phase3/resources/jquery/jquery.client.js
    trunk/phase3/resources/mediawiki.util/mediawiki.util.js

Modified: trunk/phase3/resources/jquery/jquery.client.js
===================================================================
--- trunk/phase3/resources/jquery/jquery.client.js      2010-10-29 15:14:44 UTC 
(rev 75643)
+++ trunk/phase3/resources/jquery/jquery.client.js      2010-10-29 15:27:53 UTC 
(rev 75644)
@@ -16,6 +16,7 @@
         *  {
         *              'name': 'firefox',
         *              'layout': 'gecko',
+        *              'layoutVersion': '20101026',
         *              'platform': 'linux'
         *              'version': '3.5.1',
         *              'versionBase': '3',
@@ -68,6 +69,8 @@
                        var layouts = ['gecko', 'konqueror', 'msie', 'opera', 
'webkit'];
                        // Translations for conforming layout names
                        var layoutTranslations = [['konqueror', 'khtml'], 
['msie', 'trident'], ['opera', 'presto']];
+                       // Names of supported layout engines for version number
+                       var layoutVersions = ['applewebkit', 'gecko'];
                        // Names of known operating systems
                        var platforms = ['win', 'mac', 'linux', 'sunos', 
'solaris', 'iphone'];
                        // Translations for conforming operating system names
@@ -85,7 +88,7 @@
                        
                        /* Pre-processing  */
                        
-                       var userAgent = navigator.userAgent, match, name = uk, 
layout = uk, platform = uk, version = x;
+                       var userAgent = navigator.userAgent, match, name = uk, 
layout = uk, layoutversion = uk, platform = uk, version = x;
                        if ( match = new RegExp( '(' + wildUserAgents.join( '|' 
) + ')' ).exec( userAgent ) ) {
                                // Takes a userAgent string and translates 
given text into something we can more easily work with
                                userAgent = translate( userAgent, 
userAgentTranslations );
@@ -101,6 +104,9 @@
                        if ( match = new RegExp( '(' + layouts.join( '|' ) + 
')' ).exec( userAgent ) ) {
                                layout = translate( match[1], 
layoutTranslations );
                        }
+                       if ( match = new RegExp( '(' + layoutVersions.join( '|' 
) + ')\\\/(\\d+)').exec( navigator.userAgent.toLowerCase() ) ) {
+                               layoutversion = parseInt(match[2]);
+                       }
                        if ( match = new RegExp( '(' + platforms.join( '|' ) + 
')' ).exec( navigator.platform.toLowerCase() ) ) {
                                platform = translate( match[1], 
platformTranslations );
                        }
@@ -124,6 +130,7 @@
                        profile = {
                                'name': name,
                                'layout': layout,
+                               'layoutVersion': layoutversion,
                                'platform': platform,
                                'version': version,
                                'versionBase': ( version !== x ? new String( 
version ).substr( 0, 1 ) : x ),

Modified: trunk/phase3/resources/mediawiki.util/mediawiki.util.js
===================================================================
--- trunk/phase3/resources/mediawiki.util/mediawiki.util.js     2010-10-29 
15:14:44 UTC (rev 75643)
+++ trunk/phase3/resources/mediawiki.util/mediawiki.util.js     2010-10-29 
15:27:53 UTC (rev 75644)
@@ -17,33 +17,34 @@
                                        
                                        // Populate clientProfile var
                                        mw.util.clientProfile = 
$.client.profile();
+                                       var webkit = 
navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
 
                                        // Set tooltipAccessKeyPrefix
                                        
-                                               // Opera on any platform
-                                               if ( mw.util.isBrowser('opera') 
) {
-                                                       
this.tooltipAccessKeyPrefix = 'shift-esc-';
-                                               
-                                               // Chrome on any platform
-                                               } else if ( 
mw.util.isBrowser('chrome') ) {
-                                                       // Chrome on Mac or 
Chrome on other platform ?
-                                                       
this.tooltipAccessKeyPrefix = mw.util.isPlatform('mac') ? 'ctrl-option-' : 
'alt-';
-                                               
-                                               // Non-Windows Safari with 
webkit_version > 526
-                                               } else if ( 
!mw.util.isPlatform('win') && mw.util.isBrowser('safari') && webkit_version > 
526 ) {
-                                                       
this.tooltipAccessKeyPrefix = 'ctrl-alt-';
-                                               
-                                               // Safari/Konqueror on any 
platform, or any browser on Mac (but not Safari on Windows)
-                                               } else if ( !( 
mw.util.isPlatform('win') && mw.util.isBrowser('safari') )
-                                                                               
&& ( mw.util.isBrowser('safari')
-                                                                               
  || mw.util.isPlatform('mac')
-                                                                               
  || mw.util.isBrowser('konqueror') ) ) {
-                                                       
this.tooltipAccessKeyPrefix = 'ctrl-';
-                                               
-                                               // Firefox 2.x
-                                               } else if ( 
mw.util.isBrowser('firefox') && mw.util.isBrowserVersion('2') ) {
-                                                       
this.tooltipAccessKeyPrefix = 'alt-shift-';
-                                               }
+                                       // Opera on any platform
+                                       if ( mw.util.isBrowser('opera') ) {
+                                               this.tooltipAccessKeyPrefix = 
'shift-esc-';
+                                       
+                                       // Chrome on any platform
+                                       } else if ( mw.util.isBrowser('chrome') 
) {
+                                               // Chrome on Mac or Chrome on 
other platform ?
+                                               this.tooltipAccessKeyPrefix = 
mw.util.isPlatform('mac') ? 'ctrl-option-' : 'alt-';
+                                       
+                                       // Non-Windows Safari with 
webkit_version > 526
+                                       } else if ( !mw.util.isPlatform('win') 
&& mw.util.isBrowser('safari') && webkit_version > 526 ) {
+                                               this.tooltipAccessKeyPrefix = 
'ctrl-alt-';
+                                       
+                                       // Safari/Konqueror on any platform, or 
any browser on Mac (but not Safari on Windows)
+                                       } else if ( !( 
mw.util.isPlatform('win') && mw.util.isBrowser('safari') )
+                                                                       && ( 
mw.util.isBrowser('safari')
+                                                                         || 
mw.util.isPlatform('mac')
+                                                                         || 
mw.util.isBrowser('konqueror') ) ) {
+                                               this.tooltipAccessKeyPrefix = 
'ctrl-';
+                                       
+                                       // Firefox 2.x
+                                       } else if ( 
mw.util.isBrowser('firefox') && mw.util.isBrowserVersion('2') ) {
+                                               this.tooltipAccessKeyPrefix = 
'alt-shift-';
+                                       }
 
                                        // Enable CheckboxShiftClick
                                        
$('input[type=checkbox]:not(.noshiftselect)').checkboxShiftClick();
@@ -75,7 +76,7 @@
                *
                * @example      mw.util.isBrowser( 'safari' );
                * @param        String  str     name of a browser (case 
insensitive). Check jquery.client.js for possible values
-               * @return       Boolean         true of the browsername matches 
the clients browser
+               * @return       Boolean         true if the browsername matches 
the clients browser
                */
                'isBrowser' : function( str ) {
                        str = (str + '').toLowerCase();
@@ -87,7 +88,7 @@
                *
                * @example      mw.util.isLayout( 'webkit' );
                * @param        String  str     name of a layout engine (case 
insensitive). Check jquery.client.js for possible values
-               * @return       Boolean         true of the layout engine 
matches the clients browser
+               * @return       Boolean         true if the layout engine 
matches the clients browser
                */
                'isLayout' : function( str ) {
                        str = (str + '').toLowerCase();
@@ -95,11 +96,22 @@
                },
 
                /**
+               * Checks if the current layout engine version matches
+               *
+               * @example      mw.util.isLayoutVersion( 533 );
+               * @param        Number  num     version number of a layout 
engine.
+               * @return       Boolean         true if the layout engine 
matches the clients browser
+               */
+               'isLayoutVersion' : function( num ) {
+                       return this.clientProfile.layoutVersion == num;
+               },
+
+               /**
                * Checks if the current layout matches
                *
                * @example      mw.util.isPlatform( 'mac' );
                * @param        String  str     name of a platform (case 
insensitive). Check jquery.client.js for possible values
-               * @return       Boolean         true of the platform matches 
the clients platform
+               * @return       Boolean         true if the platform matches 
the clients platform
                */
                'isPlatform' : function( str ) {
                        str = (str + '').toLowerCase();
@@ -111,7 +123,7 @@
                *
                * @example      mw.util.isBrowserVersion( '5' );
                * @param        String  str     version number without decimals
-               * @return       Boolean         true of the version number 
matches the clients browser
+               * @return       Boolean         true if the version number 
matches the clients browser
                */
                'isBrowserVersion' : function( str ) {
                        return this.clientProfile.versionBase === str;


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to