Skip to content

Commit 0e4b6ec

Browse files
mohit-maratheeszkadev
authored andcommitted
Notebookbar: Add in-app Settings dialog to File tab
Signed-off-by: Mohit Marathe <mohit.marathe@collabora.com> Change-Id: I192fa7292248b8f552226c44cf110efb010aff81
1 parent 6f18b49 commit 0e4b6ec

17 files changed

Lines changed: 364 additions & 5 deletions

browser/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ COOL_CSS_LST =\
192192
$(srcdir)/css/jquery-ui-lightness.css \
193193
$(srcdir)/css/infobar.css \
194194
$(srcdir)/css/tooltip.css \
195-
$(srcdir)/css/progressbar.css
195+
$(srcdir)/css/progressbar.css \
196+
$(srcdir)/css/settings.css
196197

197198
COOL_CSS = $(filter %,$(COOL_CSS_LST))
198199

@@ -389,6 +390,7 @@ COOL_JS_LST =\
389390
src/map/handler/Map.KeyboardShortcuts.ts \
390391
src/map/handler/Map.Welcome.js \
391392
src/map/handler/Map.Feedback.js \
393+
src/map/handler/Map.Settings.ts \
392394
src/map/handler/Map.VersionBar.js \
393395
src/dom/DomEvent.MultiClick.js \
394396
src/map/handler/Map.Mouse.js \
@@ -1120,6 +1122,7 @@ pot:
11201122
src/map/handler/Map.VersionBar.js \
11211123
src/map/handler/Map.WOPI.js \
11221124
src/map/handler/Map.Welcome.js \
1125+
src/map/handler/Map.Settings.ts \
11231126
src/slideshow/PauseTimer.ts \
11241127
src/slideshow/PresenterConsole.js \
11251128
src/slideshow/SlideShowPresenter.ts

browser/admin/src/integrator/AdminIntegratorSettings.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,35 @@ const initTranslationStr = () => {
6666
document.documentElement.getAttribute('lang') || String.defaultLocale;
6767
};
6868

