author | nowmad@nowmads-macbook-pro.local |
Fri, 15 Jan 2016 15:49:42 +0100 | |
changeset 84 | 36f84e8f1ad5 |
parent 81 | 848e4a5ad4d9 |
child 86 | 15ded106ef1a |
permissions | -rw-r--r-- |
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, |
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
8 |
date: [], |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
9 |
thematique: null, |
84 | 10 |
isShowingModal: false, |
11 |
currentDetails: 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
|
12 |
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
|
13 |
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
|
14 |
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
|
15 |
var langue = this.get('langue'); |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
16 |
var discours = this.get('discours'); |
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
17 |
var date = this.get('date'); |
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
18 |
var thematique = this.get('thematique'); |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
19 |
|
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
|
20 |
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
|
21 |
|
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 |
if (location) { |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
23 |
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
|
24 |
} |
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 |
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
|
26 |
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
|
27 |
} |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
28 |
if (discours) { |
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
29 |
sounds = sounds.filterBy('type', discours); |
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
30 |
} |
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
31 |
if (date.length > 0) { |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
32 |
var temp = sounds; |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
33 |
sounds.map(function(elt, index){ |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
34 |
if (date.indexOf(elt.get('created')) === -1){ |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
35 |
temp = temp.without(elt); |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
36 |
} |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
37 |
}); |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
38 |
sounds = temp; |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
39 |
} |
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
40 |
if (thematique) { |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
41 |
sounds = sounds.filterBy('thematique', thematique); |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
42 |
} |
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
|
43 |
return sounds; |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
44 |
}), |
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
45 |
actions: { |
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
46 |
deleteTag: function(query, item){ |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
47 |
var queryParams = {}; |
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
48 |
if (query === 'date'){ |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
49 |
var array = this.get('date'); |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
50 |
if(array.indexOf(item) !== -1) { |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
51 |
array.splice(array.indexOf(item), 1); |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
52 |
} |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
53 |
} |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
72
diff
changeset
|
54 |
queryParams[query] = array || null; |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
55 |
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
|
56 |
}, |
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
|
57 |
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
|
58 |
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
|
59 |
$("#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
|
60 |
$(".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
|
61 |
$("#"+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
|
62 |
}, |
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
|
63 |
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
|
64 |
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
|
65 |
$("#"+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
|
66 |
} 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
|
67 |
$(".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
|
68 |
$("#"+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
|
69 |
} |
84 | 70 |
}, |
71 |
toggleModal: function(item){ |
|
72 |
this.set("isShowingModal", !this.isShowingModal); |
|
73 |
this.set("currentDetails", item); |
|
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
74 |
} |
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
75 |
} |
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
|
76 |
}); |