var econda; (function (econda) { var env; (function (env) { /** * Provides access to basic user agent properties. This class was created to detect older internet explorer versions to support * special Ajax methods. * * // test for internet explorer * // JavaScript * var isIE = (econda.env.UserAgent.getName() == econda.env.UserAgent.INTERNET_EXPLORER) * * // TypeScript * import UserAgent = econda.env.UserAgent; * var isIE = (UserAgent.getName() == UserAgent.INTERNET_EXPLORER) * * <h3>Constants</h3> * <ul> * <li>CHROME</li> * <li>INTERNET_EXPLORER</li> * <li>FIREFOX</li> * <li>SAFARI</li> * </ul> * * @class econda.env.UserAgent * @static */ var UserAgent = (function () { function UserAgent() { } /** * Get value of window.navigation.userAgent. * @returns {String} user agent string */ UserAgent.getUserAgent = function () { if (this.userAgent == null) { this.userAgent = window.navigator.userAgent; } return this.userAgent; }; /** * Get name of current user agent * @returns {String} */ UserAgent.getName = function () { if (this._name == null) { this.init(); } return this._name; }; /** * Get version number of current user agent * @returns {Number} */ UserAgent.getVersion = function () { if (this._version == null) { this.init(); } return this._version; }; /** * True if it's a mobile client * @returns {Boolean} */ UserAgent.isMobile = function () { if (this._isMobile == null) { this.init(); } return this._isMobile; }; /** * Parse data from user agent string and write to properties * @private */ UserAgent.init = function () { this.initNameAndVersion(); this.initIsMobile(); }; /** * Run is mobile detection * @private */ UserAgent.initIsMobile = function () { this._isMobile = (navigator.userAgent.match(/mobile/i) != null); }; /** * Initialize name and version properties from user agent string * @private */ UserAgent.initNameAndVersion = function () { var uas = this.getUserAgent(); // internet explorer if (this._name == null && /;\s*MSIE\s+(\d+\.\d+)*/.test(uas)) { this._name = this.INTERNET_EXPLORER; this._version = +(RegExp.$1); } // firefox if (this._name == null && /Firefox\s*\/\s*(\d+\.\d+)*/.test(uas)) { this._name = this.FIREFOX; this._version = +(RegExp.$1); } // chrome if (this._name == null && /Chrome\s*\/\s*(\d+\.\d+)*/.test(uas)) { this._name = this.CHROME; this._version = +(RegExp.$1); } // safari (must be below chrome) if (this._name == null && /Version\s*\/\s*(\d+\.\d+)*.*Safari/.test(uas)) { this._name = this.SAFARI; this._version = +(RegExp.$1); } }; /** * Constant for Microsoft Internet Explorer * @property {String} INTERNET_EXPLORER * @static */ UserAgent.INTERNET_EXPLORER = 'internet explorer'; /** * Constant for Google Chrome * @property {String} CHROME * @static */ UserAgent.CHROME = 'chrome'; /** * Constant for Mozilla Firefox * @property {String} FIREFOX * @static */ UserAgent.FIREFOX = 'firefox'; /** * Constant for Apple Safari * @property {String} SAFARI * @static */ UserAgent.SAFARI = 'safari'; /** * User Agent string. Use {@link #getUserAgent} to access the current browsers user agent string. * Do not access window.navigation.userAgent directly, we need a way to set the user agent string in unit tests * @property {String} userAgent */ UserAgent.userAgent = null; /** * Name of current user agent. * @property {String} name * @private */ UserAgent._name = null; /** * Version number of current user agent * @property {Number} version * @private */ UserAgent._version = null; /** * True, if it's a mobile client * @property {Boolean} _isMobile * @private */ UserAgent._isMobile = null; return UserAgent; }()); env.UserAgent = UserAgent; // end of class })(env = econda.env || (econda.env = {})); })(econda || (econda = {})); // end of module