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

Henry Castro hcastro at collabora.com
Sun Aug 21 20:08:01 UTC 2016


 loleaflet/build/deps.js                       |    7 ++
 loleaflet/dist/leaflet.css                    |    3 
 loleaflet/src/control/Control.ColumnHeader.js |   22 ++++++
 loleaflet/src/control/Control.MetricInput.js  |   89 ++++++++++++++++++++++++++
 loleaflet/src/control/Control.RowHeader.js    |   22 ++++++
 loleaflet/src/control/Control.Scroll.js       |    4 +
 loleaflet/src/control/Control.js              |    1 
 loleaflet/src/map/Map.js                      |   13 +++
 8 files changed, 158 insertions(+), 3 deletions(-)

New commits:
commit 23a71ac35bb889771b6b55ae2debd9ee0b33c113
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Aug 21 16:07:01 2016 -0400

    loleaflet: add L.Control.MetricInput

diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index 284aca3..1425ed1 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -281,6 +281,13 @@ var deps = {
 		desc: 'Row Header bar'
 	},
 
+	ControlMetricInput: {
+		src: ['control/Control.js',
+		      'control/Control.MetricInput.js'],
+		heading: 'Controls',
+		desc: 'Metric Input'
+	},
+
 	ControlContextmenu: {
 		src: ['control/Control.js',
 		      'control/Control.ContextMenu.js'],
diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index eeeb24c..5b0c8f1 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -111,6 +111,9 @@
 .leaflet-top {
 	top: 0;
 	}
+.leaflet-middle {
+	left: 50%;
+	}
 .leaflet-right {
 	right: 0;
 	}
diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index 88a5b9f..74949ab 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -31,7 +31,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({
 
 		var colHeaderObj = this;
 		$.contextMenu({
-			selector: '.spreadsheet-header-column',
+			selector: '.spreadsheet-header-column-text',
 			className: 'loleaflet-font',
 			items: {
 				'insertcolbefore': {
@@ -47,12 +47,28 @@ L.Control.ColumnHeader = L.Control.Header.extend({
 						var colAlpha = options.$trigger.attr('rel').split('spreadsheet-column-')[1];
 						colHeaderObj.deleteColumn.call(colHeaderObj, colAlpha);
 					}
+				},
+				'optimalwidth': {
+					name: _('Optimal Width'),
+					callback: function(key, options) {
+						var colAlpha = options.$trigger.attr('rel').split('spreadsheet-column-')[1];
+						colHeaderObj.optimalWidth.call(colHeaderObj, colAlpha);
+					}
 				}
 			},
 			zIndex: 10
 		});
 	},
 
+	optimalWidth: function(colAlpha) {
+		if (!this._dialog) {
+			this._dialog = L.control.metricInput(this._onDialogResult, this, {title: _('Optimal Column Width')});
+		}
+		this._dialog.addTo(this._map);
+		this._map.enable(false);
+		this._dialog.update();
+	},
+
 	insertColumn: function(colAlpha) {
 		// First select the corresponding column because
 		// .uno:InsertColumn doesn't accept any column number
@@ -177,6 +193,10 @@ L.Control.ColumnHeader = L.Control.Header.extend({
 		this._map.sendUnoCommand('.uno:SelectAll');
 	},
 
+	_onDialogResult: function (e) {
+		this._map.enable(true);
+	},
+
 	_getVertLatLng: function (start, offset, e) {
 		var limit = this._map.mouseEventToContainerPoint({clientX: start.x, clientY: start.y});
 		var drag = this._map.mouseEventToContainerPoint(e);
diff --git a/loleaflet/src/control/Control.MetricInput.js b/loleaflet/src/control/Control.MetricInput.js
new file mode 100644
index 0000000..88d3f69
--- /dev/null
+++ b/loleaflet/src/control/Control.MetricInput.js
@@ -0,0 +1,89 @@
+/*
+ * L.Control.MetricInput.
+ */
+
+L.Control.MetricInput = L.Control.extend({
+	options: {
+		position: 'topmiddle',
+		title: ''
+	},
+
+	initialize: function (callback, context, options) {
+		L.setOptions(this, options);
+
+		this._callback = callback;
+		this._context = context;
+	},
+
+	onAdd: function (map) {
+		this._initLayout();
+
+		return this._container;
+	},
+
+	_initLayout: function () {
+		var className = 'leaflet-control-layers',
+		container = this._container = L.DomUtil.create('div', className);
+		container.style.visibility = 'hidden';
+
+		var closeButton = L.DomUtil.create('a', 'leaflet-popup-close-button', container);
+		closeButton.href = '#close';
+		closeButton.innerHTML = '×';
+		L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this);
+
+		var wrapper = L.DomUtil.create('div', 'leaflet-popup-content-wrapper', container);
+		var content = L.DomUtil.create('div', 'leaflet-popup-content', wrapper);
+		var labelTitle = document.createElement('span');
+		labelTitle.innerHTML = '<b>' + this.options.title + '</b>';
+		content.appendChild(labelTitle);
+		content.appendChild(document.createElement('br'));
+		content.appendChild(document.createElement('br'));
+
+		var labelAdd = document.createElement('span');
+		labelAdd.innerHTML = _('Add: ');
+		content.appendChild(labelAdd);
+
+		var inputMetric = document.createElement('input');
+		inputMetric.type = 'text';
+		content.appendChild(inputMetric);
+		content.appendChild(document.createElement('br'));
+		content.appendChild(document.createElement('br'));
+
+		var inputValue = document.createElement('input');
+		inputValue.type = 'checkbox';
+		inputValue.checked = true;
+		content.appendChild(inputValue);
+
+		var labelValue = document.createElement('span');
+		labelValue.innerHTML = _('Default value');
+		content.appendChild(labelValue);
+		content.appendChild(document.createElement('br'));
+		content.appendChild(document.createElement('br'));
+
+		var inputButton = document.createElement('input');
+		inputButton.type = 'button';
+		inputButton.value = _('OK');
+		L.DomEvent.on(inputButton, 'click', this._onOKButtonClick, this);
+
+		content.appendChild(inputButton);
+	},
+
+	update: function () {
+		this._container.style.marginLeft = (-this._container.offsetWidth / 2) + 'px';
+		this._container.style.visibility = '';
+	},
+
+	_onOKButtonClick: function (e) {
+		this.remove();
+		this._callback.call(this._context, {type: 'ok', data: 0});
+	},
+
+	_onCloseButtonClick: function (e) {
+		this.remove();
+		this._callback.call(this._context, {type : 'cancel'});
+	}
+});
+
+L.control.metricInput = function (callback, context, options) {
+	return new L.Control.MetricInput(callback, context, options);
+};
diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index 53bc3a5..c88cf6b 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -29,7 +29,7 @@ L.Control.RowHeader = L.Control.Header.extend({
 
 		var rowHeaderObj = this;
 		$.contextMenu({
-			selector: '.spreadsheet-header-row',
+			selector: '.spreadsheet-header-row-text',
 			className: 'loleaflet-font',
 			items: {
 				'insertrowabove': {
@@ -45,12 +45,28 @@ L.Control.RowHeader = L.Control.Header.extend({
 						var row = parseInt(options.$trigger.attr('rel').split('spreadsheet-row-')[1]);
 						rowHeaderObj.deleteRow.call(rowHeaderObj, row);
 					}
+				},
+				'optimalheight': {
+					name: _('Optimal Height'),
+					callback: function(key, options) {
+						var row = parseInt(options.$trigger.attr('rel').split('spreadsheet-row-')[1]);
+						rowHeaderObj.optimalHeight.call(rowHeaderObj, row);
+					}
 				}
 			},
 			zIndex: 10
 		});
 	},
 
+	optimalHeight: function(row) {
+		if (!this._dialog) {
+			this._dialog = L.control.metricInput(this._onDialogResult, this, {title: _('Optimal Row Height')});
+		}
+		this._dialog.addTo(this._map);
+		this._map.enable(false);
+		this._dialog.update();
+	},
+
 	insertRow: function(row) {
 		// First select the corresponding row because
 		// .uno:InsertRows doesn't accept any row number
@@ -159,6 +175,10 @@ L.Control.RowHeader = L.Control.Header.extend({
 		this._selectRow(row, modifier);
 	},
 
+	_onDialogResult: function (e) {
+		this._map.enable(true);
+	},
+
 	_getHorzLatLng: function (start, offset, e) {
 		var limit = this._map.mouseEventToContainerPoint({clientX: start.x, clientY: start.y});
 		var drag = this._map.mouseEventToContainerPoint(e);
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index b5e6b1b..3131440 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -35,6 +35,10 @@ L.Control.Scroll = L.Control.extend({
 	},
 
 	_onScroll: function (e) {
+		if (!this._map._enabled) {
+			return;
+		}
+
 		if (this._ignoreScroll) {
 			this._ignoreScroll = null;
 			return;
diff --git a/loleaflet/src/control/Control.js b/loleaflet/src/control/Control.js
index aa7f9c1..ba46995 100644
--- a/loleaflet/src/control/Control.js
+++ b/loleaflet/src/control/Control.js
@@ -125,6 +125,7 @@ L.Map.include({
 		}
 
 		createCorner('top', 'left');
+		createCorner('top', 'middle');
 		createCorner('top', 'right');
 		createCorner('bottom', 'left');
 		createCorner('bottom', 'right');
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 3d9346f..ba2fe3c 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -65,6 +65,7 @@ L.Map = L.Evented.extend({
 		this._sizeChanged = true;
 		this._bDisableKeyboard = false;
 		this._active = true;
+		this._enabled = true;
 
 		vex.dialogID = -1;
 
@@ -829,7 +830,7 @@ L.Map = L.Evented.extend({
 	},
 
 	_handleDOMEvent: function (e) {
-		if (!this._loaded || L.DomEvent._skipped(e)) { return; }
+		if (!this._loaded || !this._enabled || L.DomEvent._skipped(e)) { return; }
 
 		// find the layer the event is propagating from
 		var target = this._targets[L.stamp(e.target || e.srcElement)],
@@ -1000,6 +1001,16 @@ L.Map = L.Evented.extend({
 		    max = this.getMaxZoom();
 
 		return Math.max(min, Math.min(max, zoom));
+	},
+
+	enable: function(enabled) {
+		this._enabled = enabled;
+		if (this._enabled) {
+			$('.scroll-container').mCustomScrollbar('update');
+		}
+		else {
+			$('.scroll-container').mCustomScrollbar('disable');
+		}
 	}
 });
 


More information about the Libreoffice-commits mailing list