Merge "Improve behavior of IP::toUnsigned on Windows"
[lhc/web/wiklou.git] / resources / jquery / jquery.client.js
index b0bd685..2da022c 100644 (file)
@@ -6,7 +6,7 @@
        /* Private Members */
 
        /**
-        * @var profileCache {Object} Keyed by userAgent string,
+        * @var {Object} profileCache Keyed by userAgent string,
         * value is the parsed $.client.profile object for that user agent.
         */
        var profileCache = {};
@@ -18,9 +18,9 @@
                /**
                 * Get an object containing information about the client.
                 *
-                * @param nav {Object} An object with atleast a 'userAgent' and 'platform' key.
+                * @param {Object} nav An object with atleast a 'userAgent' and 'platform' key.
                 * Defaults to the global Navigator object.
-                * @return {Object} The resulting client object will be in the following format:
+                * @returns {Object} The resulting client object will be in the following format:
                 *  {
                 *   'name': 'firefox',
                 *   'layout': 'gecko',
                                        // Generic version digit
                                        x = 'x',
                                        // Strings found in user agent strings that need to be conformed
-                                       wildUserAgents = ['Opera', 'Navigator', 'Minefield', 'KHTML', 'Chrome', 'PLAYSTATION 3'],
+                                       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)/, ''],
+                                               [/(Firefox|MSIE|KHTML,?\slike\sGecko|Konqueror)/, ''],
                                                // Chrome lives in the shadow of Safari still
                                                ['Chrome Safari', 'Chrome'],
                                                // KHTML is the layout engine not the browser - LIES!
                                        // version detectection
                                        versionPrefixes = [
                                                'camino', 'chrome', 'firefox', 'iceweasel', 'netscape', 'netscape6', 'opera', 'version', 'konqueror',
-                                               'lynx', 'msie', 'safari', 'ps3'
+                                               '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'
+                                               'safari', 'ipod', 'iphone', 'blackberry', 'ps3', 'rekonq', 'android'
                                        ],
                                        // Tanslations for conforming browser names
                                        nameTranslations = [],
                },
 
                /**
-                * Checks the current browser against a support map object to determine if the browser has been black-listed or
-                * not. If the browser was not configured specifically it is assumed to work. It is assumed that the body
-                * element is classified as either "ltr" or "rtl". If neither is set, "ltr" is assumed.
+                * Checks the current browser against a support map object.
                 *
                 * A browser map is in the following format:
                 * {
+                *   // Multiple rules with configurable operators
+                *   'msie': [['>=', 7], ['!=', 9]],
+                *    // Match no versions
+                *   'iphone': false,
+                *    // Match any version
+                *   'android': null
+                * }
+                *
+                * It can optionally be split into ltr/rtl sections:
+                * {
                 *   'ltr': {
-                *     // Multiple rules with configurable operators
-                *     'msie': [['>=', 7], ['!=', 9]],
-                *      // Blocked entirely
+                *     'android': null,
                 *     'iphone': false
                 *   },
                 *   'rtl': {
-                *     // Test against a string
-                *     'msie': [['!==', '8.1.2.3']],
-                *     // RTL rules do not fall through to LTR rules, you must explicity set each of them
+                *     'android': false,
+                *     // rules are not inherited from ltr
                 *     'iphone': false
                 *   }
                 * }
                 *
-                * @param map {Object} Browser support map
-                * @param profile {Object} (optional) a client-profile object.
+                * @param {Object} map Browser support map
+                * @param {Object} [profile] A client-profile object
+                * @param {boolean} [exactMatchOnly=false] Only return true if the browser is matched, otherwise
+                * returns true if the browser is not found.
                 *
-                * @return Boolean true if browser known or assumed to be supported, false if blacklisted
+                * @returns {boolean} The current browser is in the support map
                 */
-               test: function ( map, profile ) {
+               test: function ( map, profile, exactMatchOnly ) {
                        /*jshint evil: true */
 
                        var conditions, dir, i, op, val;
                        profile = $.isPlainObject( profile ) ? profile : $.client.profile();
-                       dir = $( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr';
+                       if ( map.ltr && map.rtl ) {
+                               dir = $( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr';
+                               map = map[dir];
+                       }
                        // Check over each browser condition to determine if we are running in a compatible client
-                       if ( typeof map[dir] !== 'object' || map[dir][profile.name] === undefined ) {
-                               // Unknown, so we assume it's working
-                               return true;
+                       if ( typeof map !== 'object' || map[profile.name] === undefined ) {
+                               // Not found, return true if exactMatchOnly not set, false otherwise
+                               return !exactMatchOnly;
                        }
-                       conditions = map[dir][profile.name];
+                       conditions = map[profile.name];
                        if ( conditions === false ) {
+                               // Match no versions
                                return false;
                        }
+                       if ( conditions === null ) {
+                               // Match all versions
+                               return true;
+                       }
                        for ( i = 0; i < conditions.length; i++ ) {
                                op = conditions[i][0];
                                val = conditions[i][1];