CLOUDSTACK-4931: Instance wizard: use fn to hide/show template root size

This commit is contained in:
Brian Federle 2013-10-23 09:58:38 -07:00
parent 69b131fa15
commit 1f0dd7cc36
2 changed files with 15 additions and 65 deletions

View File

@ -238,7 +238,9 @@
templates: templatesObj,
hypervisors: hypervisorObjs
},
customFlag: 'isdynamicallyscalable', // Field determines if custom slider is shown
customHidden: function(args) {
return true;
}
});
},

View File

@ -383,72 +383,20 @@
originalValues(formData);
$step.find('input[type=radio]').bind('change', function() {
var $target = $(this);
var val = $target.val();
var item;
$.map(args.data.templates, function(v, k) {
if (!v) {
return true;
}
var target = $.grep(v, function(elem) {
return elem.id == val;
});
if (target.length) {
item = target[0];
return false;
}
return true;
});
if (!item) return true;
var custom = item[args.customFlag];
$step.find('.custom-size-label').remove();
if (custom) {
$target.parent().find('.name')
.append(
$('<span>').addClass('custom-size-label')
.append(': ')
.append(
$('<span>').addClass('custom-disk-size').html(
$step.find('.custom-size input[name=size]').val()
)
)
.append(' GB')
);
$target.parent().find('.select-desc .desc')
.append(
$('<span>').addClass('custom-size-label')
.append(', ')
.append(
$('<span>').addClass('custom-disk-size').html(
$step.find('.custom-size input[name=size]').val()
)
)
.append(' GB')
);
$step.find('.section.custom-size').show();
$step.addClass('custom-disk-size');
$target.closest('.select-container').scrollTop(
$target.position().top
);
} else {
$step.find('.section.custom-size').hide();
$step.removeClass('custom-disk-size');
}
return true;
var custom = args.customHidden({
context: context,
data: args.data
});
$step.find('input[type=radio]:first').trigger('change');
$step.find('.custom-size-label').remove();
if (!custom) {
$step.find('.section.custom-size').show();
$step.addClass('custom-disk-size');
} else {
$step.find('.section.custom-size').hide();
$step.removeClass('custom-disk-size');
}
}
}
};