cms/app-client/app/controllers/application.js
changeset 209 35cb7200bb0a
parent 204 dd969e178944
child 212 f2c6080a73aa
--- a/cms/app-client/app/controllers/application.js	Fri Jun 24 17:07:24 2016 +0200
+++ b/cms/app-client/app/controllers/application.js	Mon Jun 27 11:35:10 2016 +0200
@@ -85,22 +85,27 @@
         return true;
     },
 
+    player: Ember.inject.service(),
+
     detail: null,
 
-    currentId: null,
-    currentItem: Ember.computed('currentId', function() {
-        Ember.$(".result-item").toggleClass("playing", false);
-        if (this.get('currentId') === null){
-            return null;
-        }
-        Ember.$("div[id='" + this.get('currentId') + "']").toggleClass("playing", true);
-        return this.store.findRecord('document', this.get('currentId'));
-    }),
 
     modalItem: Ember.computed('detail', function() {
         return this.store.findRecord('document', this.get('detail'));
     }),
 
+    itemIdObserver: Ember.observer('player.itemId', function() {
+        var self = this;
+        this.store.findRecord('document', this.get('player').get('itemId'), { reload: true }).then(function(it){
+            self.get('player').set('item', it);
+        });
+    }),
+
+    init: function() {
+        this._super(...arguments);
+        this.get('player');
+    },
+
     actions: {
 
         changeDocument: function(docDirection){