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

Revision: 75653
Author:   krinkle
Date:     2010-10-29 17:11:22 +0000 (Fri, 29 Oct 2010)
Log Message:
-----------
$.client has been enhanced and made easier since the initial version, may 
aswell be used directly (r75593)

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

Modified: trunk/phase3/resources/mediawiki.util/mediawiki.util.js
===================================================================
--- trunk/phase3/resources/mediawiki.util/mediawiki.util.js     2010-10-29 
17:05:24 UTC (rev 75652)
+++ trunk/phase3/resources/mediawiki.util/mediawiki.util.js     2010-10-29 
17:11:22 UTC (rev 75653)
@@ -15,33 +15,33 @@
                                // Any initialisation after the DOM is ready
                                $(function () {
 
-                                       // Populate clientProfile var
-                                       mw.util.clientProfile = 
$.client.profile();
+                                       // Initiate jQuery.client.profile
+                                       $.client.profile();
 
                                        // Set tooltipAccessKeyPrefix
 
                                        // Opera on any platform
-                                       if ( mw.util.isBrowser('opera') ) {
+                                       if ( $.client.profile.name == 'opera' ) 
{
                                                this.tooltipAccessKeyPrefix = 
'shift-esc-';
 
                                        // Chrome on any platform
-                                       } else if ( mw.util.isBrowser('chrome') 
) {
+                                       } else if ( $.client.profile.name == 
'chrome' ) {
                                                // Chrome on Mac or Chrome on 
other platform ?
-                                               this.tooltipAccessKeyPrefix = 
mw.util.isPlatform('mac') ? 'ctrl-option-' : 'alt-';
+                                               this.tooltipAccessKeyPrefix = 
$.client.profile.platform == 'mac' ? 'ctrl-option-' : 'alt-';
 
                                        // Non-Windows Safari with 
webkit_version > 526
-                                       } else if ( !mw.util.isPlatform('win') 
&& mw.util.isBrowser('safari') && webkit_version > 526 ) {
+                                       } else if ( $.client.profile.platform 
!== 'win' && $.client.profile.name == 'safari' && 
$.client.profile.layoutVersion > 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') ) ) {
+                                       } else if ( !( 
$.client.profile.platform == 'win' && $.client.profile.name == 'safari' )
+                                                                       && ( 
$.client.profile.name == 'safari'
+                                                                         || 
$.client.profile.platform == 'mac'
+                                                                         || 
$.client.profile.name == 'konqueror' ) ) {
                                                this.tooltipAccessKeyPrefix = 
'ctrl-';
 
                                        // Firefox 2.x
-                                       } else if ( 
mw.util.isBrowser('firefox') && mw.util.isBrowserVersion('2') ) {
+                                       } else if ( $.client.profile.name == 
'firefox' && $.client.profile.versionBase == '2' ) {
                                                this.tooltipAccessKeyPrefix = 
'alt-shift-';
                                        }
 
@@ -66,69 +66,7 @@
 
                /* Main body */
 
-               // Holds result of $.client.profile()
-               // Populated by init()
-               'clientProfile' : {},
-
                /**
-               * Checks if the current browser matches
-               *
-               * @example      mw.util.isBrowser( 'safari' );
-               * @param        String  str     name of a browser (case 
insensitive). Check jquery.client.js for possible values
-               * @return       Boolean         true if the browsername matches 
the clients browser
-               */
-               'isBrowser' : function( str ) {
-                       str = (str + '').toLowerCase();
-                       return this.clientProfile.name == str;
-               },
-
-               /**
-               * Checks if the current layout matches
-               *
-               * @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 if the layout engine 
matches the clients browser
-               */
-               'isLayout' : function( str ) {
-                       str = (str + '').toLowerCase();
-                       return this.clientProfile.layout == str;
-               },
-
-               /**
-               * 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 if the platform matches 
the clients platform
-               */
-               'isPlatform' : function( str ) {
-                       str = (str + '').toLowerCase();
-                       return this.clientProfile.platform == str;
-               },
-
-               /**
-               * Checks if the current browser version matches
-               *
-               * @example      mw.util.isBrowserVersion( '5' );
-               * @param        String  str     version number without decimals
-               * @return       Boolean         true if the version number 
matches the clients browser
-               */
-               'isBrowserVersion' : function( str ) {
-                       return this.clientProfile.versionBase === str;
-               },
-
-               /**
                * Encodes the string like PHP's rawurlencode
                *
                * @param String str             string to be encoded

Modified: trunk/phase3/resources/mediawiki.util/mediawiki.util.test.js
===================================================================
--- trunk/phase3/resources/mediawiki.util/mediawiki.util.test.js        
2010-10-29 17:05:24 UTC (rev 75652)
+++ trunk/phase3/resources/mediawiki.util/mediawiki.util.test.js        
2010-10-29 17:11:22 UTC (rev 75653)
@@ -78,14 +78,6 @@
                                                        '\\.st\\{e\\}\\$st 
(string)');
                                                mw.test.addTest('typeof 
$.fn.checkboxShiftClick',
                                                        'function (string)');
-                                               mw.test.addTest('typeof 
mw.util.isBrowser( \'safari\' )',
-                                                       'boolean (string)');
-                                               mw.test.addTest('typeof 
mw.util.isLayout( \'webKit\' )',
-                                                       'boolean (string)');
-                                               mw.test.addTest('typeof 
mw.util.isPlatform( \'MAC\' )',
-                                                       'boolean (string)');
-                                               mw.test.addTest('typeof 
mw.util.isBrowserVersion( \'5\' )',
-                                                       'boolean (string)');
                                                mw.test.addTest('typeof 
mw.util.rawurlencode',
                                                        'function (string)');
                                                
mw.test.addTest('mw.util.rawurlencode( \'Test: A&B/Here\' )',


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

Reply via email to