# HG changeset patch # User Chloe Laisne # Date 1469137010 -7200 # Node ID 5b7ae96768be72ca166e33ddac9fcba747af0950 # Parent c9dd78a43b076d0d5ac888a57b7dac5ca95f74b4 Bsic transcript-component design Autoscroll transcript diff -r c9dd78a43b07 -r 5b7ae96768be cms/app-client/app/components/player-component.js --- a/cms/app-client/app/components/player-component.js Wed Jul 20 21:08:31 2016 +0200 +++ b/cms/app-client/app/components/player-component.js Thu Jul 21 23:36:50 2016 +0200 @@ -55,11 +55,12 @@ }, onUpdate: function() { - var currentTime = this.get('popcorn').currentTime(); + var progress = this.get('popcorn').currentTime(); var duration = this.get('popcorn').duration(); - this.$('.bar .value').width(currentTime * 100 / duration + '%'); - this.set('head', currentTime); - this.set('remaining', duration - currentTime); + this.$('.bar .value').width(progress * 100 / duration + '%'); + this.get('player').set('progress', progress * 1000); + this.set('head', progress); + this.set('remaining', duration - progress); }, onPlay: function() { diff -r c9dd78a43b07 -r 5b7ae96768be cms/app-client/app/components/transcript-component.js --- a/cms/app-client/app/components/transcript-component.js Wed Jul 20 21:08:31 2016 +0200 +++ b/cms/app-client/app/components/transcript-component.js Thu Jul 21 23:36:50 2016 +0200 @@ -2,8 +2,30 @@ export default Ember.Component.extend({ - player: Ember.inject.service(), + classNames: ['transcript-component'], + + player: Ember.inject.service(), + + autoscroll: true, + autoscrollElement : Ember.$('.corpus-app-container'), + + itemObserver: Ember.observer('player.item', function () { + this.set('autoscroll', true); + }), - language: 'fr' + init: function() { + var self = this; + this.get('autoscrollElement').bind('scroll', function() { + self.set('autoscroll', false); + }); + + this._super(...arguments); + }, + + didUpdate: function() { + if(this.get('autoscroll')) { + this.get('autoscrollElement').scrollTop((Ember.$('.sentence.active').offset().top + this.get('autoscrollElement').scrollTop()) - this.get('autoscrollElement').offset().top) + } + } }); diff -r c9dd78a43b07 -r 5b7ae96768be cms/app-client/app/helpers/if-operator.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cms/app-client/app/helpers/if-operator.js Thu Jul 21 23:36:50 2016 +0200 @@ -0,0 +1,23 @@ +import Ember from 'ember'; + +export function ifOperator([value1, operator, value2]) { + switch(operator) { + case '>': + return value1 > value2; + break; + case '>=': + return value1 >= value2; + break; + case '<=': + return value1 <= value2; + break; + case '<': + return value1 < value2; + break; + default: + break; + } + return; +} + +export default Ember.Helper.helper(ifOperator); diff -r c9dd78a43b07 -r 5b7ae96768be cms/app-client/app/services/player.js --- a/cms/app-client/app/services/player.js Wed Jul 20 21:08:31 2016 +0200 +++ b/cms/app-client/app/services/player.js Thu Jul 21 23:36:50 2016 +0200 @@ -8,6 +8,7 @@ window: '', playing: false, + progress: 0, reduce: false, init: function() { diff -r c9dd78a43b07 -r 5b7ae96768be cms/app-client/app/styles/app.scss --- a/cms/app-client/app/styles/app.scss Wed Jul 20 21:08:31 2016 +0200 +++ b/cms/app-client/app/styles/app.scss Thu Jul 21 23:36:50 2016 +0200 @@ -1,4 +1,5 @@ $dark-blue: #13212d; +$grey-blue: #71848d; $medium-blue: #253946; $light-blue: #becfd4; $blue: #2faddd; @@ -46,6 +47,7 @@ @import 'components/player-component'; @import 'components/toolbar-component'; @import 'components/notice-component'; + @import 'components/transcript-component'; } @@ -124,6 +126,10 @@ border-top: none; } +.corpus-app-container.window { + overflow: scroll; +} + .corpus-app-modal { position: absolute; top: 0px; diff -r c9dd78a43b07 -r 5b7ae96768be cms/app-client/app/styles/components/transcript-component.scss --- a/cms/app-client/app/styles/components/transcript-component.scss Wed Jul 20 21:08:31 2016 +0200 +++ b/cms/app-client/app/styles/components/transcript-component.scss Thu Jul 21 23:36:50 2016 +0200 @@ -0,0 +1,18 @@ +.transcript-component { + background-color: $light-blue; + padding: 20px; +} + +.transcript-component .sentence { + padding: 20px; + color: $medium-grey; +} + +.transcript-component .sentence.active { + background-color: $grey-blue; + color: $light-white; +} + +.transcript-component .sentence.active .translation { + color: $light-blue; +} \ No newline at end of file diff -r c9dd78a43b07 -r 5b7ae96768be cms/app-client/app/templates/application.hbs --- a/cms/app-client/app/templates/application.hbs Wed Jul 20 21:08:31 2016 +0200 +++ b/cms/app-client/app/templates/application.hbs Thu Jul 21 23:36:50 2016 +0200 @@ -6,7 +6,7 @@ {{ notice-component class="overlay" model=noticeModel }} {{/if}} -
+
{{#if player.window}} {{#if (eq player.window 'notice')}} {{ notice-component }} diff -r c9dd78a43b07 -r 5b7ae96768be cms/app-client/app/templates/components/transcript-component.hbs --- a/cms/app-client/app/templates/components/transcript-component.hbs Wed Jul 20 21:08:31 2016 +0200 +++ b/cms/app-client/app/templates/components/transcript-component.hbs Thu Jul 21 23:36:50 2016 +0200 @@ -1,8 +1,10 @@

{{player.transcript.title}}

{{#each player.transcript.annotations as |annotation|}} - Play -

{{annotation.content}}

-

{{annotation.translation}}

+
+ Play +

{{annotation.content}}

+

{{annotation.translation}}

+
{{/each}}
\ No newline at end of file diff -r c9dd78a43b07 -r 5b7ae96768be cms/app-client/tests/unit/helpers/if-operator-test.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cms/app-client/tests/unit/helpers/if-operator-test.js Thu Jul 21 23:36:50 2016 +0200 @@ -0,0 +1,10 @@ +import { ifOperator } from 'app-client/helpers/if-operator'; +import { module, test } from 'qunit'; + +module('Unit | Helper | if operator'); + +// Replace this with your real tests. +test('it works', function(assert) { + let result = ifOperator([42]); + assert.ok(result); +});