author | ymh <ymh.work@gmail.com> |
Fri, 09 Dec 2016 11:41:15 +0100 | |
changeset 467 | 762fc0eb4946 |
parent 462 | ebd8269781fa |
permissions | -rw-r--r-- |
196 | 1 |
import Ember from 'ember'; |
415 | 2 |
import SocialShareKit from 'socialsharekit'; |
196 | 3 |
|
4 |
export default Ember.Component.extend({ |
|
5 |
||
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
6 |
classNames: ['playlist-component'], |
200
a441c40f9c5e
Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents:
196
diff
changeset
|
7 |
|
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
8 |
filter: Ember.inject.service(), |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
9 |
player: Ember.inject.service(), |
200
a441c40f9c5e
Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents:
196
diff
changeset
|
10 |
|
404
0a5eef6ad2fe
correction, change colors for discourse categories, add loding spinner
ymh <ymh.work@gmail.com>
parents:
347
diff
changeset
|
11 |
isLoading: false, |
0a5eef6ad2fe
correction, change colors for discourse categories, add loding spinner
ymh <ymh.work@gmail.com>
parents:
347
diff
changeset
|
12 |
|
344 | 13 |
model: [], |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
14 |
documents: Ember.computed('model', 'filter.location', 'filter.language', 'filter.discourse', 'filter.date', 'filter.theme', function() { |
317
e653de66f252
Remove document filtering in playlist
Chloe Laisne <chloe.laisne@gmail.com>
parents:
301
diff
changeset
|
15 |
return this.get('model'); |
200
a441c40f9c5e
Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents:
196
diff
changeset
|
16 |
}), |
a441c40f9c5e
Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents:
196
diff
changeset
|
17 |
|
215
82878d132784
Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
212
diff
changeset
|
18 |
documentsLoaded: Ember.observer('documents', function() { |
82878d132784
Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
212
diff
changeset
|
19 |
this.get('player').set('items', this.get('documents').map(function(document) { |
82878d132784
Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
212
diff
changeset
|
20 |
return document.get('id'); |
82878d132784
Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
212
diff
changeset
|
21 |
})); |
240
aa101458cd4e
Player forward and backward
Chloe Laisne <chloe.laisne@gmail.com>
parents:
233
diff
changeset
|
22 |
if(this.get('player').get('items').length && this.get('player').get('playing') === false) { |
347 | 23 |
this.get('player').set('item', this.get('player').get('items')[0]); |
216
c174124d1849
/discours and /chrono design changes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
215
diff
changeset
|
24 |
} |
215
82878d132784
Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
212
diff
changeset
|
25 |
}).on('init'), |
82878d132784
Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
212
diff
changeset
|
26 |
|
336
f076ddd29e13
Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents:
317
diff
changeset
|
27 |
playerItemObserver: Ember.observer('player.item', function() { |
f076ddd29e13
Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents:
317
diff
changeset
|
28 |
if(this.$() && this.get('player').get('item')) { |
f076ddd29e13
Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents:
317
diff
changeset
|
29 |
var ul = this.$().find('ul'); |
f076ddd29e13
Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents:
317
diff
changeset
|
30 |
var li = this.$().find('li#' + this.get('player').get('item').replace('.', '\\.').replace('/', '\\/')); |
344 | 31 |
if(li.length) { |
32 |
if(li.offset().top - ul.offset().top < 0) { |
|
33 |
ul.animate({ |
|
34 |
'scrollTop': ul.scrollTop() + li.offset().top - ul.offset().top |
|
35 |
}); |
|
36 |
} else if(li.offset().top + li.outerHeight() - ul.offset().top > ul.outerHeight()) { |
|
37 |
ul.animate({ |
|
38 |
'scrollTop': ul.scrollTop() + li.offset().top + li.outerHeight() - ul.offset().top - ul.height() |
|
39 |
}); |
|
40 |
} |
|
336
f076ddd29e13
Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents:
317
diff
changeset
|
41 |
} |
f076ddd29e13
Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents:
317
diff
changeset
|
42 |
} |
f076ddd29e13
Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents:
317
diff
changeset
|
43 |
}), |
f076ddd29e13
Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents:
317
diff
changeset
|
44 |
|
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
45 |
didRender: function() { |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
46 |
this._super(...arguments); |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
47 |
this.$().find('ul').height(Ember.$('.corpus-app-wrapper').outerHeight() - (Ember.$('.filter-component').outerHeight() + this.$().find('h2').outerHeight())); |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
48 |
}, |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
49 |
|
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
50 |
actions: { |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
51 |
|
344 | 52 |
previous: function() { |
53 |
this.sendAction('pageAction', 'previous'); |
|
54 |
}, |
|
55 |
||
56 |
next: function() { |
|
57 |
this.sendAction('pageAction', 'next'); |
|
58 |
}, |
|
59 |
||
252
ba4fd614582a
Load player with selected row
Chloe Laisne <chloe.laisne@gmail.com>
parents:
251
diff
changeset
|
60 |
select: function(id) { |
ba4fd614582a
Load player with selected row
Chloe Laisne <chloe.laisne@gmail.com>
parents:
251
diff
changeset
|
61 |
this.get('player').select(id); |
342
9375b692ff22
Display transcript by default
Chloe Laisne <chloe.laisne@gmail.com>
parents:
338
diff
changeset
|
62 |
this.get('player').displayMetadata('notice'); |
252
ba4fd614582a
Load player with selected row
Chloe Laisne <chloe.laisne@gmail.com>
parents:
251
diff
changeset
|
63 |
}, |
ba4fd614582a
Load player with selected row
Chloe Laisne <chloe.laisne@gmail.com>
parents:
251
diff
changeset
|
64 |
|
249 | 65 |
play: function(id) { |
66 |
this.get('player').play(id); |
|
67 |
}, |
|
68 |
||
257
eba9edbd8f46
Add title to annotation
Chloe Laisne <chloe.laisne@gmail.com>
parents:
254
diff
changeset
|
69 |
pause: function() { |
249 | 70 |
this.get('player').pause(); |
227
5c9250f55f4b
Basic notice logic from query parameters
Chloe Laisne <chloe.laisne@gmail.com>
parents:
216
diff
changeset
|
71 |
}, |
5c9250f55f4b
Basic notice logic from query parameters
Chloe Laisne <chloe.laisne@gmail.com>
parents:
216
diff
changeset
|
72 |
|
301
29b425234094
Transcript icon in tool container + Toggle transcript action on click
Chloe Laisne <chloe.laisne@gmail.com>
parents:
257
diff
changeset
|
73 |
displayTranscript: function() { |
462 | 74 |
this.get('player').set('transcriptLoading', (this.get('player.window') !== 'transcript') && !this.get("player.transcriptIframe")); |
459
6a296e92887f
add a spinner when opening a transcript
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
75 |
|
6a296e92887f
add a spinner when opening a transcript
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
76 |
Ember.run.later(() => { this.get('player').displayAdditionalInformation('transcript'); }, 10); |
301
29b425234094
Transcript icon in tool container + Toggle transcript action on click
Chloe Laisne <chloe.laisne@gmail.com>
parents:
257
diff
changeset
|
77 |
}, |
29b425234094
Transcript icon in tool container + Toggle transcript action on click
Chloe Laisne <chloe.laisne@gmail.com>
parents:
257
diff
changeset
|
78 |
|
347 | 79 |
displayNotice: function() { |
338
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
336
diff
changeset
|
80 |
if(this.get('player').get('window') !== 'notice') { |
254 | 81 |
this.get('player').displayMetadata('notice'); |
227
5c9250f55f4b
Basic notice logic from query parameters
Chloe Laisne <chloe.laisne@gmail.com>
parents:
216
diff
changeset
|
82 |
} else { |
338
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
336
diff
changeset
|
83 |
this.get('player').displayMetadata(false); |
227
5c9250f55f4b
Basic notice logic from query parameters
Chloe Laisne <chloe.laisne@gmail.com>
parents:
216
diff
changeset
|
84 |
} |
415 | 85 |
}, |
86 |
||
87 |
shareLinkRender: (elemId) => { |
|
88 |
SocialShareKit.init({selector: "#"+elemId+" .ssk"}); |
|
89 |
Ember.$("#"+elemId+" .playlist-share-button-close").click(function() { |
|
90 |
// This is done like this because I was not able to register an action directly on the button like shgown on ember-tooltips documentaion (https://github.com/sir-dunxalot/ember-tooltips#popover-on-element) |
|
91 |
Ember.$("#corpus-app").click(); |
|
92 |
}); |
|
93 |
return true; |
|
94 |
}, |
|
95 |
||
96 |
shareLinkShow: (elemId) => { |
|
97 |
let input = Ember.$("#"+elemId+" input"); |
|
98 |
input.get(0).setSelectionRange(0, input.val().length); |
|
99 |
input.get(0).select(0, input.val().length); |
|
100 |
return true; |
|
101 |
}, |
|
102 |
||
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
201
diff
changeset
|
103 |
} |
196 | 104 |
|
105 |
}); |