[Libreoffice-commits] online.git: loleaflet/src
Henry Castro (via logerrit)
logerrit at kemper.freedesktop.org
Wed Mar 18 22:20:47 UTC 2020
loleaflet/src/control/Control.Toolbar.js | 59 ++++++++++++++++++-------------
1 file changed, 35 insertions(+), 24 deletions(-)
New commits:
commit 1c4a66e736d73ab372745972a3bfcbb611e2de8a
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Mar 12 23:43:15 2020 -0400
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Mar 18 23:20:27 2020 +0100
lolealet: fill the font list when data is received
The changes only populate the font list when the data
is received by the client, the other approach iterates
all toolbar items to refresh each one.
Change-Id: I837b52275b49e025fa353dcf088f97c19779bc79
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90450
Tested-by: Andras Timar <andras.timar at collabora.com>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js
index ea80836a4..d6e8ce67d 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -2090,6 +2090,39 @@ function onCommandValues(e) {
}
}
+function updateToolbarCommandValues(e) {
+ if (e.commandName === '.uno:CharFontName') {
+ // 2) For .uno:CharFontName
+ var commandValues = map.getToolbarCommandValues(e.commandName);
+ if (typeof commandValues === 'undefined') {
+ return;
+ }
+
+ var data = []; // reset data in order to avoid that the font select box is populated with styles, too.
+ // Old browsers like IE11 et al don't like Object.keys with
+ // empty arguments
+ if (typeof commandValues === 'object') {
+ data = data.concat(Object.keys(commandValues));
+ }
+
+ /* debug messages it will be removed later */
+ if (data.length < 3) {
+ console.log('ALERT!, the server is sending a small font list');
+ }
+ /* debug end*/
+
+ $('.fonts-select').select2({
+ data: data.sort(function (a, b) { // also sort(localely)
+ return a.localeCompare(b);
+ }),
+ placeholder: _('Font')
+ });
+ $('.fonts-select').on('select2:select', onFontSelect);
+ $('.fonts-select').val(fontsSelectValue).trigger('change');
+ w2ui['editbar'].resize();
+ }
+}
+
function updateCommandValues(targetName) {
var data = [];
// 1) For .uno:StyleApply
@@ -2162,29 +2195,6 @@ function updateCommandValues(targetName) {
$('.styles-select').on('select2:select', onStyleSelect);
w2ui['editbar'].resize();
}
-
- if (targetName === 'fonts' && $('.fonts-select option').length === 1) {
- // 2) For .uno:CharFontName
- commandValues = map.getToolbarCommandValues('.uno:CharFontName');
- if (typeof commandValues === 'undefined') {
- return;
- }
- data = []; // reset data in order to avoid that the font select box is populated with styles, too.
- // Old browsers like IE11 et al don't like Object.keys with
- // empty arguments
- if (typeof commandValues === 'object') {
- data = data.concat(Object.keys(commandValues));
- }
- $('.fonts-select').select2({
- data: data.sort(function (a, b) { // also sort(localely)
- return a.localeCompare(b);
- }),
- placeholder: _('Font')
- });
- $('.fonts-select').on('select2:select', onFontSelect);
- $('.fonts-select').val(fontsSelectValue).trigger('change');
- w2ui['editbar'].resize();
- }
}
@@ -2683,7 +2693,8 @@ function setupToolbar(e) {
if (!window.mode.isMobile()) {
- map.on('updatetoolbarcommandvalues', function() {
+ map.on('updatetoolbarcommandvalues', function(e) {
+ updateToolbarCommandValues(e);
w2ui['editbar'].refresh();
});
More information about the Libreoffice-commits
mailing list