8 date: [], |
8 date: [], |
9 thematique: null, |
9 thematique: null, |
10 isShowingModal: false, |
10 isShowingModal: false, |
11 currentDetails: null, |
11 currentDetails: null, |
12 currentItem: {title: "example", master: 'http://www.noiseaddicts.com/samples_1w72b820/3921.mp3'}, |
12 currentItem: {title: "example", master: 'http://www.noiseaddicts.com/samples_1w72b820/3921.mp3'}, |
13 filteredSounds: Ember.computed('location', 'langue', 'discours', 'date', 'thematique', 'model', function() { |
13 filteredDocuments: Ember.computed('location', 'langue', 'discours', 'date', 'thematique', 'model', function() { |
14 var location = this.get('location'); |
14 var location = this.get('location'); |
15 var langue = this.get('langue'); |
15 var langue = this.get('langue'); |
16 var discours = this.get('discours'); |
16 var discours = this.get('discours'); |
17 var date = this.get('date'); |
17 var date = this.get('date'); |
18 var thematique = this.get('thematique'); |
18 var thematique = this.get('thematique'); |
19 |
19 |
20 var sounds = this.get('model'); |
20 var documents = this.get('model'); |
21 |
21 |
22 if (location) { |
22 if (location) { |
23 sounds = sounds.filterBy('spatial', location); |
23 documents = documents.filterBy('spatial', location); |
24 } |
24 } |
25 if (langue) { |
25 if (langue) { |
26 sounds = sounds.filterBy('language', langue); |
26 documents = documents.filterBy('language', langue); |
27 } |
27 } |
28 if (discours) { |
28 if (discours) { |
29 sounds = sounds.filterBy('type', discours); |
29 documents = documents.filterBy('type', discours); |
30 } |
30 } |
31 if (date.length > 0) { |
31 if (date.length > 0) { |
32 var temp = sounds; |
32 var temp = documents; |
33 sounds.map(function(elt){ |
33 documents.map(function(elt){ |
34 if (date.indexOf(elt.get('created')) === -1){ |
34 if (date.indexOf(elt.get('created')) === -1){ |
35 temp = temp.without(elt); |
35 temp = temp.without(elt); |
36 } |
36 } |
37 }); |
37 }); |
38 sounds = temp; |
38 documents = temp; |
39 } |
39 } |
40 if (thematique) { |
40 if (thematique) { |
41 sounds = sounds.filterBy('thematique', thematique); |
41 documents = documents.filterBy('thematique', thematique); |
42 } |
42 } |
43 return sounds; |
43 return documents; |
44 }), |
44 }), |
45 currentItemChanged: Ember.observer('currentItem', function() { |
45 currentItemChanged: Ember.observer('currentItem', function() { |
46 Ember.$(".result-item").toggleClass("playing", false); |
46 Ember.$(".result-item").toggleClass("playing", false); |
47 Ember.$("#"+this.get('currentItem').id).toggleClass("playing", true); |
47 Ember.$("#"+this.get('currentItem').id).toggleClass("playing", true); |
48 }), |
48 }), |
59 }); |
59 }); |
60 } |
60 } |
61 |
61 |
62 this.set(query, newParams); |
62 this.set(query, newParams); |
63 }, |
63 }, |
64 changeSong: function(songDirection){ |
64 changeDocument: function(docDirection){ |
65 var direction = (songDirection === "next") ? 1 : -1; |
65 var direction = (docDirection === "next") ? 1 : -1; |
66 var index = this.get("filteredSounds").indexOf(this.get("currentItem")); |
66 var index = this.get("filteredDocuments").indexOf(this.get("currentItem")); |
67 if ( index !== -1){ |
67 if ( index !== -1){ |
68 if (typeof(this.get("filteredSounds").objectAt(index+direction)) !== 'undefined'){ |
68 if (typeof(this.get("filteredDocuments").objectAt(index+direction)) !== 'undefined'){ |
69 return this.set('currentItem', this.get("filteredSounds").objectAt(index+direction)); |
69 return this.set('currentItem', this.get("filteredDocuments").objectAt(index+direction)); |
70 } |
70 } |
71 } |
71 } |
72 return this.set('currentItem', this.get('filteredSounds').get('firstObject')); |
72 return this.set('currentItem', this.get('filteredDocuments').get('firstObject')); |
73 }, |
73 }, |
74 play: function(item){ |
74 play: function(item){ |
75 this.set("currentItem", item); |
75 this.set("currentItem", item); |
76 }, |
76 }, |
77 details: function(item){ |
77 details: function(item){ |