diff --git a/assets/css/components/posts/form.css b/assets/css/components/posts/form.css index 699662a2..397703ff 100644 --- a/assets/css/components/posts/form.css +++ b/assets/css/components/posts/form.css @@ -47,7 +47,8 @@ .post-form .post-movie, .post-form .post-weblink, .post-form .post-pdf, -.post-form .post-countdown { +.post-form .post-countdown, +.post-form .post-survey { display: none; } @@ -55,6 +56,10 @@ margin-right: 5px; } +.post-form .post-survey .select2-dropdown { + /* Hide select2 suggestions*/ + display: none; +} /** * Visibility choice diff --git a/assets/js/components/posts/form.js b/assets/js/components/posts/form.js index 8e441c7b..b4d42480 100644 --- a/assets/js/components/posts/form.js +++ b/assets/js/components/posts/form.js @@ -183,7 +183,7 @@ ComunicWeb.components.posts.form = { var timeEndInput = createFormGroup({ target: countdownForm, - label: "Date de fin", + label: "End date", placeholder: "dd/mm/yyyy", type: "text" }); @@ -194,7 +194,43 @@ ComunicWeb.components.posts.form = { }); //End : countdown timer + //Add survey specific informations + var surveyForm = createElem2({ + appendTo: boxBody, + type: "div", + class: "post-survey" + }); + //Survey question + var surveyQuestionInput = createFormGroup({ + target: surveyForm, + label: "Question for the survey", + placeholder: "Question", + type: "text" + }); + + //Survey answers + var surveyAnswerInput = createFormGroup({ + target: surveyForm, + label: "Answers", + type: "select2", + multiple: true, + }); + + //Survey message help + var surveyAnswerHelper = createElem2({ + appendTo: surveyForm, + type: "p", + innerHTML: "Type your answer and then press return (enter) key to confirm it." + }) + + //Enable select2 + $(surveyAnswerInput).select2({ + tags: true, + tokenSeparators: ['\n'], + dropdownParent: $(surveyQuestionInput) + }); + //End: survey specific //Create post type change handler var changesHandler = function(){ @@ -205,6 +241,7 @@ ComunicWeb.components.posts.form = { linkChooseForm.style.display = linkType.checked ? "block" : "none"; pdfUploadForm.style.display = pdfType.checked ? "block" : "none"; countdownForm.style.display = countdownType.checked ? "block" : "none"; + surveyForm.style.display = surveyType.checked ? "block" : "none"; }; //Apply changesHandler function to all the data types