summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-01-12 16:33:35 +0530
committerAndras Timar <andras.timar@collabora.com>2017-01-12 11:26:10 +0000
commit11f20a2ec165bb32cd3fa3e5da2486abaae28d71 (patch)
tree55ddfba141ed077084f2f5e115457b9f7d9ade8a
parentd1502fa918583f77926b0a2c49b7f183c3b6ab8d (diff)
loleaflet: Update dropdowns on refresh everytime2.0.2-1
Change-Id: I39071f1c6249e6ecf71684d3b93cc88f1f859510 (cherry picked from commit 1566ae634d08cb6d0b426d486ee5f1c8ed378b75) loleaflet: Move this logic to updateCommandValues() Change-Id: I64e96f87e56c1b14dd2085d552eebd40977cd7e9 (cherry picked from commit fac3c3aafcb5182c9f59eb6ba5131b6b5606704e) Reviewed-on: https://gerrit.libreoffice.org/32993 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--loleaflet/dist/toolbar/toolbar.js55
1 files changed, 42 insertions, 13 deletions
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 84de90a16..3572b2870 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -436,6 +436,10 @@ function onColorPick(e, color) {
// edit/view mode, state from this object is read and then applied on corresponding buttons
var formatButtons = {};
+var stylesSelectValue;
+var fontsSelectValue;
+var fontsizesSelectValue;
+
$(function () {
$('#toolbar-up-more').w2toolbar({
name: 'toolbar-up-more',
@@ -595,6 +599,8 @@ $(function () {
}
}
+ updateCommandValues();
+
insertTable();
}
});
@@ -1082,6 +1088,8 @@ map.on('commandstatechanged', function (e) {
.append($('<option></option>')
.text(state));
}
+
+ stylesSelectValue = state;
$('.styles-select').val(state).trigger('change');
}
else if (commandName === '.uno:CharFontName') {
@@ -1099,6 +1107,7 @@ map.on('commandstatechanged', function (e) {
.append($('<option></option>')
.text(state));
}
+ fontsSelectValue = state;
$('.fonts-select').val(state).trigger('change');
}
else if (commandName === '.uno:FontHeight') {
@@ -1117,6 +1126,7 @@ map.on('commandstatechanged', function (e) {
.append($('<option></option>')
.text(state).val(state));
}
+ fontsizesSelectValue = state;
$('.fontsizes-select').val(state).trigger('change');
sortFontSizes();
}
@@ -1258,13 +1268,17 @@ map.on('search', function (e) {
}
});
-map.on('updatetoolbarcommandvalues', function (e) {
- // we need an empty option for the place holder to work
+function updateCommandValues() {
var data = [];
- var styles = [];
- var topStyles = [];
- if (e.commandName === '.uno:StyleApply') {
- var commands = e.commandValues.Commands;
+ // 1) For .uno:StyleApply
+ // we need an empty option for the place holder to work
+ if ($('.styles-select option').length === 0) {
+ var styles = [];
+ var topStyles = [];
+ var commandValues = map.getToolbarCommandValues('.uno:StyleApply');
+ if (typeof commandValues === 'undefined')
+ return;
+ var commands = commandValues.Commands;
if (commands && commands.length > 0) {
// Inserts a separator element
data = data.concat({text: '\u2500\u2500\u2500\u2500\u2500\u2500', disabled: true});
@@ -1275,11 +1289,11 @@ map.on('updatetoolbarcommandvalues', function (e) {
}
if (map.getDocType() === 'text') {
- styles = e.commandValues.ParagraphStyles.slice(7, 19);
- topStyles = e.commandValues.ParagraphStyles.slice(0, 7);
+ styles = commandValues.ParagraphStyles.slice(7, 19);
+ topStyles = commandValues.ParagraphStyles.slice(0, 7);
}
else if (map.getDocType() === 'spreadsheet') {
- styles = e.commandValues.CellStyles;
+ styles = commandValues.CellStyles;
}
else if (map.getDocType() === 'presentation') {
// styles are not applied for presentation
@@ -1317,27 +1331,42 @@ map.on('updatetoolbarcommandvalues', function (e) {
data: data,
placeholder: _('Style')
});
+ $('.styles-select').val(stylesSelectValue).trigger('change');
$('.styles-select').on('select2:select', onStyleSelect);
}
- else if (e.commandName === '.uno:CharFontName') {
+
+ if ($('.fonts-select option').length === 0) {
+ // 2) For .uno:CharFontName
+ commandValues = map.getToolbarCommandValues('.uno:CharFontName');
+ if (typeof commandValues === 'undefined') {
+ return;
+ }
// Old browsers like IE11 et al don't like Object.keys with
// empty arguments
- if (typeof e.commandValues === 'object') {
- data = data.concat(Object.keys(e.commandValues));
+ if (typeof commandValues === 'object') {
+ data = data.concat(Object.keys(commandValues));
}
$('.fonts-select').select2({
data: data,
placeholder: _('Font')
});
$('.fonts-select').on('select2:select', onFontSelect);
+ $('.fonts-select').val(fontsSelectValue).trigger('change');
+ }
+ if ($('.fontsizes-select option').length === 0) {
$('.fontsizes-select').select2({
placeholder: _('Size'),
data: []
});
+
$('.fontsizes-select').on('select2:select', onFontSizeSelect);
+ if (fontsSelectValue) {
+ updateFontSizeList(fontsSelectValue);
+ }
+ $('.fontsizes-select').val(fontsizesSelectValue).trigger('change');
}
-});
+}
map.on('updateparts pagenumberchanged', function (e) {
if (e.docType === 'text') {