2014-11-20 22:25:33 +00:00
|
|
|
function setFromPresets (preset) {
|
2015-07-16 23:09:27 +00:00
|
|
|
var elCustomQuality = $('.show-if-quality-custom'),
|
2018-01-29 02:26:23 +00:00
|
|
|
selected = 'selected', quality, selectState, btn$, dev = !1;
|
2015-09-29 13:17:58 +00:00
|
|
|
if (preset = parseInt(preset)) {
|
2018-01-29 02:26:23 +00:00
|
|
|
!dev && elCustomQuality.fadeOut('fast', 'linear');
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-09-29 13:17:58 +00:00
|
|
|
var upgrade = !0;
|
2018-01-29 02:26:23 +00:00
|
|
|
$('#initial-qualities, #upgrade-qualities').find('option').each(function() {
|
|
|
|
if (upgrade && 'upgrade-qualities' === $(this).parent().attr('id')) {
|
2015-09-29 13:17:58 +00:00
|
|
|
upgrade = !1;
|
|
|
|
switch (preset) {
|
|
|
|
case 3: preset = 128 + 32 + 4; break;
|
|
|
|
case 164: preset = 256 + 64 + 16 + 4; break;
|
|
|
|
case 336: preset = 256; break;
|
|
|
|
default: preset = 0;
|
|
|
|
}
|
|
|
|
}
|
2018-01-29 02:26:23 +00:00
|
|
|
|
|
|
|
quality = $(this).val();
|
|
|
|
selectState = ((preset & parseInt(quality, 10)) ? selected : !1);
|
|
|
|
$(this).attr(selected, selectState);
|
|
|
|
|
|
|
|
var list = /initial/.test($(this).parent().attr('id')) ? '#initial-quality': '#upgrade-quality';
|
|
|
|
btn$ = $(/initial/.test($(this).parent().attr('id')) ? '#initial-quality': '#upgrade-quality').find('a.btn[data-quality="' + quality + '"]');
|
|
|
|
if(!selectState){
|
|
|
|
btn$.removeClass('active')
|
|
|
|
|
|
|
|
} else {
|
|
|
|
btn$.addClass('active')
|
|
|
|
}
|
|
|
|
dev && console.log(preset, list, 'this.val():', quality, 'selectState:', selectState, 'hasClass:', btn$.hasClass('active'))
|
2015-09-29 13:17:58 +00:00
|
|
|
});
|
2018-01-29 02:26:23 +00:00
|
|
|
dev && console.log('-----------------------');
|
2015-09-29 13:17:58 +00:00
|
|
|
} else
|
2016-02-19 17:38:38 +00:00
|
|
|
elCustomQuality.fadeIn('fast', 'linear');
|
2016-11-14 21:33:15 +00:00
|
|
|
|
|
|
|
presentTips();
|
|
|
|
}
|
|
|
|
|
|
|
|
function presentTips() {
|
2018-01-29 02:26:23 +00:00
|
|
|
var tip$ = $('#unknown-quality');
|
|
|
|
if ($('#initial-quality').find('a.btn[data-quality="32768"]').hasClass('active')) {
|
|
|
|
tip$.fadeIn('fast', 'linear');
|
|
|
|
} else {
|
2016-11-14 21:33:15 +00:00
|
|
|
tip$.fadeOut('fast', 'linear');
|
2018-01-29 02:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var tip$ = $('#no-upgrade'), tip2$ = $('#upgrade-cond');
|
|
|
|
if ($('#upgrade-quality').find('a.btn').hasClass('active')) {
|
|
|
|
tip$.fadeOut('fast', 'linear', function(){tip2$.fadeIn('fast', 'linear');});
|
2016-11-14 21:33:15 +00:00
|
|
|
} else {
|
2018-01-29 02:26:23 +00:00
|
|
|
tip2$.fadeOut('fast', 'linear', function(){tip$.fadeIn('fast', 'linear');});
|
2016-11-14 21:33:15 +00:00
|
|
|
}
|
2014-11-20 22:25:33 +00:00
|
|
|
}
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2018-01-29 02:26:23 +00:00
|
|
|
$(function() {
|
|
|
|
var elQualityPreset = $('#quality-preset'),
|
2014-11-20 22:25:33 +00:00
|
|
|
selected = ':selected';
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-11-20 22:25:33 +00:00
|
|
|
elQualityPreset.change(function() {
|
2015-09-29 13:17:58 +00:00
|
|
|
setFromPresets($(this).find(selected).val());
|
2014-11-20 22:25:33 +00:00
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-11-20 22:25:33 +00:00
|
|
|
setFromPresets(elQualityPreset.find(selected).val());
|
2016-11-14 21:33:15 +00:00
|
|
|
|
2018-01-29 02:26:23 +00:00
|
|
|
$('#initial-qualities').change(function() {
|
|
|
|
presentTips();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#custom-quality').find('a[href="#"].btn').on('click', function(event){
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
$(this).toggleClass('active');
|
|
|
|
|
|
|
|
var select$ = $('initial-quality' === $(this).closest('.component-desc').attr('id') ? '#initial-qualities' : '#upgrade-qualities'),
|
|
|
|
quality = $(this).data('quality'), arrSelected = $.map(select$.val(), function(v){return parseInt(v, 10)}) || Array();
|
|
|
|
|
|
|
|
if($(this).hasClass('active')){
|
|
|
|
arrSelected.push(quality);
|
|
|
|
} else {
|
|
|
|
arrSelected = arrSelected.filter(function(elem){
|
|
|
|
return elem !== quality;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
select$.val(arrSelected).change();
|
|
|
|
|
2016-11-14 21:33:15 +00:00
|
|
|
presentTips();
|
2018-01-29 02:26:23 +00:00
|
|
|
return !1;
|
2016-11-14 21:33:15 +00:00
|
|
|
});
|
2016-02-19 17:38:38 +00:00
|
|
|
});
|