Buy Licenses Contact Support Login/Register
v 1.7.19
v 1.7.19
Overview Survey Creator Examples Docs Source Download

Minimalistic configuration

Hide multiple page support, hide object selector, custom items editor, custom colors and other customizations


                        

// Change item editor icons
SurveyCreator.SurveyNestedPropertyEditorItem.dragIconName = "icon-custom-drag";
SurveyCreator.SurveyNestedPropertyEditorItem.deleteIconName = "icon-custom-delete";

Survey.settings.allowShowEmptyTitleInDesignMode = false;

// Color customization
var mainColor = "#0078d4";
var mainHoverColor = "#60C5FB";
var textColor = "#4a4a4a";
var headerColor = "#4a4a4a";
var headerBackgroundColor = "#4a4a4a";
var bodyContainerBackgroundColor = "#f8f8f8";

var defaultThemeColorsSurvey = Survey
    .StylesManager
    .ThemeColors["default"];
defaultThemeColorsSurvey["$main-color"] = mainColor;
defaultThemeColorsSurvey["$main-hover-color"] = mainHoverColor;
defaultThemeColorsSurvey["$text-color"] = textColor;
defaultThemeColorsSurvey["$header-color"] = headerColor;
defaultThemeColorsSurvey["$header-background-color"] = headerBackgroundColor;
defaultThemeColorsSurvey["$body-container-background-color"] = bodyContainerBackgroundColor;

var defaultThemeColorsEditor = SurveyCreator
    .StylesManager
    .ThemeColors["default"];
defaultThemeColorsEditor["$primary-color"] = mainColor;
defaultThemeColorsEditor["$secondary-color"] = mainColor;
defaultThemeColorsEditor["$primary-hover-color"] = mainHoverColor;
defaultThemeColorsEditor["$primary-text-color"] = textColor;
defaultThemeColorsEditor["$selection-border-color"] = mainColor;

Survey
    .StylesManager
    .applyTheme();
SurveyCreator
    .StylesManager
    .applyTheme();

// Hide some properties of the itemvalue object
// Design itemvalue[] property editor
// Hide visbileIf, enableIf and text properties
Survey.Serializer.findProperty("itemvalue", "visibleIf").visible = false;
Survey.Serializer.findProperty("itemvalue", "enableIf").visible = false;
Survey.Serializer.findProperty("itemvalue", "text").visible = false;
// Make the detail editor for itemvalue invisible, hide Edit button
SurveyCreator.SurveyQuestionEditorDefinition.definition["itemvalue[]@choices"].tabs = [
    { name: "general", visible: false }
  ];

// Show Designer, Test Survey, JSON Editor and additionally Logic tabs
// Show chosen question types in toolbox
// Set single page mode
// Show question title in the expression builder instead of question name
// Do not allow to edit expression as text, use expression builder only
var options = {
    showLogicTab: true, showJSONEditorTab: false,
    questionTypes: ["text", "checkbox", "radiogroup", "dropdown", "comment",
          "rating", "imagepicker", "boolean", "html", "file", "expression"],
    pageEditMode: "single",
    showTitlesInExpressions: true,
    allowEditExpressionsInTextEditor: false,
    showSurveyTitle: "always"
};
// Create the SurveyJS Creator and render it in div with id equals to "creatorElement"
var creator = new SurveyCreator.SurveyCreator("creatorElement", options);
// Show toolbox in the right container. It is shown on the left by default
creator.showToolbox = "right";
// Show property grid in the right container, combined with toolbox
creator.showPropertyGrid = "right";
// Make toolbox active by default
creator.rightContainerActiveItem("toolbox");

//Remove default properties layout in property grid and have only one "general" category.
SurveyCreator.SurveyQuestionEditorDefinition.definition = {};

//Define visibleIndex for properties we want to show and set attribute that marks we want to show this property
var maxVisibleIndex = 0;
function showTheProperty(className, propertyName, visibleIndex) {
    if(!visibleIndex) visibleIndex = ++maxVisibleIndex;
    else {
        if(visibleIndex > maxVisibleIndex) maxVisibleIndex = visibleIndex;
    }
    //Use Survey Serializer to find the property, it looks for property in the class and all it's parents
    var property = Survey.Serializer.findProperty(className, propertyName)
    if(!property) return;
    property.visibleIndex = visibleIndex;
    //Custom JavaScript attribute that we will use in onShowingProperty event
    property.showProperty = true;
}

showTheProperty("question", "name");
showTheProperty("question", "title");
showTheProperty("question", "description");
showTheProperty("question", "visible");
showTheProperty("question", "required");
showTheProperty("checkbox", "choices");
showTheProperty("checkbox", "hasOther");
showTheProperty("checkbox", "hasSelectAll");
showTheProperty("checkbox", "hasNone");
showTheProperty("text", "inputType");
showTheProperty("text", "placeHolder");
showTheProperty("comment", "placeHolder");
showTheProperty("comment", "rows");

