Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 256 | Rev 258 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 256 Rev 257
Línea 813... Línea 813...
813
                });
813
                });
814
                return false;
814
                return false;
815
            }
815
            }
816
        }
816
        }
817
    });
817
    });
818
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
-
 
819
    $("#form-section").on('submit', function() {
-
 
820
        for (var instanceName in CKEDITOR.instances) {
-
 
821
            CKEDITOR.instances[instanceName].updateElement();
-
 
822
        }
-
 
823
    })
-
 
824
    /**
-
 
825
     * Validate rules form section
-
 
826
     */
-
 
827
    var validatorFormSection = $("#form-section").validate({
-
 
828
        ignore: [],
-
 
829
        errorClass: 'help-block',
-
 
830
        errorElement: 'span',
-
 
831
        rules: {
-
 
832
            'section-name': {
-
 
833
                required: true,
-
 
834
                minlength: 2,
-
 
835
                maxlength: 50
-
 
836
            },
-
 
837
            'section-text': {
-
 
838
                required: false,
-
 
839
            },
-
 
840
            'section-value': {
-
 
841
                required: true,
-
 
842
                number: true,
-
 
843
                min: 1
-
 
844
            },
-
 
845
        },
-
 
846
        highlight: function(element) {
-
 
847
            $(element).closest('.form-group').addClass('has-error');
-
 
848
        },
-
 
849
        unhighlight: function(element) {
-
 
850
            $(element).closest('.form-group').removeClass('has-error');
-
 
851
        },
-
 
852
        errorPlacement: function(error, element) {
-
 
853
            if (element.attr("data-error-container")) {
-
 
854
                error.appendTo(element.attr("data-error-container"));
-
 
855
            } else {
-
 
856
                error.insertAfter(element);
-
 
857
            }
-
 
858
        },
-
 
859
        invalidHandler: function(form, validator) {
-
 
860
            if (!validator.numberOfInvalids())
-
 
861
                return;
-
 
862
            $('html, body').animate({
-
 
863
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
864
            }, 1000);
-
 
865
        },
-
 
866
        submitHandler: function(form) {
-
 
867
            // do other things for a valid form
-
 
868
            //form.submit();
-
 
869
            var slug = $('#form-section #section-slug').val();
-
 
870
            if (slug) {
-
 
871
                objFormGenerator.editSection(
-
 
872
                    $('#form-section #section-slug').val(),
-
 
873
                    $('#form-section #section-name').val(),
-
 
874
                    $('#form-section #section-text').val(),
-
 
875
                    $('#form-section #section-value').val()
-
 
876
                );
-
 
877
            } else {
-
 
878
                objFormGenerator.addSection(
-
 
879
                    $('#form-section #section-name').val(),
-
 
880
                    $('#form-section #section-text').val(),
-
 
881
                    $('#form-section #section-value').val()
-
 
882
                );
-
 
883
            }
-
 
884
            renderSectionData(objFormGenerator.sections);
-
 
885
            $('#modal-section').modal('hide');
-
 
886
            return false;
-
 
887
        }
-
 
888
    });
-
 
889
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
-
 
890
    $("#form-question").on('submit', function() {
-
 
891
        for (var instanceName in CKEDITOR.instances) {
-
 
892
            CKEDITOR.instances[instanceName].updateElement();
-
 
893
        }
-
 
894
    })
-
 
895
    /**
-
 
896
     * Validate rules form Questions
-
 
897
     */
-
 
