Wizard start

This commit is contained in:
Ruud committed 2011-12-06 00:24:45 +01:00
1 parent f788591b42
commit 0e936e9990
20 files changed
+547 -432

No files matched your search

+20 -24
View File
@@ -4,15 +4,9 @@ Page.Settings = new Class({
name: 'settings',
title: 'Change settings.',
wizard_only: false,
tabs: {
'general': {},
'searcher': {},
'providers': {},
'downloaders': {},
'notifications': {},
'renamer': {}
},
tabs: {},
open: function(action, params){
var self = this;
@@ -20,9 +14,10 @@ Page.Settings = new Class({
self.params = params;
if(!self.data)
self.getData(self.create.bind(self))
else
self.getData(self.create.bind(self));
else {
self.openTab(action);
}
},
openTab: function(action){
@@ -88,7 +83,7 @@ Page.Settings = new Class({
},
create: function(json){
var self = this
var self = this;
self.el.adopt(
self.tabs_container = new Element('ul.tabs'),
@@ -108,12 +103,7 @@ Page.Settings = new Class({
);
self.showAdvanced();
new Form.Check(self.advanced_toggle)
// Create tabs
Object.each(self.tabs, function(tab, tab_name){
self.createTab(tab_name, tab)
});
new Form.Check(self.advanced_toggle);
// Add content to tabs
Object.each(json.options, function(section, section_name){
@@ -121,6 +111,13 @@ Page.Settings = new Class({
// Add groups to content
section.groups.sortBy('order').each(function(group){
if(self.wizard_only && !group.wizard)
return;
// Create tab
if(!self.tabs[group.tab] || !self.tabs[group.tab].groups)
self.createTab(group.tab, {});
// Create the group
if(!self.tabs[group.tab].groups[group.name]){
var group_el = self.createGroup(group)
@@ -132,7 +129,7 @@ Page.Settings = new Class({
// Add options to group
group.options.sortBy('order').each(function(option){
var class_name = (option.type || 'string').capitalize();
var input = new Option[class_name](self, section_name, option.name, option);
var input = new Option[class_name](section_name, option.name, self.getValue(section_name, option.name), option);
input.inject(self.tabs[group.tab].groups[group.name]);
input.fireEvent('injected');
});
@@ -152,7 +149,7 @@ Page.Settings = new Class({
return self.tabs[tab_name].tab
var label = (tab.label || tab.name || tab_name).capitalize()
var tab_el = new Element('li').adopt(
var tab_el = new Element('li.t_'+tab_name).adopt(
new Element('a', {
'href': '/'+self.name+'/'+tab_name+'/',
'text': label
@@ -202,13 +199,13 @@ var OptionBase = new Class({
focused_class : 'focused',
save_on_change: true,
initialize: function(parent, section, name, options){
initialize: function(section, name, value, options){
var self = this
self.setOptions(options)
self.page = parent;
self.section = section;
self.name = name;
self.value = value;
self.createBase();
self.create();
@@ -316,8 +313,7 @@ var OptionBase = new Class({
},
getSettingValue: function(){
var self = this;
return self.page.getValue(self.section, self.name);
return this.value;
},
inject: function(el, position){
@@ -571,7 +567,7 @@ Option.Directory = new Class({
}
})
)
).inject(self.el)
).inject(self.input, 'before');
new Form.Check(self.show_hidden);
}
+203 -200
View File
@@ -24,216 +24,219 @@ Page.Wanted = new Class({
});
var MovieActions = {};
window.addEvent('domready', function(){
MovieActions.Wanted = {
'IMBD': IMDBAction
,'releases': ReleaseAction
,'Edit': new Class({
Extends: MovieAction,
create: function(){
var self = this;
self.el = new Element('a.edit', {
'title': 'Refresh the movie info and do a forced search',
'events': {
'click': self.editMovie.bind(self)
MovieActions.Wanted = {
'IMBD': IMDBAction
,'releases': ReleaseAction
,'Edit': new Class({
Extends: MovieAction,
create: function(){
var self = this;
self.el = new Element('a.edit', {
'title': 'Refresh the movie info and do a forced search',
'events': {
'click': self.editMovie.bind(self)
}
});
},
editMovie: function(e){
var self = this;
(e).stop();
if(!self.options_container){
self.options_container = new Element('div.options').adopt(
$(self.movie.thumbnail).clone(),
new Element('div.form', {
'styles': {
'line-height': self.movie.getHeight()
}
}).adopt(
self.title_select = new Element('select', {
'name': 'title'
}),
self.profile_select = new Element('select', {
'name': 'profile'
}),
new Element('a.button.edit', {
'text': 'Save',
'events': {
'click': self.save.bind(self)
}
})
)
).inject(self.movie, 'top');
Array.each(self.movie.data.library.titles, function(alt){
new Element('option', {
'text': alt.title
}).inject(self.title_select);
});
Object.each(Quality.getActiveProfiles(), function(profile){
new Element('option', {
'value': profile.id ? profile.id : profile.data.id,
'text': profile.label ? profile.label : profile.data.label
}).inject(self.profile_select);
self.profile_select.set('value', self.movie.profile.get('id'));
});
}
});
},
editMovie: function(e){
var self = this;
(e).stop();
if(!self.options_container){
self.options_container = new Element('div.options').adopt(
$(self.movie.thumbnail).clone(),
new Element('div.form', {
self.movie.slide('in');
},
save: function(e){
(e).stop();
var self = this;
Api.request('movie.edit', {
'data': {
'id': self.movie.get('id'),
'default_title': self.title_select.get('value'),
'profile_id': self.profile_select.get('value')
},
'useSpinner': true,
'spinnerTarget': $(self.movie),
'onComplete': function(){
self.movie.quality.set('text', self.profile_select.getSelected()[0].get('text'));
self.movie.title.set('text', self.title_select.getSelected()[0].get('text'));
}
});
self.movie.slide('out');
}
})
,'Refresh': new Class({
Extends: MovieAction,
create: function(){
var self = this;
self.el = new Element('a.refresh', {
'title': 'Refresh the movie info and do a forced search',
'events': {
'click': self.doSearch.bind(self)
}
});
},
doSearch: function(e){
var self = this;
(e).stop();
Api.request('movie.refresh', {
'data': {
'id': self.movie.get('id')
}
});
}
})
,'Delete': new Class({
Extends: MovieAction,
Implements: [Chain],
create: function(){
var self = this;
self.el = new Element('a.delete', {
'title': 'Remove the movie from your wanted list',
'events': {
'click': self.showConfirm.bind(self)
}
});
},
showConfirm: function(e){
var self = this;
(e).stop();
if(!self.delete_container){
self.delete_container = new Element('div.delete_container', {
'styles': {
'line-height': self.movie.getHeight()
}
}).adopt(
self.title_select = new Element('select', {
'name': 'title'
}),
self.profile_select = new Element('select', {
'name': 'profile'
}),
new Element('a.button.edit', {
'text': 'Save',
new Element('a.cancel', {
'text': 'Cancel',
'events': {
'click': self.save.bind(self)
'click': self.hideConfirm.bind(self)
}
}),
new Element('span.or', {
'text': 'or'
}),
new Element('a.button.delete', {
'text': 'Delete ' + self.movie.title.get('text'),
'events': {
'click': self.del.bind(self)
}
})
)
).inject(self.movie, 'top');
Array.each(self.movie.data.library.titles, function(alt){
new Element('option', {
'text': alt.title
}).inject(self.title_select);
});
Object.each(Quality.getActiveProfiles(), function(profile){
new Element('option', {
'value': profile.id ? profile.id : profile.data.id,
'text': profile.label ? profile.label : profile.data.label
}).inject(self.profile_select);
self.profile_select.set('value', self.movie.profile.get('id'));
});
}
self.movie.slide('in');
},
save: function(e){
(e).stop();
var self = this;
Api.request('movie.edit', {
'data': {
'id': self.movie.get('id'),
'default_title': self.title_select.get('value'),
'profile_id': self.profile_select.get('value')
},
'useSpinner': true,
'spinnerTarget': $(self.movie),
'onComplete': function(){
self.movie.quality.set('text', self.profile_select.getSelected()[0].get('text'));
self.movie.title.set('text', self.title_select.getSelected()[0].get('text'));
).inject(self.movie, 'top');
}
});
self.movie.slide('out');
}
})
,'Refresh': new Class({
Extends: MovieAction,
create: function(){
var self = this;
self.el = new Element('a.refresh', {
'title': 'Refresh the movie info and do a forced search',
'events': {
'click': self.doSearch.bind(self)
}
});
},
doSearch: function(e){
var self = this;
(e).stop();
Api.request('movie.refresh', {
'data': {
'id': self.movie.get('id')
}
});
}
})
,'Delete': new Class({
Extends: MovieAction,
Implements: [Chain],
create: function(){
var self = this;
self.el = new Element('a.delete', {
'title': 'Remove the movie from your wanted list',
'events': {
'click': self.showConfirm.bind(self)
}
});
},
showConfirm: function(e){
var self = this;
(e).stop();
if(!self.delete_container){
self.delete_container = new Element('div.delete_container', {
'styles': {
'line-height': self.movie.getHeight()
self.movie.slide('in');
},
hideConfirm: function(e){
var self = this;
(e).stop();
self.movie.slide('out');
},
del: function(e){
(e).stop();
var self = this;
var movie = $(self.movie);
self.chain(
function(){
self.callChain();
},
function(){
Api.request('movie.delete', {
'data': {
'id': self.movie.get('id')
},
'onComplete': function(){
movie.set('tween', {
'onComplete': function(){
movie.destroy();
}
});
movie.tween('height', 0);
}
});
}
}).adopt(
new Element('a.cancel', {
'text': 'Cancel',
'events': {
'click': self.hideConfirm.bind(self)
}
}),
new Element('span.or', {
'text': 'or'
}),
new Element('a.button.delete', {
'text': 'Delete ' + self.movie.title.get('text'),
'events': {
'click': self.del.bind(self)
}
})
).inject(self.movie, 'top');
);
self.callChain();
}
})
};
MovieActions.Snatched = {
'IMBD': IMDBAction
,'Delete': MovieActions.Wanted.Delete
};
self.movie.slide('in');
},
hideConfirm: function(e){
var self = this;
(e).stop();
self.movie.slide('out');
},
del: function(e){
(e).stop();
var self = this;
var movie = $(self.movie);
self.chain(
function(){
self.callChain();
},
function(){
Api.request('movie.delete', {
'data': {
'id': self.movie.get('id')
},
'onComplete': function(){
movie.set('tween', {
'onComplete': function(){
movie.destroy();
}
});
movie.tween('height', 0);
}
});
}
);
self.callChain();
}
})
};
MovieActions.Snatched = {
'IMBD': IMDBAction
,'Delete': MovieActions.Wanted.Delete
};
})