Hide/show transcript button in the player - Do not request transscript when property is null in the document request
authorChloe Laisne <chloe.laisne@gmail.com>
Fri, 05 Aug 2016 18:51:59 +0200
changeset 253 0be9770b09b4
parent 252 ba4fd614582a
child 254 a7cf2887e993
Hide/show transcript button in the player - Do not request transscript when property is null in the document request
cms/app-client/app/controllers/application.js
cms/app-client/app/models/document.js
cms/app-client/app/services/player.js
cms/app-client/app/styles/components/player-component.scss
cms/app-client/app/styles/components/playlist-component.scss
cms/app-client/app/templates/components/player-component.hbs
cms/app-client/app/templates/components/toolbar-component.hbs
--- a/cms/app-client/app/controllers/application.js	Fri Aug 05 15:06:06 2016 +0200
+++ b/cms/app-client/app/controllers/application.js	Fri Aug 05 18:51:59 2016 +0200
@@ -91,9 +91,13 @@
         var self = this;
         this.store.findRecord('document', this.get('player').get('item'), { reload: true }).then(function(model){
             self.get('player').set('model', model);
-        });
-        this.store.findRecord('transcript', encodeURIComponent('11280.100/crdo-09-CAYCHAX_SOUND')).then(function(model) {
-            self.get('player').set('transcript', model);
+            if (self.get('player').get('model').get('transcript')) {
+                self.store.findRecord('transcript', encodeURIComponent(self.get('player').get('item'))).then(function(model) {
+                    self.get('player').set('transcript', model);
+                });
+            } else {
+                self.get('player').set('transcript', null);
+            }
         });
     }),
 
--- a/cms/app-client/app/models/document.js	Fri Aug 05 15:06:06 2016 +0200
+++ b/cms/app-client/app/models/document.js	Fri Aug 05 18:51:59 2016 +0200
@@ -9,6 +9,7 @@
     title: DS.attr('string'),
     language: DS.attr('string'),
     publisher: DS.attr('string'),
+    transcript: DS.attr({ defaultValue: function() { return {}; } }),
 
     publishers: DS.attr({ defaultValue: function() { return []; } }),
     contributors: DS.attr({ defaultValue: function() { return []; } }),
--- a/cms/app-client/app/services/player.js	Fri Aug 05 15:06:06 2016 +0200
+++ b/cms/app-client/app/services/player.js	Fri Aug 05 18:51:59 2016 +0200
@@ -5,6 +5,7 @@
     items: [],
     item: null,
     model: null,
+    transcript: null,
 
     window: '',
     playing: false,
--- a/cms/app-client/app/styles/components/player-component.scss	Fri Aug 05 15:06:06 2016 +0200
+++ b/cms/app-client/app/styles/components/player-component.scss	Fri Aug 05 18:51:59 2016 +0200
@@ -90,7 +90,7 @@
 }
 
 .player-component #audio .progress .bar {
-    width: 226px;
+    width: 303px;
     height: 3px;
     background-color: $light-white;
     margin: -1px 60px 0 60px;
@@ -100,6 +100,10 @@
     cursor: pointer;
 }
 
+.player-component #audio.extra .progress .bar {
+    width: 226px;
+}
+
 .player-component #audio .progress .bar .value {
     width: 0%;
     height: 100%;
@@ -120,6 +124,10 @@
 }
 
 .player-component #audio .meta p:first-child {
+    margin-left: 0px;
+}
+
+.player-component #audio.extra .meta p:first-child {
     margin-left: 59px;
 }
 
--- a/cms/app-client/app/styles/components/playlist-component.scss	Fri Aug 05 15:06:06 2016 +0200
+++ b/cms/app-client/app/styles/components/playlist-component.scss	Fri Aug 05 18:51:59 2016 +0200
@@ -54,6 +54,7 @@
     border: 1px solid $dark-grey;
     cursor: pointer;
     color: inherit;
+    pointer-events: all;
 }
 
 .playlist-component ul li.playing .tools button,
--- a/cms/app-client/app/templates/components/player-component.hbs	Fri Aug 05 15:06:06 2016 +0200
+++ b/cms/app-client/app/templates/components/player-component.hbs	Fri Aug 05 18:51:59 2016 +0200
@@ -1,4 +1,4 @@
-<div id="audio">
+<div id="audio" class="{{if player.transcript 'extra'}}">
 	<div class="controls">
 		<i title="Backward" class="fa fa-backward{{if isFirst ' disabled'}}" {{action 'backward'}}>Backward</i>
 		{{#if player.playing}}
@@ -14,9 +14,9 @@
 		<span class="remaining">- {{to-minutes remaining}}</span>
 	</div>
 	<div class="controls extra">
-		<i title="Transcript" class="fa fa-bars{{if (eq player.window 'transcript') ' active'}}" {{action 'display' 'transcript'}}>
-			Transcript
-		</i>
+	{{#if player.transcript}}
+		<i title="Transcript" class="fa fa-bars{{if (eq player.window 'transcript') ' active'}}" {{action 'display' 'transcript'}}>Transcript</i>
+	{{/if}}
 	</div>
 	<div class="meta">
 		<p>
--- a/cms/app-client/app/templates/components/toolbar-component.hbs	Fri Aug 05 15:06:06 2016 +0200
+++ b/cms/app-client/app/templates/components/toolbar-component.hbs	Fri Aug 05 18:51:59 2016 +0200
@@ -1,5 +1,9 @@
 <ul>
 	<li {{ action 'display' 'notice'}} class="{{if (eq player.window 'notice') 'active'}}">Notice</li>
+{{#if player.transcript}}
 	<li {{ action 'display' 'transcript'}} class="{{if (eq player.window 'transcript') 'active'}}">Transcript</li>
-	{{#if player.model.video}}<li {{ action 'display' 'video'}} class="{{unless player.reduce 'active'}}">Video</li>{{/if}}
+{{/if}}
+{{#if player.model.video}}
+	<li {{ action 'display' 'video'}} class="{{unless player.reduce 'active'}}">Video</li>
+{{/if}}
 </ul>
\ No newline at end of file