Browse Source

Cleanup javascript events on movie delete

pull/874/merge
Ruud 13 years ago
parent
commit
3a3a4fb1f3
  1. 12
      couchpotato/core/plugins/movie/static/list.js
  2. 23
      couchpotato/core/plugins/movie/static/movie.js
  3. 2
      couchpotato/core/plugins/movie/static/search.js
  4. 2
      couchpotato/static/scripts/page/wanted.js

12
couchpotato/core/plugins/movie/static/list.js

@ -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();

23
couchpotato/core/plugins/movie/static/movie.js

@ -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;

2
couchpotato/core/plugins/movie/static/search.js

@ -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){

2
couchpotato/static/scripts/page/wanted.js

@ -222,7 +222,7 @@ window.addEvent('domready', function(){
movie.set('tween', {
'duration': 300,
'onComplete': function(){
movie.destroy();
self.movie.destroy()
}
});
movie.tween('height', 0);

Loading…
Cancel
Save