[Libreoffice-commits] online.git: 5 commits - loleaflet/dist loleaflet/.eslintignore loleaflet/.eslintrc loleaflet/Jakefile.js loleaflet/package.json loleaflet/src
Pranav Kant
pranavk at collabora.com
Sun May 29 09:34:03 UTC 2016
loleaflet/.eslintignore | 6
loleaflet/.eslintrc | 6
loleaflet/Jakefile.js | 2
loleaflet/dist/toolbar/toolbar.js | 807 ++++++++++++++--------------
loleaflet/package.json | 2
loleaflet/src/admin/AdminSocketAnalytics.js | 8
loleaflet/src/admin/AdminSocketSettings.js | 2
loleaflet/src/control/Control.Permission.js | 2
loleaflet/src/control/Control.Selection.js | 2
loleaflet/src/control/Control.Tabs.js | 18
loleaflet/src/core/Log.js | 4
loleaflet/src/dom/DomEvent.DoubleTap.js | 2
loleaflet/src/dom/DomEvent.js | 6
loleaflet/src/dom/Draggable.js | 2
loleaflet/src/geo/LatLng.js | 2
loleaflet/src/geo/LatLngBounds.js | 4
loleaflet/src/layer/GeoJSON.js | 2
loleaflet/src/layer/Layer.Popup.js | 6
loleaflet/src/layer/Layer.js | 4
loleaflet/src/layer/marker/Cursor.js | 2
loleaflet/src/layer/marker/Marker.js | 6
loleaflet/src/layer/tile/GridLayer.js | 32 -
loleaflet/src/layer/tile/TileLayer.js | 6
loleaflet/src/layer/vector/Polyline.js | 4
loleaflet/src/layer/vector/SVG.js | 4
loleaflet/src/map/Map.js | 12
loleaflet/src/map/anim/Map.ZoomAnimation.js | 4
loleaflet/src/map/ext/Map.Geolocation.js | 2
loleaflet/src/map/handler/Map.Keyboard.js | 108 +--
loleaflet/src/map/handler/Map.Scroll.js | 4
30 files changed, 538 insertions(+), 533 deletions(-)
New commits:
commit eaf34618733aec2f46c6744ed21e6329a7e08022
Author: Pranav Kant <pranavk at collabora.com>
Date: Fri May 27 22:22:35 2016 +0530
loleaflet: fix indent errors reported by bumped eslint
Change-Id: I49e274e1d4869d9d0a39342d9c3b64747a1fc870
diff --git a/loleaflet/src/admin/AdminSocketAnalytics.js b/loleaflet/src/admin/AdminSocketAnalytics.js
index 4f93626..c8815b7 100644
--- a/loleaflet/src/admin/AdminSocketAnalytics.js
+++ b/loleaflet/src/admin/AdminSocketAnalytics.js
@@ -66,10 +66,10 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
_setUpAxis: function() {
this._xScale = d3.scale.linear().range([this._graphMargins.left, this._graphWidth - this._graphMargins.right]).domain([d3.min(this._memStatsData, function(d) {
- return d.time;
- }), d3.max(this._memStatsData, function(d) {
- return d.time;
- })]);
+ return d.time;
+ }), d3.max(this._memStatsData, function(d) {
+ return d.time;
+ })]);
this._yScale = d3.scale.linear().range([this._graphHeight - this._graphMargins.bottom, this._graphMargins.top]).domain([d3.min(this._memStatsData, function(d) {
diff --git a/loleaflet/src/admin/AdminSocketSettings.js b/loleaflet/src/admin/AdminSocketSettings.js
index 241150f..094cfeb 100644
--- a/loleaflet/src/admin/AdminSocketSettings.js
+++ b/loleaflet/src/admin/AdminSocketSettings.js
@@ -33,7 +33,7 @@ var AdminSocketSettings = AdminSocketBase.extend({
this.socket.send('settings');
},
- onSocketMessage: function(e) {
+ onSocketMessage: function(e) {
var textMsg;
if (typeof e.data === 'string') {
textMsg = e.data;
diff --git a/loleaflet/src/control/Control.Permission.js b/loleaflet/src/control/Control.Permission.js
index 2f67eec..1178580 100644
--- a/loleaflet/src/control/Control.Permission.js
+++ b/loleaflet/src/control/Control.Permission.js
@@ -9,7 +9,7 @@ L.Control.PermissionSwitch = L.Control.extend({
onAdd: function (map) {
var partName = 'leaflet-control-editviewswitch',
- container = L.DomUtil.create('label', partName + ' leaflet-bar');
+ container = L.DomUtil.create('label', partName + ' leaflet-bar');
this._checkBox = L.DomUtil.create('input', 'editview-cb', container);
this._checkBox.type = 'checkbox';
diff --git a/loleaflet/src/control/Control.Selection.js b/loleaflet/src/control/Control.Selection.js
index 524b187..af0ed0e 100644
--- a/loleaflet/src/control/Control.Selection.js
+++ b/loleaflet/src/control/Control.Selection.js
@@ -9,7 +9,7 @@ L.Control.Selection = L.Control.extend({
onAdd: function (map) {
var partName = 'leaflet-control-editviewswitch',
- container = L.DomUtil.create('label', partName + ' leaflet-bar');
+ container = L.DomUtil.create('label', partName + ' leaflet-bar');
this._checkBox = L.DomUtil.create('input', 'editview-cb', container);
this._checkBox.type = 'checkbox';
diff --git a/loleaflet/src/control/Control.Tabs.js b/loleaflet/src/control/Control.Tabs.js
index 863dc4d..a7895f7 100644
--- a/loleaflet/src/control/Control.Tabs.js
+++ b/loleaflet/src/control/Control.Tabs.js
@@ -53,15 +53,15 @@ L.Control.Tabs = L.Control.extend({
},
'renamesheet': {name: _('Rename sheet'),
callback: function(key, options) {
- var nPos = parseInt(options.$trigger.attr('id').split('spreadsheet-tab')[1]);
- vex.dialog.open({
- message: _('Enter new sheet name'),
- input: '<input name="sheetname" type="text" required />',
- callback: function(data) {
- map.renamePage(data.sheetname, nPos);
- }
- });
- }}
+ var nPos = parseInt(options.$trigger.attr('id').split('spreadsheet-tab')[1]);
+ vex.dialog.open({
+ message: _('Enter new sheet name'),
+ input: '<input name="sheetname" type="text" required />',
+ callback: function(data) {
+ map.renamePage(data.sheetname, nPos);
+ }
+ });
+ }}
},
zIndex: 10
});
diff --git a/loleaflet/src/core/Log.js b/loleaflet/src/core/Log.js
index 7f0fb03..9f9c3dd 100644
--- a/loleaflet/src/core/Log.js
+++ b/loleaflet/src/core/Log.js
@@ -37,8 +37,8 @@ L.Log = {
save: function () {
var blob = new Blob([this._getEntries()], {type: 'text/csv'}),
- e = document.createEvent('MouseEvents'),
- a = document.createElement('a');
+ e = document.createEvent('MouseEvents'),
+ a = document.createElement('a');
a.download = Date.now() + '.csv';
a.href = window.URL.createObjectURL(blob);
diff --git a/loleaflet/src/dom/DomEvent.DoubleTap.js b/loleaflet/src/dom/DomEvent.DoubleTap.js
index d0f374b..81df6b2 100644
--- a/loleaflet/src/dom/DomEvent.DoubleTap.js
+++ b/loleaflet/src/dom/DomEvent.DoubleTap.js
@@ -37,7 +37,7 @@ L.extend(L.DomEvent, {
if (L.Browser.pointer) {
// work around .type being readonly with MSPointer* events
var newTouch = {},
- prop, i;
+ prop, i;
for (i in touch) {
prop = touch[i];
diff --git a/loleaflet/src/dom/DomEvent.js b/loleaflet/src/dom/DomEvent.js
index d1f9141..59a7ce5 100644
--- a/loleaflet/src/dom/DomEvent.js
+++ b/loleaflet/src/dom/DomEvent.js
@@ -181,8 +181,8 @@ L.DomEvent = {
}
var rect = container.getBoundingClientRect(), // constant object
- left = rect.left,
- top = rect.top;
+ left = rect.left,
+ top = rect.top;
// iframe mouse coordinates are relative to the frame area
// `target`: body element of the iframe; `currentTarget`: content window of the iframe
@@ -243,7 +243,7 @@ L.DomEvent = {
// this is a horrible workaround for a bug in Android where a single touch triggers two click events
_filterClick: function (e, handler) {
var timeStamp = (e.timeStamp || e.originalEvent.timeStamp),
- elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);
+ elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);
// are they closer together than 500ms yet more than 100ms?
// Android typically triggers them ~300ms apart while multiple listeners
diff --git a/loleaflet/src/dom/Draggable.js b/loleaflet/src/dom/Draggable.js
index 9924510..99cd6a9 100644
--- a/loleaflet/src/dom/Draggable.js
+++ b/loleaflet/src/dom/Draggable.js
@@ -100,7 +100,7 @@ L.Draggable = L.Evented.extend({
if (e.currentTarget && e.currentTarget.frameElement
&& L.DomUtil.hasClass(e.currentTarget.frameElement, 'resize-detector')) {
var rect = this._map._container.getBoundingClientRect(),
- correction = new L.Point(rect.left, rect.top);
+ correction = new L.Point(rect.left, rect.top);
offset = offset.add(correction);
}
if (this._map.getDocSize().x < this._map.getSize().x) {
diff --git a/loleaflet/src/geo/LatLng.js b/loleaflet/src/geo/LatLng.js
index 333abad..4f3a6bb 100644
--- a/loleaflet/src/geo/LatLng.js
+++ b/loleaflet/src/geo/LatLng.js
@@ -44,7 +44,7 @@ L.LatLng.prototype = {
toBounds: function (sizeInMeters) {
var latAccuracy = 180 * sizeInMeters / 40075017,
- lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
+ lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
return L.latLngBounds(
[this.lat - latAccuracy, this.lng - lngAccuracy],
diff --git a/loleaflet/src/geo/LatLngBounds.js b/loleaflet/src/geo/LatLngBounds.js
index da0a57c..0b64be9 100644
--- a/loleaflet/src/geo/LatLngBounds.js
+++ b/loleaflet/src/geo/LatLngBounds.js
@@ -17,8 +17,8 @@ L.LatLngBounds.prototype = {
// extend the bounds to contain the given point or bounds
extend: function (obj) { // (LatLng) or (LatLngBounds)
var sw = this._southWest,
- ne = this._northEast,
- sw2, ne2;
+ ne = this._northEast,
+ sw2, ne2;
if (obj instanceof L.LatLng) {
sw2 = obj;
diff --git a/loleaflet/src/layer/GeoJSON.js b/loleaflet/src/layer/GeoJSON.js
index 1766a0f..cb17f88 100644
--- a/loleaflet/src/layer/GeoJSON.js
+++ b/loleaflet/src/layer/GeoJSON.js
@@ -240,7 +240,7 @@ L.LayerGroup.include({
}
var isGeometryCollection = type === 'GeometryCollection',
- jsons = [];
+ jsons = [];
this.eachLayer(function (layer) {
if (layer.toGeoJSON) {
diff --git a/loleaflet/src/layer/Layer.Popup.js b/loleaflet/src/layer/Layer.Popup.js
index 5561f97..d81bf59 100644
--- a/loleaflet/src/layer/Layer.Popup.js
+++ b/loleaflet/src/layer/Layer.Popup.js
@@ -32,9 +32,9 @@ L.Layer.include({
unbindPopup: function () {
if (this._popup) {
this.off({
- click: this._openPopup,
- remove: this.closePopup,
- move: this._movePopup
+ click: this._openPopup,
+ remove: this.closePopup,
+ move: this._movePopup
});
this._popupHandlersAdded = false;
this._popup = null;
diff --git a/loleaflet/src/layer/Layer.js b/loleaflet/src/layer/Layer.js
index 579d30b..493bd04 100644
--- a/loleaflet/src/layer/Layer.js
+++ b/loleaflet/src/layer/Layer.js
@@ -143,8 +143,8 @@ L.Map.include({
_updateZoomLevels: function () {
var minZoom = Infinity,
- maxZoom = -Infinity,
- oldZoomSpan = this._getZoomSpan();
+ maxZoom = -Infinity,
+ oldZoomSpan = this._getZoomSpan();
for (var i in this._zoomBoundLayers) {
var options = this._zoomBoundLayers[i].options;
diff --git a/loleaflet/src/layer/marker/Cursor.js b/loleaflet/src/layer/marker/Cursor.js
index 4bb4cf5..4fb32c2 100644
--- a/loleaflet/src/layer/marker/Cursor.js
+++ b/loleaflet/src/layer/marker/Cursor.js
@@ -93,7 +93,7 @@ L.cursor = function (latlng, options) {
L.Cursor.getCursorURL = function (localPath) {
var scripts = document.getElementsByTagName('script'),
- leafletRe = /[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;
+ leafletRe = /[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;
var i, len, src, path;
diff --git a/loleaflet/src/layer/marker/Marker.js b/loleaflet/src/layer/marker/Marker.js
index 28bd7b8..95044da 100644
--- a/loleaflet/src/layer/marker/Marker.js
+++ b/loleaflet/src/layer/marker/Marker.js
@@ -110,7 +110,7 @@ L.Marker = L.Layer.extend({
classToAdd = 'leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide');
var icon = options.icon.createIcon(this._icon),
- addIcon = false;
+ addIcon = false;
// if we're not reusing the icon, remove the old one and init new one
if (icon !== this._icon) {
@@ -144,7 +144,7 @@ L.Marker = L.Layer.extend({
}
var newShadow = options.icon.createShadow(this._shadow),
- addShadow = false;
+ addShadow = false;
if (newShadow !== this._shadow) {
this._removeShadow();
@@ -174,7 +174,7 @@ L.Marker = L.Layer.extend({
if (this.options.riseOnHover) {
this.off({
mouseover: this._bringToFront,
- mouseout: this._resetZIndex
+ mouseout: this._resetZIndex
});
}
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 20dd36a..89b71bd 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -167,7 +167,7 @@ L.GridLayer = L.Layer.extend({
}
var now = +new Date(),
- nextFrame = false;
+ nextFrame = false;
for (var key in this._tiles) {
var tile = this._tiles[key];
@@ -205,7 +205,7 @@ L.GridLayer = L.Layer.extend({
_updateLevels: function () {
var zoom = this._tileZoom,
- maxZoom = this.options.maxZoom;
+ maxZoom = this.options.maxZoom;
for (var z in this._levels) {
if (this._levels[z].el.children.length || z === zoom) {
@@ -272,11 +272,11 @@ L.GridLayer = L.Layer.extend({
_retainParent: function (x, y, z, part, minZoom) {
var x2 = Math.floor(x / 1.2),
- y2 = Math.floor(y / 1.2),
- z2 = z - 1;
+ y2 = Math.floor(y / 1.2),
+ z2 = z - 1;
var key = x2 + ':' + y2 + ':' + z2 + ':' + part,
- tile = this._tiles[key];
+ tile = this._tiles[key];
if (tile && tile.active) {
tile.retain = true;
@@ -300,7 +300,7 @@ L.GridLayer = L.Layer.extend({
var key = Math.floor(i) + ':' + Math.floor(j) + ':' +
(z + 1) + ':' + part,
- tile = this._tiles[key];
+ tile = this._tiles[key];
if (tile && tile.active) {
tile.retain = true;
@@ -327,7 +327,7 @@ L.GridLayer = L.Layer.extend({
_reset: function (center, zoom, hard, noPrune, noUpdate) {
var tileZoom = Math.round(zoom),
- tileZoomChanged = this._tileZoom !== tileZoom;
+ tileZoomChanged = this._tileZoom !== tileZoom;
if (!noUpdate && (hard || tileZoomChanged)) {
@@ -497,8 +497,8 @@ L.GridLayer = L.Layer.extend({
if (zoom === undefined) { zoom = Math.round(map.getZoom()); }
var pixelBounds = map.getPixelBounds(center, zoom),
- tileRange = this._pxBoundsToTileRange(pixelBounds),
- queue = [];
+ tileRange = this._pxBoundsToTileRange(pixelBounds),
+ queue = [];
for (var key in this._tiles) {
if (this._keyToTileCoords(key).z !== zoom ||
@@ -565,8 +565,8 @@ L.GridLayer = L.Layer.extend({
var zoom = Math.round(map.getZoom());
var pixelBounds = map.getPixelBounds(center, zoom),
- tileRange = this._pxBoundsToTileRange(pixelBounds),
- queue = [];
+ tileRange = this._pxBoundsToTileRange(pixelBounds),
+ queue = [];
for (key in this._tiles) {
if (this._keyToTileCoords(key).z !== zoom ||
@@ -728,7 +728,7 @@ L.GridLayer = L.Layer.extend({
// converts tile cache key to coordinates
_keyToTileCoords: function (key) {
var k = key.split(':'),
- coords = new L.Point(+k[0], +k[1]);
+ coords = new L.Point(+k[0], +k[1]);
coords.z = +k[2];
coords.part = +k[3];
return coords;
@@ -1100,10 +1100,10 @@ L.GridLayer = L.Layer.extend({
tileBorder = this._preFetchBorder;
}
var queue = [],
- finalQueue = [],
- visitedTiles = {},
- borderWidth = 0;
- // don't search on a border wider than 5 tiles because it will freeze the UI
+ finalQueue = [],
+ visitedTiles = {},
+ borderWidth = 0;
+ // don't search on a border wider than 5 tiles because it will freeze the UI
while ((tileBorder.min.x >= 0 || tileBorder.min.y >= 0 ||
tileBorder.max.x * this._tileWidthTwips < this._docWidthTwips ||
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 8cbe56c..313a431 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -127,7 +127,7 @@ L.TileLayer = L.GridLayer.extend({
this._invalidateClientVisibleArea();
},
- onAdd: function (map) {
+ onAdd: function (map) {
this._initContainer();
this._getToolbarCommandsValues();
this._selections = new L.LayerGroup();
@@ -620,7 +620,7 @@ L.TileLayer = L.GridLayer.extend({
_onStateChangedMsg: function (textMsg) {
var unoMsg = textMsg.substr(14).split('=');
var commandName = '',
- state = '';
+ state = '';
if (unoMsg.length > 0) {
commandName = unoMsg[0];
}
@@ -1286,7 +1286,7 @@ L.TileLayer = L.GridLayer.extend({
}
},
- _invalidatePreviews: function () {
+ _invalidatePreviews: function () {
if (this._map._docPreviews && this._previewInvalidations.length > 0) {
var toInvalidate = {};
for (var i = 0; i < this._previewInvalidations.length; i++) {
diff --git a/loleaflet/src/layer/vector/Polyline.js b/loleaflet/src/layer/vector/Polyline.js
index 9f2209f..a636c5d 100644
--- a/loleaflet/src/layer/vector/Polyline.js
+++ b/loleaflet/src/layer/vector/Polyline.js
@@ -133,7 +133,7 @@ L.Polyline = L.Path.extend({
// project bounds as well to use later for Canvas hit detection/etc.
var w = this._clickTolerance(),
- p = new L.Point(w, -w);
+ p = new L.Point(w, -w);
if (this._latlngs.length) {
this._pxBounds = new L.Bounds(
@@ -198,7 +198,7 @@ L.Polyline = L.Path.extend({
// simplify each clipped part of the polyline for performance
_simplifyPoints: function () {
var parts = this._parts,
- tolerance = this.options.smoothFactor;
+ tolerance = this.options.smoothFactor;
for (var i = 0, len = parts.length; i < len; i++) {
parts[i] = L.LineUtil.simplify(parts[i], tolerance);
diff --git a/loleaflet/src/layer/vector/SVG.js b/loleaflet/src/layer/vector/SVG.js
index 0459978..3b203df 100644
--- a/loleaflet/src/layer/vector/SVG.js
+++ b/loleaflet/src/layer/vector/SVG.js
@@ -67,7 +67,7 @@ L.SVG = L.Renderer.extend({
_updateStyle: function (layer) {
var path = layer._path,
- options = layer.options;
+ options = layer.options;
if (!path) { return; }
@@ -146,7 +146,7 @@ L.extend(L.SVG, {
// generates SVG path string for multiple rings, with each ring turning into "M..L..L.." instructions
pointsToPath: function (rings, closed) {
var str = '',
- i, j, len, len2, points, p;
+ i, j, len, len2, points, p;
for (i = 0, len = rings.length; i < len; i++) {
points = rings[i];
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 7d71fba..22e569f 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -230,7 +230,7 @@ L.Map = L.Evented.extend({
panInsideBounds: function (bounds, options) {
var center = this.getCenter(),
- newCenter = this._limitCenter(center, this._zoom, bounds);
+ newCenter = this._limitCenter(center, this._zoom, bounds);
if (center.equals(newCenter)) { return this; }
@@ -738,10 +738,10 @@ L.Map = L.Evented.extend({
vex.dialogID = options.id;
vex.globalID += 1;
options.$vex = $('<div>').addClass(vex.baseClassNames.vex).addClass(options.className).css(options.css).data({
- vex: options
+ vex: options
});
options.$vexOverlay = $('<div>').addClass(vex.baseClassNames.overlay).addClass(options.overlayClassName).css(options.overlayCSS).data({
- vex: options
+ vex: options
});
options.$vexOverlay.bind('click.vex', function(e) {
@@ -753,7 +753,7 @@ L.Map = L.Evented.extend({
options.$vex.append(options.$vexOverlay);
options.$vexContent = $('<div>').addClass(vex.baseClassNames.content).addClass(options.contentClassName).css(options.contentCSS).data({
- vex: options
+ vex: options
});
options.$vex.append(options.$vexContent);
@@ -815,7 +815,7 @@ L.Map = L.Evented.extend({
_isMouseEnteringLeaving: function (e) {
var target = e.target || e.srcElement,
- related = e.relatedTarget;
+ related = e.relatedTarget;
if (!target) { return false; }
@@ -830,7 +830,7 @@ L.Map = L.Evented.extend({
// find the layer the event is propagating from
var target = this._targets[L.stamp(e.target || e.srcElement)],
//type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type;
- type = e.type;
+ type = e.type;
// we need to keep track if we have entered/left the map
this._mouseEnteringLeaving = false;
diff --git a/loleaflet/src/map/anim/Map.ZoomAnimation.js b/loleaflet/src/map/anim/Map.ZoomAnimation.js
index 27e14a2..379d8f0 100644
--- a/loleaflet/src/map/anim/Map.ZoomAnimation.js
+++ b/loleaflet/src/map/anim/Map.ZoomAnimation.js
@@ -35,7 +35,7 @@ L.Map.include(!zoomAnimated ? {} : {
this.on('zoomanim', function (e) {
var prop = L.DomUtil.TRANSFORM,
- transform = proxy.style[prop];
+ transform = proxy.style[prop];
L.DomUtil.setTransform(proxy, this.project(e.center, e.zoom), this.getZoomScale(e.zoom, 1));
@@ -47,7 +47,7 @@ L.Map.include(!zoomAnimated ? {} : {
this.on('load moveend', function () {
var c = this.getCenter(),
- z = this.getZoom();
+ z = this.getZoom();
L.DomUtil.setTransform(proxy, this.project(c, z), this.getZoomScale(z, 1));
}, this);
},
diff --git a/loleaflet/src/map/ext/Map.Geolocation.js b/loleaflet/src/map/ext/Map.Geolocation.js
index e4b0258..e318081 100644
--- a/loleaflet/src/map/ext/Map.Geolocation.js
+++ b/loleaflet/src/map/ext/Map.Geolocation.js
@@ -25,7 +25,7 @@ L.Map.include({
}
var onResponse = L.bind(this._handleGeolocationResponse, this),
- onError = L.bind(this._handleGeolocationError, this);
+ onError = L.bind(this._handleGeolocationError, this);
if (options.watch) {
this._locationWatchId =
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 65cfe88..e316e8e 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -181,8 +181,8 @@ L.Map.Keyboard = L.Handler.extend({
_setPanOffset: function (pan) {
var keys = this._panKeys = {},
- codes = this.navigationKeyCodes,
- i, len;
+ codes = this.navigationKeyCodes,
+ i, len;
for (i = 0, len = codes.left.length; i < len; i++) {
keys[codes.left[i]] = [-1 * pan, 0];
@@ -200,8 +200,8 @@ L.Map.Keyboard = L.Handler.extend({
_setZoomOffset: function (zoom) {
var keys = this._zoomKeys = {},
- codes = this.navigationKeyCodes,
- i, len;
+ codes = this.navigationKeyCodes,
+ i, len;
for (i = 0, len = codes.zoomIn.length; i < len; i++) {
keys[codes.zoomIn[i]] = zoom;
@@ -371,19 +371,19 @@ L.Map.Keyboard = L.Handler.extend({
// Ctrl + Alt
if (!e.originalEvent.shiftKey) {
switch (e.originalEvent.keyCode) {
- case 53: // 5
- this._map._socket.sendMessage('uno .uno:Strikeout');
- return true;
- case 70: // f
- this._map._socket.sendMessage('uno .uno:InsertFootnote');
- return true;
- case 67: // c
- case 77: // m
- this._map._socket.sendMessage('uno .uno:InsertAnnotation');
- return true;
- case 68: // d
- this._map._socket.sendMessage('uno .uno:InsertEndnote');
- return true;
+ case 53: // 5
+ this._map._socket.sendMessage('uno .uno:Strikeout');
+ return true;
+ case 70: // f
+ this._map._socket.sendMessage('uno .uno:InsertFootnote');
+ return true;
+ case 67: // c
+ case 77: // m
+ this._map._socket.sendMessage('uno .uno:InsertAnnotation');
+ return true;
+ case 68: // d
+ this._map._socket.sendMessage('uno .uno:InsertEndnote');
+ return true;
}
}
@@ -391,45 +391,45 @@ L.Map.Keyboard = L.Handler.extend({
}
switch (e.originalEvent.keyCode) {
- case 51: // 3
- if (this._map.getDocType() === 'spreadsheet') {
- this._map._socket.sendMessage('uno .uno:SetOptimalColumnWidthDirect');
- this._map._socket.sendMessage('commandvalues command=.uno:ViewRowColumnHeaders');
- return true;
- }
- return false;
- case 53: // 5
- if (this._map.getDocType() === 'spreadsheet') {
- this._map._socket.sendMessage('uno .uno:Strikeout');
- return true;
- }
- return false;
- case 67: // c
- case 88: // x
- case 99: // c (Safari)
- case 120: // x (Safari)
- case 91: // Left Cmd (Safari)
- case 93: // Right Cmd (Safari)
- // we prepare for a copy or cut event
- this._map._docLayer._textArea.value = 'dummy text';
- this._map._docLayer._textArea.focus();
- this._map._docLayer._textArea.select();
- return true;
- case 80: // p
- this._map.print();
- return true;
- case 86: // v
- case 118: // v (Safari)
+ case 51: // 3
+ if (this._map.getDocType() === 'spreadsheet') {
+ this._map._socket.sendMessage('uno .uno:SetOptimalColumnWidthDirect');
+ this._map._socket.sendMessage('commandvalues command=.uno:ViewRowColumnHeaders');
return true;
- case 112: // f1
- this._map._socket.sendMessage('uno .uno:NoteVisible');
- return true;
- case 188: // ,
- this._map._socket.sendMessage('uno .uno:SubScript');
- return true;
- case 190: // .
- this._map._socket.sendMessage('uno .uno:SuperScript');
+ }
+ return false;
+ case 53: // 5
+ if (this._map.getDocType() === 'spreadsheet') {
+ this._map._socket.sendMessage('uno .uno:Strikeout');
return true;
+ }
+ return false;
+ case 67: // c
+ case 88: // x
+ case 99: // c (Safari)
+ case 120: // x (Safari)
+ case 91: // Left Cmd (Safari)
+ case 93: // Right Cmd (Safari)
+ // we prepare for a copy or cut event
+ this._map._docLayer._textArea.value = 'dummy text';
+ this._map._docLayer._textArea.focus();
+ this._map._docLayer._textArea.select();
+ return true;
+ case 80: // p
+ this._map.print();
+ return true;
+ case 86: // v
+ case 118: // v (Safari)
+ return true;
+ case 112: // f1
+ this._map._socket.sendMessage('uno .uno:NoteVisible');
+ return true;
+ case 188: // ,
+ this._map._socket.sendMessage('uno .uno:SubScript');
+ return true;
+ case 190: // .
+ this._map._socket.sendMessage('uno .uno:SuperScript');
+ return true;
}
if (e.type === 'keypress' && (e.originalEvent.ctrlKey || e.originalEvent.metaKey) &&
(e.originalEvent.key === 'c' || e.originalEvent.key === 'v' || e.originalEvent.key === 'x')) {
diff --git a/loleaflet/src/map/handler/Map.Scroll.js b/loleaflet/src/map/handler/Map.Scroll.js
index b07dec8..f7a98f3 100644
--- a/loleaflet/src/map/handler/Map.Scroll.js
+++ b/loleaflet/src/map/handler/Map.Scroll.js
@@ -45,8 +45,8 @@ L.Map.Scroll = L.Handler.extend({
_performScroll: function () {
var map = this._map,
- delta = -this._delta,
- scrollAmount = Math.round(map.getSize().y / 4);
+ delta = -this._delta,
+ scrollAmount = Math.round(map.getSize().y / 4);
this._delta = 0;
this._startTime = null;
commit 6e45f4fbfb54e08cc7511c2bda5ab2edb55fadca
Author: Pranav Kant <pranavk at collabora.com>
Date: Fri May 27 22:08:44 2016 +0530
loleaflet: Bump eslint version to 2.8.0
Adjust config file, .eslintrc, accordingly; remove deprecated
options
Change-Id: I113606c5d1fdc4c46216b1fa340c957fd0e69308
diff --git a/loleaflet/.eslintrc b/loleaflet/.eslintrc
index c6678be..d073b55 100644
--- a/loleaflet/.eslintrc
+++ b/loleaflet/.eslintrc
@@ -3,14 +3,12 @@
"camelcase": 2,
"quotes": [2, "single"],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
- "space-after-function-name": 2,
"space-in-parens": 2,
- "space-in-brackets": 2,
"space-before-blocks": 2,
- "space-after-keywords": 2,
+ "keyword-spacing": 2,
"no-lonely-if": 2,
"comma-style": 2,
- "indent": [2, "tab"],
+ "indent": [2, "tab", {"VariableDeclarator": 0}],
"no-underscore-dangle": 0,
"no-constant-condition": 0,
"no-multi-spaces": 0,
diff --git a/loleaflet/package.json b/loleaflet/package.json
index 9c423c4..883699c 100644
--- a/loleaflet/package.json
+++ b/loleaflet/package.json
@@ -4,7 +4,7 @@
"description": "JavaScript library for mobile-friendly interactive maps",
"devDependencies": {
"copyfiles": "0.1.0",
- "eslint": "^0.15.1",
+ "eslint": "^2.8.0",
"happen": "~0.1.3",
"jake": "~8.0.10",
"karma": "~0.12.31",
commit 3414ab2754c7e3b367be56c0739a41b0a0b02b90
Author: Pranav Kant <pranavk at collabora.com>
Date: Fri May 27 20:46:30 2016 +0530
loleaflet: linting: fix errors in toolbar.js
Such a huge confusing diff is mainly due to moving of functions from bottom
to top because a function should be defined before it is used.
Other changes include using single quotes for strings, and other
minor style fixes.
Change-Id: Ieb8e5054a9c8113ec211973e086111d91759f80b
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index b2b7eeb..eeb79d9 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -1,201 +1,73 @@
/*
* LibreOffice Online toolbar
*/
-$(function () {
- $('#toolbar-up-more').w2toolbar({
- name: 'toolbar-up-more',
- items: [
- ],
- onClick: function (e) {
- onClick(e.target);
- }
- });
-
- $('#toolbar-up').w2toolbar({
- name: 'toolbar-up',
- items: [
- { type: 'html', id: 'left' },
- { type: 'button', id: 'save', img: 'save', hint: _("Save"), uno: 'Save' },
- { type: 'break' },
- { type: 'button', id: 'undo', img: 'undo', hint: _("Undo"), uno: 'Undo' },
- { type: 'button', id: 'redo', img: 'redo', hint: _("Redo"), uno: 'Redo' },
- { type: 'break' },
- { type: 'html', id: 'styles', html: '<select class="styles-select"></select>' },
- { type: 'html', id: 'fonts', html: '<select class="fonts-select"></select>' },
- { type: 'html', id: 'fontsizes', html: '<select class="fontsizes-select"></select>' },
- { type: 'break' },
- { type: 'button', id: 'bold', img: 'bold', hint: _("Bold"), uno: 'Bold' },
- { type: 'button', id: 'italic', img: 'italic', hint: _("Italic"), uno: 'Italic' },
- { type: 'button', id: 'underline', img: 'underline', hint: _("Underline"), uno: 'Underline' },
- { type: 'button', id: 'strikeout', img: 'strikeout', hint: _("Strikeout"), uno: 'Strikeout' },
- { type: 'break' },
- { type: 'html', id: 'fontcolor-html', html: '<input id="fontColorPicker" style="display:none;">' },
- { type: 'button', id: 'fontcolor', img: 'color', hint: _("Font color") },
- { type: 'html', id: 'backcolor-html', html: '<input id="backColorPicker" style="display:none;">' },
- { type: 'button', id: 'backcolor', img: 'backcolor', hint: _("Highlighting") },
- { type: 'break' },
- { type: 'button', id: 'alignleft', img: 'alignleft', hint: _("Align left"), uno: 'LeftPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"1"}}' },
- { type: 'button', id: 'alignhorizontal', img: 'alignhorizontal', hint: _("Center horizontally"), uno: 'CenterPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"2"}}' },
- { type: 'button', id: 'alignright', img: 'alignright', hint: _("Align right"), uno: 'RightPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"3"}}' },
- { type: 'button', id: 'alignblock', img: 'alignblock', hint: _("Justified"), uno: 'JustifyPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"4"}}' },
- { type: 'break' },
- { type: 'button', id: 'bullet', img: 'bullet', hint: _("Bullets on/off"), uno: 'DefaultBullet' },
- { type: 'button', id: 'numbering', img: 'numbering', hint: _("Numbering on/off"), uno: 'DefaultNumbering' },
- { type: 'break' },
- { type: 'button', id: 'incrementindent', img: 'incrementindent', hint: _("Increase indent"), uno: 'IncrementIndent' },
- { type: 'button', id: 'decrementindent', img: 'decrementindent', hint: _("Decrease indent"), uno: 'DecrementIndent' },
- { type: 'break', id: 'incdecindent' },
- { type: 'html', id: 'inserttable-html', html: '<div id="inserttable-popup" class="inserttable-pop ui-widget ui-widget-content ui-corner-all" style="position: absolute; display: none;"><div class="inserttable-grid"></div><div id="inserttable-status" class="loleaflet-font" style="padding: 5px;"><br/></div>' },
- { type: 'button', id: 'inserttable', img: 'inserttable', hint: _("Insert table") },
- { type: 'button', id: 'annotation', img: 'annotation', hint: _("Insert comment"), uno: 'InsertAnnotation' },
- { type: 'button', id: 'insertgraphic', img: 'insertgraphic', hint: _("Insert graphic") },
- { type: 'break' },
- { type: 'button', id: 'help', img: 'help', hint: _("Help") },
- { type: 'html', id: 'right' },
- { type: 'button', id: 'more', img: 'more', hint: _("More") },
- { type: 'button', id: 'close', img: 'closedoc', hint: _("Close document"), hidden: true }
- ],
- onClick: function (e) {
- onClick(e.target);
- },
- onRefresh: function(e) {
- if (!L.DomUtil.get('fontcolorindicator')) {
- var fontColorIndicator = L.DomUtil.create('div', 'font-color-indicator', L.DomUtil.get('tb_toolbar-up_item_fontcolor'));
- fontColorIndicator.id = 'fontcolorindicator';
-
- $('#fontColorPicker').colorpicker({showOn:'none', hideButton:true});
- $("#fontColorPicker").on("change.color", onColorPick);
- }
-
- if (!L.DomUtil.get('backcolorindicator')) {
- var backColorIndicator = L.DomUtil.create('div', 'back-color-indicator', L.DomUtil.get('tb_toolbar-up_item_backcolor'));
- backColorIndicator.id = 'backcolorindicator';
- $('#backColorPicker').colorpicker({showOn:'none', hideButton:true});
- $("#backColorPicker").on("change.color", onColorPick);
- }
+/* global $ map closebutton w2ui vex _ */
- insertTable();
- }
- });
+function onDelete(e) {
+ if (e !== false) {
+ map.deletePage();
+ }
+}
- $('#formulabar').w2toolbar({
- name: 'formulabar',
- items: [
- { type: 'html', id: 'left' },
- { type: 'button', id: 'sum', img: 'autosum', hint: _("Sum") },
- { type: 'button', id: 'function', img: 'equal', hint: _("Function") },
- { type: 'button', hidden: true, id: 'cancelformula', img: 'cancel', hint: _("Cancel") },
- { type: 'button', hidden: true, id: 'acceptformula', img: 'accepttrackedchanges', hint: _("Accept") },
- { type: 'html', id: 'formula', html: '<input id="formulaInput" onkeyup="onFormulaInput()"' +
- 'onblur="onFormulaBarBlur()" onfocus="onFormulaBarFocus()" type=text>' }
- ],
- onClick: function (e) {
- onClick(e.target);
- }
- });
- $('#spreadsheet-toolbar').w2toolbar({
- name: 'spreadsheet-toolbar',
- items: [
- { type: 'button', id: 'firstrecord', img: 'firstrecord', hidden: true, hint: _("First sheet") },
- { type: 'button', id: 'prevrecord', img: 'prevrecord', hidden: true, hint: _("Previous sheet") },
- { type: 'button', id: 'nextrecord', img: 'nextrecord', hidden: true, hint: _("Next sheet") },
- { type: 'button', id: 'lastrecord', img: 'lastrecord', hidden: true, hint: _("Last sheet") }
- ],
- onClick: function (e) {
- onClick(e.target);
- }
- });
- $('#presentation-toolbar').w2toolbar({
- name: 'presentation-toolbar',
- items: [
- { type: 'html', id: 'left' },
- { type: 'button', id: 'presentation', img: 'presentation', hidden:true, hint: _("Fullscreen presentation") },
- { type: 'break', id: 'presentationbreak', hidden:true },
- { type: 'button', id: 'insertpage', img: 'insertpage', hidden:true, hint: _("Insert slide") },
- { type: 'button', id: 'duplicatepage', img: 'duplicatepage', hidden:true, hint: _("Duplicate slide") },
- { type: 'button', id: 'deletepage', img: 'deletepage', hidden:true, hint: _("Delete slide") },
- { type: 'html', id: 'right' }
- ],
- onClick: function (e) {
- onClick(e.target);
- }
- });
- $('#toolbar-down').w2toolbar({
- name: 'toolbar-down',
- items: [
- { type: 'html', id: 'search',
- html: '<div style="padding: 3px 10px;" class="loleaflet-font">'+
- ' ' + _("Search:") +
- ' <input size="10" id="search-input" onkeypress="onSearch(event)"' +
- 'style="padding: 3px; border-radius: 2px; border: 1px solid silver"/>'+
- '</div>'
- },
- { type: 'button', id: 'searchprev', img: 'prev', hint: _("Search backwards"), disabled: true },
- { type: 'button', id: 'searchnext', img: 'next', hint: _("Search forward"), disabled: true },
- { type: 'button', id: 'cancelsearch', img: 'cancel', hint: _("Cancel the search"), hidden: true },
- { type: 'html', id: 'left' },
- { type: 'html', id: 'right' },
- { type: 'html', id: 'modifiedstatuslabel', html: '<div id="modifiedstatuslabel" class="loleaflet-font"></div>' },
- { type: 'break' },
- { type: 'button', id: 'takeedit', img: 'edit', hint: _("Take edit lock (others can only view)"), caption: _('VIEWING')},
- { type: 'break' },
- { type: 'button', id: 'prev', img: 'prev', hint: _("Previous page") },
- { type: 'button', id: 'next', img: 'next', hint: _("Next page") },
- { type: 'break', id: 'prevnextbreak' },
- { type: 'button', id: 'zoomreset', img: 'zoomreset', hint: _("Reset zoom") },
- { type: 'button', id: 'zoomout', img: 'zoomout', hint: _("Zoom out") },
- { type: 'html', id: 'zoomlevel', html: '<div id="zoomlevel" class="loleaflet-font">100%</div>'},
- { type: 'button', id: 'zoomin', img: 'zoomin', hint: _("Zoom in") }
- ],
- onClick: function (e) {
- onClick(e.target);
+function resizeToolbar() {
+ var hasMoreItems = false;
+ var toolbarUp = w2ui['toolbar-up'];
+ var toolbarUpMore = w2ui['toolbar-up-more'];
+ // move items from toolbar-up-more -> toolbar-up
+ while ($('#toolbar-up')[0].scrollWidth <= $(window).width()) {
+ var item = toolbarUpMore.items[0];
+ if (!item) {
+ break;
}
- });
-});
-
-// This object is used to track enabled/disabled state when one is in view mode
-var formatButtons = {
- 'undo': true, 'redo': true, 'save': true,
- 'bold': true, 'italic': true, 'underline': true, 'strikeout': true,
- 'annotation': true, 'inserttable': true,
- 'fontcolor': true, 'backcolor': true, 'bullet': true, 'numbering': true,
- 'alignleft': true, 'alignhorizontal': true, 'alignright': true, 'alignblock': true,
- 'incrementindent': true, 'decrementindent': true, 'insertgraphic': true
-};
+ toolbarUpMore.items.shift();
+ toolbarUp.insert('right', item);
+ }
-var takeEditPopupMessage = '<div>' + _("You are viewing now.") + '<br/>' + _("Click here to take edit.") + '</div>';
-var takeEditPopupTimeout = null;
+ // move items from toolbar-up -> toolbar-up-more
+ while ($('#toolbar-up')[0].scrollWidth > Math.max($(window).width(), parseInt($('body').css('min-width')))) {
+ var itemId = toolbarUp.items[toolbarUp.items.length - 4].id;
+ item = toolbarUp.get(itemId);
+ toolbarUp.remove(itemId);
+ toolbarUpMore.insert(toolbarUpMore.items[0], item);
+ hasMoreItems = true;
+ }
-function onSearch(e) {
- if (e.keyCode === 13) {
- var toolbar = w2ui['toolbar-down'];
- map.search(L.DomUtil.get('search-input').value);
- toolbar.enable('searchprev');
- toolbar.enable('searchnext');
- toolbar.show('cancelsearch');
+ if (hasMoreItems) {
+ w2ui['toolbar-up'].show('more');
}
else {
- map.fire('requestloksession');
+ w2ui['toolbar-up'].hide('more');
+ }
+
+ // resize toolbar-up-more
+ var lastItem = $('#toolbar-up-more>table>tbody>tr>td[valign="middle"]').last();
+ if (lastItem.length) {
+ $('#toolbar-up-more').width($(lastItem).position().left + $(lastItem).width());
+ w2ui['toolbar-up-more'].render();
+ } else {
+ $('#toolbar-up-more').hide();
+ var toolbar = w2ui['toolbar-up'];
+ toolbar.uncheck('more');
}
}
function onClick(id) {
if (w2ui['toolbar-up'].get(id) !== null) {
var toolbar = w2ui['toolbar-up'];
- var item = toolbar.get(id) ;
+ var item = toolbar.get(id);
}
- else if (w2ui['formulabar'].get(id) !== null) {
- toolbar = w2ui['formulabar'];
- item = toolbar.get(id) ;
+ else if (w2ui.formulabar.get(id) !== null) {
+ toolbar = w2ui.formulabar;
+ item = toolbar.get(id);
}
else if (w2ui['toolbar-down'].get(id) !== null) {
toolbar = w2ui['toolbar-down'];
- item = toolbar.get(id) ;
+ item = toolbar.get(id);
}
else if (w2ui['spreadsheet-toolbar'].get(id) !== null) {
toolbar = w2ui['spreadsheet-toolbar'];
- item = toolbar.get(id) ;
+ item = toolbar.get(id);
}
else if (w2ui['presentation-toolbar'].get(id) !== null) {
toolbar = w2ui['presentation-toolbar'];
@@ -269,7 +141,7 @@ function onClick(id) {
}
else if (id === 'deletepage') {
vex.dialog.confirm({
- message: _("Are you sure you want to delete this page?"),
+ message: _('Are you sure you want to delete this page?'),
callback: onDelete
});
}
@@ -278,13 +150,13 @@ function onClick(id) {
}
// TODO: We should get visible tab's width instead of 60px
else if (id === 'nextrecord') {
- $('#spreadsheet-tab-scroll').scrollLeft($('#spreadsheet-tab-scroll').scrollLeft()+60);
+ $('#spreadsheet-tab-scroll').scrollLeft($('#spreadsheet-tab-scroll').scrollLeft() + 60);
}
else if (id === 'prevrecord') {
- $('#spreadsheet-tab-scroll').scrollLeft($('#spreadsheet-tab-scroll').scrollLeft()-60);
+ $('#spreadsheet-tab-scroll').scrollLeft($('#spreadsheet-tab-scroll').scrollLeft() - 60);
}
else if (id === 'lastrecord') {
- $('#spreadsheet-tab-scroll').scrollLeft($('#spreadsheet-tab-scroll').prop("scrollWidth"));
+ $('#spreadsheet-tab-scroll').scrollLeft($('#spreadsheet-tab-scroll').prop('scrollWidth'));
}
else if (id === 'insertgraphic') {
L.DomUtil.get('insertgraphic').click();
@@ -295,12 +167,12 @@ function onClick(id) {
else if (id === 'fontcolor') {
// absolutely no idea why, but without the timeout, the popup is
// closed as soon as it is opend
- setTimeout(function () {$('#fontColorPicker').colorpicker('showPalette')}, 0);
+ setTimeout(function () {$('#fontColorPicker').colorpicker('showPalette');}, 0);
}
else if (id === 'backcolor') {
// absolutely no idea why, but without the timeout, the popup is
// closed as soon as it is opend
- setTimeout(function () {$('#backColorPicker').colorpicker('showPalette')}, 0);
+ setTimeout(function () {$('#backColorPicker').colorpicker('showPalette');}, 0);
}
else if (id === 'sum') {
L.DomUtil.get('formulaInput').value = '=SUM()';
@@ -337,13 +209,13 @@ function onClick(id) {
overlayClose:true,
opacity: 80,
overlayCss: {
- backgroundColor : "#000"
+ backgroundColor : '#000'
},
containerCss: {
- overflow : "hidden",
- backgroundColor : "#fff",
- padding : "20px",
- border : "2px solid #000"
+ overflow : 'hidden',
+ backgroundColor : '#fff',
+ padding : '20px',
+ border : '2px solid #000'
}
});
}
@@ -353,19 +225,295 @@ function onClick(id) {
}
}
-function onDelete (e) {
- if (e !== false) {
- map.deletePage();
+function insertTable() {
+ var rows = 10;
+ var cols = 10;
+ var $grid = $('.inserttable-grid');
+ var $popup = $('#inserttable-popup');
+ var $status = $('#inserttable-status');
+
+ // Return if already initialized
+ if ($grid.children().length) {
+ return;
+ }
+
+ // init
+ for (var r = 0; r < rows; r++) {
+ var $row = $('<div/>').addClass('row');
+ $grid.append($row);
+ for (var c = 0; c < cols; c++) {
+ var $col = $('<div/>').addClass('col');
+ $row.append($col);
+ }
}
+
+ // events
+ $grid.on({
+ mouseover: function () {
+ var col = $(this).index() + 1;
+ var row = $(this).parent().index() + 1;
+ $('.col').removeClass('bright');
+ $('.row:nth-child(-n+' + row + ') .col:nth-child(-n+' + col + ')')
+ .addClass('bright');
+ $status.html(col + 'x' + row);
+
+ },
+ click: function() {
+ var col = $(this).index() + 1;
+ var row = $(this).parent().index() + 1;
+ $popup.toggle();
+ $('.col').removeClass('bright');
+ $status.html('<br/>');
+ var msg = 'uno .uno:InsertTable {' +
+ ' "Columns": { "type": "long","value": '
+ + col +
+ ' }, "Rows": { "type": "long","value": '
+ + row + ' }}';
+ map._socket.sendMessage(msg);
+ }
+ }, '.col');
+
+ // close dialog on mouseleave
+ $popup.mouseleave(function() {
+ $(this).hide();
+ $('.col').removeClass('bright');
+ $status.html('<br/>');
+ });
}
-function onSaveAs (e) {
+function onColorPick(e, color) {
+ if (map.getPermission() !== 'edit' || color === undefined) {
+ return;
+ }
+ // transform from #FFFFFF to an Int
+ color = parseInt(color.replace('#', ''), 16);
+ var command = {};
+ var fontcolor, backcolor;
+ if (e.target.id === 'fontColorPicker') {
+ fontcolor = {'text': 'FontColor',
+ 'spreadsheet': 'Color',
+ 'presentation': 'Color'}[map.getDocType()];
+ command[fontcolor] = {};
+ command[fontcolor].type = 'long';
+ command[fontcolor].value = color;
+ var uno = '.uno:' + fontcolor;
+ }
+ else if (e.target.id === 'backColorPicker') {
+ backcolor = {'text': 'BackColor',
+ 'spreadsheet': 'BackgroundColor',
+ 'presentation': 'CharBackColor'}[map.getDocType()];
+ command[backcolor] = {};
+ command[backcolor].type = 'long';
+ command[backcolor].value = color;
+ uno = '.uno:' + backcolor;
+ }
+ map.sendUnoCommand(uno, command);
+ map.focus();
+}
+
+$(function () {
+ $('#toolbar-up-more').w2toolbar({
+ name: 'toolbar-up-more',
+ items: [
+ ],
+ onClick: function (e) {
+ onClick(e.target);
+ }
+ });
+
+ $('#toolbar-up').w2toolbar({
+ name: 'toolbar-up',
+ items: [
+ {type: 'html', id: 'left'},
+ {type: 'button', id: 'save', img: 'save', hint: _('Save'), uno: 'Save'},
+ {type: 'break'},
+ {type: 'button', id: 'undo', img: 'undo', hint: _('Undo'), uno: 'Undo'},
+ {type: 'button', id: 'redo', img: 'redo', hint: _('Redo'), uno: 'Redo'},
+ {type: 'break'},
+ {type: 'html', id: 'styles', html: '<select class="styles-select"></select>'},
+ {type: 'html', id: 'fonts', html: '<select class="fonts-select"></select>'},
+ {type: 'html', id: 'fontsizes', html: '<select class="fontsizes-select"></select>'},
+ {type: 'break'},
+ {type: 'button', id: 'bold', img: 'bold', hint: _('Bold'), uno: 'Bold'},
+ {type: 'button', id: 'italic', img: 'italic', hint: _('Italic'), uno: 'Italic'},
+ {type: 'button', id: 'underline', img: 'underline', hint: _('Underline'), uno: 'Underline'},
+ {type: 'button', id: 'strikeout', img: 'strikeout', hint: _('Strikeout'), uno: 'Strikeout'},
+ {type: 'break'},
+ {type: 'html', id: 'fontcolor-html', html: '<input id="fontColorPicker" style="display:none;">'},
+ {type: 'button', id: 'fontcolor', img: 'color', hint: _('Font color')},
+ {type: 'html', id: 'backcolor-html', html: '<input id="backColorPicker" style="display:none;">'},
+ {type: 'button', id: 'backcolor', img: 'backcolor', hint: _('Highlighting')},
+ {type: 'break'},
+ {type: 'button', id: 'alignleft', img: 'alignleft', hint: _('Align left'), uno: 'LeftPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"1"}}'},
+ {type: 'button', id: 'alignhorizontal', img: 'alignhorizontal', hint: _('Center horizontally'), uno: 'CenterPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"2"}}'},
+ {type: 'button', id: 'alignright', img: 'alignright', hint: _('Align right'), uno: 'RightPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"3"}}'},
+ {type: 'button', id: 'alignblock', img: 'alignblock', hint: _('Justified'), uno: 'JustifyPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"4"}}'},
+ {type: 'break'},
+ {type: 'button', id: 'bullet', img: 'bullet', hint: _('Bullets on/off'), uno: 'DefaultBullet'},
+ {type: 'button', id: 'numbering', img: 'numbering', hint: _('Numbering on/off'), uno: 'DefaultNumbering'},
+ {type: 'break'},
+ {type: 'button', id: 'incrementindent', img: 'incrementindent', hint: _('Increase indent'), uno: 'IncrementIndent'},
+ {type: 'button', id: 'decrementindent', img: 'decrementindent', hint: _('Decrease indent'), uno: 'DecrementIndent'},
+ {type: 'break', id: 'incdecindent'},
+ {type: 'html', id: 'inserttable-html', html: '<div id="inserttable-popup" class="inserttable-pop ui-widget ui-widget-content ui-corner-all" style="position: absolute; display: none;"><div class="inserttable-grid"></div><div id="inserttable-status" class="loleaflet-font" style="padding: 5px;"><br/></div>'},
+ {type: 'button', id: 'inserttable', img: 'inserttable', hint: _('Insert table')},
+ {type: 'button', id: 'annotation', img: 'annotation', hint: _('Insert comment'), uno: 'InsertAnnotation'},
+ {type: 'button', id: 'insertgraphic', img: 'insertgraphic', hint: _('Insert graphic')},
+ {type: 'break'},
+ {type: 'button', id: 'help', img: 'help', hint: _('Help')},
+ {type: 'html', id: 'right'},
+ {type: 'button', id: 'more', img: 'more', hint: _('More')},
+ {type: 'button', id: 'close', img: 'closedoc', hint: _('Close document'), hidden: true}
+ ],
+ onClick: function (e) {
+ onClick(e.target);
+ },
+ onRefresh: function() {
+ if (!L.DomUtil.get('fontcolorindicator')) {
+ var fontColorIndicator = L.DomUtil.create('div', 'font-color-indicator', L.DomUtil.get('tb_toolbar-up_item_fontcolor'));
+ fontColorIndicator.id = 'fontcolorindicator';
+
+ $('#fontColorPicker').colorpicker({showOn:'none', hideButton:true});
+ $('#fontColorPicker').on('change.color', onColorPick);
+ }
+
+ if (!L.DomUtil.get('backcolorindicator')) {
+ var backColorIndicator = L.DomUtil.create('div', 'back-color-indicator', L.DomUtil.get('tb_toolbar-up_item_backcolor'));
+ backColorIndicator.id = 'backcolorindicator';
+
+ $('#backColorPicker').colorpicker({showOn:'none', hideButton:true});
+ $('#backColorPicker').on('change.color', onColorPick);
+ }
+
+ insertTable();
+ }
+ });
+
+ $('#formulabar').w2toolbar({
+ name: 'formulabar',
+ items: [
+ {type: 'html', id: 'left'},
+ {type: 'button', id: 'sum', img: 'autosum', hint: _('Sum')},
+ {type: 'button', id: 'function', img: 'equal', hint: _('Function')},
+ {type: 'button', hidden: true, id: 'cancelformula', img: 'cancel', hint: _('Cancel')},
+ {type: 'button', hidden: true, id: 'acceptformula', img: 'accepttrackedchanges', hint: _('Accept')},
+ {type: 'html', id: 'formula', html: '<input id="formulaInput" onkeyup="onFormulaInput()"' +
+ 'onblur="onFormulaBarBlur()" onfocus="onFormulaBarFocus()" type=text>'}
+ ],
+ onClick: function (e) {
+ onClick(e.target);
+ }
+ });
+ $('#spreadsheet-toolbar').w2toolbar({
+ name: 'spreadsheet-toolbar',
+ items: [
+ {type: 'button', id: 'firstrecord', img: 'firstrecord', hidden: true, hint: _('First sheet')},
+ {type: 'button', id: 'prevrecord', img: 'prevrecord', hidden: true, hint: _('Previous sheet')},
+ {type: 'button', id: 'nextrecord', img: 'nextrecord', hidden: true, hint: _('Next sheet')},
+ {type: 'button', id: 'lastrecord', img: 'lastrecord', hidden: true, hint: _('Last sheet')}
+ ],
+ onClick: function (e) {
+ onClick(e.target);
+ }
+ });
+ $('#presentation-toolbar').w2toolbar({
+ name: 'presentation-toolbar',
+ items: [
+ {type: 'html', id: 'left'},
+ {type: 'button', id: 'presentation', img: 'presentation', hidden:true, hint: _('Fullscreen presentation')},
+ {type: 'break', id: 'presentationbreak', hidden:true},
+ {type: 'button', id: 'insertpage', img: 'insertpage', hidden:true, hint: _('Insert slide')},
+ {type: 'button', id: 'duplicatepage', img: 'duplicatepage', hidden:true, hint: _('Duplicate slide')},
+ {type: 'button', id: 'deletepage', img: 'deletepage', hidden:true, hint: _('Delete slide')},
+ {type: 'html', id: 'right'}
+ ],
+ onClick: function (e) {
+ onClick(e.target);
+ }
+ });
+ $('#toolbar-down').w2toolbar({
+ name: 'toolbar-down',
+ items: [
+ {type: 'html', id: 'search',
+ html: '<div style="padding: 3px 10px;" class="loleaflet-font">' +
+ ' ' + _('Search:') +
+ ' <input size="10" id="search-input" onkeypress="onSearch(event)"' +
+ 'style="padding: 3px; border-radius: 2px; border: 1px solid silver"/>' +
+ '</div>'
+ },
+ {type: 'button', id: 'searchprev', img: 'prev', hint: _('Search backwards'), disabled: true},
+ {type: 'button', id: 'searchnext', img: 'next', hint: _('Search forward'), disabled: true},
+ {type: 'button', id: 'cancelsearch', img: 'cancel', hint: _('Cancel the search'), hidden: true},
+ {type: 'html', id: 'left'},
+ {type: 'html', id: 'right'},
+ {type: 'html', id: 'modifiedstatuslabel', html: '<div id="modifiedstatuslabel" class="loleaflet-font"></div>'},
+ {type: 'break'},
+ {type: 'button', id: 'takeedit', img: 'edit', hint: _('Take edit lock (others can only view)'), caption: _('VIEWING')},
+ {type: 'break'},
+ {type: 'button', id: 'prev', img: 'prev', hint: _('Previous page')},
+ {type: 'button', id: 'next', img: 'next', hint: _('Next page')},
+ {type: 'break', id: 'prevnextbreak'},
+ {type: 'button', id: 'zoomreset', img: 'zoomreset', hint: _('Reset zoom')},
+ {type: 'button', id: 'zoomout', img: 'zoomout', hint: _('Zoom out')},
+ {type: 'html', id: 'zoomlevel', html: '<div id="zoomlevel" class="loleaflet-font">100%</div>'},
+ {type: 'button', id: 'zoomin', img: 'zoomin', hint: _('Zoom in')}
+ ],
+ onClick: function (e) {
+ onClick(e.target);
+ }
+ });
+});
+
+// This object is used to track enabled/disabled state when one is in view mode
+var formatButtons = {
+ 'undo': true, 'redo': true, 'save': true,
+ 'bold': true, 'italic': true, 'underline': true, 'strikeout': true,
+ 'annotation': true, 'inserttable': true,
+ 'fontcolor': true, 'backcolor': true, 'bullet': true, 'numbering': true,
+ 'alignleft': true, 'alignhorizontal': true, 'alignright': true, 'alignblock': true,
+ 'incrementindent': true, 'decrementindent': true, 'insertgraphic': true
+};
+
+var takeEditPopupMessage = '<div>' + _('You are viewing now.') + '<br/>' + _('Click here to take edit.') + '</div>';
+var takeEditPopupTimeout = null;
+
+function onSearch(e) {
+ if (e.keyCode === 13) {
+ var toolbar = w2ui['toolbar-down'];
+ map.search(L.DomUtil.get('search-input').value);
+ toolbar.enable('searchprev');
+ toolbar.enable('searchnext');
+ toolbar.show('cancelsearch');
+ }
+ else {
+ map.fire('requestloksession');
+ }
+}
+
+function onSaveAs(e) {
if (e !== false) {
map.saveAs(e.url, e.format, e.options);
}
}
-function onStyleSelect (e) {
+function sortFontSizes() {
+ var oldVal = $('.fontsizes-select').val();
+ var selectList = $('.fontsizes-select option');
+ selectList.sort(function (a, b) {
+ a = parseFloat($(a).text() * 1);
+ b = parseFloat($(b).text() * 1);
+ if (a > b) {
+ return 1;
+ } else if (a < b) {
+ return -1;
+ }
+ return 0;
+ });
+ $('.fontsizes-select').html(selectList);
+ $('.fontsizes-select').val(oldVal).trigger('change');
+}
+
+function onStyleSelect(e) {
var style = e.target.value;
if (style.startsWith('.uno:')) {
map.sendUnoCommand(style);
@@ -382,28 +530,28 @@ function onStyleSelect (e) {
map.focus();
}
-function updateFontSizeList (font) {
- var oldSize = $(".fontsizes-select").val();
+function updateFontSizeList(font) {
+ var oldSize = $('.fontsizes-select').val();
var found = false;
- $(".fontsizes-select").find('option').remove();
+ $('.fontsizes-select').find('option').remove();
var data = [''];
data = data.concat(map.getToolbarCommandValues('.uno:CharFontName')[font]);
- $(".fontsizes-select").select2({
+ $('.fontsizes-select').select2({
data: data,
- placeholder: _("Size"),
+ placeholder: _('Size'),
//Allow manually entered font size.
- createTag:function(query) {
+ createTag: function(query) {
return {
id: query.term,
text: query.term,
tag: true
- }
+ };
},
- tags: true,
+ tags: true
});
- $(".fontsizes-select option").each(function (i, e) {
- if ($(e).text() == oldSize) {
- $(".fontsizes-select").val(oldSize).trigger('change');
+ $('.fontsizes-select option').each(function (i, e) {
+ if ($(e).text() === oldSize) {
+ $('.fontsizes-select').val(oldSize).trigger('change');
found = true;
return;
}
@@ -411,48 +559,31 @@ function updateFontSizeList (font) {
if (!found) {
// we need to add the size
$('.fontsizes-select')
- .append($("<option></option>")
+ .append($('<option></option>')
.text(oldSize));
}
- $(".fontsizes-select").val(oldSize).trigger('change');
+ $('.fontsizes-select').val(oldSize).trigger('change');
sortFontSizes();
}
-function sortFontSizes() {
- var oldVal = $('.fontsizes-select').val();
- var selectList = $('.fontsizes-select option');
- selectList.sort(function (a,b){
- a = parseFloat($(a).text() * 1);
- b = parseFloat($(b).text() * 1);
- if(a > b) {
- return 1;
- } else if (a < b) {
- return -1;
- }
- return 0;
- });
- $('.fontsizes-select').html(selectList);
- $('.fontsizes-select').val(oldVal).trigger('change');
-}
-
-function onFontSelect (e) {
+function onFontSelect(e) {
var font = e.target.value;
updateFontSizeList(font);
map.applyFont(font);
map.focus();
}
-function onFontSizeSelect (e) {
+function onFontSizeSelect(e) {
var size = e.target.value;
var command = {};
$(e.target).find('option[data-select2-tag]').removeAttr('data-select2-tag');
map.applyFontSize(size);
- fontcolor = map.getDocType() === 'text' ? 'FontColor' : 'Color';
+ var fontcolor = map.getDocType() === 'text' ? 'FontColor' : 'Color';
command[fontcolor] = {};
map.focus();
}
-function onInsertFile () {
+function onInsertFile() {
var insertGraphic = L.DomUtil.get('insertgraphic');
if ('files' in insertGraphic) {
for (var i = 0; i < insertGraphic.files.length; i++) {
@@ -462,41 +593,12 @@ function onInsertFile () {
}
}
-function onColorPick (e, color) {
- if (map.getPermission() !== 'edit' || color === undefined) {
- return;
- }
- // transform from #FFFFFF to an Int
- color = parseInt(color.replace('#', ''), 16);
- var command = {};
- if (e.target.id === 'fontColorPicker') {
- fontcolor = { 'text': 'FontColor',
- 'spreadsheet': 'Color',
- 'presentation': 'Color' }[map.getDocType()];
- command[fontcolor] = {};
- command[fontcolor].type = 'long';
- command[fontcolor].value = color;
- var uno = '.uno:' + fontcolor;
- }
- else if (e.target.id === 'backColorPicker') {
- backcolor = { 'text': 'BackColor',
- 'spreadsheet': 'BackgroundColor',
- 'presentation': 'CharBackColor' }[map.getDocType()];
- command[backcolor] = {};
- command[backcolor].type = 'long';
- command[backcolor].value = color;
- uno = '.uno:' + backcolor;
- }
- map.sendUnoCommand(uno, command);
- map.focus();
-}
-
-function onFormulaInput () {
+function onFormulaInput() {
map.cellEnterString(L.DomUtil.get('formulaInput').value);
}
-function onFormulaBarFocus () {
- var formulabar = w2ui['formulabar'];
+function onFormulaBarFocus() {
+ var formulabar = w2ui.formulabar;
formulabar.hide('sum');
formulabar.hide('function');
formulabar.show('cancelformula');
@@ -504,14 +606,14 @@ function onFormulaBarFocus () {
}
function onFormulaBarBlur() {
- var formulabar = w2ui['formulabar'];
+ var formulabar = w2ui.formulabar;
formulabar.show('sum');
formulabar.show('function');
formulabar.hide('cancelformula');
formulabar.hide('acceptformula');
}
-map.on('updatepermission', function (e) {
+map.on('updatepermission', function () {
var toolbar = w2ui['toolbar-up'];
var docType = map.getDocType();
if (docType !== 'text') {
@@ -542,12 +644,13 @@ map.on('commandstatechanged', function (e) {
var commandName = e.commandName;
var state = e.state;
var found = false;
+ var value, color, div;
if (commandName === '.uno:AssignLayout') {
- $(".styles-select").val(state).trigger('change');
- }
- else if (commandName === '.uno:StyleApply') {
- if (!state)
+ $('.styles-select').val(state).trigger('change');
+ } else if (commandName === '.uno:StyleApply') {
+ if (!state) {
return;
+ }
// For impress documents, template name is prefixed with style name.
// Strip the template name until we support it
@@ -556,8 +659,8 @@ map.on('commandstatechanged', function (e) {
state = L.Styles.impressMapping[state];
}
- $(".styles-select option").each(function () {
- value = this.value;
+ $('.styles-select option').each(function () {
+ var value = this.value;
// For writer we get UI names; ideally we should be getting only programmatic ones
// For eg: 'Text body' vs 'Text Body'
// (likely to be fixed in core to make the pattern consistent)
@@ -570,13 +673,13 @@ map.on('commandstatechanged', function (e) {
if (!found) {
// we need to add the size
$('.styles-select')
- .append($("<option></option>")
+ .append($('<option></option>')
.text(state));
}
- $(".styles-select").val(state).trigger('change');
+ $('.styles-select').val(state).trigger('change');
}
else if (commandName === '.uno:CharFontName') {
- $(".fonts-select option").each(function () {
+ $('.fonts-select option').each(function () {
value = this.value;
if (value.toLowerCase() === state.toLowerCase()) {
found = true;
@@ -587,17 +690,17 @@ map.on('commandstatechanged', function (e) {
if (!found) {
// we need to add the size
$('.fonts-select')
- .append($("<option></option>")
+ .append($('<option></option>')
.text(state));
}
- $(".fonts-select").val(state).trigger('change');
+ $('.fonts-select').val(state).trigger('change');
}
else if (commandName === '.uno:FontHeight') {
if (state === '0') {
state = '';
}
- $(".fontsizes-select option").each(function (i, e) {
- if ($(e).text() == state) {
+ $('.fontsizes-select option').each(function (i, e) {
+ if ($(e).text() === state) {
found = true;
return;
}
@@ -605,15 +708,15 @@ map.on('commandstatechanged', function (e) {
if (!found) {
// we need to add the size
$('.fontsizes-select')
- .append($("<option></option>")
+ .append($('<option></option>')
.text(state).val(state));
}
- $(".fontsizes-select").val(state).trigger('change');
+ $('.fontsizes-select').val(state).trigger('change');
sortFontSizes();
}
else if (commandName === '.uno:FontColor' || commandName === '.uno:Color') {
// confusingly, the .uno: command is named differently in Writer, Calc and Impress
- var color = parseInt(e.state);
+ color = parseInt(e.state);
if (color === -1) {
color = 'transparent';
}
@@ -622,12 +725,12 @@ map.on('commandstatechanged', function (e) {
color = color.toString(16);
color = '#' + '0'.repeat(6 - color.length) + color;
}
- var div = L.DomUtil.get('fontcolorindicator');
+ div = L.DomUtil.get('fontcolorindicator');
L.DomUtil.setStyle(div, 'background', color);
}
else if (commandName === '.uno:BackColor' || commandName === '.uno:BackgroundColor' || commandName === '.uno:CharBackColor') {
// confusingly, the .uno: command is named differently in Writer, Calc and Impress
- var color = parseInt(e.state);
+ color = parseInt(e.state);
if (color === -1) {
color = 'transparent';
}
@@ -635,7 +738,7 @@ map.on('commandstatechanged', function (e) {
color = color.toString(16);
color = '#' + '0'.repeat(6 - color.length) + color;
}
- var div = L.DomUtil.get('backcolorindicator');
+ div = L.DomUtil.get('backcolorindicator');
L.DomUtil.setStyle(div, 'background', color);
}
else if (commandName === '.uno:ModifiedStatus') {
@@ -693,7 +796,9 @@ map.on('search', function (e) {
toolbar.disable('searchnext');
toolbar.hide('cancelsearch');
L.DomUtil.addClass(searchInput, 'search-not-found');
- setTimeout(function () {L.DomUtil.removeClass(searchInput, 'search-not-found')}, 500);
+ setTimeout(function () {
+ L.DomUtil.removeClass(searchInput, 'search-not-found');
+ }, 500);
}
});
@@ -751,11 +856,11 @@ map.on('updatetoolbarcommandvalues', function (e) {
}, this);
}
- $(".styles-select").select2({
+ $('.styles-select').select2({
data: data,
- placeholder: _("Style")
+ placeholder: _('Style')
});
- $(".styles-select").on('select2:select', onStyleSelect);
+ $('.styles-select').on('select2:select', onStyleSelect);
}
else if (e.commandName === '.uno:CharFontName') {
// Old browsers like IE11 et al don't like Object.keys with
@@ -763,17 +868,17 @@ map.on('updatetoolbarcommandvalues', function (e) {
if (typeof e.commandValues === 'object') {
data = data.concat(Object.keys(e.commandValues));
}
- $(".fonts-select").select2({
+ $('.fonts-select').select2({
data: data,
- placeholder: _("Font")
+ placeholder: _('Font')
});
- $(".fonts-select").on('select2:select', onFontSelect);
+ $('.fonts-select').on('select2:select', onFontSelect);
- $(".fontsizes-select").select2({
- placeholder: _("Size"),
+ $('.fontsizes-select').select2({
+ placeholder: _('Size'),
data: []
});
- $(".fontsizes-select").on('select2:select', onFontSizeSelect);
+ $('.fontsizes-select').on('select2:select', onFontSizeSelect);
}
});
@@ -821,7 +926,7 @@ map.on('updateparts pagenumberchanged', function (e) {
}
toolbar = w2ui['toolbar-up'];
- if (e.docType !== 'text' && e.docType !== 'spreadsheet' ) {
+ if (e.docType !== 'text' && e.docType !== 'spreadsheet') {
toolbar.hide('incrementindent');
toolbar.hide('decrementindent');
toolbar.hide('incdecindent');
@@ -838,11 +943,10 @@ map.on('updateparts pagenumberchanged', function (e) {
map.on('commandresult', function (e) {
var commandName = e.commandName;
- var success = e.success;
- if (commandName === '.uno:Save' && e.success == true) {
+ if (commandName === '.uno:Save' && e.success === true) {
// owncloud integration
- if (typeof window.parent.documentsMain != 'undefined') {
+ if (typeof window.parent.documentsMain !== 'undefined') {
window.parent.documentsMain.saveDocumentBack();
}
}
@@ -855,10 +959,10 @@ map.on('cellformula', function (e) {
}
});
-map.on('zoomend', function (e) {
- var _zoom_ratio = map.getZoomScale(map.getZoom(), map.options.zoom);
- var _zoom_percent = Math.round(_zoom_ratio * 100);
- $('#zoomlevel').html(_zoom_percent + '%');
+map.on('zoomend', function () {
+ var zoomRatio = map.getZoomScale(map.getZoom(), map.options.zoom);
+ var zoomPercent = Math.round(zoomRatio * 100);
+ $('#zoomlevel').html(zoomPercent + '%');
});
map.on('hyperlinkclicked', function (e) {
@@ -915,7 +1019,7 @@ map.on('editlock', function (e) {
// Enable formula bar
$('#formulaInput').prop('disabled', false);
- toolbar = w2ui['formulabar'];
+ toolbar = w2ui.formulabar;
formulaBarButtons.forEach(function(id) {
toolbar.enable(id);
});
@@ -945,7 +1049,7 @@ map.on('editlock', function (e) {
// Disable formula bar
$('#formulaInput').prop('disabled', true);
- toolbar = w2ui['formulabar'];
+ toolbar = w2ui.formulabar;
formulaBarButtons.forEach(function(id) {
toolbar.disable(id);
});
@@ -969,7 +1073,7 @@ map.on('editlock', function (e) {
});
-map.on('mouseup keypress', function(e) {
+map.on('mouseup keypress', function() {
if (!map._editlock) {
$('#tb_toolbar-down_item_takeedit')
.w2overlay({
@@ -985,7 +1089,7 @@ map.on('mouseup keypress', function(e) {
}
});
-map.on('locontextmenu', function (e) {
+map.on('locontextmenu', function () {
// TODO: context menu handling...
});
@@ -1000,11 +1104,11 @@ map.on('statusindicator', function (e) {
data = data.concat({id: layout.id, text: _(layout.text)});
}, this);
- $(".styles-select").select2({
+ $('.styles-select').select2({
data: data,
- placeholder: _("Layout")
+ placeholder: _('Layout')
});
- $(".styles-select").on('select2:select', onStyleSelect);
+ $('.styles-select').on('select2:select', onStyleSelect);
}
}
});
@@ -1019,103 +1123,4 @@ $(document).ready(function() {
if (closebutton) {
toolbar.show('close');
}
- inserttable();
});
-
-function resizeToolbar() {
- var has_more_items = false;
- var toolbarUp = w2ui['toolbar-up'];
- var toolbarUpMore = w2ui['toolbar-up-more'];
- // move items from toolbar-up-more -> toolbar-up
- while ($('#toolbar-up')[0].scrollWidth <= $(window).width()) {
- var item = toolbarUpMore.items[0];
- if (!item) {
- break;
- }
- toolbarUpMore.items.shift();
- toolbarUp.insert('right', item);
- }
-
- // move items from toolbar-up -> toolbar-up-more
- while ($('#toolbar-up')[0].scrollWidth > Math.max($(window).width(), parseInt($('body').css('min-width')))) {
- var itemId = toolbarUp.items[toolbarUp.items.length - 4].id;
- item = toolbarUp.get(itemId);
- toolbarUp.remove(itemId);
- toolbarUpMore.insert(toolbarUpMore.items[0], item);
- has_more_items = true;
- }
-
- if (has_more_items) {
- w2ui['toolbar-up'].show('more');
- }
- else {
- w2ui['toolbar-up'].hide('more');
- }
-
- // resize toolbar-up-more
- var lastItem = $('#toolbar-up-more>table>tbody>tr>td[valign="middle"]').last();
- if (lastItem.length) {
- $('#toolbar-up-more').width($(lastItem).position().left + $(lastItem).width());
- w2ui['toolbar-up-more'].render();
- } else {
- $('#toolbar-up-more').hide();
- var toolbar = w2ui['toolbar-up'];
- toolbar.uncheck('more');
- }
-}
-
-function insertTable() {
- var rows = 10;
- var cols = 10;
- var $grid = $('.inserttable-grid');
- var $popup = $('#inserttable-popup');
- var $status = $("#inserttable-status");
-
- // Return if already initialized
- if ($grid.children().length) {
- return;
- }
-
- // init
- for (var r = 0; r < rows; r++) {
- var $row = $('<div/>').addClass('row');
- $grid.append($row);
- for (var c = 0; c < cols; c++) {
- var $col = $('<div/>').addClass('col');
- $row.append($col);
- }
- }
-
- // events
- $grid.on({
- mouseover: function () {
- var col = $(this).index() + 1;
- var row = $(this).parent().index() + 1;
- $('.col').removeClass('bright');
- $('.row:nth-child(-n+' + row + ') .col:nth-child(-n+' + col + ')')
- .addClass('bright');
- $status.html(col + " x " + row);
-
- },
- click: function(){
- var col = $(this).index() + 1;
- var row = $(this).parent().index() + 1;
- $popup.toggle();
- $('.col').removeClass('bright');
- $status.html('<br/>');
- var msg = 'uno .uno:InsertTable {' +
- ' "Columns": { "type": "long","value": '
- + col +
- ' }, "Rows": { "type": "long","value": '
- + row +' }}';
- map._socket.sendMessage(msg);
- }
- }, ".col");
-
- // close dialog on mouseleave
- $popup.mouseleave(function(){
- $(this).hide();
- $('.col').removeClass('bright');
- $status.html('<br/>');
- });
-}
commit a7d3a8e9c36e58457ee82427921cc3306995e1ee
Author: Pranav Kant <pranavk at collabora.com>
Date: Fri May 27 20:08:03 2016 +0530
loleaflet: Enable toolbar linting
Till now we have only been linting our src/ directory. toolbar.js
is the only file we edit directly in dist/. Lets keep a check on
it too.
Change-Id: I3e8a6e675a1d0c508339db1363600b5fe8f9c2cd
diff --git a/loleaflet/.eslintignore b/loleaflet/.eslintignore
index 6abb0a8..26e742c 100644
--- a/loleaflet/.eslintignore
+++ b/loleaflet/.eslintignore
@@ -1 +1,5 @@
+# We only directly edit toolbar.js in dist/
+dist/**/*.js
+!dist/toolbar/toolbar.js
+
src/admin/Base.js
diff --git a/loleaflet/Jakefile.js b/loleaflet/Jakefile.js
index 62e9ed2..d1cb7ab 100644
--- a/loleaflet/Jakefile.js
+++ b/loleaflet/Jakefile.js
@@ -27,7 +27,7 @@ function hint(msg, args) {
}
desc('Check Leaflet source for errors with ESLint');
-task('lint', {async: true}, hint('Checking for JS errors...', 'src --config .eslintrc'));
+task('lint', {async: true}, hint('Checking for JS errors...', 'src dist --config .eslintrc'));
desc('Check Leaflet specs source for errors with ESLint');
task('lintspec', {async: true}, hint('Checking for specs JS errors...', 'spec/suites --config spec/.eslintrc'));
commit 7460884df47a82d066edcfc64e97ad100d67f5db
Author: Pranav Kant <pranavk at collabora.com>
Date: Fri May 27 20:04:58 2016 +0530
loleaflet: Remove superfluous entries
All files in dist/ are ignored already by our linting tool.
There's no point in list them here.
Change-Id: I0a3a67796d85506196eb13be347b1ff59bcae02f
diff --git a/loleaflet/.eslintignore b/loleaflet/.eslintignore
index 45d125b..6abb0a8 100644
--- a/loleaflet/.eslintignore
+++ b/loleaflet/.eslintignore
@@ -1,3 +1 @@
-dist/scrollbar
-dist/contextMenu
src/admin/Base.js
More information about the Libreoffice-commits
mailing list