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

Mihai Varga mihai.varga at collabora.com
Mon Jul 13 06:01:40 PDT 2015


 loleaflet/src/control/Control.Selection.js |   49 +++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

New commits:
commit f6a9a8ce0435927bf4dc6f2001675870829eb275
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Mon Jul 13 16:01:18 2015 +0300

    loleaflet: selection control for viewing modes

diff --git a/loleaflet/src/control/Control.Selection.js b/loleaflet/src/control/Control.Selection.js
new file mode 100644
index 0000000..abe3237
--- /dev/null
+++ b/loleaflet/src/control/Control.Selection.js
@@ -0,0 +1,49 @@
+/*
+ * L.Control.Selection enables by mouse drag selection in viewing mode
+ */
+
+L.Control.Selection = L.Control.extend({
+	options: {
+		position: 'topleft'
+	},
+
+	onAdd: function (map) {
+		var partName = 'leaflet-control-editviewswitch',
+			container = L.DomUtil.create('label', partName + ' leaflet-bar');
+
+		this._checkBox = L.DomUtil.create('input', 'editview-cb', container);
+		this._checkBox.type = 'checkbox';
+		L.DomEvent.on(this._checkBox, 'change', this._onChange, this);
+		map.on('updatepermission', this._onUpdatePermission, this);
+		container.appendChild(document.createTextNode('Enable Selection'));
+		return container;
+	},
+
+	_onChange: function () {
+		if (this._checkBox.checked) {
+			this._map.enableSelection();
+		}
+		else {
+			this._map.disableSelection();
+		}
+	},
+
+	_onUpdatePermission: function (e) {
+		if (e.perm === 'edit') {
+			this._checkBox.checked = false;
+			this._checkBox.disabled = true;
+		}
+		else if (e.perm === 'view') {
+			this._checkBox.checked = false;
+			this._checkBox.disabled = false;
+		}
+		else if (e.perm === 'readonly') {
+			this._checkBox.checked = false;
+			this._checkBox.disabled = false;
+		}
+	}
+});
+
+L.control.selection = function (options) {
+	return new L.Control.Selection(options);
+};


More information about the Libreoffice-commits mailing list