From b15f521bd04a2d9fd92e52f689861e9e4686512b Mon Sep 17 00:00:00 2001 From: fkloft Date: Thu, 12 Feb 2015 17:55:29 +0100 Subject: [PATCH] [bookmarks-by-zaso] make bookmarks searchable --- {plugins => images}/bookmarks-img.png | Bin images/icon-bookmark-map.png | Bin 0 -> 347 bytes images/icon-bookmark.png | Bin 0 -> 328 bytes ...ookmarks-css.css => bookmarks-by-zaso.css} | 2 +- plugins/bookmarks-by-zaso.user.js | 52 +++++++++++++++++- 5 files changed, 52 insertions(+), 2 deletions(-) rename {plugins => images}/bookmarks-img.png (100%) create mode 100644 images/icon-bookmark-map.png create mode 100644 images/icon-bookmark.png rename plugins/{bookmarks-css.css => bookmarks-by-zaso.css} (99%) diff --git a/plugins/bookmarks-img.png b/images/bookmarks-img.png similarity index 100% rename from plugins/bookmarks-img.png rename to images/bookmarks-img.png diff --git a/images/icon-bookmark-map.png b/images/icon-bookmark-map.png new file mode 100644 index 0000000000000000000000000000000000000000..b0151a7b1b425ee7c20cb4cebc1da170bb43f293 GIT binary patch literal 347 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kmSQK*5Dp-y;YjHK@;M7UB8!3Q zuY)k7lg8`{prB-lYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt(q^T^vI+ zCQiL*sMk^`!202SP2@u+F7^un5kE^#1a&fZI4urX6?1?wgl|C+C+pmE|2J<9$dGAh zYLjjCeUrA|cSg#r%J*mYOz#Zx`sH4_VBKqp+20nc?|J>~?u#9nv(`jiUlROs2k$Hq zlZ}cw$?^8jqIGxn%RUs~*7A1F5!3(mvB!OC@u?4oW=peFN!+z+c71rT>vg<$^v{2OpU%bUKGu+&K?X!ueq~eZSES+-3 nr~YM-SJ{uB4_dx!e&yY_Ir5*G+OJnYKQef_`njxgN@xNAg&d2@ literal 0 HcmV?d00001 diff --git a/images/icon-bookmark.png b/images/icon-bookmark.png new file mode 100644 index 0000000000000000000000000000000000000000..ed32f5577320d743fd1b9f60901b8209a635cb15 GIT binary patch literal 328 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kmSQK*5Dp-y;YjHK@;M7UB8!3Q zuY)k7lg8`{prB-lYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt)GAT^vI+ zCa%4x>*vfU!15qJ-suvzf`A8)Xzt`i4I=Iq3|!3)i*_)uuXx265Yr?OknnRO3yU0U zo4^CzCbch5Z9QfiD64dHsLD&Kfkp9z#8$!ymSel RxeL%k44$rjF6*2Ung9;#M* literal 0 HcmV?d00001 diff --git a/plugins/bookmarks-css.css b/plugins/bookmarks-by-zaso.css similarity index 99% rename from plugins/bookmarks-css.css rename to plugins/bookmarks-by-zaso.css index caf8d354..fdb2e5f3 100644 --- a/plugins/bookmarks-css.css +++ b/plugins/bookmarks-by-zaso.css @@ -283,7 +283,7 @@ cursor:pointer; } #bkmrksTrigger, .bkmrksStar span, .portal-list-bookmark span { - background-image:url(@@INCLUDEIMAGE:plugins/bookmarks-img.png@@); + background-image:url(@@INCLUDEIMAGE:images/bookmarks-img.png@@); } .bkmrksStar span{ display:inline-block; diff --git a/plugins/bookmarks-by-zaso.user.js b/plugins/bookmarks-by-zaso.user.js index dfb7f098..930a96fc 100644 --- a/plugins/bookmarks-by-zaso.user.js +++ b/plugins/bookmarks-by-zaso.user.js @@ -479,6 +479,55 @@ console.log('Move Bookmarks '+type+' ID:'+idBkmrk+' from folder ID:'+oldFold+' to folder ID:'+newFold); } + window.plugin.bookmarks.onSearch = function(query) { + var term = query.term.toLowerCase(); + + $.each(plugin.bookmarks.bkmrksObj.maps, function(id, folder) { + $.each(folder.bkmrk, function(id, bookmark) { + if(bookmark.label.toLowerCase().indexOf(term) === -1) return; + + query.addResult({ + title: bookmark.label, + description: 'Map in folder "' + folder.label + '"', + icon: '@@INCLUDEIMAGE:images/icon-bookmark-map.png@@', + position: L.latLng(bookmark.latlng.split(",")), + zoom: bookmark.z, + onSelected: window.plugin.bookmarks.onSearchResultSelected, + }); + }); + }); + + $.each(plugin.bookmarks.bkmrksObj.portals, function(id, folder) { + $.each(folder.bkmrk, function(id, bookmark) { + if(bookmark.label.toLowerCase().indexOf(term) === -1) return; + + query.addResult({ + title: bookmark.label, + description: 'Bookmark in folder "' + folder.label + '"', + icon: '@@INCLUDEIMAGE:images/icon-bookmark.png@@', + position: L.latLng(bookmark.latlng.split(",")), + guid: bookmark.guid, + onSelected: window.plugin.bookmarks.onSearchResultSelected, + }); + }); + }); + }; + + window.plugin.bookmarks.onSearchResultSelected = function(result, event) { + if(result.guid) { // portal + var guid = result.guid; + if(event.type == 'dblclick') + zoomToAndShowPortal(guid, result.position); + else if(window.portals[guid]) + renderPortalDetails(guid); + else + window.selectPortalByLatLng(result.position); + } else if(result.zoom) { // map + map.setView(result.position, result.zoom); + } + return true; // prevent default behavior + }; + /***************************************************************************************************************************************************************/ // Saved the new sort of the folders (in the localStorage) @@ -1060,7 +1109,7 @@ /***************************************************************************************************************************************************************/ window.plugin.bookmarks.setupCSS = function() { - $('