fit-ui 2.10.13 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Fit.UI.js CHANGED
@@ -682,7 +682,7 @@ Fit._internal =
682
682
  {
683
683
  Core:
684
684
  {
685
- VersionInfo: { Major: 2, Minor: 10, Patch: 13 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
685
+ VersionInfo: { Major: 2, Minor: 11, Patch: 0 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
686
686
  }
687
687
  };
688
688
 
@@ -2219,17 +2219,29 @@ for (var i in vals = [1,3,6,8])
2219
2219
  Fit.Browser = {};
2220
2220
  Fit._internal.Browser = {};
2221
2221
 
2222
+ // Allow Fit.Browser unit tests to override user agent information
2223
+ // to test parsing of a range of different user agent strings.
2224
+ Fit._internal.Browser.UserAgent = navigator.userAgent;
2225
+
2222
2226
  /// <function container="Fit.Browser" name="GetBrowser" access="public" static="true" returns='"Edge" | "Chrome" | "Safari" | "MSIE" | "Firefox" | "Opera" | "Unknown"'>
2223
2227
  /// <description>
2224
- /// Returns name of browser. Possible values are: Chrome (which also covers modern versions of Opera and Edge),
2225
- /// Safari, Edge (version 12-18), MSIE (version 8-11), Firefox, Opera (version 1-12), Unknown.
2228
+ /// Returns name of browser useful for adjusting behaviour based on render engine.
2229
+ /// Possible values are: Chrome (both WebKit and Blink based - also returned for modern versions of
2230
+ /// Opera and Edge), Safari (also returned for Edge, Chrome, Opera, and Firefox on iOS), Edge (version 12-18),
2231
+ /// MSIE (version 8-11), Firefox, Opera (version 1-12), and Unknown.
2226
2232
  /// </description>
2227
2233
  /// <param name="returnAppId" type="false" default="false"> Set True to have app specific identifier returned </param>
2228
2234
  /// </function>
2229
- /// <function container="Fit.Browser" name="GetBrowser" access="public" static="true" returns='"Edge" | "EdgeChromium" | "Chrome" | "Safari" | "MSIE" | "Firefox" | "Opera" | "OperaChromium" | "Unknown"'>
2235
+ /// <function container="Fit.Browser" name="GetBrowser" access="public" static="true" returns='"Edge" | "Chrome" | "Safari" | "MSIE" | "Firefox" | "Opera" | "Unknown"'>
2230
2236
  /// <description>
2231
- /// Returns browser app identifer. Possible values are: Chrome, Safari, Edge (version 12-18), EdgeChromium (version 85+),
2232
- /// MSIE (version 8-11), Firefox, Opera (version 1-12), OperaChromium (version 15+), Unknown
2237
+ /// Returns browser app name useful for adjusting behaviour based on actual
2238
+ /// application, regardless of render engine and platform. Possible values are:
2239
+ /// Chrome (both Webkit and Blink based), Safari, Edge (both legacy and modern),
2240
+ /// MSIE (version 8-11), Firefox, Opera (both legacy and modern), and Unknown.
2241
+ /// Be careful not to check against browser app name and app version alone.
2242
+ /// For instance Opera 3 on a touch device is newer than Opera 60 on a Desktop
2243
+ /// device, as they are two completely different browsers. Check whether the browser runs on
2244
+ /// a tablet or phone using e.g. Fit.Browser.IsMobile(true) or Fit.Browser.GetInfo(true).IsMobile.
2233
2245
  /// </description>
2234
2246
  /// <param name="returnAppId" type="true"> Set True to have app specific identifier returned </param>
2235
2247
  /// </function>
@@ -2237,7 +2249,7 @@ Fit.Browser.GetBrowser = function(returnAppId)
2237
2249
  {
2238
2250
  Fit.Validation.ExpectBoolean(returnAppId, true);
2239
2251
 
2240
- var agent = navigator.userAgent;
2252
+ var agent = Fit._internal.Browser.UserAgent;
2241
2253
 
2242
2254
  // IMPORTANT: The order in which browsers are detected matters! For instance, several browsers define both Chrome and Safari as part of their user agent string. Examples:
2243
2255
  // Firefox 46 "Mozilla/5.0 (Windows NT 5.2; rv:46.0) Gecko/20100101 Firefox/46.0"
@@ -2251,20 +2263,18 @@ Fit.Browser.GetBrowser = function(returnAppId)
2251
2263
  // Edge 18 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18363"
2252
2264
  // Edge 85 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36 Edg/85.0.564.41"
2253
2265
 
2254
- if (agent.indexOf("Edge/") > -1)
2255
- return "Edge";
2256
- if (returnAppId === true && agent.indexOf("Edg/") > -1)
2257
- return "EdgeChromium";
2266
+ if (agent.indexOf("Edge/") > -1 || (returnAppId === true && (agent.indexOf("Edg/") > -1 || agent.indexOf("EdgiOS/") > -1 || agent.indexOf("EdgA/") > -1)))
2267
+ return "Edge"; // Legacy Edge is identified by "Edge/", Chromium based Edge is identified by "Edg/", Edge on iOS is identified by "EdgiOS/", and Edge on Android is identified by "EdgA/"
2258
2268
  if (agent.indexOf("MSIE") > -1 || agent.indexOf("Trident") > -1)
2259
2269
  return "MSIE";
2260
- if (agent.indexOf("Firefox") > -1)
2261
- return "Firefox";
2262
- if (agent.indexOf("Opera") > -1)
2263
- return "Opera";
2264
- if (returnAppId === true && agent.indexOf("OPR/") > -1)
2265
- return "OperaChromium";
2266
- if (agent.indexOf("Chrome") > -1)
2267
- return "Chrome";
2270
+ if (agent.indexOf("Opera") > -1 || (returnAppId === true && (agent.indexOf("OPR/") > -1 || agent.indexOf("OPT/") > -1)))
2271
+ return "Opera"; // Legacy Opera is identified by "Opera", Chromium based Opera is identified by "OPR/", and Opera on iOS is identified by "OPT/"
2272
+ if (agent.indexOf("OPT/") > -1 && (agent.indexOf("iPhone;") > -1 || agent.indexOf("iPad;") > -1))
2273
+ return "Safari"; // Opera on iOS does not contain "Opera", nor "Safari" to identify the engine like other browsers using WebView - we can use "OPT/" plus "iPhone;" or "iPad;" instead
2274
+ if (agent.indexOf("Firefox") > -1 || (returnAppId === true && agent.indexOf("FxiOS/") > -1))
2275
+ return "Firefox"; // Firefox is identified by "Firefox" except on iOS where "FxiOS/" identifies it instead
2276
+ if (agent.indexOf("Chrome") > -1 || (returnAppId === true && agent.indexOf("CriOS/") > -1))
2277
+ return "Chrome"; // Chrome is identified by "Chrome" except on iOS where "CriOS/" identifies it instead
2268
2278
  if (agent.indexOf("Safari") > -1)
2269
2279
  return "Safari";
2270
2280
 
@@ -2298,37 +2308,56 @@ Fit.Browser.GetVersion = function(returnAppVersion)
2298
2308
 
2299
2309
  var start = 0;
2300
2310
  var end = 0;
2301
- var agent = navigator.userAgent;
2311
+ var agent = Fit._internal.Browser.UserAgent;
2302
2312
 
2303
2313
  if (browser === "Edge")
2304
2314
  {
2305
- start = agent.indexOf("Edge/");
2306
- start = (start !== -1 ? start + 5 : 0);
2307
- end = agent.indexOf(".", start);
2308
- end = (end !== -1 ? end : 0);
2309
- }
2310
- if (browser === "EdgeChromium")
2311
- {
2312
- start = agent.indexOf("Edg/");
2313
- start = (start !== -1 ? start + 4 : 0);
2315
+ var search = agent.indexOf("Edge/") > -1 && "Edge/" || agent.indexOf("Edg/") > -1 && "Edg/" || agent.indexOf("EdgiOS/") > -1 && "EdgiOS/" || agent.indexOf("EdgA/") > -1 && "EdgA/" || null;
2316
+
2317
+ start = search !== null && agent.indexOf(search) || -1;
2318
+ start = (start !== -1 ? start + search.length : 0);
2314
2319
  end = agent.indexOf(".", start);
2315
2320
  end = (end !== -1 ? end : 0);
2316
2321
  }
2317
- if (browser === "Chrome")
2322
+ else if (browser === "Chrome")
2318
2323
  {
2319
- start = agent.indexOf("Chrome/");
2320
- start = (start !== -1 ? start + 7 : 0);
2324
+ var search = agent.indexOf("Chrome/") > -1 && "Chrome/" || agent.indexOf("CriOS/") > -1 && "CriOS/" || null;
2325
+
2326
+ start = search !== null && agent.indexOf(search) || -1;
2327
+ start = (start !== -1 ? start + search.length : 0);
2321
2328
  end = agent.indexOf(".", start);
2322
2329
  end = (end !== -1 ? end : 0);
2323
2330
  }
2324
- if (browser === "Safari")
2331
+ else if (browser === "Safari")
2325
2332
  {
2326
- start = agent.indexOf("Version/");
2327
- start = (start !== -1 ? start + 8 : 0);
2328
- end = agent.indexOf(".", start);
2329
- end = (end !== -1 ? end : 0);
2333
+ var search = agent.indexOf("CriOS/") > -1 && "CriOS/" || agent.indexOf("FxiOS/") > -1 && "FxiOS/" || agent.indexOf("EdgiOS/") > -1 && "EdgiOS/" || agent.indexOf("OPT/") > -1 && "OPT/" || null;
2334
+
2335
+ if (search !== null) // Browser based on WebView on iOS - Chrome, Firefox, Edge, or Opera
2336
+ {
2337
+ if (returnAppVersion !== true) // Return Safari version parsed from OS version
2338
+ {
2339
+ start = agent.indexOf(" OS ");
2340
+ start = (start !== -1 ? start + 4 : 0);
2341
+ end = agent.indexOf("_", start);
2342
+ end = (end !== -1 ? end : 0);
2343
+ }
2344
+ else // Return application version
2345
+ {
2346
+ start = agent.indexOf(search);
2347
+ start = (start !== -1 ? start + search.length : 0);
2348
+ end = agent.indexOf(".", start);
2349
+ end = (end !== -1 ? end : 0);
2350
+ }
2351
+ }
2352
+ else // Real Safari or Firefox on iPad which does not identify itself as Firefox
2353
+ {
2354
+ start = agent.indexOf("Version/");
2355
+ start = (start !== -1 ? start + 8 : 0);
2356
+ end = agent.indexOf(".", start);
2357
+ end = (end !== -1 ? end : 0);
2358
+ }
2330
2359
  }
2331
- if (browser === "MSIE")
2360
+ else if (browser === "MSIE")
2332
2361
  {
2333
2362
  if (agent.indexOf("MSIE") > -1)
2334
2363
  {
@@ -2345,37 +2374,21 @@ Fit.Browser.GetVersion = function(returnAppVersion)
2345
2374
  end = (end !== -1 ? end : 0);
2346
2375
  }
2347
2376
  }
2348
- if (browser === "Firefox")
2377
+ else if (browser === "Firefox")
2349
2378
  {
2350
- start = agent.indexOf("Firefox/");
2351
- start = (start !== -1 ? start + 8 : 0);
2352
- end = agent.indexOf(".", start);
2353
- end = (end !== -1 ? end : 0);
2354
- }
2355
- if (browser === "Opera")
2356
- {
2357
- start = agent.indexOf("Version/");
2358
- start = (start !== -1 ? start + 8 : -1);
2359
-
2360
- if (start === -1)
2361
- {
2362
- start = agent.indexOf("Opera/");
2363
- start = (start !== -1 ? start + 6 : -1);
2364
- }
2365
-
2366
- if (start === -1)
2367
- {
2368
- start = agent.indexOf("Opera ");
2369
- start = (start !== -1 ? start + 6 : -1);
2370
- }
2379
+ var search = agent.indexOf("Firefox/") > -1 && "Firefox/" || agent.indexOf("FxiOS/") > -1 && "FxiOS/" || null;
2371
2380
 
2381
+ start = search !== null && agent.indexOf(search) || -1;
2382
+ start = (start !== -1 ? start + search.length : 0);
2372
2383
  end = agent.indexOf(".", start);
2373
2384
  end = (end !== -1 ? end : 0);
2374
2385
  }
2375
- if (browser === "OperaChromium")
2386
+ else if (browser === "Opera")
2376
2387
  {
2377
- start = agent.indexOf("OPR/");
2378
- start = (start !== -1 ? start + 4 : 0);
2388
+ var search = agent.indexOf("Version/") > -1 && "Version/" || agent.indexOf("Opera ") > -1 && "Opera " || agent.indexOf("Opera/") > -1 && "Opera/" || agent.indexOf("OPR/") > -1 && "OPR/" || agent.indexOf("OPT/") > -1 && "OPT/" || null;
2389
+
2390
+ start = search !== null && agent.indexOf(search) || -1;
2391
+ start = (start !== -1 ? start + search.length : 0);
2379
2392
  end = agent.indexOf(".", start);
2380
2393
  end = (end !== -1 ? end : 0);
2381
2394
  }
@@ -2909,7 +2922,22 @@ Fit.Browser.GetScreenDimensions = function(onlyAvailable)
2909
2922
  }
2910
2923
 
2911
2924
  /// <function container="Fit.Browser" name="IsMobile" access="public" static="true" returns="boolean">
2912
- /// <description> Returns value indicating whether device is a mobile device or not </description>
2925
+ /// <description>
2926
+ /// Returns value indicating whether device is a mobile device or not.
2927
+ /// Notice that some phones and tablets may identify as desktop devices,
2928
+ /// in which case IsMobile(..) will return False. In this case consider
2929
+ /// using Fit.Browser.IsTouchEnabled(), e.g. in combination with
2930
+ /// Fit.Browser.GetBrowser(), or a check against the size of the viewport,
2931
+ /// which will provide some indication as to whether device should be treated
2932
+ /// as a mobile device or not. As an example, Safari on iPad identifies as
2933
+ /// a Mac computer by default (it has &quot;Request Desktop Website&quot; enabled by default).
2934
+ /// To always detect iPad and iPhone as a mobile device, no matter the configuration
2935
+ /// of &quot;Request Desktop Website&quot;), simply use:
2936
+ /// var isMobile = Fit.Browser.IsMobile(true) || (Fit.Browser.GetBrowser() === &quot;Safari&quot; &amp;&amp; Fit.Browser.IsTouchEnabled())
2937
+ /// We will not be able to distinguish between an iPhone and an iPad though, not even
2938
+ /// by looking at the viewport size, since this approach is unreliable with high resolution
2939
+ /// iPhones and support for split screen which affects the viewport size.
2940
+ /// </description>
2913
2941
  /// <param name="includeTablets" type="boolean" default="true"> Value indicating whether tablets are considered mobile devices or not </param>
2914
2942
  /// </function>
2915
2943
  Fit.Browser.IsMobile = function(includeTablets)
@@ -2919,7 +2947,7 @@ Fit.Browser.IsMobile = function(includeTablets)
2919
2947
  // Based on http://detectmobilebrowsers.com
2920
2948
  // See About section for Tablet support: http://detectmobilebrowsers.com/about
2921
2949
 
2922
- var nav = navigator.userAgent || navigator.vendor;
2950
+ var nav = Fit._internal.Browser.UserAgent;
2923
2951
 
2924
2952
  if (includeTablets !== false && /android|ipad|playbook|silk/i.test(nav))
2925
2953
  return true;
@@ -2935,7 +2963,6 @@ Fit.Browser.IsTouchEnabled = function()
2935
2963
  return ("ontouchstart" in window);
2936
2964
  }
2937
2965
 
2938
-
2939
2966
  /// <function container="Fit.Browser" name="Log" access="public" static="true">
2940
2967
  /// <description> Log message or object </description>
2941
2968
  /// <param name="msg" type="object"> Message or object to log </param>