| 4384 | eleazar | 1 | <?php
 | 
        
           |  |  | 2 | $acl = $this->viewModel()->getRoot()->getVariable('acl');
 | 
        
           |  |  | 3 | $currentUser = $this->currentUserHelper();
 | 
        
           |  |  | 4 |   | 
        
           |  |  | 5 | $roleName = $currentUser->getUserTypeId();
 | 
        
           |  |  | 6 |   | 
        
           |  |  | 7 | $routeAdd = $this->url('survey/form/add');
 | 
        
           |  |  | 8 | $routeDatatable = $this->url('survey/form');
 | 
        
           |  |  | 9 | $routeDashboard = $this->url('dashboard');
 | 
        
           |  |  | 10 |   | 
        
           |  |  | 11 | $allowAdd = $acl->isAllowed($roleName, 'survey/form/add') ? 1 : 0;
 | 
        
           |  |  | 12 | $allowEdit = $acl->isAllowed($roleName, 'survey/form/edit') ? 1 : 0;
 | 
        
           |  |  | 13 | $allowDelete = $acl->isAllowed($roleName, 'survey/form/delete') ? 1 : 0;
 | 
        
           |  |  | 14 |   | 
        
           |  |  | 15 |   | 
        
           |  |  | 16 | $this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
 | 
        
           |  |  | 17 |   | 
        
           |  |  | 18 |   | 
        
           |  |  | 19 | $this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
 | 
        
           |  |  | 20 | $this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
 | 
        
           |  |  | 21 |   | 
        
           |  |  | 22 |   | 
        
           |  |  | 23 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
 | 
        
           |  |  | 24 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
 | 
        
           |  |  | 25 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 | $this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
 | 
        
           |  |  | 28 | $this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 | $this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
 | 
        
           |  |  | 31 | $this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
 | 
        
           |  |  | 32 | $this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
 | 
        
           |  |  | 33 | $this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 |   | 
        
           |  |  | 36 | $this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));
 | 
        
           |  |  | 37 | $this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
 | 
        
           |  |  | 38 |   | 
        
           |  |  | 39 | $this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.full.min.js'));
 | 
        
           |  |  | 40 |   | 
        
           |  |  | 41 | $this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
 | 
        
           |  |  | 42 | $this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
 | 
        
           |  |  | 43 | $this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
 | 
        
           |  |  | 44 |   | 
        
           |  |  | 45 |   | 
        
           |  |  | 46 | $this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
 | 
        
           |  |  | 47 | $this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 | $this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
 | 
        
           |  |  | 50 | $this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
 | 
        
           |  |  | 51 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
 | 
        
           |  |  | 52 |   | 
        
           |  |  | 53 | // bootbox Alert //
 | 
        
           |  |  | 54 | $this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
 | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 | // JsRender //
 | 
        
           |  |  | 57 | $this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 | // Page Styles
 | 
        
           |  |  | 60 | $this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));
 | 
        
           |  |  | 61 |   | 
        
           | 4399 | eleazar | 62 | $status_active = \LeadersLinked\Model\SurveyForm::STATUS_ACTIVE;
 | 
        
           |  |  | 63 | $status_inactive = \LeadersLinked\Model\SurveyForm::STATUS_INACTIVE;
 | 
        
           | 4384 | eleazar | 64 |   | 
        
           |  |  | 65 | $this->inlineScript()->captureStart();
 | 
        
           |  |  | 66 | echo <<<JS
 | 
        
           |  |  | 67 |     const classFormGenerator = function() {
 | 
        
           |  |  | 68 |     this.id = 0,
 | 
        
           |  |  | 69 |         this.table = '',
 | 
        
           |  |  | 70 |         this.name = '',
 | 
        
           |  |  | 71 |         this.text = '',
 | 
        
           |  |  | 72 |         this.status = 'a',
 | 
        
           |  |  | 73 |         this.sections = [],
 | 
        
           |  |  | 74 |         this.clear = function() {
 | 
        
           |  |  | 75 |             this.sections = [];
 | 
        
           |  |  | 76 |             this.render();
 | 
        
           |  |  | 77 |         },
 | 
        
           |  |  | 78 |         /**
 | 
        
           |  |  | 79 |          * Render array sections
 | 
        
           |  |  | 80 |          */
 | 
        
           |  |  | 81 |         this.renderSection = function(slug_section) {
 | 
        
           |  |  | 82 |             var s = '';
 | 
        
           |  |  | 83 |             for (i = 0; i < this.sections.length; i++) {
 | 
        
           |  |  | 84 |                 if (slug_section != this.sections[i].slug_section) {
 | 
        
           |  |  | 85 |                     continue;
 | 
        
           |  |  | 86 |                 }
 | 
        
           |  |  | 87 |                 for (j = 0; j < this.sections[i].questions.length; j++) {
 | 
        
           |  |  | 88 |                     this.sections[i].questions[j].position = j;
 | 
        
           | 6467 | eleazar | 89 |                     if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
 | 
        
           | 4384 | eleazar | 90 |                         this.sections[i].questions[j].options.sort(function(a, b) {
 | 
        
           |  |  | 91 |                             if (a.position > b.position) {
 | 
        
           |  |  | 92 |                                 return 1;
 | 
        
           |  |  | 93 |                             }
 | 
        
           |  |  | 94 |                             if (a.position < b.position) {
 | 
        
           |  |  | 95 |                                 return -1;
 | 
        
           |  |  | 96 |                             }
 | 
        
           |  |  | 97 |                             return 0;
 | 
        
           |  |  | 98 |                         });
 | 
        
           |  |  | 99 |                         for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
 | 
        
           |  |  | 100 |                             this.sections[i].questions[j].options[k].position = j;
 | 
        
           |  |  | 101 |                         }
 | 
        
           |  |  | 102 |                     }
 | 
        
           |  |  | 103 |                 }
 | 
        
           |  |  | 104 |             }
 | 
        
           |  |  | 105 |             $('[data-toggle="tooltip"]').tooltip();
 | 
        
           |  |  | 106 |         },
 | 
        
           |  |  | 107 |         this.render = function() {
 | 
        
           |  |  | 108 |             this.sections.sort(function(a, b) {
 | 
        
           |  |  | 109 |                 if (a.position > b.position) {
 | 
        
           |  |  | 110 |                     return 1;
 | 
        
           |  |  | 111 |                 }
 | 
        
           |  |  | 112 |                 if (a.position < b.position) {
 | 
        
           |  |  | 113 |                     return -1;
 | 
        
           |  |  | 114 |                 }
 | 
        
           |  |  | 115 |                 return 0;
 | 
        
           |  |  | 116 |             });
 | 
        
           |  |  | 117 |             var s = '';
 | 
        
           |  |  | 118 |             for (i = 0; i < this.sections.length; i++) {
 | 
        
           |  |  | 119 |                 this.sections[i].position = i;
 | 
        
           |  |  | 120 |                 this.sections[i].questions.sort(function(a, b) {
 | 
        
           |  |  | 121 |                     if (a.position > b.position) {
 | 
        
           |  |  | 122 |                         return 1;
 | 
        
           |  |  | 123 |                     }
 | 
        
           |  |  | 124 |                     if (a.position < b.position) {
 | 
        
           |  |  | 125 |                         return -1;
 | 
        
           |  |  | 126 |                     }
 | 
        
           |  |  | 127 |                     return 0;
 | 
        
           |  |  | 128 |                 });
 | 
        
           |  |  | 129 |                 for (j = 0; j < this.sections[i].questions.length; j++) {
 | 
        
           |  |  | 130 |                     this.sections[i].questions[j].position = j;
 | 
        
           | 6467 | eleazar | 131 |                     if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
 | 
        
           | 4384 | eleazar | 132 |                         this.sections[i].questions[j].options.sort(function(a, b) {
 | 
        
           |  |  | 133 |                             if (a.position > b.position) {
 | 
        
           |  |  | 134 |                                 return 1;
 | 
        
           |  |  | 135 |                             }
 | 
        
           |  |  | 136 |                             if (a.position < b.position) {
 | 
        
           |  |  | 137 |                                 return -1;
 | 
        
           |  |  | 138 |                             }
 | 
        
           |  |  | 139 |                             return 0;
 | 
        
           |  |  | 140 |                         });
 | 
        
           |  |  | 141 |                         for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
 | 
        
           |  |  | 142 |                             this.sections[i].questions[j].options[k].position = j;
 | 
        
           |  |  | 143 |                         }
 | 
        
           |  |  | 144 |                     }
 | 
        
           |  |  | 145 |                 }
 | 
        
           |  |  | 146 |             }
 | 
        
           |  |  | 147 |             $('[data-toggle="tooltip"]').tooltip();
 | 
        
           |  |  | 148 |         },
 | 
        
           |  |  | 149 |         /**
 | 
        
           |  |  | 150 |          * Add element to section array
 | 
        
           |  |  | 151 |          */
 | 
        
           | 4546 | eleazar | 152 |         this.addSection = function(name, text) {
 | 
        
           | 4384 | eleazar | 153 |             var d = new Date();
 | 
        
           |  |  | 154 |             var slug = 'section' + d.getTime();
 | 
        
           |  |  | 155 |             var position = 0;
 | 
        
           |  |  | 156 |             $.each(this.sections, function(index, section) {
 | 
        
           |  |  | 157 |                 if (position < section.position) {
 | 
        
           |  |  | 158 |                     position = section.position;
 | 
        
           |  |  | 159 |                 }
 | 
        
           |  |  | 160 |             });
 | 
        
           |  |  | 161 |             position++;
 | 
        
           |  |  | 162 |             var section = {
 | 
        
           |  |  | 163 |                 'slug_section': slug,
 | 
        
           |  |  | 164 |                 'name': name,
 | 
        
           |  |  | 165 |                 'text': text,
 | 
        
           |  |  | 166 |                 'position': position,
 | 
        
           |  |  | 167 |                 'questions': [],
 | 
        
           |  |  | 168 |                 'status': 0
 | 
        
           |  |  | 169 |             }
 | 
        
           |  |  | 170 |             this.sections.push(section);
 | 
        
           |  |  | 171 |         },
 | 
        
           |  |  | 172 |          /**
 | 
        
           |  |  | 173 |          * Edit element to section array
 | 
        
           |  |  | 174 |          */
 | 
        
           | 4546 | eleazar | 175 |         this.editSection = function(slug, name, text) {
 | 
        
           | 4384 | eleazar | 176 |             var renderTable = false;
 | 
        
           |  |  | 177 |             for (i = 0; i < this.sections.length; i++) {
 | 
        
           |  |  | 178 |                 if (slug == this.sections[i].slug_section) {
 | 
        
           |  |  | 179 |                     this.sections[i].name = name;
 | 
        
           |  |  | 180 |                     this.sections[i].text = text;
 | 
        
           |  |  | 181 |                     renderTable = true;
 | 
        
           |  |  | 182 |                     break;
 | 
        
           |  |  | 183 |                 }
 | 
        
           |  |  | 184 |             }
 | 
        
           |  |  | 185 |             if (renderTable) {
 | 
        
           |  |  | 186 |                 this.renderSection(slug);
 | 
        
           |  |  | 187 |             }
 | 
        
           |  |  | 188 |         },
 | 
        
           |  |  | 189 |          /**
 | 
        
           |  |  | 190 |          * Remove element to section array
 | 
        
           |  |  | 191 |          */
 | 
        
           |  |  | 192 |         this.deleteSection = function(slug) {
 | 
        
           |  |  | 193 |             var renderTable = false;
 | 
        
           |  |  | 194 |             for (i = 0; i < this.sections.length; i++) {
 | 
        
           |  |  | 195 |                 if (slug == this.sections[i].slug_section) {
 | 
        
           |  |  | 196 |                     this.sections.splice(i, 1);
 | 
        
           |  |  | 197 |                     renderTable = true;
 | 
        
           |  |  | 198 |                     break;
 | 
        
           |  |  | 199 |                 }
 | 
        
           |  |  | 200 |             }
 | 
        
           |  |  | 201 |             if (renderTable) {
 | 
        
           |  |  | 202 |                 $('#panel' + slug).remove();
 | 
        
           |  |  | 203 |             }
 | 
        
           |  |  | 204 |         },
 | 
        
           |  |  | 205 |          /**
 | 
        
           |  |  | 206 |          * Add element to question array
 | 
        
           |  |  | 207 |          */
 | 
        
           | 6467 | eleazar | 208 |         this.addQuestion = function(slug_section, text, type, maxlength, multiline, range) {
 | 
        
           | 4384 | eleazar | 209 |             var d = new Date();
 | 
        
           |  |  | 210 |             var slug_question = 'question' + d.getTime();
 | 
        
           |  |  | 211 |             var position = 0;
 | 
        
           |  |  | 212 |             var renderTable = false;
 | 
        
           |  |  | 213 |             for (i = 0; i < this.sections.length; i++) {
 | 
        
           |  |  | 214 |                 if (slug_section == this.sections[i].slug_section) {
 | 
        
           |  |  | 215 |                     $.each(this.sections[i].questions, function(index, question) {
 | 
        
           |  |  | 216 |                         if (position < question.position) {
 | 
        
           |  |  | 217 |                             position = question.position;
 | 
        
           |  |  | 218 |                         }
 | 
        
           |  |  | 219 |                     });
 | 
        
           |  |  | 220 |                     position++;
 | 
        
           |  |  | 221 |                     var question = {
 | 
        
           |  |  | 222 |                         'slug_section': slug_section,
 | 
        
           |  |  | 223 |                         'slug_question': slug_question,
 | 
        
           |  |  | 224 |                         'text': text,
 | 
        
           |  |  | 225 |                         'type': type,
 | 
        
           |  |  | 226 |                         'position': position,
 | 
        
           |  |  | 227 |                         'maxlength': maxlength,
 | 
        
           |  |  | 228 |                         'multiline': multiline,
 | 
        
           | 6467 | eleazar | 229 |                         'range': range,
 | 
        
           | 4384 | eleazar | 230 |                         'options': [],
 | 
        
           |  |  | 231 |                         'answer': type=='multiple' ? [] : ''
 | 
        
           |  |  | 232 |                     }
 | 
        
           |  |  | 233 |                     this.sections[i].questions.push(question);
 | 
        
           |  |  | 234 |                     renderTable = true;
 | 
        
           |  |  | 235 |                     break;
 | 
        
           |  |  | 236 |                 }
 | 
        
           |  |  | 237 |             }
 | 
        
           |  |  | 238 |             if (renderTable) {
 | 
        
           |  |  | 239 |                 this.renderSection(slug_section);
 | 
        
           |  |  | 240 |             }
 | 
        
           |  |  | 241 |         },
 | 
        
           |  |  | 242 |          /**
 | 
        
           |  |  | 243 |          * Add element to question array
 | 
        
           |  |  | 244 |          */
 | 
        
           | 6467 | eleazar | 245 |         this.editQuestion = function(slug_section, slug_question, text, type, maxlength, multiline, range) {
 | 
        
           | 4384 | eleazar | 246 |             var renderTable = false;
 | 
        
           |  |  | 247 |             for (i = 0; i < this.sections.length; i++) {
 | 
        
           |  |  | 248 |                 if (slug_section == this.sections[i].slug_section) {
 | 
        
           |  |  | 249 |                     for (j = 0; j < this.sections[i].questions.length; j++) {
 | 
        
           |  |  | 250 |                         if (slug_question == this.sections[i].questions[j].slug_question) {
 | 
        
           |  |  | 251 |                             this.sections[i].questions[j].text = text,
 | 
        
           |  |  | 252 |                                 this.sections[i].questions[j].type = type;
 | 
        
           |  |  | 253 |                             if (type == 'open') {
 | 
        
           |  |  | 254 |                                 this.sections[i].questions[j].maxlength = maxlength;
 | 
        
           |  |  | 255 |                                 this.sections[i].questions[j].multiline = multiline;
 | 
        
           |  |  | 256 |                                 this.sections[i].questions[j].options = [];
 | 
        
           |  |  | 257 |                             } else {
 | 
        
           |  |  | 258 |                                 this.sections[i].questions[j].maxlength = 0;
 | 
        
           |  |  | 259 |                                 this.sections[i].questions[j].multiline = 0;
 | 
        
           |  |  | 260 |                             }
 | 
        
           | 6467 | eleazar | 261 |                             if (type == 'rating-range') {
 | 
        
           |  |  | 262 |                                 this.sections[i].questions[j].range = range;
 | 
        
           |  |  | 263 |                             } else {
 | 
        
           |  |  | 264 |                                 this.sections[i].questions[j].range = 0;
 | 
        
           |  |  | 265 |                             }
 | 
        
           | 4384 | eleazar | 266 |   | 
        
           |  |  | 267 |                             if(type=='multiple'){
 | 
        
           |  |  | 268 |                                 this.sections[i].questions[j].answer = [];
 | 
        
           |  |  | 269 |                             }else{
 | 
        
           |  |  | 270 |                                 this.sections[i].questions[j].answer = '';
 | 
        
           |  |  | 271 |                             }
 | 
        
           |  |  | 272 |   | 
        
           |  |  | 273 |                             renderTable = true;
 | 
        
           |  |  | 274 |                             break;
 | 
        
           |  |  | 275 |                         }
 | 
        
           |  |  | 276 |                     }
 | 
        
           |  |  | 277 |                 }
 | 
        
           |  |  | 278 |                 if (renderTable) {
 | 
        
           |  |  | 279 |                     break;
 | 
        
           |  |  | 280 |                 }
 | 
        
           |  |  | 281 |             }
 | 
        
           |  |  | 282 |             if (renderTable) {
 | 
        
           |  |  | 283 |                 this.renderSection(slug_section);
 | 
        
           |  |  | 284 |             }
 | 
        
           |  |  | 285 |         },
 | 
        
           |  |  | 286 |         /**
 | 
        
           |  |  | 287 |          * Remove element to question array
 | 
        
           |  |  | 288 |          */
 | 
        
           |  |  | 289 |         this.deleteQuestion = function(slug_section, slug_question) {
 | 
        
           |  |  | 290 |             var renderTable = false;
 | 
        
           |  |  | 291 |             for (i = 0; i < this.sections.length; i++) {
 | 
        
           |  |  | 292 |                 if (slug_section == this.sections[i].slug_section) {
 | 
        
           |  |  | 293 |                     for (j = 0; j < this.sections[i].questions.length; j++) {
 | 
        
           |  |  | 294 |                         if (slug_question == this.sections[i].questions[j].slug_question) {
 | 
        
           |  |  | 295 |                             this.sections[i].questions.splice(j, 1);
 | 
        
           |  |  | 296 |                             renderTable = true;
 | 
        
           |  |  | 297 |                             break;
 | 
        
           |  |  | 298 |                         }
 | 
        
           |  |  | 299 |                     }
 | 
        
           |  |  | 300 |                 }
 | 
        
           |  |  | 301 |                 if (renderTable) {
 | 
        
           |  |  | 302 |                     break;
 | 
        
           |  |  | 303 |                 }
 | 
        
           |  |  | 304 |             }
 | 
        
           |  |  | 305 |             if (renderTable) {
 | 
        
           |  |  | 306 |                 this.renderSection(slug_section);
 | 
        
           |  |  | 307 |             }
 | 
        
           |  |  | 308 |         },
 | 
        
           |  |  | 309 |         /**
 | 
        
           |  |  | 310 |          * Add element to option array
 | 
        
           |  |  | 311 |          */
 | 
        
           | 6276 | eleazar | 312 |         this.addOption = function(slug_section, slug_question, text) {
 | 
        
           | 4384 | eleazar | 313 |             var d = new Date();
 | 
        
           |  |  | 314 |             var slug_option = 'option' + d.getTime();
 | 
        
           |  |  | 315 |             var position = 0;
 | 
        
           |  |  | 316 |             var renderTable = false;
 | 
        
           |  |  | 317 |             for (i = 0; i < this.sections.length; i++) {
 | 
        
           |  |  | 318 |                 if (slug_section == this.sections[i].slug_section) {
 | 
        
           |  |  | 319 |                     for (j = 0; j < this.sections[i].questions.length; j++) {
 | 
        
           |  |  | 320 |                         if (slug_question == this.sections[i].questions[j].slug_question) {
 | 
        
           |  |  | 321 |                             $.each(this.sections[i].questions[j].options, function(index, option) {
 | 
        
           |  |  | 322 |                                 if (position < option.position) {
 | 
        
           |  |  | 323 |                                     position = option.position;
 | 
        
           |  |  | 324 |                                 }
 | 
        
           |  |  | 325 |                             });
 | 
        
           |  |  | 326 |                             position++;
 | 
        
           |  |  | 327 |                             var option = {
 | 
        
           |  |  | 328 |                                 'slug_section': slug_section,
 | 
        
           |  |  | 329 |                                 'slug_question': slug_question,
 | 
        
           |  |  | 330 |                                 'slug_option': slug_option,
 | 
        
           |  |  | 331 |                                 'text': text,
 | 
        
           |  |  | 332 |                                 'checked': false
 | 
        
           |  |  | 333 |                             }
 | 
        
           |  |  | 334 |                             this.sections[i].questions[j].options.push(option);
 | 
        
           |  |  | 335 |                             renderTable = true;
 | 
        
           |  |  | 336 |                             break;
 | 
        
           |  |  | 337 |                         }
 | 
        
           |  |  | 338 |                         if (renderTable) {
 | 
        
           |  |  | 339 |                             break;
 | 
        
           |  |  | 340 |                         }
 | 
        
           |  |  | 341 |                     }
 | 
        
           |  |  | 342 |                 }
 | 
        
           |  |  | 343 |             }
 | 
        
           |  |  | 344 |             if (renderTable) {
 | 
        
           |  |  | 345 |                 this.renderSection(slug_section);
 | 
        
           |  |  | 346 |             }
 | 
        
           |  |  | 347 |         },
 | 
        
           |  |  | 348 |         /**
 | 
        
           |  |  | 349 |          * Edit element to option array
 | 
        
           |  |  | 350 |          */
 | 
        
           | 6276 | eleazar | 351 |         this.editOption = function(slug_section, slug_question, option_slug, text) {
 | 
        
           | 4384 | eleazar | 352 |             var renderTable = false;
 | 
        
           |  |  | 353 |             for (i = 0; i < this.sections.length; i++) {
 | 
        
           |  |  | 354 |                 if (slug_section == this.sections[i].slug_section) {
 | 
        
           |  |  | 355 |                     for (j = 0; j < this.sections[i].questions.length; j++) {
 | 
        
           |  |  | 356 |                         if (slug_question == this.sections[i].questions[j].slug_question) {
 | 
        
           |  |  | 357 |                             for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
 | 
        
           |  |  | 358 |                                 if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
 | 
        
           |  |  | 359 |                                     this.sections[i].questions[j].options[k].text = text;
 | 
        
           |  |  | 360 |                                     renderTable = true;
 | 
        
           |  |  | 361 |                                     break;
 | 
        
           |  |  | 362 |                                 }
 | 
        
           |  |  | 363 |                             }
 | 
        
           |  |  | 364 |                         }
 | 
        
           |  |  | 365 |                         if (renderTable) {
 | 
        
           |  |  | 366 |                             break;
 | 
        
           |  |  | 367 |                         }
 | 
        
           |  |  | 368 |                     }
 | 
        
           |  |  | 369 |                 }
 | 
        
           |  |  | 370 |                 if (renderTable) {
 | 
        
           |  |  | 371 |                     break;
 | 
        
           |  |  | 372 |                 }
 | 
        
           |  |  | 373 |             }
 | 
        
           |  |  | 374 |             if (renderTable) {
 | 
        
           |  |  | 375 |                 this.renderSection(slug_section);
 | 
        
           |  |  | 376 |             }
 | 
        
           |  |  | 377 |         },
 | 
        
           |  |  | 378 |         /**
 | 
        
           |  |  | 379 |          * Remove element to option array
 | 
        
           |  |  | 380 |          */
 | 
        
           |  |  | 381 |         this.deleteOption = function(slug_section, slug_question, option_slug) {
 | 
        
           |  |  | 382 |             var renderTable = false;
 | 
        
           |  |  | 383 |             for (i = 0; i < this.sections.length; i++) {
 | 
        
           |  |  | 384 |                 if (slug_section == this.sections[i].slug_section) {
 | 
        
           |  |  | 385 |                     for (j = 0; j < this.sections[i].questions.length; j++) {
 | 
        
           |  |  | 386 |                         if (slug_question == this.sections[i].questions[j].slug_question) {
 | 
        
           |  |  | 387 |                             for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
 | 
        
           |  |  | 388 |                                 if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
 | 
        
           |  |  | 389 |                                     this.sections[i].questions[j].options.splice(k, 1);
 | 
        
           |  |  | 390 |                                     renderTable = true;
 | 
        
           |  |  | 391 |                                     break;
 | 
        
           |  |  | 392 |                                 }
 | 
        
           |  |  | 393 |                             }
 | 
        
           |  |  | 394 |                         }
 | 
        
           |  |  | 395 |                         if (renderTable) {
 | 
        
           |  |  | 396 |                             break;
 | 
        
           |  |  | 397 |                         }
 | 
        
           |  |  | 398 |                     }
 | 
        
           |  |  | 399 |                 }
 | 
        
           |  |  | 400 |                 if (renderTable) {
 | 
        
           |  |  | 401 |                     break;
 | 
        
           |  |  | 402 |                 }
 | 
        
           |  |  | 403 |             }
 | 
        
           |  |  | 404 |             if (renderTable) {
 | 
        
           |  |  | 405 |                 this.renderSection(slug_section);
 | 
        
           |  |  | 406 |             }
 | 
        
           |  |  | 407 |         }
 | 
        
           |  |  | 408 | }
 | 
        
           |  |  | 409 |   | 
        
           |  |  | 410 | function htmlEntities(str) {
 | 
        
           |  |  | 411 |     return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
 | 
        
           |  |  | 412 | }
 | 
        
           |  |  | 413 | jQuery(document).ready(function($) {
 | 
        
           |  |  | 414 |     var objFormGenerator = new classFormGenerator();
 | 
        
           |  |  | 415 |     objFormGenerator.render();
 | 
        
           |  |  | 416 |     var allowEdit = $allowEdit;
 | 
        
           |  |  | 417 |     var allowDelete = $allowDelete;
 | 
        
           |  |  | 418 |     /**
 | 
        
           |  |  | 419 |      * Get rows and set data table
 | 
        
           |  |  | 420 |      */
 | 
        
           |  |  | 421 |     var tableForm = $('#gridTable').dataTable({
 | 
        
           |  |  | 422 |         'processing': true,
 | 
        
           |  |  | 423 |         'serverSide': true,
 | 
        
           |  |  | 424 |         'searching': true,
 | 
        
           |  |  | 425 |         'order': [
 | 
        
           |  |  | 426 |             [0, 'asc']
 | 
        
           |  |  | 427 |         ],
 | 
        
           |  |  | 428 |         'ordering': true,
 | 
        
           |  |  | 429 |         'ordenable': true,
 | 
        
           |  |  | 430 |         'responsive': true,
 | 
        
           |  |  | 431 |         'select': false,
 | 
        
           |  |  | 432 |         'paging': true,
 | 
        
           |  |  | 433 |         'pagingType': 'simple_numbers',
 | 
        
           |  |  | 434 |         'ajax': {
 | 
        
           |  |  | 435 |             'url': '$routeDatatable',
 | 
        
           |  |  | 436 |             'type': 'get',
 | 
        
           |  |  | 437 |             'beforeSend': function(request) {
 | 
        
           |  |  | 438 |                 NProgress.start();
 | 
        
           |  |  | 439 |             },
 | 
        
           |  |  | 440 |             'dataFilter': function(response) {
 | 
        
           |  |  | 441 |                 var response = jQuery.parseJSON(response);
 | 
        
           |  |  | 442 |                 var json = {};
 | 
        
           |  |  | 443 |                 json.recordsTotal = 0;
 | 
        
           |  |  | 444 |                 json.recordsFiltered = 0;
 | 
        
           |  |  | 445 |                 json.data = [];
 | 
        
           |  |  | 446 |                 if (response.success) {
 | 
        
           |  |  | 447 |                     json.recordsTotal = response.data.total;
 | 
        
           |  |  | 448 |                     json.recordsFiltered = response.data.total;
 | 
        
           |  |  | 449 |                     json.data = response.data.items;
 | 
        
           |  |  | 450 |                 } else {
 | 
        
           |  |  | 451 |                     $.fn.showError(response.data)
 | 
        
           |  |  | 452 |                 }
 | 
        
           |  |  | 453 |                 return JSON.stringify(json);
 | 
        
           |  |  | 454 |             }
 | 
        
           |  |  | 455 |         },
 | 
        
           |  |  | 456 |         'language': {
 | 
        
           |  |  | 457 |             'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
 | 
        
           |  |  | 458 |             'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
 | 
        
           |  |  | 459 |             'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
 | 
        
           |  |  | 460 |             'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
 | 
        
           |  |  | 461 |             'sInfo': 'LABEL_DATATABLE_SINFO',
 | 
        
           |  |  | 462 |             'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
 | 
        
           |  |  | 463 |             'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
 | 
        
           |  |  | 464 |             'sInfoPostFix': '',
 | 
        
           |  |  | 465 |             'sSearch': 'LABEL_DATATABLE_SSEARCH',
 | 
        
           |  |  | 466 |             'sUrl': '',
 | 
        
           |  |  | 467 |             'sInfoThousands': ',',
 | 
        
           |  |  | 468 |             'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
 | 
        
           |  |  | 469 |             'oPaginate': {
 | 
        
           |  |  | 470 |                 'sFirst': 'LABEL_DATATABLE_SFIRST',
 | 
        
           |  |  | 471 |                 'sLast': 'LABEL_DATATABLE_SLAST',
 | 
        
           |  |  | 472 |                 'sNext': 'LABEL_DATATABLE_SNEXT',
 | 
        
           |  |  | 473 |                 'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
 | 
        
           |  |  | 474 |             },
 | 
        
           |  |  | 475 |             'oAria': {
 | 
        
           |  |  | 476 |                 'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
 | 
        
           |  |  | 477 |                 'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
 | 
        
           |  |  | 478 |             },
 | 
        
           |  |  | 479 |         },
 | 
        
           |  |  | 480 |         'drawCallback': function(settings) {
 | 
        
           |  |  | 481 |             NProgress.done();
 | 
        
           |  |  | 482 |             $('button.btn-delete').confirmation({
 | 
        
           |  |  | 483 |                 rootSelector: 'button.btn-delete',
 | 
        
           |  |  | 484 |                 title: 'LABEL_ARE_YOU_SURE',
 | 
        
           |  |  | 485 |                 singleton: true,
 | 
        
           |  |  | 486 |                 btnOkLabel: 'LABEL_YES',
 | 
        
           |  |  | 487 |                 btnCancelLabel: 'LABEL_NO',
 | 
        
           |  |  | 488 |                 onConfirm: function(value) {
 | 
        
           |  |  | 489 |                     action = $(this).data('href');
 | 
        
           |  |  | 490 |                     NProgress.start();
 | 
        
           |  |  | 491 |                     $.ajax({
 | 
        
           |  |  | 492 |                         'dataType': 'json',
 | 
        
           |  |  | 493 |                         'accept': 'application/json',
 | 
        
           |  |  | 494 |                         'method': 'post',
 | 
        
           |  |  | 495 |                         'url': action,
 | 
        
           |  |  | 496 |                     }).done(function(response) {
 | 
        
           |  |  | 497 |                         if (response['success']) {
 | 
        
           |  |  | 498 |                             $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 499 |                             tableForm.fnDraw();
 | 
        
           |  |  | 500 |                         } else {
 | 
        
           |  |  | 501 |                             $.fn.showError(response['data']);
 | 
        
           |  |  | 502 |                         }
 | 
        
           |  |  | 503 |                     }).fail(function(jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 504 |                         $.fn.showError(textStatus);
 | 
        
           |  |  | 505 |                     }).always(function() {
 | 
        
           |  |  | 506 |                         NProgress.done();
 | 
        
           |  |  | 507 |                     });
 | 
        
           |  |  | 508 |                 },
 | 
        
           |  |  | 509 |             });
 | 
        
           |  |  | 510 |         },
 | 
        
           |  |  | 511 |         'aoColumns': [{
 | 
        
           |  |  | 512 |                 'mDataProp': 'name'
 | 
        
           |  |  | 513 |             },
 | 
        
           |  |  | 514 |             {
 | 
        
           |  |  | 515 |                 'mDataProp': 'status'
 | 
        
           |  |  | 516 |             },
 | 
        
           |  |  | 517 |             {
 | 
        
           |  |  | 518 |                 'mDataProp': 'actions'
 | 
        
           |  |  | 519 |             },
 | 
        
           |  |  | 520 |         ],
 | 
        
           |  |  | 521 |         'columnDefs': [{
 | 
        
           |  |  | 522 |                 'targets': 0,
 | 
        
           |  |  | 523 |                 'className': 'text-vertical-middle',
 | 
        
           |  |  | 524 |             },
 | 
        
           |  |  | 525 |             {
 | 
        
           |  |  | 526 |                 'targets': 1,
 | 
        
           |  |  | 527 |                 'className': 'text-vertical-middle',
 | 
        
           |  |  | 528 |             },
 | 
        
           |  |  | 529 |             {
 | 
        
           |  |  | 530 |                 'targets': -2,
 | 
        
           |  |  | 531 |                 'orderable': false,
 | 
        
           |  |  | 532 |                 'className': 'text-center',
 | 
        
           |  |  | 533 |                 'render': function(data, type, row) {
 | 
        
           | 8303 | eleazar | 534 |                     checked = data == 'A' ? ' checked="checked" ' : '';
 | 
        
           | 4384 | eleazar | 535 |                     return '<div class="checkbox checkbox-success">' +
 | 
        
           |  |  | 536 |                         '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
 | 
        
           |  |  | 537 |                         '<label ></label></div>';
 | 
        
           |  |  | 538 |                 }
 | 
        
           |  |  | 539 |             },
 | 
        
           |  |  | 540 |             {
 | 
        
           |  |  | 541 |                 'targets': -1,
 | 
        
           |  |  | 542 |                 'orderable': false,
 | 
        
           |  |  | 543 |                 'render': function(data, type, row) {
 | 
        
           |  |  | 544 |                     s = '';
 | 
        
           |  |  | 545 |                     if (allowEdit) {
 | 
        
           |  |  | 546 |                         s = s + '<button class="btn btn-primary btn-edit-form" data-href="' + data['link_edit'] + '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button> ';
 | 
        
           |  |  | 547 |                     }
 | 
        
           |  |  | 548 |                     if (allowDelete) {
 | 
        
           |  |  | 549 |                         s = s + '<button class="btn btn-danger btn-delete" data-href="' + data['link_delete'] + '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button> ';
 | 
        
           |  |  | 550 |                     }
 | 
        
           |  |  | 551 |                     return s;
 | 
        
           |  |  | 552 |                 }
 | 
        
           |  |  | 553 |             }
 | 
        
           |  |  | 554 |         ],
 | 
        
           |  |  | 555 |     });
 | 
        
           |  |  | 556 |     /**
 | 
        
           |  |  | 557 |      * Clicked on edit form
 | 
        
           |  |  | 558 |      */
 | 
        
           |  |  | 559 |     $('body').on('click', 'button.btn-edit-form', function(e) {
 | 
        
           |  |  | 560 |         e.preventDefault();
 | 
        
           |  |  | 561 |         form_id = $(this).data('id')
 | 
        
           |  |  | 562 |         var action = $(this).data('href');
 | 
        
           |  |  | 563 |         $.ajax({
 | 
        
           |  |  | 564 |             'dataType': 'json',
 | 
        
           |  |  | 565 |             'accept': 'application/json',
 | 
        
           |  |  | 566 |             'method': 'get',
 | 
        
           |  |  | 567 |             'url': action,
 | 
        
           |  |  | 568 |         }).done(function(response) {
 | 
        
           |  |  | 569 |             if (response['success']) {
 | 
        
           |  |  | 570 |                 validatorForm.resetForm();
 | 
        
           |  |  | 571 |                 $('#form-main').attr('action', action);
 | 
        
           |  |  | 572 |                 $('#form-main #form-id').val(response['data']['id']),
 | 
        
           |  |  | 573 |                 $('#form-main #form-continue').val('0');
 | 
        
           | 4459 | eleazar | 574 |                 $('#form-main #name').val(response['data']['name']),
 | 
        
           | 4384 | eleazar | 575 |   | 
        
           |  |  | 576 |                 /*----------Set Ckeditor ------------*/
 | 
        
           | 4466 | eleazar | 577 |                 CKEDITOR.instances.description.setData(response['data']['description']);
 | 
        
           |  |  | 578 |                 CKEDITOR.instances.text.setData(response['data']['text']);
 | 
        
           | 4384 | eleazar | 579 |   | 
        
           | 4493 | eleazar | 580 |                 $('#form-main #status').val(response['data']['status']);
 | 
        
           | 4384 | eleazar | 581 |   | 
        
           |  |  | 582 |                 /*-------------Render Sections -------*/
 | 
        
           |  |  | 583 |   | 
        
           |  |  | 584 |                 objFormGenerator.clear();
 | 
        
           |  |  | 585 |                 objFormGenerator.sections = response['data']['content'] || [];
 | 
        
           |  |  | 586 |                 objFormGenerator.render();
 | 
        
           |  |  | 587 |                 renderSectionData(objFormGenerator.sections);
 | 
        
           |  |  | 588 |   | 
        
           |  |  | 589 |                 $('#row-forms').hide();
 | 
        
           |  |  | 590 |                 $('#row-edit').show();
 | 
        
           | 4459 | eleazar | 591 |                 $('#form-main #name').focus();
 | 
        
           | 4384 | eleazar | 592 |   | 
        
           |  |  | 593 |             } else {
 | 
        
           |  |  | 594 |                 $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
 | 
        
           |  |  | 595 |             }
 | 
        
           |  |  | 596 |         }).fail(function(jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 597 |             $.fn.showError(textStatus);
 | 
        
           |  |  | 598 |         });
 | 
        
           |  |  | 599 |     });
 | 
        
           |  |  | 600 |     $(document).on('click', '[data-type="select_all"]', function() {
 | 
        
           |  |  | 601 |         if ($('input[name="select_all"]:checked').val() == 'all') {
 | 
        
           |  |  | 602 |             $('[data-type="select"]').prop('checked', true);
 | 
        
           |  |  | 603 |             $('[data-action="delete"]').removeClass('hide');
 | 
        
           |  |  | 604 |         } else {
 | 
        
           |  |  | 605 |             $('[data-type="select"]').prop('checked', false);
 | 
        
           |  |  | 606 |             $('[data-action="delete"]').addClass('hide');
 | 
        
           |  |  | 607 |         }
 | 
        
           |  |  | 608 |     });
 | 
        
           |  |  | 609 |   | 
        
           |  |  | 610 |     function getLength() {
 | 
        
           |  |  | 611 |         return $('[data-type="select"]').length;
 | 
        
           |  |  | 612 |     }
 | 
        
           |  |  | 613 |   | 
        
           |  |  | 614 |     function currentSelected() {
 | 
        
           |  |  | 615 |         var selected = [];
 | 
        
           |  |  | 616 |         $.each($("input[name='select[]']:checked"), function() {
 | 
        
           |  |  | 617 |             selected.push($(this).val());
 | 
        
           |  |  | 618 |         });
 | 
        
           |  |  | 619 |         return selected;
 | 
        
           |  |  | 620 |     }
 | 
        
           |  |  | 621 |     $(document).on('change', "input[name='select[]']", function() {
 | 
        
           |  |  | 622 |         var c = currentSelected();
 | 
        
           |  |  | 623 |         var cc = getLength();
 | 
        
           |  |  | 624 |         if (c.length == cc) {
 | 
        
           |  |  | 625 |             if ($('[data-action="delete"]').hasClass('hide')) {
 | 
        
           |  |  | 626 |                 $('[data-action="delete"]').removeClass('hide');
 | 
        
           |  |  | 627 |             }
 | 
        
           |  |  | 628 |             return true;
 | 
        
           |  |  | 629 |         } else {
 | 
        
           |  |  | 630 |             $('input[name="select_all"]').prop('checked', false);
 | 
        
           |  |  | 631 |         }
 | 
        
           |  |  | 632 |         if (c.length > 0) {
 | 
        
           |  |  | 633 |             if ($('[data-action="delete"]').hasClass('hide')) {
 | 
        
           |  |  | 634 |                 $('[data-action="delete"]').removeClass('hide');
 | 
        
           |  |  | 635 |             }
 | 
        
           |  |  | 636 |         } else {
 | 
        
           |  |  | 637 |             if (!$('[data-action="delete"]').hasClass('hide')) {
 | 
        
           |  |  | 638 |                 $('[data-action="delete"]').addClass('hide');
 | 
        
           |  |  | 639 |             }
 | 
        
           |  |  | 640 |         }
 | 
        
           |  |  | 641 |     });
 | 
        
           |  |  | 642 |     var form3 = $('#form_sample_3');
 | 
        
           |  |  | 643 |     var error3 = $('.alert-danger', form3);
 | 
        
           |  |  | 644 |     var success3 = $('.alert-success', form3);
 | 
        
           |  |  | 645 |     //IMPORTANT: update CKEDITOR textarea with actual content before submit
 | 
        
           |  |  | 646 |     $("#form-main").on('submit', function() {
 | 
        
           |  |  | 647 |         for (var instanceName in CKEDITOR.instances) {
 | 
        
           |  |  | 648 |             CKEDITOR.instances[instanceName].updateElement();
 | 
        
           |  |  | 649 |         }
 | 
        
           |  |  | 650 |     })
 | 
        
           |  |  | 651 |     /**
 | 
        
           |  |  | 652 |      * Validate rules form
 | 
        
           |  |  | 653 |      */
 | 
        
           |  |  | 654 |     var validatorForm = $("#form-main").validate({
 | 
        
           |  |  | 655 |         ignore: [],
 | 
        
           |  |  | 656 |         errorClass: 'help-block',
 | 
        
           |  |  | 657 |         errorElement: 'span',
 | 
        
           |  |  | 658 |         rules: {
 | 
        
           |  |  | 659 |             'form-name': {
 | 
        
           |  |  | 660 |                 required: true,
 | 
        
           |  |  | 661 |                 minlength: 2,
 | 
        
           |  |  | 662 |                 maxlength: 50
 | 
        
           |  |  | 663 |             },
 | 
        
           | 4466 | eleazar | 664 |             'description':{
 | 
        
           |  |  | 665 |                 updateCkeditor:function() {
 | 
        
           |  |  | 666 |                     CKEDITOR.instances.description.updateElement();
 | 
        
           |  |  | 667 |                 },
 | 
        
           | 4384 | eleazar | 668 |             },
 | 
        
           | 4466 | eleazar | 669 |             'text':{
 | 
        
           |  |  | 670 |                 updateCkeditor:function() {
 | 
        
           |  |  | 671 |                     CKEDITOR.instances.text.updateElement();
 | 
        
           |  |  | 672 |                 },
 | 
        
           | 4384 | eleazar | 673 |             },
 | 
        
           |  |  | 674 |             'forrm-status': {
 | 
        
           |  |  | 675 |                 required: true,
 | 
        
           |  |  | 676 |             },
 | 
        
           |  |  | 677 |         },
 | 
        
           |  |  | 678 |         highlight: function(element) {
 | 
        
           |  |  | 679 |             $(element).closest('.form-group').addClass('has-error');
 | 
        
           |  |  | 680 |         },
 | 
        
           |  |  | 681 |         unhighlight: function(element) {
 | 
        
           |  |  | 682 |             $(element).closest('.form-group').removeClass('has-error');
 | 
        
           |  |  | 683 |         },
 | 
        
           |  |  | 684 |         errorPlacement: function(error, element) {
 | 
        
           |  |  | 685 |             if (element.attr("data-error-container")) {
 | 
        
           |  |  | 686 |                 error.appendTo(element.attr("data-error-container"));
 | 
        
           |  |  | 687 |             } else {
 | 
        
           |  |  | 688 |                 error.insertAfter(element);
 | 
        
           |  |  | 689 |             }
 | 
        
           |  |  | 690 |         },
 | 
        
           |  |  | 691 |         invalidHandler: function(form, validator) {
 | 
        
           |  |  | 692 |             if (!validator.numberOfInvalids())
 | 
        
           |  |  | 693 |                 return;
 | 
        
           |  |  | 694 |             $('html, body').animate({
 | 
        
           |  |  | 695 |                 scrollTop: $(validator.errorList[0].element).offset().top - 100
 | 
        
           |  |  | 696 |             }, 1000);
 | 
        
           |  |  | 697 |         },
 | 
        
           |  |  | 698 |         submitHandler: function(form) {
 | 
        
           |  |  | 699 |             var error = false;
 | 
        
           |  |  | 700 |             if (objFormGenerator.sections.length == 0) {
 | 
        
           |  |  | 701 |                 $.fn.showError('ERROR_SECCTIONS');
 | 
        
           |  |  | 702 |                 return false;
 | 
        
           |  |  | 703 |             } else {
 | 
        
           |  |  | 704 |                 for (i = 0; i < objFormGenerator.sections.length; i++) {
 | 
        
           |  |  | 705 |                     if (objFormGenerator.sections[i].questions.length == 0) {
 | 
        
           |  |  | 706 |                         $.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
 | 
        
           |  |  | 707 |                         return false;
 | 
        
           |  |  | 708 |                     }
 | 
        
           |  |  | 709 |                     for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
 | 
        
           |  |  | 710 |                         if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
 | 
        
           | 6467 | eleazar | 711 |                             objFormGenerator.sections[i].questions[j].type == 'multiple' ||
 | 
        
           |  |  | 712 |                             objFormGenerator.sections[i].questions[j].type == 'rating-open') {
 | 
        
           | 4384 | eleazar | 713 |                             var questionNumber = j + 1;
 | 
        
           |  |  | 714 |                             var numberCorrect = 0;
 | 
        
           |  |  | 715 |                             if (objFormGenerator.sections[i].questions[j].options.length == 0) {
 | 
        
           |  |  | 716 |                                 $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
 | 
        
           |  |  | 717 |                                 return false;
 | 
        
           |  |  | 718 |                             }
 | 
        
           |  |  | 719 |                             var totalOption = 0;
 | 
        
           |  |  | 720 |                             var maxOption = 0;
 | 
        
           |  |  | 721 |                         }
 | 
        
           |  |  | 722 |                     }
 | 
        
           |  |  | 723 |                 }
 | 
        
           |  |  | 724 |                 var formContinue = parseInt($('#form-main #form-continue').val());
 | 
        
           |  |  | 725 |                 var data = {
 | 
        
           | 4459 | eleazar | 726 |                     'name': $('#form-main #name').val(),
 | 
        
           |  |  | 727 |                     'description': $('#form-main #description').val(),
 | 
        
           |  |  | 728 |                     'text': $('#form-main #text').val(),
 | 
        
           |  |  | 729 |                     'status': $('#form-main #status').val(),
 | 
        
           | 4384 | eleazar | 730 |                     'content': JSON.stringify(objFormGenerator.sections)
 | 
        
           |  |  | 731 |                 }
 | 
        
           |  |  | 732 |                 $.ajax({
 | 
        
           |  |  | 733 |                     'dataType': 'json',
 | 
        
           |  |  | 734 |                     'method': 'post',
 | 
        
           |  |  | 735 |                     'url': $('#form-main').attr('action'),
 | 
        
           |  |  | 736 |                     'data': data,
 | 
        
           |  |  | 737 |                 }).done(function(response) {
 | 
        
           |  |  | 738 |                     if (response['success']) {
 | 
        
           |  |  | 739 |                         $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 740 |                         if (formContinue == 1) {
 | 
        
           |  |  | 741 |                             $('#form-main').attr('action',response['action_edit']);
 | 
        
           |  |  | 742 |                             $('#form-main #form-id').val(response['id']);
 | 
        
           | 8366 | eleazar | 743 |                             $('#form-main #form-continue').val(0);
 | 
        
           | 4384 | eleazar | 744 |                         } else {
 | 
        
           |  |  | 745 |                             $('#row-edit').hide();
 | 
        
           |  |  | 746 |                             $('#row-forms').show();
 | 
        
           |  |  | 747 |                         /*---------- Reset Form -------- */
 | 
        
           |  |  | 748 |                         $('#form-main')[0].reset();
 | 
        
           |  |  | 749 |                         /*--------Reset Ckeditor ----------*/
 | 
        
           | 4466 | eleazar | 750 |                         CKEDITOR.instances.text.setData('');
 | 
        
           |  |  | 751 |                         CKEDITOR.instances.description.setData('');
 | 
        
           | 4384 | eleazar | 752 |                         /*--------Reset Sections ----------*/
 | 
        
           |  |  | 753 |                         clearSectionData();
 | 
        
           |  |  | 754 |                         /* ------- Refresh Table -----------*/
 | 
        
           |  |  | 755 |   | 
        
           |  |  | 756 |                         }
 | 
        
           |  |  | 757 |                         tableForm.fnDraw();
 | 
        
           |  |  | 758 |                     } else {
 | 
        
           |  |  | 759 |                         $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
 | 
        
           |  |  | 760 |                     }
 | 
        
           |  |  | 761 |                 }).fail(function(jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 762 |                     $.fn.showError(textStatus);
 | 
        
           |  |  | 763 |                 });
 | 
        
           |  |  | 764 |                 return false;
 | 
        
           |  |  | 765 |             }
 | 
        
           |  |  | 766 |         }
 | 
        
           |  |  | 767 |     });
 | 
        
           |  |  | 768 |     //IMPORTANT: update CKEDITOR textarea with actual content before submit
 | 
        
           |  |  | 769 |     $("#form-section").on('submit', function() {
 | 
        
           |  |  | 770 |         for (var instanceName in CKEDITOR.instances) {
 | 
        
           |  |  | 771 |             CKEDITOR.instances[instanceName].updateElement();
 | 
        
           |  |  | 772 |         }
 | 
        
           |  |  | 773 |     })
 | 
        
           |  |  | 774 |     /**
 | 
        
           |  |  | 775 |      * Validate rules form section
 | 
        
           |  |  | 776 |      */
 | 
        
           |  |  | 777 |     var validatorFormSection = $("#form-section").validate({
 | 
        
           |  |  | 778 |         ignore: [],
 | 
        
           |  |  | 779 |         errorClass: 'help-block',
 | 
        
           |  |  | 780 |         errorElement: 'span',
 | 
        
           |  |  | 781 |         rules: {
 | 
        
           |  |  | 782 |             'section-name': {
 | 
        
           |  |  | 783 |                 required: true,
 | 
        
           |  |  | 784 |                 minlength: 2,
 | 
        
           |  |  | 785 |                 maxlength: 50
 | 
        
           |  |  | 786 |             },
 | 
        
           | 8988 | stevensc | 787 |             'section': {
 | 
        
           | 4384 | eleazar | 788 |                 required: false,
 | 
        
           |  |  | 789 |             },
 | 
        
           |  |  | 790 |         },
 | 
        
           |  |  | 791 |         highlight: function(element) {
 | 
        
           |  |  | 792 |             $(element).closest('.form-group').addClass('has-error');
 | 
        
           |  |  | 793 |         },
 | 
        
           |  |  | 794 |         unhighlight: function(element) {
 | 
        
           |  |  | 795 |             $(element).closest('.form-group').removeClass('has-error');
 | 
        
           |  |  | 796 |         },
 | 
        
           |  |  | 797 |         errorPlacement: function(error, element) {
 | 
        
           |  |  | 798 |             if (element.attr("data-error-container")) {
 | 
        
           |  |  | 799 |                 error.appendTo(element.attr("data-error-container"));
 | 
        
           |  |  | 800 |             } else {
 | 
        
           |  |  | 801 |                 error.insertAfter(element);
 | 
        
           |  |  | 802 |             }
 | 
        
           |  |  | 803 |         },
 | 
        
           |  |  | 804 |         invalidHandler: function(form, validator) {
 | 
        
           |  |  | 805 |             if (!validator.numberOfInvalids())
 | 
        
           |  |  | 806 |                 return;
 | 
        
           |  |  | 807 |             $('html, body').animate({
 | 
        
           |  |  | 808 |                 scrollTop: $(validator.errorList[0].element).offset().top - 100
 | 
        
           |  |  | 809 |             }, 1000);
 | 
        
           |  |  | 810 |         },
 | 
        
           |  |  | 811 |         submitHandler: function(form) {
 | 
        
           |  |  | 812 |             // do other things for a valid form
 | 
        
           |  |  | 813 |             //form.submit();
 | 
        
           |  |  | 814 |             var slug = $('#form-section #section-slug').val();
 | 
        
           |  |  | 815 |             if (slug) {
 | 
        
           |  |  | 816 |                 objFormGenerator.editSection(
 | 
        
           |  |  | 817 |                     $('#form-section #section-slug').val(),
 | 
        
           |  |  | 818 |                     $('#form-section #section-name').val(),
 | 
        
           | 8988 | stevensc | 819 |                     $('#form-section #section').val(),
 | 
        
           | 4384 | eleazar | 820 |                 );
 | 
        
           |  |  | 821 |             } else {
 | 
        
           |  |  | 822 |                 objFormGenerator.addSection(
 | 
        
           |  |  | 823 |                     $('#form-section #section-name').val(),
 | 
        
           | 8988 | stevensc | 824 |                     $('#form-section #section').val()
 | 
        
           | 4384 | eleazar | 825 |                 );
 | 
        
           |  |  | 826 |             }
 | 
        
           |  |  | 827 |             renderSectionData(objFormGenerator.sections);
 | 
        
           |  |  | 828 |             $('#modal-section').modal('hide');
 | 
        
           |  |  | 829 |             return false;
 | 
        
           |  |  | 830 |         }
 | 
        
           |  |  | 831 |     });
 | 
        
           |  |  | 832 |     //IMPORTANT: update CKEDITOR textarea with actual content before submit
 | 
        
           |  |  | 833 |     $("#form-question").on('submit', function() {
 | 
        
           |  |  | 834 |         for (var instanceName in CKEDITOR.instances) {
 | 
        
           |  |  | 835 |             CKEDITOR.instances[instanceName].updateElement();
 | 
        
           |  |  | 836 |         }
 | 
        
           |  |  | 837 |     })
 | 
        
           |  |  | 838 |     /**
 | 
        
           |  |  | 839 |      * Validate rules form Questions
 | 
        
           |  |  | 840 |      */
 | 
        
           |  |  | 841 |     var validatorFormQuestion = $("#form-question").validate({
 | 
        
           |  |  | 842 |         ignore: [],
 | 
        
           |  |  | 843 |         errorClass: 'help-block',
 | 
        
           |  |  | 844 |         errorElement: 'span',
 | 
        
           |  |  | 845 |         rules: {
 | 
        
           |  |  | 846 |             'question-text': {
 | 
        
           |  |  | 847 |                 required: true,
 | 
        
           |  |  | 848 |             },
 | 
        
           |  |  | 849 |             'question-type': {
 | 
        
           |  |  | 850 |                 required: true,
 | 
        
           |  |  | 851 |             },
 | 
        
           |  |  | 852 |             'question-max-length': {
 | 
        
           |  |  | 853 |                 required: true,
 | 
        
           |  |  | 854 |                 digits: true,
 | 
        
           |  |  | 855 |                 min: 0
 | 
        
           |  |  | 856 |             },
 | 
        
           | 6467 | eleazar | 857 |             'question-range': {
 | 
        
           |  |  | 858 |                 required: true,
 | 
        
           |  |  | 859 |                 number: true,
 | 
        
           |  |  | 860 |                 min: 1
 | 
        
           |  |  | 861 |             },
 | 
        
           | 4384 | eleazar | 862 |         },
 | 
        
           |  |  | 863 |         highlight: function(element) {
 | 
        
           |  |  | 864 |             $(element).closest('.form-group').addClass('has-error');
 | 
        
           |  |  | 865 |         },
 | 
        
           |  |  | 866 |         unhighlight: function(element) {
 | 
        
           |  |  | 867 |             $(element).closest('.form-group').removeClass('has-error');
 | 
        
           |  |  | 868 |         },
 | 
        
           |  |  | 869 |         errorPlacement: function(error, element) {
 | 
        
           |  |  | 870 |             if (element.attr("data-error-container")) {
 | 
        
           |  |  | 871 |                 error.appendTo(element.attr("data-error-container"));
 | 
        
           |  |  | 872 |             } else {
 | 
        
           |  |  | 873 |                 error.insertAfter(element);
 | 
        
           |  |  | 874 |             }
 | 
        
           |  |  | 875 |         },
 | 
        
           |  |  | 876 |         invalidHandler: function(form, validator) {
 | 
        
           |  |  | 877 |             if (!validator.numberOfInvalids())
 | 
        
           |  |  | 878 |                 return;
 | 
        
           |  |  | 879 |             $('html, body').animate({
 | 
        
           |  |  | 880 |                 scrollTop: $(validator.errorList[0].element).offset().top - 100
 | 
        
           |  |  | 881 |             }, 1000);
 | 
        
           |  |  | 882 |         },
 | 
        
           |  |  | 883 |         submitHandler: function(form) {
 | 
        
           |  |  | 884 |             if ($('#form-question #question-slug').val()) {
 | 
        
           |  |  | 885 |                 objFormGenerator.editQuestion(
 | 
        
           |  |  | 886 |                     $('#form-question #question-section').val(),
 | 
        
           |  |  | 887 |                     $('#form-question #question-slug').val(),
 | 
        
           |  |  | 888 |                     $('#form-question #question-text').val(),
 | 
        
           |  |  | 889 |                     $('#form-question #question-type').val(),
 | 
        
           |  |  | 890 |                     $('#form-question #question-max-length').val(),
 | 
        
           | 6467 | eleazar | 891 |                     $('#form-question #question-multiline').val(),
 | 
        
           |  |  | 892 |                     $('#form-question #question-range').val()
 | 
        
           | 4384 | eleazar | 893 |                 );
 | 
        
           |  |  | 894 |             } else {
 | 
        
           |  |  | 895 |                 objFormGenerator.addQuestion(
 | 
        
           |  |  | 896 |                     $('#form-question #question-section').val(),
 | 
        
           |  |  | 897 |                     $('#form-question #question-text').val(),
 | 
        
           |  |  | 898 |                     $('#form-question #question-type').val(),
 | 
        
           |  |  | 899 |                     $('#form-question #question-max-length').val(),
 | 
        
           | 6467 | eleazar | 900 |                     $('#form-question #question-multiline').val(),
 | 
        
           |  |  | 901 |                     $('#form-question #question-range').val()
 | 
        
           | 4384 | eleazar | 902 |                 );
 | 
        
           |  |  | 903 |             }
 | 
        
           |  |  | 904 |             renderSectionData(objFormGenerator.sections);
 | 
        
           |  |  | 905 |             $('#modal-question').modal('hide');
 | 
        
           |  |  | 906 |             return false;
 | 
        
           |  |  | 907 |         }
 | 
        
           |  |  | 908 |     });
 | 
        
           |  |  | 909 |     //IMPORTANT: update CKEDITOR textarea with actual content before submit
 | 
        
           |  |  | 910 |     $("#form-option").on('submit', function() {
 | 
        
           |  |  | 911 |         for (var instanceName in CKEDITOR.instances) {
 | 
        
           |  |  | 912 |             CKEDITOR.instances[instanceName].updateElement();
 | 
        
           |  |  | 913 |         }
 | 
        
           |  |  | 914 |     })
 | 
        
           |  |  | 915 |     /**
 | 
        
           |  |  | 916 |      * Validate rules form options
 | 
        
           |  |  | 917 |      */
 | 
        
           |  |  | 918 |     var validatorFormOption = $("#form-option").validate({
 | 
        
           |  |  | 919 |         ignore: [],
 | 
        
           |  |  | 920 |         errorClass: 'help-block',
 | 
        
           |  |  | 921 |         errorElement: 'span',
 | 
        
           |  |  | 922 |         rules: {
 | 
        
           |  |  | 923 |             'option-text': {
 | 
        
           |  |  | 924 |                 required: true,
 | 
        
           |  |  | 925 |             }
 | 
        
           | 4546 | eleazar | 926 |   | 
        
           | 4384 | eleazar | 927 |         },
 | 
        
           |  |  | 928 |         highlight: function(element) {
 | 
        
           |  |  | 929 |             $(element).closest('.form-group').addClass('has-error');
 | 
        
           |  |  | 930 |         },
 | 
        
           |  |  | 931 |         unhighlight: function(element) {
 | 
        
           |  |  | 932 |             $(element).closest('.form-group').removeClass('has-error');
 | 
        
           |  |  | 933 |         },
 | 
        
           |  |  | 934 |         errorPlacement: function(error, element) {
 | 
        
           |  |  | 935 |             if (element.attr("data-error-container")) {
 | 
        
           |  |  | 936 |                 error.appendTo(element.attr("data-error-container"));
 | 
        
           |  |  | 937 |             } else {
 | 
        
           |  |  | 938 |                 error.insertAfter(element);
 | 
        
           |  |  | 939 |             }
 | 
        
           |  |  | 940 |         },
 | 
        
           |  |  | 941 |         invalidHandler: function(form, validator) {
 | 
        
           |  |  | 942 |             if (!validator.numberOfInvalids())
 | 
        
           |  |  | 943 |                 return;
 | 
        
           |  |  | 944 |             $('html, body').animate({
 | 
        
           |  |  | 945 |                 scrollTop: $(validator.errorList[0].element).offset().top - 100
 | 
        
           |  |  | 946 |             }, 1000);
 | 
        
           |  |  | 947 |         },
 | 
        
           |  |  | 948 |         submitHandler: function(form) {
 | 
        
           |  |  | 949 |             if ($('#form-option #option-slug').val()) {
 | 
        
           |  |  | 950 |                 objFormGenerator.editOption(
 | 
        
           |  |  | 951 |                     $('#form-option #option-section').val(),
 | 
        
           |  |  | 952 |                     $('#form-option #option-question').val(),
 | 
        
           |  |  | 953 |                     $('#form-option #option-slug').val(),
 | 
        
           | 6276 | eleazar | 954 |                     $('#form-option #option-text').val()
 | 
        
           | 4384 | eleazar | 955 |                 );
 | 
        
           |  |  | 956 |             } else {
 | 
        
           |  |  | 957 |                 objFormGenerator.addOption(
 | 
        
           |  |  | 958 |                     $('#form-option #option-section').val(),
 | 
        
           |  |  | 959 |                     $('#form-option #option-question').val(),
 | 
        
           | 6276 | eleazar | 960 |                     $('#form-option #option-text').val()
 | 
        
           | 4384 | eleazar | 961 |                 );
 | 
        
           |  |  | 962 |             }
 | 
        
           |  |  | 963 |             renderSectionData(objFormGenerator.sections);
 | 
        
           |  |  | 964 |             $('#modal-option').modal('hide');
 | 
        
           |  |  | 965 |             return false;
 | 
        
           |  |  | 966 |         }
 | 
        
           |  |  | 967 |     });
 | 
        
           |  |  | 968 |     /**
 | 
        
           |  |  | 969 |      * Clicked on add new section
 | 
        
           |  |  | 970 |      */
 | 
        
           |  |  | 971 |     $('body').on('click', 'button[id="btn-add-section"]', function(e) {
 | 
        
           |  |  | 972 |         e.preventDefault();
 | 
        
           |  |  | 973 |         validatorFormSection.resetForm();
 | 
        
           |  |  | 974 |         $('#form-section #section-slug').val('');
 | 
        
           |  |  | 975 |         $('#form-section #section-name').val('');
 | 
        
           | 8989 | stevensc | 976 |         CKEDITOR.replace('section').val('');
 | 
        
           | 4384 | eleazar | 977 |         $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
 | 
        
           |  |  | 978 |         $('#modal-section').modal('show');
 | 
        
           |  |  | 979 |     });
 | 
        
           |  |  | 980 |     /**
 | 
        
           |  |  | 981 |      * Clicked on edit section
 | 
        
           |  |  | 982 |      */
 | 
        
           |  |  | 983 |     $('body').on('click', 'button.btn-edit-section', function(e) {
 | 
        
           |  |  | 984 |         e.preventDefault();
 | 
        
           |  |  | 985 |         var slug = $(this).data('section');
 | 
        
           |  |  | 986 |         var section;
 | 
        
           |  |  | 987 |         var showForm = false;
 | 
        
           |  |  | 988 |         for (i = 0; i < objFormGenerator.sections.length; i++) {
 | 
        
           |  |  | 989 |             section = objFormGenerator.sections[i];
 | 
        
           |  |  | 990 |             if (slug == section.slug_section) {
 | 
        
           |  |  | 991 |                 validatorFormSection.resetForm();
 | 
        
           |  |  | 992 |                 $('#form-section #section-slug').val(section.slug_section);
 | 
        
           |  |  | 993 |                 $('#form-section #section-name').val(section.name);
 | 
        
           | 8988 | stevensc | 994 |                 CKEDITOR.instances.section.setData(section.text);
 | 
        
           | 4384 | eleazar | 995 |                 showForm = true;
 | 
        
           |  |  | 996 |                 break;
 | 
        
           |  |  | 997 |             }
 | 
        
           |  |  | 998 |         }
 | 
        
           |  |  | 999 |         if (showForm) {
 | 
        
           |  |  | 1000 |             $('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
 | 
        
           |  |  | 1001 |             $('#modal-section').modal('show');
 | 
        
           |  |  | 1002 |         }
 | 
        
           |  |  | 1003 |     });
 | 
        
           |  |  | 1004 |     /**
 | 
        
           |  |  | 1005 |      * Clicked on remove section
 | 
        
           |  |  | 1006 |      */
 | 
        
           |  |  | 1007 |     $('body').on('click', 'button.btn-delete-section', function(e) {
 | 
        
           |  |  | 1008 |         e.preventDefault();
 | 
        
           |  |  | 1009 |         var slug = $(this).data('section');
 | 
        
           |  |  | 1010 |         bootbox.confirm({
 | 
        
           |  |  | 1011 |             title: "LABEL_DELETE LABEL_SECTION",
 | 
        
           |  |  | 1012 |             message: "LABEL_QUESTION_DELETE",
 | 
        
           |  |  | 1013 |             buttons: {
 | 
        
           |  |  | 1014 |                 cancel: {
 | 
        
           |  |  | 1015 |                     label: '<i class="fa fa-times"></i> LABEL_CANCEL'
 | 
        
           |  |  | 1016 |                 },
 | 
        
           |  |  | 1017 |                 confirm: {
 | 
        
           |  |  | 1018 |                     label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
 | 
        
           |  |  | 1019 |                 }
 | 
        
           |  |  | 1020 |             },
 | 
        
           |  |  | 1021 |             callback: function(result) {
 | 
        
           |  |  | 1022 |                 if (result) {
 | 
        
           |  |  | 1023 |                     objFormGenerator.deleteSection(slug);
 | 
        
           |  |  | 1024 |                     renderSectionData(objFormGenerator.sections);
 | 
        
           |  |  | 1025 |                 }
 | 
        
           |  |  | 1026 |             }
 | 
        
           |  |  | 1027 |         });
 | 
        
           |  |  | 1028 |     });
 | 
        
           |  |  | 1029 |     /**
 | 
        
           |  |  | 1030 |      * Clicked add new question
 | 
        
           |  |  | 1031 |      */
 | 
        
           |  |  | 1032 |     $('body').on('click', 'button.btn-add-question', function(e) {
 | 
        
           |  |  | 1033 |         e.preventDefault();
 | 
        
           |  |  | 1034 |         validatorFormQuestion.resetForm();
 | 
        
           |  |  | 1035 |         var slug = $(this).data('section');
 | 
        
           |  |  | 1036 |         $('#form-question #question-section').val(slug);
 | 
        
           |  |  | 1037 |         $('#form-question #question-slug').val('');
 | 
        
           |  |  | 1038 |         CKEDITOR.instances['question-text'].setData('');
 | 
        
           |  |  | 1039 |         $('#form-question #question-type').val($('#form-question #question-type option:first').val());
 | 
        
           |  |  | 1040 |         $('#form-question #question-max-length').val('0');
 | 
        
           |  |  | 1041 |         $('#form-question #question-max-length').parent().show();
 | 
        
           |  |  | 1042 |         $('#form-question #question-multiline').val('0');
 | 
        
           |  |  | 1043 |         $('#form-question #question-multiline').parent().show();
 | 
        
           | 6467 | eleazar | 1044 |         $('#form-question #question-range').val('10');
 | 
        
           |  |  | 1045 |         $('#form-question #question-range').parent().hide();
 | 
        
           | 4384 | eleazar | 1046 |         $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
 | 
        
           |  |  | 1047 |         $('#modal-question').modal('show');
 | 
        
           |  |  | 1048 |     });
 | 
        
           |  |  | 1049 |     /**
 | 
        
           |  |  | 1050 |      * Clicked edit question
 | 
        
           |  |  | 1051 |      */
 | 
        
           |  |  | 1052 |     $('body').on('click', 'button.btn-edit-question', function(e) {
 | 
        
           |  |  | 1053 |         e.preventDefault();
 | 
        
           |  |  | 1054 |         var slug_section = $(this).data('section');
 | 
        
           |  |  | 1055 |         var slug = $(this).data('question');
 | 
        
           |  |  | 1056 |         var showForm = false;
 | 
        
           |  |  | 1057 |         for (i = 0; i < objFormGenerator.sections.length; i++) {
 | 
        
           |  |  | 1058 |             if (slug_section == objFormGenerator.sections[i].slug_section) {
 | 
        
           |  |  | 1059 |                 for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
 | 
        
           |  |  | 1060 |                     if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
 | 
        
           |  |  | 1061 |                         validatorFormQuestion.resetForm();
 | 
        
           |  |  | 1062 |                         $('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
 | 
        
           |  |  | 1063 |                         $('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
 | 
        
           |  |  | 1064 |                         CKEDITOR.instances['question-text'].setData(objFormGenerator.sections[i].questions[j].text);
 | 
        
           |  |  | 1065 |                         $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
 | 
        
           |  |  | 1066 |                         if (objFormGenerator.sections[i].questions[j].type == 'open') {
 | 
        
           |  |  | 1067 |                             $('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
 | 
        
           |  |  | 1068 |                             $('#form-question #question-max-length').parent().show();
 | 
        
           |  |  | 1069 |                             $('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
 | 
        
           |  |  | 1070 |                             $('#form-question #question-multiline').parent().show();
 | 
        
           |  |  | 1071 |                         } else {
 | 
        
           |  |  | 1072 |                             $('#form-question #question-max-length').val('0');
 | 
        
           |  |  | 1073 |                             $('#form-question #question-max-length').parent().hide();
 | 
        
           |  |  | 1074 |                             $('#form-question #question-multiline').val('0');
 | 
        
           |  |  | 1075 |                             $('#form-question #question-multiline').parent().hide();
 | 
        
           |  |  | 1076 |                         }
 | 
        
           | 6467 | eleazar | 1077 |                         if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
 | 
        
           |  |  | 1078 |                             $('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
 | 
        
           |  |  | 1079 |                             $('#form-question #question-range').parent().show();
 | 
        
           |  |  | 1080 |                         } else {
 | 
        
           |  |  | 1081 |                             $('#form-question #question-range').val('10');
 | 
        
           |  |  | 1082 |                             $('#form-question #question-range').parent().hide();
 | 
        
           |  |  | 1083 |                         }
 | 
        
           | 4384 | eleazar | 1084 |                         showForm = true;
 | 
        
           |  |  | 1085 |                         break;
 | 
        
           |  |  | 1086 |                     }
 | 
        
           |  |  | 1087 |                 }
 | 
        
           |  |  | 1088 |                 break;
 | 
        
           |  |  | 1089 |             }
 | 
        
           |  |  | 1090 |         }
 | 
        
           |  |  | 1091 |         if (showForm) {
 | 
        
           |  |  | 1092 |             $('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
 | 
        
           |  |  | 1093 |             $('#modal-question').modal('show');
 | 
        
           |  |  | 1094 |         }
 | 
        
           |  |  | 1095 |     });
 | 
        
           |  |  | 1096 |     /**
 | 
        
           |  |  | 1097 |      * Clicked remove question
 | 
        
           |  |  | 1098 |      */
 | 
        
           |  |  | 1099 |     $('body').on('click', 'button.btn-delete-question', function(e) {
 | 
        
           |  |  | 1100 |         e.preventDefault();
 | 
        
           |  |  | 1101 |         var slug_section = $(this).data('section');
 | 
        
           |  |  | 1102 |         var slug = $(this).data('question');
 | 
        
           |  |  | 1103 |         bootbox.confirm({
 | 
        
           |  |  | 1104 |             title: "LABEL_DELETE LABEL_QUESTION",
 | 
        
           |  |  | 1105 |             message: "LABEL_QUESTION_DELETE",
 | 
        
           |  |  | 1106 |             buttons: {
 | 
        
           |  |  | 1107 |                 cancel: {
 | 
        
           |  |  | 1108 |                     label: '<i class="fa fa-times"></i> LABEL_CANCEL'
 | 
        
           |  |  | 1109 |                 },
 | 
        
           |  |  | 1110 |                 confirm: {
 | 
        
           |  |  | 1111 |                     label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
 | 
        
           |  |  | 1112 |                 }
 | 
        
           |  |  | 1113 |             },
 | 
        
           |  |  | 1114 |             callback: function(result) {
 | 
        
           |  |  | 1115 |                 if (result) {
 | 
        
           |  |  | 1116 |                     objFormGenerator.deleteQuestion(slug_section, slug);
 | 
        
           |  |  | 1117 |                     renderSectionData(objFormGenerator.sections);
 | 
        
           |  |  | 1118 |                 }
 | 
        
           |  |  | 1119 |             }
 | 
        
           |  |  | 1120 |         });
 | 
        
           |  |  | 1121 |     });
 | 
        
           |  |  | 1122 |     /**
 | 
        
           |  |  | 1123 |      * Clicked add new Option
 | 
        
           |  |  | 1124 |      */
 | 
        
           |  |  | 1125 |     $('body').on('click', 'button.btn-add-option', function(e) {
 | 
        
           |  |  | 1126 |         e.preventDefault();
 | 
        
           |  |  | 1127 |         var slug_section = $(this).data('section');
 | 
        
           |  |  | 1128 |         var slug_question = $(this).data('question');
 | 
        
           |  |  | 1129 |         var showForm = false;
 | 
        
           |  |  | 1130 |         for (i = 0; i < objFormGenerator.sections.length; i++) {
 | 
        
           |  |  | 1131 |             if (slug_section == objFormGenerator.sections[i].slug_section) {
 | 
        
           |  |  | 1132 |                 for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
 | 
        
           |  |  | 1133 |                     if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
 | 
        
           |  |  | 1134 |                         validatorFormOption.resetForm();
 | 
        
           |  |  | 1135 |                         $('#form-option #option-section').val(slug_section);
 | 
        
           |  |  | 1136 |                         $('#form-option #option-question').val(slug_question);
 | 
        
           |  |  | 1137 |                         $('#form-option #option-slug').val('');
 | 
        
           |  |  | 1138 |                         CKEDITOR.instances['option-text'].setData('', function() {
 | 
        
           |  |  | 1139 |                             editor.focus();
 | 
        
           |  |  | 1140 |                         });
 | 
        
           | 6276 | eleazar | 1141 |   | 
        
           | 4384 | eleazar | 1142 |                         renderSectionData(objFormGenerator.sections);
 | 
        
           |  |  | 1143 |                         $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
 | 
        
           |  |  | 1144 |                         $('#modal-option').modal('show');
 | 
        
           |  |  | 1145 |                         return true;
 | 
        
           |  |  | 1146 |                     }
 | 
        
           |  |  | 1147 |                 }
 | 
        
           |  |  | 1148 |             }
 | 
        
           |  |  | 1149 |         }
 | 
        
           |  |  | 1150 |     });
 | 
        
           |  |  | 1151 |     /**
 | 
        
           |  |  | 1152 |      * Clicked edit option
 | 
        
           |  |  | 1153 |      */
 | 
        
           |  |  | 1154 |     $('body').on('click', 'button.btn-edit-option', function(e) {
 | 
        
           |  |  | 1155 |         e.preventDefault();
 | 
        
           |  |  | 1156 |         var slug_section = $(this).data('section');
 | 
        
           |  |  | 1157 |         var slug_question = $(this).data('question');
 | 
        
           |  |  | 1158 |         var slug = $(this).data('slug');
 | 
        
           |  |  | 1159 |         var showForm = false;
 | 
        
           |  |  | 1160 |         for (i = 0; i < objFormGenerator.sections.length; i++) {
 | 
        
           |  |  | 1161 |             if (slug_section == objFormGenerator.sections[i].slug_section) {
 | 
        
           |  |  | 1162 |                 for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
 | 
        
           |  |  | 1163 |                     if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
 | 
        
           |  |  | 1164 |                         for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
 | 
        
           |  |  | 1165 |                             if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
 | 
        
           |  |  | 1166 |                                 validatorFormOption.resetForm();
 | 
        
           |  |  | 1167 |                                 $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
 | 
        
           |  |  | 1168 |                                 $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
 | 
        
           |  |  | 1169 |                                 $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
 | 
        
           |  |  | 1170 |                                 CKEDITOR.instances['option-text'].setData(objFormGenerator.sections[i].questions[j].options[k].text,
 | 
        
           |  |  | 1171 |                                     function() {
 | 
        
           |  |  | 1172 |                                         editor.focus();
 | 
        
           |  |  | 1173 |                                     });
 | 
        
           |  |  | 1174 |                                 showForm = true;
 | 
        
           |  |  | 1175 |                                 break;
 | 
        
           |  |  | 1176 |                             }
 | 
        
           |  |  | 1177 |                         }
 | 
        
           |  |  | 1178 |                     }
 | 
        
           |  |  | 1179 |                     if (showForm) {
 | 
        
           |  |  | 1180 |                         break;
 | 
        
           |  |  | 1181 |                     }
 | 
        
           |  |  | 1182 |                 }
 | 
        
           |  |  | 1183 |             }
 | 
        
           |  |  | 1184 |             if (showForm) {
 | 
        
           |  |  | 1185 |                 break;
 | 
        
           |  |  | 1186 |             }
 | 
        
           |  |  | 1187 |         }
 | 
        
           |  |  | 1188 |         if (showForm) {
 | 
        
           |  |  | 1189 |             $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
 | 
        
           |  |  | 1190 |             $('#modal-option').modal('show');
 | 
        
           |  |  | 1191 |         }
 | 
        
           |  |  | 1192 |     });
 | 
        
           |  |  | 1193 |     /**
 | 
        
           |  |  | 1194 |      * Clicked remove option
 | 
        
           |  |  | 1195 |      */
 | 
        
           |  |  | 1196 |     $('body').on('click', 'button.btn-delete-option', function(e) {
 | 
        
           |  |  | 1197 |         e.preventDefault();
 | 
        
           |  |  | 1198 |         var slug_section = $(this).data('section');
 | 
        
           |  |  | 1199 |         var slug_question = $(this).data('question');
 | 
        
           |  |  | 1200 |         var slug = $(this).data('slug');
 | 
        
           |  |  | 1201 |         bootbox.confirm({
 | 
        
           |  |  | 1202 |             title: "LABEL_DELETE LABEL_OPTION",
 | 
        
           |  |  | 1203 |             message: "LABEL_QUESTION_DELETE",
 | 
        
           |  |  | 1204 |             buttons: {
 | 
        
           |  |  | 1205 |                 cancel: {
 | 
        
           |  |  | 1206 |                     label: '<i class="fa fa-times"></i> LABEL_CANCEL'
 | 
        
           |  |  | 1207 |                 },
 | 
        
           |  |  | 1208 |                 confirm: {
 | 
        
           |  |  | 1209 |                     label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
 | 
        
           |  |  | 1210 |                 }
 | 
        
           |  |  | 1211 |             },
 | 
        
           |  |  | 1212 |             callback: function(result) {
 | 
        
           |  |  | 1213 |                 if (result) {
 | 
        
           |  |  | 1214 |                     objFormGenerator.deleteOption(slug_section, slug_question, slug);
 | 
        
           |  |  | 1215 |                     renderSectionData(objFormGenerator.sections);
 | 
        
           |  |  | 1216 |                 }
 | 
        
           |  |  | 1217 |             }
 | 
        
           |  |  | 1218 |         });
 | 
        
           |  |  | 1219 |     })
 | 
        
           | 4546 | eleazar | 1220 |   | 
        
           | 4384 | eleazar | 1221 |     /**
 | 
        
           |  |  | 1222 |      * Format input number (Form Question)
 | 
        
           |  |  | 1223 |      */
 | 
        
           |  |  | 1224 |     $('#form-question #question-max-length').inputNumberFormat({
 | 
        
           |  |  | 1225 |         'decimal': 0
 | 
        
           |  |  | 1226 |     });
 | 
        
           |  |  | 1227 |     /**
 | 
        
           |  |  | 1228 |      * Detect when updating question status and hide/Show options
 | 
        
           |  |  | 1229 |      */
 | 
        
           |  |  | 1230 |     $('#form-question #question-type').change(function(e) {
 | 
        
           |  |  | 1231 |         e.preventDefault();
 | 
        
           |  |  | 1232 |         if ($('#form-question #question-type').val() == 'open') {
 | 
        
           |  |  | 1233 |             $('#form-question #question-max-length').parent().show();
 | 
        
           |  |  | 1234 |             $('#form-question #question-multiline').parent().show();
 | 
        
           |  |  | 1235 |         } else {
 | 
        
           |  |  | 1236 |             $('#form-question #question-max-length').val('0');
 | 
        
           |  |  | 1237 |             $('#form-question #question-max-length').parent().hide();
 | 
        
           |  |  | 1238 |             $('#form-question #question-multiline').val('0');
 | 
        
           |  |  | 1239 |             $('#form-question #question-multiline').parent().hide();
 | 
        
           |  |  | 1240 |         }
 | 
        
           | 6467 | eleazar | 1241 |         $('#form-question #question-range').val('10');
 | 
        
           |  |  | 1242 |         if ($('#form-question #question-type').val() == 'rating-range') {
 | 
        
           |  |  | 1243 |             $('#form-question #question-range').parent().show();
 | 
        
           |  |  | 1244 |         } else {
 | 
        
           |  |  | 1245 |             $('#form-question #question-range').parent().hide();
 | 
        
           |  |  | 1246 |         }
 | 
        
           | 4384 | eleazar | 1247 |     });
 | 
        
           |  |  | 1248 |     /**
 | 
        
           |  |  | 1249 |      * Clicked new Form
 | 
        
           |  |  | 1250 |      */
 | 
        
           |  |  | 1251 |     $('button.btn-add-form').click(function(e) {
 | 
        
           |  |  | 1252 |         e.preventDefault();
 | 
        
           |  |  | 1253 |         objFormGenerator.clear();
 | 
        
           |  |  | 1254 |         objFormGenerator.render();
 | 
        
           |  |  | 1255 |         validatorForm.resetForm();
 | 
        
           |  |  | 1256 |         clearSectionData();
 | 
        
           |  |  | 1257 |         $('#form-main').attr('action', '$routeAdd');
 | 
        
           |  |  | 1258 |         $('#form-main #form-continue').val('0');
 | 
        
           | 4459 | eleazar | 1259 |         $('#form-main #name').val('');
 | 
        
           |  |  | 1260 |         $('#form-main #status').val('$status_inactive');
 | 
        
           | 4466 | eleazar | 1261 |         CKEDITOR.instances.text.setData('');
 | 
        
           |  |  | 1262 |         CKEDITOR.instances.description.setData('');
 | 
        
           | 4384 | eleazar | 1263 |         $('#row-forms').hide();
 | 
        
           |  |  | 1264 |         $('#row-edit').show();
 | 
        
           | 4459 | eleazar | 1265 |         $('#form-main #name').focus();
 | 
        
           | 4384 | eleazar | 1266 |     });
 | 
        
           |  |  | 1267 |     /**
 | 
        
           |  |  | 1268 |      * Clicked cancel new/edit Form
 | 
        
           |  |  | 1269 |      */
 | 
        
           |  |  | 1270 |     $('button.btn-edit-cancel').click(function(e) {
 | 
        
           |  |  | 1271 |         e.preventDefault();
 | 
        
           |  |  | 1272 |         $('#row-edit').hide();
 | 
        
           |  |  | 1273 |         $('#row-forms').show();
 | 
        
           |  |  | 1274 |     });
 | 
        
           |  |  | 1275 |     /**
 | 
        
           |  |  | 1276 |      * Clicked save and continue new Form
 | 
        
           |  |  | 1277 |      */
 | 
        
           |  |  | 1278 |     $('button.btn-form-save-continue').click(function(e) {
 | 
        
           | 8365 | eleazar | 1279 |         e.preventDefault();
 | 
        
           |  |  | 1280 |         $('#form-main #form-continue').val('1')
 | 
        
           | 8366 | eleazar | 1281 |         $('#form-main').submit();
 | 
        
           | 4384 | eleazar | 1282 |     });
 | 
        
           |  |  | 1283 |     /**
 | 
        
           |  |  | 1284 |      * Clicked save and close new/edit Form
 | 
        
           |  |  | 1285 |      */
 | 
        
           |  |  | 1286 |     $('button.btn-form-save-close').click(function(e) {
 | 
        
           |  |  | 1287 |         e.preventDefault();
 | 
        
           |  |  | 1288 |         $('#form-main #form-continue').val('0')
 | 
        
           |  |  | 1289 |         $('#form-main').submit();
 | 
        
           |  |  | 1290 |     });
 | 
        
           | 8364 | eleazar | 1291 |   | 
        
           |  |  | 1292 |     const saveData = (action) => {
 | 
        
           |  |  | 1293 |   | 
        
           |  |  | 1294 |             $.ajax({
 | 
        
           |  |  | 1295 |                 'dataType': 'json',
 | 
        
           |  |  | 1296 |                 'method': 'post',
 | 
        
           |  |  | 1297 |                 'url': $('#form-main').attr('action'),
 | 
        
           |  |  | 1298 |                 'data': {
 | 
        
           |  |  | 1299 |                     'name': $('#form-main #form-name').val(),
 | 
        
           |  |  | 1300 |   | 
        
           |  |  | 1301 |                     'status': $('#form-main #form-status').val(),
 | 
        
           |  |  | 1302 |                     'description': $('#form-main #form-description').val(),
 | 
        
           |  |  | 1303 |                     'content': JSON.stringify(sections)
 | 
        
           |  |  | 1304 |                 },
 | 
        
           |  |  | 1305 |             }).done(function(response) {
 | 
        
           |  |  | 1306 |                 if (response['success']) {
 | 
        
           |  |  | 1307 |                     $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 1308 |                     if (action == 1) {
 | 
        
           |  |  | 1309 |                         $('#form-main').attr('action', response['action_edit']);
 | 
        
           |  |  | 1310 |                     } else {
 | 
        
           |  |  | 1311 |                         $('#row-form').hide();
 | 
        
           |  |  | 1312 |                         $('#row-lists').show();
 | 
        
           |  |  | 1313 |                         /*---------- Reset Form -------- */
 | 
        
           |  |  | 1314 |                         $('#form-main')[0].reset();
 | 
        
           |  |  | 1315 |                         /*--------Reset Sections ----------*/
 | 
        
           |  |  | 1316 |                         sections = [];
 | 
        
           |  |  | 1317 |                         tableForm.fnDraw();
 | 
        
           |  |  | 1318 |                     }
 | 
        
           |  |  | 1319 |                     return;
 | 
        
           |  |  | 1320 |                 } else {
 | 
        
           |  |  | 1321 |                     $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
 | 
        
           |  |  | 1322 |                     return;
 | 
        
           |  |  | 1323 |                 }
 | 
        
           |  |  | 1324 |             });
 | 
        
           |  |  | 1325 |   | 
        
           |  |  | 1326 |     }
 | 
        
           |  |  | 1327 |   | 
        
           | 4384 | eleazar | 1328 |     /**
 | 
        
           |  |  | 1329 |      * Modal Settings
 | 
        
           |  |  | 1330 |      */
 | 
        
           |  |  | 1331 |     $('#modal-section, #modal-question, #modal-option').modal({
 | 
        
           |  |  | 1332 |         backdrop: 'static',
 | 
        
           |  |  | 1333 |         keyboard: false,
 | 
        
           |  |  | 1334 |         show: false
 | 
        
           |  |  | 1335 |     });
 | 
        
           |  |  | 1336 |     /**
 | 
        
           |  |  | 1337 |      * Get Question type
 | 
        
           |  |  | 1338 |      */
 | 
        
           |  |  | 1339 |     const getQuestionTypeBySlug = (slug_section, slug_question) => {
 | 
        
           |  |  | 1340 |         for (i = 0; i < objFormGenerator.sections.length; i++) {
 | 
        
           |  |  | 1341 |             if (slug_section == objFormGenerator.sections[i].slug_section) {
 | 
        
           |  |  | 1342 |                 for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
 | 
        
           |  |  | 1343 |                     if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
 | 
        
           |  |  | 1344 |                         return objFormGenerator.sections[i].questions[j].type;
 | 
        
           |  |  | 1345 |                     }
 | 
        
           |  |  | 1346 |                 }
 | 
        
           |  |  | 1347 |             }
 | 
        
           |  |  | 1348 |         }
 | 
        
           |  |  | 1349 |     }
 | 
        
           |  |  | 1350 |     /**
 | 
        
           |  |  | 1351 |      * Remove Html Tags
 | 
        
           |  |  | 1352 |      */
 | 
        
           |  |  | 1353 |     const removeTags = (str) => str.toString().replace( /(<([^>]+)>)/ig, '')
 | 
        
           |  |  | 1354 |     /**
 | 
        
           |  |  | 1355 |      * Render Sections data
 | 
        
           |  |  | 1356 |      */
 | 
        
           |  |  | 1357 |     const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
 | 
        
           |  |  | 1358 |         getType: getQuestionTypeBySlug,
 | 
        
           |  |  | 1359 |         removeTags: removeTags
 | 
        
           |  |  | 1360 |     }));
 | 
        
           |  |  | 1361 |   | 
        
           |  |  | 1362 |   | 
        
           |  |  | 1363 |     /**
 | 
        
           |  |  | 1364 |      * Clear Div Section data
 | 
        
           |  |  | 1365 |      */
 | 
        
           |  |  | 1366 |     const clearSectionData = () => $("#rows").html('');
 | 
        
           |  |  | 1367 |     /**
 | 
        
           |  |  | 1368 |      * Clicked refresh button
 | 
        
           |  |  | 1369 |      */
 | 
        
           |  |  | 1370 |     $('button.btn-refresh').click(function(e) {
 | 
        
           |  |  | 1371 |         tableForm.fnDraw();
 | 
        
           |  |  | 1372 |     });
 | 
        
           | 4466 | eleazar | 1373 |   | 
        
           | 8987 | stevensc | 1374 |   | 
        
           |  |  | 1375 |     const config = {
 | 
        
           | 8967 | stevensc | 1376 |         toolbar: [
 | 
        
           |  |  | 1377 |                     { name: 'editing', items: ['Scayt'] },
 | 
        
           |  |  | 1378 |                     { name: 'links', items: ['Link', 'Unlink'] },
 | 
        
           |  |  | 1379 |                     { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
 | 
        
           |  |  | 1380 |                     { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
 | 
        
           |  |  | 1381 |                     '/',
 | 
        
           |  |  | 1382 |                     { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
 | 
        
           |  |  | 1383 |                     { name: 'styles', items: ['Styles', 'Format'] },
 | 
        
           |  |  | 1384 |                     { name: 'tools', items: ['Maximize'] }
 | 
        
           |  |  | 1385 |                 ],
 | 
        
           |  |  | 1386 |                 removePlugins: 'elementspath,Anchor',
 | 
        
           |  |  | 1387 |                 heigth: 100
 | 
        
           | 8987 | stevensc | 1388 |     }
 | 
        
           |  |  | 1389 |   | 
        
           | 8988 | stevensc | 1390 |     CKEDITOR.replace('section', config);
 | 
        
           | 8987 | stevensc | 1391 |     CKEDITOR.replace('description', config);
 | 
        
           |  |  | 1392 |     CKEDITOR.replace('text', config);
 | 
        
           | 4384 | eleazar | 1393 |   | 
        
           |  |  | 1394 | });
 | 
        
           |  |  | 1395 | JS;
 | 
        
           |  |  | 1396 | $this->inlineScript()->captureEnd();
 | 
        
           |  |  | 1397 | ?>
 | 
        
           |  |  | 1398 |   | 
        
           |  |  | 1399 | <!-- Content Header (Page header) -->
 | 
        
           |  |  | 1400 | <section class="content-header">
 | 
        
           |  |  | 1401 |     <div class="container-fluid">
 | 
        
           |  |  | 1402 |         <div class="row mb-2">
 | 
        
           |  |  | 1403 |             <div class="col-sm-12">
 | 
        
           |  |  | 1404 |                 <h1>LABEL_SELF_EVALUATION_FORMS</h1>
 | 
        
           |  |  | 1405 |             </div>
 | 
        
           |  |  | 1406 |         </div>
 | 
        
           |  |  | 1407 |     </div>
 | 
        
           |  |  | 1408 |     <!-- /.container-fluid -->
 | 
        
           |  |  | 1409 | </section>
 | 
        
           |  |  | 1410 | <section class="content">
 | 
        
           |  |  | 1411 |     <div class="container-fluid" id="row-forms">
 | 
        
           |  |  | 1412 |         <div class="row">
 | 
        
           |  |  | 1413 |             <div class="col-12">
 | 
        
           |  |  | 1414 |                 <div class="card">
 | 
        
           |  |  | 1415 |                     <div class="card-body">
 | 
        
           |  |  | 1416 |                         <table id="gridTable" class="table   table-hover">
 | 
        
           |  |  | 1417 |                             <thead>
 | 
        
           |  |  | 1418 |                                 <tr>
 | 
        
           |  |  | 1419 |                                     <th>LABEL_NAME</th>
 | 
        
           |  |  | 1420 |                                     <th>LABEL_ACTIVE</th>
 | 
        
           |  |  | 1421 |                                     <th>LABEL_ACTIONS</th>
 | 
        
           |  |  | 1422 |                                 </tr>
 | 
        
           |  |  | 1423 |                             </thead>
 | 
        
           |  |  | 1424 |                             <tbody></tbody>
 | 
        
           |  |  | 1425 |                         </table>
 | 
        
           |  |  | 1426 |                     </div>
 | 
        
           |  |  | 1427 |                     <div class="card-footer clearfix">
 | 
        
           |  |  | 1428 |                         <div style="float:right;">
 | 
        
           |  |  | 1429 |                             <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
 | 
        
           |  |  | 1430 |                             <?php if ($allowAdd) : ?>
 | 
        
           |  |  | 1431 |                                 <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
 | 
        
           |  |  | 1432 |                             <?php endif; ?>
 | 
        
           |  |  | 1433 |                         </div>
 | 
        
           |  |  | 1434 |                     </div>
 | 
        
           |  |  | 1435 |                 </div>
 | 
        
           |  |  | 1436 |             </div>
 | 
        
           |  |  | 1437 |         </div>
 | 
        
           |  |  | 1438 |     </div>
 | 
        
           |  |  | 1439 |   | 
        
           |  |  | 1440 |     <!-- Create/Edit Form -->
 | 
        
           |  |  | 1441 |   | 
        
           |  |  | 1442 |     <div class="row" id="row-edit" style="display: none">
 | 
        
           |  |  | 1443 |         <div class="col-xs-12 col-md-12">
 | 
        
           |  |  | 1444 |             <form action="#" name="form-main" id="form-main">
 | 
        
           |  |  | 1445 |                 <input type="hidden" name="form-id" id="form-id" value="0" />
 | 
        
           |  |  | 1446 |                 <input type="hidden" name="form-continue" id="form-continue" value="0" />
 | 
        
           | 4450 | eleazar | 1447 |                 <?php
 | 
        
           |  |  | 1448 |                      //$form = $this->formAdd;
 | 
        
           |  |  | 1449 |                      $form->setAttributes([
 | 
        
           |  |  | 1450 |                          'method' => 'post',
 | 
        
           |  |  | 1451 |                          'name' => 'form-main',
 | 
        
           |  |  | 1452 |                          'action' => $routeAdd,
 | 
        
           |  |  | 1453 |                          'id' => 'form-main'
 | 
        
           |  |  | 1454 |                      ]);
 | 
        
           |  |  | 1455 |                      $form->prepare();
 | 
        
           |  |  | 1456 |                      echo $this->form()->openTag($form);
 | 
        
           |  |  | 1457 |                 ?>
 | 
        
           |  |  | 1458 |                <div class="form-group">
 | 
        
           |  |  | 1459 |                     <?php
 | 
        
           |  |  | 1460 |                     $element = $form->get('name');
 | 
        
           |  |  | 1461 |                     $element->setOptions(['label' => 'LABEL_FIRST_NAME']);
 | 
        
           |  |  | 1462 |                     $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 1463 |                     echo $this->formLabel($element);
 | 
        
           |  |  | 1464 |                     echo $this->formText($element);
 | 
        
           |  |  | 1465 |                     ?>
 | 
        
           | 4384 | eleazar | 1466 |                 </div>
 | 
        
           |  |  | 1467 |                 <div class="form-group">
 | 
        
           | 4450 | eleazar | 1468 |                         <?php
 | 
        
           |  |  | 1469 |                         $element = $form->get('description');
 | 
        
           | 6269 | eleazar | 1470 |                         $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
 | 
        
           | 4450 | eleazar | 1471 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 1472 |                         echo $this->formLabel($element);
 | 
        
           | 4468 | eleazar | 1473 |                         echo $this->formTextArea($element);
 | 
        
           | 4450 | eleazar | 1474 |                         ?>
 | 
        
           | 4384 | eleazar | 1475 |                 </div>
 | 
        
           |  |  | 1476 |                 <div class="form-group">
 | 
        
           | 4450 | eleazar | 1477 |                         <?php
 | 
        
           |  |  | 1478 |                         $element = $form->get('text');
 | 
        
           |  |  | 1479 |                         $element->setOptions(['label' => 'LABEL_TEXT']);
 | 
        
           |  |  | 1480 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 1481 |                         echo $this->formLabel($element);
 | 
        
           | 4468 | eleazar | 1482 |                         echo $this->formTextArea($element);
 | 
        
           | 4450 | eleazar | 1483 |                         ?>
 | 
        
           | 4384 | eleazar | 1484 |                 </div>
 | 
        
           |  |  | 1485 |                 <div class="form-group">
 | 
        
           | 4450 | eleazar | 1486 |                         <?php
 | 
        
           |  |  | 1487 |                         $element = $form->get('status');
 | 
        
           |  |  | 1488 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 1489 |                         $element->setOptions(['label' => 'LABEL_STATUS']);
 | 
        
           |  |  | 1490 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 1491 |                         echo $this->formSelect($element);
 | 
        
           |  |  | 1492 |                         ?>
 | 
        
           |  |  | 1493 |                     </div>
 | 
        
           | 4384 | eleazar | 1494 |                 <br/>
 | 
        
           |  |  | 1495 |                 <div class="row">
 | 
        
           |  |  | 1496 |                     <div class="col-xs-12 col-md-12 text-right">
 | 
        
           |  |  | 1497 |                         <button class="btn btn-primary" id="btn-add-section" data-toggle="tooltip" title="LABEL_ADD LABEL_SECTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_SECTION</button>
 | 
        
           |  |  | 1498 |                     </div>
 | 
        
           |  |  | 1499 |                 </div>
 | 
        
           |  |  | 1500 |                 <br />
 | 
        
           |  |  | 1501 |                 <div class="row">
 | 
        
           |  |  | 1502 |                     <div class="col-xs-12 col-md-12">
 | 
        
           |  |  | 1503 |                         <div class="panel-group" id="rows"></div>
 | 
        
           |  |  | 1504 |                     </div>
 | 
        
           |  |  | 1505 |                 </div>
 | 
        
           |  |  | 1506 |                 <div class="form-group">
 | 
        
           |  |  | 1507 |                     <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
 | 
        
           |  |  | 1508 |                     <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
 | 
        
           |  |  | 1509 |                     <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
 | 
        
           |  |  | 1510 |                 </div>
 | 
        
           |  |  | 1511 |             </form>
 | 
        
           |  |  | 1512 |         </div>
 | 
        
           |  |  | 1513 |     </div>
 | 
        
           |  |  | 1514 |   | 
        
           |  |  | 1515 |     <!-- Create/Edit Form-->
 | 
        
           |  |  | 1516 |   | 
        
           |  |  | 1517 |     <!-- Section Modal -->
 | 
        
           |  |  | 1518 |     <div  id="modal-section" class="modal" tabindex="-1" role="dialog">
 | 
        
           |  |  | 1519 |         <div class="modal-dialog modal-lg" role="document">
 | 
        
           |  |  | 1520 |             <form action="#" name="form-section" id="form-section">
 | 
        
           |  |  | 1521 |                 <input type="hidden" name="section-slug" id="section-slug" value="" />
 | 
        
           |  |  | 1522 |                 <div class="modal-content">
 | 
        
           |  |  | 1523 |                     <div class="modal-header">
 | 
        
           |  |  | 1524 |                         <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
 | 
        
           |  |  | 1525 |                         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
 | 
        
           |  |  | 1526 |                             <span aria-hidden="true">×</span>
 | 
        
           |  |  | 1527 |                         </button>
 | 
        
           |  |  | 1528 |                     </div>
 | 
        
           |  |  | 1529 |                     <div class="modal-body">
 | 
        
           |  |  | 1530 |                         <div class="form-group">
 | 
        
           |  |  | 1531 |                             <label for="section-name">LABEL_FIRST_NAME</label>
 | 
        
           |  |  | 1532 |                             <input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
 | 
        
           |  |  | 1533 |                         </div>
 | 
        
           |  |  | 1534 |                         <div class="form-group">
 | 
        
           | 8981 | stevensc | 1535 |                         <div class="form-group">
 | 
        
           | 8988 | stevensc | 1536 |                             <label for="section">LABEL_TEXT</label>
 | 
        
           | 8981 | stevensc | 1537 |                             <!--  ckeditor -->
 | 
        
           | 8988 | stevensc | 1538 |                             <textarea  name="section" id="section" rows="5" class="ckeditor form-control"></textarea>
 | 
        
           | 4384 | eleazar | 1539 |                         </div>
 | 
        
           |  |  | 1540 |                     </div>
 | 
        
           |  |  | 1541 |                     <div class="modal-footer">
 | 
        
           |  |  | 1542 |                         <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
 | 
        
           |  |  | 1543 |                         <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
 | 
        
           |  |  | 1544 |                     </div>
 | 
        
           |  |  | 1545 |                 </div>
 | 
        
           |  |  | 1546 |             </form>
 | 
        
           |  |  | 1547 |         </div>
 | 
        
           |  |  | 1548 |     </div>
 | 
        
           |  |  | 1549 |     <!-- End Modal Section -->
 | 
        
           |  |  | 1550 |   | 
        
           |  |  | 1551 |     <!-- Question Modal -->
 | 
        
           |  |  | 1552 |   | 
        
           |  |  | 1553 |     <div  id="modal-question" class="modal" tabindex="-1" role="dialog">
 | 
        
           |  |  | 1554 |         <div class="modal-dialog modal-lg" role="document">
 | 
        
           |  |  | 1555 |             <form action="#" name="form-question" id="form-question">
 | 
        
           |  |  | 1556 |                 <input type="hidden" name="question-section" id="question-section" />
 | 
        
           |  |  | 1557 |                 <input type="hidden" name="question-slug" id="question-slug" />
 | 
        
           |  |  | 1558 |                 <div class="modal-content">
 | 
        
           |  |  | 1559 |                     <div class="modal-header">
 | 
        
           |  |  | 1560 |                         <h4 class="modal-title">LABEL_ADD LABEL_QUESTION</h4>
 | 
        
           |  |  | 1561 |                         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
 | 
        
           |  |  | 1562 |                             <span aria-hidden="true">×</span>
 | 
        
           |  |  | 1563 |                         </button>
 | 
        
           |  |  | 1564 |                     </div>
 | 
        
           |  |  | 1565 |                     <div class="modal-body">
 | 
        
           |  |  | 1566 |                         <div class="form-group">
 | 
        
           |  |  | 1567 |                             <label for="question-text">LABEL_TEXT</label>
 | 
        
           |  |  | 1568 |                             <!--  ckeditor -->
 | 
        
           |  |  | 1569 |                             <textarea  name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
 | 
        
           |  |  | 1570 |                         </div>
 | 
        
           |  |  | 1571 |                         <div class="form-group">
 | 
        
           |  |  | 1572 |                             <label for="question-type">LABEL_TYPE</label>
 | 
        
           |  |  | 1573 |                             <select name="question-type" id="question-type" class="form-control">
 | 
        
           |  |  | 1574 |                                 <option value="open">LABEL_OPEN</option>
 | 
        
           |  |  | 1575 |                                 <option value="simple">Simple</option>
 | 
        
           |  |  | 1576 |                                 <option value="multiple">Multiple</option>
 | 
        
           | 6467 | eleazar | 1577 |   | 
        
           | 4384 | eleazar | 1578 |                             </select>
 | 
        
           |  |  | 1579 |                         </div>
 | 
        
           |  |  | 1580 |                         <div class="form-group">
 | 
        
           |  |  | 1581 |                             <label for="question-max-length">LABEL_MAXLENGTH</label>
 | 
        
           |  |  | 1582 |                             <input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
 | 
        
           |  |  | 1583 |                         </div>
 | 
        
           |  |  | 1584 |                         <div class="form-group">
 | 
        
           |  |  | 1585 |                             <label for="question-multiline">LABEL_MULTI_LINE</label>
 | 
        
           |  |  | 1586 |                             <select name="question-multiline" id="question-multiline" class="form-control">
 | 
        
           |  |  | 1587 |                                 <option value="1">LABEL_YES</option>
 | 
        
           |  |  | 1588 |                                 <option value="0">LABEL_NOT</option>
 | 
        
           |  |  | 1589 |                             </select>
 | 
        
           |  |  | 1590 |                         </div>
 | 
        
           | 6467 | eleazar | 1591 |                         <div class="form-group">
 | 
        
           |  |  | 1592 |                             <label for="question-range">LABEL_RANGE</label>
 | 
        
           |  |  | 1593 |                             <select name="question-range" id="question-range" class="form-control">
 | 
        
           |  |  | 1594 |                                 <option value="10">1-10</option>
 | 
        
           |  |  | 1595 |                                 <option value="6">1-6</option>
 | 
        
           |  |  | 1596 |                                 <option value="5">1-5</option>
 | 
        
           |  |  | 1597 |                             </select>
 | 
        
           |  |  | 1598 |                         </div>
 | 
        
           | 4384 | eleazar | 1599 |                     </div>
 | 
        
           |  |  | 1600 |                     <div class="modal-footer">
 | 
        
           |  |  | 1601 |                         <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
 | 
        
           |  |  | 1602 |                         <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
 | 
        
           |  |  | 1603 |                     </div>
 | 
        
           |  |  | 1604 |                 </div>
 | 
        
           |  |  | 1605 |             </form>
 | 
        
           |  |  | 1606 |         </div>
 | 
        
           |  |  | 1607 |     </div>
 | 
        
           |  |  | 1608 |   | 
        
           |  |  | 1609 |     <!-- End Modal Question -->
 | 
        
           |  |  | 1610 |   | 
        
           |  |  | 1611 |     <!-- Modal Options -->
 | 
        
           |  |  | 1612 |   | 
        
           |  |  | 1613 |     <div  id="modal-option" class="modal" tabindex="-1" role="dialog">
 | 
        
           |  |  | 1614 |         <div class="modal-dialog modal-lg" role="document">
 | 
        
           |  |  | 1615 |             <form action="#" name="form-option" id="form-option">
 | 
        
           |  |  | 1616 |                 <input type="hidden" name="option-section" id="option-section" value="" />
 | 
        
           |  |  | 1617 |                 <input type="hidden" name="option-question" id="option-question" value="" />
 | 
        
           |  |  | 1618 |                 <input type="hidden" name="option-slug" id="option-slug" value="" />
 | 
        
           |  |  | 1619 |                 <div class="modal-content">
 | 
        
           |  |  | 1620 |                     <div class="modal-header">
 | 
        
           |  |  | 1621 |                         <h4 class="modal-title">LABEL_OPTION</h4>
 | 
        
           |  |  | 1622 |                         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
 | 
        
           |  |  | 1623 |                             <span aria-hidden="true">×</span>
 | 
        
           |  |  | 1624 |                         </button>
 | 
        
           |  |  | 1625 |                     </div>
 | 
        
           |  |  | 1626 |                     <div class="modal-body">
 | 
        
           |  |  | 1627 |                         <div class="form-group">
 | 
        
           |  |  | 1628 |                             <label for="option-text">LABEL_TEXT</label>
 | 
        
           |  |  | 1629 |                             <!--  ckeditor -->
 | 
        
           |  |  | 1630 |                             <textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
 | 
        
           |  |  | 1631 |                         </div>
 | 
        
           |  |  | 1632 |                     </div>
 | 
        
           |  |  | 1633 |                     <div class="modal-footer">
 | 
        
           |  |  | 1634 |                         <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
 | 
        
           |  |  | 1635 |                         <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
 | 
        
           |  |  | 1636 |                     </div>
 | 
        
           |  |  | 1637 |                 </div>
 | 
        
           |  |  | 1638 |             </form>
 | 
        
           |  |  | 1639 |         </div>
 | 
        
           |  |  | 1640 |     </div>
 | 
        
           |  |  | 1641 |   | 
        
           |  |  | 1642 |     <!-- End Modal Options -->
 | 
        
           |  |  | 1643 |   | 
        
           |  |  | 1644 |     <!---Template Sections --->
 | 
        
           |  |  | 1645 |     <script id="sectionTemplate" type="text/x-jsrender">
 | 
        
           |  |  | 1646 |     <div class="panel panel-default" id="panel-{{:slug_section}}">
 | 
        
           |  |  | 1647 |         <div class="panel-heading">
 | 
        
           |  |  | 1648 |             <h4 class="panel-title">
 | 
        
           |  |  | 1649 |                 <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
 | 
        
           |  |  | 1650 |                     <span class="section-name{{:slug_section}}">
 | 
        
           |  |  | 1651 |                         {{:name}}
 | 
        
           |  |  | 1652 |                     </span>
 | 
        
           |  |  | 1653 |                 </a>
 | 
        
           |  |  | 1654 |             </h4>
 | 
        
           |  |  | 1655 |         </div>
 | 
        
           |  |  | 1656 |         <div id="collapse-{{:slug_section}}" class="panel-collapse in collapse show">
 | 
        
           |  |  | 1657 |             <div class="panel-body">
 | 
        
           |  |  | 1658 |                 <div class="table-responsive">
 | 
        
           |  |  | 1659 |                     <table class="table table-bordered">
 | 
        
           |  |  | 1660 |                         <thead>
 | 
        
           |  |  | 1661 |                             <tr>
 | 
        
           |  |  | 1662 |                                 <th style="width: 10%;">LABEL_ELEMENT</th>
 | 
        
           |  |  | 1663 |                                 <th style="width: 50%;">LABEL_TEXT</th>
 | 
        
           |  |  | 1664 |                                 <th style="width: 10%;">LABEL_TYPE</th>
 | 
        
           |  |  | 1665 |                                 <th style="width: 20%;">LABEL_ACTIONS</th>
 | 
        
           |  |  | 1666 |                             </tr>
 | 
        
           |  |  | 1667 |                         </thead>
 | 
        
           |  |  | 1668 |                         <tbody>
 | 
        
           |  |  | 1669 |                             <tr class="tr-section">
 | 
        
           |  |  | 1670 |                                 <td class="text-left">LABEL_SECTION</td>
 | 
        
           |  |  | 1671 |                                 <td class="text-left">{{:name}}</td>
 | 
        
           |  |  | 1672 |                                 <td></td>
 | 
        
           |  |  | 1673 |                                 <td>
 | 
        
           |  |  | 1674 |                                     <button class="btn btn-default btn-edit-section" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>
 | 
        
           |  |  | 1675 |                                     <button class="btn btn-default btn-delete-section" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button>
 | 
        
           |  |  | 1676 |                                     <button class="btn btn-default btn-add-question" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_QUESTION </button>
 | 
        
           |  |  | 1677 |                                 </td>
 | 
        
           |  |  | 1678 |                             </tr>
 | 
        
           |  |  | 1679 |                             {{for questions}}
 | 
        
           |  |  | 1680 |                             <tr class="tr-question">
 | 
        
           |  |  | 1681 |                                 <td class="text-left">--LABEL_QUESTION</td>
 | 
        
           |  |  | 1682 |                                 <td class="text-left">
 | 
        
           |  |  | 1683 |                                     {{:~removeTags(text)}}
 | 
        
           |  |  | 1684 |                                 </td>
 | 
        
           |  |  | 1685 |                                 <td class="text-capitalize">
 | 
        
           |  |  | 1686 |                                     {{if type == 'open'}} LABEL_OPEN {{/if}}
 | 
        
           |  |  | 1687 |                                     {{if type == 'simple'}} Simple {{/if}}
 | 
        
           |  |  | 1688 |                                     {{if type == 'multiple'}} Multiple {{/if}}
 | 
        
           |  |  | 1689 |                                 </td>
 | 
        
           |  |  | 1690 |                                 <td>
 | 
        
           |  |  | 1691 |                                     <button class="btn btn-default btn-edit-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_QUESTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_QUESTION</button>
 | 
        
           |  |  | 1692 |                                     <button class="btn btn-default btn-delete-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_QUESTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_QUESTION</button>
 | 
        
           |  |  | 1693 |   | 
        
           | 6467 | eleazar | 1694 |                                     {{if type == 'simple' || type == 'rating-open' || type=='multiple' }}
 | 
        
           | 4384 | eleazar | 1695 |                                     <button class="btn btn-default btn-add-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_OPTION</button>
 | 
        
           |  |  | 1696 |                                     {{/if}}
 | 
        
           |  |  | 1697 |   | 
        
           |  |  | 1698 |                                 </td>
 | 
        
           |  |  | 1699 |                             </tr>
 | 
        
           |  |  | 1700 |                             {{for options}}
 | 
        
           |  |  | 1701 |                             <tr class="tr-option">
 | 
        
           |  |  | 1702 |                                 <td class="text-left">---LABEL_OPTION</td>
 | 
        
           |  |  | 1703 |                                 <td class="text-left">
 | 
        
           |  |  | 1704 |                                     {{:~removeTags(text)}}
 | 
        
           |  |  | 1705 |                                 </td>
 | 
        
           |  |  | 1706 |                                 <td>
 | 
        
           |  |  | 1707 |   | 
        
           |  |  | 1708 |                                     {{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open'  }}
 | 
        
           |  |  | 1709 |                                     {{/if}}
 | 
        
           |  |  | 1710 |                                 </td>
 | 
        
           |  |  | 1711 |                                 <td>
 | 
        
           |  |  | 1712 |                                     <button class="btn btn-default btn-edit-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_OPTION</button>
 | 
        
           |  |  | 1713 |                                     <button class="btn btn-default btn-delete-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_OPTION</button>
 | 
        
           |  |  | 1714 |                                 </td>
 | 
        
           |  |  | 1715 |                             </tr>
 | 
        
           |  |  | 1716 |                             {{/for}}
 | 
        
           |  |  | 1717 |                             {{/for}}
 | 
        
           |  |  | 1718 |                         </tbody>
 | 
        
           |  |  | 1719 |                     </table>
 | 
        
           |  |  | 1720 |                 </div>
 | 
        
           |  |  | 1721 |             </div>
 | 
        
           |  |  | 1722 |         </div>
 | 
        
           |  |  | 1723 |     </div>
 | 
        
           |  |  | 1724 |     </script>
 | 
        
           |  |  | 1725 |   | 
        
           |  |  | 1726 |     <!-- End Template Sections-->
 | 
        
           |  |  | 1727 |   | 
        
           |  |  | 1728 | </section>
 |