cms/app-client/app/components/playlist-component.js
author Chloe Laisne <chloe.laisne@gmail.com>
Mon, 17 Oct 2016 00:30:36 +0530
changeset 342 9375b692ff22
parent 338 4a3899b6a7ed
child 344 70451a4dc9ae
permissions -rw-r--r--
Display transcript by default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
196
7550cb541901 Filter as a service
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     1
import Ember from 'ember';
7550cb541901 Filter as a service
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     2
7550cb541901 Filter as a service
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     3
export default Ember.Component.extend({
7550cb541901 Filter as a service
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     4
209
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
     5
    classNames: ['playlist-component'],
200
a441c40f9c5e Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents: 196
diff changeset
     6
209
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
     7
    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
     8
    player: Ember.inject.service(),
200
a441c40f9c5e Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents: 196
diff changeset
     9
209
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
    10
    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
    11
        return this.get('model');
200
a441c40f9c5e Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents: 196
diff changeset
    12
    }),
a441c40f9c5e Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents: 196
diff changeset
    13
215
82878d132784 Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents: 212
diff changeset
    14
    documentsLoaded: Ember.observer('documents', function() {
82878d132784 Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents: 212
diff changeset
    15
        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
    16
            return document.get('id');
82878d132784 Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents: 212
diff changeset
    17
        }));
240
aa101458cd4e Player forward and backward
Chloe Laisne <chloe.laisne@gmail.com>
parents: 233
diff changeset
    18
        if(this.get('player').get('items').length && this.get('player').get('playing') === false) {
216
c174124d1849 /discours and /chrono design changes
Chloe Laisne <chloe.laisne@gmail.com>
parents: 215
diff changeset
    19
            this.get('player').set('item', this.get('player').get('items')[0]);    
c174124d1849 /discours and /chrono design changes
Chloe Laisne <chloe.laisne@gmail.com>
parents: 215
diff changeset
    20
        }
215
82878d132784 Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents: 212
diff changeset
    21
    }).on('init'),
82878d132784 Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents: 212
diff changeset
    22
336
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    23
    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
    24
        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
    25
            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
    26
            var li = this.$().find('li#' + this.get('player').get('item').replace('.', '\\.').replace('/', '\\/'));
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    27
            if(li.offset().top - ul.offset().top < 0) {
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    28
                ul.animate({
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    29
                    'scrollTop': ul.scrollTop() + li.offset().top - ul.offset().top
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    30
                });
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    31
            } else if(li.offset().top + li.outerHeight() - ul.offset().top > ul.outerHeight()) {
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    32
                ul.animate({
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    33
                    'scrollTop': ul.scrollTop() + li.offset().top  + li.outerHeight() - ul.offset().top  - ul.height()
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    34
                });
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    35
            }
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    36
        }
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    37
    }),
f076ddd29e13 Playlist scroll to show playing track in view always
Chloe Laisne <chloe.laisne@gmail.com>
parents: 317
diff changeset
    38
215
82878d132784 Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents: 212
diff changeset
    39
    init: function() {
82878d132784 Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents: 212
diff changeset
    40
        this._super(...arguments);
82878d132784 Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents: 212
diff changeset
    41
    },
82878d132784 Play/Pause/Reset events from player/playlist-components
Chloe Laisne <chloe.laisne@gmail.com>
parents: 212
diff changeset
    42
209
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
    43
    didRender: function() {
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
    44
        this._super(...arguments);
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
    45
        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
    46
    },
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
    47
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
    48
    actions: {
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
    49
252
ba4fd614582a Load player with selected row
Chloe Laisne <chloe.laisne@gmail.com>
parents: 251
diff changeset
    50
        select: function(id) {
ba4fd614582a Load player with selected row
Chloe Laisne <chloe.laisne@gmail.com>
parents: 251
diff changeset
    51
            this.get('player').select(id);
342
9375b692ff22 Display transcript by default
Chloe Laisne <chloe.laisne@gmail.com>
parents: 338
diff changeset
    52
            this.get('player').displayMetadata('notice');
252
ba4fd614582a Load player with selected row
Chloe Laisne <chloe.laisne@gmail.com>
parents: 251
diff changeset
    53
        },
ba4fd614582a Load player with selected row
Chloe Laisne <chloe.laisne@gmail.com>
parents: 251
diff changeset
    54
249
e4204b1a579a Quickfix micro-cuts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 240
diff changeset
    55
        play: function(id) {
e4204b1a579a Quickfix micro-cuts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 240
diff changeset
    56
            this.get('player').play(id);
e4204b1a579a Quickfix micro-cuts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 240
diff changeset
    57
        },
e4204b1a579a Quickfix micro-cuts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 240
diff changeset
    58
257
eba9edbd8f46 Add title to annotation
Chloe Laisne <chloe.laisne@gmail.com>
parents: 254
diff changeset
    59
        pause: function() {
249
e4204b1a579a Quickfix micro-cuts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 240
diff changeset
    60
            this.get('player').pause();
227
5c9250f55f4b Basic notice logic from query parameters
Chloe Laisne <chloe.laisne@gmail.com>
parents: 216
diff changeset
    61
        },
5c9250f55f4b Basic notice logic from query parameters
Chloe Laisne <chloe.laisne@gmail.com>
parents: 216
diff changeset
    62
301
29b425234094 Transcript icon in tool container + Toggle transcript action on click
Chloe Laisne <chloe.laisne@gmail.com>
parents: 257
diff changeset
    63
        displayTranscript: function() {
29b425234094 Transcript icon in tool container + Toggle transcript action on click
Chloe Laisne <chloe.laisne@gmail.com>
parents: 257
diff changeset
    64
            this.get('player').displayAdditionalInformation('transcript');
29b425234094 Transcript icon in tool container + Toggle transcript action on click
Chloe Laisne <chloe.laisne@gmail.com>
parents: 257
diff changeset
    65
        },
29b425234094 Transcript icon in tool container + Toggle transcript action on click
Chloe Laisne <chloe.laisne@gmail.com>
parents: 257
diff changeset
    66
227
5c9250f55f4b Basic notice logic from query parameters
Chloe Laisne <chloe.laisne@gmail.com>
parents: 216
diff changeset
    67
        displayNotice: function(id) {
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
    68
            if(this.get('player').get('window') !== 'notice') {
254
a7cf2887e993 Hide/Show video CSS
Chloe Laisne <chloe.laisne@gmail.com>
parents: 252
diff changeset
    69
                this.get('player').displayMetadata('notice');
227
5c9250f55f4b Basic notice logic from query parameters
Chloe Laisne <chloe.laisne@gmail.com>
parents: 216
diff changeset
    70
            } 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
    71
                this.get('player').displayMetadata(false);
227
5c9250f55f4b Basic notice logic from query parameters
Chloe Laisne <chloe.laisne@gmail.com>
parents: 216
diff changeset
    72
            }
209
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
    73
        }
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
    74
35cb7200bb0a Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents: 201
diff changeset
    75
    }
196
7550cb541901 Filter as a service
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    76
7550cb541901 Filter as a service
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    77
});