From 053f1e4901051e2d7c02665e0d2609fc9ddc55b0 Mon Sep 17 00:00:00 2001 From: Krinkle Date: Fri, 29 Oct 2010 17:11:22 +0000 Subject: [PATCH] $.client has been enhanced and made easier since the initial version, may aswell be used directly (r75593) --- resources/mediawiki.util/mediawiki.util.js | 84 +++---------------- .../mediawiki.util/mediawiki.util.test.js | 8 -- 2 files changed, 11 insertions(+), 81 deletions(-) diff --git a/resources/mediawiki.util/mediawiki.util.js b/resources/mediawiki.util/mediawiki.util.js index 6ccd3fba6c..4105786a20 100644 --- a/resources/mediawiki.util/mediawiki.util.js +++ b/resources/mediawiki.util/mediawiki.util.js @@ -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,68 +66,6 @@ /* 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 * diff --git a/resources/mediawiki.util/mediawiki.util.test.js b/resources/mediawiki.util/mediawiki.util.test.js index a30ad4404d..dc955cce61 100644 --- a/resources/mediawiki.util/mediawiki.util.test.js +++ b/resources/mediawiki.util/mediawiki.util.test.js @@ -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\' )', -- 2.20.1