898
    var validatorFormQuestion = $("#form-question").validate({
-
 
899
        ignore: [],
-
 
900
        errorClass: 'help-block',
-
 
901
        errorElement: 'span',
-
 
902
        rules: {
-
 
903
            'question-text': {
-
 
904
                required: true,
-
 
905
            },
-
 
906
            'question-value': {
-
 
907
                required: true,
-
 
908
                number: true,
-
 
909
                min: 1
-
 
910
            },
-
 
911
            'question-type': {
-
 
912
                required: true,
-
 
913
            },
-
 
914
            'question-max-length': {
-
 
915
                required: true,
-
 
916
                digits: true,
-
 
917
                min: 0
-
 
918
            },
-
 
919
            'question-range': {
-
 
920
                required: true,
-
 
921
                number: true,
-
 
922
                min: 1
-
 
923
            },
-
 
924
        },
-
 
925
        highlight: function(element) {
-
 
926
            $(element).closest('.form-group').addClass('has-error');
-
 
927
        },
-
 
928
        unhighlight: function(element) {
-
 
929
            $(element).closest('.form-group').removeClass('has-error');
-
 
930
        },
-
 
931
        errorPlacement: function(error, element) {
-
 
932
            if (element.attr("data-error-container")) {
-
 
933
                error.appendTo(element.attr("data-error-container"));
-
 
934
            } else {
-
 
935
                error.insertAfter(element);
-
 
936
            }
-
 
937
        },
-
 
938
        invalidHandler: function(form, validator) {
-
 
939
            if (!validator.numberOfInvalids())
-
 
940
                return;
-
 
941
            $('html, body').animate({
-
 
942
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
943
            }, 1000);
-
 
944
        },
-
 
945
        submitHandler: function(form) {
-
 
946
            if ($('#form-question #question-slug').val()) {
-
 
947
                objFormGenerator.editQuestion(
-
 
948
                    $('#form-question #question-section').val(),
-
 
949
                    $('#form-question #question-slug').val(),
-
 
950
                    $('#form-question #question-text').val(),
-
 
951
                    $('#form-question #question-value').val(),
-
 
952
                    $('#form-question #question-type').val(),
-
 
953
                    $('#form-question #question-max-length').val(),
-
 
954
                    $('#form-question #question-multiline').val(),
-
 
955
                    $('#form-question #question-range').val()
-
 
956
                );
-
 
957
            } else {
-
 
958
                objFormGenerator.addQuestion(
-
 
959
                    $('#form-question #question-section').val(),
-
 
960
                    $('#form-question #question-text').val(),
-
 
961
                    $('#form-question #question-value').val(),
-
 
962
                    $('#form-question #question-type').val(),
-
 
963
                    $('#form-question #question-max-length').val(),
-
 
964
                    $('#form-question #question-multiline').val(),
-
 
965
                    $('#form-question #question-range').val()
-
 
966
                );
-
 
967
            }
-
 
968
            renderSectionData(objFormGenerator.sections);
-
 
969
            $('#modal-question').modal('hide');
-
 
970
            return false;
-
 
971
        }
-
 
972
    });
-
 
973
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
-
 
974
    $("#form-option").on('submit', function() {
-
 
975
        for (var instanceName in CKEDITOR.instances) {
-
 
976
            CKEDITOR.instances[instanceName].updateElement();
-
 
977
        }
-
 
978
    })
818
    
979
    /**
-
 
980
     * Validate rules form options
-
 
981
     */
-
 
982
    var validatorFormOption = $("#form-option").validate({
-
 
983
        ignore: [],
-
 
984
        errorClass: 'help-block',
-
 
985
        errorElement: 'span',
-
 
986
        rules: {
-
 
987
            'option-text': {
-
 
988
                required: true,
-
 
989
            },
-
 
990
            'option-value': {
-
 
991
                required: true,
-
 
992
                number: true,
-
 
993
                min: 1
-
 
994
            }
-
 
995
        },
-
 
996
        highlight: function(element) {
-
 
997
            $(element).closest('.form-group').addClass('has-error');
-
 
998
        },
-
 
999
        unhighlight: function(element) {
-
 
1000
            $(element).closest('.form-group').removeClass('has-error');
-
 
1001
        },
-
 
1002
        errorPlacement: function(error, element) {
-
 
1003
            if (element.attr("data-error-container")) {
-
 
1004
                error.appendTo(element.attr("data-error-container"));
-
 
1005
            } else {
-
 
1006
                error.insertAfter(element);
-
 
1007
            }
-
 
1008
        },
-
 
1009
        invalidHandler: function(form, validator) {
-
 
1010
            if (!validator.numberOfInvalids())
-
 
1011
                return;
-
 
1012
            $('html, body').animate({
-
 
1013
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
1014
            }, 1000);
-
 
1015
        },
-
 
1016
        submitHandler: function(form) {
-
 
1017
            if ($('#form-option #option-slug').val()) {
-
 
1018
                objFormGenerator.editOption(
-
 
1019
                    $('#form-option #option-section').val(),
-
 
1020
                    $('#form-option #option-question').val(),
-
 
1021
                    $('#form-option #option-slug').val(),
-
 
1022
                    $('#form-option #option-text').val(),
-
 
1023
                    $('#form-option #option-correct').val(),
-
 
1024
                    $('#form-option #option-value').val()
-
 
1025
                );
-
 
1026
            } else {
-
 
1027
                objFormGenerator.addOption(
-
 
1028
                    $('#form-option #option-section').val(),
-
 
1029
                    $('#form-option #option-question').val(),
-
 
1030
                    $('#form-option #option-text').val(),
-
 
1031
                    $('#form-option #option-correct').val(),
-
 
1032
                    $('#form-option #option-value').val()
-
 
1033
                );
-
 
1034
            }
-
 
1035
            renderSectionData(objFormGenerator.sections);
-
 
1036
            $('#modal-option').modal('hide');
-
 
1037
            return false;
-
 
1038
        }
-
 
1039
    });
