Cleanup javascript events on movie delete
This commit is contained in:
@@ -86,18 +86,18 @@ var MovieList = new Class({
|
||||
Object.each(movies, function(movie){
|
||||
self.createMovie(movie);
|
||||
});
|
||||
|
||||
|
||||
self.setCounter(total);
|
||||
|
||||
},
|
||||
|
||||
|
||||
setCounter: function(count){
|
||||
var self = this;
|
||||
|
||||
|
||||
if(!self.navigation_counter) return;
|
||||
|
||||
|
||||
self.navigation_counter.set('text', (count || 0));
|
||||
|
||||
|
||||
},
|
||||
|
||||
createMovie: function(movie, inject_at){
|
||||
@@ -309,6 +309,8 @@ var MovieList = new Class({
|
||||
|
||||
erase_movies.each(function(movie){
|
||||
self.movies.erase(movie);
|
||||
|
||||
movie.destroy()
|
||||
});
|
||||
|
||||
self.calculateSelected();
|
||||
|
||||
@@ -16,16 +16,35 @@ var Movie = new Class({
|
||||
self.profile = Quality.getProfile(data.profile_id) || {};
|
||||
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){
|
||||
App.addEvent(listener+'.'+data.id, function(notification){
|
||||
App.addEvent(listener+'.'+self.data.id, function(notification){
|
||||
if(notification.data)
|
||||
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){
|
||||
var self = this;
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ Block.Search.Item = new Class({
|
||||
var self = this;
|
||||
|
||||
if(!self.options.hasClass('set')){
|
||||
|
||||
|
||||
if(self.info.in_library){
|
||||
var in_library = [];
|
||||
self.info.in_library.releases.each(function(release){
|
||||
|
||||
@@ -222,7 +222,7 @@ window.addEvent('domready', function(){
|
||||
movie.set('tween', {
|
||||
'duration': 300,
|
||||
'onComplete': function(){
|
||||
movie.destroy();
|
||||
self.movie.destroy()
|
||||
}
|
||||
});
|
||||
movie.tween('height', 0);
|
||||
|
||||
Reference in New Issue
Block a user