[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-4' - 4 commits - loleaflet/build loleaflet/debug loleaflet/dist loleaflet/src

Mihai Varga mihai.varga at collabora.com
Mon Aug 17 00:47:40 PDT 2015


 loleaflet/build/deps.js                               |   14 ++
 loleaflet/debug/document/document_simple_example.html |    2 
 loleaflet/dist/leaflet.css                            |    3 
 loleaflet/src/control/Control.Parts.js                |   87 ------------------
 loleaflet/src/control/Control.PartsPreview.js         |   75 +++++++++++++++
 loleaflet/src/control/Control.Tabs.js                 |   67 +++++++++++++
 loleaflet/src/control/Parts.js                        |   17 ++-
 loleaflet/src/control/Search.js                       |    4 
 8 files changed, 177 insertions(+), 92 deletions(-)

New commits:
commit 16fc2583acd94f643ad8ab7d3116c306d7bdb282
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Mon Aug 17 10:45:30 2015 +0300

    loleaflet: fixed the parts preview height

diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index 477f86f..c7c43b7 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -676,10 +676,11 @@ a.leaflet-control-buttons:hover:first-child {
 .parts-preview {
 	background: #DFDFDF;
 	position: absolute;
-	top: 100px;
+	top: 65px;
 	bottom: 0px;
 	max-width: 195px;
 	overflow: hidden;
+	border-top: 2px solid #B6B6B6;
 }
 
 .preview-frame {
commit 576485557a13c7a53d0a29f3b428caaa892952ca
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Mon Aug 17 10:41:01 2015 +0300

    loleaflet: separate parts preview and tabs from the next/prev buttons

diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index 62ef933..d527e7d 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -233,6 +233,20 @@ var deps = {
 		desc: 'Parts control with two buttons (previous / next).'
 	},
 
+	ControlPartsPreview: {
+		src: ['control/Control.js',
+		      'control/Control.PartsPreview.js'],
+		heading: 'Controls',
+		desc: 'Parts preview sidebar'
+	},
+
+	ControlTabs: {
+		src: ['control/Control.js',
+		      'control/Control.Tabs.js'],
+		heading: 'Controls',
+		desc: 'Tabs for switching sheets'
+	},
+
 	ControlPermissionSwitch: {
 		src: ['control/Control.js',
 		      'control/Control.Permission.js'],
diff --git a/loleaflet/debug/document/document_simple_example.html b/loleaflet/debug/document/document_simple_example.html
index 234a2bc..9d31f45 100644
--- a/loleaflet/debug/document/document_simple_example.html
+++ b/loleaflet/debug/document/document_simple_example.html
@@ -76,6 +76,8 @@
     globalMap.addControl(L.control.statusIndicator());
     globalMap.addControl(L.control.scroll());
     globalMap.addControl(L.control.dialog());
+    globalMap.addControl(L.control.partsPreview());
+    globalMap.addControl(L.control.tabs());
 
     ////// Document layer ////
     var docLayer = new L.TileLayer('', {
diff --git a/loleaflet/src/control/Control.Parts.js b/loleaflet/src/control/Control.Parts.js
index d32650a..9fc0b16 100644
--- a/loleaflet/src/control/Control.Parts.js
+++ b/loleaflet/src/control/Control.Parts.js
@@ -20,16 +20,8 @@ L.Control.Parts = L.Control.extend({
 				partName + '-prev',  container, this._prevPart);
 		this._nextPartButton = this._createButton(options.nextPartText, options.nextPartTitle,
 				partName + '-next', container, this._nextPart);
-		this._previewInitialized = false;
-		this._previewTiles = {};
-		this._tabsInitialized = false;
-		this._spreadsheetTabs = {};
-		var docContainer = L.DomUtil.get('document-container');
-		this._partsPreviewCont = L.DomUtil.create('div', 'parts-preview', docContainer.parentElement);
-		this._tabsCont = L.DomUtil.create('div', 'spreadsheet-tab', docContainer.parentElement);
 
 		map.on('updateparts', this._updateDisabled, this);
-		map.on('tilepreview', this._updatePreview, this);
 		map.on('pagenumberchanged', this._updateDisabledText, this);
 		return container;
 	},
@@ -72,7 +64,6 @@ L.Control.Parts = L.Control.extend({
 		var parts = e.parts;
 		var currentPart = e.currentPart;
 		var docType = e.docType;
-		var partNames = e.partNames;
 		if (docType === 'text') {
 			return;
 		}
@@ -86,64 +77,8 @@ L.Control.Parts = L.Control.extend({
 		} else {
 			L.DomUtil.removeClass(this._nextPartButton, className);
 		}
-		if (!this._previewInitialized && docType === 'presentation') {
-			// make room for the preview
-			var docContainer = L.DomUtil.get('document-container');
-			L.DomUtil.setStyle(docContainer, 'left', '200px');
-			setTimeout(L.bind(function () {
-				this._map.invalidateSize();
-				$('.scroll-container').mCustomScrollbar('update');
-			}, this), 500);
-			for (var i = 0; i < parts; i++) {
-				var id = 'preview-tile' + i;
-				var frame = L.DomUtil.create('div', 'preview-frame', this._partsPreviewCont);
-				L.DomUtil.create('span', 'preview-helper', frame);
-				var img = L.DomUtil.create('img', 'preview-img', frame);
-				img.id = id;
-				this._previewTiles[id] = img;
-				L.DomEvent
-					.on(img, 'click', L.DomEvent.stopPropagation)
-					.on(img, 'click', L.DomEvent.stop)
-					.on(img, 'click', this._setPart, this)
-					.on(img, 'click', this._refocusOnMap, this);
-				this._map.getPartPreview(i, i, 180, 180);
-			}
-			this._previewInitialized = true;
-		}
-		if (docType === 'spreadsheet') {
-			if (!this._tabsInitialized) {
-				// make room for the preview
-				docContainer = L.DomUtil.get('document-container');
-				L.DomUtil.setStyle(docContainer, 'bottom', '20px');
-				setTimeout(L.bind(function () {
-					this._map.invalidateSize();
-					$('.scroll-container').mCustomScrollbar('update');
-				}, this), 500);
-				for (i = 0; i < parts; i++) {
-					id = 'spreadsheet-tab' + i;
-					var tab = L.DomUtil.create('li', '', this._tabsCont);
-					tab.innerHTML = partNames[i];
-					tab.id = id;
-					L.DomEvent
-						.on(tab, 'click', L.DomEvent.stopPropagation)
-						.on(tab, 'click', L.DomEvent.stop)
-						.on(tab, 'click', this._setPart, this)
-						.on(tab, 'click', this._refocusOnMap, this);
-					this._spreadsheetTabs[id] = tab;
-				}
-				this._tabsInitialized = true;
-			}
-			for (var key in this._spreadsheetTabs) {
-				var part =  parseInt(key.match(/\d+/g)[0]);
-				L.DomUtil.removeClass(this._spreadsheetTabs[key], 'selected');
-				if (part === currentPart) {
-					L.DomUtil.addClass(this._spreadsheetTabs[key], 'selected');
-				}
-			}
-		}
 	},
 
-
 	_updateDisabledText: function (e) {
 		if (e) {
 			this._currentPage = e.currentPage;
@@ -161,28 +96,6 @@ L.Control.Parts = L.Control.extend({
 		} else {
 			L.DomUtil.removeClass(this._nextPartButton, className);
 		}
-	},
-
-	_setPart: function (e) {
-		var part =  e.target.id.match(/\d+/g)[0];
-		if (part !== null) {
-			this._map.setPart(parseInt(part));
-		}
-	},
-
-	_updatePreview: function (e) {
-		var id = 'preview-tile' + e.id;
-		// the scrollbar has to be re-initialized here else it doesn't work
-		// probably a bug from the scrollbar
-		this._previewTiles[id].onload = function () {
-			$('.parts-preview').mCustomScrollbar({
-				axis: 'y',
-				theme: 'dark-thick',
-				scrollInertia: 0,
-				alwaysShowScrollbar: 1});
-		};
-
-		this._previewTiles[id].src = e.tile;
 	}
 });
 
diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
new file mode 100644
index 0000000..4556111
--- /dev/null
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -0,0 +1,75 @@
+/*
+ * L.Control.PartsPreview
+ */
+
+L.Control.PartsPreview = L.Control.extend({
+	onAdd: function (map) {
+		this._previewInitialized = false;
+		this._previewTiles = {};
+		var docContainer = L.DomUtil.get('document-container');
+		this._partsPreviewCont = L.DomUtil.create('div', 'parts-preview', docContainer.parentElement);
+
+		map.on('updateparts', this._updateDisabled, this);
+		map.on('tilepreview', this._updatePreview, this);
+		return document.createElement('div');
+	},
+
+	_updateDisabled: function (e) {
+		var parts = e.parts;
+		var docType = e.docType;
+		if (docType === 'text') {
+			return;
+		}
+
+		if (!this._previewInitialized && docType === 'presentation') {
+			// make room for the preview
+			var docContainer = L.DomUtil.get('document-container');
+			L.DomUtil.setStyle(docContainer, 'left', '200px');
+			setTimeout(L.bind(function () {
+				this._map.invalidateSize();
+				$('.scroll-container').mCustomScrollbar('update');
+			}, this), 500);
+			for (var i = 0; i < parts; i++) {
+				var id = 'preview-tile' + i;
+				var frame = L.DomUtil.create('div', 'preview-frame', this._partsPreviewCont);
+				L.DomUtil.create('span', 'preview-helper', frame);
+				var img = L.DomUtil.create('img', 'preview-img', frame);
+				img.id = id;
+				this._previewTiles[id] = img;
+				L.DomEvent
+					.on(img, 'click', L.DomEvent.stopPropagation)
+					.on(img, 'click', L.DomEvent.stop)
+					.on(img, 'click', this._setPart, this)
+					.on(img, 'click', this._refocusOnMap, this);
+				this._map.getPartPreview(i, i, 180, 180);
+			}
+			this._previewInitialized = true;
+		}
+	},
+
+	_setPart: function (e) {
+		var part =  e.target.id.match(/\d+/g)[0];
+		if (part !== null) {
+			this._map.setPart(parseInt(part));
+		}
+	},
+
+	_updatePreview: function (e) {
+		var id = 'preview-tile' + e.id;
+		// the scrollbar has to be re-initialized here else it doesn't work
+		// probably a bug from the scrollbar
+		this._previewTiles[id].onload = function () {
+			$('.parts-preview').mCustomScrollbar({
+				axis: 'y',
+				theme: 'dark-thick',
+				scrollInertia: 0,
+				alwaysShowScrollbar: 1});
+		};
+
+		this._previewTiles[id].src = e.tile;
+	}
+});
+
+L.control.partsPreview = function (options) {
+	return new L.Control.PartsPreview(options);
+};
diff --git a/loleaflet/src/control/Control.Tabs.js b/loleaflet/src/control/Control.Tabs.js
new file mode 100644
index 0000000..cce0de9
--- /dev/null
+++ b/loleaflet/src/control/Control.Tabs.js
@@ -0,0 +1,67 @@
+/*
+ * L.Control.Tabs is used to swtich sheets in Calc
+ */
+
+L.Control.Tabs = L.Control.extend({
+	onAdd: function (map) {
+		this._tabsInitialized = false;
+		this._spreadsheetTabs = {};
+		var docContainer = L.DomUtil.get('document-container');
+		this._tabsCont = L.DomUtil.create('div', 'spreadsheet-tab', docContainer.parentElement);
+
+		map.on('updateparts', this._updateDisabled, this);
+		return document.createElement('div');
+	},
+
+	_updateDisabled: function (e) {
+		var parts = e.parts;
+		var currentPart = e.currentPart;
+		var docType = e.docType;
+		var partNames = e.partNames;
+		if (docType === 'text') {
+			return;
+		}
+		if (docType === 'spreadsheet') {
+			if (!this._tabsInitialized) {
+				// make room for the preview
+				var docContainer = L.DomUtil.get('document-container');
+				L.DomUtil.setStyle(docContainer, 'bottom', '20px');
+				setTimeout(L.bind(function () {
+					this._map.invalidateSize();
+					$('.scroll-container').mCustomScrollbar('update');
+				}, this), 500);
+				for (var i = 0; i < parts; i++) {
+					var id = 'spreadsheet-tab' + i;
+					var tab = L.DomUtil.create('li', '', this._tabsCont);
+					tab.innerHTML = partNames[i];
+					tab.id = id;
+					L.DomEvent
+						.on(tab, 'click', L.DomEvent.stopPropagation)
+						.on(tab, 'click', L.DomEvent.stop)
+						.on(tab, 'click', this._setPart, this)
+						.on(tab, 'click', this._refocusOnMap, this);
+					this._spreadsheetTabs[id] = tab;
+				}
+				this._tabsInitialized = true;
+			}
+			for (var key in this._spreadsheetTabs) {
+				var part =  parseInt(key.match(/\d+/g)[0]);
+				L.DomUtil.removeClass(this._spreadsheetTabs[key], 'selected');
+				if (part === currentPart) {
+					L.DomUtil.addClass(this._spreadsheetTabs[key], 'selected');
+				}
+			}
+		}
+	},
+
+	_setPart: function (e) {
+		var part =  e.target.id.match(/\d+/g)[0];
+		if (part !== null) {
+			this._map.setPart(parseInt(part));
+		}
+	}
+});
+
+L.control.tabs = function (options) {
+	return new L.Control.Tabs(options);
+};
commit ccafeb755dae2607e19dfe302e145328b1150cbf
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Sat Aug 15 12:32:17 2015 +0300

    lolealfet: map.resetSelection method

diff --git a/loleaflet/src/control/Search.js b/loleaflet/src/control/Search.js
index 1526e99..174f08b 100644
--- a/loleaflet/src/control/Search.js
+++ b/loleaflet/src/control/Search.js
@@ -30,5 +30,9 @@ L.Map.include({
 		searchCmd['SearchItem.SearchStartPointY'].type = 'long';
 		searchCmd['SearchItem.SearchStartPointY'].value = topLeftTwips.y;
 		this._docLayer.sendMessage('uno .uno:ExecuteSearch ' + JSON.stringify(searchCmd));
+	},
+
+	resetSelection: function () {
+		this._docLayer.sendMessage('resetselection');
 	}
 });
commit 8422525c6f183dc12a063d03e5b648751986758e
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Aug 14 15:32:25 2015 +0300

    loleaflet: goToPage accepts 'next' and 'prev'

diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index f465f2c..78c998d 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -81,11 +81,20 @@ L.Map.include({
 
 	goToPage: function (page) {
 		var docLayer = this._docLayer;
-		if (page < 0 || page >= docLayer._pages) {
-			return;
+		if (page === 'prev') {
+			if (docLayer._currentPage > 0) {
+				docLayer._currentPage -= 1;
+			}
+		}
+		else if (page === 'next') {
+			if (docLayer._currentPage < docLayer._pages - 1) {
+				docLayer._currentPage += 1;
+			}
+		}
+		else if (typeof (page) === 'number' && page >= 0 && page < docLayer._pages) {
+			docLayer._currentPage = page;
 		}
-		docLayer._currentPage = page;
-		docLayer.sendMessage('setpage page=' + page);
+		docLayer.sendMessage('setpage page=' + docLayer._currentPage);
 	},
 
 	getNumberOfPages: function () {


More information about the Libreoffice-commits mailing list