69+
const onLoaded = () => {
70+
window.addEventListener('message', onMessage, false);
71+
window.parent.postMessage('{"MessageId":"settings-ready"}', '*');
72+
};
73+
74+
const onMessage = (e) => {
75+
try {
76+
const data = JSON.parse(e.data);
77+
if (e.origin === window.origin && window.parent !== window.self) {
78+
if (data.MessageId === 'settings-ready')
79+
window.parent.postMessage('{"MessageId":"settings-show"}', '*');
80+
else if (data.MessageId === 'settings-save-all') {
81+
const saveButtons = [
82+
'xcu-save-button',
83+
'browser-settings-save-button',
84+
'document-settings-save-button',
85+
];
86+
for (const i in saveButtons) {
87+
const button = document.getElementById(saveButtons[i]);
88+
button?.click();
89+
}
90+
}
91+
}
92+
} catch (err) {
93+
console.error('Could not process postmessage:', err);
94+
return;
95+
}
96+
};
97+
6998
const defaultBrowserSetting: Record<string, any> = {
7099
compactMode: {
71100
value: false,
@@ -347,7 +376,7 @@ class SettingIframe {
347376

348377
if (!response.ok) {
349378
console.error(
350-
'something wend wrong shared config response',
379+
'something went wrong shared config response',
351380
response.text(),
352381
);
353382
throw new Error(
@@ -1609,3 +1638,4 @@ document.addEventListener('DOMContentLoaded', () => {
16091638
});
16101639

16111640
(window as any)._ = _;
1641+
(window as any).onload = onLoaded;

browser/admin/src/integrator/Xcu.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class Xcu {
397397

398398
const resetButton = document.createElement('button');
399399
resetButton.type = 'button';
400-
resetButton.id = 'xcu-reset-button';
400+
resetButton.id = 'document-settings-reset-button';
401401
resetButton.classList.add('button', 'button--vue-secondary');
402402
resetButton.title = _('Reset to default Document settings');
403403
resetButton.innerHTML = `
@@ -426,7 +426,7 @@ class Xcu {
426426

427427
const saveButton = document.createElement('button');
428428
saveButton.type = 'button';
429-
saveButton.id = 'xcu-save-button';
429+
saveButton.id = 'document-settings-save-button';
430430
saveButton.classList.add('button', 'button-primary');
431431
saveButton.title = _('Save Document settings');
432432
saveButton.innerHTML = `

browser/css/settings.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.iframe-settings-wrap {
2+
position: fixed;
3+
left: 50%;
4+
top: 50%;
5+
transform: translate(-50%, -50%);
6+
}
7+
8+
.iframe-settings-content {
9+
position: relative;
10+
z-index: 1106;
11+
display: flex;
12+
flex-direction: column;
13+
width: 700px;
14+
height: 512px;
15+
justify-content: center;
16+
}
17+
18+
.iframe-settings-modal {
19+
display: flex;
20+
max-width: 700px;
21+
min-height: 460px;
22+
justify-content: center;
23+
align-items: center;
24+
border: 0;
25+
}
26+
27+
#iframe-settings-save {
28+
color: var(--color-primary-text);
29+
background-color: var(--color-primary);
30+
}
31+
32+
#allConfigSection {
33+
padding-left: 5px;
34+
}
35+
36+
.jsdialog.ui-button-box-right {
37+
margin-inline-end: 0px
38+
}
39+
40+
#xcu-save-button, #xcu-reset-button, #browser-settings-reset-button, #browser-settings-save-button, #document-settings-reset-button, #document-settings-save-button {
41+
display: none;
42+
}
43+
44+
.section {
45+
padding-top: 0px;
46+
}

browser/html/cool.html.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ m4_ifelse(MOBILEAPP, [true],
293293
data-indirection-url = "%INDIRECTION_URL%"
294294
data-geolocation-setup = "%GEOLOCATION_SETUP%"
295295
data-canvas-slideshow-enabled = "%CANVAS_SLIDESHOW_ENABLED%"
296+
data-wopi-setting-base-url = "%WOPI_SETTING_BASE_URL%"
296297
/>
297298
])
298299

browser/images/lc_settings.svg

Lines changed: 1 addition & 0 deletions
Loading

browser/js/global.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ class InitializerBase {
267267
window.indirectionUrl = "";
268268
window.geolocationSetup = false;
269269
window.canvasSlideshowEnabled = false;
270+
window.wopiSettingBaseUrl = element.dataset.wopiSettingBaseUrl;
270271

271272
window.tileSize = 256;
272273

@@ -411,6 +412,7 @@ class BrowserInitializer extends InitializerBase {
411412
window.indirectionUrl = element.dataset.indirectionUrl;
412413
window.geolocationSetup = element.dataset.geolocationSetup.toLowerCase().trim() === "true";
413414
window.canvasSlideshowEnabled = element.dataset.canvasSlideshowEnabled.toLowerCase().trim() === "true";
415+
window.wopiSettingBaseUrl = element.dataset.wopiSettingBaseUrl;
414416
}
415417

416418
postMessageHandler(e) {

browser/src/control/Control.Menubar.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,8 @@ class Menubar extends L.Control {
21832183
|| id === 'print-all-sheets'
21842184
|| id === 'serveraudit') {
21852185
app.dispatcher.dispatch(id);
2186+
} else if (id === ('settings-dialog')) {
2187+
this._map.settings.showSettingsDialog();
21862188
} else if (id === 'insertcomment') {
21872189
this._map.insertComment();
21882190
} else if (id === 'insert-signatureline') {

browser/src/control/Control.NotebookbarBuilder.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({
4444
this._toolitemHandlers['.uno:Save'] = this._saveControl;
4545
this._toolitemHandlers['.uno:SaveAs'] = this._saveAsControl;
4646
this._toolitemHandlers['.uno:Print'] = this._printControl;
47+
this._toolitemHandlers['.uno:Settings'] = this._onlineHelpControl;
4748
this._toolitemHandlers['.uno:InsertPageHeader'] = this._headerFooterControl;
4849
this._toolitemHandlers['.uno:InsertPageFooter'] = this._headerFooterControl;
4950
this._toolitemHandlers['.uno:Text'] = this._insertTextBoxControl;

browser/src/control/Control.NotebookbarCalc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,22 @@ L.Control.NotebookbarCalc = L.Control.NotebookbarWriter.extend({
362362
);
363363
}
364364

365+
if (window.wopiSettingBaseUrl) {
366+
content.push({
367+
'type': 'separator',
368+
'id': 'file-properties-break',
369+
'orientation': 'vertical'
370+
});
371+
372+
content.push({
373+
'id': 'settings-dialog',
374+
'type': 'bigtoolitem',
375+
'text': _('Options'),
376+
'command': '.uno:Settings',
377+
'accessibility': { focusBack: false, combination: 'T', de: null }
378+
});
379+
}
380+
365381
return this.getTabPage('File', content);
366382
},
367383

0 commit comments

Comments
 (0)