-
 
1040
    /**
-
 
1041
     * Clicked on add new section
-
 
1042
     */
-
 
1043
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
-
 
1044
        e.preventDefault();
-
 
1045
        validatorFormSection.resetForm();
-
 
1046
        $('#form-section #section-slug').val('');
-
 
1047
        $('#form-section #section-name').val('');
-
 
1048
        CKEDITOR.instances['section-text'].setData('');
-
 
1049
        $('#form-section #section-value').val('0');
-
 
1050
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
-
 
1051
        $('#modal-section').modal('show');
-
 
1052
    });
-
 
1053
    /**
-
 
1054
     * Clicked on edit section
-
 
1055
     */
-
 
1056
    $('body').on('click', 'button.btn-edit-section', function(e) {
-
 
1057
        e.preventDefault();
-
 
1058
        var slug = $(this).data('section');
-
 
1059
        var section;
-
 
1060
        var showForm = false;
-
 
1061
        for (i = 0; i < objFormGenerator.sections.length; i++) {
-
 
1062
            section = objFormGenerator.sections[i];
-
 
1063
            if (slug == section.slug_section) {
-
 
1064
                validatorFormSection.resetForm();
-
 
1065
                $('#form-section #section-slug').val(section.slug_section);
-
 
1066
                $('#form-section #section-name').val(section.name);
-
 
1067
                CKEDITOR.instances['section-text'].setData(section.text);
-
 
1068
                $('#form-section #section-value').val(section.value);
-
 
1069
                showForm = true;
-
 
1070
                break;
-
 
1071
            }
-
 
1072
        }
-
 
1073
        if (showForm) {
-
 
1074
            $('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
-
 
1075
            $('#modal-section').modal('show');
-
 
1076
        }
-
 
1077
    });
-
 
1078
    /**
-
 
1079
     * Clicked on remove section
-
 
1080
     */
-
 
1081
    $('body').on('click', 'button.btn-delete-section', function(e) {
-
 
1082
        e.preventDefault();
-
 
1083
        var slug = $(this).data('section');
-
 
1084
        bootbox.confirm({
-
 
1085
            title: "LABEL_DELETE LABEL_SECTION",
-
 
1086
            message: "LABEL_QUESTION_DELETE",
-
 
1087
            buttons: {
-
 
1088
                cancel: {
-
 
1089
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
1090
                },
-
 
1091
                confirm: {
-
 
1092
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
1093
                }
-
 
1094
            },
-
 
1095
            callback: function(result) {
-
 
1096
                if (result) {
-
 
1097
                    objFormGenerator.deleteSection(slug);
-
 
1098
                    renderSectionData(objFormGenerator.sections);
-
 
1099
                }
-
 
1100
            }
-
 
1101
        });
-
 
1102
    });
-
 
1103
    /**
-
 
1104
     * Clicked add new question
-
 
1105
     */
-
 
1106
    $('body').on('click', 'button.btn-add-question', function(e) {
-
 
1107
        e.preventDefault();
-
 
1108
        validatorFormQuestion.resetForm();
-
 
1109
        var slug = $(this).data('section');
-
 
1110
        $('#form-question #question-section').val(slug);
-
 
1111
        $('#form-question #question-slug').val('');
-
 
1112
        CKEDITOR.instances['question-text'].setData('');
-
 
1113
        $('#form-question #question-value').val('0');
-
 
1114
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
-
 
1115
        $('#form-question #question-max-length').val('0');
-
 
1116
        $('#form-question #question-max-length').parent().show();
-
 
1117
        $('#form-question #question-multiline').val('0');
-
 
1118
        $('#form-question #question-multiline').parent().show();
-
 
1119
        $('#form-question #question-range').val('10');
-
 
1120
        $('#form-question #question-range').parent().hide();
-
 
1121
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
-
 
1122
        $('#modal-question').modal('show');
-
 
1123
    });
-
 
1124
    /**
-
 
1125
     * Clicked edit question
-
 
1126
     */
-
 
1127
    $('body').on('click', 'button.btn-edit-question', function(e) {
-
 
1128
        e.preventDefault();
-
 
1129
        var slug_section = $(this).data('section');
-
 
1130
        var slug = $(this).data('question');
-
 
1131
        var showForm = false;
-
 
1132
        for (i = 0; i < objFormGenerator.sections.length; i++) {
-
 
1133
            if (slug_section == objFormGenerator.sections[i].slug_section) {
-
 
1134
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
-
 
1135
                    if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
-
 
1136
                        validatorFormQuestion.resetForm();
-
 
1137
                        $('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
-
 
1138
                        $('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
-
 
1139
                        CKEDITOR.instances['question-text'].setData(objFormGenerator.sections[i].questions[j].text);
-
 
1140
                        $('#form-question #question-value').val(objFormGenerator.sections[i].questions[j].value);
-
 
1141
                        $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
-
 
1142
                        if (objFormGenerator.sections[i].questions[j].type == 'open') {
-
 
1143
                            $('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
-
 
1144
                            $('#form-question #question-max-length').parent().show();
-
 
1145
                            $('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
-
 
1146
                            $('#form-question #question-multiline').parent().show();
-
 
1147
                        } else {
-
 
1148
                            $('#form-question #question-max-length').val('0');
-
 
1149
                            $('#form-question #question-max-length').parent().hide();
-
 
1150
                            $('#form-question #question-multiline').val('0');
-
 
1151
                            $('#form-question #question-multiline').parent().hide();
-
 
1152
                        }
-
 
1153
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
-
 
1154
                            $('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
-
 
1155
                            $('#form-question #question-range').parent().show();
-
 
1156
                        } else {
-
 
1157
                            $('#form-question #question-range').val('10');
-
 
1158
                            $('#form-question #question-range').parent().hide();
-
 
1159
                        }
-
 
1160
                        showForm = true;
-
 
1161
                        break;
-
 
1162
                    }
-
 
1163
                }
-
 
1164
                break;
-
 
1165
            }
-
 
1166
        }
-
 
1167
        if (showForm) {
-
 
1168
            $('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
-
 
1169
            $('#modal-question').modal('show');
-
 
1170
        }
-
 
1171
    });
-
 
1172
    /**
-
 
1173
     * Clicked remove question
-
 
1174
     */
-
 
1175
    $('body').on('click', 'button.btn-delete-question', function(e) {
-
 
1176
        e.preventDefault();
-
 
1177
        var slug_section = $(this).data('section');
-
 
1178
        var slug = $(this).data('question');
-
 
1179
        bootbox.confirm({
-
 
1180
            title: "LABEL_DELETE LABEL_QUESTION",
-
 
1181
            message: "LABEL_QUESTION_DELETE",
-
 
1182
            buttons: {
-
 
1183
                cancel: {
-
 
1184
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
1185
                },
-
 
1186
                confirm: {
-
 
1187
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
1188
                }
-
 
1189
            },
-
 
1190
            callback: function(result) {
-
 
1191
                if (result) {
-
 
1192
                    objFormGenerator.deleteQuestion(slug_section, slug);
-
 
1193
                    renderSectionData(objFormGenerator.sections);
-
 
1194
                }
-
 
1195
            }
-
 
1196
        });
-
 
1197
    });
-
 
1198
    /**
-
 
1199
     * Clicked add new Option
-
 
1200
     */
-
 
1201
    $('body').on('click', 'button.btn-add-option', function(e) {
-
 
1202
        e.preventDefault();
-
 
1203
        var slug_section = $(this).data('section');
-
 
1204
        var slug_question = $(this).data('question');
-
 
1205
        var showForm = false;
-
 
1206
        for (i = 0; i < objFormGenerator.sections.length; i++) {
-
 
1207
            if (slug_section == objFormGenerator.sections[i].slug_section) {
-
 
1208
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
-
 
1209
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
-
 
1210
                        validatorFormOption.resetForm();
-
 
1211
                        $('#form-option #option-section').val(slug_section);
-
 
1212
                        $('#form-option #option-question').val(slug_question);
-
 
1213
                        $('#form-option #option-slug').val('');
-
 
1214
                        CKEDITOR.instances['option-text'].setData('', function() {
-
 
1215
                            editor.focus();
-
 
1216
                        });
-
 
1217
                        $('#form-option #option-correct').val('0');
-
 
1218
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
-
 
1219
                            $('#form-option #option-correct').parent().hide();
-
 
1220
                        } else {
-
 
1221
                            $('#form-option #option-correct').parent().show();
-
 
1222
                        }
-
 
1223
                        if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
-
 
1224
                            $('#form-option #option-value').val('0');
-
 
1225
                            $('#form-option #option-value').parent().show();
-
 
1226
                        } else {
-
 
1227
                            $('#form-option #option-value').val('1');
-
 
1228
                            $('#form-option #option-value').parent().hide();
-
 
1229
                        }
-
 
1230
                        renderSectionData(objFormGenerator.sections);
-
 
1231
                        $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
-
 
1232
                        $('#modal-option').modal('show');
-
 
1233
                        return true;
-
 
1234
                    }
-
 
1235
                }
-
 
1236
            }
-
 
1237
        }
-
 
1238
    });
