[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - loleaflet/dist
Henry Castro
hcastro at collabora.com
Thu Oct 26 19:14:28 UTC 2017
loleaflet/dist/toolbar/toolbar.js | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
New commits:
commit 09e997f583e8a38134519e3f8423e7dd936c679e
Author: Henry Castro <hcastro at collabora.com>
Date: Wed Oct 4 09:39:50 2017 -0400
loleaflet: fix statusbar items when refreshed
when the statusbar is refreshed the items are restored to according to
html property
Change-Id: I79f77c5ab4932c10d10dd9780cbd6e6a9b132a38
Reviewed-on: https://gerrit.libreoffice.org/43391
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 66a4b064..2f2eb146 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -701,6 +701,13 @@ function toLocalePattern (pattern, regex, text, sub1, sub2) {
return text;
}
+function updateToolbarItem(toolbar, id, html) {
+ var item = toolbar.get(id);
+ if (item) {
+ item.html = html;
+ }
+}
+
function unoCmdToToolbarId(commandname)
{
var id = commandname.toLowerCase().substr(5);
@@ -736,6 +743,7 @@ function selectItem(item, func)
item.current = index;
}
}
+
function onSearch(e) {
var toolbar = w2ui['toolbar-down'];
// conditionally disabling until, we find a solution for tdf#108577
@@ -1004,7 +1012,7 @@ map.on('doclayerinit', function () {
toolbarUp.remove('wraptextseparator', 'wraptext', 'togglemergecells', 'break-toggle', 'numberformatcurrency', 'numberformatpercent', 'numberformatdecimal', 'numberformatdate', 'numberformatincdecimals', 'numberformatdecdecimals', 'break-number', 'sortascending', 'sortdescending');
toolbarUpMore.remove('wraptextseparator', 'wraptext', 'togglemergecells', 'break-toggle', 'numberformatcurrency', 'numberformatpercent', 'numberformatdecimal', 'numberformatdate', 'numberformatincdecimals', 'numberformatdecdecimals', 'break-number', 'sortascending', 'sortdescending');
statusbar.insert('left', [
- {type: 'break', id:'break1'},
+ {type: 'break', id: 'break1'},
{type: 'html', id: 'StatePageNumber',
html: '<div id="StatePageNumber" class="loleaflet-font" title="'+_('Number of Pages')+ '" style="padding: 5px 5px;">  </div>' },
{type: 'break', id:'break2'},
@@ -1014,7 +1022,7 @@ map.on('doclayerinit', function () {
{type: 'html', id: 'InsertMode',
html: '<div id="InsertMode" class="loleaflet-font" title="'+_('Entering text mode')+ '" style="padding: 5px 5px;">  </div>' },
{type: 'break', id:'break6'},
- {type: 'html', id: 'SelectionMode',
+ {type: 'html', id: 'StatusSelectionMode',
html: '<div id="StatusSelectionMode" class="loleaflet-font" title="'+_('Selection Mode')+ '" style="padding: 5px 5px;">  </div>' },
{type: 'break', id:'break7'},
{type: 'html', id: 'LanguageStatus',
@@ -1179,34 +1187,36 @@ map.on('commandstatechanged', function (e) {
}
}
else if (commandName === '.uno:LanguageStatus') {
- $('#LanguageStatus').html(_(state));
+ updateToolbarItem(statusbar, 'LanguageStatus', $('#LanguageStatus').html(_(state)).html());
}
else if (commandName === '.uno:ModifiedStatus') {
var modifiedStatus = e.state === 'true';
+ var html;
if (modifiedStatus) {
- $('#modifiedstatuslabel').html('');
+ html = $('#modifiedstatuslabel').html('').html();
}
else {
- $('#modifiedstatuslabel').html(_('Document saved'));
+ html = $('#modifiedstatuslabel').html(_('Document saved')).html();
}
+ updateToolbarItem(statusbar, 'modifiedstatuslabel', html);
}
else if (commandName === '.uno:StatusDocPos') {
state = toLocalePattern('Sheet %1 of %2', 'Sheet (\\d+) of (\\d+)', state, '%1', '%2');
- $('#StatusDocPos').html(state ? state : '  ');
+ updateToolbarItem(statusbar, 'StatusDocPos', $('#StatusDocPos').html(state ? state : '  ').html());
}
else if (commandName === '.uno:RowColSelCount') {
state = toLocalePattern('$1 rows, $2 columns selected', '(\\d+) rows, (\\d+) columns selected', state, '$1', '$2');
- $('#RowColSelCount').html(state ? state : '  ');
+ updateToolbarItem(statusbar, 'RowColSelCount', $('#RowColSelCount').html(state ? state : '  ').html());
}
else if (commandName === '.uno:InsertMode') {
- $('#InsertMode').html(state ? L.Styles.insertMode[state].toLocaleString() : '  ');
+ updateToolbarItem(statusbar, 'InsertMode', $('#InsertMode').html(state ? L.Styles.insertMode[state].toLocaleString() : '  ').html());
}
else if (commandName === '.uno:StatusSelectionMode' ||
commandName === '.uno:SelectionMode') {
- $('#StatusSelectionMode').html(state ? L.Styles.selectionMode[state].toLocaleString() : '  ');
+ updateToolbarItem(statusbar, 'StatusSelectionMode', $('#StatusSelectionMode').html(state ? L.Styles.selectionMode[state].toLocaleString() : '  ').html());
}
else if (commandName == '.uno:StateTableCell') {
- $('#StateTableCell').html(state ? state : '  ');
+ updateToolbarItem(statusbar, 'StateTableCell', $('#StateTableCell').html(state ? state : '  ').html());
}
else if (commandName === '.uno:StatusBarFunc') {
if (state) {
@@ -1215,15 +1225,15 @@ map.on('commandstatechanged', function (e) {
}
else if (commandName === '.uno:StatePageNumber') {
state = toLocalePattern('Page %1 of %2', 'Page (\\d+) of (\\d+)', state, '%1', '%2');
- $('#StatePageNumber').html(state ? state : '  ');
+ updateToolbarItem(statusbar, 'StatePageNumber', $('#StatePageNumber').html(state ? state : '  ').html());
}
else if (commandName === '.uno:StateWordCount') {
state = toLocalePattern('%1 words, %2 characters', '([\\d,]+) words, ([\\d,]+) characters', state, '%1', '%2');
- $('#StateWordCount').html(state ? state : '  ');
+ updateToolbarItem(statusbar, 'StateWordCount', $('#StateWordCount').html(state ? state : '  ').html());
}
else if (commandName === '.uno:PageStatus') {
state = toLocalePattern('Slide %1 of %2', 'Slide (\\d+) of (\\d+)', state, '%1', '%2');
- $('#PageStatus').html(state ? state : '  ');
+ updateToolbarItem(statusbar, 'PageStatus', $('#PageStatus').html(state ? state : '  ').html());
}
var id = unoCmdToToolbarId(commandName);
More information about the Libreoffice-commits
mailing list