[Libreoffice-commits] online.git: 2 commits - loleaflet/html loleaflet/js loleaflet/src Makefile.am

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Oct 16 23:10:40 UTC 2018


 Makefile.am                              |    7 +++++++
 loleaflet/html/loleaflet.html.m4         |   25 ++++++++++++++++++++-----
 loleaflet/js/global.js                   |    4 ++--
 loleaflet/js/main.js                     |    4 ++--
 loleaflet/js/toolbar.js                  |    2 +-
 loleaflet/src/control/Control.Menubar.js |    2 +-
 loleaflet/src/core/Socket.js             |    6 +++---
 7 files changed, 36 insertions(+), 14 deletions(-)

New commits:
commit e15dc044d7630557b009d4c0e8e38ad67ea40294
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Oct 17 02:04:38 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 17 02:10:14 2018 +0300

    Handle the GTKAPP case, too, in loleaflet
    
    In loleaflet.html.m4, define a macro MOBILEAPP as true if either
    IOSAPP or GTKAPP is true.
    
    Set a window.ThisIsAMobileApp property in either case, and
    window.ThisIsTheGtkApp in the GTKAPP case.
    
    The checks for ThisIsTheiOSApp in the JS could in fact all be changed
    to check for ThisIsAMobileApp instead, as they were all equally valid
    for the gtk+ testbed app. For instance, sending WebKit messages to the
    app code works the same way in JavaScript both for iOS and
    webkit-gtk+. Which is not surprising, I guess, as the underlying
    WebKit is the same.

diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index 61ca22426..08ac4e34a 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -12,7 +12,11 @@ define([_foreachq],[ifelse([$#],[3],[],[define([$1],[$4])$2[]$0([$1],[$2],shift(
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
 <script>
-ifelse(IOSAPP,[],
+dnl# Define MOBILEAPP as true if this is either for the iOS aoo or for the gtk+ "app" testbed
+ifelse(IOSAPP,[true],[define([MOBILEAPP],[true])])
+ifelse(GTKAPP,[true],[define([MOBILEAPP],[true])])
+
+ifelse(MOBILEAPP,[],
   // Start listening for Host_PostmessageReady message and save the
   // result for future
   window.WOPIpostMessageReady = false;
@@ -41,7 +45,7 @@ var Base64ToArrayBuffer = function(base64Str) {
 }
 </script>
 
-ifelse(IOSAPP,[true],
+ifelse(MOBILEAPP,[true],
   ifelse(DEBUG,[true],
     foreachq([fileCSS],[LOLEAFLET_CSS],[<link rel="stylesheet" href="fileCSS" />
   ]),
@@ -54,7 +58,7 @@ ifelse(IOSAPP,[true],
   ])dnl
 )dnl
 <!--%BRANDING_CSS%--> <!-- add your logo here -->
-ifelse(IOSAPP,[true],
+ifelse(MOBILEAPP,[true],
   [<link rel="localizations" href="l10n/localizations.json" type="application/vnd.oftn.l10n+json"/>
    <link rel="localizations" href="l10n/locore-localizations.json" type="application/vnd.oftn.l10n+json"/>
    <link rel="localizations" href="l10n/help-localizations.json" type="application/vnd.oftn.l10n+json"/>
@@ -131,7 +135,7 @@ ifelse(IOSAPP,[true],
     </div>
 
     <script>
-ifelse(IOSAPP,[true],
+ifelse(MOBILEAPP,[true],
      [window.host = '';
       window.serviceRoot = '';
       window.accessToken = '';
@@ -150,13 +154,24 @@ ifelse(IOSAPP,[true],
       window.idleTimeoutSecs = %IDLE_TIMEOUT_SECS%;])
     </script>
   <script>
+
+dnl# For use in conditionals in JS: window.ThisIsAMobileApp, window.ThisIsTheiOSApp,
+dnl# and window.ThisIsTheGtkApp
+ifelse(MOBILEAPP,[true],
+  [window.ThisIsAMobileApp = true;],
+  [window.ThisIsAMobileApp = false;]
+)
 ifelse(IOSAPP,[true],
   [window.ThisIsTheiOSApp = true;],
   [window.ThisIsTheiOSApp = false;]
 )
+ifelse(GTKAPP,[true],
+  [window.ThisIsTheGtkApp = true;],
+  [window.ThisIsTheGtkApp = false;]
+)
   </script>
 
-ifelse(IOSAPP,[true],
+ifelse(MOBILEAPP,[true],
   ifelse(DEBUG,[true],foreachq([fileJS],[LOLEAFLET_JS],
   [    <script src="fileJS"></script>
   ]),
diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js
index c8d540cc8..27a7f3dd5 100644
--- a/loleaflet/js/global.js
+++ b/loleaflet/js/global.js
@@ -29,9 +29,9 @@ global.getParameterByName = function (name) {
 };
 
 global._ = function (string) {
-	// In the iOS case we can't use the stuff from l10n-for-node, as that assumes HTTP.
+	// In the mobile app case we can't use the stuff from l10n-for-node, as that assumes HTTP.
 	// So bail out for now.
-	if (window.ThisIsTheiOSApp) {
+	if (window.ThisIsaMobileApp) {
 		return string;
 	} else {
 		return string.toLocaleString();
diff --git a/loleaflet/js/main.js b/loleaflet/js/main.js
index 3ff8edf5d..15e859606 100644
--- a/loleaflet/js/main.js
+++ b/loleaflet/js/main.js
@@ -25,10 +25,10 @@ var revHistoryEnabled = getParameterByName('revisionhistory');
 var alwaysActive = getParameterByName('alwaysactive');
 // Loleaflet Debug mode
 var debugMode = getParameterByName('debug');
-if (wopiSrc === '' && filePath === '' && !window.ThisIsTheiOSApp) {
+if (wopiSrc === '' && filePath === '' && !window.ThisIsAMobileApp) {
 	vex.dialog.alert(errorMessages.wrongwopisrc);
 }
-if (host === '' && !window.ThisIsTheiOSApp) {
+if (host === '' && !window.ThisIsAMobileApp) {
 	vex.dialog.alert(errorMessages.emptyhosturl);
 }
 
diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index 40a16b668..258aad8cd 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -1869,7 +1869,7 @@ $(document).ready(function() {
 		$('#closebuttonwrapper').hide();
 	} else {
 		$('#closebutton').click(function() {
-			if (window.ThisIsTheiOSApp) {
+			if (window.ThisIsAMobileApp) {
 				window.webkit.messageHandlers.lool.postMessage('BYE', '*');
 			} else {
 				map.fire('postMessage', {msgId: 'close', args: {EverModified: map._everModified, Deprecated: true}});
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 7c0e46e52..8f88f2558 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -735,7 +735,7 @@ L.Control.Menubar = L.Control.extend({
 			this._map.fire('postMessage', {msgId: 'rev-history', args: {Deprecated: true}});
 			this._map.fire('postMessage', {msgId: 'UI_FileVersions'});
 		} else if (id === 'closedocument') {
-			if (window.ThisIsTheiOSApp) {
+			if (window.ThisIsAMobileApp) {
 				window.webkit.messageHandlers.lool.postMessage('BYE', '*');
 			} else {
 				this._map.fire('postMessage', {msgId: 'close', args: {EverModified: this._map._everModified, Deprecated: true}});
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 9676889c3..70d611400 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -61,7 +61,7 @@ L.Socket = L.Class.extend({
 		if (this.socket) {
 			this.close();
 		}
-		if (window.ThisIsTheiOSApp) {
+		if (window.ThisIsAMobileApp) {
 			this.socket = new FakeWebSocket();
 			window.TheFakeWebSocket = this.socket;
 		} else {
@@ -91,7 +91,7 @@ L.Socket = L.Class.extend({
 		this.socket.onopen = L.bind(this._onSocketOpen, this);
 		this.socket.onmessage = L.bind(this._onMessage, this);
 		this.socket.binaryType = 'arraybuffer';
-		if (window.ThisIsTheiOSApp) {
+		if (window.ThisIsAMobileApp) {
 			// This corresponds to the initial GET request when creating a WebSocket
 			// connection and tells the app's code that it is OK to start invoking
 			// TheFakeWebSocket's onmessage handler. Should we also include the
@@ -196,7 +196,7 @@ L.Socket = L.Class.extend({
 
 	_onSocketOpen: function () {
 		console.debug('_onSocketOpen:');
-		if (window.ThisIsTheiOSApp) {
+		if (window.ThisIsAMobileApp) {
 			window.webkit.messageHandlers.debug.postMessage('>>>>>> _onSocketOpen');
 		}
 		this._map._serverRecycling = false;
commit cc2bfc9770d65d3871459d92a2525500012e5308
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Oct 17 02:03:39 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 17 02:10:14 2018 +0300

    Build just loleaflet in the --enable-gtkapp case, too
    
    When I fix the gtk+ testbed app to use autofoo, that subdirectory will
    be built, too.

diff --git a/Makefile.am b/Makefile.am
index 141467a5e..d5fd39ba7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,6 +4,12 @@ SUBDIRS = loleaflet
 
 else
 
+if ENABLE_GTKAPP
+
+SUBDIRS = loleaflet
+
+else
+
 SUBDIRS = . test loleaflet
 
 export ENABLE_DEBUG
@@ -365,3 +371,4 @@ endif
 build-nocheck: all-am
 
 endif
+endif


More information about the Libreoffice-commits mailing list