Moved window.app variable into its own file.

"socket" and "console" variables are used at initialization, so they are left in global.js file.

Debugging of window.app object's variables is now easier.

Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
Change-Id: Ic2811ff45ce845cb32d15018eaa2fa9e140202d7
This commit is contained in:
Gökay Şatır 2022-04-08 20:48:25 +03:00 committed by Gökay ŞATIR
parent 9679c36432
commit 4f4c11a886
3 changed files with 48 additions and 43 deletions

View file

@ -193,6 +193,7 @@ COOL_LIBS_JS_DST = $(patsubst %.js,$(DIST_FOLDER)/%.js,$(COOL_LIBS_JS))
# this list includes both Javascript and Typescript generated files
# in a rather precise order.
COOL_JS_LST =\
src/docstate.js \
src/Leaflet.js \
src/errormessages.js \
src/unocommands.js \

View file

@ -1,50 +1,9 @@
/* -*- js-indent-level: 8 -*- */
/* global Uint8Array */
window.app = { // Shouldn't have any functions defined.
definitions: {}, // Class instances are created using definitions under this variable.
dpiScale: window.devicePixelRatio,
roundedDpiScale: Math.round(window.devicePixelRatio),
twipsToPixels: 0, // Twips to pixels multiplier.
pixelsToTwips: 0, // Pixels to twips multiplier.
file: {
editComment: false,
readOnly: true,
disableSidebar: false,
size: {
pixels: [0, 0], // This can change according to the zoom level and document's size.
twips: [0, 0]
},
viewedRectangle: [0, 0, 0, 0], // Visible part of the file (x, y, w, h).
fileBasedView: false, // (draw-impress only) Default is false. For read-only documents, user can view all parts at once. In that case, this variable is set to "true".
calc: {
cellCursor: {
address: [0, 0],
rectangle: {
pixels: [0, 0, 0, 0],
twips: [0, 0, 0, 0]
},
visible: false,
}
},
writer: {
pageRectangleList: [] // Array of arrays: [x, y, w, h] (as usual) // twips only. Pixels will be calculated on the fly. Corresponding pixels may change too ofte
},
},
view: {
commentHasFocus: false,
size: {
pixels: [0, 0] // This can be larger than the document's size.
}
},
tile: {
size: {
pixels: [0, 0],
twips: [0, 0]
}
},
window.app = {
socket: null,
console: {},
console: {}
};
(function (global) {

45
browser/src/docstate.js Normal file
View file

@ -0,0 +1,45 @@
window.app = { // Shouldn't have any functions defined.
definitions: {}, // Class instances are created using definitions under this variable.
dpiScale: window.devicePixelRatio,
roundedDpiScale: Math.round(window.devicePixelRatio),
twipsToPixels: 0, // Twips to pixels multiplier.
pixelsToTwips: 0, // Pixels to twips multiplier.
file: {
editComment: false,
readOnly: true,
disableSidebar: false,
size: {
pixels: [0, 0], // This can change according to the zoom level and document's size.
twips: [0, 0]
},
viewedRectangle: [0, 0, 0, 0], // Visible part of the file (x, y, w, h).
fileBasedView: false, // (draw-impress only) Default is false. For read-only documents, user can view all parts at once. In that case, this variable is set to "true".
calc: {
cellCursor: {
address: [0, 0],
rectangle: {
pixels: [0, 0, 0, 0],
twips: [0, 0, 0, 0]
},
visible: false,
}
},
writer: {
pageRectangleList: [] // Array of arrays: [x, y, w, h] (as usual) // twips only. Pixels will be calculated on the fly. Corresponding pixels may change too ofte
},
},
view: {
commentHasFocus: false,
size: {
pixels: [0, 0] // This can be larger than the document's size.
}
},
tile: {
size: {
pixels: [0, 0],
twips: [0, 0]
}
},
socket: window.app.socket,
console: window.app.console,
};