-
 
1239
    /**
-
 
1240
     * Clicked edit option
-
 
1241
     */
-
 
1242
    $('body').on('click', 'button.btn-edit-option', function(e) {
-
 
1243
        e.preventDefault();
-
 
1244
        var slug_section = $(this).data('section');
-
 
1245
        var slug_question = $(this).data('question');
-
 
1246
        var slug = $(this).data('slug');
-
 
1247
        var showForm = false;
-
 
1248
        for (i = 0; i < objFormGenerator.sections.length; i++) {
-
 
1249
            if (slug_section == objFormGenerator.sections[i].slug_section) {
-
 
1250
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
-
 
1251
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
-
 
1252
                        for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
-
 
1253
                            if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
-
 
1254
                                validatorFormOption.resetForm();
-
 
1255
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
-
 
1256
                                $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
-
 
1257
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
-
 
1258
                                CKEDITOR.instances['option-text'].setData(objFormGenerator.sections[i].questions[j].options[k].text,
-
 
1259
                                    function() {
-
 
1260
                                        editor.focus();
-
 
1261
                                    });
-
 
1262
                                $('#form-option #option-correct').val(objFormGenerator.sections[i].questions[j].options[k].correct);
-
 
1263
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
-
 
1264
                                    $('#form-option #option-correct').parent().show();
-
 
1265
                                } else {
-
 
1266
                                    $('#form-option #option-correct').parent().hide();
-
 
1267
                                }
-
 
1268
                                $('#form-option #option-value').val(objFormGenerator.sections[i].questions[j].options[k].value);
-
 
1269
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
-
 
1270
                                    $('#form-option #option-value').parent().show();
-
 
1271
                                } else {
-
 
1272
                                    $('#form-option #option-value').parent().hide();
-
 
1273
                                }
-
 
1274
                                showForm = true;
-
 
1275
                                break;
-
 
1276
                            }
-
 
1277
                        }
