[Libreoffice-commits] online.git: loleaflet/dist loleaflet/src
Pranav Kant
pranavk at collabora.com
Fri Mar 18 15:45:36 UTC 2016
loleaflet/dist/spreadsheet.css | 25 +++++++++++++
loleaflet/src/control/Control.ColumnHeader.js | 47 +++++++++++++++++++++++++-
loleaflet/src/control/Control.RowHeader.js | 28 +++++++++++++++
3 files changed, 99 insertions(+), 1 deletion(-)
New commits:
commit b881e986d803f51b187212c09e43da65e7351634
Author: Pranav Kant <pranavk at collabora.com>
Date: Fri Mar 11 20:16:15 2016 +0530
loleaflet: Column and row headers are selectable now
... with multi-select shift and ctrl key behavior like desktop
calc version.
Change-Id: I574037f984ee1844773b0fb8c90c5bb1c079188b
diff --git a/loleaflet/dist/spreadsheet.css b/loleaflet/dist/spreadsheet.css
index 665c7fe..1ccfb1e 100644
--- a/loleaflet/dist/spreadsheet.css
+++ b/loleaflet/dist/spreadsheet.css
@@ -50,6 +50,7 @@
border-right: 1px solid darkgrey;
border-bottom: 1px solid darkgrey;
background-color: lightgrey;
+ cursor: pointer;
position: absolute;
padding: 0px;
@@ -98,6 +99,18 @@
padding: 0px;
margin: 0px;
height: 100%;
+ cursor: pointer;
+
+ /* Make the text unselectable for all browsers */
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ }
+
+.spreadsheet-header-column:hover {
+ background-color: #DDD;
}
.spreadsheet-header-rows-container {
@@ -134,4 +147,16 @@
padding: 0px;
margin: 0px;
height: 100%;
+ cursor: pointer;
+
+ /* Make the text unselectable for all browsers */
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ }
+
+.spreadsheet-header-row:hover {
+ background-color: #DDD;
}
diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index 0091893..9a0cd16 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -2,6 +2,7 @@
* Control.ColumnHeader
*/
+/* global $ */
L.Control.ColumnHeader = L.Control.extend({
onAdd: function (map) {
map.on('updatepermission', this._onUpdatePermission, this);
@@ -15,7 +16,8 @@ L.Control.ColumnHeader = L.Control.extend({
this._map.on('updateviewport', this.setViewPort, this);
this._map.on('viewrowcolumnheaders', this.viewRowColumnHeaders, this);
var docContainer = this._map.options.documentContainer;
- L.DomUtil.create('div', 'spreadsheet-header-corner', docContainer.parentElement);
+ var cornerHeader = L.DomUtil.create('div', 'spreadsheet-header-corner', docContainer.parentElement);
+ L.DomEvent.addListener(cornerHeader, 'click', this._onCornerHeaderClick, this);
var headersContainer = L.DomUtil.create('div', 'spreadsheet-header-columns-container', docContainer.parentElement);
this._columns = L.DomUtil.create('div', 'spreadsheet-header-columns', headersContainer);
@@ -71,7 +73,50 @@ L.Control.ColumnHeader = L.Control.extend({
else {
L.DomUtil.setStyle(text, 'width', width);
}
+
+ L.DomEvent.addListener(text, 'click', this._onColumnHeaderClick, this);
+ }
+ },
+
+ _colAlphaToNumber: function(alpha) {
+ var res = 0;
+ var offset = 'A'.charCodeAt();
+ for (var i = 0; i < alpha.length; i++) {
+ var chr = alpha[alpha.length - i - 1];
+ res += (chr.charCodeAt() - offset + 1) * Math.pow(26, i);
}
+
+ return res;
+ },
+
+ _onColumnHeaderClick: function (e) {
+ var colAlpha = e.target.getAttribute('rel').split('spreadsheet-column-')[1];
+ var colNumber = this._colAlphaToNumber(colAlpha);
+
+ var modifier = 0;
+ if (e.shiftKey) {
+ modifier += this._map.keyboard.keyModifier.shift;
+ }
+ if (e.ctrlKey) {
+ modifier += this._map.keyboard.keyModifier.ctrl;
+ }
+
+ var command = {
+ Col: {
+ type: 'unsigned short',
+ value: parseInt(colNumber - 1)
+ },
+ Modifier: {
+ type: 'unsigned short',
+ value: modifier
+ }
+ };
+
+ this._map.sendUnoCommand('.uno:SelectColumn ', command);
+ },
+
+ _onCornerHeaderClick: function() {
+ this._map.sendUnoCommand('.uno:SelectAll');
},
_onUpdatePermission: function () {
diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index b7a8e72..fff931a 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -2,6 +2,7 @@
* L.Control.RowHeader
*/
+/* global $ */
L.Control.RowHeader = L.Control.extend({
onAdd: function (map) {
map.on('updatepermission', this._onUpdatePermission, this);
@@ -70,7 +71,34 @@ L.Control.RowHeader = L.Control.extend({
L.DomUtil.setStyle(text, 'line-height', height);
L.DomUtil.setStyle(text, 'height', height);
}
+
+ L.DomEvent.addListener(text, 'click', this._onRowHeaderClick, this);
+ }
+ },
+
+ _onRowHeaderClick: function (e) {
+ var row = e.target.getAttribute('rel').split('spreadsheet-row-')[1];
+
+ var modifier = 0;
+ if (e.shiftKey) {
+ modifier += this._map.keyboard.keyModifier.shift;
}
+ if (e.ctrlKey) {
+ modifier += this._map.keyboard.keyModifier.ctrl;
+ }
+
+ var command = {
+ Row: {
+ type: 'long',
+ value: parseInt(row - 1)
+ },
+ Modifier: {
+ type: 'unsigned short',
+ value: modifier
+ }
+ };
+
+ this._map.sendUnoCommand('.uno:SelectRow ', command);
},
_onUpdatePermission: function () {
More information about the Libreoffice-commits
mailing list