loleaflet: renamed 'currentPart' to 'selectedPart'
This commit is contained in:
parent
e28da7e12e
commit
6bf8a7dee0
6 changed files with 43 additions and 43 deletions
|
@ -62,17 +62,17 @@ L.Control.Parts = L.Control.extend({
|
|||
_updateDisabled: function (e) {
|
||||
var className = 'leaflet-disabled';
|
||||
var parts = e.parts;
|
||||
var currentPart = e.currentPart;
|
||||
var selectedPart = e.selectedPart;
|
||||
var docType = e.docType;
|
||||
if (docType === 'text') {
|
||||
return;
|
||||
}
|
||||
if (currentPart === 0) {
|
||||
if (selectedPart === 0) {
|
||||
L.DomUtil.addClass(this._prevPartButton, className);
|
||||
} else {
|
||||
L.DomUtil.removeClass(this._prevPartButton, className);
|
||||
}
|
||||
if (currentPart === parts - 1) {
|
||||
if (selectedPart === parts - 1) {
|
||||
L.DomUtil.addClass(this._nextPartButton, className);
|
||||
} else {
|
||||
L.DomUtil.removeClass(this._nextPartButton, className);
|
||||
|
|
|
@ -15,7 +15,7 @@ L.Control.Tabs = L.Control.extend({
|
|||
|
||||
_updateDisabled: function (e) {
|
||||
var parts = e.parts;
|
||||
var currentPart = e.currentPart;
|
||||
var selectedPart = e.selectedPart;
|
||||
var docType = e.docType;
|
||||
var partNames = e.partNames;
|
||||
if (docType === 'text') {
|
||||
|
@ -47,7 +47,7 @@ L.Control.Tabs = L.Control.extend({
|
|||
for (var key in this._spreadsheetTabs) {
|
||||
var part = parseInt(key.match(/\d+/g)[0]);
|
||||
L.DomUtil.removeClass(this._spreadsheetTabs[key], 'selected');
|
||||
if (part === currentPart) {
|
||||
if (part === selectedPart) {
|
||||
L.DomUtil.addClass(this._spreadsheetTabs[key], 'selected');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,17 @@ L.Map.include({
|
|||
setPart: function (part) {
|
||||
var docLayer = this._docLayer;
|
||||
if (part === 'prev') {
|
||||
if (docLayer._currentPart > 0) {
|
||||
docLayer._currentPart -= 1;
|
||||
if (docLayer._selectedPart > 0) {
|
||||
docLayer._selectedPart -= 1;
|
||||
}
|
||||
}
|
||||
else if (part === 'next') {
|
||||
if (docLayer._currentPart < docLayer._parts - 1) {
|
||||
docLayer._currentPart += 1;
|
||||
if (docLayer._selectedPart < docLayer._parts - 1) {
|
||||
docLayer._selectedPart += 1;
|
||||
}
|
||||
}
|
||||
else if (typeof (part) === 'number' && part >= 0 && part < docLayer._parts) {
|
||||
docLayer._currentPart = part;
|
||||
docLayer._selectedPart = part;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
|
@ -25,11 +25,11 @@ L.Map.include({
|
|||
L.Socket.sendMessage('resetselection');
|
||||
}
|
||||
this.fire('updateparts', {
|
||||
currentPart: docLayer._currentPart,
|
||||
selectedPart: docLayer._selectedPart,
|
||||
parts: docLayer._parts,
|
||||
docType: docLayer._docType
|
||||
});
|
||||
L.Socket.sendMessage('setclientpart part=' + docLayer._currentPart);
|
||||
L.Socket.sendMessage('setclientpart part=' + docLayer._selectedPart);
|
||||
docLayer._update();
|
||||
docLayer._pruneTiles();
|
||||
docLayer._clearSelections();
|
||||
|
@ -114,7 +114,7 @@ L.Map.include({
|
|||
},
|
||||
|
||||
getCurrentPartNumber: function () {
|
||||
return this._docLayer._currentPart;
|
||||
return this._docLayer._selectedPart;
|
||||
},
|
||||
|
||||
getDocSize: function () {
|
||||
|
|
|
@ -160,7 +160,7 @@ L.Socket = {
|
|||
command.parts = parseInt(tokens[i].substring(6));
|
||||
}
|
||||
else if (tokens[i].substring(0, 8) === 'current=') {
|
||||
command.currentPart = parseInt(tokens[i].substring(8));
|
||||
command.selectedPart = parseInt(tokens[i].substring(8));
|
||||
}
|
||||
else if (tokens[i].substring(0, 3) === 'id=') {
|
||||
// remove newline characters
|
||||
|
|
|
@ -470,7 +470,7 @@ L.GridLayer = L.Layer.extend({
|
|||
|
||||
for (var key in this._tiles) {
|
||||
if (this._keyToTileCoords(key).z !== zoom ||
|
||||
this._keyToTileCoords(key).part !== this._currentPart) {
|
||||
this._keyToTileCoords(key).part !== this._selectedPart) {
|
||||
this._tiles[key].current = false;
|
||||
}
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ L.GridLayer = L.Layer.extend({
|
|||
for (var i = tileRange.min.x; i <= tileRange.max.x; i++) {
|
||||
var coords = new L.Point(i, j);
|
||||
coords.z = zoom;
|
||||
coords.part = this._currentPart;
|
||||
coords.part = this._selectedPart;
|
||||
|
||||
if (!this._isValidTile(coords)) { continue; }
|
||||
|
||||
|
@ -619,7 +619,7 @@ L.GridLayer = L.Layer.extend({
|
|||
var tilePos = this._getTilePos(coords),
|
||||
key = this._tileCoordsToKey(coords);
|
||||
|
||||
if (coords.part === this._currentPart) {
|
||||
if (coords.part === this._selectedPart) {
|
||||
var tile = this.createTile(this._wrapCoords(coords), L.bind(this._tileReady, this, coords));
|
||||
|
||||
this._initTile(tile);
|
||||
|
@ -660,7 +660,7 @@ L.GridLayer = L.Layer.extend({
|
|||
'tileposy=' + twips.y + ' ' +
|
||||
'tilewidth=' + this._tileWidthTwips + ' ' +
|
||||
'tileheight=' + this._tileHeightTwips;
|
||||
if (coords.part !== this._currentPart) {
|
||||
if (coords.part !== this._selectedPart) {
|
||||
msg += ' prefetch=true';
|
||||
}
|
||||
L.Socket.sendMessage(msg, key);
|
||||
|
@ -770,7 +770,7 @@ L.GridLayer = L.Layer.extend({
|
|||
}
|
||||
|
||||
if (!this._preFetchBorder) {
|
||||
if (this._currentPart !== this._preFetchPart) {
|
||||
if (this._selectedPart !== this._preFetchPart) {
|
||||
// all tiles from the new part have to be pre-fetched
|
||||
var tileBorder = this._preFetchBorder = new L.Bounds(new L.Point(0, 0), new L.Point(0, 0));
|
||||
}
|
||||
|
@ -855,36 +855,36 @@ L.GridLayer = L.Layer.extend({
|
|||
tileBorder.max.x * this._tileWidthTwips < this._docWidthTwips ||
|
||||
tileBorder.max.y * this._tileHeightTwips < this._docHeightTwips) &&
|
||||
this.options.preFetchOtherParts) {
|
||||
var diff = this._preFetchPart - this._currentPart;
|
||||
if (diff === 0 && this._currentPart < this._parts - 1) {
|
||||
var diff = this._preFetchPart - this._selectedPart;
|
||||
if (diff === 0 && this._selectedPart < this._parts - 1) {
|
||||
this._preFetchPart += 1;
|
||||
this._preFetchBorder = null;
|
||||
}
|
||||
else if (diff === 0 && this._currentPart > 0) {
|
||||
else if (diff === 0 && this._selectedPart > 0) {
|
||||
this._preFetchPart -= 1;
|
||||
this._preFetchBorder = null;
|
||||
}
|
||||
else if (diff > 0) {
|
||||
if (this._currentPart - diff >= 0) {
|
||||
if (this._selectedPart - diff >= 0) {
|
||||
// lower part number
|
||||
this._preFetchPart = this._currentPart - diff;
|
||||
this._preFetchPart = this._selectedPart - diff;
|
||||
this._preFetchBorder = null;
|
||||
}
|
||||
else if (this._currentPart + diff + 1 < this._parts) {
|
||||
else if (this._selectedPart + diff + 1 < this._parts) {
|
||||
// higher part number
|
||||
this._preFetchPart = this._currentPart + diff + 1;
|
||||
this._preFetchPart = this._selectedPart + diff + 1;
|
||||
this._preFetchBorder = null;
|
||||
}
|
||||
}
|
||||
else if (diff < 0) {
|
||||
if (this._currentPart - diff + 1 < this._parts) {
|
||||
if (this._selectedPart - diff + 1 < this._parts) {
|
||||
// higher part number
|
||||
this._preFetchPart = this._currentPart - diff + 1;
|
||||
this._preFetchPart = this._selectedPart - diff + 1;
|
||||
this._preFetchBorder = null;
|
||||
}
|
||||
else if (this._currentPart + diff - 1 >= 0) {
|
||||
else if (this._selectedPart + diff - 1 >= 0) {
|
||||
// lower part number
|
||||
this._preFetchPart = this._currentPart + diff - 1;
|
||||
this._preFetchPart = this._selectedPart + diff - 1;
|
||||
this._preFetchBorder = null;
|
||||
}
|
||||
}
|
||||
|
@ -908,7 +908,7 @@ L.GridLayer = L.Layer.extend({
|
|||
}
|
||||
var interval = 750;
|
||||
var idleTime = 5000;
|
||||
this._preFetchPart = this._currentPart;
|
||||
this._preFetchPart = this._selectedPart;
|
||||
this._preFetchIdle = setTimeout(L.bind(function () {
|
||||
this._tilesPreFetcher = setInterval(L.bind(this._preFetchTiles, this), interval);
|
||||
}, this), idleTime);
|
||||
|
|
|
@ -274,7 +274,7 @@ L.TileLayer = L.GridLayer.extend({
|
|||
command.y = parseInt(strTwips[1]);
|
||||
command.width = parseInt(strTwips[2]);
|
||||
command.height = parseInt(strTwips[3]);
|
||||
command.part = this._currentPart;
|
||||
command.part = this._selectedPart;
|
||||
}
|
||||
if (this._docType === 'text') {
|
||||
command.part = 0;
|
||||
|
@ -346,7 +346,7 @@ L.TileLayer = L.GridLayer.extend({
|
|||
delete this._tileCache[key];
|
||||
}
|
||||
}
|
||||
if (command.part === this._currentPart &&
|
||||
if (command.part === this._selectedPart &&
|
||||
command.part !== this._lastValidPart) {
|
||||
this._lastValidPart = command.part;
|
||||
this._map.fire('updatepart', {part: command.part, docType: this._docType});
|
||||
|
@ -361,11 +361,11 @@ L.TileLayer = L.GridLayer.extend({
|
|||
|
||||
_onSetPartMsg: function (textMsg) {
|
||||
var part = parseInt(textMsg.match(/\d+/g)[0]);
|
||||
if (part !== this._currentPart && this._docType !== 'text') {
|
||||
this._currentPart = part;
|
||||
if (part !== this._selectedPart && this._docType !== 'text') {
|
||||
this._selectedPart = part;
|
||||
this._update();
|
||||
this._clearSelections();
|
||||
this._map.fire('setpart', {currentPart: this._currentPart});
|
||||
this._map.fire('setpart', {selectedPart: this._selectedPart});
|
||||
}
|
||||
else if (this._docType === 'text') {
|
||||
this._currentPage = part;
|
||||
|
@ -395,11 +395,11 @@ L.TileLayer = L.GridLayer.extend({
|
|||
this._updateMaxBounds(true);
|
||||
this._documentInfo = textMsg;
|
||||
this._parts = command.parts;
|
||||
this._currentPart = command.currentPart;
|
||||
this._selectedPart = command.selectedPart;
|
||||
if (this._docType === 'text') {
|
||||
this._currentPart = 0;
|
||||
this._selectedPart = 0;
|
||||
this._parts = 1;
|
||||
this._currentPage = command.currentPart;
|
||||
this._currentPage = command.selectedPart;
|
||||
this._pages = command.parts;
|
||||
this._map.fire('pagenumberchanged', {
|
||||
currentPage: this._currentPage,
|
||||
|
@ -408,20 +408,20 @@ L.TileLayer = L.GridLayer.extend({
|
|||
});
|
||||
}
|
||||
else {
|
||||
L.Socket.sendMessage('setclientpart part=' + this._currentPart);
|
||||
L.Socket.sendMessage('setclientpart part=' + this._selectedPart);
|
||||
var partNames = textMsg.match(/[^\r\n]+/g);
|
||||
// only get the last matches
|
||||
partNames = partNames.slice(partNames.length - this._parts);
|
||||
this._map.fire('updateparts', {
|
||||
currentPart: this._currentPart,
|
||||
selectedPart: this._selectedPart,
|
||||
parts: this._parts,
|
||||
docType: this._docType,
|
||||
partNames: partNames
|
||||
});
|
||||
}
|
||||
this._update();
|
||||
if (this._preFetchPart !== this._currentPart) {
|
||||
this._preFetchPart = this._currentPart;
|
||||
if (this._preFetchPart !== this._selectedPart) {
|
||||
this._preFetchPart = this._selectedPart;
|
||||
this._preFetchBorder = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue