diff options
author | alexwl <alexey.a.kiryushin@gmail.com> | 2019-02-06 21:42:29 +0300 |
---|---|---|
committer | alexwl <alexey.a.kiryushin@gmail.com> | 2019-02-06 21:42:29 +0300 |
commit | d6a64db1ced3d3577886a7aec140a5174cbceb48 (patch) | |
tree | 88a6535043547da7093c126df642770533a4ab71 /javascript/app/routes/search.js | |
parent | b796d370c6b7ec7452a37440b089fd45853a47f4 (diff) |
Add identifier search in all indexed packages
Diffstat (limited to 'javascript/app/routes/search.js')
-rw-r--r-- | javascript/app/routes/search.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/javascript/app/routes/search.js b/javascript/app/routes/search.js new file mode 100644 index 0000000..c181c2f --- /dev/null +++ b/javascript/app/routes/search.js @@ -0,0 +1,42 @@ +import Ember from 'ember'; +import {urls} from '../utils/api-urls'; +import {goToDefinition} from '../utils/go-to-definition'; + +export default Ember.Route.extend({ + store : Ember.inject.service('store'), + model (params) { + return { + query: params.query, + url: urls.globalIdentifiersUrl(params.query)+"?per_page=20" + }; + }, + setupController(controller, model) { + this._super(controller, model); + controller.set('createSearchUrlFunction',(query) => { + return urls.globalIdentifiersUrl(query); + }); + }, + afterModel () { + const onmouseup = (event) => { + // This makes links in documentation clickable + if(event.target.dataset.location) { + let location; + try { + location = JSON.parse(event.target.dataset.location); + } catch (e) { + console.log(e); + } + if(location) { + goToDefinition(this.get('store'),location,event.which); + } + } + }; + this._onmouseup = onmouseup; + document.addEventListener('mouseup',onmouseup); + }, + deactivate() { + if(this._onmouseup) { + document.removeEventListener('mouseup',this._onmouseup); + } + } +}); |