diff --git a/assets/js/updation.js b/assets/js/updation.js
index 3bd83e5..20d77af 100644
--- a/assets/js/updation.js
+++ b/assets/js/updation.js
@@ -1,34 +1,35 @@
-$(document).ready(function() {
- let index = 1;
- let activeSection = null;
+$(document).ready(function () {
+ let index = 1
+ let activeSection = null
- function addOption(type, container) {
- let optionHtml;
- if (type === 'multiple-choice' || type === 'checkboxes') {
- optionHtml = `
+ function addOption(type, container) {
+ let optionHtml
+ if (type === 'multiple-choice' || type === 'checkboxes') {
+ optionHtml = `
+
×
- `;
- } else if (type === 'dropdown') {
- optionHtml = `
+ `
+ } else if (type === 'dropdown') {
+ optionHtml = `
×
- `;
- }
- container.append(optionHtml);
+ `
}
+ container.append(optionHtml)
+ }
- function createFormSection() {
- let newSection = `
+ function createFormSection() {
+ let newSection = `
-
- `;
- $('#form-container').append(newSection);
- index++;
+ `
+ $('#form-container').append(newSection)
+ index++
- positionAddSectionButton();
+ positionAddSectionButton()
+ }
+
+ function positionAddSectionButton() {
+ if (activeSection) {
+ let position = activeSection.position()
+ let buttonWidth = $('#add-section-btn').outerWidth()
+ let buttonHeight = $('#add-section-btn').outerHeight()
+
+ $('#add-section-btn').css({
+ position: 'absolute',
+ left: position.left - buttonWidth - 47 + 'px',
+ top:
+ position.top + activeSection.height() / 2 - buttonHeight / 2 + 'px',
+ })
}
+ }
- function positionAddSectionButton() {
- if (activeSection) {
- let position = activeSection.position();
- let buttonWidth = $('#add-section-btn').outerWidth();
- let buttonHeight = $('#add-section-btn').outerHeight();
+ $('#add-section-btn').on('click', function () {
+ createFormSection()
+ $('.form-section').removeClass('active')
+ activeSection = $('.form-section').last()
+ activeSection.addClass('active')
+ positionAddSectionButton()
+ })
- $('#add-section-btn').css({
- position: 'absolute',
- left: position.left - buttonWidth - 47 + 'px',
- top: position.top + activeSection.height() / 2 - buttonHeight / 2 + 'px'
- });
- }
+ $(document).on('change', '.custom-select', function () {
+ let type = $(this).val()
+ let container = $(this).closest('.form-section').find('.options-container')
+ container.empty()
+
+ $(this).closest('.form-section').find('.add-option-btn').remove()
+
+ if (type === 'short-answer') {
+ container.append(
+ ''
+ )
+ } else if (type === 'paragraph') {
+ container.append(
+ ''
+ )
+ } else {
+ addOption(type, container)
+ $(this)
+ .closest('.form-section')
+ .append(
+ ''
+ )
}
-
- $('#add-section-btn').on('click', function() {
- createFormSection();
- $('.form-section').removeClass('active');
- activeSection = $('.form-section').last();
- activeSection.addClass('active');
- positionAddSectionButton();
- });
-
- $(document).on('change', '.custom-select', function() {
- let type = $(this).val();
- let container = $(this).closest('.form-section').find('.options-container');
- container.empty();
-
- $(this).closest('.form-section').find('.add-option-btn').remove();
-
- if (type === 'short-answer') {
- container.append('');
- } else if (type === 'paragraph') {
- container.append('');
- } else {
- addOption(type, container);
- $(this).closest('.form-section').append('');
- }
- });
-
-});
\ No newline at end of file
+ })
+})