1 line
24 KiB
JavaScript
1 line
24 KiB
JavaScript
"use strict";angular.module(ApplicationConfiguration.applicationModuleName,ApplicationConfiguration.applicationModuleVendorDependencies),angular.module(ApplicationConfiguration.applicationModuleName).config(["$locationProvider",function(a){a.hashPrefix("!")}]),angular.module(ApplicationConfiguration.applicationModuleName).constant("APP_PERMISSIONS",{viewAdminSettings:"viewAdminSettings",editAdminSettings:"editAdminSettings",editForm:"editForm",viewPrivateForm:"viewPrivateForm"}),angular.module(ApplicationConfiguration.applicationModuleName).constant("USER_ROLES",{admin:"admin",normal:"user",superuser:"superuser"}),angular.module(ApplicationConfiguration.applicationModuleName).constant("FORM_URL","/forms/:formId"),angular.element(document).ready(function(){"#_=_"===window.location.hash&&(window.location.hash="#!"),angular.bootstrap(document,[ApplicationConfiguration.applicationModuleName])});var ApplicationConfiguration=function(){var a="TellForm",b=["duScroll","ui.select","ngSanitize","vButton","ngResource","TellForm.templates","ui.router","ui.bootstrap","ui.utils","pascalprecht.translate","view-form"],c=function(b,c){angular.module(b,c||[]),angular.module(a).requires.push(b)};return{applicationModuleName:a,applicationModuleVendorDependencies:b,registerModule:c}}();angular.module("view-form").filter("formValidity",function(){return function(a){if(a&&a.form_fields&&a.visible_form_fields){var b=Object.keys(a),c=(b.filter(function(a){return"$"!==a[0]}),a.form_fields),d=c.filter(function(a){return"object"==typeof a&&"rating"!==a.fieldType&&"statement"!==a.fieldType?!!a.fieldValue:"rating"===a.fieldType||void 0}).length;return d-(a.form_fields.length-a.visible_form_fields.length)}return 0}}),angular.module("view-form").value("supportedFields",["textfield","textarea","date","dropdown","hidden","password","radio","legal","statement","rating","yes_no","number","natural"]),angular.module("view-form").constant("VIEW_FORM_URL","/forms/:formId/render"),angular.module("view-form").config(["$translateProvider",function(a){a.translations("en",{FORM_SUCCESS:"Form entry successfully submitted!",REVIEW:"Review",BACK_TO_FORM:"Go back to Form",EDIT_FORM:"Edit this TellForm",CREATE_FORM:"Create this TellForm",ADVANCEMENT:"{{done}} out of {{total}} answered",CONTINUE_FORM:"Continue to Form",REQUIRED:"required",COMPLETING_NEEDED:"{{answers_not_completed}} answer(s) need completing",OPTIONAL:"optional",ERROR_EMAIL_INVALID:"Please enter a valid email address",ERROR_NOT_A_NUMBER:"Please enter valid numbers only",ERROR_URL_INVALID:"Please a valid url",OK:"OK",ENTER:"press ENTER",YES:"Yes",NO:"No",NEWLINE:"press SHIFT+ENTER to create a newline",CONTINUE:"Continue",LEGAL_ACCEPT:"I accept",LEGAL_NO_ACCEPT:"I don’t accept",DELETE:"Delete",CANCEL:"Cancel",SUBMIT:"Submit",UPLOAD_FILE:"Upload your File",Y:"Y",N:"N",OPTION_PLACEHOLDER:"Type or select an option",ADD_NEW_LINE_INSTR:"Press SHIFT+ENTER to add a newline",ERROR:"Error",FORM_404_HEADER:"404 - Form Does Not Exist",FORM_404_BODY:"The form you are trying to access does not exist. Sorry about that!",FORM_UNAUTHORIZED_HEADER:"Not Authorized to Access Form",FORM_UNAUTHORIZED_BODY1:"The form you are trying to access is currently private and not accesible publically.",FORM_UNAUTHORIZED_BODY2:'If you are the owner of the form, you can set it to "Public" in the "Configuration" panel in the form admin.'}),a.preferredLanguage("en").fallbackLanguage("en").useSanitizeValueStrategy("escape")}]),angular.module("view-form").config(["$translateProvider",function(a){a.translations("fr",{FORM_SUCCESS:"Votre formulaire a été enregistré!",REVIEW:"Incomplet",BACK_TO_FORM:"Retourner au formulaire",EDIT_FORM:"Éditer le Tellform",CREATE_FORM:"Créer un TellForm",ADVANCEMENT:"{{done}} complétés sur {{total}}",CONTINUE_FORM:"Aller au formulaire",REQUIRED:"obligatoire",COMPLETING_NEEDED:"{{answers_not_completed}} réponse(s) doive(nt) être complétée(s)",OPTIONAL:"facultatif",ERROR_EMAIL_INVALID:"Merci de rentrer une adresse mail valide",ERROR_NOT_A_NUMBER:"Merce de ne rentrer que des nombres",ERROR_URL_INVALID:"Merci de rentrer une url valide",OK:"OK",ENTER:"presser ENTRÉE",YES:"Oui",NO:"Non",NEWLINE:"presser SHIFT+ENTER pour créer une nouvelle ligne",CONTINUE:"Continuer",LEGAL_ACCEPT:"J’accepte",LEGAL_NO_ACCEPT:"Je n’accepte pas",DELETE:"Supprimer",CANCEL:"Réinitialiser",SUBMIT:"Enregistrer",UPLOAD_FILE:"Envoyer un fichier",Y:"O",N:"N",OPTION_PLACEHOLDER:"Tapez ou sélectionnez une option",ADD_NEW_LINE_INSTR:"Appuyez sur MAJ + ENTRÉE pour ajouter une nouvelle ligne",ERROR:"Erreur",FORM_404_HEADER:"404 - Le formulaire n'existe pas",FORM_404_BODY:"Le formulaire auquel vous essayez d'accéder n'existe pas. Désolé pour ça!",FORM_UNAUTHORIZED_HEADER:"Non autorisé à accéder au formulaire",FORM_UNAUTHORIZED_BODY1:"Le formulaire auquel vous essayez d'accéder est actuellement privé et inaccessible publiquement.",FORM_UNAUTHORIZED_BODY2:'Si vous êtes le propriétaire du formulaire, vous pouvez le définir sur "Public" dans le panneau "Configuration" du formulaire admin.'})}]),angular.module("view-form").config(["$translateProvider",function(a){a.translations("de",{FORM_SUCCESS:"Ihre Angaben wurden gespeichert.",REVIEW:"Unvollständig",BACK_TO_FORM:"Zurück zum Formular",EDIT_FORM:"Bearbeiten Sie diese TellForm",CREATE_FORM:"Dieses TellForm erstellen",ADVANCEMENT:"{{done}} von {{total}} beantwortet",CONTINUE_FORM:"Zum Formular",REQUIRED:"verpflichtend",COMPLETING_NEEDED:"Es fehlen/fehtl noch {{answers_not_completed}} Antwort(en)",OPTIONAL:"fakultativ",ERROR_EMAIL_INVALID:"Bitte gültige Mailadresse eingeben",ERROR_NOT_A_NUMBER:"Bitte nur Zahlen eingeben",ERROR_URL_INVALID:"Bitte eine gültige URL eingeben",OK:"Okay",ENTER:"Eingabetaste drücken",YES:"Ja",NO:"Nein",NEWLINE:"Für eine neue Zeile SHIFT+ENTER drücken",CONTINUE:"Weiter",LEGAL_ACCEPT:"I accept",LEGAL_NO_ACCEPT:"I don’t accept",DELETE:"Entfernen",CANCEL:"Canceln",SUBMIT:"Speichern",UPLOAD_FILE:"Datei versenden",Y:"J",N:"N",OPTION_PLACEHOLDER:"Geben oder wählen Sie eine Option aus",ADD_NEW_LINE_INSTR:"Drücken Sie UMSCHALT + EINGABETASTE, um eine neue Zeile hinzuzufügen",ERROR:"Fehler",FORM_404_HEADER:"404 - Formular existiert nicht",FORM_404_BODY:"Das Formular, auf das Sie zugreifen möchten, existiert nicht. Das tut mir leid!",FORM_UNAUTHORIZED_HEADER:"Nicht zum Zugriffsformular berechtigt' ",FORM_UNAUTHORIZED_BODY1:"Das Formular, auf das Sie zugreifen möchten, ist derzeit privat und nicht öffentlich zugänglich.",FORM_UNAUTHORIZED_BODY2:'Wenn Sie der Eigentümer des Formulars sind, können Sie es im Fenster "Konfiguration" im Formular admin auf "Öffentlich" setzen.'})}]),angular.module("view-form").config(["$translateProvider",function(a){a.translations("it",{FORM_SUCCESS:"Il formulario è stato inviato con successo!",REVIEW:"Incompleto",BACK_TO_FORM:"Ritorna al formulario",EDIT_FORM:"Modifica questo TellForm",CREATE_FORM:"Crea questo TellForm",ADVANCEMENT:"{{done}} su {{total}} completate",CONTINUE_FORM:"Vai al formulario",REQUIRED:"obbligatorio",COMPLETING_NEEDED:"{{answers_not_completed}} risposta/e deve/ono essere completata/e",OPTIONAL:"opzionale",ERROR_EMAIL_INVALID:"Si prega di inserire un indirizzo email valido",ERROR_NOT_A_NUMBER:"Si prega di inserire solo numeri",ERROR_URL_INVALID:"Grazie per inserire un URL valido",OK:"OK",ENTER:"premere INVIO",YES:"Sì",NO:"No",NEWLINE:"premere SHIFT+INVIO per creare una nuova linea",CONTINUE:"Continua",LEGAL_ACCEPT:"I accept",LEGAL_NO_ACCEPT:"I don’t accept",DELETE:"Cancella",CANCEL:"Reset",SUBMIT:"Registra",UPLOAD_FILE:"Invia un file",Y:"S",N:"N",OPTION_PLACEHOLDER:"Digitare o selezionare un'opzione",ADD_NEW_LINE_INSTR:"Premere SHIFT + INVIO per aggiungere una nuova riga",ERROR:"Errore",FORM_404_HEADER:"404 - Il modulo non esiste",FORM_404_BODY:"La forma che stai cercando di accedere non esiste. Ci dispiace!",FORM_UNAUTHORIZED_HEADER:"Non autorizzato per accedere al modulo",FORM_UNAUTHORIZED_BODY1:"Il modulo che si sta tentando di accedere è attualmente privato e non accessibile in pubblico.",FORM_UNAUTHORIZED_BODY2:'Se sei il proprietario del modulo, puoi impostarlo su "Pubblico" nel pannello "Configurazione" nell\'amministratore di moduli.'})}]),angular.module("view-form").config(["$translateProvider",function(a){a.translations("es",{FORM_SUCCESS:"¡El formulario ha sido enviado con éxito!",REVIEW:"Revisar",BACK_TO_FORM:"Regresar al formulario",EDIT_FORM:"Editar este TellForm",CREATE_FORM:"Crear este TellForm",ADVANCEMENT:"{{done}} de {{total}} contestadas",CONTINUE_FORM:"Continuar al formulario",REQUIRED:"Información requerida",COMPLETING_NEEDED:"{{answers_not_completed}} respuesta(s) necesita(n) ser completada(s)",OPTIONAL:"Opcional",ERROR_EMAIL_INVALID:"Favor de proporcionar un correo electrónico válido",ERROR_NOT_A_NUMBER:"Por favor, introduzca sólo números válidos",ERROR_URL_INVALID:"Favor de proporcionar un url válido",OK:"OK",ENTER:"pulse INTRO",YES:"Si",NO:"No",NEWLINE:"presione SHIFT+INTRO para crear una nueva línea",CONTINUE:"Continuar",LEGAL_ACCEPT:"Yo acepto",LEGAL_NO_ACCEPT:"Yo no acepto",DELETE:"Eliminar",CANCEL:"Cancelar",SUBMIT:"Registrar",UPLOAD_FILE:"Cargar el archivo",Y:"S",N:"N",OPTION_PLACEHOLDER:"Escriba o seleccione una opción",ADD_NEW_LINE_INSTR:"Presione MAYÚS + ENTRAR para agregar una nueva línea",ERROR:"Error",FORM_404_HEADER:"404 - La forma no existe",FORM_404_BODY:"El formulario al que intenta acceder no existe. ¡Lo siento por eso!",FORM_UNAUTHORIZED_HEADER:"Non autorizzato per accedere al modulo",FORM_UNAUTHORIZED_BODY1:"Il modulo che si sta tentando di accedere è attualmente privato e non accessibile in pubblico.",FORM_UNAUTHORIZED_BODY2:'Se sei il proprietario del modulo, puoi impostarlo su "Pubblico" nel pannello "Configurazione" nell\'amministratore di moduli.'})}]),angular.module("view-form").controller("SubmitFormController",["$scope","$rootScope","$state","$translate","myForm",function(a,b,c,d,e){a.myform=e,$(".loader").fadeOut("slow"),document.body.style.background=e.design.colors.backgroundColor,d.use(e.language)}]),angular.module("view-form").directive("fieldIconDirective",function(){return{template:'<i class="{{typeIcon}}"></i>',restrict:"E",scope:{typeName:"@"},controller:["$scope",function(a){var b={textfield:"fa fa-pencil-square-o",dropdown:"fa fa-th-list",date:"fa fa-calendar",checkbox:"fa fa-check-square-o",radio:"fa fa-dot-circle-o",email:"fa fa-envelope-o",textarea:"fa fa-pencil-square",legal:"fa fa-legal",file:"fa fa-cloud-upload",rating:"fa fa-star-half-o",link:"fa fa-link",scale:"fa fa-sliders",stripe:"fa fa-credit-card",statement:"fa fa-quote-left",yes_no:"fa fa-toggle-on",number:"fa fa-slack"};a.typeIcon=b[a.typeName]}]}});var __indexOf=[].indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1};angular.module("view-form").directive("fieldDirective",["$http","$compile","$rootScope","$templateCache","supportedFields",function(a,b,c,d,e){var f=function(a){var b=a,c="form_modules/forms/base/views/directiveViews/field/";return __indexOf.call(e,b)>=0&&(c=c+b+".html"),d.get(c)};return{template:"<div>{{field.title}}</div>",restrict:"E",scope:{field:"=",required:"&",design:"=",index:"=",forms:"="},link:function(a,d){c.chooseDefaultOption=a.chooseDefaultOption=function(b){"yes_no"===b?a.field.fieldValue="true":"rating"===b?a.field.fieldValue=0:"radio"===a.field.fieldType?a.field.fieldValue=a.field.fieldOptions[0].option_value:"legal"===b&&(a.field.fieldValue="true",c.nextField())},a.nextField=c.nextField,a.setActiveField=c.setActiveField,"date"===a.field.fieldType&&(a.dateOptions={changeYear:!0,changeMonth:!0,altFormat:"mm/dd/yyyy",yearRange:"1900:-0",defaultDate:0});var e=a.field.fieldType;if("number"===a.field.fieldType||"textfield"===a.field.fieldType||"email"===a.field.fieldType||"link"===a.field.fieldType){switch(a.field.fieldType){case"textfield":a.input_type="text";break;case"email":a.input_type="email",a.placeholder="joesmith@example.com";break;case"number":a.input_type="text",a.validateRegex=/^-?\d+$/;break;default:a.input_type="url",a.placeholder="http://example.com"}e="textfield"}var g=f(e);d.html(g).show();b(d.contents())(a)}}}]),angular.module("view-form").directive("onEnterKey",["$rootScope",function(a){return{restrict:"A",link:function(b,c,d){c.bind("keydown keypress",function(b){var c=b.which||b.keyCode,e=!1;null!==d.onEnterKeyDisabled&&(e=d.onEnterKeyDisabled),13!==c||b.shiftKey||e||(b.preventDefault(),a.$apply(function(){a.$eval(d.onEnterKey)}))})}}}]).directive("onTabKey",["$rootScope",function(a){return{restrict:"A",link:function(b,c,d){c.bind("keyup keypress",function(b){var c=b.which||b.keyCode;9!==c||b.shiftKey||(b.preventDefault(),a.$apply(function(){a.$eval(d.onTabKey)}))})}}}]).directive("onEnterOrTabKey",["$rootScope",function(a){return{restrict:"A",link:function(b,c,d){c.bind("keydown keypress",function(b){var c=b.which||b.keyCode;13!==c&&9!==c||b.shiftKey||(b.preventDefault(),a.$apply(function(){a.$eval(d.onEnterOrTabKey)}))})}}}]).directive("onTabAndShiftKey",["$rootScope",function(a){return{restrict:"A",link:function(b,c,d){c.bind("keydown keypress",function(b){var c=b.which||b.keyCode;9===c&&b.shiftKey&&(console.log("onTabAndShiftKey"),b.preventDefault(),a.$apply(function(){a.$eval(d.onTabAndShiftKey)}))})}}}]),angular.module("view-form").directive("onFinishRender",["$rootScope","$timeout",function(a,b){return{restrict:"A",link:function(b,c,d){if(c.attr("ng-repeat")||c.attr("data-ng-repeat")){var e=d.onFinishRender||"ngRepeat";b.$first&&!b.$last?b.$evalAsync(function(){a.$broadcast(e+" Started")}):b.$last&&b.$evalAsync(function(){a.$broadcast(e+" Finished")})}}}}]),jsep.addBinaryOp("contains",10),jsep.addBinaryOp("!contains",10),jsep.addBinaryOp("begins",10),jsep.addBinaryOp("!begins",10),jsep.addBinaryOp("ends",10),jsep.addBinaryOp("!ends",10),angular.module("view-form").directive("submitFormDirective",["$http","TimeCounter","$filter","$rootScope","SendVisitorData","$translate","$timeout",function(a,b,c,d,e,f,g){return{templateUrl:"form_modules/forms/base/views/directiveViews/form/submit-form.client.view.html",restrict:"E",scope:{myform:"=",ispreview:"="},controller:["$document","$window","$scope",function(f,g,h){var i=!1,j="submit_field";h.forms={},h.ispreview&&b.restartClock();var k=h.myform.visible_form_fields.filter(function(a){return"statement"!==a.fieldType}).length,l=c("formValidity")(h.myform);h.translateAdvancementData={done:l,total:k,answers_not_completed:k-l},h.reloadForm=function(){h.myform.submitted=!1,h.myform.form_fields=_.chain(h.myform.visible_form_fields).map(function(a){return a.fieldValue="",a}).value(),h.loading=!1,h.error="",h.selected={_id:"",index:0},h.setActiveField(h.myform.visible_form_fields[0]._id,0,!1),b.restartClock()};var m=function(a){var b=a.logicJump;if(b.enabled&&b.expressionString&&b.valueB&&a.fieldValue){var c,d,e=jsep(b.expressionString);if("field"===e.left.name?(c=a.fieldValue,d=b.valueB):(c=b.valueB,d=a.fieldValue),"number"===a.fieldType||"scale"===a.fieldType||"rating"===a.fieldType)switch(e.operator){case"==":return parseInt(c)===parseInt(d);case"!==":return parseInt(c)!==parseInt(d);case">":return parseInt(c)>parseInt(d);case">=":return parseInt(c)>parseInt(d);case"<":return parseInt(c)<parseInt(d);case"<=":return parseInt(c)<=parseInt(d);default:return!1}else switch(e.operator){case"==":return c===d;case"!==":return c!==d;case"contains":return c.indexOf(d)>-1;case"!contains":return!(c.indexOf(d)>-1);case"begins":return c.startsWith(d);case"!begins":return!c.startsWith(d);case"ends":return c.endsWith(d);case"!ends":return c.endsWith(d);default:return!1}}},n=function(){if(null===h.selected)throw console.error("current active field is null"),new Error("current active field is null");return h.selected._id===j?h.myform.form_fields.length-1:h.selected.index};h.isActiveField=function(a){return h.selected._id===a._id},h.setActiveField=d.setActiveField=function(a,b,d){if(null!==h.selected&&(a||null!==b)){if(a){if(null===b){b=h.myform.visible_form_fields.length;for(var e=0;e<h.myform.visible_form_fields.length;e++){var g=h.myform.visible_form_fields[e];if(g._id==a){b=e;break}}}}else a=h.myform.visible_form_fields[b]._id;if(h.selected._id!==a){h.selected._id=a,h.selected.index=b;var j=c("formValidity")(h.myform);h.translateAdvancementData={done:j,total:k,answers_not_completed:k-j},d&&(i=!0,setTimeout(function(){f.scrollToElement(angular.element(".activeField"),-10,200).then(function(){i=!1,setTimeout(function(){document.querySelectorAll(".activeField .focusOn").length?document.querySelectorAll(".activeField .focusOn")[0].focus():document.querySelectorAll(".activeField input").length?document.querySelectorAll(".activeField input")[0].focus():document.querySelectorAll(".activeField .selectize-input")[0].focus()})})}))}}},h.$watch("selected.index",function(a,c){a!==c&&c<h.myform.form_fields.length&&(h.myform.submitted||(console.log("SendVisitorData.send()"),e.send(h.myform,c,b.getTimeElapsed())))}),g.onscroll=function(){if(!i){var a,b=$(window).scrollTop(),c=document.getElementsByClassName("activeField")[0].getBoundingClientRect(),d=c.top,e=c.bottom,f=$(".activeField").height(),g=$(".form-actions").height(),k=$(document).height()-$(window).height(),l=($("form_fields").height(),"form > .field-directive:nth-of-type("+String(h.myform.visible_form_fields.length-1)+")"),m=$(l).height(),n=k-g-1.2*m,o=.9;h.selected.index===h.myform.visible_form_fields.length?b<n&&(a=h.selected.index-1,h.setActiveField(null,a,!1)):h.selected.index===h.myform.visible_form_fields.length-1&&b>n?(a=h.selected.index+1,h.setActiveField(j,a,!1)):e<f*o&&h.selected.index<h.myform.visible_form_fields.length-1?(a=h.selected.index+1,h.setActiveField(null,a,!1)):0!==h.selected.index&&d>f*o&&(a=h.selected.index-1,h.setActiveField(null,a,!1))}h.$apply()},d.nextField=h.nextField=function(){if(h.selected&&h.selected.index>-1)if(h.selected._id!==j){var a=h.myform.visible_form_fields[h.selected.index];a.logicJump&&a.logicJump.jumpTo&&m(a)?h.setActiveField(a.logicJump.jumpTo,null,!0):h.selected.index<h.myform.visible_form_fields.length-1?h.setActiveField(null,h.selected.index+1,!0):h.setActiveField(j,null,!0)}else d.setActiveField(null,0,!0);else d.setActiveField(null,0,!0)},d.prevField=h.prevField=function(){console.log("prevField"),console.log(h.selected);var a=h.selected.index-1;h.selected.index>0&&h.setActiveField(null,a,!0)},d.goToInvalid=h.goToInvalid=function(){var a=$(".row.field-directive .ng-invalid.focusOn, .row.field-directive .ng-untouched.focusOn:not(.ng-valid)").first().parents(".row.field-directive").first().attr("data-id");h.setActiveField(a,null,!0)},h.exitStartPage=function(){h.myform.startPage.showStart=!1,h.myform.visible_form_fields.length>0&&(h.selected._id=h.myform.visible_form_fields[0]._id)};var o=function(){var a=new MobileDetect(window.navigator.userAgent),b="other";return a.tablet()?b="tablet":a.mobile()?b="mobile":a.is("bot")||(b="desktop"),{type:b,name:window.navigator.platform}},p=function(){$.ajaxSetup({async:!1});var a=$.getJSON("https://freegeoip.net/json/").responseJSON;return $.ajaxSetup({async:!0}),a&&a.ip||(a={ip:"Adblocker"}),{ipAddr:a.ip,geoLocation:{City:a.city,Country:a.country_name}}};d.submitForm=h.submitForm=function(){if(h.forms.myForm.$invalid)return void h.goToInvalid();var d=b.stopClock();h.loading=!0;var f=_.cloneDeep(h.myform),g=o();f.device=g;var i=p();f.ipAddr=i.ipAddr,f.geoLocation=i.geoLocation,f.timeElapsed=d,f.percentageComplete=c("formValidity")(h.myform)/h.myform.visible_form_fields.length*100,delete f.endPage,delete f.isLive,delete f.provider,delete f.startPage,delete f.visible_form_fields,delete f.analytics,delete f.design,delete f.submissions,delete f.submitted;for(var j=0;j<h.myform.form_fields.length;j++)"dropdown"!==h.myform.form_fields[j].fieldType||h.myform.form_fields[j].deletePreserved||(h.myform.form_fields[j].fieldValue=h.myform.form_fields[j].fieldValue.option_value),delete f.form_fields[j].submissionId,delete f.form_fields[j].disabled,delete f.form_fields[j].ratingOptions,delete f.form_fields[j].fieldOptions,delete f.form_fields[j].logicJump,delete f.form_fields[j].description,delete f.form_fields[j].validFieldTypes,delete f.form_fields[j].fieldType;setTimeout(function(){h.submitPromise=a.post("/forms/"+h.myform._id,f).success(function(a,b){h.myform.submitted=!0,h.loading=!1,e.send(f,n(),d)}).error(function(a){h.loading=!1,console.error(a),h.error=a.message})},500)},h.reloadForm()}]}}]),angular.module("view-form").service("CurrentForm",function(){var a={};this.getForm=function(){return a},this.setForm=function(b){a=b}}),angular.module("view-form").factory("Forms",["$resource","VIEW_FORM_URL",function(a,b){return a(b,{formId:"@_id"},{get:{method:"GET",transformResponse:function(a,b){var c=angular.fromJson(a);return c.visible_form_fields=_.filter(c.form_fields,function(a){return a.deletePreserved===!1}),c}},update:{method:"PUT"},save:{method:"POST"}})}]),function(){function a(a,b){function c(){var a="";a=b.socketUrl&&b.socketPort?window.location.protocol+"//"+b.socketUrl+":"+b.socketPort:b.socketUrl?window.location.protocol+"//"+b.socketUrl:b.socketPort?window.location.protocol+"//"+window.location.hostname+":"+b.socketPort:window.location.protocol+"//"+window.location.hostname,g.socket=io(a,{transports:["websocket","polling"]})}function d(a,b){g.socket&&g.socket.emit(a,b)}function e(b,c){g.socket&&g.socket.on(b,function(b){a(function(){c(b)})})}function f(a){g.socket&&g.socket.removeListener(a)}var g={socket:null};return c(),g={connect:c,emit:d,on:e,removeListener:f,socket:null}}angular.module("view-form").factory("Socket",a),a.$inject=["$timeout","$window"]}(),angular.module("view-form").service("TimeCounter",function(){var a,b=null;this.timeSpent=0,this.restartClock=function(){a=Date.now(),b=null},this.getTimeElapsed=function(){if(a)return Math.abs(Date.now().valueOf()-a.valueOf())/1e3},this.stopClock=function(){return a&&null===b?(b=Date.now(),this.timeSpent=Math.abs(b.valueOf()-a.valueOf())/1e3,this._startTime=this._endTime=null,this.timeSpent):new Error("Clock has not been started")},this.clockStarted=function(){return!!this._startTime}}),angular.module("view-form").config(["$stateProvider",function(a){a.state("submitForm",{url:"/forms/:formId",templateUrl:"/static/form_modules/forms/base/views/submit-form.client.view.html",resolve:{Forms:"Forms",myForm:["Forms","$q","$state","$stateParams",function(a,b,c,d){var e=b.defer();return a.get({formId:d.formId}).$promise.then(function(a){e.resolve(a)},function(a){c.go("unauthorizedFormAccess"),e.reject({redirectTo:"unauthorizedFormAccess"})}),e.promise}]},controller:"SubmitFormController",controllerAs:"ctrl"}).state("unauthorizedFormAccess",{url:"/forms/unauthorized",templateUrl:"/static/form_modules/forms/base/views/form-unauthorized.client.view.html"}).state("formNotFound",{url:"*path",templateUrl:"/static/form_modules/forms/base/views/form-not-found.client.view.html"})}]),function(){function a(a,b){function c(b,c,d){var e=window.navigator.userLanguage||window.navigator.language;e=e.slice(0,2);var f=navigator.userAgent,g=new MobileDetect(f),h="other";g.tablet()?h="tablet":g.mobile()?h="mobile":g.is("bot")||(h="desktop");var i={referrer:document.referrer,isSubmitted:b.submitted,formId:b._id,lastActiveField:b.form_fields[c]._id,timeElapsed:d,language:e,deviceType:h,ipAddr:null,geoLocation:null};a.emit("form-visitor-data",i)}function d(){a.socket||a.connect(),a.on("disconnect",function(){a.connect()})}var e={send:c};return d(),e}angular.module("view-form").factory("SendVisitorData",a),a.$inject=["Socket","$state"]}(),angular.module("view-form").directive("keyToOption",function(){return{restrict:"A",scope:{field:"="},link:function(a,b,c,d){b.bind("keydown keypress",function(b){var c=b.which||b.keyCode,d=parseInt(String.fromCharCode(c))-1;d<a.field.fieldOptions.length&&(b.preventDefault(),a.$apply(function(){a.field.fieldValue=a.field.fieldOptions[d].option_value}))})}}}),angular.module("view-form").directive("keyToTruthy",["$rootScope",function(a){return{restrict:"A",scope:{field:"=",nextField:"&"},link:function(a,b,c){b.bind("keydown keypress",function(b){var d=b.which||b.keyCode,e=c.keyCharTruthy.charCodeAt(0)-32,f=c.keyCharFalsey.charCodeAt(0)-32;d===e?(b.preventDefault(),a.$apply(function(){a.field.fieldValue="true",c.onValidKey&&a.$root.$eval(c.onValidKey)})):d===f&&(b.preventDefault(),a.$apply(function(){a.field.fieldValue="false",c.onValidKey&&a.$root.$eval(c.onValidKey)}))})}}}]),ApplicationConfiguration.registerModule("view-form",["ngFileUpload","ui.date","angular-input-stars"]); |