[Libreoffice-commits] online.git: loleaflet/dist loleaflet/src
Pranav Kant
pranavk at collabora.co.uk
Sun Sep 25 18:08:01 UTC 2016
loleaflet/dist/toolbar.css | 16 +++++++++
loleaflet/dist/toolbar/toolbar.js | 57 +++++++++++++++++++---------------
loleaflet/src/layer/tile/TileLayer.js | 10 -----
3 files changed, 48 insertions(+), 35 deletions(-)
New commits:
commit 5891371dcacf04182827317482df6b92700aabbd
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Sun Sep 25 22:47:59 2016 +0530
loleaflet: Show usercolor in userlist
Change-Id: I6be05f36ffc4c00aa986b3873fce1bc5acc6fbf0
diff --git a/loleaflet/dist/toolbar.css b/loleaflet/dist/toolbar.css
index aef6e23..d607b39 100644
--- a/loleaflet/dist/toolbar.css
+++ b/loleaflet/dist/toolbar.css
@@ -306,3 +306,19 @@ button.leaflet-control-search-next
border: 0px;
background: rgba(66, 151, 215, 1);
}
+
+tr.useritem:hover {
+ cursor: default;
+ background-color: rgba(67, 172, 232, 0.25);
+}
+
+tr.useritem > td {
+ padding: 7px;
+}
+
+tr.useritem > td.usercolor {
+ display: inline-block;
+ top: 5px;
+ left: 3px;
+ position: relative;
+}
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 2e282e9..b7a02a4 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -461,9 +461,7 @@ $(function () {
{type: 'html', id: 'right'},
{type: 'html', id: 'modifiedstatuslabel', html: '<div id="modifiedstatuslabel" class="loleaflet-font"></div>'},
{type: 'break'},
- {type: 'menu', id: 'userlist', caption: _('1 user'), items: [
- { id: '-1', text: _('You'), disabled: true },
- ]},
+ {type: 'drop', id: 'userlist', text: _('No users'), html: '<div id="userlist_container"><table id="userlist_table"><tbody></tbody></table></div>' },
{type: 'break'},
{type: 'button', id: 'prev', img: 'prev', hint: _('Previous page')},
{type: 'button', id: 'next', img: 'next', hint: _('Next page')},
@@ -474,6 +472,9 @@ $(function () {
{type: 'button', id: 'zoomin', img: 'zoomin', hint: _('Zoom in')}
],
onClick: function (e) {
+ if (e.item.id === 'userlist') {
+ return;
+ }
onClick(e.target, e.item, e.subItem);
}
});
@@ -1307,18 +1308,26 @@ map.on('statusindicator', function (e) {
}
});
-function getUserListItem(viewId, userName) {
- var userListItem = { id: viewId, text: userName, disabled: true };
- return userListItem;
+function getUserItem(viewId, userName, color) {
+ var html = '<tr class="useritem" id="user-' + viewId + '">' +
+ '<td class=usercolor style="background-color: ' + color +';"></td>' +
+ '<td class="username">' + userName + '</td>' +
+ '</tr>';
+ return html;
}
var nUsers = _('%n users');
-function updateUserListCount(userlist) {
- var count = userlist.items.length;
+function updateUserListCount() {
+ var userlistItem = w2ui['toolbar-down'].get('userlist');
+ var count = $(userlistItem.html).find('#userlist_table tbody tr').length;
if (count > 1) {
- userlist.caption = nUsers.replace('%n', count);
+ userlistItem.text = nUsers.replace('%n', count);
} else if (count === 1) {
- userlist.caption = _('1 user');
+ userlistItem.text = _('1 user');
+ } else {
+ userlistItem.text = _('No users');
}
+
+ w2ui['toolbar-down'].refresh();
}
map.on('addview', function(e) {
@@ -1335,11 +1344,16 @@ map.on('addview', function(e) {
userPopupTimeout = null;
}, 3000);
- var userlist = w2ui['toolbar-down'].get('userlist');
- userlist.items.push(getUserListItem(e.viewId, e.username));
-
- updateUserListCount(userlist);
- w2ui['toolbar-down'].refresh();
+ var username = e.username;
+ var color = L.LOUtil.getViewIdHexColor(e.viewId);
+ if (e.viewId === map._docLayer._viewId) {
+ username = _('You');
+ color = '#000';
+ }
+ var userlistItem = w2ui['toolbar-down'].get('userlist');
+ var newhtml = $(userlistItem.html).find('#userlist_table tbody').append(getUserItem(e.viewId, username, color)).parent().parent()[0].outerHTML;
+ userlistItem.html = newhtml;
+ updateUserListCount();
});
map.on('removeview', function(e) {
@@ -1356,16 +1370,9 @@ map.on('removeview', function(e) {
userPopupTimeout = null;
}, 3000);
- var userlist = w2ui['toolbar-down'].get('userlist');
- for (var idx in userlist.items) {
- if (userlist.items[idx].id == e.viewId) {
- userlist.items.splice(idx, 1);
- break;
- }
- }
-
- updateUserListCount(userlist);
- w2ui['toolbar-down'].refresh();
+ var userlistItem = w2ui['toolbar-down'].get('userlist');
+ userlistItem.html = $(userlistItem.html).find('#user-' + e.viewId).remove().end()[0].outerHTML;
+ updateUserListCount();
});
$(window).resize(function() {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 047a40d..df48df7 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -697,11 +697,6 @@ L.TileLayer = L.GridLayer.extend({
},
_addView: function(viewId, username) {
- // Ignore if viewid is same as ours
- if (viewId === this._viewId) {
- return;
- }
-
this._map.addView(viewId, username);
//TODO: We can initialize color and other properties here.
@@ -713,11 +708,6 @@ L.TileLayer = L.GridLayer.extend({
},
_removeView: function(viewId) {
- // Couldn't be ours, now could it?!
- if (viewId === this._viewId) {
- return;
- }
-
// Remove selection, if any.
if (this._viewSelections[viewId] && this._viewSelections[viewId].selection) {
this._viewLayerGroup.removeLayer(this._viewSelections[viewId].selection);
More information about the Libreoffice-commits
mailing list