Path: blob/trunk/third_party/closure/goog/events/browserfeature.js
2868 views
// Copyright 2010 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview Browser capability checks for the events package.16*17*/181920goog.provide('goog.events.BrowserFeature');2122goog.require('goog.userAgent');232425/**26* Enum of browser capabilities.27* @enum {boolean}28*/29goog.events.BrowserFeature = {30/**31* Whether the button attribute of the event is W3C compliant. False in32* Internet Explorer prior to version 9; document-version dependent.33*/34HAS_W3C_BUTTON:35!goog.userAgent.IE || goog.userAgent.isDocumentModeOrHigher(9),3637/**38* Whether the browser supports full W3C event model.39*/40HAS_W3C_EVENT_SUPPORT:41!goog.userAgent.IE || goog.userAgent.isDocumentModeOrHigher(9),4243/**44* To prevent default in IE7-8 for certain keydown events we need set the45* keyCode to -1.46*/47SET_KEY_CODE_TO_PREVENT_DEFAULT:48goog.userAgent.IE && !goog.userAgent.isVersionOrHigher('9'),4950/**51* Whether the {@code navigator.onLine} property is supported.52*/53HAS_NAVIGATOR_ONLINE_PROPERTY:54!goog.userAgent.WEBKIT || goog.userAgent.isVersionOrHigher('528'),5556/**57* Whether HTML5 network online/offline events are supported.58*/59HAS_HTML5_NETWORK_EVENT_SUPPORT:60goog.userAgent.GECKO && goog.userAgent.isVersionOrHigher('1.9b') ||61goog.userAgent.IE && goog.userAgent.isVersionOrHigher('8') ||62goog.userAgent.OPERA && goog.userAgent.isVersionOrHigher('9.5') ||63goog.userAgent.WEBKIT && goog.userAgent.isVersionOrHigher('528'),6465/**66* Whether HTML5 network events fire on document.body, or otherwise the67* window.68*/69HTML5_NETWORK_EVENTS_FIRE_ON_BODY:70goog.userAgent.GECKO && !goog.userAgent.isVersionOrHigher('8') ||71goog.userAgent.IE && !goog.userAgent.isVersionOrHigher('9'),7273/**74* Whether touch is enabled in the browser.75*/76TOUCH_ENABLED:77('ontouchstart' in goog.global ||78!!(goog.global['document'] && document.documentElement &&79'ontouchstart' in document.documentElement) ||80// IE10 uses non-standard touch events, so it has a different check.81!!(goog.global['navigator'] &&82goog.global['navigator']['msMaxTouchPoints']))83};848586