loleaflet/src/control/Control.Parts.js | 38 +++++++++++++++++++++++++++++++-- loleaflet/src/layer/tile/TileLayer.js | 24 +++++++++++--------- 2 files changed, 49 insertions(+), 13 deletions(-)
New commits: commit c4511f1c218490869a7f36c9b6047373d7817987 Author: Mihai Varga <mihai.va...@collabora.com> Date: Tue Aug 4 13:59:33 2015 +0300 loleaflet: enable page switching in toolbar diff --git a/loleaflet/src/control/Control.Parts.js b/loleaflet/src/control/Control.Parts.js index c789340..d32650a 100644 --- a/loleaflet/src/control/Control.Parts.js +++ b/loleaflet/src/control/Control.Parts.js @@ -30,15 +30,26 @@ L.Control.Parts = L.Control.extend({ map.on('updateparts', this._updateDisabled, this); map.on('tilepreview', this._updatePreview, this); + map.on('pagenumberchanged', this._updateDisabledText, this); return container; }, _prevPart: function () { - this._map.setPart('prev'); + if (this._docType === 'text' && this._currentPage > 0) { + this._map.goToPage(this._currentPage - 1); + } + else { + this._map.setPart('prev'); + } }, _nextPart: function () { - this._map.setPart('next'); + if (this._docType === 'text' && this._currentPage < this._pages - 1) { + this._map.goToPage(this._currentPage + 1); + } + else { + this._map.setPart('next'); + } }, _createButton: function (html, title, className, container, fn) { @@ -62,6 +73,9 @@ L.Control.Parts = L.Control.extend({ var currentPart = e.currentPart; var docType = e.docType; var partNames = e.partNames; + if (docType === 'text') { + return; + } if (currentPart === 0) { L.DomUtil.addClass(this._prevPartButton, className); } else { @@ -129,6 +143,26 @@ L.Control.Parts = L.Control.extend({ } }, + + _updateDisabledText: function (e) { + if (e) { + this._currentPage = e.currentPage; + this._pages = e.pages; + this._docType = e.docType; + } + var className = 'leaflet-disabled'; + if (this._currentPage === 0) { + L.DomUtil.addClass(this._prevPartButton, className); + } else { + L.DomUtil.removeClass(this._prevPartButton, className); + } + if (this._currentPage === this._pages - 1) { + L.DomUtil.addClass(this._nextPartButton, className); + } else { + L.DomUtil.removeClass(this._nextPartButton, className); + } + }, + _setPart: function (e) { var part = e.target.id.match(/\d+/g)[0]; if (part !== null) { commit 364d9f8053cd58ee6ff2235438d87654946ae6e9 Author: Mihai Varga <mihai.va...@collabora.com> Date: Tue Aug 4 13:59:16 2015 +0300 loleaflet: don't emit the updateparts event for text docs diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 6f3326f..21aebe0 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -346,7 +346,7 @@ L.TileLayer = L.GridLayer.extend({ if (this._docType === 'text') { this._currentPart = 0; this._parts = 1; - this._currentPage = command.part; + this._currentPage = command.currentPart; this._pages = command.parts; map.fire('pagenumberchanged', { currentPage: this._currentPage, @@ -354,16 +354,18 @@ L.TileLayer = L.GridLayer.extend({ docType: this._docType }); } - this.sendMessage('setclientpart part=' + this._currentPart); - 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, - parts: this._parts, - docType: this._docType, - partNames: partNames - }); + else { + this.sendMessage('setclientpart part=' + this._currentPart); + 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, + parts: this._parts, + docType: this._docType, + partNames: partNames + }); + } this._update(); if (this._preFetchPart !== this._currentPart) { this._preFetchPart = this._currentPart; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits