Cleanup javascript events on movie delete

This commit is contained in:
Ruud committed 2012-09-25 23:11:27 +02:00
1 parent 3fa352e7c8
commit 3a3a4fb1f3
3 files changed
+24 -3

No files matched your search

@@ -309,6 +309,8 @@ var MovieList = new Class({
erase_movies.each(function(movie){ erase_movies.each(function(movie){
self.movies.erase(movie); self.movies.erase(movie);
movie.destroy()
}); });
self.calculateSelected(); self.calculateSelected();
+21 -2
View File
@@ -16,16 +16,35 @@ var Movie = new Class({
self.profile = Quality.getProfile(data.profile_id) || {}; self.profile = Quality.getProfile(data.profile_id) || {};
self.parent(self, options); self.parent(self, options);
App.addEvent('movie.update.'+data.id, self.update.bind(self)); self.addEvents();
},
addEvents: function(){
var self = this;
App.addEvent('movie.update.'+self.data.id, self.update.bind(self));
['movie.busy', 'searcher.started'].each(function(listener){ ['movie.busy', 'searcher.started'].each(function(listener){
App.addEvent(listener+'.'+data.id, function(notification){ App.addEvent(listener+'.'+self.data.id, function(notification){
if(notification.data) if(notification.data)
self.busy(true) self.busy(true)
}); });
}) })
}, },
destroy: function(){
var self = this;
self.el.destroy();
delete self.list.movies_added[self.get('id')];
// Remove events
App.removeEvents('movie.update.'+self.data.id);
['movie.busy', 'searcher.started'].each(function(listener){
App.removeEvents(listener+'.'+self.data.id);
})
},
busy: function(set_busy){ busy: function(set_busy){
var self = this; var self = this;
+1 -1
View File
@@ -222,7 +222,7 @@ window.addEvent('domready', function(){
movie.set('tween', { movie.set('tween', {
'duration': 300, 'duration': 300,
'onComplete': function(){ 'onComplete': function(){
movie.destroy(); self.movie.destroy()
} }
}); });
movie.tween('height', 0); movie.tween('height', 0);