tellform/public/dist/application.min.js

4 lines
120 KiB
JavaScript
Raw Normal View History

2016-06-16 00:38:22 +00:00
"use strict";function removeDateFieldsFunc(o){function eachObject(v,k){"lastModified"!==k&&"created"!==k||delete clone[k]}for(var clone=_.clone(o),i=0;i<clone.length;i++)_.each(clone[i],eachObject);return clone}var ApplicationConfiguration=function(){var applicationModuleName="NodeForm",applicationModuleVendorDependencies=["duScroll","ui.select","cgBusy","ngSanitize","vButton","ngResource","NodeForm.templates","ui.router","ui.bootstrap","ui.utils","pascalprecht.translate"],registerModule=function(moduleName,dependencies){angular.module(moduleName,dependencies||[]),angular.module(applicationModuleName).requires.push(moduleName)};return{applicationModuleName:applicationModuleName,applicationModuleVendorDependencies:applicationModuleVendorDependencies,registerModule:registerModule}}();angular.module(ApplicationConfiguration.applicationModuleName,ApplicationConfiguration.applicationModuleVendorDependencies),angular.module(ApplicationConfiguration.applicationModuleName).config(["$locationProvider",function($locationProvider){$locationProvider.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.module(ApplicationConfiguration.applicationModuleName).run(["$rootScope","Auth","$state","$stateParams",function($rootScope,Auth,$state,$stateParams){$rootScope.$state=$state,$rootScope.$stateParams=$stateParams,$rootScope.$on("$stateChangeSuccess",function(event,toState,toParams,fromState){$state.previous=fromState;var statesToIgnore=["home","signin","resendVerifyEmail","verify","signup","signup-success","forgot","reset-invalid","reset","reset-success"];statesToIgnore.indexOf(toState.name)>0?Auth.isAuthenticated()&&(event.preventDefault(),$state.go("listForms")):"access_denied"===toState.name||Auth.isAuthenticated()||"submitForm"===toState.name||(console.log("go to signup"),event.preventDefault(),$state.go("listForms"))})}]),angular.module(ApplicationConfiguration.applicationModuleName).run(["$rootScope","Auth","User","Authorizer","$state","$stateParams",function($rootScope,Auth,User,Authorizer,$state,$stateParams){$rootScope.$on("$stateChangeStart",function(event,next){var authenticator,permissions,user;permissions=next&&next.data&&next.data.permissions?next.data.permissions:null,Auth.ensureHasCurrentUser(User),user=Auth.currentUser,user&&(authenticator=new Authorizer(user),null!=permissions&&(authenticator.canAccess(permissions)||(event.preventDefault(),$state.go("access_denied"))))})}]),angular.element(document).ready(function(){"#_=_"===window.location.hash&&(window.location.hash="#!"),angular.bootstrap(document,[ApplicationConfiguration.applicationModuleName])}),angular.module("NodeForm.templates",[]).run(["$templateCache",function($templateCache){$templateCache.put("modules/core/views/header.client.view.html",'<section class="navbar navbar-fixed-top navbar-inverse" data-ng-controller=HeaderController ng-hide=hideNav><div class=container><div class=navbar-header><button class=navbar-toggle type=button data-ng-click=toggleCollapsibleMenu()><span class=sr-only>Toggle navigation</span> <span>{{ \'MENU_BTN\' | translate }}</span></button> <a href="https://www.tellform.com/#!/" class=navbar-brand><i class="fa fa-archive" style="padding-right: 0.3em"></i>Tell<span>Form</span></a></div><nav class="collapse navbar-collapse" collapse=!isCollapsed role=navigation><ul class="nav navbar-nav" data-ng-if=authentication.isAuthenticated()><li data-ng-repeat="item in menu.items | orderBy: \'position\'" data-ng-if=item.shouldRender(authentication.isAuthenticated()); ng-switch=item.menuItemType ui-route={{item.uiRoute}} class={{item.menuItemClass}} ng-class="{active: ($uiRoute)}" dropdown="item.menuItemType === \'dropdo
$templateCache.put("modules/forms/base/views/directiveViews/entryPage/startPage.html",'<div class="field row text-center"><div class="col-xs-12 text-center"><h1>{{pageData.introTitle}}</h1></div><div class="col-xs-10 col-xs-offset-1 text-left"><p style=color:#ddd>{{pageData.introParagraph}}</p></div></div><div class="row form-actions" style="padding-bottom:3em; padding-left: 1em; padding-right: 1em"><p ng-repeat="button in pageData.buttons" class=text-center style=display:inline><button class="btn btn-info" type=button ng-style="{\'background-color\':button.bgColor, \'color\':button.color}"><a href={{button.url}} style="font-size: 1.6em; text-decoration: none; color: inherit">{{button.text}}</a></button></p></div><div class="row form-actions"><p class="col-xs-3 col-xs-offset-3 text-center"><button class="btn btn-info" type=button><a ng-click=exitpageData() style="color:white; font-size: 1.6em; text-decoration: none">{{ \'CONTINUE_FORM\' | translate }}</a></button></p></div>'),$templateCache.put("modules/forms/base/views/directiveViews/field/date.html",'<div class="field row" ng-click="setActiveField(field._id, index, true)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><small class=field-number>{{index+1}} <i class="fa fa-angle-double-right" aria-hidden=true></i></small> {{field.title}} <span class=required-error ng-show="!field.required && !field.fieldValue">{{ \'OPTIONAL\' | translate }}</span></h3><p class=col-xs-12><small>{{field.description}}</small></p></div><div class="col-xs-12 field-input"><div class="control-group input-append"><input class=focusOn ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" ng-class="{ \'no-border\': !!field.fieldValue }" ui-date=dateOptions ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled=field.disabled placeholder=MM/DD/YYYY ng-focus="setActiveField(field._id, index, true)" on-tab-key=nextField() on-tab-and-shift-key=prevField() ng-change=$root.nextField()></div></div></div>'),$templateCache.put("modules/forms/base/views/directiveViews/field/dropdown.html",'<div class="field row dropdown" ng-if="field.fieldOptions.length > 0"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><small class=field-number>{{index+1}} <i class="fa fa-angle-double-right" aria-hidden=true></i></small> {{field.title}} <span class=required-error ng-show=!field.required>{{ \'OPTIONAL\' | translate }}</span></h3><p class=col-xs-12><small>{{field.description}}</small></p></div><div class="col-xs-12 field-input"><ui-select ng-model=field.fieldValue theme=selectize search-enabled=true search-by=option_value set-search-to-answer=true ng-required=field.required ng-disabled=field.disabled on-tab-and-shift-key=prevField() on-tab-key=nextField() ng-change=$root.nextField()><ui-select-match placeholder="Type or select an option"></ui-select-match><ui-select-choices repeat="option in field.fieldOptions | filter: $select.search" ng-class="{\'active\': option.option_value === field.fieldValue }"><span ng-bind-html="option.option_value | highlight: $select.search"></span></ui-select-choices></ui-select></div></div><br>'),$templateCache.put("modules/forms/base/views/directiveViews/field/file.html",'<div class="field row" ng-if=form.autofillPDFs ng-click="setActiveField(field._id, index, true)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><small class=field-number>{{index+1}} <i class="fa fa-angle-double-right" aria-hidden=true></i></small> {{field.title}} <span class=required-error ng-show=!field.required>{{ \'OPTIONAL\' | translate }}</span></h3></div><div class="col-sm-8 field-input"><div class=input-group><div tabindex=-1 class="form-control file-caption"><span class=file-caption-ellipsis ng-if=!form.pdf></span><div class=file-caption-name ng-if=form.pdf>{{field.file.originalname}}</div></div><div class=input-group-btn><button type=button ng-if=field.file ng-click=removeFile(field); title="Clear
$templateCache.put("modules/users/views/verify/resend-verify-email.client.view.html",'<section class="auth row" data-ng-controller=VerifyController><section ng-if=!isResetSent><h3 class="col-md-12 text-center">Resend your account verification email</h3><p class="small text-center">Enter your account email.</p><div data-ng-show=error class="text-center text-danger"><strong>{{error}}</strong></div><div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6"><form data-ng-submit=resendVerifyEmail() class="signin form-horizontal" autocomplete=off><fieldset><div class=form-group><input id=username name=email class=form-control data-ng-model=credentials.email placeholder=bob@example.com></div><div class="text-center form-group"><button type=submit class="btn btn-primary" ng-click=resendVerifyEmail()>Submit</button></div></fieldset></form></div></section><section ng-if=isResetSent><h3 class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6 text-center">Verification Email has been Sent</h3><div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6"><h2>A verification email has been sent to {{username}}.<br>But your account is still <b>not activated yet</b></h2><p>Check your email and click on the activation link to activate your account. If you have any questions drop us a line at <a href=mail:polydaic@gmail.com>polydaic@gmail.com</a></p><div class="text-center form-group"><button type=submit class="btn btn-large btn-primary"><a href="/#!/" style=color:white>Continue</a></button></div></div></section></section>'),$templateCache.put("modules/users/views/verify/verify-account.client.view.html",'<section style=margin-top:50px class="row text-center" data-ng-controller=VerifyController ng-init=validateVerifyToken()><section class="row text-center" ng-if=isResetSent><h3 class=col-md-12>Account successfuly activated</h3><a href=/#!/signin class=col-md-12>Continue to login page</a></section><section class="row text-center" ng-if=!isResetSent><h3 class=col-md-12>Verification link is invalid or has expired</h3><a href=/#!/verify class=col-md-6>Resend your verification email</a> <a href=/#!/signin class=col-md-6>Signin to your account</a></section></section>')}]),ApplicationConfiguration.registerModule("core",["users"]),ApplicationConfiguration.registerModule("forms",["ngFileUpload","ui.router.tabs","ui.date","ui.sortable","angular-input-stars","users"]),ApplicationConfiguration.registerModule("users"),angular.module("forms").config(["$translateProvider",function($translateProvider){$translateProvider.translations("english",{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 dont accept",DELETE:"Delete",CANCEL:"Cancel",SUBMIT:"Submit",UPLOAD_FILE:"Upload your File"}),$translateProvider.preferredLanguage("english").fallbackLanguage("english").useSanitizeValueStrategy("escape")}]),angular.module("forms").config(["$translateProvider",function($translateProvider){$translateProvider.translations("french",{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:"Merc
angular.element(document).ready(function(){var $formCtrl=$ctrls[0],savePromise=null;$rootScope.finishedRender=!1,$scope.$on("editFormFields Started",function(ngRepeatFinishedEvent){$rootScope.finishedRender=!1}),$scope.$on("editFormFields Finished",function(ngRepeatFinishedEvent){$rootScope.finishedRender=!0}),$scope.anyDirtyAndTouched=function(form){var propCount=0;for(var prop in form)if(form.hasOwnProperty(prop)&&"$"!==prop[0]&&(propCount++,form[prop].$touched&&form[prop].$dirty))return!0;return!1};var debounceSave=function(){$rootScope.saveInProgress=!0,$rootScope[$attrs.autoSaveCallback](!0,function(err){err?(console.error("Error form data NOT persisted"),console.error(err)):($formCtrl.$setPristine(),$formCtrl.$setUntouched())})};$scope.$watch(function(newValue,oldValue){$rootScope.finishedRender&&$scope.anyDirtyAndTouched($scope.editForm)&&!$rootScope.saveInProgress&&debounceSave()}),$scope.$watch($attrs.autoSaveWatch,function(newValue,oldValue){newValue=angular.copy(newValue),oldValue=angular.copy(oldValue),newValue.form_fields=_.removeDateFields(newValue.form_fields),oldValue.form_fields=_.removeDateFields(oldValue.form_fields);var changedFields=!_.isEqual(oldValue.form_fields,newValue.form_fields)||!_.isEqual(oldValue.startPage,newValue.startPage),changedFieldMap=!1;oldValue.hasOwnProperty("plugins.oscarhost.settings.fieldMap")&&(changedFieldMap=!!oldValue.plugins.oscarhost.settings.fieldMap&&!_.isEqual(oldValue.plugins.oscarhost.settings.fieldMap,newValue.plugins.oscarhost.settings.fieldMap)),(newValue||oldValue)&&oldValue&&(0===oldValue.form_fields.length&&($rootScope.finishedRender=!0),$rootScope.finishedRender&&(changedFields&&!$formCtrl.$dirty||changedFieldMap)&&!$rootScope.saveInProgress?(savePromise&&($timeout.cancel(savePromise),savePromise=null),savePromise=$timeout(function(){debounceSave()})):$rootScope.finishedRender&&$rootScope.saveInProgress&&($rootScope.saveInProgress=!1))},!0)})}}}]),angular.module("forms").directive("configureFormDirective",["$rootScope","$http","Upload","CurrentForm",function($rootScope,$http,Upload,CurrentForm){return{templateUrl:"modules/forms/admin/views/directiveViews/form/configure-form.client.view.html",restrict:"E",scope:{myform:"=",user:"=",pdfFields:"@",formFields:"@"},controller:["$scope",function($scope){console.log($scope.myform),CurrentForm.getForm().plugins?CurrentForm.getForm().plugins.oscarhost.baseUrl&&($scope.oscarhostAPI=!0):$scope.oscarhostAPI=!1,$scope.log="",$scope.pdfLoading=!1,$scope.languages=$rootScope.languages,this._current_upload=null,$scope.resetForm=$rootScope.resetForm,$scope.update=$rootScope.update,this._unbindedPdfFields=$scope.pdfFields,$scope.cancelUpload=function(){this._current_upload.abort(),$scope.pdfLoading=!1,$scope.removePDF()},$scope.removePDF=function(){$scope.myform.pdf=null,$scope.myform.isGenerated=!1,$scope.myform.autofillPDFs=!1,console.log("form.pdf: "+$scope.myform.pdf+" REMOVED")},$scope.uploadPDF=function(file){file&&(console.log(file),Upload.upload({url:"/upload/pdf",data:{user:$scope.user,file:file}}).then(function(resp){var data=resp.data;$scope.log="file "+data.originalname+" uploaded as "+data.filename+". JSON: "+JSON.stringify(data)+"\n"+$scope.log,$scope.myform.pdf=angular.fromJson(angular.toJson(data)),$scope.pdfLoading=!1,console.log($scope.log),$scope.$$phase||$scope.$digest||$scope.$apply()},function(resp){$scope.pdfLoading=!1,console.log("Error occured during upload.\n"),console.log(resp.status)},function(evt){var progressPercentage=parseInt(100*evt.loaded/evt.total,10);$scope.log="progress: "+progressPercentage+"% "+evt.config.data.file.name+"\n"+$scope.log,console.log($scope.log),$scope.pdfLoading=!0}))}}]}}]),angular.module("forms").directive("editFormDirective",["$rootScope","FormFields",function($rootScope,FormFields){return{templateUrl:"modules/forms/admin/views/directiveViews/form/edit-form.client.view.html",restrict:"E",scope:{myform:"="},controller:["$scope",function($scope){console.log($scope.myform);for(var field_ids=_($scope.myform.form_fields).pluck("_id"),i=0;i<field_ids.length;i++)$scope.myform.p