[Libreoffice-commits] online.git: loleaflet/src
Pranav Kant
pranavk at collabora.com
Thu Feb 18 16:05:39 UTC 2016
loleaflet/src/layer/tile/GridLayer.js | 24 +++++++++++++-----------
loleaflet/src/layer/tile/TileLayer.js | 19 +++++++++++--------
loleaflet/src/map/Map.js | 7 ++++---
3 files changed, 28 insertions(+), 22 deletions(-)
New commits:
commit f8b104b88c4217124c275dc7b9c5d6457232d8b4
Author: Pranav Kant <pranavk at collabora.com>
Date: Thu Feb 18 21:28:58 2016 +0530
loleaflet: Silence ESLint errors
Moral - Run 'jake lint' before committing your code.
Change-Id: I401567360dfdfb16e99dafc3171ac158a90605e4
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 2b4c0d7..4a6ab4d 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -563,7 +563,7 @@ L.GridLayer = L.Layer.extend({
if (!map || this._documentInfo === '') {
return;
}
-
+ var key, coords, tile;
var center = map.getCenter();
var zoom = Math.round(map.getZoom());
@@ -571,7 +571,7 @@ L.GridLayer = L.Layer.extend({
tileRange = this._pxBoundsToTileRange(pixelBounds),
queue = [];
- for (var key in this._tiles) {
+ for (key in this._tiles) {
if (this._keyToTileCoords(key).z !== zoom ||
this._keyToTileCoords(key).part !== this._selectedPart) {
this._tiles[key].current = false;
@@ -583,14 +583,14 @@ L.GridLayer = L.Layer.extend({
// create a queue of coordinates to load tiles from
for (var j = tileRange.min.y; j <= tileRange.max.y; j++) {
for (var i = tileRange.min.x; i <= tileRange.max.x; i++) {
- var coords = new L.Point(i, j);
+ coords = new L.Point(i, j);
coords.z = zoom;
coords.part = this._selectedPart;
if (!this._isValidTile(coords)) { continue; }
key = this._tileCoordsToKey(coords);
- var tile = this._tiles[key];
+ tile = this._tiles[key];
if (tile) {
tile.current = true;
newView = false;
@@ -606,7 +606,7 @@ L.GridLayer = L.Layer.extend({
// so we're able to cancel the previous requests that are being processed
this._map._socket.sendMessage('canceltiles');
for (key in this._tiles) {
- var tile = this._tiles[key];
+ tile = this._tiles[key];
if (!tile.loaded) {
L.DomUtil.remove(tile.el);
delete this._tiles[key];
@@ -626,12 +626,12 @@ L.GridLayer = L.Layer.extend({
var tilePositionsY = '';
for (i = 0; i < queue.length; i++) {
- var coords = queue[i];
- var tilePos = this._getTilePos(coords),
+ coords = queue[i];
+ var tilePos = this._getTilePos(coords);
key = this._tileCoordsToKey(coords);
if (coords.part === this._selectedPart) {
- var tile = this.createTile(this._wrapCoords(coords), L.bind(this._tileReady, this, coords));
+ tile = this.createTile(this._wrapCoords(coords), L.bind(this._tileReady, this, coords));
this._initTile(tile);
@@ -662,11 +662,13 @@ L.GridLayer = L.Layer.extend({
}
if (!this._tileCache[key]) {
var twips = this._coordsToTwips(coords);
- if (tilePositionsX !== '')
+ if (tilePositionsX !== '') {
tilePositionsX += ',';
+ }
tilePositionsX += twips.x;
- if (tilePositionsY !== '')
+ if (tilePositionsY !== '') {
tilePositionsY += ',';
+ }
tilePositionsY += twips.y;
}
else {
@@ -684,7 +686,7 @@ L.GridLayer = L.Layer.extend({
'tilewidth=' + this._tileWidthTwips + ' ' +
'tileheight=' + this._tileHeightTwips;
- this._map._socket.sendMessage(message, "");
+ this._map._socket.sendMessage(message, '');
}
this._level.el.appendChild(fragment);
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index caf3a75..ad6567e 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -395,8 +395,9 @@ L.TileLayer = L.GridLayer.extend({
}
var errorCode = -1;
- if (command.errorCode !== undefined)
+ if (command.errorCode !== undefined) {
errorCode = command.errorCode;
+ }
this._map.fire('error', {cmd: command.errorCmd, kind: command.errorKind, id: errorId, code: errorCode});
},
@@ -1097,13 +1098,7 @@ L.TileLayer = L.GridLayer.extend({
var file = files[i];
if (file.type.match(/image.*/)) {
var reader = new FileReader();
- var socket = this._map._socket;
- reader.onload = (function(aImg) {
- return function(e) {
- var blob = new Blob(['paste mimetype=' + file.type + '\n', e.target.result]);
- socket.sendMessage(blob);
- };
- })(file);
+ reader.onload = this._onFileLoadFunc(file);
reader.readAsArrayBuffer(file);
handled = true;
}
@@ -1112,6 +1107,14 @@ L.TileLayer = L.GridLayer.extend({
}
},
+ _onFileLoadFunc: function(file) {
+ var socket = this._map._socket;
+ return function(e) {
+ var blob = new Blob(['paste mimetype=' + file.type + '\n', e.target.result]);
+ socket.sendMessage(blob);
+ };
+ },
+
_onDragStart: function () {
this._map.on('moveend', this._updateScrollOffset, this);
},
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index acc979f..c2ae5bd 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -85,13 +85,13 @@ L.Map = L.Evented.extend({
};
this.initComplete = false;
- this.on('updatepermission', function(e){
+ this.on('updatepermission', function() {
if (this.initComplete) {
return;
}
this._fireInitComplete('updatepermission');
});
- this.on('updatetoolbarcommandvalues', function(e){
+ this.on('updatetoolbarcommandvalues', function(e) {
if (this.initComplete) {
return;
}
@@ -503,8 +503,9 @@ L.Map = L.Evented.extend({
},
_fireInitComplete: function (condition) {
- if (this.initComplete)
+ if (this.initComplete) {
return;
+ }
this.initConditions[condition] = true;
for (var key in this.initConditions) {
More information about the Libreoffice-commits
mailing list