aboutsummaryrefslogtreecommitdiff
path: root/javascript/app/controllers/packages.js
blob: 614ecd8e8e48f695d01875e5e8bf7063fc369532 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Ember from 'ember';
import {goToDefinition} from '../utils/go-to-definition';

export default Ember.Controller.extend({  
  queryObserver : Ember.observer("query",function() {    
    Ember.run.debounce(this, () => {
      const regExp = new RegExp(this.get('query'),"i");
      const packages = this.get('model').filter((p) => p.name.search(regExp) != -1);      
      Ember.run.next(() => {
        this.set('packages',packages);
      });
    }, 300);
  }),
  actions: {
    searchIdentifier (query) {
      if(query) {
        document.title = "Haskell code explorer";
        this.transitionToRoute('search',query);
      }
    },
    showIdentifier (identifierInfo) {
      goToDefinition(this.get('store'),
                     identifierInfo.locationInfo,
                     1,//left mouse button
                     null);
      return false;
    }
  }
});