-
 
1278
                    }
-
 
1279
                    if (showForm) {
-
 
1280
                        break;
-
 
1281
                    }
-
 
1282
                }
-
 
1283
            }
-
 
1284
            if (showForm) {
-
 
1285
                break;
-
 
1286
            }
-
 
1287
        }
-
 
1288
        if (showForm) {
-
 
1289
            $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
-
 
1290
            $('#modal-option').modal('show');
-
 
1291
        }
-
 
1292
    });
-
 
1293
    /**
-
 
1294
     * Clicked remove option
-
 
1295
     */
-
 
1296
    $('body').on('click', 'button.btn-delete-option', function(e) {
-
 
1297
        e.preventDefault();
-
 
1298
        var slug_section = $(this).data('section');
-
 
1299
        var slug_question = $(this).data('question');
-
 
1300
        var slug = $(this).data('slug');
-
 
1301
        bootbox.confirm({
-
 
1302
            title: "LABEL_DELETE LABEL_OPTION",
-
 
1303
            message: "LABEL_QUESTION_DELETE",
-
 
1304
            buttons: {
-
 
1305
                cancel: {
-
 
1306
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
1307
                },
-
 
1308
                confirm: {
-
 
1309
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
1310
                }
-
 
1311
            },
-
 
1312
            callback: function(result) {
-
 
1313
                if (result) {
-
 
1314
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
-
 
1315
                    renderSectionData(objFormGenerator.sections);
-
 
1316
                }
-
 
1317
            }
-
 
1318
        });
-
 
1319
    })
