Different actions per movie status

This commit is contained in:
Ruud
2011-09-07 17:24:02 +02:00
parent 603a325a21
commit 517e79dfce
+40 -38
View File
@@ -9,11 +9,11 @@ Page.Wanted = new Class({
var self = this; var self = this;
if(!self.list){ if(!self.list){
// Wanted movies // Wanted movies
self.wanted = new MovieList({ self.wanted = new MovieList({
'status': ['active', 'snatched'], 'status': ['active', 'snatched'],
'actions': WantedActions 'actions': MovieActions
}); });
$(self.wanted).inject(self.el); $(self.wanted).inject(self.el);
App.addEvent('library.update', self.wanted.update.bind(self.wanted)); App.addEvent('library.update', self.wanted.update.bind(self.wanted));
@@ -23,30 +23,32 @@ Page.Wanted = new Class({
}); });
var WantedActions = { var MovieActions = {};
MovieActions.Wanted = {
'IMBD': IMDBAction 'IMBD': IMDBAction
//,'releases': ReleaseAction //,'releases': ReleaseAction
,'Edit': new Class({ ,'Edit': new Class({
Extends: MovieAction, Extends: MovieAction,
create: function(){ create: function(){
var self = this; var self = this;
self.el = new Element('a.edit', { self.el = new Element('a.edit', {
'title': 'Refresh the movie info and do a forced search', 'title': 'Refresh the movie info and do a forced search',
'events': { 'events': {
'click': self.editMovie.bind(self) 'click': self.editMovie.bind(self)
} }
}); });
}, },
editMovie: function(e){ editMovie: function(e){
var self = this; var self = this;
(e).stop(); (e).stop();
if(!self.options_container){ if(!self.options_container){
self.options_container = new Element('div.options').adopt( self.options_container = new Element('div.options').adopt(
$(self.movie.thumbnail).clone(), $(self.movie.thumbnail).clone(),
@@ -69,13 +71,13 @@ var WantedActions = {
}) })
) )
).inject(self.movie, 'top'); ).inject(self.movie, 'top');
Array.each(self.movie.data.library.titles, function(alt){ Array.each(self.movie.data.library.titles, function(alt){
new Element('option', { new Element('option', {
'text': alt.title 'text': alt.title
}).inject(self.title_select); }).inject(self.title_select);
}); });
Object.each(Quality.profiles, function(profile){ Object.each(Quality.profiles, function(profile){
new Element('option', { new Element('option', {
'value': profile.id ? profile.id : profile.data.id, 'value': profile.id ? profile.id : profile.data.id,
@@ -83,15 +85,15 @@ var WantedActions = {
}).inject(self.profile_select); }).inject(self.profile_select);
self.profile_select.set('value', self.movie.profile.get('id')); self.profile_select.set('value', self.movie.profile.get('id'));
}); });
} }
self.movie.slide('in'); self.movie.slide('in');
}, },
save: function(e){ save: function(e){
(e).stop(); (e).stop();
var self = this; var self = this;
Api.request('movie.edit', { Api.request('movie.edit', {
'data': { 'data': {
'id': self.movie.get('id'), 'id': self.movie.get('id'),
@@ -105,63 +107,63 @@ var WantedActions = {
self.movie.title.set('text', self.title_select.getSelected()[0].get('text')); self.movie.title.set('text', self.title_select.getSelected()[0].get('text'));
} }
}); });
self.movie.slide('out'); self.movie.slide('out');
} }
}) })
,'Refresh': new Class({ ,'Refresh': new Class({
Extends: MovieAction, Extends: MovieAction,
create: function(){ create: function(){
var self = this; var self = this;
self.el = new Element('a.refresh', { self.el = new Element('a.refresh', {
'title': 'Refresh the movie info and do a forced search', 'title': 'Refresh the movie info and do a forced search',
'events': { 'events': {
'click': self.doSearch.bind(self) 'click': self.doSearch.bind(self)
} }
}); });
}, },
doSearch: function(e){ doSearch: function(e){
var self = this; var self = this;
(e).stop(); (e).stop();
Api.request('movie.refresh', { Api.request('movie.refresh', {
'data': { 'data': {
'id': self.movie.get('id') 'id': self.movie.get('id')
} }
}); });
} }
}) })
,'Delete': new Class({ ,'Delete': new Class({
Extends: MovieAction, Extends: MovieAction,
Implements: [Chain], Implements: [Chain],
create: function(){ create: function(){
var self = this; var self = this;
self.el = new Element('a.delete', { self.el = new Element('a.delete', {
'title': 'Remove the movie from your wanted list', 'title': 'Remove the movie from your wanted list',
'events': { 'events': {
'click': self.showConfirm.bind(self) 'click': self.showConfirm.bind(self)
} }
}); });
}, },
showConfirm: function(e){ showConfirm: function(e){
var self = this; var self = this;
(e).stop(); (e).stop();
if(!self.delete_container){ if(!self.delete_container){
self.delete_container = new Element('div.delete_container', { self.delete_container = new Element('div.delete_container', {
'styles': { 'styles': {
@@ -185,24 +187,24 @@ var WantedActions = {
}) })
).inject(self.movie, 'top'); ).inject(self.movie, 'top');
} }
self.movie.slide('in'); self.movie.slide('in');
}, },
hideConfirm: function(e){ hideConfirm: function(e){
var self = this; var self = this;
(e).stop(); (e).stop();
self.movie.slide('out'); self.movie.slide('out');
}, },
del: function(e){ del: function(e){
(e).stop(); (e).stop();
var self = this; var self = this;
var movie = $(self.movie); var movie = $(self.movie);
self.chain( self.chain(
function(){ function(){
$(movie).mask().addClass('loading'); $(movie).mask().addClass('loading');
@@ -224,16 +226,16 @@ var WantedActions = {
}); });
} }
); );
self.callChain(); self.callChain();
} }
}) })
}; };
var SnatchedActions = { MovieActions.Snatched = {
'IMBD': IMDBAction 'IMBD': IMDBAction
,'Releases': ReleaseAction ,'Releases': ReleaseAction
,'Delete': WantedActions.Delete ,'Delete': MovieActions.Wanted.Delete
}; };