cms/app-client/app/controllers/application.js
author nowmad@23.1.168.192.in-addr.arpa
Thu, 17 Dec 2015 12:32:01 +0100
changeset 72 9a7ea5349882
parent 61 bbc8a582fcc3
child 81 848e4a5ad4d9
permissions -rw-r--r--
clean console log
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     1
import Ember from 'ember';
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     2
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     3
export default Ember.Controller.extend({
58
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
     4
  queryParams: ['location', 'langue', 'discours', 'date', 'thematique'],
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     5
  location: null,
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     6
  langue: null,
58
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
     7
  discours: null,
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
     8
  date: null,
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
     9
  thematique: null,
61
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    10
  currentItem: {title: "example", master: 'http://www.noiseaddicts.com/samples_1w72b820/3921.mp3'},
58
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    11
  filteredSounds: Ember.computed('location', 'langue', 'discours', 'date', 'thematique', 'model', function() {
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    12
    var location = this.get('location');
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    13
    var langue = this.get('langue');
58
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    14
    var discours = this.get('discours');
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    15
    var date = this.get('date');
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    16
    // var thematique = this.get('thematique');
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    17
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    18
    var sounds = this.get('model');
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    19
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    20
    if (location) {
58
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    21
      sounds = sounds.filterBy('spatial', location);
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    22
    }
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    23
    if (langue) {
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    24
      sounds = sounds.filterBy('language', langue);
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    25
    }
58
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    26
    if (discours) {
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    27
      sounds = sounds.filterBy('type', discours);
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    28
    }
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    29
    if (date) {
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    30
      sounds = sounds.filterBy('created', parseInt(date));
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    31
    }
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    32
    // if (thematique) {
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    33
    //   sounds = sounds.filterBy('thematique', thematique);
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    34
    // }
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    35
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    36
    return sounds;
58
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    37
  }),
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    38
  actions: {
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    39
    deleteTag: function(query){
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    40
      var queryParams = {};
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    41
      queryParams[query]  = null;
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    42
      this.transitionToRoute({queryParams: queryParams});
61
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    43
    },
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    44
    play: function(item){
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    45
      this.set("currentItem", item);
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    46
      $("#audio-player").load();
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    47
      $(".result-item").toggleClass("playing", false);
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    48
      $("#"+item.id).toggleClass("playing", true);
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    49
    },
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    50
    details: function(item){
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    51
      if ($("#"+item.id).hasClass("details")){
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    52
          $("#"+item.id).toggleClass("details", false);
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    53
      } else{
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    54
        $(".result-item").toggleClass("details", false);
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    55
        $("#"+item.id).toggleClass("details", true);
bbc8a582fcc3 introduce new action "play" to play the sounds and "details" to show more
nowmad@23.1.168.192.in-addr.arpa
parents: 58
diff changeset
    56
      }
58
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    57
    }
6c03fafb6b62 Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents: 51
diff changeset
    58
  }
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    59
});