Test Husky pre-commit hook.

This commit is contained in:
RameshT 2024-08-06 14:50:56 +05:30
parent f31bf6e2d2
commit 70036952b4
1 changed files with 69 additions and 60 deletions

View File

@ -1,26 +1,27 @@
$(document).ready(function() { $(document).ready(function () {
let index = 1; let index = 1
let activeSection = null; let activeSection = null
function addOption(type, container) { function addOption(type, container) {
let optionHtml; let optionHtml
if (type === 'multiple-choice' || type === 'checkboxes') { if (type === 'multiple-choice' || type === 'checkboxes') {
optionHtml = ` optionHtml = `
<div class="option"> <div class="option">
<input type="${type === 'multiple-choice' ? 'radio' : 'checkbox'}" disabled> <input type="${type === 'multiple-choice' ? 'radio' : 'checkbox'}" disabled>
<input type="text" class="form-control option-label"> <input type="text" class="form-control option-label">
<span class="delete-option-icon">&times;</span> <span class="delete-option-icon">&times;</span>
</div> </div>
`; `
} else if (type === 'dropdown') { } else if (type === 'dropdown') {
optionHtml = ` optionHtml = `
<div class="option"> <div class="option">
<input type="text" class="form-control option-label"> <input type="text" class="form-control option-label">
<span class="delete-option-icon">&times;</span> <span class="delete-option-icon">&times;</span>
</div> </div>
`; `
} }
container.append(optionHtml); container.append(optionHtml)
} }
function createFormSection() { function createFormSection() {
@ -44,50 +45,58 @@ $(document).ready(function() {
</div> </div>
<div class="options-container"></div> <div class="options-container"></div>
</div> </div>
`; `
$('#form-container').append(newSection); $('#form-container').append(newSection)
index++; index++
positionAddSectionButton(); positionAddSectionButton()
} }
function positionAddSectionButton() { function positionAddSectionButton() {
if (activeSection) { if (activeSection) {
let position = activeSection.position(); let position = activeSection.position()
let buttonWidth = $('#add-section-btn').outerWidth(); let buttonWidth = $('#add-section-btn').outerWidth()
let buttonHeight = $('#add-section-btn').outerHeight(); let buttonHeight = $('#add-section-btn').outerHeight()
$('#add-section-btn').css({ $('#add-section-btn').css({
position: 'absolute', position: 'absolute',
left: position.left - buttonWidth - 47 + 'px', left: position.left - buttonWidth - 47 + 'px',
top: position.top + activeSection.height() / 2 - buttonHeight / 2 + 'px' top:
}); position.top + activeSection.height() / 2 - buttonHeight / 2 + 'px',
})
} }
} }
$('#add-section-btn').on('click', function() { $('#add-section-btn').on('click', function () {
createFormSection(); createFormSection()
$('.form-section').removeClass('active'); $('.form-section').removeClass('active')
activeSection = $('.form-section').last(); activeSection = $('.form-section').last()
activeSection.addClass('active'); activeSection.addClass('active')
positionAddSectionButton(); positionAddSectionButton()
}); })
$(document).on('change', '.custom-select', function() { $(document).on('change', '.custom-select', function () {
let type = $(this).val(); let type = $(this).val()
let container = $(this).closest('.form-section').find('.options-container'); let container = $(this).closest('.form-section').find('.options-container')
container.empty(); container.empty()
$(this).closest('.form-section').find('.add-option-btn').remove(); $(this).closest('.form-section').find('.add-option-btn').remove()
if (type === 'short-answer') { if (type === 'short-answer') {
container.append('<input type="text" class="form-control" disabled placeholder="Short answer text">'); container.append(
'<input type="text" class="form-control" disabled placeholder="Short answer text">'
)
} else if (type === 'paragraph') { } else if (type === 'paragraph') {
container.append('<textarea class="form-control" disabled placeholder="Paragraph text"></textarea>'); container.append(
'<textarea class="form-control" disabled placeholder="Paragraph text"></textarea>'
)
} else { } else {
addOption(type, container); addOption(type, container)
$(this).closest('.form-section').append('<button class="btn btn-secondary add-option-btn">Add Option</button>'); $(this)
.closest('.form-section')
.append(
'<button class="btn btn-secondary add-option-btn">Add Option</button>'
)
} }
}); })
})
});