$.client has been enhanced and made easier since the initial version, may aswell...
authorKrinkle <krinkle@users.mediawiki.org>
Fri, 29 Oct 2010 17:11:22 +0000 (17:11 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Fri, 29 Oct 2010 17:11:22 +0000 (17:11 +0000)
resources/mediawiki.util/mediawiki.util.js
resources/mediawiki.util/mediawiki.util.test.js

index 6ccd3fb..4105786 100644 (file)
                                // 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-';
                                        }
 
 
                /* 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
                *
index a30ad44..dc955cc 100644 (file)
                                                        '\\.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\' )',