From 3d02fb74975d967e0b59496d2b25afbe3c9256b8 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Thu, 5 May 2016 14:26:40 +0530 Subject: [PATCH] loleaflet: Enable/disable spreadsheet tabs for edit/view mode Change-Id: I084f676e77fc161c109a5271dd1cad60a3e5474f --- loleaflet/dist/spreadsheet.css | 8 +++++++- loleaflet/src/control/Control.Tabs.js | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/loleaflet/dist/spreadsheet.css b/loleaflet/dist/spreadsheet.css index aabd15e6a..774a366c4 100644 --- a/loleaflet/dist/spreadsheet.css +++ b/loleaflet/dist/spreadsheet.css @@ -41,16 +41,22 @@ display: inline-block; border: 1px solid darkgrey; background-color: lightgrey; + color: black; } .spreadsheet-context-menu-selected { - background: white; + background: white !important; + color: black !important; border-top: 1px solid lightgrey; border-left: 1px solid lightgrey; border-right: 1px solid lightgrey; border-bottom: 1px solid lightgrey; } +.spreadsheet-context-menu.context-menu-disabled { + color: grey; + } + .spreadsheet-header-corner { border-top: 1px solid darkgrey; border-left: 1px solid darkgrey; diff --git a/loleaflet/src/control/Control.Tabs.js b/loleaflet/src/control/Control.Tabs.js index 499108368..8cd3be889 100644 --- a/loleaflet/src/control/Control.Tabs.js +++ b/loleaflet/src/control/Control.Tabs.js @@ -67,6 +67,15 @@ L.Control.Tabs = L.Control.extend({ }); map.on('updateparts', this._updateDisabled, this); + map.on('editlock', this._enableTabsContextMenu, this); + }, + + _enableTabsContextMenu: function(e) { + if (!e.value) { + $('.spreadsheet-context-menu').contextMenu(false); + } else { + $('.spreadsheet-context-menu').contextMenu(true); + } }, _updateDisabled: function (e) { @@ -115,11 +124,19 @@ L.Control.Tabs = L.Control.extend({ if (part === selectedPart) { L.DomUtil.addClass(this._spreadsheetTabs[key], 'spreadsheet-context-menu-selected'); } + + if (map._editlock) { + L.DomUtil.removeClass(this._spreadsheetTabs[key], 'context-menu-disabled'); + } else { + L.DomUtil.addClass(this._spreadsheetTabs[key], 'context-menu-disabled'); + } } } }, _setPart: function (e) { + if (!map._editlock) + return; var part = e.target.id.match(/\d+/g)[0]; if (part !== null) { this._map.setPart(parseInt(part));