[Libreoffice-commits] online.git: 2 commits - loleaflet/dist

Pranav Kant pranavk at collabora.co.uk
Thu Jan 12 11:10:33 UTC 2017


 loleaflet/dist/toolbar/toolbar.js |   62 ++++++++++++++++++++++++++------------
 1 file changed, 43 insertions(+), 19 deletions(-)

New commits:
commit 1566ae634d08cb6d0b426d486ee5f1c8ed378b75
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Jan 12 16:33:35 2017 +0530

    loleaflet: Update dropdowns on refresh everytime
    
    Change-Id: I39071f1c6249e6ecf71684d3b93cc88f1f859510

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index d5fb89a..23d4284 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -441,6 +441,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',
@@ -611,6 +615,12 @@ $(function () {
 				}
 			}
 
+			updateCommandValues();
+			if (fontsSelectValue){
+				$('.fontsizes-select').val(fontsizesSelectValue);
+				updateFontSizeList(fontsSelectValue);
+			}
+
 			insertTable();
 		}
 	});
@@ -1056,6 +1066,8 @@ map.on('commandstatechanged', function (e) {
 				.append($('<option></option>')
 				.text(state));
 		}
+
+		stylesSelectValue = state;
 		$('.styles-select').val(state).trigger('change');
 	}
 	else if (commandName === '.uno:CharFontName') {
@@ -1073,6 +1085,7 @@ map.on('commandstatechanged', function (e) {
 				.append($('<option></option>')
 				.text(state));
 		}
+		fontsSelectValue = state;
 		$('.fonts-select').val(state).trigger('change');
 	}
 	else if (commandName === '.uno:FontHeight') {
@@ -1091,6 +1104,7 @@ map.on('commandstatechanged', function (e) {
 				.append($('<option></option>')
 				.text(state).val(state));
 		}
+		fontsizesSelectValue = state;
 		$('.fontsizes-select').val(state).trigger('change');
 		sortFontSizes();
 	}
@@ -1233,13 +1247,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});
@@ -1250,11 +1268,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
@@ -1292,27 +1310,38 @@ 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);
 	}
-});
+}
 
 map.on('updateparts pagenumberchanged', function (e) {
 	if (e.docType === 'text') {
commit 905b077243fd3338255e40e29a99c225715db6ed
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Jan 12 15:49:57 2017 +0530

    loleaflet: Don't hide prev/next buttons for calc
    
    Primary reason we are bringing it back is because in mobile mode
    userlist icon goes to the right most edge of the screen which
    leads to userlist popup not being shown (which seems to be the
    bug in library we are using)
    
    Change-Id: Ie5b93c41f54ffeeb8615f90fa0e71c74de5ed92c

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 7065ebe..d5fb89a 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -1336,12 +1336,7 @@ map.on('updateparts pagenumberchanged', function (e) {
 		toolbar.hide('deletepage');
 	}
 
-	if (e.docType === 'spreadsheet') {
-		toolbar.hide('prev');
-		toolbar.hide('next');
-		toolbar.hide('prevnextbreak');
-	}
-	else {
+	if (e.docType !== 'spreadsheet') {
 		if (current === 0) {
 			toolbar.disable('prev');
 		}


More information about the Libreoffice-commits mailing list