aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/coding-rules/facets/template-facet.js
blob: 81a031da126d45e51b1bad4b8350b7976e7878c6 (plain)
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
define([
  'coding-rules/facets/base-facet',
  'templates/coding-rules'
], function (BaseFacet) {

  var $ = jQuery;

  return BaseFacet.extend({
    template: Templates['coding-rules-template-facet'],

    onRender: function () {
      BaseFacet.prototype.onRender.apply(this, arguments);
      var value = this.options.app.state.get('query').is_template;
      if (value != null) {
        this.$('.js-facet').filter('[data-value="' + value + '"]').addClass('active');
      }
    },

    toggleFacet: function (e) {
      $(e.currentTarget).toggleClass('active');
      var property = this.model.get('property'),
          obj = {};
      obj[property] = '' + $(e.currentTarget).data('value');
      this.options.app.state.updateFilter(obj);
    }

  });

});