Adding float-no-zero branch hosted build
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
// Copyright 2008 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Detects the Adobe Reader PDF browser plugin.
|
||||
*
|
||||
* @author chrisn@google.com (Chris Nokleberg)
|
||||
* @see ../demos/useragent.html
|
||||
*/
|
||||
|
||||
/** @suppress {extraProvide} */
|
||||
goog.provide('goog.userAgent.adobeReader');
|
||||
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.userAgent');
|
||||
|
||||
|
||||
(function() {
|
||||
var version = '';
|
||||
if (goog.userAgent.IE) {
|
||||
var detectOnIe = function(classId) {
|
||||
/** @preserveTry */
|
||||
try {
|
||||
new ActiveXObject(classId);
|
||||
return true;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
if (detectOnIe('AcroPDF.PDF.1')) {
|
||||
version = '7';
|
||||
} else if (detectOnIe('PDF.PdfCtrl.6')) {
|
||||
version = '6';
|
||||
}
|
||||
// TODO(chrisn): Add detection for previous versions if anyone needs them.
|
||||
} else {
|
||||
if (navigator.mimeTypes && navigator.mimeTypes.length > 0) {
|
||||
var mimeType = navigator.mimeTypes['application/pdf'];
|
||||
if (mimeType && mimeType.enabledPlugin) {
|
||||
var description = mimeType.enabledPlugin.description;
|
||||
if (description && description.indexOf('Adobe') != -1) {
|
||||
// Newer plugins do not include the version in the description, so we
|
||||
// default to 7.
|
||||
version = description.indexOf('Version') != -1 ?
|
||||
description.split('Version')[1] : '7';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we detect the user has the Adobe Reader browser plugin installed.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.adobeReader.HAS_READER = !!version;
|
||||
|
||||
|
||||
/**
|
||||
* The version of the installed Adobe Reader plugin. Versions after 7
|
||||
* will all be reported as '7'.
|
||||
* @type {string}
|
||||
*/
|
||||
goog.userAgent.adobeReader.VERSION = version;
|
||||
|
||||
|
||||
/**
|
||||
* On certain combinations of platform/browser/plugin, a print dialog
|
||||
* can be shown for PDF files without a download dialog or making the
|
||||
* PDF visible to the user, by loading the PDF into a hidden iframe.
|
||||
*
|
||||
* Currently this variable is true if Adobe Reader version 6 or later
|
||||
* is detected on Windows.
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.adobeReader.SILENT_PRINT = goog.userAgent.WINDOWS &&
|
||||
goog.string.compareVersions(version, '6') >= 0;
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,153 @@
|
||||
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Flash detection.
|
||||
* @see ../demos/useragent.html
|
||||
*/
|
||||
|
||||
goog.provide('goog.userAgent.flash');
|
||||
|
||||
goog.require('goog.string');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether we know at compile-time that the browser doesn't
|
||||
* have flash.
|
||||
*/
|
||||
goog.define('goog.userAgent.flash.ASSUME_NO_FLASH', false);
|
||||
|
||||
|
||||
/**
|
||||
* Whether we can detect that the browser has flash
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.flash.detectedFlash_ = false;
|
||||
|
||||
|
||||
/**
|
||||
* Full version information of flash installed, in form 7.0.61
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.flash.detectedFlashVersion_ = '';
|
||||
|
||||
|
||||
/**
|
||||
* Initializer for goog.userAgent.flash
|
||||
*
|
||||
* This is a named function so that it can be stripped via the jscompiler if
|
||||
* goog.userAgent.flash.ASSUME_NO_FLASH is true.
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.flash.init_ = function() {
|
||||
if (navigator.plugins && navigator.plugins.length) {
|
||||
var plugin = navigator.plugins['Shockwave Flash'];
|
||||
if (plugin) {
|
||||
goog.userAgent.flash.detectedFlash_ = true;
|
||||
if (plugin.description) {
|
||||
goog.userAgent.flash.detectedFlashVersion_ =
|
||||
goog.userAgent.flash.getVersion_(plugin.description);
|
||||
}
|
||||
}
|
||||
|
||||
if (navigator.plugins['Shockwave Flash 2.0']) {
|
||||
goog.userAgent.flash.detectedFlash_ = true;
|
||||
goog.userAgent.flash.detectedFlashVersion_ = '2.0.0.11';
|
||||
}
|
||||
|
||||
} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
|
||||
var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
|
||||
goog.userAgent.flash.detectedFlash_ = mimeType && mimeType.enabledPlugin;
|
||||
if (goog.userAgent.flash.detectedFlash_) {
|
||||
goog.userAgent.flash.detectedFlashVersion_ =
|
||||
goog.userAgent.flash.getVersion_(mimeType.enabledPlugin.description);
|
||||
}
|
||||
|
||||
} else {
|
||||
/** @preserveTry */
|
||||
try {
|
||||
// Try 7 first, since we know we can use GetVariable with it
|
||||
var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
|
||||
goog.userAgent.flash.detectedFlash_ = true;
|
||||
goog.userAgent.flash.detectedFlashVersion_ =
|
||||
goog.userAgent.flash.getVersion_(ax.GetVariable('$version'));
|
||||
} catch (e) {
|
||||
// Try 6 next, some versions are known to crash with GetVariable calls
|
||||
/** @preserveTry */
|
||||
try {
|
||||
var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
|
||||
goog.userAgent.flash.detectedFlash_ = true;
|
||||
// First public version of Flash 6
|
||||
goog.userAgent.flash.detectedFlashVersion_ = '6.0.21';
|
||||
} catch (e2) {
|
||||
/** @preserveTry */
|
||||
try {
|
||||
// Try the default activeX
|
||||
var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
|
||||
goog.userAgent.flash.detectedFlash_ = true;
|
||||
goog.userAgent.flash.detectedFlashVersion_ =
|
||||
goog.userAgent.flash.getVersion_(ax.GetVariable('$version'));
|
||||
} catch (e3) {
|
||||
// No flash
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Derived from Apple's suggested sniffer.
|
||||
* @param {string} desc e.g. Shockwave Flash 7.0 r61.
|
||||
* @return {string} 7.0.61.
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.flash.getVersion_ = function(desc) {
|
||||
var matches = desc.match(/[\d]+/g);
|
||||
matches.length = 3; // To standardize IE vs FF
|
||||
return matches.join('.');
|
||||
};
|
||||
|
||||
|
||||
if (!goog.userAgent.flash.ASSUME_NO_FLASH) {
|
||||
goog.userAgent.flash.init_();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether we can detect that the browser has flash
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.flash.HAS_FLASH = goog.userAgent.flash.detectedFlash_;
|
||||
|
||||
|
||||
/**
|
||||
* Full version information of flash installed, in form 7.0.61
|
||||
* @type {string}
|
||||
*/
|
||||
goog.userAgent.flash.VERSION = goog.userAgent.flash.detectedFlashVersion_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the installed flash version is as new or newer than a given version.
|
||||
* @param {string} version The version to check.
|
||||
* @return {boolean} Whether the installed flash version is as new or newer
|
||||
* than a given version.
|
||||
*/
|
||||
goog.userAgent.flash.isVersion = function(version) {
|
||||
return goog.string.compareVersions(goog.userAgent.flash.VERSION,
|
||||
version) >= 0;
|
||||
};
|
||||
@@ -0,0 +1,87 @@
|
||||
// Copyright 2007 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Newer versions of iPhoto include a Safari plugin which allows
|
||||
* the browser to detect if iPhoto is installed. Adapted from detection code
|
||||
* built into the Mac.com Gallery RSS feeds.
|
||||
* @author brenneman@google.com (Shawn Brenneman)
|
||||
* @see ../demos/useragent.html
|
||||
*/
|
||||
|
||||
|
||||
goog.provide('goog.userAgent.iphoto');
|
||||
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.userAgent');
|
||||
|
||||
|
||||
(function() {
|
||||
var hasIphoto = false;
|
||||
var version = '';
|
||||
|
||||
/**
|
||||
* The plugin description string contains the version number as in the form
|
||||
* 'iPhoto 700'. This returns just the version number as a dotted string,
|
||||
* e.g., '7.0.0', compatible with {@code goog.string.compareVersions}.
|
||||
* @param {string} desc The version string.
|
||||
* @return {string} The dotted version.
|
||||
*/
|
||||
function getIphotoVersion(desc) {
|
||||
var matches = desc.match(/\d/g);
|
||||
return matches.join('.');
|
||||
}
|
||||
|
||||
if (goog.userAgent.WEBKIT &&
|
||||
navigator.mimeTypes &&
|
||||
navigator.mimeTypes.length > 0) {
|
||||
var iphoto = navigator.mimeTypes['application/photo'];
|
||||
|
||||
if (iphoto) {
|
||||
hasIphoto = true;
|
||||
var description = iphoto['description'];
|
||||
|
||||
if (description) {
|
||||
version = getIphotoVersion(description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we can detect that the user has iPhoto installed.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.iphoto.HAS_IPHOTO = hasIphoto;
|
||||
|
||||
|
||||
/**
|
||||
* The version of iPhoto installed if found.
|
||||
* @type {string}
|
||||
*/
|
||||
goog.userAgent.iphoto.VERSION = version;
|
||||
|
||||
})();
|
||||
|
||||
|
||||
/**
|
||||
* Whether the installed version of iPhoto is as new or newer than a given
|
||||
* version.
|
||||
* @param {string} version The version to check.
|
||||
* @return {boolean} Whether the installed version of iPhoto is as new or newer
|
||||
* than a given version.
|
||||
*/
|
||||
goog.userAgent.iphoto.isVersion = function(version) {
|
||||
return goog.string.compareVersions(
|
||||
goog.userAgent.iphoto.VERSION, version) >= 0;
|
||||
};
|
||||
@@ -0,0 +1,95 @@
|
||||
// Copyright 2007 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Detection of JScript version.
|
||||
*
|
||||
* @author arv@google.com (Erik Arvidsson)
|
||||
*/
|
||||
|
||||
|
||||
goog.provide('goog.userAgent.jscript');
|
||||
|
||||
goog.require('goog.string');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} True if it is known at compile time that the runtime
|
||||
* environment will not be using JScript.
|
||||
*/
|
||||
goog.define('goog.userAgent.jscript.ASSUME_NO_JSCRIPT', false);
|
||||
|
||||
|
||||
/**
|
||||
* Initializer for goog.userAgent.jscript. Detects if the user agent is using
|
||||
* Microsoft JScript and which version of it.
|
||||
*
|
||||
* This is a named function so that it can be stripped via the jscompiler
|
||||
* option for stripping types.
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.jscript.init_ = function() {
|
||||
var hasScriptEngine = 'ScriptEngine' in goog.global;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.jscript.DETECTED_HAS_JSCRIPT_ =
|
||||
hasScriptEngine && goog.global['ScriptEngine']() == 'JScript';
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.jscript.DETECTED_VERSION_ =
|
||||
goog.userAgent.jscript.DETECTED_HAS_JSCRIPT_ ?
|
||||
(goog.global['ScriptEngineMajorVersion']() + '.' +
|
||||
goog.global['ScriptEngineMinorVersion']() + '.' +
|
||||
goog.global['ScriptEngineBuildVersion']()) :
|
||||
'0';
|
||||
};
|
||||
|
||||
if (!goog.userAgent.jscript.ASSUME_NO_JSCRIPT) {
|
||||
goog.userAgent.jscript.init_();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether we detect that the user agent is using Microsoft JScript.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.jscript.HAS_JSCRIPT = goog.userAgent.jscript.ASSUME_NO_JSCRIPT ?
|
||||
false : goog.userAgent.jscript.DETECTED_HAS_JSCRIPT_;
|
||||
|
||||
|
||||
/**
|
||||
* The installed version of JScript.
|
||||
* @type {string}
|
||||
*/
|
||||
goog.userAgent.jscript.VERSION = goog.userAgent.jscript.ASSUME_NO_JSCRIPT ?
|
||||
'0' : goog.userAgent.jscript.DETECTED_VERSION_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the installed version of JScript is as new or newer than a given
|
||||
* version.
|
||||
* @param {string} version The version to check.
|
||||
* @return {boolean} Whether the installed version of JScript is as new or
|
||||
* newer than the given version.
|
||||
*/
|
||||
goog.userAgent.jscript.isVersion = function(version) {
|
||||
return goog.string.compareVersions(goog.userAgent.jscript.VERSION,
|
||||
version) >= 0;
|
||||
};
|
||||
@@ -0,0 +1,112 @@
|
||||
// Copyright 2007 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Detection for whether the user has Picasa installed.
|
||||
* Only Picasa versions 2 and later can be detected, and only from Firefox or
|
||||
* Internet Explorer. Picasa for Linux cannot be detected.
|
||||
*
|
||||
* In the future, Picasa may provide access to the installed version number,
|
||||
* but until then we can only detect that Picasa 2 or later is present.
|
||||
*
|
||||
* To check for Picasa on Internet Explorer requires using document.write, so
|
||||
* this file must be included at page rendering time and cannot be imported
|
||||
* later as part of a dynamically loaded module.
|
||||
*
|
||||
* @author brenneman@google.com (Shawn Brenneman)
|
||||
* @see ../demos/useragent.html
|
||||
*/
|
||||
|
||||
|
||||
goog.provide('goog.userAgent.picasa');
|
||||
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.userAgent');
|
||||
|
||||
|
||||
/**
|
||||
* Variable name used to temporarily save the Picasa state in the global object
|
||||
* in Internet Explorer.
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.picasa.IE_HAS_PICASA_ = 'hasPicasa';
|
||||
|
||||
|
||||
(function() {
|
||||
var hasPicasa = false;
|
||||
|
||||
if (goog.userAgent.IE) {
|
||||
// In Internet Explorer, Picasa 2 can be detected using conditional comments
|
||||
// due to some nice registry magic. The precise version number is not
|
||||
// available, only the major version. This may be updated for Picasa 3. This
|
||||
// check must pollute the global namespace.
|
||||
goog.global[goog.userAgent.picasa.IE_HAS_PICASA_] = hasPicasa;
|
||||
|
||||
// NOTE(user): Some browsers do not like seeing
|
||||
// slash-script anywhere in the text even if it's inside a string
|
||||
// and escaped with a backslash, make a string in a way that
|
||||
// avoids problems.
|
||||
|
||||
document.write(goog.string.subs(
|
||||
'<!--[if gte Picasa 2]>' +
|
||||
'<%s>' +
|
||||
'this.%s=true;' +
|
||||
'</%s>' +
|
||||
'<![endif]-->',
|
||||
'script', goog.userAgent.picasa.IE_HAS_PICASA_, 'script'));
|
||||
|
||||
hasPicasa = goog.global[goog.userAgent.picasa.IE_HAS_PICASA_];
|
||||
|
||||
// Unset the variable in a crude attempt to leave no trace.
|
||||
goog.global[goog.userAgent.picasa.IE_HAS_PICASA_] = undefined;
|
||||
|
||||
} else if (navigator.mimeTypes &&
|
||||
navigator.mimeTypes['application/x-picasa-detect']) {
|
||||
// Picasa 2.x registers a file handler for the MIME-type
|
||||
// 'application/x-picasa-detect' for detection in Firefox. Future versions
|
||||
// may make precise version detection possible.
|
||||
hasPicasa = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we detect the user has Picasa installed.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.picasa.HAS_PICASA = hasPicasa;
|
||||
|
||||
|
||||
/**
|
||||
* The installed version of Picasa. If Picasa is detected, this means it is
|
||||
* version 2 or later. The precise version number is not yet available to the
|
||||
* browser, this is a placeholder for later versions of Picasa.
|
||||
* @type {string}
|
||||
*/
|
||||
goog.userAgent.picasa.VERSION = hasPicasa ? '2' : '';
|
||||
|
||||
})();
|
||||
|
||||
|
||||
/**
|
||||
* Whether the installed Picasa version is as new or newer than a given version.
|
||||
* This is not yet relevant, we can't detect the true Picasa version number yet,
|
||||
* but this may be possible in future Picasa releases.
|
||||
* @param {string} version The version to check.
|
||||
* @return {boolean} Whether the installed Picasa version is as new or newer
|
||||
* than a given version.
|
||||
*/
|
||||
goog.userAgent.picasa.isVersion = function(version) {
|
||||
return goog.string.compareVersions(
|
||||
goog.userAgent.picasa.VERSION, version) >= 0;
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
// Copyright 2010 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Utilities for getting details about the user's platform.
|
||||
*/
|
||||
|
||||
goog.provide('goog.userAgent.platform');
|
||||
|
||||
goog.require('goog.userAgent');
|
||||
|
||||
|
||||
/**
|
||||
* Detects the version of Windows or Mac OS that is running.
|
||||
*
|
||||
* @private
|
||||
* @return {string} The platform version.
|
||||
*/
|
||||
goog.userAgent.platform.determineVersion_ = function() {
|
||||
var version = '', re;
|
||||
if (goog.userAgent.WINDOWS) {
|
||||
re = /Windows NT ([0-9.]+)/;
|
||||
var match = re.exec(goog.userAgent.getUserAgentString());
|
||||
if (match) {
|
||||
return match[1];
|
||||
} else {
|
||||
return '0';
|
||||
}
|
||||
} else if (goog.userAgent.MAC) {
|
||||
re = /10[_.][0-9_.]+/;
|
||||
var match = re.exec(goog.userAgent.getUserAgentString());
|
||||
// Note: some old versions of Camino do not report an OSX version.
|
||||
// Default to 10.
|
||||
return match ? match[0].replace(/_/g, '.') : '10';
|
||||
} else if (goog.userAgent.ANDROID) {
|
||||
re = /Android\s+([^\);]+)(\)|;)/;
|
||||
var match = re.exec(goog.userAgent.getUserAgentString());
|
||||
return match ? match[1] : '';
|
||||
} else if (goog.userAgent.IPHONE || goog.userAgent.IPAD) {
|
||||
re = /(?:iPhone|CPU)\s+OS\s+(\S+)/;
|
||||
var match = re.exec(goog.userAgent.getUserAgentString());
|
||||
// Report the version as x.y.z and not x_y_z
|
||||
return match ? match[1].replace(/_/g, '.') : '';
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The version of the platform. We only determine the version for Windows and
|
||||
* Mac, since it doesn't make much sense on Linux. For Windows, we only look at
|
||||
* the NT version. Non-NT-based versions (e.g. 95, 98, etc.) are given version
|
||||
* 0.0
|
||||
* @type {string}
|
||||
*/
|
||||
goog.userAgent.platform.VERSION = goog.userAgent.platform.determineVersion_();
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent platform version is higher or the same as the given
|
||||
* version.
|
||||
*
|
||||
* @param {string|number} version The version to check.
|
||||
* @return {boolean} Whether the user agent platform version is higher or the
|
||||
* same as the given version.
|
||||
*/
|
||||
goog.userAgent.platform.isVersion = function(version) {
|
||||
return goog.string.compareVersions(
|
||||
goog.userAgent.platform.VERSION, version) >= 0;
|
||||
};
|
||||
@@ -0,0 +1,253 @@
|
||||
// Copyright 2008 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Detects the specific browser and not just the rendering engine.
|
||||
*
|
||||
*/
|
||||
|
||||
goog.provide('goog.userAgent.product');
|
||||
|
||||
goog.require('goog.userAgent');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the code is running on the Firefox web browser.
|
||||
*/
|
||||
goog.define('goog.userAgent.product.ASSUME_FIREFOX', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the code is running on the Camino web browser.
|
||||
*/
|
||||
goog.define('goog.userAgent.product.ASSUME_CAMINO', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether we know at compile-time that the product is an
|
||||
* iPhone.
|
||||
*/
|
||||
goog.define('goog.userAgent.product.ASSUME_IPHONE', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether we know at compile-time that the product is an
|
||||
* iPad.
|
||||
*/
|
||||
goog.define('goog.userAgent.product.ASSUME_IPAD', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether we know at compile-time that the product is an
|
||||
* Android phone.
|
||||
*/
|
||||
goog.define('goog.userAgent.product.ASSUME_ANDROID', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the code is running on the Chrome web browser.
|
||||
*/
|
||||
goog.define('goog.userAgent.product.ASSUME_CHROME', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the code is running on the Safari web browser.
|
||||
*/
|
||||
goog.define('goog.userAgent.product.ASSUME_SAFARI', false);
|
||||
|
||||
|
||||
/**
|
||||
* Whether we know the product type at compile-time.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.PRODUCT_KNOWN_ =
|
||||
goog.userAgent.ASSUME_IE ||
|
||||
goog.userAgent.ASSUME_OPERA ||
|
||||
goog.userAgent.product.ASSUME_FIREFOX ||
|
||||
goog.userAgent.product.ASSUME_CAMINO ||
|
||||
goog.userAgent.product.ASSUME_IPHONE ||
|
||||
goog.userAgent.product.ASSUME_IPAD ||
|
||||
goog.userAgent.product.ASSUME_ANDROID ||
|
||||
goog.userAgent.product.ASSUME_CHROME ||
|
||||
goog.userAgent.product.ASSUME_SAFARI;
|
||||
|
||||
|
||||
/**
|
||||
* Right now we just focus on Tier 1-3 browsers at:
|
||||
* http://wiki/Nonconf/ProductPlatformGuidelines
|
||||
* As well as the YUI grade A browsers at:
|
||||
* http://developer.yahoo.com/yui/articles/gbs/
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.init_ = function() {
|
||||
|
||||
/**
|
||||
* Whether the code is running on the Firefox web browser.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.detectedFirefox_ = false;
|
||||
|
||||
/**
|
||||
* Whether the code is running on the Camino web browser.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.detectedCamino_ = false;
|
||||
|
||||
/**
|
||||
* Whether the code is running on an iPhone or iPod touch.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.detectedIphone_ = false;
|
||||
|
||||
/**
|
||||
* Whether the code is running on an iPad
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.detectedIpad_ = false;
|
||||
|
||||
/**
|
||||
* Whether the code is running on the default browser on an Android phone.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.detectedAndroid_ = false;
|
||||
|
||||
/**
|
||||
* Whether the code is running on the Chrome web browser.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.detectedChrome_ = false;
|
||||
|
||||
/**
|
||||
* Whether the code is running on the Safari web browser.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.detectedSafari_ = false;
|
||||
|
||||
var ua = goog.userAgent.getUserAgentString();
|
||||
if (!ua) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The order of the if-statements in the following code is important.
|
||||
// For example, in the WebKit section, we put Chrome in front of Safari
|
||||
// because the string 'Safari' is present on both of those browsers'
|
||||
// userAgent strings as well as the string we are looking for.
|
||||
// The idea is to prevent accidental detection of more than one client.
|
||||
|
||||
if (ua.indexOf('Firefox') != -1) {
|
||||
goog.userAgent.product.detectedFirefox_ = true;
|
||||
} else if (ua.indexOf('Camino') != -1) {
|
||||
goog.userAgent.product.detectedCamino_ = true;
|
||||
} else if (ua.indexOf('iPhone') != -1 || ua.indexOf('iPod') != -1) {
|
||||
goog.userAgent.product.detectedIphone_ = true;
|
||||
} else if (ua.indexOf('iPad') != -1) {
|
||||
goog.userAgent.product.detectedIpad_ = true;
|
||||
} else if (ua.indexOf('Android') != -1) {
|
||||
goog.userAgent.product.detectedAndroid_ = true;
|
||||
} else if (ua.indexOf('Chrome') != -1) {
|
||||
goog.userAgent.product.detectedChrome_ = true;
|
||||
} else if (ua.indexOf('Safari') != -1) {
|
||||
goog.userAgent.product.detectedSafari_ = true;
|
||||
}
|
||||
};
|
||||
|
||||
if (!goog.userAgent.product.PRODUCT_KNOWN_) {
|
||||
goog.userAgent.product.init_();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the code is running on the Opera web browser.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.product.OPERA = goog.userAgent.OPERA;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the code is running on an IE web browser.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.product.IE = goog.userAgent.IE;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the code is running on the Firefox web browser.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.product.FIREFOX = goog.userAgent.product.PRODUCT_KNOWN_ ?
|
||||
goog.userAgent.product.ASSUME_FIREFOX :
|
||||
goog.userAgent.product.detectedFirefox_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the code is running on the Camino web browser.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.product.CAMINO = goog.userAgent.product.PRODUCT_KNOWN_ ?
|
||||
goog.userAgent.product.ASSUME_CAMINO :
|
||||
goog.userAgent.product.detectedCamino_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the code is running on an iPhone or iPod touch.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.product.IPHONE = goog.userAgent.product.PRODUCT_KNOWN_ ?
|
||||
goog.userAgent.product.ASSUME_IPHONE :
|
||||
goog.userAgent.product.detectedIphone_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the code is running on an iPad.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.product.IPAD = goog.userAgent.product.PRODUCT_KNOWN_ ?
|
||||
goog.userAgent.product.ASSUME_IPAD :
|
||||
goog.userAgent.product.detectedIpad_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the code is running on the default browser on an Android phone.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.product.ANDROID = goog.userAgent.product.PRODUCT_KNOWN_ ?
|
||||
goog.userAgent.product.ASSUME_ANDROID :
|
||||
goog.userAgent.product.detectedAndroid_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the code is running on the Chrome web browser.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.product.CHROME = goog.userAgent.product.PRODUCT_KNOWN_ ?
|
||||
goog.userAgent.product.ASSUME_CHROME :
|
||||
goog.userAgent.product.detectedChrome_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the code is running on the Safari web browser.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.product.SAFARI = goog.userAgent.product.PRODUCT_KNOWN_ ?
|
||||
goog.userAgent.product.ASSUME_SAFARI :
|
||||
goog.userAgent.product.detectedSafari_;
|
||||
@@ -0,0 +1,140 @@
|
||||
// Copyright 2009 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Functions for understanding the version of the browser.
|
||||
* This is pulled out of product.js to ensure that only builds that need
|
||||
* this functionality actually get it, without having to rely on the compiler
|
||||
* to strip out unneeded pieces.
|
||||
*
|
||||
* TODO(nnaze): Move to more appropriate filename/namespace.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
goog.provide('goog.userAgent.product.isVersion');
|
||||
|
||||
|
||||
goog.require('goog.userAgent.product');
|
||||
|
||||
|
||||
/**
|
||||
* @return {string} The string that describes the version number of the user
|
||||
* agent product. This is a string rather than a number because it may
|
||||
* contain 'b', 'a', and so on.
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.determineVersion_ = function() {
|
||||
// All browsers have different ways to detect the version and they all have
|
||||
// different naming schemes.
|
||||
|
||||
if (goog.userAgent.product.FIREFOX) {
|
||||
// Firefox/2.0.0.1 or Firefox/3.5.3
|
||||
return goog.userAgent.product.getFirstRegExpGroup_(/Firefox\/([0-9.]+)/);
|
||||
}
|
||||
|
||||
if (goog.userAgent.product.IE || goog.userAgent.product.OPERA) {
|
||||
return goog.userAgent.VERSION;
|
||||
}
|
||||
|
||||
if (goog.userAgent.product.CHROME) {
|
||||
// Chrome/4.0.223.1
|
||||
return goog.userAgent.product.getFirstRegExpGroup_(/Chrome\/([0-9.]+)/);
|
||||
}
|
||||
|
||||
if (goog.userAgent.product.SAFARI) {
|
||||
// Version/5.0.3
|
||||
//
|
||||
// NOTE: Before version 3, Safari did not report a product version number.
|
||||
// The product version number for these browsers will be the empty string.
|
||||
// They may be differentiated by WebKit version number in goog.userAgent.
|
||||
return goog.userAgent.product.getFirstRegExpGroup_(/Version\/([0-9.]+)/);
|
||||
}
|
||||
|
||||
if (goog.userAgent.product.IPHONE || goog.userAgent.product.IPAD) {
|
||||
// Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1
|
||||
// (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3
|
||||
// Version is the browser version, Mobile is the build number. We combine
|
||||
// the version string with the build number: 3.0.3A100a for the example.
|
||||
var arr = goog.userAgent.product.execRegExp_(
|
||||
/Version\/(\S+).*Mobile\/(\S+)/);
|
||||
if (arr) {
|
||||
return arr[1] + '.' + arr[2];
|
||||
}
|
||||
} else if (goog.userAgent.product.ANDROID) {
|
||||
// Mozilla/5.0 (Linux; U; Android 0.5; en-us) AppleWebKit/522+
|
||||
// (KHTML, like Gecko) Safari/419.3
|
||||
//
|
||||
// Mozilla/5.0 (Linux; U; Android 1.0; en-us; dream) AppleWebKit/525.10+
|
||||
// (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2
|
||||
//
|
||||
// Prefer Version number if present, else make do with the OS number
|
||||
var version = goog.userAgent.product.getFirstRegExpGroup_(
|
||||
/Android\s+([0-9.]+)/);
|
||||
if (version) {
|
||||
return version;
|
||||
}
|
||||
|
||||
return goog.userAgent.product.getFirstRegExpGroup_(/Version\/([0-9.]+)/);
|
||||
} else if (goog.userAgent.product.CAMINO) {
|
||||
return goog.userAgent.product.getFirstRegExpGroup_(/Camino\/([0-9.]+)/);
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Return the first group of the given regex.
|
||||
* @param {!RegExp} re Regular expression with at least one group.
|
||||
* @return {string} Contents of the first group or an empty string if no match.
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.getFirstRegExpGroup_ = function(re) {
|
||||
var arr = goog.userAgent.product.execRegExp_(re);
|
||||
return arr ? arr[1] : '';
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Run regexp's exec() on the userAgent string.
|
||||
* @param {!RegExp} re Regular expression.
|
||||
* @return {Array} A result array, or null for no match.
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.product.execRegExp_ = function(re) {
|
||||
return re.exec(goog.userAgent.getUserAgentString());
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The version of the user agent. This is a string because it might contain
|
||||
* 'b' (as in beta) as well as multiple dots.
|
||||
* @type {string}
|
||||
*/
|
||||
goog.userAgent.product.VERSION = goog.userAgent.product.determineVersion_();
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent product version is higher or the same as the given
|
||||
* version.
|
||||
*
|
||||
* @param {string|number} version The version to check.
|
||||
* @return {boolean} Whether the user agent product version is higher or the
|
||||
* same as the given version.
|
||||
*/
|
||||
goog.userAgent.product.isVersion = function(version) {
|
||||
return goog.string.compareVersions(
|
||||
goog.userAgent.product.VERSION, version) >= 0;
|
||||
};
|
||||
@@ -0,0 +1,599 @@
|
||||
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Rendering engine detection.
|
||||
* @see <a href="http://www.useragentstring.com/">User agent strings</a>
|
||||
* For information on the browser brand (such as Safari versus Chrome), see
|
||||
* goog.userAgent.product.
|
||||
* @see ../demos/useragent.html
|
||||
*/
|
||||
|
||||
goog.provide('goog.userAgent');
|
||||
|
||||
goog.require('goog.string');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether we know at compile-time that the browser is IE.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_IE', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether we know at compile-time that the browser is GECKO.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_GECKO', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether we know at compile-time that the browser is WEBKIT.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_WEBKIT', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether we know at compile-time that the browser is a
|
||||
* mobile device running WebKit e.g. iPhone or Android.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_MOBILE_WEBKIT', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether we know at compile-time that the browser is OPERA.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_OPERA', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the
|
||||
* {@code goog.userAgent.isVersionOrHigher}
|
||||
* function will return true for any version.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_ANY_VERSION', false);
|
||||
|
||||
|
||||
/**
|
||||
* Whether we know the browser engine at compile-time.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.BROWSER_KNOWN_ =
|
||||
goog.userAgent.ASSUME_IE ||
|
||||
goog.userAgent.ASSUME_GECKO ||
|
||||
goog.userAgent.ASSUME_MOBILE_WEBKIT ||
|
||||
goog.userAgent.ASSUME_WEBKIT ||
|
||||
goog.userAgent.ASSUME_OPERA;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the userAgent string for the current browser.
|
||||
* Some user agents (I'm thinking of you, Gears WorkerPool) do not expose a
|
||||
* navigator object off the global scope. In that case we return null.
|
||||
*
|
||||
* @return {?string} The userAgent string or null if there is none.
|
||||
*/
|
||||
goog.userAgent.getUserAgentString = function() {
|
||||
return goog.global['navigator'] ? goog.global['navigator'].userAgent : null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {Object} The native navigator object.
|
||||
*/
|
||||
goog.userAgent.getNavigator = function() {
|
||||
// Need a local navigator reference instead of using the global one,
|
||||
// to avoid the rare case where they reference different objects.
|
||||
// (in a WorkerPool, for example).
|
||||
return goog.global['navigator'];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Initializer for goog.userAgent.
|
||||
*
|
||||
* This is a named function so that it can be stripped via the jscompiler
|
||||
* option for stripping types.
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.init_ = function() {
|
||||
/**
|
||||
* Whether the user agent string denotes Opera.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedOpera_ = false;
|
||||
|
||||
/**
|
||||
* Whether the user agent string denotes Internet Explorer. This includes
|
||||
* other browsers using Trident as its rendering engine. For example AOL
|
||||
* and Netscape 8
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedIe_ = false;
|
||||
|
||||
/**
|
||||
* Whether the user agent string denotes WebKit. WebKit is the rendering
|
||||
* engine that Safari, Android and others use.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedWebkit_ = false;
|
||||
|
||||
/**
|
||||
* Whether the user agent string denotes a mobile device.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedMobile_ = false;
|
||||
|
||||
/**
|
||||
* Whether the user agent string denotes Gecko. Gecko is the rendering
|
||||
* engine used by Mozilla, Mozilla Firefox, Camino and many more.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedGecko_ = false;
|
||||
|
||||
var ua;
|
||||
if (!goog.userAgent.BROWSER_KNOWN_ &&
|
||||
(ua = goog.userAgent.getUserAgentString())) {
|
||||
var navigator = goog.userAgent.getNavigator();
|
||||
goog.userAgent.detectedOpera_ = goog.string.startsWith(ua, 'Opera');
|
||||
goog.userAgent.detectedIe_ = !goog.userAgent.detectedOpera_ &&
|
||||
(goog.string.contains(ua, 'MSIE') ||
|
||||
goog.string.contains(ua, 'Trident'));
|
||||
goog.userAgent.detectedWebkit_ = !goog.userAgent.detectedOpera_ &&
|
||||
goog.string.contains(ua, 'WebKit');
|
||||
// WebKit also gives navigator.product string equal to 'Gecko'.
|
||||
goog.userAgent.detectedMobile_ = goog.userAgent.detectedWebkit_ &&
|
||||
goog.string.contains(ua, 'Mobile');
|
||||
goog.userAgent.detectedGecko_ = !goog.userAgent.detectedOpera_ &&
|
||||
!goog.userAgent.detectedWebkit_ && !goog.userAgent.detectedIe_ &&
|
||||
navigator.product == 'Gecko';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (!goog.userAgent.BROWSER_KNOWN_) {
|
||||
goog.userAgent.init_();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is Opera.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.OPERA = goog.userAgent.BROWSER_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_OPERA : goog.userAgent.detectedOpera_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is Internet Explorer. This includes other browsers
|
||||
* using Trident as its rendering engine. For example AOL and Netscape 8
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.IE = goog.userAgent.BROWSER_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_IE : goog.userAgent.detectedIe_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is Gecko. Gecko is the rendering engine used by
|
||||
* Mozilla, Mozilla Firefox, Camino and many more.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.GECKO = goog.userAgent.BROWSER_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_GECKO :
|
||||
goog.userAgent.detectedGecko_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is WebKit. WebKit is the rendering engine that
|
||||
* Safari, Android and others use.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.WEBKIT = goog.userAgent.BROWSER_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_WEBKIT || goog.userAgent.ASSUME_MOBILE_WEBKIT :
|
||||
goog.userAgent.detectedWebkit_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on a mobile device.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.MOBILE = goog.userAgent.ASSUME_MOBILE_WEBKIT ||
|
||||
goog.userAgent.detectedMobile_;
|
||||
|
||||
|
||||
/**
|
||||
* Used while transitioning code to use WEBKIT instead.
|
||||
* @type {boolean}
|
||||
* @deprecated Use {@link goog.userAgent.product.SAFARI} instead.
|
||||
* TODO(nicksantos): Delete this from goog.userAgent.
|
||||
*/
|
||||
goog.userAgent.SAFARI = goog.userAgent.WEBKIT;
|
||||
|
||||
|
||||
/**
|
||||
* @return {string} the platform (operating system) the user agent is running
|
||||
* on. Default to empty string because navigator.platform may not be defined
|
||||
* (on Rhino, for example).
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.determinePlatform_ = function() {
|
||||
var navigator = goog.userAgent.getNavigator();
|
||||
return navigator && navigator.platform || '';
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The platform (operating system) the user agent is running on. Default to
|
||||
* empty string because navigator.platform may not be defined (on Rhino, for
|
||||
* example).
|
||||
* @type {string}
|
||||
*/
|
||||
goog.userAgent.PLATFORM = goog.userAgent.determinePlatform_();
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the user agent is running on a Macintosh operating
|
||||
* system.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_MAC', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the user agent is running on a Windows operating
|
||||
* system.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_WINDOWS', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the user agent is running on a Linux operating
|
||||
* system.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_LINUX', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the user agent is running on a X11 windowing
|
||||
* system.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_X11', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the user agent is running on Android.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_ANDROID', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the user agent is running on an iPhone.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_IPHONE', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether the user agent is running on an iPad.
|
||||
*/
|
||||
goog.define('goog.userAgent.ASSUME_IPAD', false);
|
||||
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.PLATFORM_KNOWN_ =
|
||||
goog.userAgent.ASSUME_MAC ||
|
||||
goog.userAgent.ASSUME_WINDOWS ||
|
||||
goog.userAgent.ASSUME_LINUX ||
|
||||
goog.userAgent.ASSUME_X11 ||
|
||||
goog.userAgent.ASSUME_ANDROID ||
|
||||
goog.userAgent.ASSUME_IPHONE ||
|
||||
goog.userAgent.ASSUME_IPAD;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the goog.userAgent constants that define which platform the user
|
||||
* agent is running on.
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.initPlatform_ = function() {
|
||||
/**
|
||||
* Whether the user agent is running on a Macintosh operating system.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedMac_ = goog.string.contains(goog.userAgent.PLATFORM,
|
||||
'Mac');
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on a Windows operating system.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedWindows_ = goog.string.contains(
|
||||
goog.userAgent.PLATFORM, 'Win');
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on a Linux operating system.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedLinux_ = goog.string.contains(goog.userAgent.PLATFORM,
|
||||
'Linux');
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on a X11 windowing system.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedX11_ = !!goog.userAgent.getNavigator() &&
|
||||
goog.string.contains(goog.userAgent.getNavigator()['appVersion'] || '',
|
||||
'X11');
|
||||
|
||||
// Need user agent string for Android/IOS detection
|
||||
var ua = goog.userAgent.getUserAgentString();
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on Android.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedAndroid_ = !!ua &&
|
||||
goog.string.contains(ua, 'Android');
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on an iPhone.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedIPhone_ = !!ua && goog.string.contains(ua, 'iPhone');
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on an iPad.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.detectedIPad_ = !!ua && goog.string.contains(ua, 'iPad');
|
||||
};
|
||||
|
||||
|
||||
if (!goog.userAgent.PLATFORM_KNOWN_) {
|
||||
goog.userAgent.initPlatform_();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on a Macintosh operating system.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.MAC = goog.userAgent.PLATFORM_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_MAC : goog.userAgent.detectedMac_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on a Windows operating system.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.WINDOWS = goog.userAgent.PLATFORM_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_WINDOWS : goog.userAgent.detectedWindows_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on a Linux operating system.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.LINUX = goog.userAgent.PLATFORM_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_LINUX : goog.userAgent.detectedLinux_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on a X11 windowing system.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.X11 = goog.userAgent.PLATFORM_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_X11 : goog.userAgent.detectedX11_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on Android.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.ANDROID = goog.userAgent.PLATFORM_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_ANDROID : goog.userAgent.detectedAndroid_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on an iPhone.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.IPHONE = goog.userAgent.PLATFORM_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_IPHONE : goog.userAgent.detectedIPhone_;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent is running on an iPad.
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.userAgent.IPAD = goog.userAgent.PLATFORM_KNOWN_ ?
|
||||
goog.userAgent.ASSUME_IPAD : goog.userAgent.detectedIPad_;
|
||||
|
||||
|
||||
/**
|
||||
* @return {string} The string that describes the version number of the user
|
||||
* agent.
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.determineVersion_ = function() {
|
||||
// All browsers have different ways to detect the version and they all have
|
||||
// different naming schemes.
|
||||
|
||||
// version is a string rather than a number because it may contain 'b', 'a',
|
||||
// and so on.
|
||||
var version = '', re;
|
||||
|
||||
if (goog.userAgent.OPERA && goog.global['opera']) {
|
||||
var operaVersion = goog.global['opera'].version;
|
||||
version = typeof operaVersion == 'function' ? operaVersion() : operaVersion;
|
||||
} else {
|
||||
if (goog.userAgent.GECKO) {
|
||||
re = /rv\:([^\);]+)(\)|;)/;
|
||||
} else if (goog.userAgent.IE) {
|
||||
re = /\b(?:MSIE|rv)\s+([^\);]+)(\)|;)/;
|
||||
} else if (goog.userAgent.WEBKIT) {
|
||||
// WebKit/125.4
|
||||
re = /WebKit\/(\S+)/;
|
||||
}
|
||||
if (re) {
|
||||
var arr = re.exec(goog.userAgent.getUserAgentString());
|
||||
version = arr ? arr[1] : '';
|
||||
}
|
||||
}
|
||||
if (goog.userAgent.IE) {
|
||||
// IE9 can be in document mode 9 but be reporting an inconsistent user agent
|
||||
// version. If it is identifying as a version lower than 9 we take the
|
||||
// documentMode as the version instead. IE8 has similar behavior.
|
||||
// It is recommended to set the X-UA-Compatible header to ensure that IE9
|
||||
// uses documentMode 9.
|
||||
var docMode = goog.userAgent.getDocumentMode_();
|
||||
if (docMode > parseFloat(version)) {
|
||||
return String(docMode);
|
||||
}
|
||||
}
|
||||
return version;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number|undefined} Returns the document mode (for testing).
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.getDocumentMode_ = function() {
|
||||
// NOTE(user): goog.userAgent may be used in context where there is no DOM.
|
||||
var doc = goog.global['document'];
|
||||
return doc ? doc['documentMode'] : undefined;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The version of the user agent. This is a string because it might contain
|
||||
* 'b' (as in beta) as well as multiple dots.
|
||||
* @type {string}
|
||||
*/
|
||||
goog.userAgent.VERSION = goog.userAgent.determineVersion_();
|
||||
|
||||
|
||||
/**
|
||||
* Compares two version numbers.
|
||||
*
|
||||
* @param {string} v1 Version of first item.
|
||||
* @param {string} v2 Version of second item.
|
||||
*
|
||||
* @return {number} 1 if first argument is higher
|
||||
* 0 if arguments are equal
|
||||
* -1 if second argument is higher.
|
||||
* @deprecated Use goog.string.compareVersions.
|
||||
*/
|
||||
goog.userAgent.compare = function(v1, v2) {
|
||||
return goog.string.compareVersions(v1, v2);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Cache for {@link goog.userAgent.isVersionOrHigher}.
|
||||
* Calls to compareVersions are surprisingly expensive and, as a browser's
|
||||
* version number is unlikely to change during a session, we cache the results.
|
||||
* @const
|
||||
* @private
|
||||
*/
|
||||
goog.userAgent.isVersionOrHigherCache_ = {};
|
||||
|
||||
|
||||
/**
|
||||
* Whether the user agent version is higher or the same as the given version.
|
||||
* NOTE: When checking the version numbers for Firefox and Safari, be sure to
|
||||
* use the engine's version, not the browser's version number. For example,
|
||||
* Firefox 3.0 corresponds to Gecko 1.9 and Safari 3.0 to Webkit 522.11.
|
||||
* Opera and Internet Explorer versions match the product release number.<br>
|
||||
* @see <a href="http://en.wikipedia.org/wiki/Safari_version_history">
|
||||
* Webkit</a>
|
||||
* @see <a href="http://en.wikipedia.org/wiki/Gecko_engine">Gecko</a>
|
||||
*
|
||||
* @param {string|number} version The version to check.
|
||||
* @return {boolean} Whether the user agent version is higher or the same as
|
||||
* the given version.
|
||||
*/
|
||||
goog.userAgent.isVersionOrHigher = function(version) {
|
||||
return goog.userAgent.ASSUME_ANY_VERSION ||
|
||||
goog.userAgent.isVersionOrHigherCache_[version] ||
|
||||
(goog.userAgent.isVersionOrHigherCache_[version] =
|
||||
goog.string.compareVersions(goog.userAgent.VERSION, version) >= 0);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deprecated alias to {@code goog.userAgent.isVersionOrHigher}.
|
||||
* @param {string|number} version The version to check.
|
||||
* @return {boolean} Whether the user agent version is higher or the same as
|
||||
* the given version.
|
||||
* @deprecated Use goog.userAgent.isVersionOrHigher().
|
||||
*/
|
||||
goog.userAgent.isVersion = goog.userAgent.isVersionOrHigher;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the IE effective document mode is higher or the same as the given
|
||||
* document mode version.
|
||||
* NOTE: Only for IE, return false for another browser.
|
||||
*
|
||||
* @param {number} documentMode The document mode version to check.
|
||||
* @return {boolean} Whether the IE effective document mode is higher or the
|
||||
* same as the given version.
|
||||
*/
|
||||
goog.userAgent.isDocumentModeOrHigher = function(documentMode) {
|
||||
return goog.userAgent.IE && goog.userAgent.DOCUMENT_MODE >= documentMode;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deprecated alias to {@code goog.userAgent.isDocumentModeOrHigher}.
|
||||
* @param {number} version The version to check.
|
||||
* @return {boolean} Whether the IE effective document mode is higher or the
|
||||
* same as the given version.
|
||||
* @deprecated Use goog.userAgent.isDocumentModeOrHigher().
|
||||
*/
|
||||
goog.userAgent.isDocumentMode = goog.userAgent.isDocumentModeOrHigher;
|
||||
|
||||
|
||||
/**
|
||||
* For IE version < 7, documentMode is undefined, so attempt to use the
|
||||
* CSS1Compat property to see if we are in standards mode. If we are in
|
||||
* standards mode, treat the browser version as the document mode. Otherwise,
|
||||
* IE is emulating version 5.
|
||||
* @type {number|undefined}
|
||||
* @const
|
||||
*/
|
||||
goog.userAgent.DOCUMENT_MODE = (function() {
|
||||
var doc = goog.global['document'];
|
||||
if (!doc || !goog.userAgent.IE) {
|
||||
return undefined;
|
||||
}
|
||||
var mode = goog.userAgent.getDocumentMode_();
|
||||
return mode || (doc['compatMode'] == 'CSS1Compat' ?
|
||||
parseInt(goog.userAgent.VERSION, 10) : 5);
|
||||
})();
|
||||
Reference in New Issue
Block a user