cms/app-client/app/components/player-component.js
changeset 302 973df1349591
parent 272 97c06607949b
child 306 3fccf43160a7
equal deleted inserted replaced
301:29b425234094 302:973df1349591
    16     isLast: false,
    16     isLast: false,
    17 
    17 
    18     item: Ember.computed('player.model', function() {
    18     item: Ember.computed('player.model', function() {
    19         return this.get('player').get('model');
    19         return this.get('player').get('model');
    20     }),
    20     }),
       
    21 
       
    22     didRender: function() {
       
    23         this.textAutoscroll(Ember.$('#' + this.elementId).find('.title'));
       
    24         this.textAutoscroll(Ember.$('#' + this.elementId).find('.author'));
       
    25     },
    21 
    26 
    22     modelLoaded: Ember.observer('player.model', function() {
    27     modelLoaded: Ember.observer('player.model', function() {
    23         var items = this.get('player').get('items');
    28         var items = this.get('player').get('items');
    24         var index = items.indexOf(this.get('player').get('item'));
    29         var index = items.indexOf(this.get('player').get('item'));
    25         this.set('isFirst', index === 0);
    30         this.set('isFirst', index === 0);
    60                 this.get('popcorn').on('loadeddata', Ember.run.bind(this, this.get('play')));
    65                 this.get('popcorn').on('loadeddata', Ember.run.bind(this, this.get('play')));
    61             } else {
    66             } else {
    62                 this.send('toggle');
    67                 this.send('toggle');
    63             }
    68             }
    64         }));
    69         }));
       
    70     },
       
    71 
       
    72     textAutoscroll: function(jElement) {
       
    73         var text = jElement.find('span');
       
    74         text.stop(true);
       
    75         text.css('text-indent', '0px');
       
    76         if(text.width() > jElement.width()) {
       
    77             var duration = ( ( text.width() - jElement.width() ) * 8 / 100 ) * 1000;
       
    78             function animate() {
       
    79                 text.delay(4000)
       
    80                     .animate({
       
    81                         'text-indent': -( text.width() - jElement.width() ) + 'px'
       
    82                     }, duration, 'linear', function() {
       
    83                         text.stop(true);
       
    84                         text.css('text-indent', '0px')
       
    85                         window.setTimeout(function() { animate() }, 1);
       
    86                     });
       
    87             }
       
    88             animate();
       
    89         }
    65     },
    90     },
    66 
    91 
    67     onUpdate: function() {
    92     onUpdate: function() {
    68         var progress = this.get('popcorn').currentTime();
    93         var progress = this.get('popcorn').currentTime();
    69         var duration = this.get('popcorn').duration();
    94         var duration = this.get('popcorn').duration();