[Libreoffice-commits] online.git: loleaflet/build loleaflet/src
Mihai Varga
mihai.varga at collabora.com
Thu May 28 08:43:53 PDT 2015
loleaflet/build/deps.js | 7 +++
loleaflet/src/control/Control.StatusIndicator.js | 46 +++++++++++++++++++++++
loleaflet/src/layer/tile/TileLayer.js | 10 +++++
3 files changed, 63 insertions(+)
New commits:
commit 2fa440c18f75e81748f9780762979854b8d7e9f9
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu May 28 18:43:29 2015 +0300
Status indicator control
diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index b3e838d..e1fd636 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -227,6 +227,13 @@ var deps = {
desc: 'Switches from viewing to editing mode and backwards'
},
+ ControlStatusIndicator: {
+ src: ['control/Control.js',
+ 'control/Control.StatusIndicator.js'],
+ heading: 'Controls',
+ desc: 'Display document loading status'
+ },
+
ControlAttrib: {
src: ['control/Control.js',
'control/Control.Attribution.js'],
diff --git a/loleaflet/src/control/Control.StatusIndicator.js b/loleaflet/src/control/Control.StatusIndicator.js
new file mode 100644
index 0000000..96b9da9
--- /dev/null
+++ b/loleaflet/src/control/Control.StatusIndicator.js
@@ -0,0 +1,46 @@
+/*
+ * L.Control.StatusIndicator is used for displaying the current loading status
+ */
+
+L.Control.StatusIndicator = L.Control.extend({
+ options: {
+ position: 'topleft',
+ },
+
+ onAdd: function (map) {
+ var partName = 'leaflet-control-statusindicator';
+ this._container = L.DomUtil.create('div', partName + ' leaflet-bar');
+
+ map.on('statusindicator:start statusindicator:setvalue statusindicator:finish',
+ this._updateStatus, this);
+ return this._container;
+ },
+
+ _updateStatus: function (e) {
+ if (e.type === 'statusindicator:start') {
+ L.DomUtil.setStyle(this._container, 'display', '');
+ this._container.innerText = '0 %';
+ }
+ else if (e.type === 'statusindicator:setvalue') {
+ this._container.innerText = e.statusIndicator + '% ';
+ }
+ else if (e.type === 'statusindicator:finish') {
+ L.DomUtil.setStyle(this._container, 'display', 'none');
+ }
+ }
+});
+
+L.Map.mergeOptions({
+ statusIndicatorControl: true
+});
+
+L.Map.addInitHook(function () {
+ if (this.options.statusIndicatorControl) {
+ this.statusIndicatorControl = new L.Control.StatusIndicator();
+ this.addControl(this.statusIndicatorControl);
+ }
+});
+
+L.control.statusIndicator = function (options) {
+ return new L.Control.StatusIndicator(options);
+};
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 6bcab24..a4ee0b4 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -194,6 +194,16 @@ L.TileLayer = L.GridLayer.extend({
this._update();
}
}
+ else if (textMsg.startsWith('statusindicatorstart:')) {
+ this._map.fire('statusindicator:start');
+ }
+ else if (textMsg.startsWith('statusindicatorsetvalue:')) {
+ var statusIndicator = textMsg.match(/\d+/g)[0];
+ this._map.fire('statusindicator:setvalue', {statusIndicator:statusIndicator});
+ }
+ else if (textMsg.startsWith('statusindicatorfinish:')) {
+ this._map.fire('statusindicator:finish');
+ }
else if (textMsg.startsWith('tile:')) {
var command = this._parseServerCmd(textMsg);
var coords = this._twipsToCoords(new L.Point(command.x, command.y));
More information about the Libreoffice-commits
mailing list