2012-03-01 17:33:46 +00:00
|
|
|
$(document).ready(function() {
|
2012-05-25 08:26:42 +01:00
|
|
|
// TODO: Refactor this handler!! It's too complicated.
|
2012-05-05 22:43:04 +01:00
|
|
|
$('#build_list_save_to_platform_id').change(function() {
|
2012-03-01 17:33:46 +00:00
|
|
|
var platform_id = $(this).val();
|
2012-03-19 19:52:46 +00:00
|
|
|
var base_platforms = $('.all_platforms input[type=checkbox].build_bpl_ids');
|
2012-03-01 17:33:46 +00:00
|
|
|
|
|
|
|
base_platforms.each(function(){
|
|
|
|
if ($.inArray(platform_id, base_platforms.map(function(){ return $(this).val() }).get()) >= 0) {
|
|
|
|
if ($(this).val() == platform_id) {
|
2012-04-17 19:18:39 +01:00
|
|
|
if ($(this).attr('data-released') === '1') {
|
|
|
|
$('#build_list_auto_publish').removeAttr('checked').attr('disabled', 'disabled');
|
2012-07-06 00:05:47 +01:00
|
|
|
//disableUpdateTypes();
|
2012-04-17 19:18:39 +01:00
|
|
|
} else {
|
|
|
|
$('#build_list_auto_publish').removeAttr('disabled').attr('checked', 'checked');
|
2012-07-06 00:05:47 +01:00
|
|
|
//enableUpdateTypes();
|
2012-04-17 19:18:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$(this).attr('checked', 'checked').removeAttr('disabled').trigger('change');
|
2012-03-19 19:52:46 +00:00
|
|
|
$(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled');
|
2012-04-10 10:05:42 +01:00
|
|
|
|
2012-05-05 22:43:04 +01:00
|
|
|
var rep_name = $('#build_list_save_to_platform_id option[value="' + $(this).val() + '"]').text().match(/[\w-]+\/([\w-]+)/)[1];
|
2012-04-10 10:05:42 +01:00
|
|
|
if (rep_name != 'main') {
|
|
|
|
$(this).parent().find('.offset25 input[type="checkbox"][rep_name="' + rep_name + '"]').attr('checked', 'checked');
|
2012-03-21 11:34:11 +00:00
|
|
|
}
|
2012-04-10 10:05:42 +01:00
|
|
|
$(this).parent().find('.offset25 input[type="checkbox"][rep_name="main"]').attr('checked', 'checked');
|
2012-03-01 17:33:46 +00:00
|
|
|
} else {
|
2012-04-17 19:18:39 +01:00
|
|
|
$(this).removeAttr('checked').attr('disabled', 'disabled').trigger('change');
|
2012-04-10 14:15:48 +01:00
|
|
|
$(this).parent().find('.offset25 input[type="checkbox"]').attr('disabled', 'disabled').removeAttr('checked');
|
2012-03-01 17:33:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-04-17 19:18:39 +01:00
|
|
|
$(this).removeAttr('disabled').removeAttr('checked').trigger('change');
|
2012-04-10 14:15:48 +01:00
|
|
|
$(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled').removeAttr('checked');
|
2012-04-18 18:31:11 +01:00
|
|
|
$('#build_list_auto_publish').removeAttr('disabled').attr('checked', 'checked');
|
2012-03-01 17:33:46 +00:00
|
|
|
}
|
|
|
|
});
|
2012-04-16 17:06:34 +01:00
|
|
|
|
2012-05-25 09:28:43 +01:00
|
|
|
if ($.inArray(platform_id, base_platforms.map(function(){ return $(this).val() }).get()) == -1) {
|
|
|
|
// For personal platforms update types always enebaled:
|
|
|
|
enableUpdateTypes();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-16 17:06:34 +01:00
|
|
|
setBranchSelected();
|
2012-03-01 17:33:46 +00:00
|
|
|
});
|
2012-05-05 22:43:04 +01:00
|
|
|
$('#build_list_save_to_platform_id').trigger('change');
|
2012-03-21 15:04:01 +00:00
|
|
|
|
|
|
|
$('.offset25 label').click(function() {
|
|
|
|
setPlChecked($(this).prev()[0], !$(this).prev().attr('checked'));
|
|
|
|
});
|
|
|
|
$('.offset25 input[type="checkbox"]').click(function() {
|
|
|
|
setPlChecked(this, $(this).attr('checked'));
|
|
|
|
});
|
2012-04-09 15:33:51 +01:00
|
|
|
|
|
|
|
$('.build_bpl_ids').click(function() {
|
|
|
|
return false;
|
|
|
|
});
|
2012-05-24 11:21:57 +01:00
|
|
|
|
2012-03-01 17:33:46 +00:00
|
|
|
});
|
2012-03-21 15:04:01 +00:00
|
|
|
|
|
|
|
function setPlChecked(pointer, checked) {
|
2012-04-09 15:33:51 +01:00
|
|
|
var pl_cbx = $(pointer).parent().parent().parent().find('input[type="checkbox"].build_bpl_ids');
|
|
|
|
var pl_id = pl_cbx.val();
|
2012-03-21 15:04:01 +00:00
|
|
|
if (checked && !$(pointer).attr('disabled')) {
|
2012-04-17 19:18:39 +01:00
|
|
|
pl_cbx.attr('checked', 'checked').trigger('change');
|
2012-04-09 15:33:51 +01:00
|
|
|
} else if ($('input[pl_id=' + pl_id + '][checked="checked"]').size() == 0) {
|
2012-04-17 19:18:39 +01:00
|
|
|
pl_cbx.removeAttr('checked').trigger('change');
|
2012-03-21 15:04:01 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-16 17:06:34 +01:00
|
|
|
|
|
|
|
function setBranchSelected() {
|
2012-05-05 22:43:04 +01:00
|
|
|
var pl_id = $('#build_list_save_to_platform_id').val();
|
2012-04-16 17:06:34 +01:00
|
|
|
// Checks if selected platform is main or not:
|
|
|
|
if ( $('.all_platforms').find('input[type="checkbox"][value=' + pl_id + '].build_bpl_ids').size() > 0 ) {
|
2012-06-19 15:52:29 +01:00
|
|
|
var pl_name = $('#build_list_save_to_platform_id option[value="' + pl_id + '"]').text().match(/([\w-.]+)\/[\w-.]+/)[1];
|
2012-04-16 17:06:34 +01:00
|
|
|
var branch_pl_opt = $('#build_list_project_version option[value="latest_' + pl_name + '"]');
|
|
|
|
// If there is branch we need - set it selected:
|
|
|
|
if ( branch_pl_opt.size() > 0 ) {
|
|
|
|
$('#build_list_project_version option[selected]').removeAttr('selected');
|
|
|
|
branch_pl_opt.attr('selected', 'selected');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-04-17 19:18:39 +01:00
|
|
|
|
2012-05-25 08:26:42 +01:00
|
|
|
function disableUpdateTypes() {
|
|
|
|
$("select#build_list_update_type option").each(function(i,el) {
|
|
|
|
if ( $.inArray($(el).attr("value"), ["security", "bugfix"]) == -1 ) {
|
|
|
|
$(el).attr("disabled", "disabled");
|
|
|
|
// If disabled option is selected - select 'bugfix':
|
|
|
|
if ( $(el).attr("selected") ) {
|
|
|
|
$( $('select#build_list_update_type option[value="bugfix"]') ).attr("selected", "selected");
|
|
|
|
}
|
2012-04-17 19:18:39 +01:00
|
|
|
}
|
2012-05-25 08:26:42 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function enableUpdateTypes() {
|
|
|
|
$("select#build_list_update_type option").removeAttr("disabled");
|
2012-04-17 19:18:39 +01:00
|
|
|
}
|