819
   
1320
    /**
-
 
1321
     * Format input number (Form Section) 
-
 
1322
     */
-
 
1323
    $('#form-section #section-value').inputNumberFormat({
-
 
1324
        'decimal': 2
-
 
1325
    });
-
 
1326
    /**
-
 
1327
     * Format input number (Form Question) 
-
 
1328
     */
-
 
1329
    $('#form-question #question-value').inputNumberFormat({
-
 
1330
        'decimal': 2
-
 
1331
    });
-
 
1332
    /**
-
 
1333
     * Format input number (Form Question) 
-
 
1334
     */
-
 
1335
    $('#form-question #question-max-length').inputNumberFormat({
-
 
1336
        'decimal': 0
-
 
1337
    });
-
 
1338
    /**
-
 
1339
     * Format input number (Form Option) 
-
 
1340
     */
-
 
1341
    $('#form-option #option-value').inputNumberFormat({
-
 
1342
        'decimal': 2
-
 
1343
    });
-
 
1344
    /**
-
 
1345
     * Detect when updating question status and hide/Show options
-
 
1346
     */
-
 
1347
    $('#form-question #question-type').change(function(e) {
-
 
1348
        e.preventDefault();
-
 
1349
        if ($('#form-question #question-type').val() == 'open') {
-
 
1350
            $('#form-question #question-max-length').parent().show();
-
 
1351
            $('#form-question #question-multiline').parent().show();
-
 
1352
        } else {
-
 
1353
            $('#form-question #question-max-length').val('0');
-
 
1354
            $('#form-question #question-max-length').parent().hide();
-
 
1355
            $('#form-question #question-multiline').val('0');
-
 
1356
            $('#form-question #question-multiline').parent().hide();
-
 
1357
        }
-
 
1358
        $('#form-question #question-range').val('10');
-
 
1359
        if ($('#form-question #question-type').val() == 'rating-range') {
-
 
1360
            $('#form-question #question-range').parent().show();
-
 
1361
        } else {
-
 
1362
            $('#form-question #question-range').parent().hide();
-
 
1363
        }
-
 
1364
    });
-
 
1365
    /**
820
    /**
1366
     * Clicked cancel new/edit Form
821
     * Clicked cancel new/edit Form
1367
     */
822
     */
1368
    $('button.btn-edit-cancel').click(function(e) {
823
    $('button.btn-edit-cancel').click(function(e) {
1369
        e.preventDefault();
824
        e.preventDefault();