var whitePropertyList = ["name", "title", "description", "visible", "isRequired", "choices", "hasOther",
    "hasSelectAll", "hasNone", "placeHolder", "rows", "inputType"];

//Use it to show properties that has our showProperty custom attribute equals to true
creator.onShowingProperty.add(function(sender, options){
  options.canShow = options.property.showProperty === true;
});

// Remove toolbar items except undo/redo buttons
creator.toolbarItems.splice(2, 5);
// Set custom designer placeholder
creator.placeholderHtml =
'<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center;">' +
    '<img src="/Content/Images/examples/drag-image.svg" />' +
    '<div style="font-size: 16px; max-width: 210px;">' +
        'Drag and drop a question to start designing your form' +
    '</div>' +
'</div>';

// Adorners for item inplace editing edit itemvalue.value and not itemvalue.text
creator.inplaceEditForValues = true;
// Hide Fast Entry option for ItemValue[] editor
creator.onSetPropertyEditorOptions.add(function(sender, options){
  options.editorOptions.showTextView = false;
});

// Add title for the sidebar panel
var rightContainerElement = document.getElementsByClassName("svd-designer-container--right-side")[0];
var titleDiv = document.createElement("div");
titleDiv.className = "svd-sidebar-title";
titleDiv.innerText = "Questions";
rightContainerElement.insertBefore(titleDiv, rightContainerElement.children[1]);



                    
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Hide multiple page support,  hide object selector, custom items editor, custom colors and other customizations, Survey Creator Example</title>

<meta name="viewport" content="width=device-width" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script>
<script src="https://surveyjs.azureedge.net/1.7.19/survey.ko.js"></script>
    <link href="https://surveyjs.azureedge.net/1.7.19/survey.css" type="text/css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.10/ace.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.10/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
    <!-- Uncomment to enable Select2
    <script src="https://unpkg.com/jquery"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
    -->
    <link href="https://surveyjs.azureedge.net/1.7.19/survey-creator.css" type="text/css" rel="stylesheet" />
    <script src="https://surveyjs.azureedge.net/1.7.19/survey-creator.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="./index.css">

</head>
<body>
    
<svg style="display:none;">
    <symbol viewBox="0 0 20 20" id="icon-custom-drag">
        <g>
            <rect x="5" y="0" width="4" height="4" />
            <rect x="11" y="0" width="4" height="4" />
            <rect x="5" y="6" width="4" height="4" />
            <rect x="11" y="6" width="4" height="4" />
            <rect x="5" y="12" width="4" height="4" />
            <rect x="11" y="12" width="4" height="4" />
        </g>
    </symbol>
    <symbol viewBox="0 0 20 20" id="icon-custom-delete">
        <polygon points="15,3 14,2 8.5,7.5 3,2 2,3 7.5,8.5 2,14 3,15 8.5,9.5 14,15 15,14 9.5,8.5 " />
    </symbol>
</svg>
    <div id="surveyContainer">
        <div id="creatorElement"></div>
    </div>

<script type="text/javascript" src="./index.js"></script>

</body>
</html>

/* Designer shadow style */
.svd_questions_editor {
    -webkit-box-shadow: 0px 0px 10px 4px rgba(235,235,235,1);
    -moz-box-shadow: 0px 0px 10px 4px rgba(235,235,235,1);
    box-shadow: 0px 0px 10px 4px rgba(235,235,235,1);
}
.svd_container.svd_container.svd_container .btn-primary {
    color: gray;
    background-color: transparent;
    border-color: transparent;
}
.svd_container.svd_container.svd_container .svd_toolbar .icon-white .svd-svg-icon {
    fill: gray;
}
.svd_container .svd_toolbar {
    text-align: right;
}

/*
.svd_container {
    font-family: "Georgia";
    font-size: 16px;
}
.sv_main {
    font-family: "Georgia";
    font-size: 16px;
}
*/

.svd_container.svd_container .nav-tabs > li.active > a[class=nav-link] {
    color: rgb(74, 74, 74);
    border-bottom: 4px solid #0065FF;
}
.svd_container.svd_container .nav-tabs a[class=nav-link] {
    color: rgb(167, 167, 167);
    padding: 0;
    padding-bottom: 8px;
}
.svd_container.svd_container .nav-tabs .nav-item {
    margin-bottom: 10px;
    padding: 10px;
}

.svd-sidebar-title {
    font-size: 20px;
    padding: 10px 30px;
    color: gray;
}

/* Remove/delete button style */
.svd_container .svd-textitems-column .btn.btn-danger {
    background-color: transparent;
    color: rgb(0, 101, 255);
    font-size: 1.5em;
    padding: 5px;
}
.svd-itemvalue-actions-container {
    color: rgb(0, 101, 255);
}

/* Hide object selector */
.svd_container .svd_object_selector {
    display: none;
}

.svd_object_editor {
    margin-top: 10px;
}