aboutsummaryrefslogtreecommitdiff
path: root/javascript/app/routes
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/app/routes')
-rw-r--r--javascript/app/routes/packages.js3
-rw-r--r--javascript/app/routes/search.js42
2 files changed, 45 insertions, 0 deletions
diff --git a/javascript/app/routes/packages.js b/javascript/app/routes/packages.js
index 2bbf9bc..34a454d 100644
--- a/javascript/app/routes/packages.js
+++ b/javascript/app/routes/packages.js
@@ -9,6 +9,9 @@ export default Ember.Route.extend({
setupController(controller, model) {
this._super(controller, model);
controller.set('packages',model);
+ controller.set('createSearchUrlFunction',(query) => {
+ return urls.globalIdentifiersUrl(query);
+ });
},
afterModel () {
document.title = config.APP.title;
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);
+ }
+ }
+});