|
@@ -18,13 +18,15 @@
|
|
import BrowserName = threema.BrowserName;
|
|
import BrowserName = threema.BrowserName;
|
|
|
|
|
|
export class BrowserService {
|
|
export class BrowserService {
|
|
|
|
+ private logTag: string = '[BrowserService]';
|
|
|
|
+
|
|
private browser: threema.BrowserInfo;
|
|
private browser: threema.BrowserInfo;
|
|
private $log: ng.ILogService;
|
|
private $log: ng.ILogService;
|
|
private $window: ng.IWindowService;
|
|
private $window: ng.IWindowService;
|
|
private isPageVisible = true;
|
|
private isPageVisible = true;
|
|
|
|
+ private supportsExtendedLocaleCompareCache: boolean;
|
|
|
|
|
|
public static $inject = ['$log', '$window'];
|
|
public static $inject = ['$log', '$window'];
|
|
-
|
|
|
|
constructor($log: ng.ILogService, $window: ng.IWindowService) {
|
|
constructor($log: ng.ILogService, $window: ng.IWindowService) {
|
|
// Angular services
|
|
// Angular services
|
|
this.$log = $log;
|
|
this.$log = $log;
|
|
@@ -184,4 +186,29 @@ export class BrowserService {
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Return whether the browser supports extended `string.localeCompare` options.
|
|
|
|
+ */
|
|
|
|
+ public supportsExtendedLocaleCompare() {
|
|
|
|
+ if (this.supportsExtendedLocaleCompareCache !== undefined) {
|
|
|
|
+ return this.supportsExtendedLocaleCompareCache;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function getSupport(): boolean {
|
|
|
|
+ try {
|
|
|
|
+ 'foo'.localeCompare('bar', 'i');
|
|
|
|
+ } catch (e) {
|
|
|
|
+ return e.name === 'RangeError';
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const support = getSupport();
|
|
|
|
+ this.supportsExtendedLocaleCompareCache = support;
|
|
|
|
+ this.$log.debug(this.logTag, 'Browser',
|
|
|
|
+ support ? 'supports' : 'does not support',
|
|
|
|
+ 'extended locale compare options');
|
|
|
|
+ return support;
|
|
|
|
+ }
|
|
}
|
|
}
|