Línea 835... |
Línea 835... |
835 |
var validatorFormQuestion = $("#form-section").validate({
|
835 |
var validatorFormQuestion = $("#form-section").validate({
|
836 |
ignore: [],
|
836 |
ignore: [],
|
837 |
errorClass: 'help-block',
|
837 |
errorClass: 'help-block',
|
838 |
errorElement: 'span',
|
838 |
errorElement: 'span',
|
839 |
rules: {
|
839 |
rules: {
|
840 |
'question-text': {
|
840 |
'section-text': {
|
841 |
required: true,
|
841 |
required: true,
|
842 |
},
|
842 |
},
|
843 |
'question-value': {
|
843 |
'section-value': {
|
844 |
required: true,
|
844 |
required: true,
|
845 |
number: true,
|
845 |
number: true,
|
846 |
min: 1
|
846 |
min: 1
|
847 |
},
|
847 |
},
|
848 |
'question-type': {
|
848 |
'section-type': {
|
849 |
required: true,
|
849 |
required: true,
|
850 |
},
|
850 |
},
|
851 |
'question-max-length': {
|
851 |
'section-max-length': {
|
852 |
required: true,
|
852 |
required: true,
|
853 |
digits: true,
|
853 |
digits: true,
|
854 |
min: 0
|
854 |
min: 0
|
855 |
},
|
855 |
},
|
856 |
'question-range': {
|
856 |
'section-range': {
|
857 |
required: true,
|
857 |
required: true,
|
858 |
number: true,
|
858 |
number: true,
|
859 |
min: 1
|
859 |
min: 1
|
860 |
},
|
860 |
},
|
861 |
},
|
861 |
},
|
Línea 880... |
Línea 880... |
880 |
}, 1000);
|
880 |
}, 1000);
|
881 |
},
|
881 |
},
|
882 |
submitHandler: function(form) {
|
882 |
submitHandler: function(form) {
|
883 |
if ($('#form-section #section-id').val()) {
|
883 |
if ($('#form-section #section-id').val()) {
|
884 |
objFormGenerator.editQuestion(
|
884 |
objFormGenerator.editQuestion(
|
885 |
$('#form-section #question-section').val(),
|
885 |
$('#form-section #section-section').val(),
|
886 |
$('#form-section #section-id').val(),
|
886 |
$('#form-section #section-id').val(),
|
887 |
$('#form-section #question-text').val(),
|
887 |
$('#form-section #section-text').val(),
|
888 |
$('#form-section #question-value').val(),
|
888 |
$('#form-section #section-value').val(),
|
889 |
$('#form-section #question-type').val(),
|
889 |
$('#form-section #section-type').val(),
|
890 |
$('#form-section #question-max-length').val(),
|
890 |
$('#form-section #section-max-length').val(),
|
891 |
$('#form-section #question-multiline').val(),
|
891 |
$('#form-section #section-multiline').val(),
|
892 |
$('#form-section #question-range').val()
|
892 |
$('#form-section #section-range').val()
|
893 |
);
|
893 |
);
|
894 |
} else {
|
894 |
} else {
|
895 |
objFormGenerator.addQuestion(
|
895 |
objFormGenerator.addQuestion(
|
896 |
$('#form-section #question-section').val(),
|
896 |
$('#form-section #section-section').val(),
|
897 |
$('#form-section #question-text').val(),
|
897 |
$('#form-section #section-text').val(),
|
898 |
$('#form-section #question-value').val(),
|
898 |
$('#form-section #section-value').val(),
|
899 |
$('#form-section #question-type').val(),
|
899 |
$('#form-section #section-type').val(),
|
900 |
$('#form-section #question-max-length').val(),
|
900 |
$('#form-section #section-max-length').val(),
|
901 |
$('#form-section #question-multiline').val(),
|
901 |
$('#form-section #section-multiline').val(),
|
902 |
$('#form-section #question-range').val()
|
902 |
$('#form-section #section-range').val()
|
903 |
);
|
903 |
);
|
904 |
}
|
904 |
}
|
905 |
renderSectionData(objFormGenerator.sections);
|
905 |
renderSectionData(objFormGenerator.sections);
|
906 |
$('#modal-section').modal('hide');
|
906 |
$('#modal-section').modal('hide');
|
907 |
return false;
|
907 |
return false;
|
Línea 976... |
Línea 976... |
976 |
});
|
976 |
});
|
977 |
/**
|
977 |
/**
|
978 |
* Clicked add new question
|
978 |
* Clicked add new question
|
979 |
*/
|
979 |
*/
|
980 |
$('body').on('click', 'button.btn-add-section', function(e) {
|
980 |
$('body').on('click', 'button.btn-add-section', function(e) {
|
981 |
e.preventDefault();
|
- |
|
982 |
validatorFormQuestion.resetForm();
|
981 |
validatorFormQuestion.resetForm();
|
983 |
$('#form-section #section-id').val('');
|
982 |
$('#form-section #section-id').val('');
|
984 |
CKEDITOR.instances['question-text'].setData('');
|
983 |
CKEDITOR.instances['section-text'].setData('');
|
985 |
$('#form-section #question-type').val($('#form-section #question-type option:first').val());
|
984 |
$('#form-section #section-type').val($('#form-section #section-type option:first').val());
|
986 |
$('#form-section #question-max-length').val('0');
|
985 |
$('#form-section #section-max-length').val('0');
|
987 |
$('#form-section #question-max-length').parent().show();
|
986 |
$('#form-section #section-max-length').parent().show();
|
988 |
$('#form-section #question-multiline').val('0');
|
987 |
$('#form-section #section-multiline').val('0');
|
989 |
$('#form-section #question-multiline').parent().show();
|
988 |
$('#form-section #section-multiline').parent().show();
|
990 |
$('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
|
989 |
$('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
|
991 |
$('#modal-section').modal('show');
|
990 |
$('#modal-section').modal('show');
|
992 |
});
|
991 |
});
|
993 |
/**
|
992 |
/**
|
994 |
* Clicked edit question
|
993 |
* Clicked edit question
|
Línea 1001... |
Línea 1000... |
1001 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
1000 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
1002 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
1001 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
1003 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
1002 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
1004 |
if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
|
1003 |
if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
|
1005 |
validatorFormQuestion.resetForm();
|
1004 |
validatorFormQuestion.resetForm();
|
1006 |
$('#form-section #question-section').val(objFormGenerator.sections[i].slug_section);
|
1005 |
$('#form-section #section-section').val(objFormGenerator.sections[i].slug_section);
|
1007 |
$('#form-section #section-id').val(objFormGenerator.sections[i].questions[j].slug_question);
|
1006 |
$('#form-section #section-id').val(objFormGenerator.sections[i].questions[j].slug_question);
|
1008 |
CKEDITOR.instances['question-text'].setData(objFormGenerator.sections[i].questions[j].text);
|
1007 |
CKEDITOR.instances['section-text'].setData(objFormGenerator.sections[i].questions[j].text);
|
1009 |
$('#form-section #question-value').val(objFormGenerator.sections[i].questions[j].value);
|
1008 |
$('#form-section #section-value').val(objFormGenerator.sections[i].questions[j].value);
|
1010 |
$('#form-section #question-type').val(objFormGenerator.sections[i].questions[j].type);
|
1009 |
$('#form-section #section-type').val(objFormGenerator.sections[i].questions[j].type);
|
1011 |
if (objFormGenerator.sections[i].questions[j].type == 'open') {
|
1010 |
if (objFormGenerator.sections[i].questions[j].type == 'open') {
|
1012 |
$('#form-section #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
|
1011 |
$('#form-section #section-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
|
1013 |
$('#form-section #question-max-length').parent().show();
|
1012 |
$('#form-section #section-max-length').parent().show();
|
1014 |
$('#form-section #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
|
1013 |
$('#form-section #section-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
|
1015 |
$('#form-section #question-multiline').parent().show();
|
1014 |
$('#form-section #section-multiline').parent().show();
|
1016 |
} else {
|
1015 |
} else {
|
1017 |
$('#form-section #question-max-length').val('0');
|
1016 |
$('#form-section #section-max-length').val('0');
|
1018 |
$('#form-section #question-max-length').parent().hide();
|
1017 |
$('#form-section #section-max-length').parent().hide();
|
1019 |
$('#form-section #question-multiline').val('0');
|
1018 |
$('#form-section #section-multiline').val('0');
|
1020 |
$('#form-section #question-multiline').parent().hide();
|
1019 |
$('#form-section #section-multiline').parent().hide();
|
1021 |
}
|
1020 |
}
|
1022 |
if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
|
1021 |
if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
|
1023 |
$('#form-section #question-range').val(objFormGenerator.sections[i].questions[j].range);
|
1022 |
$('#form-section #section-range').val(objFormGenerator.sections[i].questions[j].range);
|
1024 |
$('#form-section #question-range').parent().show();
|
1023 |
$('#form-section #section-range').parent().show();
|
1025 |
} else {
|
1024 |
} else {
|
1026 |
$('#form-section #question-range').val('10');
|
1025 |
$('#form-section #section-range').val('10');
|
1027 |
$('#form-section #question-range').parent().hide();
|
1026 |
$('#form-section #section-range').parent().hide();
|
1028 |
}
|
1027 |
}
|
1029 |
showForm = true;
|
1028 |
showForm = true;
|
1030 |
break;
|
1029 |
break;
|
1031 |
}
|
1030 |
}
|
1032 |
}
|
1031 |
}
|
Línea 1358... |
Línea 1357... |
1358 |
<!-- Question Modal -->
|
1357 |
<!-- Question Modal -->
|
Línea 1359... |
Línea 1358... |
1359 |
|
1358 |
|
1360 |
<div id="modal-section" class="modal" tabindex="-1" role="dialog">
|
1359 |
<div id="modal-section" class="modal" tabindex="-1" role="dialog">
|
1361 |
<div class="modal-dialog modal-lg" role="document">
|
1360 |
<div class="modal-dialog modal-lg" role="document">
|
1362 |
<form action="#" name="form-section" id="form-section">
|
1361 |
<form action="#" name="form-section" id="form-section">
|
1363 |
<input type="hidden" name="question-section" id="question-section" />
|
1362 |
<input type="hidden" name="section-section" id="section-section" />
|
1364 |
<input type="hidden" name="section-id" id="section-id" />
|
1363 |
<input type="hidden" name="section-id" id="section-id" />
|
1365 |
<div class="modal-content">
|
1364 |
<div class="modal-content">
|
1366 |
<div class="modal-header">
|
1365 |
<div class="modal-header">
|
1367 |
<h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
|
1366 |
<h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
|
1368 |
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
1367 |
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
1369 |
<span aria-hidden="true">×</span>
|
1368 |
<span aria-hidden="true">×</span>
|
1370 |
</button>
|
1369 |
</button>
|
1371 |
</div>
|
1370 |
</div>
|
1372 |
<div class="modal-body">
|
1371 |
<div class="modal-body">
|
1373 |
<div class="form-group">
|
1372 |
<div class="form-group">
|
1374 |
<label for="question-text">LABEL_TEXT</label>
|
1373 |
<label for="section-text">LABEL_TEXT</label>
|
1375 |
<!-- ckeditor -->
|
1374 |
<!-- ckeditor -->
|
1376 |
<textarea name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
|
1375 |
<textarea name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
|
1377 |
</div>
|
1376 |
</div>
|
1378 |
<div class="form-group">
|
1377 |
<div class="form-group">
|
1379 |
<label for="question-value">LABEL_VALUE</label>
|
1378 |
<label for="section-value">LABEL_VALUE</label>
|
1380 |
<input type="text" name="question-value" id="question-value" class="form-control" />
|
1379 |
<input type="text" name="section-value" id="section-value" class="form-control" />
|
1381 |
</div>
|
1380 |
</div>
|
1382 |
<div class="form-group">
|
1381 |
<div class="form-group">
|
1383 |
<label for="question-type">LABEL_TYPE</label>
|
1382 |
<label for="section-type">LABEL_TYPE</label>
|
1384 |
<select name="question-type" id="question-type" class="form-control">
|
1383 |
<select name="section-type" id="section-type" class="form-control">
|
1385 |
<option value="open">LABEL_OPEN</option>
|
1384 |
<option value="open">LABEL_OPEN</option>
|
1386 |
<option value="simple">Simple</option>
|
1385 |
<option value="simple">Simple</option>
|
1387 |
<option value="multiple">Multiple</option>
|
1386 |
<option value="multiple">Multiple</option>
|
1388 |
</select>
|
1387 |
</select>
|
1389 |
</div>
|
1388 |
</div>
|
1390 |
<div class="form-group">
|
1389 |
<div class="form-group">
|
1391 |
<label for="question-max-length">LABEL_MAXLENGTH</label>
|
1390 |
<label for="section-max-length">LABEL_MAXLENGTH</label>
|
1392 |
<input type="text" name="question-max-length" id="question-max-length" class="form-control" />
|
1391 |
<input type="text" name="section-max-length" id="section-max-length" class="form-control" />
|
1393 |
</div>
|
1392 |
</div>
|
1394 |
<div class="form-group">
|
1393 |
<div class="form-group">
|
1395 |
<label for="question-multiline">LABEL_MULTI_LINE</label>
|
1394 |
<label for="section-multiline">LABEL_MULTI_LINE</label>
|
1396 |
<select name="question-multiline" id="question-multiline" class="form-control">
|
1395 |
<select name="section-multiline" id="section-multiline" class="form-control">
|
1397 |
<option value="1">LABEL_YES</option>
|
1396 |
<option value="1">LABEL_YES</option>
|
1398 |
<option value="0">LABEL_NOT</option>
|
1397 |
<option value="0">LABEL_NOT</option>
|
1399 |
</select>
|
1398 |
</select>
|
1400 |
</div>
|
1399 |
</div>
|