You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
2.5 KiB

var QualityBase = new Class({
tab: '',
content: '',
setup: function(data){
var self = this;
self.qualities = data.qualities;
14 years ago
self.profiles = {}
Object.each(data.profiles, self.createProfilesClass.bind(self));
App.addEvent('load', self.addSettings.bind(self))
},
14 years ago
getProfile: function(id){
return this.profiles[id]
},
getQuality: function(id){
return this.qualities.filter(function(q){
return q.id == id;
}).pick();
},
addSettings: function(){
var self = this;
self.settings = App.getPage('Settings')
self.settings.addEvent('create', function(){
var tab = self.settings.createTab('profile', {
'label': 'Profiles',
'name': 'profile'
});
self.tab = tab.tab;
self.content = tab.content;
self.createProfiles();
self.createSizes();
})
},
/**
* Profiles
*/
createProfiles: function(){
var self = this;
self.settings.createGroup({
'label': 'Quality Profiles',
'description': 'Create your own profiles with multiple qualities.',
'class': 'test123'
}).inject(self.content).adopt(
new Element('a.add_new_profile', {
'text': 'Create a new quality profile',
'events': {
14 years ago
'click': function(){
var profile = self.createProfilesClass();
$(profile).inject(self.profile_container, 'top')
}
}
}),
self.profile_container = new Element('div.container')
)
14 years ago
Object.each(self.profiles, function(profile){
if(!profile.isCore())
$(profile).inject(self.profile_container, 'top')
})
},
14 years ago
createProfilesClass: function(data){
var self = this;
14 years ago
if(data){
return self.profiles[data.id] = new Profile(data);
}
else {
var data = {
'id': randomString()
}
return self.profiles[data.id] = new Profile(data);
}
},
/**
* Sizes
*/
createSizes: function(){
var self = this;
var group = self.settings.createGroup({
'label': 'Sizes',
'description': 'Edit the minimal and maximum sizes (in MB) for each quality.',
'advanced': true
}).inject(self.content)
new Element('div.item.head').adopt(
new Element('span.label', {'text': 'Quality'}),
new Element('span.min', {'text': 'Min'}),
new Element('span.max', {'text': 'Max'})
).inject(group)
Object.each(self.qualities, function(quality){
new Element('div.item').adopt(
new Element('span.label', {'text': quality.label}),
new Element('input.min', {'value': quality.size_min}),
new Element('input.max', {'value': quality.size_max})
).inject(group)
});
}
});
window.Quality = new QualityBase();