resources: Update jquery-client from 2.0.2 to 3.0.0
Bug: T262223 Change-Id: I29a1f086f0fbc93336965925244d9d9efa17513b
This commit is contained in:
parent
dcc88f70f4
commit
70f07bfd66
5 changed files with 107 additions and 87 deletions
|
|
@ -62,6 +62,7 @@ For notes on 1.35.x and older releases, see HISTORY.
|
|||
* pear/mail_mime was upgraded from 1.10.8 to 1.10.9.
|
||||
* wikimedia/html-formatter was upgraded from 1.0.2 to 2.0.0.
|
||||
* Updated OOUI from 0.39.3 to 0.40.3.
|
||||
* Updated jquery.client from 2.0.2 to 3.0.0.
|
||||
* …
|
||||
|
||||
===== Changed development-only external libraries =====
|
||||
|
|
|
|||
|
|
@ -129,8 +129,8 @@ jquery.chosen:
|
|||
|
||||
jquery.client:
|
||||
type: tar
|
||||
src: https://registry.npmjs.org/jquery-client/-/jquery-client-2.0.2.tgz
|
||||
integrity: sha256-8c8nBbBykHEMc4I7ksdKJvvw/P7WkaC2X46RTPdz/pw=
|
||||
src: https://registry.npmjs.org/jquery-client/-/jquery-client-3.0.0.tgz
|
||||
integrity: sha256-BRPTsJn7fViZ2ip0YUBT9L90wJ8s0BFE17ccpmLfPUk=
|
||||
dest:
|
||||
package/AUTHORS.txt:
|
||||
package/jquery.client.js:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Copyright 2010-2015 jquery-client maintainers and other contributors.
|
||||
Copyright 2010-2020 wikimedia/jquery-client maintainers and other contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
[](https://travis-ci.org/wikimedia/jquery-client) [](https://www.npmjs.com/package/jquery-client)
|
||||
[](https://www.npmjs.com/package/jquery-client)
|
||||
|
||||
jQuery Client
|
||||
=================
|
||||
|
||||
jQuery Client is a jQuery plugin for user-agent detection.
|
||||
A minimal user-agent parser for client-side JavaScript.
|
||||
|
||||
## Documentation
|
||||
|
||||
See [API Documentation](https://doc.wikimedia.org/jquery-client/master/#!/api/jQuery.client) and [Test coverage](https://doc.wikimedia.org/cover/jquery-client/) on doc.wikimedia.org.
|
||||
|
||||
## Issue tracker
|
||||
|
||||
Report bugs or feature requests to [Wikimedia Phabricator](https://phabricator.wikimedia.org/tag/jquery-client/).
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
/*!
|
||||
* jQuery Client v2.0.2
|
||||
* https://www.mediawiki.org/wiki/JQuery_Client
|
||||
* jQuery Client 3.0.0
|
||||
* https://gerrit.wikimedia.org/g/jquery-client/
|
||||
*
|
||||
* Copyright 2010-2019 jquery-client maintainers and other contributors.
|
||||
* Copyright 2010-2020 wikimedia/jquery-client maintainers and other contributors.
|
||||
* Released under the MIT license
|
||||
* http://jquery-client.mit-license.org
|
||||
* https://jquery-client.mit-license.org
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -27,9 +27,7 @@
|
|||
/**
|
||||
* Get an object containing information about the client.
|
||||
*
|
||||
* @param {Object} [nav] An object with a 'userAgent' and 'platform' property.
|
||||
* Defaults to the global `navigator` object.
|
||||
* @return {Object} The resulting client object will be in the following format:
|
||||
* The resulting client object will be in the following format:
|
||||
*
|
||||
* {
|
||||
* 'name': 'firefox',
|
||||
|
|
@ -40,14 +38,65 @@
|
|||
* 'versionBase': '3',
|
||||
* 'versionNumber': 3.5,
|
||||
* }
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* if ( $.client.profile().layout == 'gecko' ) {
|
||||
* // This will only run in Gecko browsers, such as Mozilla Firefox.
|
||||
* }
|
||||
*
|
||||
* var profile = $.client.profile();
|
||||
* if ( profile.layout == 'gecko' && profile.platform == 'linux' ) {
|
||||
* // This will only run in Gecko browsers on Linux.
|
||||
* }
|
||||
*
|
||||
* Recognised browser names:
|
||||
*
|
||||
* - `android` (legacy Android browser, prior to Chrome Mobile)
|
||||
* - `chrome` (includes Chrome Mobile, Microsoft Edge, Opera, and others)
|
||||
* - `crios` (Chrome on iOS, which uses Mobile Safari)
|
||||
* - `edge` (legacy Microsoft Edge, which uses EdgeHTML)
|
||||
* - `firefox` (includes Firefox Mobile, Iceweasel, and others)
|
||||
* - `fxios` (Firefox on iOS, which uses Mobile Safari)
|
||||
* - `konqueror`
|
||||
* - `msie`
|
||||
* - `opera` (legacy Opera, which uses Presto)
|
||||
* - `rekonq`
|
||||
* - `safari` (including Mobile Safari)
|
||||
* - `silk`
|
||||
*
|
||||
* Recognised layout engines:
|
||||
*
|
||||
* - `edge` (EdgeHTML 12-18, as used by legacy Microsoft Edge)
|
||||
* - `gecko`
|
||||
* - `khtml`
|
||||
* - `presto`
|
||||
* - `trident`
|
||||
* - `webkit`
|
||||
*
|
||||
* Note that Chrome and Chromium-based browsers like Opera have their layout
|
||||
* engine identified as `webkit`.
|
||||
*
|
||||
* Recognised platforms:
|
||||
*
|
||||
* - `ipad`
|
||||
* - `iphone`
|
||||
* - `linux`
|
||||
* - `mac`
|
||||
* - `solaris` (untested)
|
||||
* - `win`
|
||||
*
|
||||
* @param {Object} [nav] An object with a 'userAgent' and 'platform' property.
|
||||
* Defaults to the global `navigator` object.
|
||||
* @return {Object} The client object
|
||||
*/
|
||||
profile: function ( nav ) {
|
||||
if ( nav === undefined ) {
|
||||
if ( !nav ) {
|
||||
nav = window.navigator;
|
||||
}
|
||||
|
||||
// Use the cached version if possible
|
||||
if ( profileCache[ nav.userAgent + '|' + nav.platform ] !== undefined ) {
|
||||
if ( profileCache[ nav.userAgent + '|' + nav.platform ] ) {
|
||||
return profileCache[ nav.userAgent + '|' + nav.platform ];
|
||||
}
|
||||
|
||||
|
|
@ -62,59 +111,33 @@
|
|||
uk = 'unknown',
|
||||
// Generic version digit
|
||||
x = 'x',
|
||||
// Strings found in user agent strings that need to be conformed
|
||||
wildUserAgents = [ 'Opera', 'Navigator', 'Minefield', 'KHTML', 'Chrome', 'PLAYSTATION 3', 'Iceweasel' ],
|
||||
// Translations for conforming user agent strings
|
||||
userAgentTranslations = [
|
||||
// Tons of browsers lie about being something they are not
|
||||
[ /(Firefox|MSIE|KHTML,?\slike\sGecko|Konqueror)/, '' ],
|
||||
// Fixups for user agent strings that contain wild words
|
||||
wildFixups = [
|
||||
// Chrome lives in the shadow of Safari still
|
||||
[ 'Chrome Safari', 'Chrome' ],
|
||||
// KHTML is the layout engine not the browser - LIES!
|
||||
[ 'KHTML', 'Konqueror' ],
|
||||
// Firefox nightly builds
|
||||
[ 'Minefield', 'Firefox' ],
|
||||
// This helps keep different versions consistent
|
||||
[ 'Navigator', 'Netscape' ],
|
||||
// This prevents version extraction issues,
|
||||
// otherwise translation would happen later
|
||||
[ 'PLAYSTATION 3', 'PS3' ]
|
||||
[ 'KHTML/', 'Konqueror/' ],
|
||||
// For Firefox Mobile, strip out "Android;" or "Android [version]" so that we
|
||||
// classify it as Firefox instead of Android (default browser)
|
||||
[ /Android(?:;|\s[a-zA-Z0-9.+-]+)(.*Firefox)/, '$1' ]
|
||||
],
|
||||
// Strings which precede a version number in a user agent string - combined and
|
||||
// used as match 1 in version detection
|
||||
versionPrefixes = [
|
||||
'camino', 'chrome', 'firefox', 'iceweasel', 'netscape', 'netscape6', 'opera', 'version', 'konqueror',
|
||||
'lynx', 'msie', 'safari', 'ps3', 'android'
|
||||
],
|
||||
// Used as matches 2, 3 and 4 in version extraction - 3 is used as actual
|
||||
// version number
|
||||
versionSuffix = '(\\/|\\;?\\s|)([a-z0-9\\.\\+]*?)(\\;|dev|rel|\\)|\\s|$)',
|
||||
// Names of known browsers
|
||||
names = [
|
||||
'camino', 'chrome', 'firefox', 'iceweasel', 'netscape', 'konqueror', 'lynx', 'msie', 'opera',
|
||||
'safari', 'ipod', 'iphone', 'blackberry', 'ps3', 'rekonq', 'android'
|
||||
],
|
||||
// Tanslations for conforming browser names
|
||||
nameTranslations = [],
|
||||
// Names of known layout engines
|
||||
layouts = [ 'gecko', 'konqueror', 'msie', 'trident', 'edge', 'opera', 'webkit' ],
|
||||
// Strings which precede a version number in a user agent string
|
||||
versionPrefixes = '(?:chrome|crios|firefox|fxios|opera|version|konqueror|msie|safari|android)',
|
||||
// This matches the actual version number, with non-capturing groups for the
|
||||
// separator and suffix
|
||||
versionSuffix = '(?:\\/|;?\\s|)([a-z0-9\\.\\+]*?)(?:;|dev|rel|\\)|\\s|$)',
|
||||
// Match the names of known browser families
|
||||
rName = /(chrome|crios|firefox|fxios|konqueror|msie|opera|safari|rekonq|android)/,
|
||||
// Match the name of known layout engines
|
||||
rLayout = /(gecko|konqueror|msie|trident|edge|opera|webkit)/,
|
||||
// Translations for conforming layout names
|
||||
layoutTranslations = [ [ 'konqueror', 'khtml' ], [ 'msie', 'trident' ], [ 'opera', 'presto' ] ],
|
||||
// Names of supported layout engines for version number
|
||||
layoutVersions = [ 'applewebkit', 'gecko', 'trident', 'edge' ],
|
||||
// Names of known operating systems
|
||||
platforms = [ 'win', 'wow64', 'mac', 'linux', 'sunos', 'solaris', 'iphone' ],
|
||||
layoutMap = { konqueror: 'khtml', msie: 'trident', opera: 'presto' },
|
||||
// Match the prefix and version of supported layout engines
|
||||
rLayoutVersion = /(applewebkit|gecko|trident|edge)\/(\d+)/,
|
||||
// Match the name of known operating systems
|
||||
rPlatform = /(win|wow64|mac|linux|sunos|solaris|iphone|ipad)/,
|
||||
// Translations for conforming operating system names
|
||||
platformTranslations = [ [ 'sunos', 'solaris' ], [ 'wow64', 'win' ] ],
|
||||
|
||||
// Performs multiple replacements on a string
|
||||
translate = function ( source, translations ) {
|
||||
var i;
|
||||
for ( i = 0; i < translations.length; i++ ) {
|
||||
source = source.replace( translations[ i ][ 0 ], translations[ i ][ 1 ] );
|
||||
}
|
||||
return source;
|
||||
},
|
||||
platformMap = { sunos: 'solaris', wow64: 'win' },
|
||||
|
||||
// Pre-processing
|
||||
|
||||
|
|
@ -126,35 +149,30 @@
|
|||
platform = uk,
|
||||
version = x;
|
||||
|
||||
if ( ( match = new RegExp( '(' + wildUserAgents.join( '|' ) + ')' ).exec( ua ) ) ) {
|
||||
// Takes a userAgent string and translates given text into something we can more
|
||||
// easily work with
|
||||
ua = translate( ua, userAgentTranslations );
|
||||
}
|
||||
// Takes a userAgent string and fixes it into something we can more
|
||||
// easily work with
|
||||
wildFixups.forEach( function ( fixup ) {
|
||||
ua = ua.replace( fixup[ 0 ], fixup[ 1 ] );
|
||||
} );
|
||||
// Everything will be in lowercase from now on
|
||||
ua = ua.toLowerCase();
|
||||
|
||||
// Firefox Mobile: Remove 'Android' identifier so it matches to 'Firefox' instead
|
||||
if ( ua.match( /android/ ) && ua.match( /firefox/ ) ) {
|
||||
ua = ua.replace( new RegExp( 'android' + versionSuffix ), '' );
|
||||
}
|
||||
|
||||
// Extraction
|
||||
|
||||
if ( ( match = new RegExp( '(' + names.join( '|' ) + ')' ).exec( ua ) ) ) {
|
||||
name = translate( match[ 1 ], nameTranslations );
|
||||
if ( ( match = rName.exec( ua ) ) ) {
|
||||
name = match[ 1 ];
|
||||
}
|
||||
if ( ( match = new RegExp( '(' + layouts.join( '|' ) + ')' ).exec( ua ) ) ) {
|
||||
layout = translate( match[ 1 ], layoutTranslations );
|
||||
if ( ( match = rLayout.exec( ua ) ) ) {
|
||||
layout = layoutMap[ match[ 1 ] ] || match[ 1 ];
|
||||
}
|
||||
if ( ( match = new RegExp( '(' + layoutVersions.join( '|' ) + ')\\/(\\d+)' ).exec( ua ) ) ) {
|
||||
if ( ( match = rLayoutVersion.exec( ua ) ) ) {
|
||||
layoutversion = parseInt( match[ 2 ], 10 );
|
||||
}
|
||||
if ( ( match = new RegExp( '(' + platforms.join( '|' ) + ')' ).exec( nav.platform.toLowerCase() ) ) ) {
|
||||
platform = translate( match[ 1 ], platformTranslations );
|
||||
if ( ( match = rPlatform.exec( nav.platform.toLowerCase() ) ) ) {
|
||||
platform = platformMap[ match[ 1 ] ] || match[ 1 ];
|
||||
}
|
||||
if ( ( match = new RegExp( '(' + versionPrefixes.join( '|' ) + ')' + versionSuffix ).exec( ua ) ) ) {
|
||||
version = match[ 3 ];
|
||||
if ( ( match = new RegExp( versionPrefixes + versionSuffix ).exec( ua ) ) ) {
|
||||
version = match[ 1 ];
|
||||
}
|
||||
|
||||
// Edge Cases -- did I mention about how user agent string lie?
|
||||
|
|
@ -172,13 +190,6 @@
|
|||
version = '10';
|
||||
}
|
||||
}
|
||||
// And Opera 15's lies about being Chrome
|
||||
if ( name === 'chrome' && ( match = ua.match( /\bopr\/([0-9.]*)/ ) ) ) {
|
||||
if ( match[ 1 ] ) {
|
||||
name = 'opera';
|
||||
version = match[ 1 ];
|
||||
}
|
||||
}
|
||||
// And IE 11's lies about being not being IE
|
||||
if ( layout === 'trident' && layoutversion >= 7 && ( match = ua.match( /\brv[ :/]([0-9.]*)/ ) ) ) {
|
||||
if ( match[ 1 ] ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue