1$(function(){ 2 init_forms(); 3 init_sub_form(); 4 5 function init_forms(){ 6 var $forms = $(".js-obx-forms-generator").each(function(){ 7 // Get labels 8 var labels_html = $(".js-obx-forms-generator-labels").html(); 9 var labels = JSON.parse(labels_html).reduce(function(result, current) { 10 result[current.original] = current.custom; 11 return result; 12 }, {}); 13 14 var uid = $(this).attr("data-form-uid") || ''; 15 var s_uid = $(this).attr("data-submission-uid") || ''; 16 var s_edit = $(this).attr("data-submission-edit") === "1"; 17 var s_data = $(this).attr("data-submission-data") || ''; 18 var options = { 19 readOnly: !!(+$(this).attr("data-form-readonly") || 0), 20 language: $(this).attr("data-form-language") || "de", 21 submission_edit_uid: s_edit && s_uid || '', 22 submission_data: s_data, 23 labels: labels 24 }; 25 _init_form(this, uid, s_uid, options); 26 }) 27 } 28 29 function _get_language(lang) { 30 lang = lang || 'en'; 31 if (["en","de",'fr', 'it'].indexOf(lang) === -1) { 32 lang = 'en'; 33 } 34 return lang; 35 } 36 37 function _patchDateTimeLocale(Formio, labels) { 38 var attach = Formio.Components.components.datetime.prototype.attach; 39 Formio.Components.components.datetime.prototype.attach = function (e) { 40 this.component.widget.locale = labels 41 this.component.widget.format = "dd.MM.yyyy"; 42 if (this.component.widget.enableTime){ 43 this.component.widget.format += " H:mm"; 44 } 45 return attach.call(this, e) 46 } 47 } 48 49 function _patchFileUrl(Formio, url, max_size){ 50 var attach = Formio.Components.components.file.prototype.attach; 51 Formio.Components.components.file.prototype.attach = function (e) { 52 if (this.component.storage === 'url') { 53 this.component.fileKey = "formio_files"; 54 // default one 55 if (+max_size && this.component.fileMaxSize === "1GB") { 56 this.component.fileMaxSize = max_size + "MB"; 57 } 58 this.component.url = url; 59 } 60 return attach.call(this, e) 61 } 62 } 63 64 65 function _init_form(div, uid, s_uid, options) { 66 var language = _get_language(options.language); 67 var max_size = $(div).attr("data-max-file-size"); 68 var base = document.location.origin + "/sysModules/obxFormsGenerator/public/ajax/ajax.cfm?form_uid=" + uid + "&language=" + language + "&temp_uid=" + +new Date(); 69 var upload_url = base + "&method=upload_files"; 70 71 _patchDateTimeLocale(Formio, _get_labels(language + "_calendar")); 72 _patchFileUrl(Formio, upload_url, max_size); 73 74 Formio.icons = 'fontawesome'; 75 //Formio.setProjectUrl('https://examples.test-form.io'); 76 77 var i18n = {}; 78 i18n[language] = Object.assign({}, _get_labels(language), options.labels) 79 Formio.createForm(div, base + "&method=config_get", { 80 readOnly: options.readOnly, 81 noAlerts: true, 82 componentErrorClass: "", 83 language: language, 84 i18n: i18n, 85 hooks: { 86 addComponent: function(component) { 87 if (component.type === "textarea" && component.editor === "ckeditor"){ 88 // remove Image Button from toolbar 89 var wysiwyg = component.wysiwyg || {}; 90 wysiwyg["removePlugins"] = ["ImageUpload"]; 91 component.wysiwyg = wysiwyg; 92 } 93 if (options.submission_edit_uid && component.type === "file"){ 94 // if it is edit mode and type:file - we force required=false 95 if (component.validate){ 96 component.validate.required = false; 97 } 98 } 99 return component; 100 } 101 } 102 }) 103 .then(function(form) { 104 // fetch submissions 105 if (!s_uid) { 106 return form; 107 } 108 return Formio.fetch(base + "&method=submission_get&submission_uid=" + s_uid, { 109 headers: { 110 'content-type': 'text/json;charset=utf-8' 111 }, 112 method: 'POST', 113 mode: 'cors' 114 }) 115 .then(function(response) { 116 return response.json().then(function(data) { 117 form.submission = { 118 data: data 119 } 120 return form; 121 }); 122 }); 123 }) 124 .then(function(form) { 125 // Add on submit event 126 if (options.readonly) { 127 return form; 128 } 129 130 form.nosubmit = true; 131 // Triggered when they click the submit button. 132 $(div).on("captcha", function(event, token){ 133 submit_form(form, token, options); 134 }) 135 form.on('submit', function() { 136 if (window.grecaptcha) { 137 grecaptcha.execute(); 138 } else { 139 submit_form(form, '', options); 140 } 141 }); 142 return form; 143 }); 144 145 function submit_form(form, token, options){ 146 var submission = form.submission; 147 Formio.fetch(base + "&method=submission_save", { 148 body: JSON.stringify({ 149 submission: submission.data, 150 captcha_token: token || "", 151 submission_edit_uid: options.submission_edit_uid, 152 submission_data: options.submission_data 153 }), 154 headers: { 155 'content-type': 'text/json;charset=utf-8' 156 }, 157 method: 'POST', 158 mode: 'cors' 159 }) 160 .then(function(response) { 161 response.json().then(function(result) { 162 if (result && result.status === "ERROR") { 163 alert(result.message || "Server Error"); 164 form.emit('submitError'); 165 return false; 166 } 167 form.emit('submitDone'); 168 var result_url = document.location.href 169 .replace(/(\?|&)s_uid=[\w\W]*?($|&)/gi, '$1$2') 170 .replace("submission_edit=true",'') 171 .replace(/\?&/, '?') 172 .replace(/&+/, '&') 173 .replace(/&$/, ''); 174 result_url += (result_url.indexOf("?") === -1 ? "?" : "&") + 'submission_done=true&s_uid=' + result.uid; 175 document.location.href = result_url; 176 }).catch(function(err) { 177 alert("Server Error"); 178 form.emit('submitError'); 179 console.error(err); 180 return false; 181 }); 182 }) 183 } 184 185 } 186 187 function _get_labels(lang){ 188 const labels = { 189 de: { 190 'File Name': 'Dateinamen', 191 'Size': 'GröÃe', 192 'Drop files to attach,': "Dateien für den Upload hierherziehen", 193 'or': 'oder', 194 'browse': 'Dateien auswählen', 195 'Edit': 'Bearbeiten', 196 'Preview': 'Vorschau', 197 'Save': 'Speichern', 198 'Cancel': 'Abbrechen', 199 'Remove': 'Entfernen', 200 'Close': 'SchlieÃen', 201 'Move': 'Verschieben',
202 'Copy': 'Kopieren', 203 'complete': 'Vorgang abgeschlossen', 204 'error' : "Bitte beheben Sie die folgenden Fehler vor dem Absenden.", 205 'invalid_date' :"{{field}} ist kein gültiges Datum.", 206 'invalid_email' : "{{field}} muss eine gültige E-Mail sein.", 207 'invalid_regex' : "{{field}} entspricht nicht der Regel {{regex}}.", 208 'mask' : "{{field}} passt nicht zur Maske.", 209 'max' : "{{field}} kann nicht gröÃer sein als {{max}}.", 210 'maxLength' : "{{field}} muss kürzer als {{length}} Zeichen sein.", 211 'min' : "{{field}} darf nicht kleiner als {{min}} sein.", 212 'minLength' : "{{field}} muss länger als {{length}} Zeichen sein.", 213 'next' : "Nächste", 214 'pattern' : "{{field}} entspricht nicht der Regel {{pattern}}", 215 'previous' : "Vorherige", 216 'required' : "{{field}} erforderlich", 217 'Month': "Monat", 218 'Day': "Tag", 219 'Year': "Jahr", 220 'January': "Januar", 221 'February': "Februar", 222 'March': "März", 223 'April': "April", 224 'May': "Mai", 225 'June': "Juni", 226 'July': "Juli", 227 'August': "August", 228 'September': "September", 229 'October': "Oktober", 230 'November': "November", 231 'December': "Dezember", 232 'Submit': "einreichen", 233 'submitError': "Bitte überprüfen Sie das Formular und korrigieren Sie alle Fehler vor dem Absenden." 234 }, 235 fr: { 236 'File Name': 'Nom de fichier', 237 'Size': 'Taille', 238 'Drop files to attach,': "Déposez les fichiers à joindre", 239 'or': 'ou', 240 'browse': 'Feuilleter', 241 'Edit': 'Ãditer', 242 'Preview': 'Aperçu', 243 'Save': 'Sauvegarder', 244 'Cancel': 'Annuler', 245 'Remove': 'Supprimer', 246 'Close': 'Proche', 247 'Move': 'Se déplacer', 248 'Copy': 'Copie', 249 'complete': 'Processus terminé', 250 'error' : "Veuillez corriger les erreurs suivantes avant de soumettre.", 251 'invalid_date' :"{{field}} n'est pas une date valide.", 252 'invalid_email' : "{{field}} doit être une adresse e-mail valide.", 253 'invalid_regex' : "{{field}} ne correspond pas à la règle {{regex}}.", 254 'mask' : "{{field}} ne correspond pas au masque.", 255 'max' : "{{field}} ne peut pas être plus grand que {{max}}.", 256 'maxLength' : "{{field}} doit être plus court que {{length}} caractères.", 257 'min' : "{{field}} ne doit pas être inférieur à {{min}}.", 258 'minLength' : "{{field}} doit comporter plus de {{length}} caractères.", 259 'next' : "Prochain", 260 'pattern' : "{{field}} ne correspond pas à la règle {{pattern}}", 261 'previous' : "Précédent", 262 'required' : "{{field}} obligatoire", 263 'Month': "Mois", 264 'Day': "Jour", 265 'Year': "Année", 266 'January': "Janvier", 267 'February': "Février", 268 'March': "Mars", 269 'April': "Avril", 270 'May': "Mai", 271 'June': "Juin", 272 'July': "Juillet", 273 'August': "Août", 274 'September': "Septembre", 275 'October': "Octobre", 276 'November': "Novembre", 277 'December': "Décembre", 278 'Submit': "Soumettre", 279 'submitError': "Veuillez vérifier le formulaire et corriger toutes les erreurs avant de le soumettre." 280 }, 281 it: { 282 'File Name': 'Nomi file', 283 'Size': 'Dimensione', 284 'Drop files to attach,': "Trascina qui i file per caricarli", 285 'or': 'o', 286 'browse': 'Scegliere i file', 287 'Edit': 'Modificare', 288 'Preview': 'Anteprima', 289 'Save': 'Risparmia sul computer', 290 'Cancel': 'Interrompi', 291 'Remove': 'Rimuovere', 292 'Close': 'Concludere', 293 'Move': 'Spostare', 294 'Copy': 'Copia', 295 'complete': 'Processo completato', 296 'error' : "Si prega di correggere i seguenti errori prima di inviare.", 297 'invalid_date' :"{{field}} non è una data valida.", 298 'invalid_email' : "{{field}} deve essere un'email valida.", 299 'invalid_regex' : "{{field}} non corrisponde alla regola {{regex}}.", 300 'mask' : "{{field}} non corrisponde alla maschera.", 301 'max' : "{{field}} non può essere maggiore di {{max}}.", 302 'maxLength' : "{{field}} deve essere inferiore a {{length}} caratteri.", 303 'min' : "{{field}} non deve essere inferiore a {{min}}.", 304 'minLength' : "{{field}} deve essere più lungo di {{length}} caratteri.", 305 'next' : "Prossimo", 306 'pattern' : "{{field}} non corrisponde alla regola {{pattern}}", 307 'previous' : "Precedente", 308 'required' : "{{field}} obbligatorio", 309 'Month': "Mese", 310 'Day': "Giorno", 311 'Year': "Anno", 312 'January': "Gennaio", 313 'February': "Febbraio", 314 'March': "Marzo", 315 'April': "Aprile",
316 'May': "Maggio", 317 'June': "Giugno", 318 'July': "Luglio", 319 'August': "Agosto", 320 'September': "Settembre", 321 'October': "Ottobre", 322 'November': "Novembre", 323 'December': "Dicembre", 324 'Submit': "Invia", 325 'submitError': "Si prega di controllare il modulo e correggere tutti gli errori prima di inviare." 326 }, 327 de_calendar: { 328 weekdays: { 329 shorthand: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"], 330 longhand: [ 331 "Sonntag", 332 "Montag", 333 "Dienstag", 334 "Mittwoch", 335 "Donnerstag", 336 "Freitag", 337 "Samstag" 338 ] 339 }, 340 months: { 341 shorthand: [ 342 "Jan", 343 "Feb", 344 "Mär", 345 "Apr", 346 "Mai", 347 "Jun", 348 "Jul", 349 "Aug", 350 "Sep", 351 "Okt", 352 "Nov", 353 "Dez" 354 ], 355 longhand: [ 356 "Januar", 357 "Februar", 358 "März", 359 "April", 360 "Mai", 361 "Juni", 362 "Juli", 363 "August", 364 "September", 365 "Oktober", 366 "November", 367 "Dezember" 368 ] 369 }, 370 firstDayOfWeek: 1, 371 weekAbbreviation: "KW", 372 rangeSeparator: " bis ", 373 scrollTitle: "Zum Ãndern scrollen", 374 toggleTitle: "Zum Umschalten klicken", 375 time_24hr: true 376 }, 377 fr_calendar: { 378 weekdays: { 379 shorthand: ['Dim.', 'Lun.', 'Mar.', 'Mer.', 'Jeu.', 'Ven.', 'Sam.'], 380 longhand: [ 381 'Dimanche', 382 'Lundi', 383 'Mardi', 384 'Mercredi', 385 'Jeudi', 386 'Vendredi', 387 'Samedi', 388 ] 389 }, 390 months: { 391 shorthand: [ 392 'Janv.', 393 'Févr.', 394 'Mars', 395 'Avril', 396 'Mai', 397 'Juin', 398 'Juil.', 399 'Août', 400 'Sept.', 401 'Oct.', 402 'Nov.', 403 'Déc.' 404 ], 405 longhand: [ 406 'Janvier', 407 'Février', 408 'Mars', 409 'Avril', 410 'Mai', 411 'Juin', 412 'Juillet', 413 'Août', 414 'Septembre', 415 'Octobre', 416 'Novembre', 417 'Décembre' 418 ] 419 }, 420 firstDayOfWeek: 1, 421 weekAbbreviation: "Sm", 422 rangeSeparator: " jusqu'à ", 423 scrollTitle: "Faites défiler pour changer", 424 toggleTitle: "Cliquez pour basculer", 425 time_24hr: true 426 }, 427 it_calendar: { 428 weekdays: { 429 shorthand: ['Do','Lu','Ma','Me','Gio','Ve','Sa'], 430 longhand: [ 431 "Domenica", 432 "Luned", 433 "Marted", 434 "Mercoled", 435 "Gioved", 436 "Venerd", 437 "Sabato" 438 ] 439 }, 440 months: { 441 shorthand: [ 442 "Gen", 443 "Feb", 444 "Mar", 445 "Apr", 446 "Mag",
447 "Giu", 448 "Lug", 449 "Ago", 450 "Set", 451 "Ott", 452 "Nov", 453 "Dic" 454 ], 455 longhand: [ 456 "Gennaio", 457 "Febbraio", 458 "Marzo", 459 "Aprile", 460 "Maggio", 461 "Giugno", 462 "Luglio", 463 "Agosto", 464 "Settembre", 465 "Ottobre", 466 "Novembre", 467 "Dicembre" 468 ] 469 }, 470 firstDayOfWeek: 1, 471 weekAbbreviation: "Sm", 472 rangeSeparator: " fino a ", 473 scrollTitle: "Scorri per cambiare", 474 toggleTitle: "Fai clic per attivare/disattivare", 475 time_24hr: true 476 } 477 }; 478 return labels[lang] || {}; 479 } 480 481 function init_sub_form(){ 482 $(".js-parent-submission").on("click", function(){ 483 $(".js-child-submission").toggle(); 484 return false; 485 }); 486 } 487})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.