[Libreoffice-commits] online.git: loleaflet/build loleaflet/js loleaflet/src
Henry Castro (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 17 14:59:32 UTC 2020
loleaflet/build/deps.js | 1
loleaflet/js/global.js | 140 ++++++++++++++++++++++++++++++++++++
loleaflet/src/Leaflet.js | 28 -------
loleaflet/src/core/Browser.js | 162 ------------------------------------------
4 files changed, 141 insertions(+), 190 deletions(-)
New commits:
commit e10e9335c52b29d5c70a879ebc620c3900b4d1bd
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Fri Feb 14 16:51:47 2020 -0400
Commit: Henry Castro <hcastro at collabora.com>
CommitDate: Mon Feb 17 15:59:15 2020 +0100
loleaflet: allow browser detection when loading html page
Move the code related to browser detection immediately
when loading html page to be accessible to all javascript libraries
Change-Id: I442cf5ab8e9452bffa5a760768e8a3e38c1c3c21
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88744
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Henry Castro <hcastro at collabora.com>
diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index 29026afca..c80d9a17d 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -11,7 +11,6 @@ var deps = {
'core/Class.js',
'core/Events.js',
'core/Socket.js',
- 'core/Browser.js',
'core/Matrix.js',
'geometry/Point.js',
'geometry/Bounds.js',
diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js
index 9e5578163..f98450fb0 100644
--- a/loleaflet/js/global.js
+++ b/loleaflet/js/global.js
@@ -1,6 +1,146 @@
/* -*- js-indent-level: 8 -*- */
(function (global) {
+ var ua = navigator.userAgent.toLowerCase(),
+ uv = navigator.vendor.toLowerCase(),
+ doc = document.documentElement,
+
+ ie = 'ActiveXObject' in window,
+
+ webkit = ua.indexOf('webkit') !== -1,
+ phantomjs = ua.indexOf('phantom') !== -1,
+ android23 = ua.search('android [23]') !== -1,
+ chrome = ua.indexOf('chrome') !== -1,
+ gecko = ua.indexOf('gecko') !== -1 && !webkit && !window.opera && !ie,
+ safari = !chrome && (ua.indexOf('safari') !== -1 || uv.indexOf('apple') == 0),
+
+ win = navigator.platform.indexOf('Win') === 0,
+
+ mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1,
+ cypressTest = ua.indexOf('cypress') !== -1,
+ msPointer = !window.PointerEvent && window.MSPointerEvent,
+ pointer = (window.PointerEvent && navigator.pointerEnabled && navigator.maxTouchPoints) || msPointer,
+
+ ie3d = ie && ('transition' in doc.style),
+ webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23,
+ gecko3d = 'MozPerspective' in doc.style,
+ opera12 = 'OTransition' in doc.style;
+
+ var touch = !window.L_NO_TOUCH && (pointer || 'ontouchstart' in window ||
+ (window.DocumentTouch && document instanceof window.DocumentTouch));
+
+ var isInternetExplorer = (navigator.userAgent.toLowerCase().indexOf('msie') != -1 ||
+ navigator.userAgent.toLowerCase().indexOf('trident') != -1);
+
+ global.L = {};
+ global.L.Browser = {
+
+ // @property ie: Boolean
+ // `true` for all Internet Explorer versions (not Edge).
+ ie: ie,
+
+ // @property ielt9: Boolean
+ // `true` for Internet Explorer versions less than 9.
+ ielt9: ie && !document.addEventListener,
+
+ // @property edge: Boolean
+ // `true` for the Edge web browser.
+ edge: 'msLaunchUri' in navigator && !('documentMode' in document),
+
+ // @property webkit: Boolean
+ // `true` for webkit-based browsers like Chrome and Safari (including mobile versions).
+ webkit: webkit,
+
+ // @property gecko: Boolean
+ // `true` for gecko-based browsers like Firefox.
+ gecko: gecko,
+
+ // @property android: Boolean
+ // `true` for any browser running on an Android platform.
+ android: ua.indexOf('android') !== -1,
+
+ // @property android23: Boolean
+ // `true` for browsers running on Android 2 or Android 3.
+ android23: android23,
+
+ // @property chrome: Boolean
+ // `true` for the Chrome browser.
+ chrome: chrome,
+
+ // @property safari: Boolean
+ // `true` for the Safari browser.
+ safari: safari,
+
+ // @property win: Boolean
+ // `true` when the browser is running in a Windows platform
+ win: win,
+
+ // @property ie3d: Boolean
+ // `true` for all Internet Explorer versions supporting CSS transforms.
+ ie3d: ie3d,
+
+ // @property isInternetExplorer: Boolean
+ // `true` for Internet Explorer
+ isInternetExplorer: isInternetExplorer,
+
+ // @property webkit3d: Boolean
+ // `true` for webkit-based browsers supporting CSS transforms.
+ webkit3d: webkit3d,
+
+ // @property gecko3d: Boolean
+ // `true` for gecko-based browsers supporting CSS transforms.
+ gecko3d: gecko3d,
+
+ // @property opera12: Boolean
+ // `true` for the Opera browser supporting CSS transforms (version 12 or later).
+ opera12: opera12,
+
+ // @property any3d: Boolean
+ // `true` for all browsers supporting CSS transforms.
+ any3d: !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantomjs,
+
+
+ // @property mobile: Boolean
+ // `true` for all browsers running in a mobile device.
+ mobile: mobile,
+
+ // @property mobileWebkit: Boolean
+ // `true` for all webkit-based browsers in a mobile device.
+ mobileWebkit: mobile && webkit,
+
+ // @property mobileWebkit3d: Boolean
+ // `true` for all webkit-based browsers in a mobile device supporting CSS transforms.
+ mobileWebkit3d: mobile && webkit3d,
+
+ // @property mobileOpera: Boolean
+ // `true` for the Opera browser in a mobile device.
+ mobileOpera: mobile && window.opera,
+
+ // @property mobileGecko: Boolean
+ // `true` for gecko-based browsers running in a mobile device.
+ mobileGecko: mobile && gecko,
+
+ // @property cypressTest: Boolean
+ // `true` when the browser run by cypress
+ cypressTest: cypressTest,
+
+ // @property touch: Boolean
+ // `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events).
+ touch: !!touch,
+
+ // @property msPointer: Boolean
+ // `true` for browsers implementing the Microsoft touch events model (notably IE10).
+ msPointer: !!msPointer,
+
+ // @property pointer: Boolean
+ // `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx).
+ pointer: !!pointer,
+
+ // @property retina: Boolean
+ // `true` for browsers on a high-resolution "retina" screen.
+ retina: (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1
+ };
+
document.addEventListener('contextmenu', function(e) {
if (e.preventDefault) {
e.preventDefault();
diff --git a/loleaflet/src/Leaflet.js b/loleaflet/src/Leaflet.js
index 329f66a14..43b432473 100644
--- a/loleaflet/src/Leaflet.js
+++ b/loleaflet/src/Leaflet.js
@@ -1,29 +1,3 @@
/* -*- js-indent-level: 8 -*- */
-var L = {
- version: '0.8-dev'
-};
-function expose() {
- var oldL = window.L;
-
- L.noConflict = function () {
- window.L = oldL;
- return this;
- };
-
- window.L = L;
-}
-
-// define Leaflet for Node module pattern loaders, including Browserify
-if (typeof module === 'object' && typeof module.exports === 'object') {
- module.exports = L;
-
-// define Leaflet as an AMD module
-} else if (typeof define === 'function' && define.amd) {
- define(L);
-}
-
-// define Leaflet as a global L variable, saving the original L to restore later if needed
-if (typeof window !== 'undefined') {
- expose();
-}
+window.L.version = '0.8-dev';
diff --git a/loleaflet/src/core/Browser.js b/loleaflet/src/core/Browser.js
deleted file mode 100644
index 607fbb77a..000000000
--- a/loleaflet/src/core/Browser.js
+++ /dev/null
@@ -1,162 +0,0 @@
-/* -*- js-indent-level: 8 -*- */
-/*
- * @namespace Browser
- * @aka L.Browser
- *
- * A namespace with static properties for browser/feature detection used by Leaflet internally.
- *
- * @example
- *
- * ```js
- * if (L.Browser.ielt9) {
- * alert('Upgrade your browser, dude!');
- * }
- * ```
- */
-
-(function () {
-
- var ua = navigator.userAgent.toLowerCase(),
- uv = navigator.vendor.toLowerCase(),
- doc = document.documentElement,
-
- ie = 'ActiveXObject' in window,
-
- webkit = ua.indexOf('webkit') !== -1,
- phantomjs = ua.indexOf('phantom') !== -1,
- android23 = ua.search('android [23]') !== -1,
- chrome = ua.indexOf('chrome') !== -1,
- gecko = ua.indexOf('gecko') !== -1 && !webkit && !window.opera && !ie,
- safari = !chrome && (ua.indexOf('safari') !== -1 || uv.indexOf('apple') == 0),
-
- win = navigator.platform.indexOf('Win') === 0,
-
- mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1,
- cypressTest = ua.indexOf('cypress') !== -1,
- msPointer = !window.PointerEvent && window.MSPointerEvent,
- pointer = (window.PointerEvent && navigator.pointerEnabled && navigator.maxTouchPoints) || msPointer,
-
- ie3d = ie && ('transition' in doc.style),
- webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23,
- gecko3d = 'MozPerspective' in doc.style,
- opera12 = 'OTransition' in doc.style;
-
-
- var touch = !window.L_NO_TOUCH && (pointer || 'ontouchstart' in window ||
- (window.DocumentTouch && document instanceof window.DocumentTouch));
-
- var isInternetExplorer = (navigator.userAgent.toLowerCase().indexOf('msie') != -1 ||
- navigator.userAgent.toLowerCase().indexOf('trident') != -1);
-
- L.Browser = {
-
- // @property ie: Boolean
- // `true` for all Internet Explorer versions (not Edge).
- ie: ie,
-
- // @property ielt9: Boolean
- // `true` for Internet Explorer versions less than 9.
- ielt9: ie && !document.addEventListener,
-
- // @property edge: Boolean
- // `true` for the Edge web browser.
- edge: 'msLaunchUri' in navigator && !('documentMode' in document),
-
- // @property webkit: Boolean
- // `true` for webkit-based browsers like Chrome and Safari (including mobile versions).
- webkit: webkit,
-
- // @property gecko: Boolean
- // `true` for gecko-based browsers like Firefox.
- gecko: gecko,
-
- // @property android: Boolean
- // `true` for any browser running on an Android platform.
- android: ua.indexOf('android') !== -1,
-
- // @property android23: Boolean
- // `true` for browsers running on Android 2 or Android 3.
- android23: android23,
-
- // @property chrome: Boolean
- // `true` for the Chrome browser.
- chrome: chrome,
-
- // @property safari: Boolean
- // `true` for the Safari browser.
- safari: safari,
-
-
- // @property win: Boolean
- // `true` when the browser is running in a Windows platform
- win: win,
-
-
- // @property ie3d: Boolean
- // `true` for all Internet Explorer versions supporting CSS transforms.
- ie3d: ie3d,
-
- // @property isInternetExplorer: Boolean
- // `true` for Internet Explorer
- isInternetExplorer: isInternetExplorer,
-
- // @property webkit3d: Boolean
- // `true` for webkit-based browsers supporting CSS transforms.
- webkit3d: webkit3d,
-
- // @property gecko3d: Boolean
- // `true` for gecko-based browsers supporting CSS transforms.
- gecko3d: gecko3d,
-
- // @property opera12: Boolean
- // `true` for the Opera browser supporting CSS transforms (version 12 or later).
- opera12: opera12,
-
- // @property any3d: Boolean
- // `true` for all browsers supporting CSS transforms.
- any3d: !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantomjs,
-
-
- // @property mobile: Boolean
- // `true` for all browsers running in a mobile device.
- mobile: mobile,
-
- // @property mobileWebkit: Boolean
- // `true` for all webkit-based browsers in a mobile device.
- mobileWebkit: mobile && webkit,
-
- // @property mobileWebkit3d: Boolean
- // `true` for all webkit-based browsers in a mobile device supporting CSS transforms.
- mobileWebkit3d: mobile && webkit3d,
-
- // @property mobileOpera: Boolean
- // `true` for the Opera browser in a mobile device.
- mobileOpera: mobile && window.opera,
-
- // @property mobileGecko: Boolean
- // `true` for gecko-based browsers running in a mobile device.
- mobileGecko: mobile && gecko,
-
- // @property cypressTest: Boolean
- // `true` when the browser run by cypress
- cypressTest: cypressTest,
-
- // @property touch: Boolean
- // `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events).
- touch: !!touch,
-
- // @property msPointer: Boolean
- // `true` for browsers implementing the Microsoft touch events model (notably IE10).
- msPointer: !!msPointer,
-
- // @property pointer: Boolean
- // `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx).
- pointer: !!pointer,
-
-
- // @property retina: Boolean
- // `true` for browsers on a high-resolution "retina" screen.
- retina: (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1
- };
-
-}());
More information about the Libreoffice-commits
mailing list