Remove ol.global
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.color');
|
goog.provide('ol.color');
|
||||||
|
|
||||||
goog.require('ol');
|
|
||||||
goog.require('ol.asserts');
|
goog.require('ol.asserts');
|
||||||
goog.require('ol.math');
|
goog.require('ol.math');
|
||||||
|
|
||||||
@@ -83,7 +82,7 @@ ol.color.fromNamed = function(color) {
|
|||||||
var el = document.createElement('div');
|
var el = document.createElement('div');
|
||||||
el.style.color = color;
|
el.style.color = color;
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
var rgb = ol.global.getComputedStyle(el).color;
|
var rgb = getComputedStyle(el).color;
|
||||||
document.body.removeChild(el);
|
document.body.removeChild(el);
|
||||||
return rgb;
|
return rgb;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -158,10 +158,9 @@ ol.control.FullScreen.prototype.handleFullScreenChange_ = function() {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.control.FullScreen.prototype.setMap = function(map) {
|
ol.control.FullScreen.prototype.setMap = function(map) {
|
||||||
var global = ol.global;
|
|
||||||
ol.control.Control.prototype.setMap.call(this, map);
|
ol.control.Control.prototype.setMap.call(this, map);
|
||||||
if (map) {
|
if (map) {
|
||||||
this.listenerKeys.push(ol.events.listen(global.document,
|
this.listenerKeys.push(ol.events.listen(document,
|
||||||
ol.control.FullScreen.getChangeType_(),
|
ol.control.FullScreen.getChangeType_(),
|
||||||
this.handleFullScreenChange_, this)
|
this.handleFullScreenChange_, this)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -181,14 +181,13 @@ ol.control.ZoomSlider.prototype.setMap = function(map) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.control.ZoomSlider.prototype.initSlider_ = function() {
|
ol.control.ZoomSlider.prototype.initSlider_ = function() {
|
||||||
var global = ol.global;
|
|
||||||
var container = this.element;
|
var container = this.element;
|
||||||
var containerSize = {
|
var containerSize = {
|
||||||
width: container.offsetWidth, height: container.offsetHeight
|
width: container.offsetWidth, height: container.offsetHeight
|
||||||
};
|
};
|
||||||
|
|
||||||
var thumb = container.firstElementChild;
|
var thumb = container.firstElementChild;
|
||||||
var computedStyle = global.getComputedStyle(thumb);
|
var computedStyle = getComputedStyle(thumb);
|
||||||
var thumbWidth = thumb.offsetWidth +
|
var thumbWidth = thumb.offsetWidth +
|
||||||
parseFloat(computedStyle['marginRight']) +
|
parseFloat(computedStyle['marginRight']) +
|
||||||
parseFloat(computedStyle['marginLeft']);
|
parseFloat(computedStyle['marginLeft']);
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ ol.DeviceOrientation.prototype.handleTrackingChanged_ = function() {
|
|||||||
if (ol.has.DEVICE_ORIENTATION) {
|
if (ol.has.DEVICE_ORIENTATION) {
|
||||||
var tracking = this.getTracking();
|
var tracking = this.getTracking();
|
||||||
if (tracking && !this.listenerKey_) {
|
if (tracking && !this.listenerKey_) {
|
||||||
this.listenerKey_ = ol.events.listen(ol.global, 'deviceorientation',
|
this.listenerKey_ = ol.events.listen(window, 'deviceorientation',
|
||||||
this.orientationChange_, this);
|
this.orientationChange_, this);
|
||||||
} else if (!tracking && this.listenerKey_ !== null) {
|
} else if (!tracking && this.listenerKey_ !== null) {
|
||||||
ol.events.unlistenByKey(this.listenerKey_);
|
ol.events.unlistenByKey(this.listenerKey_);
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
goog.provide('ol.dom');
|
goog.provide('ol.dom');
|
||||||
|
|
||||||
goog.require('ol');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an html canvas element and returns its 2d context.
|
* Create an html canvas element and returns its 2d context.
|
||||||
@@ -29,9 +27,8 @@ ol.dom.createCanvasContext2D = function(opt_width, opt_height) {
|
|||||||
* @return {number} The width.
|
* @return {number} The width.
|
||||||
*/
|
*/
|
||||||
ol.dom.outerWidth = function(element) {
|
ol.dom.outerWidth = function(element) {
|
||||||
var global = ol.global;
|
|
||||||
var width = element.offsetWidth;
|
var width = element.offsetWidth;
|
||||||
var style = element.currentStyle || global.getComputedStyle(element);
|
var style = element.currentStyle || getComputedStyle(element);
|
||||||
width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);
|
width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
@@ -46,9 +43,8 @@ ol.dom.outerWidth = function(element) {
|
|||||||
* @return {number} The height.
|
* @return {number} The height.
|
||||||
*/
|
*/
|
||||||
ol.dom.outerHeight = function(element) {
|
ol.dom.outerHeight = function(element) {
|
||||||
var global = ol.global;
|
|
||||||
var height = element.offsetHeight;
|
var height = element.offsetHeight;
|
||||||
var style = element.currentStyle || global.getComputedStyle(element);
|
var style = element.currentStyle || getComputedStyle(element);
|
||||||
height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);
|
height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
|
|||||||
@@ -113,9 +113,7 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.handleTrackingChanged_ = function() {
|
ol.Geolocation.prototype.handleTrackingChanged_ = function() {
|
||||||
var global = ol.global;
|
|
||||||
if (ol.has.GEOLOCATION) {
|
if (ol.has.GEOLOCATION) {
|
||||||
var navigator = global.navigator;
|
|
||||||
var tracking = this.getTracking();
|
var tracking = this.getTracking();
|
||||||
if (tracking && this.watchId_ === undefined) {
|
if (tracking && this.watchId_ === undefined) {
|
||||||
this.watchId_ = navigator.geolocation.watchPosition(
|
this.watchId_ = navigator.geolocation.watchPosition(
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ goog.provide('ol.has');
|
|||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.webgl');
|
goog.require('ol.webgl');
|
||||||
|
|
||||||
var olGlobal = ol.global;
|
|
||||||
var ua = typeof navigator !== 'undefined' ?
|
var ua = typeof navigator !== 'undefined' ?
|
||||||
navigator.userAgent.toLowerCase() : '';
|
navigator.userAgent.toLowerCase() : '';
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ ol.has.MAC = ua.indexOf('macintosh') !== -1;
|
|||||||
* @type {number}
|
* @type {number}
|
||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.has.DEVICE_PIXEL_RATIO = olGlobal.devicePixelRatio || 1;
|
ol.has.DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +60,7 @@ ol.has.CANVAS = ol.ENABLE_CANVAS && (
|
|||||||
* @return {boolean} Canvas supported.
|
* @return {boolean} Canvas supported.
|
||||||
*/
|
*/
|
||||||
function() {
|
function() {
|
||||||
if (!('HTMLCanvasElement' in olGlobal)) {
|
if (!('HTMLCanvasElement' in window)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -86,7 +85,7 @@ ol.has.CANVAS = ol.ENABLE_CANVAS && (
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.has.DEVICE_ORIENTATION = 'DeviceOrientationEvent' in olGlobal;
|
ol.has.DEVICE_ORIENTATION = 'DeviceOrientationEvent' in window;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,7 +94,7 @@ ol.has.DEVICE_ORIENTATION = 'DeviceOrientationEvent' in olGlobal;
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.has.GEOLOCATION = 'geolocation' in olGlobal.navigator;
|
ol.has.GEOLOCATION = 'geolocation' in navigator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +103,7 @@ ol.has.GEOLOCATION = 'geolocation' in olGlobal.navigator;
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.has.TOUCH = ol.ASSUME_TOUCH || 'ontouchstart' in olGlobal;
|
ol.has.TOUCH = ol.ASSUME_TOUCH || 'ontouchstart' in window;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,7 +111,7 @@ ol.has.TOUCH = ol.ASSUME_TOUCH || 'ontouchstart' in olGlobal;
|
|||||||
* @const
|
* @const
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
ol.has.POINTER = 'PointerEvent' in olGlobal;
|
ol.has.POINTER = 'PointerEvent' in window;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,7 +119,7 @@ ol.has.POINTER = 'PointerEvent' in olGlobal;
|
|||||||
* @const
|
* @const
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
ol.has.MSPOINTER = !!(olGlobal.navigator.msPointerEnabled);
|
ol.has.MSPOINTER = !!(navigator.msPointerEnabled);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -139,7 +138,7 @@ ol.has.WEBGL;
|
|||||||
var textureSize;
|
var textureSize;
|
||||||
var /** @type {Array.<string>} */ extensions = [];
|
var /** @type {Array.<string>} */ extensions = [];
|
||||||
|
|
||||||
if ('WebGLRenderingContext' in olGlobal) {
|
if ('WebGLRenderingContext' in window) {
|
||||||
try {
|
try {
|
||||||
var canvas = /** @type {HTMLCanvasElement} */
|
var canvas = /** @type {HTMLCanvasElement} */
|
||||||
(document.createElement('CANVAS'));
|
(document.createElement('CANVAS'));
|
||||||
|
|||||||
@@ -288,15 +288,3 @@ ol.getUid = function(obj) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.uidCounter_ = 0;
|
ol.uidCounter_ = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see https://github.com/tc39/proposal-global
|
|
||||||
*/
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
ol.global = window;
|
|
||||||
} else if (typeof global !== 'undefined') {
|
|
||||||
ol.global = global;
|
|
||||||
} else if (typeof self !== 'undefined') {
|
|
||||||
ol.global = self;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -87,8 +87,6 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
|||||||
// https://github.com/mapbox/mapbox-gl-js/blob/001c7b9/js/ui/handler/scroll_zoom.js
|
// https://github.com/mapbox/mapbox-gl-js/blob/001c7b9/js/ui/handler/scroll_zoom.js
|
||||||
//TODO There's more good stuff in there for inspiration to improve this interaction.
|
//TODO There's more good stuff in there for inspiration to improve this interaction.
|
||||||
var delta;
|
var delta;
|
||||||
var global = ol.global;
|
|
||||||
var WheelEvent = global.WheelEvent;
|
|
||||||
if (mapBrowserEvent.type == ol.events.EventType.WHEEL) {
|
if (mapBrowserEvent.type == ol.events.EventType.WHEEL) {
|
||||||
delta = wheelEvent.deltaY;
|
delta = wheelEvent.deltaY;
|
||||||
if (ol.has.FIREFOX &&
|
if (ol.has.FIREFOX &&
|
||||||
@@ -114,8 +112,8 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
|||||||
var duration = ol.MOUSEWHEELZOOM_TIMEOUT_DURATION;
|
var duration = ol.MOUSEWHEELZOOM_TIMEOUT_DURATION;
|
||||||
var timeLeft = Math.max(duration - (Date.now() - this.startTime_), 0);
|
var timeLeft = Math.max(duration - (Date.now() - this.startTime_), 0);
|
||||||
|
|
||||||
global.clearTimeout(this.timeoutId_);
|
clearTimeout(this.timeoutId_);
|
||||||
this.timeoutId_ = global.setTimeout(
|
this.timeoutId_ = setTimeout(
|
||||||
this.doZoom_.bind(this, map), timeLeft);
|
this.doZoom_.bind(this, map), timeLeft);
|
||||||
|
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
|
|||||||
@@ -550,7 +550,6 @@ ol.Map.prototype.removePreRenderFunction = function(preRenderFunction) {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.disposeInternal = function() {
|
ol.Map.prototype.disposeInternal = function() {
|
||||||
var global = ol.global;
|
|
||||||
this.mapBrowserEventHandler_.dispose();
|
this.mapBrowserEventHandler_.dispose();
|
||||||
this.renderer_.dispose();
|
this.renderer_.dispose();
|
||||||
ol.events.unlisten(this.viewport_, ol.events.EventType.WHEEL,
|
ol.events.unlisten(this.viewport_, ol.events.EventType.WHEEL,
|
||||||
@@ -558,12 +557,12 @@ ol.Map.prototype.disposeInternal = function() {
|
|||||||
ol.events.unlisten(this.viewport_, ol.events.EventType.MOUSEWHEEL,
|
ol.events.unlisten(this.viewport_, ol.events.EventType.MOUSEWHEEL,
|
||||||
this.handleBrowserEvent, this);
|
this.handleBrowserEvent, this);
|
||||||
if (this.handleResize_ !== undefined) {
|
if (this.handleResize_ !== undefined) {
|
||||||
global.removeEventListener(ol.events.EventType.RESIZE,
|
window.removeEventListener(ol.events.EventType.RESIZE,
|
||||||
this.handleResize_, false);
|
this.handleResize_, false);
|
||||||
this.handleResize_ = undefined;
|
this.handleResize_ = undefined;
|
||||||
}
|
}
|
||||||
if (this.animationDelayKey_) {
|
if (this.animationDelayKey_) {
|
||||||
global.cancelAnimationFrame(this.animationDelayKey_);
|
cancelAnimationFrame(this.animationDelayKey_);
|
||||||
this.animationDelayKey_ = undefined;
|
this.animationDelayKey_ = undefined;
|
||||||
}
|
}
|
||||||
this.setTarget(null);
|
this.setTarget(null);
|
||||||
@@ -1037,7 +1036,6 @@ ol.Map.prototype.handleSizeChanged_ = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.handleTargetChanged_ = function() {
|
ol.Map.prototype.handleTargetChanged_ = function() {
|
||||||
var global = ol.global;
|
|
||||||
// target may be undefined, null, a string or an Element.
|
// target may be undefined, null, a string or an Element.
|
||||||
// If it's a string we convert it to an Element before proceeding.
|
// If it's a string we convert it to an Element before proceeding.
|
||||||
// If it's not now an Element we remove the viewport from the DOM.
|
// If it's not now an Element we remove the viewport from the DOM.
|
||||||
@@ -1060,7 +1058,7 @@ ol.Map.prototype.handleTargetChanged_ = function() {
|
|||||||
if (!targetElement) {
|
if (!targetElement) {
|
||||||
ol.dom.removeNode(this.viewport_);
|
ol.dom.removeNode(this.viewport_);
|
||||||
if (this.handleResize_ !== undefined) {
|
if (this.handleResize_ !== undefined) {
|
||||||
global.removeEventListener(ol.events.EventType.RESIZE,
|
window.removeEventListener(ol.events.EventType.RESIZE,
|
||||||
this.handleResize_, false);
|
this.handleResize_, false);
|
||||||
this.handleResize_ = undefined;
|
this.handleResize_ = undefined;
|
||||||
}
|
}
|
||||||
@@ -1078,7 +1076,7 @@ ol.Map.prototype.handleTargetChanged_ = function() {
|
|||||||
|
|
||||||
if (!this.handleResize_) {
|
if (!this.handleResize_) {
|
||||||
this.handleResize_ = this.updateSize.bind(this);
|
this.handleResize_ = this.updateSize.bind(this);
|
||||||
global.addEventListener(ol.events.EventType.RESIZE,
|
window.addEventListener(ol.events.EventType.RESIZE,
|
||||||
this.handleResize_, false);
|
this.handleResize_, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1159,9 +1157,8 @@ ol.Map.prototype.isRendered = function() {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.renderSync = function() {
|
ol.Map.prototype.renderSync = function() {
|
||||||
var global = ol.global;
|
|
||||||
if (this.animationDelayKey_) {
|
if (this.animationDelayKey_) {
|
||||||
global.cancelAnimationFrame(this.animationDelayKey_);
|
cancelAnimationFrame(this.animationDelayKey_);
|
||||||
}
|
}
|
||||||
this.animationDelay_();
|
this.animationDelay_();
|
||||||
};
|
};
|
||||||
@@ -1172,9 +1169,8 @@ ol.Map.prototype.renderSync = function() {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.render = function() {
|
ol.Map.prototype.render = function() {
|
||||||
var global = ol.global;
|
|
||||||
if (this.animationDelayKey_ === undefined) {
|
if (this.animationDelayKey_ === undefined) {
|
||||||
this.animationDelayKey_ = global.requestAnimationFrame(
|
this.animationDelayKey_ = requestAnimationFrame(
|
||||||
this.animationDelay_);
|
this.animationDelay_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1314,7 +1310,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
|
|||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new ol.MapEvent(ol.MapEventType.POSTRENDER, this, frameState));
|
new ol.MapEvent(ol.MapEventType.POSTRENDER, this, frameState));
|
||||||
|
|
||||||
ol.global.setTimeout(this.handlePostRender.bind(this), 0);
|
setTimeout(this.handlePostRender.bind(this), 0);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1381,13 +1377,12 @@ ol.Map.prototype.skipFeature = function(feature) {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.updateSize = function() {
|
ol.Map.prototype.updateSize = function() {
|
||||||
var global = ol.global;
|
|
||||||
var targetElement = this.getTargetElement();
|
var targetElement = this.getTargetElement();
|
||||||
|
|
||||||
if (!targetElement) {
|
if (!targetElement) {
|
||||||
this.setSize(undefined);
|
this.setSize(undefined);
|
||||||
} else {
|
} else {
|
||||||
var computedStyle = global.getComputedStyle(targetElement);
|
var computedStyle = getComputedStyle(targetElement);
|
||||||
this.setSize([
|
this.setSize([
|
||||||
targetElement.offsetWidth -
|
targetElement.offsetWidth -
|
||||||
parseFloat(computedStyle['borderLeftWidth']) -
|
parseFloat(computedStyle['borderLeftWidth']) -
|
||||||
|
|||||||
@@ -214,9 +214,6 @@ ol.inherits(ol.MapBrowserEventHandler, ol.events.EventTarget);
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) {
|
ol.MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) {
|
||||||
var global = ol.global;
|
|
||||||
var clearTimeout = global.clearTimeout;
|
|
||||||
var setTimeout = global.setTimeout;
|
|
||||||
var newEvent = new ol.MapBrowserPointerEvent(
|
var newEvent = new ol.MapBrowserPointerEvent(
|
||||||
ol.MapBrowserEvent.EventType.CLICK, this.map_, pointerEvent);
|
ol.MapBrowserEvent.EventType.CLICK, this.map_, pointerEvent);
|
||||||
this.dispatchEvent(newEvent);
|
this.dispatchEvent(newEvent);
|
||||||
|
|||||||
@@ -15,24 +15,23 @@ goog.require('ol');
|
|||||||
* callback. Default is 'callback'.
|
* callback. Default is 'callback'.
|
||||||
*/
|
*/
|
||||||
ol.net.jsonp = function(url, callback, opt_errback, opt_callbackParam) {
|
ol.net.jsonp = function(url, callback, opt_errback, opt_callbackParam) {
|
||||||
var global = ol.global;
|
var script = document.createElement('script');
|
||||||
var script = global.document.createElement('script');
|
|
||||||
var key = 'olc_' + ol.getUid(callback);
|
var key = 'olc_' + ol.getUid(callback);
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
delete global[key];
|
delete window[key];
|
||||||
script.parentNode.removeChild(script);
|
script.parentNode.removeChild(script);
|
||||||
}
|
}
|
||||||
script.async = true;
|
script.async = true;
|
||||||
script.src = url + (url.indexOf('?') == -1 ? '?' : '&') +
|
script.src = url + (url.indexOf('?') == -1 ? '?' : '&') +
|
||||||
(opt_callbackParam || 'callback') + '=' + key;
|
(opt_callbackParam || 'callback') + '=' + key;
|
||||||
var timer = global.setTimeout(function() {
|
var timer = setTimeout(function() {
|
||||||
cleanup();
|
cleanup();
|
||||||
if (opt_errback) {
|
if (opt_errback) {
|
||||||
opt_errback();
|
opt_errback();
|
||||||
}
|
}
|
||||||
}, 10000);
|
}, 10000);
|
||||||
global[key] = function(data) {
|
window[key] = function(data) {
|
||||||
global.clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
cleanup();
|
cleanup();
|
||||||
callback(data);
|
callback(data);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -398,10 +398,9 @@ ol.Overlay.prototype.panIntoView_ = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Overlay.prototype.getRect_ = function(element, size) {
|
ol.Overlay.prototype.getRect_ = function(element, size) {
|
||||||
var global = ol.global;
|
|
||||||
var box = element.getBoundingClientRect();
|
var box = element.getBoundingClientRect();
|
||||||
var offsetX = box.left + global.pageXOffset;
|
var offsetX = box.left + window.pageXOffset;
|
||||||
var offsetY = box.top + global.pageYOffset;
|
var offsetY = box.top + window.pageYOffset;
|
||||||
return [
|
return [
|
||||||
offsetX,
|
offsetX,
|
||||||
offsetY,
|
offsetY,
|
||||||
|
|||||||
@@ -148,8 +148,7 @@ ol.pointer.TouchSource.prototype.removePrimaryPointer_ = function(inPointer) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.pointer.TouchSource.prototype.resetClickCount_ = function() {
|
ol.pointer.TouchSource.prototype.resetClickCount_ = function() {
|
||||||
var global = ol.global;
|
this.resetId_ = setTimeout(
|
||||||
this.resetId_ = global.setTimeout(
|
|
||||||
this.resetClickCountHandler_.bind(this),
|
this.resetClickCountHandler_.bind(this),
|
||||||
ol.pointer.TouchSource.CLICK_COUNT_TIMEOUT);
|
ol.pointer.TouchSource.CLICK_COUNT_TIMEOUT);
|
||||||
};
|
};
|
||||||
@@ -168,9 +167,8 @@ ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() {
|
ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() {
|
||||||
var global = ol.global;
|
|
||||||
if (this.resetId_ !== undefined) {
|
if (this.resetId_ !== undefined) {
|
||||||
global.clearTimeout(this.resetId_);
|
clearTimeout(this.resetId_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -442,8 +440,7 @@ ol.pointer.TouchSource.prototype.dedupSynthMouse_ = function(inEvent) {
|
|||||||
var lt = [t.clientX, t.clientY];
|
var lt = [t.clientX, t.clientY];
|
||||||
lts.push(lt);
|
lts.push(lt);
|
||||||
|
|
||||||
var global = ol.global;
|
setTimeout(function() {
|
||||||
global.setTimeout(function() {
|
|
||||||
// remove touch after timeout
|
// remove touch after timeout
|
||||||
ol.array.remove(lts, lt);
|
ol.array.remove(lts, lt);
|
||||||
}, ol.pointer.TouchSource.DEDUP_TIMEOUT);
|
}, ol.pointer.TouchSource.DEDUP_TIMEOUT);
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ ol.proj.Projection = function(options) {
|
|||||||
ol.DEBUG && console.assert(code !== undefined,
|
ol.DEBUG && console.assert(code !== undefined,
|
||||||
'Option "code" is required for constructing instance');
|
'Option "code" is required for constructing instance');
|
||||||
if (ol.ENABLE_PROJ4JS) {
|
if (ol.ENABLE_PROJ4JS) {
|
||||||
var proj4js = ol.proj.proj4_ || ol.global['proj4'];
|
var proj4js = ol.proj.proj4_ || window['proj4'];
|
||||||
if (typeof proj4js == 'function' && projections[code] === undefined) {
|
if (typeof proj4js == 'function' && projections[code] === undefined) {
|
||||||
var def = proj4js.defs(code);
|
var def = proj4js.defs(code);
|
||||||
if (def !== undefined) {
|
if (def !== undefined) {
|
||||||
@@ -668,7 +668,7 @@ ol.proj.get = function(projectionLike) {
|
|||||||
var code = projectionLike;
|
var code = projectionLike;
|
||||||
projection = ol.proj.projections_[code];
|
projection = ol.proj.projections_[code];
|
||||||
if (ol.ENABLE_PROJ4JS) {
|
if (ol.ENABLE_PROJ4JS) {
|
||||||
var proj4js = ol.proj.proj4_ || ol.global['proj4'];
|
var proj4js = ol.proj.proj4_ || window['proj4'];
|
||||||
if (projection === undefined && typeof proj4js == 'function' &&
|
if (projection === undefined && typeof proj4js == 'function' &&
|
||||||
proj4js.defs(code) !== undefined) {
|
proj4js.defs(code) !== undefined) {
|
||||||
projection = new ol.proj.Projection({code: code});
|
projection = new ol.proj.Projection({code: code});
|
||||||
|
|||||||
@@ -17,18 +17,18 @@ goog.require('ol.proj');
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.reproj.browserAntialiasesClip_ = (function(global) {
|
ol.reproj.browserAntialiasesClip_ = (function() {
|
||||||
// Adapted from http://stackoverflow.com/questions/4565112/javascript-how-to-find-out-if-the-user-browser-is-chrome
|
// Adapted from http://stackoverflow.com/questions/4565112/javascript-how-to-find-out-if-the-user-browser-is-chrome
|
||||||
var isOpera = global.navigator.userAgent.indexOf('OPR') > -1;
|
var isOpera = navigator.userAgent.indexOf('OPR') > -1;
|
||||||
var isIEedge = global.navigator.userAgent.indexOf('Edge') > -1;
|
var isIEedge = navigator.userAgent.indexOf('Edge') > -1;
|
||||||
return !(
|
return !(
|
||||||
!global.navigator.userAgent.match('CriOS') && // Not Chrome on iOS
|
!navigator.userAgent.match('CriOS') && // Not Chrome on iOS
|
||||||
global.chrome !== null && global.chrome !== undefined && // Has chrome in window
|
'chrome' in window && // Has chrome in window
|
||||||
global.navigator.vendor === 'Google Inc.' && // Vendor is Google.
|
navigator.vendor === 'Google Inc.' && // Vendor is Google.
|
||||||
isOpera == false && // Not Opera
|
isOpera == false && // Not Opera
|
||||||
isIEedge == false // Not Edge
|
isIEedge == false // Not Edge
|
||||||
);
|
);
|
||||||
})(ol.global);
|
})();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -300,8 +300,7 @@ ol.reproj.Tile.prototype.load = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (leftToLoad === 0) {
|
if (leftToLoad === 0) {
|
||||||
var global = ol.global;
|
setTimeout(this.reproject_.bind(this), 0);
|
||||||
global.setTimeout(this.reproject_.bind(this), 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function(
|
|||||||
tile.forDataAtCoordinate(coordinate, callback, opt_this, opt_request);
|
tile.forDataAtCoordinate(coordinate, callback, opt_this, opt_request);
|
||||||
} else {
|
} else {
|
||||||
if (opt_request === true) {
|
if (opt_request === true) {
|
||||||
ol.global.setTimeout(function() {
|
setTimeout(function() {
|
||||||
callback.call(opt_this, null);
|
callback.call(opt_this, null);
|
||||||
}, 0);
|
}, 0);
|
||||||
} else {
|
} else {
|
||||||
@@ -389,7 +389,7 @@ ol.source.TileUTFGrid.Tile_.prototype.forDataAtCoordinate = function(coordinate,
|
|||||||
this.loadInternal_();
|
this.loadInternal_();
|
||||||
} else {
|
} else {
|
||||||
if (opt_request === true) {
|
if (opt_request === true) {
|
||||||
ol.global.setTimeout(function() {
|
setTimeout(function() {
|
||||||
callback.call(opt_this, this.getData(coordinate));
|
callback.call(opt_this, this.getData(coordinate));
|
||||||
}.bind(this), 0);
|
}.bind(this), 0);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ goog.require('ol.interaction.DragAndDrop');
|
|||||||
|
|
||||||
describe('ol.interaction.DragAndDrop', function() {
|
describe('ol.interaction.DragAndDrop', function() {
|
||||||
var viewport, map, interaction;
|
var viewport, map, interaction;
|
||||||
var global = ol.global;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
viewport = new ol.events.EventTarget();
|
viewport = new ol.events.EventTarget();
|
||||||
@@ -71,7 +70,7 @@ describe('ol.interaction.DragAndDrop', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('#handleDrop_', function() {
|
describe('#handleDrop_', function() {
|
||||||
var origFileReader = global.FileReader;
|
var OrigFileReader = FileReader;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
FileReader = function() {
|
FileReader = function() {
|
||||||
@@ -85,7 +84,7 @@ describe('ol.interaction.DragAndDrop', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
global.FileReader = origFileReader;
|
FileReader = OrigFileReader;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('reads dropped files', function(done) {
|
it('reads dropped files', function(done) {
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ goog.require('ol.net');
|
|||||||
|
|
||||||
describe('ol.net', function() {
|
describe('ol.net', function() {
|
||||||
|
|
||||||
var global = ol.global;
|
|
||||||
|
|
||||||
describe('jsonp()', function() {
|
describe('jsonp()', function() {
|
||||||
var head = global.document.getElementsByTagName('head')[0];
|
var head = document.getElementsByTagName('head')[0];
|
||||||
var origAppendChild = head.appendChild;
|
var origAppendChild = head.appendChild;
|
||||||
var origCreateElement = document.createElement;
|
var origCreateElement = document.createElement;
|
||||||
var origSetTimeout = global.setTimeout;
|
var origSetTimeout = setTimeout;
|
||||||
var key, removeChild;
|
var key, removeChild;
|
||||||
|
|
||||||
function createCallback(url, done) {
|
function createCallback(url, done) {
|
||||||
@@ -31,7 +29,7 @@ describe('ol.net', function() {
|
|||||||
if (arg == 'script') {
|
if (arg == 'script') {
|
||||||
return element;
|
return element;
|
||||||
} else {
|
} else {
|
||||||
return origCreateElement.apply(global.document, arguments);
|
return origCreateElement.apply(document, arguments);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
head.appendChild = function(el) {
|
head.appendChild = function(el) {
|
||||||
@@ -40,13 +38,13 @@ describe('ol.net', function() {
|
|||||||
removeChild: removeChild
|
removeChild: removeChild
|
||||||
};
|
};
|
||||||
origSetTimeout(function() {
|
origSetTimeout(function() {
|
||||||
global[key](element.src);
|
window[key](element.src);
|
||||||
}, 0);
|
}, 0);
|
||||||
} else {
|
} else {
|
||||||
origAppendChild.apply(head, arguments);
|
origAppendChild.apply(head, arguments);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
global.setTimeout = function(fn, time) {
|
setTimeout = function(fn, time) {
|
||||||
origSetTimeout(fn, 100);
|
origSetTimeout(fn, 100);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -54,7 +52,7 @@ describe('ol.net', function() {
|
|||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
document.createElement = origCreateElement;
|
document.createElement = origCreateElement;
|
||||||
head.appendChild = origAppendChild;
|
head.appendChild = origAppendChild;
|
||||||
global.setTimeout = origSetTimeout;
|
setTimeout = origSetTimeout;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('appends callback param to url, cleans up after call', function(done) {
|
it('appends callback param to url, cleans up after call', function(done) {
|
||||||
@@ -74,7 +72,7 @@ describe('ol.net', function() {
|
|||||||
expect.fail();
|
expect.fail();
|
||||||
}
|
}
|
||||||
function errback() {
|
function errback() {
|
||||||
expect(global[key]).to.be(undefined);
|
expect(window[key]).to.be(undefined);
|
||||||
expect(removeChild.called).to.be(true);
|
expect(removeChild.called).to.be(true);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user