loleaflet/reference.html | 257 +++++++++++++++++++++++++++++- loleaflet/spec/loleaflet/loleafletSpec.js | 4 loleaflet/src/dom/Draggable.js | 12 + loleaflet/src/layer/tile/TileLayer.js | 18 ++ loleaflet/src/map/handler/Map.Drag.js | 1 loleaflet/src/map/handler/Map.Keyboard.js | 41 +++- 6 files changed, 315 insertions(+), 18 deletions(-)
New commits: commit 0ad742dcc98947b7598c4a8489a3afd17005555c Author: Mihai Varga <[email protected]> Date: Tue Sep 29 17:50:08 2015 +0300 loleaflet: fit document horizontally when resizing the window diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index fd8771a..0bf5474 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -105,6 +105,7 @@ L.TileLayer = L.GridLayer.extend({ map.on('dragstart', this._onDragStart, this); map.on('requestloksession', this._onRequestLOKSession, this); map.on('error', this._mapOnError, this); + map.on('resize', this._fitDocumentHorizontally, this); for (var key in this._selectionHandles) { this._selectionHandles[key].on('drag dragend', this._onSelectionHandleDrag, this); } @@ -671,6 +672,23 @@ L.TileLayer = L.GridLayer.extend({ _onRequestLOKSession: function () { L.Socket.sendMessage('requestloksession'); + }, + + _fitDocumentHorizontally: function (e) { + if (this._docType !== 'spreadsheet') { + var crsScale = this._map.options.crs.scale(1); + if (this._docPixelSize.x > e.newSize.x) { + var ratio = this._docPixelSize.x / e.newSize.x; + var zoomDelta = Math.ceil(Math.log(ratio) / Math.log(crsScale)); + this._map.setZoom(Math.max(1, this._map.getZoom() - zoomDelta), {animate: false}); + } + else if (e.newSize.x / this._docPixelSize.x > crsScale) { + // we could zoom in + var ratio = e.newSize.x / this._docPixelSize.x; + var zoomDelta = Math.ceil(Math.log(ratio) / Math.log(crsScale)); + this._map.setZoom(Math.min(10, this._map.getZoom() + zoomDelta), {animate: false}); + } + } } }); commit 8f31b9bcc2e2888edce15a609fe5972e4d3d28f2 Author: Mihai Varga <[email protected]> Date: Tue Sep 29 14:44:55 2015 +0300 loleaflet: update unoKeyCode when we change keyCode diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js index 360d797..987d2b4 100644 --- a/loleaflet/src/map/handler/Map.Keyboard.js +++ b/loleaflet/src/map/handler/Map.Keyboard.js @@ -207,6 +207,7 @@ L.Map.Keyboard = L.Handler.extend({ // Chrome sets keyCode = charCode for printable keys // while LO requires it to be 0 keyCode = 0; + unoKeyCode = this._toUNOKeyCode(keyCode); } docLayer._postKeyboardEvent('input', charCode, unoKeyCode); } commit a41dd81d9f757130bf92564673a7478d3dae6a6c Author: Mihai Varga <[email protected]> Date: Tue Sep 29 13:12:30 2015 +0300 loleaflet: don't pan horiz/vertic when doc fits viewing area diff --git a/loleaflet/src/dom/Draggable.js b/loleaflet/src/dom/Draggable.js index 2263074..3df1342 100644 --- a/loleaflet/src/dom/Draggable.js +++ b/loleaflet/src/dom/Draggable.js @@ -83,6 +83,18 @@ L.Draggable = L.Evented.extend({ newPoint = new L.Point(first.clientX, first.clientY), offset = newPoint.subtract(this._startPoint); + if (this._map) { + if (this._map.getDocSize().x < this._map.getSize().x) { + // don't pan horizontaly when the document fits in the viewing + // area horizontally (docWidth < viewAreaWidth) + offset.x = 0; + } + if (this._map.getDocSize().y < this._map.getSize().y) { + // don't pan vertically when the document fits in the viewing + // area horizontally (docHeight < viewAreaHeight) + offset.y = 0; + } + } if (!offset.x && !offset.y) { return; } if (L.Browser.touch && Math.abs(offset.x) + Math.abs(offset.y) < 3) { return; } diff --git a/loleaflet/src/map/handler/Map.Drag.js b/loleaflet/src/map/handler/Map.Drag.js index 62ec332..10b3b4a 100644 --- a/loleaflet/src/map/handler/Map.Drag.js +++ b/loleaflet/src/map/handler/Map.Drag.js @@ -20,6 +20,7 @@ L.Map.Drag = L.Handler.extend({ var map = this._map; this._draggable = new L.Draggable(map._mapPane, map._container); + this._draggable._map = map; this._draggable.on({ down: this._onDown, commit 6ead48518ea759318e682bfd30d6792c6858873c Author: Mihai Varga <[email protected]> Date: Tue Sep 29 12:21:34 2015 +0300 loleaflet: fix undefined variable diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js index e54fbb0..360d797 100644 --- a/loleaflet/src/map/handler/Map.Keyboard.js +++ b/loleaflet/src/map/handler/Map.Keyboard.js @@ -179,6 +179,7 @@ L.Map.Keyboard = L.Handler.extend({ }, _onKeyDown: function (e) { + var docLayer = this._map._docLayer; if (e.originalEvent.ctrlKey) { // we prepare for a copy event docLayer._textArea.value = 'dummy text'; @@ -187,7 +188,6 @@ L.Map.Keyboard = L.Handler.extend({ return; } - var docLayer = this._map._docLayer; var charCode = e.originalEvent.charCode; var keyCode = e.originalEvent.keyCode; var unoKeyCode = this._toUNOKeyCode(keyCode); commit 1750e3746d78f0f253547b3e2d81415cd4839a4c Author: Mihai Varga <[email protected]> Date: Thu Sep 24 19:46:15 2015 +0200 loleaflet: handle shift + arrow keys selection diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js index b98c495..e54fbb0 100644 --- a/loleaflet/src/map/handler/Map.Keyboard.js +++ b/loleaflet/src/map/handler/Map.Keyboard.js @@ -10,6 +10,13 @@ L.Map.mergeOptions({ L.Map.Keyboard = L.Handler.extend({ + keyModifier: { + shift: 4096, + ctrl: 8192, + alt: 16384, + ctrlMac: 32768 + }, + keymap: { 8 : 1283, // backspace : BACKSPACE 9 : 1282, // tab : TAB @@ -129,8 +136,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]; @@ -148,8 +155,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; @@ -172,7 +179,6 @@ L.Map.Keyboard = L.Handler.extend({ }, _onKeyDown: function (e) { - var docLayer = this._map._docLayer; if (e.originalEvent.ctrlKey) { // we prepare for a copy event docLayer._textArea.value = 'dummy text'; @@ -181,24 +187,31 @@ L.Map.Keyboard = L.Handler.extend({ return; } + var docLayer = this._map._docLayer; + var charCode = e.originalEvent.charCode; + var keyCode = e.originalEvent.keyCode; + var unoKeyCode = this._toUNOKeyCode(keyCode); + + if (e.originalEvent.shiftKey) { + unoKeyCode |= this.keyModifier.shift; + } + if (docLayer._permission === 'edit') { docLayer._resetPreFetching(); - var charCode = e.originalEvent.charCode; - var keyCode = e.originalEvent.keyCode; if (e.type === 'keydown' && this.handleOnKeyDown[keyCode] && charCode === 0) { - docLayer._postKeyboardEvent('input', charCode, this._toUNOKeyCode(keyCode)); + docLayer._postKeyboardEvent('input', charCode, unoKeyCode); } else if (e.type === 'keypress' && - (!this.handleOnKeyDown[keyCode] || charCode !== 0)) { + (!this.handleOnKeyDown[keyCode] || charCode !== 0)) { if (charCode === keyCode && charCode !== 13) { // Chrome sets keyCode = charCode for printable keys // while LO requires it to be 0 keyCode = 0; } - docLayer._postKeyboardEvent('input', charCode, this._toUNOKeyCode(keyCode)); + docLayer._postKeyboardEvent('input', charCode, unoKeyCode); } else if (e.type === 'keyup') { - docLayer._postKeyboardEvent('up', charCode, this._toUNOKeyCode(keyCode)); + docLayer._postKeyboardEvent('up', charCode, unoKeyCode); } if (keyCode === 9) { // tab would change focus to other DOM elements @@ -208,12 +221,17 @@ L.Map.Keyboard = L.Handler.extend({ else if (e.type === 'keydown') { var key = e.originalEvent.keyCode; var map = this._map; - if (key in this._panKeys) { + if (key in this._panKeys && !e.originalEvent.shiftKey) { if (map._panAnim && map._panAnim._inProgress) { return; } map.fire('scrollby', {x: this._panKeys[key][0], y: this._panKeys[key][1]}); } + else if (key in this._panKeys && e.originalEvent.shiftKey && + docLayer._selections.getLayers().length !== 0) { + // if there is a selection and the user wants to modify it + docLayer._postKeyboardEvent('input', charCode, unoKeyCode); + } else if (key in this._zoomKeys) { map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]); } commit d6c328328c308c2f08bd1c7e2520bf1c80dd6c1a Author: Mihai Varga <[email protected]> Date: Mon Sep 21 23:06:59 2015 +0200 loleaflet: updated unit test's description diff --git a/loleaflet/spec/loleaflet/loleafletSpec.js b/loleaflet/spec/loleaflet/loleafletSpec.js index 4fbff63..4efa1b9 100644 --- a/loleaflet/spec/loleaflet/loleafletSpec.js +++ b/loleaflet/spec/loleaflet/loleafletSpec.js @@ -1,4 +1,4 @@ -describe('TileBench', function () { +describe('LOLeaflet test', function () { this.timeout(10000); var map; var timeOut @@ -38,7 +38,7 @@ describe('TileBench', function () { map.remove(); }); - describe('Benchmarking', function () { + describe('', function () { it('Load all new tiles', function (done) { map.on('statusindicator', function (e) { if (e.statusType === 'alltilesloaded') { commit 3cad1b0e71927ef2246fbf423c757f269daf50ad Author: Mihai Varga <[email protected]> Date: Fri Sep 18 17:53:08 2015 +0300 loleaflet: added the new methods to the html documentation diff --git a/loleaflet/reference.html b/loleaflet/reference.html index 8ce0eae..595dd62 100644 --- a/loleaflet/reference.html +++ b/loleaflet/reference.html @@ -55,6 +55,13 @@ </ul> </div> <div class="toc-col"> + <h4>LoLeaflet API</h4> + <ul> + <li><a href="#loleaflet-general">General</a></li> + <li><a href="#loleaflet-toolbar">Toolbar</a></li> + <li><a href="#loleaflet-page">Page oriented</a></li> + <li><a href="#loleaflet-part">Part oriented</a></li> + </ul> <h4>UI Layers</h4> <ul> <li><a href="#marker">Marker</a></li> @@ -1377,6 +1384,246 @@ var map = L.map('map', { </tr> </table> +<h2 id="loleaflet-general">General</h2> + +<p>General methods for document interaction.</p> + +<table data-id='map'> + <tr> + <th>Method</th> + <th>Returns</th> + <th>Description</th> + </tr> + <tr> + <td><code><b>search</b>( + <nobr><String> <i>phrase</i>,</nobr> + <nobr><Boolean> <i>backward?</i> )</nobr> + </code></td> + <td><code>undefined</code></td> + <td>Searches for the given phrase downward from the current top border of the viewing area. + Or backwards if specified.</td> + </tr> + <tr> + <td><code><b>setPermission</b>( + <nobr><<a href="#documentpermission-values">DocumentPermissionValues</a>> <i>documenPermission</i>)</nobr> + </code></td> + <td><code>undefined</code></td> + <td>Sets the permission of the document.</td> + </tr> + <tr> + <td><code><b>getDocSize</b>()</code></td> + <td><code><a href="#point">Point</a></code></td> + <td>Returns the document size.</td> + </tr> + <tr> + <td><code><b>getDocType</b>()</code></td> + <td><code><nobr><a href="#documenttype-values">DocumentTypeValues</a></nobr></code></td> + <td>Returns the document type.</td> + </tr> + <tr> + <td><code><b>scroll</b>( + <nobr><Number><i>x</i>,</nobr> + <nobr><Number><i>y</i>,</nobr> + <nobr><<a href="#scroll-options">ScrollOptions</a>><i>Options</i>)</nobr> + </code></td> + <td><code><nobr>undefined</nobr></code></td> + <td>Scroll right by 'x' and down by 'y' (or left and up if negative).</td> + </tr> + <tr> + <td><code><b>scrollDown</b>( + <nobr><Number><i>y</i>,</nobr> + <nobr><<a href="#scroll-options">ScrollOptions</a>><i>Options</i>)</nobr> + </code></td> + <td><code><nobr>undefined</nobr></code></td> + <td>Scroll down by 'y' (or up if negative).</td> + </tr> + <tr> + <td><code><b>scrollRight</b>( + <nobr><Number><i>x</i>,</nobr> + <nobr><<a href="#scroll-options">ScrollOptions</a>><i>Options</i>)</nobr> + </code></td> + <td><code><nobr>undefined</nobr></code></td> + <td>Scroll right by 'x' (or left if negative).</td> + </tr> + <tr> + <td><code><b>scrollTop</b>( + <nobr><Number><i>y</i>,</nobr> + <nobr><<a href="#scroll-options">ScrollOptions</a>><i>Options</i>)</nobr> + </code></td> + <td><code><nobr>undefined</nobr></code></td> + <td>Scroll to 'y' offset relative to the beginning of the document.</td> + </tr> + <tr> + <td><code><b>scrollLeft</b>( + <nobr><Number><i>x</i>,</nobr> + <nobr><<a href="#scroll-options">ScrollOptions</a>><i>Options</i>)</nobr> + </code></td> + <td><code><nobr>undefined</nobr></code></td> + <td>Scroll to 'x' offset relative to the beginning of the document.</td> + </tr> + <tr> + <td><code><b>scrollOffset</b>()</code></td> + <td><code><nobr><a href="#point">Point</a></nobr></code></td> + <td>Returns the scroll offset relative to the beginning of the document.</td> + </tr> +</table> + +<h3 id="scroll-options">ScrollOptions</h3> + +<table data-id='values'> + <tr> + <th class="width100">property</th> + <th class="width100">type</th> + <th>description</th> + </tr> + <tr> + <td><code><b>update</b></code></td> + <td><code>Boolean</code></td> + <td>Whether the <a href="#updatescrolloffset-event">update-scroll-offset</a> event is fired.</td> + </tr> +</table> + +<h2 id="loleaflet-toolbar">Toolbar</h2> + +<p>Toolbar methods.</p> + +<table data-id='map'> + <tr> + <th>Method</th> + <th>Returns</th> + <th>Description</th> + </tr> + <tr> + <td><code><b>getToolbarCommandValues</b>( + <nobr><<a href="#toolbarcommand-values">ToolbarCommandValues</a>> <i>unoCommand</i>)</nobr> + </code></td> + <td><code>Object</code></td> + <td>Returns a JSON mapping of the possible values.</td> + </tr> + <tr> + <td><code><b>toggleCommandState</b>( + <nobr><<a href="#commandstatechanged-values">CommandValues</a>> <i>unoCommand</i>)</nobr> + </code></td> + <td><code>undefined</code></td> + <td>Toggles the state for the given UNO command.</td> + </tr> +</table> + +<h2 id="loleaflet-page">Page oriented</h2> + +<p>Methods for page oriented documents.</p> + +<table data-id='map'> + <tr> + <th>Method</th> + <th>Returns</th> + <th>Description</th> + </tr> + <tr> + <td><code><b>getCurrentPageNumber</b>()</code></td> + <td><code>Number</code></td> + <td>Number of the current page.</td> + </tr> + <tr> + <td><code><b>getNumberOfPages</b>()</code></td> + <td><code>Number</code></td> + <td>Total number of pages.</td> + </tr> + <tr> + <td><code><b>goToPage</b>( + <nobr><Number><i>pageNumber</i>)</nobr> + </code></td> + <td><code>undfined</code></td> + <td>Scrolls to the beginning of the given page.</td> + </tr> + <tr> + <td><code><b>getDocPreview</b>( + <Object><i>id</i>,<br> + <Number><i>maxWidth</i>,<br> + <Number><i>maxHeight</i>,<br> + <Number><i>x</i>,<br> + <Number><i>y</i>,<br> + <Number><i>width</i>,<br> + <Number><i>height</i>,<br> + <nobr><<a href="#getpreview-options">PreviewOptions</a>><i>options?</i>)</nobr> + </code></td> + <td><code>undefined</code></td> + <td>Triggers the creation of a preview with the given id, of maximum maxWidth X maxHeight size, of the + [(x,y), (x + width, y + height)] section of the document keeping the original ration. By passing an + optional parameter {autoUpdate: true}, the preview will be automatically invalidated.</td> + </tr> + <tr> + <td><code><b>removePreviewUpdate</b>( + <nobr><Object><i>id</i>)</nobr> + </code></td> + <td><code>undfined</code></td> + <td>Cancels the automatic update for the preview defined by 'id'.</td> + </tr> +</table> + +<h2 id="loleaflet-part">Part oriented</h2> + +<p>Methods for page oriented documents.</p> + +<table data-id='map'> + <tr> + <th>Method</th> + <th>Returns</th> + <th>Description</th> + </tr> + <tr> + <td><code><b>getCurrentPartNumber</b>()</code></td> + <td><code>Number</code></td> + <td>Number of the current part.</td> + </tr> + <tr> + <td><code><b>getNumberOfParts</b>()</code></td> + <td><code>Number</code></td> + <td>Total number of parts.</td> + </tr> + <tr> + <td><code><b>setPart</b>( + <nobr><Number><i>partNumber</i>)</nobr> + </code></td> + <td><code>undfined</code></td> + <td>Select a specific part.</td> + </tr> + <tr> + <td><code><b>getPartPreview</b>( + <Object><i>id</i>,<br> + <Number><i>part</i>,<br> + <Number><i>maxWidth</i>,<br> + <Number><i>maxHeight</i>,<br> + <nobr><<a href="#getpreview-options">PreviewOptions</a>><i>options?</i>)</nobr> + </code></td> + <td><code>undefined</code></td> + <td>Triggers the creation of a preview with the given id, of maximum maxWidth X maxHeight size, of the + specified part keeping the original ration. By passing an + optional parameter {autoUpdate: true}, the preview will be automatically invalidated.</td> + </tr> + <tr> + <td><code><b>removePreviewUpdate</b>( + <nobr><Object><i>id</i>)</nobr> + </code></td> + <td><code>undfined</code></td> + <td>Cancels the automatic update for the preview defined by 'id'.</td> + </tr> +</table> + +<h3 id="getpreview-options">PreviewOptions</h3> + +<table data-id='values'> + <tr> + <th class="width100">property</th> + <th class="width100">type</th> + <th>description</th> + </tr> + <tr> + <td><code><b>autoUpdate</b></code></td> + <td><code>Boolean</code></td> + <td>Whether a new preview is generated automatically when it becomes invalid.</td> + </tr> +</table> <h2 id="marker">Marker</h2> @@ -6633,7 +6880,7 @@ map.addControl(new MyControl()); </tr> <tr> <td><code><b>docType</b></code></td> - <td><code><a href="#doctype-values">DocumentTypeValues</a></code></td> + <td><code><a href="#documenttype-values">DocumentTypeValues</a></code></td> <td>The document type.</td> </tr> <tr> @@ -6688,7 +6935,7 @@ map.addControl(new MyControl()); </tr> <tr> <td><code><b>docType</b></code></td> - <td><code><a href="#doctype-values">DocumentTypeValues</a></code></td> + <td><code><a href="#documenttype-values">DocumentTypeValues</a></code></td> <td>The document type.</td> </tr> <tr> @@ -6818,7 +7065,7 @@ map.addControl(new MyControl()); </tr> <tr> <td><code><b>docType</b></code></td> - <td><code><a href="#doctype-values">DocumentTypeValues</a></code></td> + <td><code><a href="#documenttype-values">DocumentTypeValues</a></code></td> <td>The document type.</td> </tr> </table> @@ -7252,7 +7499,7 @@ map.addControl(new MyControl()); </tr> </table> -<h3 id="doctype-values">DocumentTypeValues</h3> +<h3 id="documenttype-values">DocumentTypeValues</h3> <table data-id='values'> <tr> commit a2a30e46de14233d5a4190def2477be5785a30cf Author: Mihai Varga <[email protected]> Date: Fri Sep 18 11:50:41 2015 +0300 loleaflet: mention version in documentation diff --git a/loleaflet/reference.html b/loleaflet/reference.html index e64bfe3..8ce0eae 100644 --- a/loleaflet/reference.html +++ b/loleaflet/reference.html @@ -151,7 +151,7 @@ <!--<a href="#toc" id="back-to-top">↑</a>--> <hr /> -<p>This reference reflects <strong>Leaflet 1.0</strong>.</p> +<p>This reference reflects <strong>LOLeaflet master</strong>.</p> <h2 id="map-class">Map</h2> _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
