[Libreoffice-commits] online.git: loleaflet/dist
Pranav Kant
pranavk at collabora.co.uk
Thu Dec 8 13:52:14 UTC 2016
loleaflet/dist/toolbar/toolbar.js | 44 +++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 15 deletions(-)
New commits:
commit cba45fce4293f173be5534fa37b33ff7721a143e
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Dec 8 19:20:28 2016 +0530
loleaflet: Improved search
Start searching as you type
Press enter to search forward
Shift + enter to search backwards
Esc to get back to editing
Change-Id: Id366069aea9eb0e96e8d73fa4b57f972b0ce78e5
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 22b850e..fa07464 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -52,6 +52,16 @@ function resizeToolbar() {
}
}
+function _cancelSearch() {
+ var toolbar = w2ui['toolbar-down'];
+ map.resetSelection();
+ toolbar.hide('cancelsearch');
+ toolbar.disable('searchprev');
+ toolbar.disable('searchnext');
+ L.DomUtil.get('search-input').value = '';
+ map.focus();
+}
+
function onClick(id, item, subItem) {
if (w2ui['toolbar-up'].get(id) !== null) {
var toolbar = w2ui['toolbar-up'];
@@ -130,11 +140,7 @@ function onClick(id, item, subItem) {
map.search(L.DomUtil.get('search-input').value);
}
else if (id === 'cancelsearch') {
- map.resetSelection();
- toolbar.hide('cancelsearch');
- toolbar.disable('searchprev');
- toolbar.disable('searchnext');
- L.DomUtil.get('search-input').value = '';
+ _cancelSearch();
}
else if (id === 'presentation' && map.getDocType() === 'presentation') {
map.fire('fullscreen');
@@ -468,7 +474,7 @@ $(function () {
{type: 'html', id: 'search',
html: '<div style="padding: 3px 10px;" class="loleaflet-font">' +
' ' + _('Search:') +
- ' <input size="10" id="search-input" onkeypress="onSearch(event)"' +
+ ' <input size="10" id="search-input" oninput="onSearch(event)" onkeypress="onSearchKeyPress(event)" ' +
'style="padding: 3px; border-radius: 2px; border: 1px solid silver"/>' +
'</div>'
},
@@ -587,15 +593,23 @@ function selectItem(item, func)
}
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');
+ var toolbar = w2ui['toolbar-down'];
+ map.search(L.DomUtil.get('search-input').value);
+ toolbar.enable('searchprev');
+ toolbar.enable('searchnext');
+ toolbar.show('cancelsearch');
+}
+
+function onSearchKeyPress(e) {
+ if (e.keyCode === 13) { // Enter key
+ if (e.shiftKey) {
+ // search backwards
+ map.search(L.DomUtil.get('search-input').value, true);
+ } else {
+ map.search(L.DomUtil.get('search-input').value);
+ }
+ } else if (e.keyCode === 27) { // Escape key
+ _cancelSearch();
}
}
More information about the Libreoffice-commits
mailing list