4 lines
108 KiB
JavaScript
4 lines
108 KiB
JavaScript
"use strict";var ApplicationConfiguration=function(){var applicationModuleName="NodeForm",applicationModuleVendorDependencies=["ngResource","NodeForm.templates","ngAnimate","ui.router","ui.bootstrap","ui.utils","ngRaven","cgBusy"],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).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,console.log("toState: "+toState.name),"home"===toState.name||"signin"===toState.name||"resendVerifyEmail"===toState.name||"verify"===toState.name||"signup"===toState.name||"signup-success"===toState.name?Auth.isAuthenticated()&&(event.preventDefault(),$state.go("listForms")):"access_denied"===toState.name||Auth.isAuthenticated()||"submitForm"===toState.name||(console.log("go to home"),event.preventDefault(),$state.go("home"))})}]),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),console.log("access denied: "+!authenticator.canAccess(permissions)),null===permissions||authenticator.canAccess(permissions)||(event.preventDefault(),console.log("access denied"),$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("../public/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 class=icon-bar></span> <span class=icon-bar></span> <span class=icon-bar></span></button> <a href="/#!/" class=navbar-brand><i class="fa fa-archive" style="padding-right: 0.3em"></i>Tell<span>Forms</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 === \'dropdown\'"><a ng-switch-when=dropdown class=dropdown-toggle dropdown-toggle><span data-ng-bind=item.title></span> <b class=caret></b></a><ul ng-switch-when=dropdown class=dropdown-menu><li data-ng-repeat="subitem in item.items | orderBy: \'position\'" data-ng-if=subitem.shouldRender(authentication.isAuthenticated()); ui-route={{subitem.uiRoute}} ng-class="{active: $uiRoute}"><a href=/#!/{{subitem.link}} data-ng-bind=subitem.title></a></li></ul><a ng-switch-default href=/#!/{{item.link}} data-ng-bind=item.title></a></li></ul><ul class="nav navbar-nav navbar-right" data-ng-hide=authentication.isAuthenticated()><li ui-route=/signup ng-class="{active: $uiRoute}"><a href=/#!/signup>Sign Up</a></li><li class=divider-vertical></li><li ui-route=/signin ng-class="{active: $uiRoute}"><a href=/#!/signin>Sign In</a></li></ul><ul class="nav navbar-nav navbar-right" data-ng-show=authentication.isAuthenticated()><li class=dropdown uib-dropdown><a href=# class=dropdown-toggle data-toggle=dropdown dropdown-toggle><span>My Settings</span> <b class=caret></b></a><ul class=dropdown-menu><li><a href=/#!/settings/profile>Edit Profile</a></li><li class=divider></li><li><a href=/#!/settings/password>Change Password</a></li><li data-ng-show="authentication.isAuthenticated().provider === \'local\'"><a href=/#!/settings/password>Change Password</a></li></ul></li><li ng-click=signout()><a>Signout</a></li></ul></nav></div></section>'),$templateCache.put("../public/modules/core/views/home.client.view.html",'<section data-ng-controller=HomeController class=hero-section style=overflow:hidden><div class=opacity-background></div><div class=image-background></div><div class="jumbotron text-center"><div class=container data-ng-if=!authentication.isAuthenticated()><div class="row text-center logo" style="border-bottom: 1px solid rgba(255,255,255,.2); margin-bottom: 30px"><h3 class=col-xs-12 style="color: #FA787E; margin-bottom:0px"><i class="fa fa-archive fa-3x"></i></h3><h2 class=col-xs-12 style=margin-top:0px><span>Tell<span style="text-decoration: underline; color: #FA787E">Form</span></span></h2></div><div class=row style=margin-top:0px><h1 class="lead col-md-10 col-md-offset-1 hidden-xs hidden-sm" style=font-size:3.8em>Craft beautiful forms in seconds.</h1><h2 class="lead col-sm-12 text-center hidden-md hidden-lg" style=font-size:2.8em>Craft beautiful forms.</h2><p class="lead hidden-xs hidden-sm col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2" style="font-size:1.5em; color:rgba(255,255,255,.75)"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p><p class="lead col-xs-12 hidden-md hidden-lg" style="font-size:1.5em; color:rgba(255,255,255,.75)"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p></div></div></div><div class="jumbotron text-center"><div class=container data-ng-if=!authentication.isAuthenticated()><div class=row style=margin-top:0px><h1 class="lead col-md-10 col-md-offset-1 hidden-xs hidden-sm" style=font-size:3.8em>Create your next ______.</h1><h1 class="lead col-md-10 col-md-offset-1 hidden-xs hidden-sm" style=font-size:2.5em>Tell a story with a form.</h1></div><div class=row style=margin-top:7%><a class="col-xs-4 col-xs-offset-4 btn btn-info signup-btn" href=/#!/signup style="background-color:#FA787E; border: none; font-size: 2em; padding: 0.3em 0.9em; color: white">sign me up!</a></div></div></div></section>'),$templateCache.put("../public/modules/forms/views/admin-form.client.view.html",'<div class=container cg-busy="{promise:updatePromise,templateUrl:\'modules/forms/views/directiveViews/cgBusy/update-form-message-TypeB.html\',message:\'Updating form...\', backdrop:false, wrapperClass:\'.busy-updating-wrapper\'}"></div><section class="container admin-form"><script type=text/ng-template id=myModalContent.html><div class="modal-header">\n <h2 class="modal-title hidden-md hidden-lg">Are you ABSOLUTELY sure?</h2>\n <h3 class="modal-title hidden-xs hidden-sm">Are you ABSOLUTELY sure?</h3>\n </div>\n <div class="modal-body">\n <div class="modal-body-alert">\n Unexpected bad things will happen if you don’t read this!\n </div>\n <p class="hidden-xs hidden-sm">\n This action <strong>CANNOT</strong> be undone.This will permanently delete the <strong>{{myform.title}}</strong> form, form submissions and remove all associated pdfs.\n </p>\n <p>Please type in the name of the form to confirm.</p>\n </div>\n <div class="modal-footer">\n <p>\n <input type="text" data-ng-model="deleteConfirm" class="input-block" autofocus required aria-label="Type in the name of the form to confirm that you want to delete this form.">\n </p>\n <button type="submit" ng-click="removeCurrentForm()" class="btn btn-block btn-danger" ng-disabled="myform.title != deleteConfirm">\n I understand the consequences, delete this form\n </button>\n </div></script><div class="page-header row" style="padding-bottom: 0px"><div class="col-xs-10 col-sm-8"><h1 class="hidden-sm hidden-xs" data-ng-bind=myform.title style="margin-bottom: 0px"></h1><h2 class="hidden-md hidden-lg" data-ng-bind=myform.title style="margin-bottom: 0px"></h2></div><div class="col-xs-1 col-sm-2"><small class=pull-right><button class="btn btn-danger" ng-click=openDeleteModal()><i class="fa fa-trash-o"></i> <span class=hidden-xs>Delete</span> <span class="hidden-xs hidden-sm">Form</span></button></small></div><div class="col-xs-1 col-sm-2"><small class=pull-right><a class="btn btn-default view-form-btn" href=/#!/forms/{{myform._id}}><span class="hidden-xs hidden-sm">View <span ng-show=myform.isLive>Live</span> <span ng-hide=myform.isLive>Preview</span> Form</span> <span class="hidden-xs hidden-md hidden-lg">View <span ng-if=myform.isLive>Live</span> <span ng-if=!myform.isLive>Preview</span></span> <i class="status-light status-light-on fa fa-dot-circle-o" ng-if=myform.isLive></i> <i class="status-light status-light-off fa fa-dot-circle-o" ng-if=!myform.isLive></i></a></small></div></div><div class=row><div class=col-xs-12><tabs data=tabData></tabs></div><div class=col-xs-12><ui-view></ui-view></div></div></section>'),$templateCache.put("../public/modules/forms/views/list-forms.client.view.html",'<section class=overlay ng-if=showCreateModal ng-click=closeCreateModal()></section><section data-ng-controller="ListFormsController as ctrl" data-ng-init=findAll() class=container><br><div class=row><div ng-click=openCreateModal() class="col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item create-new"><div class="title-row col-xs-12"><h4 class="fa fa-plus fa-6"></h4></div><div class="col-xs-12 details-row"><small class=list-group-item-text>Create a new form</small></div></div><form name=forms.createForm class="col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item create-new new-form" ng-if=showCreateModal><div class="title-row row"><div class="col-xs-5 field-title text-left">Name</div><div class="col-xs-12 field-input"><input name=title required ng-model=formTitle ng-pattern="/^[a-zA-Z0-9 \\-.]*$/" ng-minlength="4"></div></div><div class="details-row row"><div class="col-xs-5 field-title text-left">Language</div><div class="col-xs-12 field-input"><div class="button custom-select"><select style=color:black name=language required ng-model=formLanguage ng-init="formLanguage = user.language"><option ng-repeat="language in languages" value={{language}}>{{language}}</option></select></div></div></div><div class="details-row submit row"><div class="col-xs-12 field-title text-center"><button class="btn btn-primary" ng-disabled=forms.createForm.$invalid ng-click=createNewForm()>Create Form</button></div></div></form><div data-ng-repeat="form in myforms" class="col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item container"><div class=row><span class=pull-right><i style=cursor:pointer class="fa fa-trash-o" ng-click=removeForm($index)></i> <i style=cursor:pointer class="fa fa-files-o" ng-click=duplicateForm($index)></i></span></div><div class=row><a data-ng-href=#!/forms/{{form._id}}/admin/create class="title-row col-xs-12"><h4 class=list-group-item-heading data-ng-bind=form.title></h4></a></div><div class="row footer"><div class="col-xs-12 details-row"><small class=list-group-item-text>Created on <span data-ng-bind="form.created | date:\'shortDate\'"></span></small></div></div></div></div></section>'),$templateCache.put("../public/modules/forms/views/submit-form.client.view.html","<section class=public-form ng-style=\"{ 'background-color': myform.design.colors.backgroundColor }\"><submit-form-directive myform=myform></submit-form-directive></section>"),$templateCache.put("../public/modules/forms/views/adminTabs/analyze.html","<edit-submissions-form-directive myform=myform user=user></edit-submissions-form-directive>"),$templateCache.put("../public/modules/forms/views/adminTabs/configure.html","<configure-form-directive myform=myform user=user></configure-form-directive>"),$templateCache.put("../public/modules/forms/views/adminTabs/create.html","<edit-form-directive myform=myform></edit-form-directive>"),$templateCache.put("../public/modules/forms/views/adminTabs/design.html",'<div class="config-form design container"><div class=row><div class="col-md-12 container"><div class=row><div class=col-sm-12><h2 class="hidden-sm hidden-xs">Change how your Form Looks</h2><h3 class="hidden-lg hidden-md">Change how your Form Looks</h3></div></div><div class="row field"><div class="field-title col-sm-3"><h5>Background Color</h5></div><div class="field-input col-sm-9"><input colorpicker=hex ng-model=myform.design.colors.backgroundColor ng-style="{ \'background-color\': myform.design.colors.backgroundColor }"></div></div><div class="row field"><div class="field-title col-sm-3"><h5>Question Font Color</h5></div><div class="field-input col-sm-9"><input colorpicker=hex ng-model=myform.design.colors.questionColor ng-style="{ \'background-color\': myform.design.colors.questionColor }"></div></div><div class="row field"><div class="field-title col-sm-3"><h5>Answer Font Color</h5></div><div class="field-input col-sm-9"><input colorpicker=hex ng-model=myform.design.colors.answerColor ng-style="{ \'background-color\': myform.design.colors.answerColor }"></div></div></div></div><div class=row><div class="col-sm-offset-4 col-sm-2"><button class="btn btn-primary btn-large" type=button ng-click="update(false, null)"><i class="icon-arrow-left icon-white"></i> Save Changes</button></div><div class=col-sm-1><button class="btn btn-default" type=button ng-click=resetForm()><i class="icon-eye-open icon-white"></i> Cancel</button></div></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/cgBusy/update-form-message-TypeA.html",'<div><div style="text-align:center;font-size:26px;position:absolute;top:100px;width:100%;text-shadow:1px 1px 2px white, -1px -1px 2px white,-4px 4px 4px white,-4px 4px 4px white">{{$message}}</div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/cgBusy/update-form-message-TypeB.html",'<div><div style="text-align: center; font-size: 20px;position: fixed; bottom: 0; right: 55px; background-color: gray; color: white; padding: 5px 15px 5px 10px; z-index: 10">{{$message}}</div></div>'),$templateCache.put("../public/modules/forms/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 to Form</a></button></p></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/checkbox.html",'<div class="field row" ng-if="field.fieldOptions.length > 0" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title field-title">{{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">(* required)</span></div><div class="col-xs-12 field-input"><div ng-repeat="option in field.fieldOptions" class=row-fluid><label class="btn btn-info col-xs-3"><input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor}" type=checkbox value={{option.option_id}} ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled=field.disabled ng-init="field.fieldValue = field.fieldOptions[0].option_id"> <span ng-bind=option.option_value></span></label></div></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/date.html",'<div class="field row" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><div class="control-group input-append"><input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" ui-date=dateOptions ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled=field.disabled></div></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/dropdown.html",'<div class="field row dropdown" ng-click="setActiveField(field._id, index)" ng-if="field.fieldOptions.length > 0"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><select ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled=field.disabled ng-focus="setActiveField(field._id, index)"><option ng-repeat="option in field.fieldOptions" ng-selected="option.option_value == field.fieldValue" ng-value=option.option_value>{{option.option_value}}</option></select></div></div><br>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/email.html",'<div class="field row" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" type=email class=text-field-input placeholder=email@example.com value={{field.fieldValue}} ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled=field.disabled ng-focus="setActiveField(field._id, index)"></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/file.html",'<div class="field row" ng-if=form.autofillPDFs ng-click="setActiveField(field._id, index)"><div class="col-sm-4 field-title"><h5>{{field.title}} <span class=required-error ng-show="field.required && field.fieldValue == 0">(* required)</span></h5></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 selected files" class="btn btn-danger fileinput-remove fileinput-remove-button"><i class="glyphicon glyphicon-trash"></i> Delete</button> <button type=button ng-if=field.fileLoading title="Abort ongoing upload" class="btn btn-default" ng-click=cancelFileUpload(field)><i class="glyphicon glyphicon-ban-circle"></i> Cancel</button><div class="btn btn-success btn-file" ngf-select ngf-change=uploadPDF($files) ng-if=!field.file><i class="glyphicon glyphicon-upload"></i> Upload your File</div></div></div></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/hidden.html",'<input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" type=hidden ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" value={{field.fieldValue}} ng-disabled=field.disabled>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/legal.html",'<div class="field row radio legal" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3>{{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3><br><p style=color:#ddd>{{field.description}}</p></div><div class="col-xs-12 field-input container"><div class=row-fluid><label class="btn col-xs-5"><input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" type=radio value=true ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled="field.disabled"> <span>I accept</span></label><label class="btn col-xs-5 col-xs-offset-1"><input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" type=radio value=false ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled="field.disabled"> <span>I don\'t accept</span></label></div></div></div><br>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/link.html",'<div class="field row" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" type=url class=text-field-input placeholder=https://example.com/something value={{field.fieldValue}} ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled="field.disabled"></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/natural.html",'<div class="field row textfield natural" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" class=text-field-input ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" value=field.fieldValue ng-required=field.required ng-disabled=field.disabled></div><br><div class=col-xs-12><span ng-bind=field.fieldMatchValue></span></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/number.html",'<div class="field row" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" type=number class=text-field-input placeholder="" value={{field.fieldValue}} ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled=field.disabled ng-focus="setActiveField(field._id, index)"></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/password.html",'<div class="field row" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" type=password class=text-field-input ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" value={{field.fieldValue}} ng-required=field.required ng-disabled=field.disabled></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/radio.html",'<div class="field row radio" ng-click="setActiveField(field._id, index)" ng-if="field.fieldOptions.length > 0"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><div ng-repeat="option in field.fieldOptions" class=row-fluid><label class=btn style="margin: 0.5em; padding-left:30px" ng-class="{activeBtn: field.fieldValue == field.fieldOptions[$index].option_id}"><input ng-focus="setActiveField(field._id, index)" ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" type=radio value={{option.option_value}} ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled="field.disabled"> <span ng-bind=option.option_value></span></label></div></div></div><br>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/rating.html",'<div class="textfield field row" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><input-stars max=5 ng-focus="setActiveField(field._id, index)" icon-full=fa-star icon-base="fa fa-3x" icon-empty=fa-star-o ng-init="field.fieldValue = 1" ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled=field.disabled class=angular-input-stars></input-stars></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/statement.html",'<div class="statement field row" ng-click="setActiveField(field._id, index)"><div class="row field-title field-title"><div class=col-xs-1><i class="fa fa-quote-left fa-1"></i></div><h2 class="text-center col-xs-9">{{field.title}}</h2><div class=col-xs-1><i class="fa fa-quote-right fa-1"></i></div></div><div class="row field-title field-input"><p class=col-xs-12>{{field.description}}</p><br><button class="btn btn-info col-xs-6 col-xs-offset-3" style="font-size: 1.3em" ng-focus="setActiveField(field._id, index)" ng-click=nextField()>Continue</button></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/textarea.html",'<div class="field row" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><textarea class=textarea type=text ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" value={{field.fieldValue}} ng-required=field.required ng-disabled=field.disabled ng-focus="setActiveField(field._id, index)">\n </textarea></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/textfield.html",'<div class="textfield field row" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}" ng-style="{\'color\': design.colors.questionColor}"><h3><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3></div><div class="col-xs-12 field-input"><input ng-style="{\'color\': design.colors.answerColor, \'border-color\': design.colors.answerColor}" ng-focus="setActiveField(field._id, index)" class=text-field-input ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" value=field.fieldValue ng-required=field.required ng-disabled=field.disabled></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/field/yes_no.html",'<div class="field row radio" ng-click="setActiveField(field._id, index)"><div class="col-xs-12 field-title" ng-style="{\'color\': design.colors.questionColor}"><h3 class=row><span class="fa fa-angle-double-right"></span> {{field.title}} <span class=required-error ng-show="field.required && !field.fieldValue">*(required)</span></h3><p class=row>{{field.description}}</p></div><div class="col-xs-12 field-input"><div class=row-fluid><label class="btn btn-success col-xs-3"><input ng-focus="setActiveField(field._id, index)" type=radio value=true ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled=field.disabled ng-init="field.fieldValue = true"> <span>Yes</span></label><label class="btn btn-danger col-xs-3"><input ng-focus="setActiveField(field._id, index)" type=radio value=false ng-model=field.fieldValue ng-model-options="{ debounce: 250 }" ng-required=field.required ng-disabled="field.disabled"> <span>No</span></label></div></div></div><br>'),$templateCache.put("../public/modules/forms/views/directiveViews/form/configure-form.client.view.html",'<div class="config-form container"><div class=row><div class="col-md-6 col-sm-12 container"><div class=row><div class=col-sm-12><h2 class="hidden-sm hidden-xs">PDF Generation/EMR</h2><h3 class="hidden-lg hidden-md">PDF Generation/EMR</h3></div></div><div class="row field"><div class="field-title col-sm-6"><h5>Save Submissions as PDFs?</h5></div><div class="field-input col-sm-6"><label><input type=radio data-ng-value=true ng-model=myform.autofillPDFs ng-required="true"> <span>Yes</span></label><label><input type=radio data-ng-value=false ng-model=myform.autofillPDFs ng-required="true"> <span>No</span></label></div></div><div class="row field" ng-if="myform.autofillPDFs || myform.isGenerated"><div class="col-sm-6 field-title"><h5>Upload Your PDF Template</h5></div><div class="col-sm-6 field-input"><div class=input-group><div tabindex=-1 class="form-control file-caption"><span class=file-caption-ellipsis ng-if=!myform.pdf>…</span><div class=file-caption-name ng-if=myform.pdf>{{myform.pdf.originalname}}</div></div><div class=input-group-btn><button type=button ng-if=myform.pdf ng-click=removePDF(); title="Clear selected files" class="btn btn-danger fileinput-remove fileinput-remove-button"><i class="glyphicon glyphicon-trash"></i> Delete</button> <button type=button ng-if=pdfLoading title="Abort ongoing upload" class="btn btn-default" ng-click=cancelUpload()><i class="glyphicon glyphicon-ban-circle"></i> Cancel</button><div class="btn btn-success btn-file" ngf-select ngf-change=uploadPDF($files) ng-if=!myform.pdf><i class="glyphicon glyphicon-upload"></i> Upload your PDF</div></div></div></div></div><div class="row field"><div class="col-sm-6 field-title"><h5>Autogenerate Form?</h5></div><div class="col-sm-6 field-input"><label><input type=radio data-ng-value=true ng-model=myform.isGenerated ng-required="true"> <span>Yes</span></label><label><input type=radio data-ng-value=false ng-model=myform.isGenerated ng-required="true"> <span>No</span></label></div></div><div class="row field"><div class="field-title col-sm-6"><h5>Use Oscarhost API?</h5></div><div class="field-input col-sm-6"><label><input type=radio data-ng-value=true ng-model=oscarhostAPI ng-required="true"> <span>Yes</span></label><label><input type=radio data-ng-value=false ng-model=oscarhostAPI ng-required="true"> <span>No</span></label></div></div><div class="row field" ng-if=oscarhostAPI><div class="field-title col-sm-4"><h5>Oscarhost API Username</h5></div><div class=col-sm-8><input ng-model=myform.plugins.oscarhost.auth.user value={{myform.plugins.oscarhost.auth.user}} style="width: 100%" required></div></div><div class="row field" ng-if=oscarhostAPI><div class="field-title col-sm-4"><h5>Oscarhost API Password</h5></div><div class=col-sm-8><input type=password ng-model=myform.plugins.oscarhost.auth.pass value={{myform.plugins.oscarhost.auth.pass}} style="width: 100%" required></div></div><div class="row field" ng-if=oscarhostAPI><div class="field-title col-sm-4"><h5>Oscarhost API URL</h5></div><div class=col-sm-8><input type=link ng-model=myform.plugins.oscarhost.baseUrl value={{myform.plugins.oscarhost.baseUrl}} style="width: 100%" required></div></div><div class="row field" ng-if=oscarhostAPI><div class="field-title col-sm-4"><h5>Oscarhost API Update Type</h5></div><div class=col-sm-8><select ng-model=myform.plugins.oscarhost.settings.updateType><option ng-repeat="updateType in myform.plugins.oscarhost.settings.validUpdateTypes" ng-selected="myform.plugins.oscarhost.settings.updateType == updateType" ng-value=updateType>{{updateType}}</option></select></div></div></div><div class="col-sm-12 hidden-md hidden-lg"><br><hr></div><div class="col-md-5 col-md-offset-1 col-sm-12 container"><div class=row><div class=col-sm-12><h2 class="hidden-sm hidden-xs">Advanced Settings</h2><h3 class="hidden-lg hidden-md">Advanced Settings</h3></div></div><div class="row field"><div class="field-title col-sm-4"><h5>Form Name</h5></div><div class=col-sm-8><input ng-model=myform.title value={{myform.title}} style="width: 100%" ng-minlength=4 ng-pattern="/^[a-zA-Z0-9 \\-.]*$/"></div></div><div class="row field"><div class="field-title col-sm-6"><h5>Form Status</h5></div><div class="field-input col-sm-6"><label><input type=radio data-ng-value=true ng-model=myform.isLive ng-required=true style="background-color:#33CC00"> <span>Public</span></label><label><input type=radio data-ng-value=false ng-model=myform.isLive ng-required="true"> <span>Private</span></label></div></div><div class="row field"><div class="col-xs-6 field-title">Language</div><div class="col-xs-4 field-input"><select ng-model=myform.language><option ng-repeat="language in languages" ng-selected="language == myform.language" value={{language}}>{{language}}</option></select><span class=required-error ng-show="field.required && !field.fieldValue">* required</span></div></div><div class="row field"><div class="field-title col-sm-6"><h5>Display Form Footer?</h5></div><div class="field-input col-sm-6"><label><input type=radio data-ng-value=false ng-model=myform.hideFooter ng-required="true"> <span>Yes</span></label><label><input type=radio data-ng-value=true ng-model=myform.hideFooter ng-required="true"> <span>No</span></label></div></div><div class="row field"><div class="field-title col-sm-6"><h5>Display Start Page?</h5></div><div class="field-input col-sm-6"><label><input type=radio data-ng-value=true ng-model=myform.startPage.showStart ng-required=true style="background-color:#33CC00"> <span>Yes</span></label><label><input type=radio data-ng-value=false ng-model=myform.startPage.showStart ng-required="true"> <span>No</span></label></div></div></div></div><div class=row><div class="col-sm-offset-4 col-sm-2"><button class="btn btn-primary btn-large" type=button ng-click="update(false, null)"><i class="icon-arrow-left icon-white"></i> Save Changes</button></div><div class=col-sm-1><button class="btn btn-default" type=button ng-click=resetForm()><i class="icon-eye-open icon-white"></i> Cancel</button></div></div></div>'),
|
||
$templateCache.put("../public/modules/forms/views/directiveViews/form/edit-form.client.view.html",'<form class="row container" name=editForm auto-save-form auto-save-watch=myform auto-save-callback=update><div class="col-xs-2 col-sm-4 col-md-5 add-field"><div class="row add-field-title"><h3 class="col-md-12 hidden-sm hidden-xs">Click to Add New Field</h3><h4 class="col-sm-12 hidden-xs hidden-md hidden-lg">Add New Field<h5 class="col-sm-12 hidden-sm hidden-md hidden-lg">Add Field</h5></h4></div><div class="panel-group row" class=draggable ng-model=addField.types><div class="col-xs-12 col-sm-12 col-md-6" ng-repeat="type in addField.types" style=padding-top:7.5px><div class="panel panel-default" style=background-color:#f5f5f5><div class=panel-heading ng-click="addNewField(true, type.name)" style="cursor: pointer; font-size:14px"><span><field-icon-directive type-name={{type.name}}></field-icon-directive></span> <span class=hidden-xs style=padding-left:0.3em>{{type.value}}</span></div></div></div></div></div><div class="col-xs-10 col-sm-8 col-md-7 current-fields container"><div class=row><div class="col-sm-12 col-md-10"><div class="panel panel-default startPage"><div class="panel-heading accordion-toggle collapsed" data-toggle=collapse data-target=#collapseStart><h4 class=text-center>Start Page <span class=pull-right><i class="fa fa-chevron-right" ng-hide=startPage.isOpen></i> <i class="fa fa-chevron-down" ng-show=startPage.isOpen></i></span></h4></div><div id=collapseStart class="panel-collapse collapse"><div class=panel-body><div class="row hidden-sm hidden-xs"><div class=col-md-12><h4>Preview Start Page</h4></div><ul class="col-md-12 container" style="list-style:none;border:2px lightgray solid"><div class="field row"><div class="col-xs-12 text-center" style="overflow-wrap: break-word"><h1>{{myform.startPage.introTitle}}</h1></div><div class="col-xs-10 col-xs-offset-1 text-left" style="overflow-wrap: break-word"><p style=color:#ddd>{{myform.startPage.introParagraph}}</p></div></div><div class="row form-actions" style="padding-bottom:3em; padding-left: 1em; padding-right: 1em"><p ng-repeat="button in myform.startPage.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"><button ng-click=exitStartPage() class="btn btn-info col-md-8 col-md-offset-2 col-lg-4 col-lg-offset-4" type=button><a style="color:white; font-size: 1.6em; text-decoration: none">Continue to Form</a></button></div></ul></div><div class=row><div class=col-xs-12><h4>Edit Start Page</h4><br></div></div><div class="row question"><div class="col-md-4 col-sm-12">Intro Title:</div><div class="col-md-8 col-sm-12"><input ng-model=myform.startPage.introTitle name=introTitleStartPage value={{myform.startPage.introTitle}} required></div></div><div class="row question"><div class="col-md-4 col-sm-12">Intro Paragraph:</div><div class="col-md-8 col-sm-12"><textarea type=text ng-model=myform.startPage.introParagraph name="introParagraphStartPage">\n </div>\n </div>\n\n <div class=row><br><br></div>\n\n <div class="row options buttons">\n <div class="col-md-3 col-xs-12">Buttons:</div>\n <div class="col-md-9 col-xs-12">\n <div ng-repeat="button in myform.startPage.buttons track by button._id" class=row style=padding-bottom:1em>\n\n <div class=col-xs-5>\n <span>Text</span>\n <input name={{button.text}}_buttonText_startPage ng-model=button.text value={{button.text}} placeholder="Button Text">\n </div>\n\n\n <div class=col-xs-5>\n <span>Link</span>\n <input name={{button.url}}_url_startPage ng-model=button.url value={{button.url}} placeholder=http://aeouaou.com/aoeuoa>\n </div>\n\n <div class=col-xs-2> \n <a class="btn btn-danger btn-mini right" type=button ng-click=deleteButton(button)>\n <i class="fa fa-trash-o"></i>\n </a>\n </div>\n </div>\n\n <div class=row><br></div> \n <div class=row> \n <button class="btn btn-primary btn-small col-md-offset-6 col-md-6 col-sm-4 col-sm-offset-8 col-xs-4 col-xs-offset-8" type=button ng-click=addButton()>\n <i class="icon-plus icon-white"></i> Add Button\n </button>\n </div>\n </div>\n </div> \n </div>\n </div>\n </div>\n </div>\n </div>\n <div class=row>\n <div class="col-sm-12 col-md-10"><hr></div>\n </div>\n <div class=row>\n <div class="col-sm-12 col-md-8 dropzoneContainer">\n <accordion close-others=accordion.oneAtATime ui-sortable=dropzone ng-model=myform.form_fields class=dropzone>\n\n <accordion-group data-ng-repeat="field in myform.form_fields track by field._id" is-open=accordion[$index].isOpen on-finish-render=editFormFields ng-if=!field.deletePreserved>\n\n <accordion-heading>\n\n <div class=handle>\n\n <span class=pull-left ng-switch=field.fieldType>\n <field-icon-directive type-name={{field.fieldType}}></field-icon-directive>\n </span>\n <span style=padding-left:1.2em>\n {{field.title}} \n <span ng-show=field.required>*</span>\n </span>\n <span class=pull-right>\n <i class="fa fa-chevron-right" ng-hide=accordion[$index].isOpen>\n </i>\n <i class="fa fa-chevron-down" ng-show=accordion[$index].isOpen>\n </i>\n </span>\n </div>\n </accordion-heading>\n <div class="accordion-edit container">\n\n <div class="row hidden-sm hidden-xs">\n <div class=col-md-12>\n <h4>Preview Field</h4>\n </div>\n <ul class="col-md-12 container" style="list-style:none;border:2px lightgray solid">\n <field-directive field=field validate=false>\n </field-directive>\n </ul>\n <hr>\n </div>\n\n <div class=row>\n <div class=col-xs-12>\n <h4>Edit Field</h4>\n <br>\n </div>\n </div> \n\n <div class="row question">\n <div class="col-md-4 col-sm-12">Question Title:</div>\n <div class="col-md-8 col-sm-12">\n <input ng-model=field.title name=title{{field._id}} value={{field.title}} required></div>\n </div>\n\n <div class=row><br></div> \n\n <div class="row description">\n <div class="col-md-4 col-sm-12">Description:</div>\n <div class="col-md-8 col-sm-12"><textarea type=text ng-model=field.description name=description{{field._id}} value={{field.description}}></textarea> </div>\n </div>\n\n <div class=row ng-show=showAddOptions(field)><br></div>\n <div class="row options" ng-show=showAddOptions(field)>\n <div class="col-md-4 col-xs-12">Options:</div>\n <div class="col-md-8 col-xs-12">\n <div ng-repeat="option in field.fieldOptions track by option.option_id" class=row>\n <input name={{option.option_value}}{{field._id}} ng-model=option.option_value class=col-xs-5>\n\n <a class="btn btn-danger btn-mini right" type=button ng-click="deleteOption(field, option)" class=col-xs-3>\n <i class="fa fa-trash-o"></i>\n </a>\n </div>\n <div class=row> \n <button class="btn btn-primary btn-small col-md-offset-0 col-md-6 col-sm-4 col-sm-offset-4 col-xs-6 col-xs-offset-6" type=button ng-click=addOption(field)>\n <i class="icon-plus icon-white"></i> Add Option\n </button>\n </div>\n </div>\n </div>\n\n <div class=row><br></div> \n\n <div class=row>\n <div class="col-md-4 col-xs-12 field-title">Required:</div>\n <div class="col-md-8 col-xs-12 field-input">\n <label class="btn col-xs-5">\n <input type=radio ng-value=true ng-model=field.required name="required{{field._id}}">\n <span> Yes</span>\n </label>\n\n <label class="btn col-xs-5 col-xs-offset-1">\n <input type=radio ng-value=false ng-model=field.required name="required{{field._id}}">\n <span> No</span>\n </label>\n </div>\n </div>\n\n <div class=row>\n <div class="col-md-4 col-xs-12 field-input">Disabled:</div>\n <div class="col-md-8 col-xs-12 field-input">\n <label class="btn col-xs-5">\n <input type=radio ng-value=true ng-model=field.disabled name="disabled{{field._id}}">\n <span> Yes</span>\n </label>\n\n <label class="btn col-xs-5 col-xs-offset-1">\n <input type=radio ng-value=false ng-model=field.disabled name="disabled{{field._id}}">\n <span> No</span>\n </label>\n </div>\n </div>\n\n </div>\n </accordion-group>\n\n <div class="panel panel-default" style="border-style: dashed; border-color: #a9a9a9">\n <div class=panel-heading>\n <h4 class="panel-title text-center" style="color: #a9a9a9">\n Click on Fields to add them here\n </h4>\n </div>\n </div>\n\n <hr>\n </accordion>\n </div>\n\n <div class="col-md-1 hidden-xs hidden-sm" style="padding:0 5px">\n <div class="panel-group tool-panel text-center">\n <div class="panel panel-default" ng-repeat="field in myform.form_fields track by field._id" ng-if=!field.deletePreserved>\n <div class=panel-heading style="padding: 10px 10px; height: 37px" ng-click=deleteField($index)>\n <span class=text-center>\n <a href="" class="fa fa-trash-o"></a>\n </span>\n </div>\n </div>\n </div>\n </div>\n <div class="col-md-1 hidden-xs hidden-sm" style="padding:0 5px">\n <div class="panel-group tool-panel text-center">\n <div class="panel panel-default" ng-repeat="field in myform.form_fields track by field._id" ng-if=!field.deletePreserved>\n <div class=panel-heading style="padding: 10px 10px; height: 37px" ng-click=duplicateField($index)>\n <span class=text-center>\n <a href="" class="fa fa-files-o"></a>\n </span>\n </div>\n </div>\n </div>\n </div>\n\n <div class="col-md-2 hidden-xs hidden-sm" style="padding:0 5px" ng-if=myform.plugins.oscarhost.baseUrl>\n <div class="panel-group text-center">\n <div class="panel panel-default" ng-repeat="field in myform.form_fields track by field._id" ng-if=!field.deletePreserved style="border: none">\n \n <select ng-model=myform.plugins.oscarhost.settings.fieldMap[field._id] style=height:39.2px>\n <option value="">N/A</option>\n <option ng-repeat="oscarhost_field in oscarFieldsLeft(field._id)" ng-selected="oscarhost_field == myform.plugins.oscarhost.settings.fieldMap[field._id]" ng-value=oscarhost_field>\n {{oscarhost_field}}\n </option>\n </select> \n </div>\n </div>\n </div>\n </div>\n </div>\n\n</form>'),$templateCache.put("../public/modules/forms/views/directiveViews/form/edit-submissions-form.client.view.html",'<div class="submissions-table row container" ng-init=initFormSubmissions()><div class=row><div class=col-xs-2><button class="btn btn-danger" ng-click=deleteSelectedSubmissions() ng-disabled=!isAtLeastOneChecked();><i class="fa fa-trash-o"></i> Delete Selected</button></div><div class="col-xs-2 col-xs-offset-4 text-right"><button class="btn btn-default" ng-click="exportSubmissions(\'xls\')"><small>Export to Excel</small></button></div><div class="col-md-2 text-right"><button class="btn btn-default" ng-click="exportSubmissions(\'csv\')"><small>Export to CSV</small></button></div><div class="col-md-2 text-right"><button class="btn btn-default" ng-click="exportSubmissions(\'json\')"><small>Export to JSON</small></button></div></div><div class="row table-outer"><div class=col-xs-12><table id=table-submission-data class="table table-striped table-hover table-condensed"><thead><tr><th><input ng-model=table.masterChecker ng-change=toggleAllCheckers() type="checkbox"></th><th>#</th><th data-ng-repeat="(key, value) in myform.form_fields">{{value.title}}</th><th ng-if=myform.plugins.oscarhost.baseUrl>OscarEMR User Profile</th><th>Percentage Complete</th><th>Time Elapsed</th><th>Device</th><th>Location</th><th>IP Address</th><th>Date Submitted (UTC)</th><th ng-if=myform.autofillPDFs>Generated PDF</th></tr></thead><tbody><tr data-ng-repeat="row in table.rows" ng-click=rowClicked($index) ng-class="{selected: row.selected === true}"><td><input ng-model=row.selected type="checkbox"></td><th class=scope>{{$index+1}}</th><td data-ng-repeat="field in row.form_fields">{{field.fieldValue}}</td><td ng-if=myform.plugins.oscarhost.baseUrl><a href="{{myform.plugins.oscarhost.baseUrl.split(\'ws\')[0]}}demographic/demographiccontrol.jsp?demographic_no={{row.oscarDemoNum}}&displaymode=edit">User Profile #{{row.oscarDemoNum}}</a></td><td>{{row.percentageComplete}}%</td><td>{{row.timeElapsed}}</td><td>{{row.device.name}}, {{row.device.type}}</td><td>{{row.geoLocation.city}}, {{row.geoLocation.country}}</td><td>{{row.ipAddr}}</td><td>{{row.created | date:\'yyyy-MM-dd HH:mm:ss\'}}</td><td ng-if=row.pdf><a href={{row.pdfFilePath}} download={{row.pdf.name}} target=_self>Generated PDF</a></td></tr></tbody></table></div></div></div>'),$templateCache.put("../public/modules/forms/views/directiveViews/form/submit-form.client.view.html",'<section class="overlay submitform" ng-if=selected._id.length ng-click=hideOverlay()></section><div ng-show="!myform.submitted && myform.startPage.showStart" class=form-submitted><div class="field row"><div class="col-xs-12 text-center" style="overflow-wrap: break-word"><h1>{{myform.startPage.introTitle}}</h1></div><div class="col-xs-10 col-xs-offset-1 text-left" style="overflow-wrap: break-word"><p style=color:#ddd>{{myform.startPage.introParagraph}}</p></div></div><div class="row form-actions" style="padding-bottom:3em; padding-left: 1em; padding-right: 1em"><p ng-repeat="button in myform.startPage.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"><button ng-click=exitStartPage() class="btn btn-info col-md-8 col-md-offset-2 col-lg-4 col-lg-offset-4" type=button><a style="color:white; font-size: 1.6em; text-decoration: none">Continue to Form</a></button></div></div><div cg-busy="{promise:submitPromise,message:\'Submitting form...\',wrapperClass:\'busy-submitting-wrapper\',backdrop:true}" ng-show="!myform.submitted && !myform.startPage.showStart"><div class="field row" style=padding-bottom:5em><div class="col-sm-10 col-sm-offset-1"><h1>{{ myform.title }} <span style="font-size:0.8em; color: #bbb" ng-if=!myform.isLive>(private preview)</span></h1><hr></div></div><div class=row><form name=myForm class="submission-form col-sm-12 col-md-offset-1 col-md-10"><div ng-repeat="field in myform.form_fields" ng-if=!field.deletePreserved ng-class="{activeField: selected._id == field._id }" class="row field-directive"><field-directive field=field design=myform.design index=$index></field-directive></div></form></div><hr><div class="row form-actions"><button class="btn btn-success col-sm-2 col-sm-offset-5" type=button ng-disabled=myform.$invalid ng-click=submitForm() style="font-size: 1.6em">Submit</button></div><section ng-if=!myform.hideFooter class="navbar navbar-fixed-bottom hidden-xs" style="background-color:rgba(242,242,242,0.5); padding-top:15px"><div class=container><div class=row><div class="col-xs-4 col-xs-offset-4 col-sm-4 col-sm-offset-4 text-center col-md-3 col-md-offset-0" ng-show=!myform.submitted><p class=lead>{{myform | formValidity}} out of {{myform.visible_form_fields.length}} answered</p></div><div class="hidden-xs hidden-sm col-md-6 col-md-offset-3 row"><div class="col-md-4 col-md-offset-2" ng-if=!authentication.isAuthenticated()><a href=/#!/forms class="btn btn-default">Create a TellForm</a></div><div class="col-md-4 col-md-offset-2" ng-if=authentication.isAuthenticated() class="hidden-sm hidden-xs"><a href=/#!/forms/{{myform._id}}/admin/create class="btn btn-default">Edit this TellForm</a></div><div class="col-md-1 col-md-offset-2" style=padding-left:5px class="hidden-sm hidden-xs"><button class="btn btn-info" id=focusDownButton ng-click=nextField() ng-disabled="selected.index == myform.form_fields.length-1">\\/</button></div><div class=col-md-1 class="hidden-sm hidden-xs"><button class="btn btn-info" id=focusUpButton ng-click=prevField() ng-disabled="selected.index == 0">/\\</button></div></div></div></div></section></div><div ng-show=myform.submitted class=form-submitted><div class="field row text-center"><div class="col-xs-6 col-xs-offset-3 text-center">Form entry successfully submitted!</div></div><div class="row form-actions"><p class="text-center col-xs-4 col-xs-offset-4"><button ng-click=reloadForm() class="btn btn-info" type=button><a style="color:white; font-size: 1.6em; text-decoration: none">Go back to Form</a></button></p></div></div>'),$templateCache.put("../public/modules/users/views/authentication/access-denied.client.view.html",'<section class="row text-center auth"><h3 class=col-md-12>You need to be logged in to access this page</h3><a href=/#!/sigin class=col-md-12>Login</a></section>'),$templateCache.put("../public/modules/users/views/authentication/signin.client.view.html",'<section class="row auth" data-ng-controller=AuthenticationController><h3 class="col-md-12 text-center">Sign into your account</h3><div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6"><form class="signin form-horizontal" autocomplete=off><fieldset><div data-ng-show=error class="text-center text-danger">Error: <strong data-ng-bind=error></strong></div><div class=form-group><label for=username>Account Email</label><input id=username name=username class=form-control data-ng-model=credentials.username placeholder=Username></div><div class=form-group><label for=password>Password</label><input type=password id=password name=password class=form-control data-ng-model=credentials.password placeholder=Password></div><div class=forgot-password><a href=/#!/password/forgot>Forgot your password?</a></div><div class="text-center form-group"><button class="btn btn-primary" ng-click=signin()>Sign in</button> or <a href=/#!/signup>Sign up</a></div></fieldset></form></div></section>'),$templateCache.put("../public/modules/users/views/authentication/signup-success.client.view.html",'<section class="row auth signup-view success" data-ng-controller=AuthenticationController><h3 class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6 text-center">Signup Successful</h3><div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6"><h2>You\'ve successfully registered an account at TellForm.<br><br>But your account is <b>not activated yet</b></h2><br><br><p>Before you continue, make sure to check your email for our verification. If you don\'t receive it within 24h drop us a line at <a href=mail:hi@tellform.com>hi@TellForm.com</a></p><div class="text-center form-group"><button type=submit class="btn btn-large btn-primary"><a href="/#!/" style="color: white; text-decoration: none">Continue</a></button></div></div></section>'),$templateCache.put("../public/modules/users/views/authentication/signup.client.view.html",'<section class="row auth signup-view" data-ng-controller=AuthenticationController><h3 class="col-md-12 text-center">Signup with your email</h3><div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6"><form name=userForm data-ng-submit=signup() class="signin form-horizontal" novalidate autocomplete=off><fieldset><div data-ng-show=error id=signup_errors class="text-center text-danger">Couldn\'t submit form due to errors:<br><strong data-ng-bind=error></strong></div><div class=form-group><label for=firstName>First Name</label><input ng-pattern="/^[a-zA-Z0-9 \\-.]*$/" required id=firstName name=firstName class=form-control ng-model=credentials.firstName placeholder="First Name"></div><div class=form-group><label for=lastName>Last Name</label><input ng-pattern="/^[a-zA-Z0-9 \\-.]*$/" required id=lastName name=lastName class=form-control ng-model=credentials.lastName placeholder="Last Name"></div><hr><div class=form-group><label for=email>Email</label><input type=email id=email name=email class=form-control ng-model=credentials.email placeholder=Email></div><div class=form-group><label for=password>Password</label><input type=password id=password name=password class=form-control ng-model=credentials.password placeholder=Password></div><div class="text-center form-group"><button type=submit class="btn btn-large btn-primary">Sign up</button></div></fieldset></form></div></section>'),$templateCache.put("../public/modules/users/views/password/forgot-password.client.view.html",'<section class="auth row" data-ng-controller=PasswordController><h3 class="col-md-12 text-center">Restore your password</h3><p class="small text-center">Enter your account email.</p><div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6"><form data-ng-submit=askForPasswordReset() class="signin form-horizontal" autocomplete=off><fieldset><div class=form-group><input id=username name=username class=form-control data-ng-model=credentials.username placeholder=Username></div><div class="text-center form-group"><button type=submit class="btn btn-primary">Submit</button></div><div data-ng-show=error class="text-center text-danger"><strong>{{error}}</strong></div><div data-ng-show=success class="text-center text-success"><strong>{{success}}</strong></div></fieldset></form></div></section>'),$templateCache.put("../public/modules/users/views/password/reset-password-invalid.client.view.html",'<section class="row text-center"><h3 class=col-md-12>Password reset is invalid</h3><a href=/#!/password/forgot class=col-md-12>Ask for a new password reset</a></section>'),$templateCache.put("../public/modules/users/views/password/reset-password-success.client.view.html",'<section class="row text-center"><h3 class=col-md-12>Password successfully reset</h3><a href="/#!/" class=col-md-12>Continue to home page</a></section>'),$templateCache.put("../public/modules/users/views/password/reset-password.client.view.html",'<section class="row auth" data-ng-controller=PasswordController><h3 class="col-md-12 text-center">Reset your password</h3><div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6"><form data-ng-submit=resetUserPassword() class="signin form-horizontal" autocomplete=off><fieldset><div class=form-group><label for=newPassword>New Password</label><input type=password id=newPassword name=newPassword class=form-control data-ng-model=passwordDetails.newPassword placeholder="New Password"></div><div class=form-group><label for=verifyPassword>Verify Password</label><input type=password id=verifyPassword name=verifyPassword class=form-control data-ng-model=passwordDetails.verifyPassword placeholder="Verify Password"></div><div class="text-center form-group"><button type=submit class="btn btn-large btn-primary">Update Password</button></div><div data-ng-show=error class="text-center text-danger"><strong>{{error}}</strong></div><div data-ng-show=success class="text-center text-success"><strong>{{success}}</strong></div></fieldset></form></div></section>'),$templateCache.put("../public/modules/users/views/settings/change-password.client.view.html",'<section class="row auth" data-ng-controller=SettingsController><h3 class="col-md-12 text-center">Change your password</h3><div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6"><form data-ng-submit=changeUserPassword() class="signin form-horizontal" autocomplete=off><fieldset><div class=form-group><label for=currentPassword>Current Password</label><input type=password id=currentPassword name=currentPassword class=form-control data-ng-model=passwordDetails.currentPassword placeholder="Current Password"></div><hr><div class=form-group><label for=newPassword>New Password</label><input type=password id=newPassword name=newPassword class=form-control data-ng-model=passwordDetails.newPassword placeholder="New Password"></div><div class=form-group><label for=verifyPassword>Verify Password</label><input type=password id=verifyPassword name=verifyPassword class=form-control data-ng-model=passwordDetails.verifyPassword placeholder="Verify Password"></div><div class="text-center form-group"><button type=submit class="btn btn-large btn-primary">Save Password</button></div><div data-ng-show=success class="text-center text-success"><strong>Password Changed Successfully</strong></div><div data-ng-show=error class="text-center text-danger"><strong data-ng-bind=error></strong></div></fieldset></form></div></section>'),$templateCache.put("../public/modules/users/views/settings/edit-profile.client.view.html",'<section class="row auth" data-ng-controller=SettingsController><h3 class="col-xs-offset-1 col-xs-10 text-center">Edit your profile</h3><div class="col-xs-offset-3 col-xs-6"><form name=userForm data-ng-submit=updateUserProfile(userForm.$valid) class="signin form-horizontal" autocomplete=off><fieldset><div data-ng-show=success class="text-center text-success"><strong>Profile Saved Successfully</strong></div><div data-ng-show=error class="text-center text-danger">Couldn\'t Save Your Profile.<br>Error: <strong data-ng-bind=error></strong></div><div class="form-group row"><div class="col-xs-7 field-title"><b>First Name</b></div><div class="col-xs-12 field-input"><input id=firstName name=firstName class=form-control data-ng-model=user.firstName placeholder="First Name" ng-pattern="/^[a-zA-Z0-9 \\-.]*$/"></div></div><div class="form-group row"><div class="col-xs-7 field-title"><b>Last Name</b></div><div class="col-xs-12 field-input"><input id=lastName name=lastName class=form-control data-ng-model=user.lastName placeholder="Last Name" ng-pattern="/^[a-zA-Z0-9 \\-.]*$/"></div></div><div class=row><hr></div><div class="row form-group"><div class="col-xs-7 field-title"><b>Language</b></div><div class="col-xs-12 field-input"><select ng-model=user.language required><option ng-repeat="language in languages" ng-selected="language == user.language" value={{language}}>{{language}}</option></select></div></div><div class="row form-group"><div class="col-xs-7 field-title"><b>Email</b> <small>(also your username)</small></div><div class="col-xs-12 field-input"><input type=email id=email name=email class=form-control data-ng-model=user.email placeholder=Email></div></div><div class="text-center form-group"><button type=submit class="btn btn-large btn-primary" style=font-size:1.6em>Update Profile</button></div></fieldset></form></div></section>'),$templateCache.put("../public/modules/users/views/settings/social-accounts.client.view.html",'<section class="row auth" data-ng-controller=SettingsController><h3 class="col-md-12 text-center" data-ng-show=hasConnectedAdditionalSocialAccounts()>Connected social accounts:</h3><div class="col-md-12 text-center"><div data-ng-repeat="(providerName, providerData) in user.additionalProvidersData" class=remove-account-container><img ng-src=/modules/users/img/buttons/{{providerName}}.png> <a class="btn btn-danger btn-remove-account" data-ng-click=removeUserSocialAccount(providerName)><i class="glyphicon glyphicon-trash"></i></a></div></div><h3 class="col-md-12 text-center">Connect other social accounts:</h3><div class="col-md-12 text-center"><a href=/auth/facebook data-ng-hide="isConnectedSocialAccount(\'facebook\')" class=undecorated-link><img src=/modules/users/img/buttons/facebook.png></a> <a href=/auth/twitter data-ng-hide="isConnectedSocialAccount(\'twitter\')" class=undecorated-link><img src=/modules/users/img/buttons/twitter.png></a> <a href=/auth/google data-ng-hide="isConnectedSocialAccount(\'google\')" class=undecorated-link><img src=/modules/users/img/buttons/google.png></a> <a href=/auth/linkedin data-ng-hide="isConnectedSocialAccount(\'linkedin\')" class=undecorated-link><img src=/modules/users/img/buttons/linkedin.png></a> <a href=/auth/github data-ng-hide="isConnectedSocialAccount(\'github\')" class=undecorated-link><img src=/modules/users/img/buttons/github.png></a></div></section>'),
|
||
$templateCache.put("../public/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:hi@TellForm.com>hi@TellForm.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("../public/modules/users/views/verify/verify-account.client.view.html",'<section 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","colorpicker.module","ui.date","ui.sortable","angular-input-stars","users"]),ApplicationConfiguration.registerModule("users"),angular.module("core").config(["$stateProvider","$urlRouterProvider",function($stateProvider,$urlRouterProvider,Authorization){$urlRouterProvider.otherwise("/"),$stateProvider.state("home",{url:"/",templateUrl:"modules/core/views/home.client.view.html"})}]),angular.module("core").controller("HeaderController",["$rootScope","$scope","Menus","$state","Auth","User",function($rootScope,$scope,Menus,$state,Auth,User){$scope.user=$rootScope.user=Auth.ensureHasCurrentUser(User),$scope.authentication=$rootScope.authentication=Auth,$rootScope.languages=$scope.languages=["english","french","spanish"],$scope.isCollapsed=!1,$rootScope.hideNav=!1,$scope.menu=Menus.getMenu("topbar"),$scope.signout=function(){var promise=User.logout();promise.then(function(){Auth.logout(),Auth.ensureHasCurrentUser(User),$scope.user=$rootScope.user=null,$state.go("home")},function(reason){console.log("Logout Failed: "+reason)})},$scope.toggleCollapsibleMenu=function(){$scope.isCollapsed=!$scope.isCollapsed},$scope.$on("$stateChangeSuccess",function(event,toState,toParams,fromState,fromParams){$scope.isCollapsed=!1,$rootScope.hideNav=!1,angular.isDefined(toState.data)&&angular.isDefined(toState.data.hideNav)&&($rootScope.hideNav=toState.data.hideNav)})}]),angular.module("core").controller("HomeController",["$rootScope","$scope","User","$state",function($rootScope,$scope,User,$state){$scope=$rootScope}]),angular.module("core").service("Menus",[function(){this.defaultRoles=["*"],this.menus={};var shouldRender=function(user){if(!user)return this.isPublic;if(~this.roles.indexOf("*"))return!0;for(var userRoleIndex in user.roles)for(var roleIndex in this.roles)if(console.log(this.roles[roleIndex]),console.log(this.roles[roleIndex]===user.roles[userRoleIndex]),this.roles[roleIndex]===user.roles[userRoleIndex])return!0;return!1};this.validateMenuExistance=function(menuId){if(menuId&&menuId.length){if(this.menus[menuId])return!0;throw new Error("Menu does not exists")}throw new Error("MenuId was not provided")},this.getMenu=function(menuId){return this.validateMenuExistance(menuId),this.menus[menuId]},this.addMenu=function(menuId,isPublic,roles){return this.menus[menuId]={isPublic:isPublic||!1,roles:roles||this.defaultRoles,items:[],shouldRender:shouldRender},this.menus[menuId]},this.removeMenu=function(menuId){this.validateMenuExistance(menuId),delete this.menus[menuId]},this.addMenuItem=function(menuId,menuItemTitle,menuItemURL,menuItemType,menuItemUIRoute,isPublic,roles,position){return this.validateMenuExistance(menuId),this.menus[menuId].items.push({title:menuItemTitle,link:menuItemURL,menuItemType:menuItemType||"item",menuItemClass:menuItemType,uiRoute:menuItemUIRoute||"/"+menuItemURL,isPublic:null===isPublic||"undefined"==typeof isPublic?this.menus[menuId].isPublic:isPublic,roles:null===roles||"undefined"==typeof roles?this.menus[menuId].roles:roles,position:position||0,items:[],shouldRender:shouldRender}),this.menus[menuId]},this.addSubMenuItem=function(menuId,rootMenuItemURL,menuItemTitle,menuItemURL,menuItemUIRoute,isPublic,roles,position){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)this.menus[menuId].items[itemIndex].link===rootMenuItemURL&&this.menus[menuId].items[itemIndex].items.push({title:menuItemTitle,link:menuItemURL,uiRoute:menuItemUIRoute||"/"+menuItemURL,isPublic:null===isPublic||"undefined"==typeof isPublic?this.menus[menuId].items[itemIndex].isPublic:isPublic,roles:null===roles||"undefined"==typeof roles?this.menus[menuId].items[itemIndex].roles:roles,position:position||0,shouldRender:shouldRender});return this.menus[menuId]},this.removeMenuItem=function(menuId,menuItemURL){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)this.menus[menuId].items[itemIndex].link===menuItemURL&&this.menus[menuId].items.splice(itemIndex,1);return this.menus[menuId]},this.removeSubMenuItem=function(menuId,submenuItemURL){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)for(var subitemIndex in this.menus[menuId].items[itemIndex].items)this.menus[menuId].items[itemIndex].items[subitemIndex].link===submenuItemURL&&this.menus[menuId].items[itemIndex].items.splice(subitemIndex,1);return this.menus[menuId]},this.addMenu("topbar",!1,["*"]),this.addMenu("bottombar",!1,["*"])}]),angular.module("forms").run(["Menus",function(Menus){Menus.addMenuItem("topbar","My Forms","forms","","/forms",!1)}]).filter("formValidity",function(){return function(formObj){if(formObj&&formObj.form_fields&&formObj.visible_form_fields){var formKeys=Object.keys(formObj),fields=(formKeys.filter(function(key){return"$"!==key[0]}),formObj.form_fields),valid_count=fields.filter(function(field){return"object"==typeof field?"rating"===field.fieldType||"statement"===field.fieldType?!0:!!field.fieldValue:void 0}).length;return valid_count-(formObj.form_fields.length-formObj.visible_form_fields.length)}return 0}}).config(["$provide",function($provide){$provide.decorator("accordionDirective",["$delegate",function($delegate){var directive=$delegate[0];return directive.replace=!0,$delegate}])}]),angular.module("forms").config(["$stateProvider",function($stateProvider){$stateProvider.state("listForms",{url:"/forms",templateUrl:"modules/forms/views/list-forms.client.view.html",data:{permissions:["editForm"]}}).state("submitForm",{url:"/forms/:formId",templateUrl:"modules/forms/views/submit-form.client.view.html",data:{hideNav:!0},resolve:{Forms:"Forms",myForm:["Forms","$stateParams",function(Forms,$stateParams){return Forms.get({formId:$stateParams.formId}).$promise}]},controller:"SubmitFormController"}).state("viewForm",{url:"/forms/:formId/admin",templateUrl:"modules/forms/views/admin-form.client.view.html",data:{permissions:["editForm"]},resolve:{Forms:"Forms",myForm:["Forms","$stateParams",function(Forms,$stateParams){return Forms.get({formId:$stateParams.formId}).$promise}]},controller:"AdminFormController"}).state("viewForm.configure",{url:"/configure",templateUrl:"modules/forms/views/adminTabs/configure.html"}).state("viewForm.design",{url:"/design",templateUrl:"modules/forms/views/adminTabs/design.html"}).state("viewForm.analyze",{url:"/analyze",templateUrl:"modules/forms/views/adminTabs/analyze.html"}).state("viewForm.create",{url:"/create",templateUrl:"modules/forms/views/adminTabs/create.html"})}]),angular.module("forms").controller("AdminFormController",["$rootScope","$scope","$stateParams","$state","Forms","CurrentForm","$http","$uibModal","myForm",function($rootScope,$scope,$stateParams,$state,Forms,CurrentForm,$http,$uibModal,myForm){$scope=$rootScope,$scope.animationsEnabled=!0,$scope.myform=myForm,$rootScope.saveInProgress=!1,CurrentForm.setForm($scope.myform),$scope.tabData=[{heading:"Create",route:"viewForm.create"},{heading:"Design",route:"viewForm.design"},{heading:"Configure",route:"viewForm.configure"},{heading:"Analyze",route:"viewForm.analyze"}],$scope.setForm=function(form){$scope.myform=form},$rootScope.resetForm=function(){$scope.myform=Forms.get({formId:$stateParams.formId})},$scope.openDeleteModal=function(){$scope.deleteModal=$uibModal.open({animation:$scope.animationsEnabled,templateUrl:"myModalContent.html",controller:"AdminFormController",resolve:{myForm:function(){return $scope.myform}}}),$scope.deleteModal.result.then(function(selectedItem){$scope.selected=selectedItem},function(){console.log("Modal dismissed at: "+new Date)})},$scope.cancelDeleteModal=function(){$scope.deleteModal&&$scope.deleteModal.dismiss("cancel")},$scope.removeCurrentForm=function(){if($scope.deleteModal&&$scope.deleteModal.opened){$scope.deleteModal.close();var form_id=$scope.myform._id;if(!form_id)throw new Error("Error - removeCurrentForm(): $scope.myform._id does not exist");$http["delete"]("/forms/"+form_id).success(function(data,status,headers){console.log("form deleted successfully"),$state.go("listForms",{},{reload:!0})}).error(function(error){console.log("ERROR: Form could not be deleted."),console.error(error)})}},$scope.update=$rootScope.update=function(updateImmediately,cb){var continueUpdate=!0;if(updateImmediately||(continueUpdate=!$rootScope.saveInProgress),continueUpdate){var err=null;updateImmediately||($rootScope.saveInProgress=!0),$scope.updatePromise=$http.put("/forms/"+$scope.myform._id,{form:$scope.myform}).then(function(response){$rootScope.myform=$scope.myform=response.data})["catch"](function(response){console.log("Error occured during form UPDATE.\n"),err=response.data})["finally"](function(){updateImmediately||($rootScope.saveInProgress=!1),"function"==typeof cb&&cb(err)})}}}]),angular.module("forms").controller("ListFormsController",["$rootScope","$scope","$stateParams","$state","Forms","CurrentForm","$http",function($rootScope,$scope,$stateParams,$state,Forms,CurrentForm,$http){$scope=$rootScope,$scope.forms={},$scope.showCreateModal=!1,$scope.findAll=function(){Forms.query(function(_forms){$scope.myforms=_forms})},$scope.openCreateModal=function(){$scope.showCreateModal||($scope.showCreateModal=!0)},$scope.closeCreateModal=function(){$scope.showCreateModal&&($scope.showCreateModal=!1)},$scope.setForm=function(form){$scope.myform=form},$scope.goToWithId=function(route,id){$state.go(route,{formId:id},{reload:!0})},$scope.duplicateForm=function(form_index){var form=_.cloneDeep($scope.myforms[form_index]);delete form._id,$http.post("/forms",{form:form}).success(function(data,status,headers){$scope.myforms.splice(form_index+1,0,data)}).error(function(errorResponse){console.error(errorResponse),null===errorResponse&&($scope.error=errorResponse.data.message)})},$scope.createNewForm=function(){var form={};form.title=$scope.forms.createForm.title.$modelValue,form.language=$scope.forms.createForm.language.$modelValue,$scope.forms.createForm.$valid&&$scope.forms.createForm.$dirty&&$http.post("/forms",{form:form}).success(function(data,status,headers){console.log("new form created"),$scope.goToWithId("viewForm.create",data._id+"")}).error(function(errorResponse){console.error(errorResponse),$scope.error=errorResponse.data.message})},$scope.removeForm=function(form_index){if(form_index>=$scope.myforms.length||0>form_index)throw new Error("Error: form_index in removeForm() must be between 0 and "+$scope.myforms.length-1);$http["delete"]("/forms/"+$scope.myforms[form_index]._id).success(function(data,status,headers){console.log("form deleted successfully"),$scope.myforms.splice(form_index,1)}).error(function(error){console.log("ERROR: Form could not be deleted."),console.error(error)})}}]),angular.module("forms").controller("SubmitFormController",["$scope","$rootScope","$state","myForm","Auth",function($scope,$rootScope,$state,myForm,Auth){$scope.authentication=Auth,$scope.myform=myForm,$scope.myform.isLive?$scope.hideNav=$rootScope.hideNav=!0:$scope.authentication.isAuthenticated()?$scope.hideNav=$rootScope.hideNav=!1:($scope.hideNav=$rootScope.hideNav=!0,$state.go("access_denied"))}]),_.mixin({removeDateFields:function(o){for(var clone=_.clone(o),i=0;i<clone.length;i++)_.each(clone[i],function(v,k){"lastModified"!==k&&"created"!==k||delete clone[i][k]});return clone}}),angular.module("forms").directive("autoSaveForm",["$rootScope","$timeout",function($rootScope,$timeout){return{require:["^form"],restrict:"AE",link:function($scope,$element,$attrs,$ctrls){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)):(console.log("\n\nForm data persisted -- setting pristine flag"),$formCtrl.$setPristine(),$formCtrl.$setUntouched())})};$scope.$watch(function(newValue,oldValue){console.log("introParagraphStartPage.$dirty: "+$scope.editForm.introParagraphStartPage.$dirty),console.log("introParagraphStartPage.$touched: "+$scope.editForm.introParagraphStartPage.$touched),$rootScope.finishedRender&&$scope.anyDirtyAndTouched($scope.editForm)&&!$rootScope.saveInProgress&&(console.log("Form saving started"),debounceSave(),console.log("introParagraphStartPage.$dirty AFTER: "+$scope.editForm.introParagraphStartPage.$dirty))}),$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/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(files){if(files&&files.length){var file=files[0];console.log(file),this._current_upload=Upload.upload({url:"/upload/pdf",fields:{user:$scope.user,form:$scope.myform},file:file}).progress(function(evt){var progressPercentage=parseInt(100*evt.loaded/evt.total);$scope.log="progress: "+progressPercentage+"% "+evt.config.file.name+"\n"+$scope.log,$scope.pdfLoading=!0}).success(function(data,status,headers,config){$scope.log="file "+data.originalname+" uploaded as "+data.name+". 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()}).error(function(err){$scope.pdfLoading=!1,console.log("Error occured during upload.\n"),console.log(err)})}}}]}}]),angular.module("forms").directive("editFormDirective",["$rootScope","FormFields",function($rootScope,FormFields){return{templateUrl:"modules/forms/views/directiveViews/form/edit-form.client.view.html",restrict:"E",scope:{myform:"="},controller:["$scope",function($scope){for(var field_ids=_($scope.myform.form_fields).pluck("_id"),i=0;i<field_ids.length;i++)$scope.myform.plugins.oscarhost.settings.fieldMap[field_ids[i]]=null;$scope.addField={},$scope.addField.types=FormFields.types,$scope.addField.types.forEach(function(type){return type.lastAddedID=1,type}),$scope.lastButtonID=0,$scope.accordion={},$scope.accordion.oneAtATime=!0,$scope.update=$rootScope.update,$scope.oscarFieldsLeft=function(field_id){if($scope.myform&&$scope.myform.plugins.oscarhost.settings.validFields.length>0){$scope.myform.plugins.oscarhost.settings.fieldMap||($scope.myform.plugins.oscarhost.settings.fieldMap={});var oscarhostFields=$scope.myform.plugins.oscarhost.settings.validFields,currentFields=_($scope.myform.plugins.oscarhost.settings.fieldMap).invert().keys().value();return $scope.myform.plugins.oscarhost.settings.fieldMap.hasOwnProperty(field_id)&&(currentFields=_(currentFields).difference($scope.myform.plugins.oscarhost.settings.fieldMap[field_id])),_(oscarhostFields).difference(currentFields).value()}return[]},$scope.dropzone={handle:" .handle",containment:".dropzoneContainer",cursor:"grabbing"},$scope.addNewField=function(modifyForm,fieldType){$scope.addField.lastAddedID++;for(var fieldTitle,i=0;i<$scope.addField.types.length;i++)if($scope.addField.types[i].name===fieldType){$scope.addField.types[i].lastAddedID++,fieldTitle=$scope.addField.types[i].value+$scope.addField.types[i].lastAddedID;break}var newField={title:fieldTitle,fieldType:fieldType,fieldValue:"",required:!0,disabled:!1,deletePreserved:!1};return modifyForm&&$scope.myform.form_fields.push(newField),newField},$scope.deleteField=function(field_index){var currFieldId=$scope.myform.form_fields[field_index]._id;$scope.myform.hasOwnProperty("plugins.oscarhost.baseUrl")&&delete $scope.myform.plugins.oscarhost.settings.fieldMap[currFieldId],$scope.myform.form_fields.splice(field_index,1)},$scope.duplicateField=function(field_index){var currField=_.cloneDeep($scope.myform.form_fields[field_index]);currField._id="cloned"+_.uniqueId(),currField.title+=" copy",$scope.myform.form_fields.splice(field_index+1,0,currField)},$scope.addButton=function(){var newButton={};newButton.bgColor="#ddd",newButton.color="#ffffff",newButton.text="Button",newButton._id=Math.floor(1e5*Math.random()),$scope.myform.startPage.buttons.push(newButton)},$scope.deleteButton=function(button){for(var currID,i=0;i<$scope.myform.startPage.buttons.length;i++)if(currID=$scope.myform.startPage.buttons[i]._id,console.log(currID),currID===button._id){$scope.myform.startPage.buttons.splice(i,1);break}},$scope.addOption=function(field_index){var currField=$scope.myform.form_fields[field_index];if("checkbox"===currField.fieldType||"dropdown"===currField.fieldType||"radio"===currField.fieldType){currField.fieldOptions||($scope.myform.form_fields[field_index].fieldOptions=[]);var lastOptionID=0;currField.fieldOptions[currField.fieldOptions.length-1]&&(lastOptionID=currField.fieldOptions[currField.fieldOptions.length-1].option_id);var newOption={option_id:Math.floor(1e5*Math.random()),option_title:"Option "+lastOptionID,option_value:"Option "+lastOptionID};$scope.myform.form_fields[field_index].fieldOptions.push(newOption)}},$scope.deleteOption=function(field_index,option){var currField=$scope.myform.form_fields[field_index];if("checkbox"===currField.fieldType||"dropdown"===currField.fieldType||"radio"===currField.fieldType)for(var i=0;i<currField.fieldOptions.length;i++)if(currField.fieldOptions[i].option_id===option.option_id){$scope.myform.form_fields[field_index].fieldOptions.splice(i,1);break}},$scope.showAddOptions=function(field){return"dropdown"===field.fieldType||"checkbox"===field.fieldType||"radio"===field.fieldType}}]}}]),angular.module("forms").directive("editSubmissionsFormDirective",["$rootScope","$http",function($rootScope,$http){return{templateUrl:"modules/forms/views/directiveViews/form/edit-submissions-form.client.view.html",restrict:"E",scope:{myform:"=",user:"="},controller:["$scope",function($scope){$scope.table={masterChecker:!1,rows:[]},$scope.isAtLeastOneChecked=function(){for(var i=0;i<$scope.table.rows.length;i++)if($scope.table.rows[i].selected)return!0;return!1},$scope.toggleAllCheckers=function(){for(var i=0;i<$scope.table.rows.length;i++)$scope.table.rows[i].selected=$scope.table.masterChecker},$scope.toggleObjSelection=function($event,description){$event.stopPropagation()},$scope.rowClicked=function(row_index){$scope.table.rows[row_index].selected=!$scope.table.rows[row_index].selected},$scope.initFormSubmissions=function(){$http.get("/forms/"+$scope.myform._id+"/submissions").success(function(data,status,headers){for(var defaultFormFields=_.cloneDeep($scope.myform.form_fields),i=0;i<data.length;i++){for(var x=0;x<data[i].form_fields;x++)oldValue=data[i].form_fields[x].fieldValue||"",data[i].form_fields[x]=_.merge(defaultFormFields,data[i].form_fields),data[i].form_fields[x].fieldValue=oldValue;data[i].selected=!1}$scope.table.rows=data}).error(function(err){console.error("Could not fetch form submissions.\nError: "+err)})},$scope.deleteSelectedSubmissions=function(){var delete_ids=_.chain($scope.table.rows).filter(function(row){return!!row.selected}).pluck("_id").value();$http({url:"/forms/"+$scope.myform._id+"/submissions",method:"DELETE",data:{deleted_submissions:delete_ids},headers:{"Content-Type":"application/json;charset=utf-8"}}).success(function(data,status,headers){for(var tmpArray=[],i=0;i<$scope.table.rows.length;i++)$scope.table.rows[i].selected||tmpArray.push($scope.table.rows[i]);$scope.table.rows=tmpArray}).error(function(err){console.log("Could not delete form submissions.\nError: "),console.log(err),console.error=err})},$scope.exportSubmissions=function(type){var fileMIMETypeMap={xls:"vnd.openxmlformats-officedocument.spreadsheetml.sheet",json:"json",csv:"csv"},blob=new Blob([document.getElementById("table-submission-data").innerHTM],{type:"application/"+fileMIMETypeMap[type]+";charset=utf-8"});saveAs(blob,$scope.myform.title+"_sumbissions_export_"+Date.now()+"."+type)}}]}}]),angular.module("forms").directive("fieldIconDirective",function(){return{template:'<i class="{{typeIcon}}"></i>',restrict:"E",scope:{typeName:"@"},controller:["$scope",function($scope){var iconTypeMap={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"};$scope.typeIcon=iconTypeMap[$scope.typeName]}]}});var __indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};angular.module("forms").directive("fieldDirective",["$http","$compile","$rootScope","$templateCache",function($http,$compile,$rootScope,$templateCache){var getTemplateUrl=function(field){var type=field.fieldType,templateUrl="modules/forms/views/directiveViews/field/",supported_fields=["textfield","email","textarea","checkbox","date","link","dropdown","hidden","password","radio","legal","statement","rating","yes_no","number","natural"];return __indexOf.call(supported_fields,type)>=0&&(templateUrl=templateUrl+type+".html"),$templateCache.get("../public/"+templateUrl)};return{template:"<div>{{field.title}}</div>",restrict:"E",scope:{field:"=",required:"&",design:"=",index:"="},link:function(scope,element){scope.setActiveField=$rootScope.setActiveField,"date"===scope.field.fieldType&&(scope.dateOptions={changeYear:!0,changeMonth:!0,altFormat:"mm/dd/yyyy",yearRange:"1900:-0",defaultDate:0});var template=getTemplateUrl(scope.field);element.html(template).show(),$compile(element.contents())(scope)}}}]),angular.module("forms").directive("onFinishRender",["$rootScope","$timeout",function($rootScope,$timeout){return{restrict:"A",link:function(scope,element,attrs){if(element.attr("ng-repeat")||element.attr("data-ng-repeat")){var broadcastMessage=attrs.onFinishRender||"ngRepeat";scope.$first&&!scope.$last?scope.$evalAsync(function(){$rootScope.$broadcast(broadcastMessage+" Started")}):scope.$last&&scope.$evalAsync(function(){$rootScope.$broadcast(broadcastMessage+" Finished")})}}}}]),angular.module("forms").directive("submitFormDirective",["$http","TimeCounter","$filter","$rootScope","Auth",function($http,TimeCounter,$filter,$rootScope,Auth){return{templateUrl:"modules/forms/views/directiveViews/form/submit-form.client.view.html",restrict:"E",scope:{myform:"="},controller:["$scope",function($scope){$scope.authentication=$rootScope.authentication,$scope.reloadForm=function(){$scope.myform.submitted=!1,$scope.myform.form_fields=_.chain($scope.myform.form_fields).map(function(field){return field.fieldValue="",field}).value(),$scope.error="",$scope.selected={_id:"",index:null},TimeCounter.restartClock()},$rootScope.setActiveField=function(field_id,field_index){null===$scope.selected&&($scope.selected={_id:"",index:0}),console.log("field_id: "+field_id),console.log("field_index: "+field_index),console.log($scope.selected),$scope.selected._id=field_id,$scope.selected.index=field_index,setTimeout(function(){$("html, body").animate({scrollTop:$(".activeField").offset().top},200)},10)},$scope.nextField=function(){$scope.selected.index<$scope.myform.form_fields.length-1&&($scope.selected.index++,$scope.selected._id=$scope.myform.form_fields[$scope.selected.index]._id,$rootScope.setActiveField($scope.selected._id,$scope.selected.index))},$scope.prevField=function(){$scope.selected.index>0&&($scope.selected.index=$scope.selected.index-1,$scope.selected._id=$scope.myform.form_fields[$scope.selected.index]._id,$rootScope.setActiveField($scope.selected._id,$scope.selected.index))},$scope.hideOverlay=function(){$scope.selected={_id:"",index:null}},$scope.exitStartPage=function(){$scope.myform.startPage.showStart=!1,$scope.myform.form_fields.length>0&&($scope.selected._id=$scope.myform.form_fields[0]._id)},$scope.submitForm=function(){var _timeElapsed=TimeCounter.stopClock(),form=_.cloneDeep($scope.myform);form.timeElapsed=_timeElapsed,form.percentageComplete=$filter("formValidity")($scope.myform)/$scope.myform.visible_form_fields.length*100,delete form.visible_form_fields,$scope.submitPromise=$http.post("/forms/"+$scope.myform._id,form).success(function(data,status,headers){console.log("form submitted successfully"),$scope.myform.submitted=!0}).error(function(error){console.log(error),$scope.error=error.message})},angular.element(document).ready(function(){$scope.reloadForm()})}]}}]),angular.module("forms").service("CurrentForm",function(){var _form={};this.getForm=function(){return _form},this.setForm=function(form){_form=form}}),angular.module("forms").service("FormFields",[function(){this.types=[{name:"textfield",value:"Short Text"},{name:"email",value:"Email"},{name:"radio",value:"Multiple Choice"},{name:"dropdown",value:"Dropdown"},{name:"date",value:"Date"},{name:"textarea",value:"Paragraph Text"},{name:"checkbox",value:"Checkbox"},{name:"yes_no",value:"Yes/No"},{name:"legal",value:"Legal"},{name:"rating",value:"Rating"},{name:"link",value:"Link"},{name:"number",value:"Numbers"},{name:"statement",value:"Statement"}]}]),angular.module("forms").factory("Forms",["$resource",function($resource){return $resource("/forms/:formId",{formId:"@_id"},{query:{method:"GET",isArray:!0},get:{method:"GET",transformResponse:function(data,header){var form=angular.fromJson(data);return console.log(form),form.visible_form_fields=_.filter(form.form_fields,function(field){return field.deletePreserved===!1}),form}},update:{method:"PUT"},save:{method:"POST"}})}]),angular.module("forms").factory("Submissions",["$resource",function($resource){return $resource("forms/:formID/submissions/:submissionId",{submissionId:"@_id",formId:"@_id"},{query:{method:"GET",isArray:!0},update:{method:"PUT"},save:{method:"POST"}})}]),angular.module("forms").service("TimeCounter",[function(){var _startTime,_endTime,that=this;this.timeSpent=0,this.restartClock=function(){_startTime=Date.now(),_endTime=_startTime},this.stopClock=function(){return _startTime?(_endTime=Date.now(),that.timeSpent=Math.abs(_endTime.valueOf()-_startTime.valueOf())/1e3,that.timeSpent):new Error("Clock has not been started")},this.clockStarted=function(){return!!this._startTime}}]),angular.module("users").config(["$httpProvider",function($httpProvider){$httpProvider.interceptors.push(["$q","$location",function($q,$location){return{responseError:function(response){return"/users/me"!==$location.path()&&response.config&&"/users/me"!==response.config.url&&(console.log("intercepted rejection of ",response.config.url,response.status),401===response.status?($location.nextAfterLogin=$location.path(),$location.path("/signin")):403===response.status&&$location.path("/access_denied")),$q.reject(response)}}}])}]),angular.module("users").config(["$stateProvider",function($stateProvider){var checkLoggedin=function($q,$timeout,$state,User,Auth){var deferred=$q.defer();return Auth.currentUser&&Auth.currentUser.email?$timeout(deferred.resolve):Auth.currentUser=User.getCurrent(function(){Auth.login(),$timeout(deferred.resolve())},function(){Auth.logout(),$timeout(deferred.reject()),$state.go("sigin",{reload:!0})}),deferred.promise};checkLoggedin.$inject=["$q","$timeout","$state","User","Auth"],$stateProvider.state("profile",{resolve:{loggedin:checkLoggedin},url:"/settings/profile",templateUrl:"modules/users/views/settings/edit-profile.client.view.html"}).state("password",{resolve:{loggedin:checkLoggedin},url:"/settings/password",templateUrl:"modules/users/views/settings/change-password.client.view.html"}).state("accounts",{resolve:{loggedin:checkLoggedin},url:"/settings/accounts",
|
||
templateUrl:"modules/users/views/settings/social-accounts.client.view.html"}).state("signup",{url:"/signup",templateUrl:"modules/users/views/authentication/signup.client.view.html"}).state("signup-success",{url:"/signup-success",templateUrl:"modules/users/views/authentication/signup-success.client.view.html"}).state("signin",{url:"/signin",templateUrl:"modules/users/views/authentication/signin.client.view.html"}).state("access_denied",{url:"/access_denied",templateUrl:"modules/users/views/authentication/access-denied.client.view.html"}).state("resendVerifyEmail",{url:"/verify",templateUrl:"modules/users/views/verify/resend-verify-email.client.view.html"}).state("verify",{url:"/verify/:token",templateUrl:"modules/users/views/verify/verify-account.client.view.html"}).state("forgot",{url:"/password/forgot",templateUrl:"modules/users/views/password/forgot-password.client.view.html"}).state("reset-invalid",{url:"/password/reset/invalid",templateUrl:"modules/users/views/password/reset-password-invalid.client.view.html"}).state("reset-success",{url:"/password/reset/success",templateUrl:"modules/users/views/password/reset-password-success.client.view.html"}).state("reset",{url:"/password/reset/:token",templateUrl:"modules/users/views/password/reset-password.client.view.html"})}]),angular.module("users").controller("AuthenticationController",["$scope","$location","$state","$rootScope","User","Auth",function($scope,$location,$state,$rootScope,User,Auth){$scope=$rootScope,$scope.credentials={},$scope.error="",$scope.signin=function(){$scope.credentials.email=$scope.credentials.username,User.login($scope.credentials).then(function(response){Auth.login(response),$scope.user=$rootScope.user=Auth.ensureHasCurrentUser(User),"home"!==$state.previous.name&&"verify"!==$state.previous.name&&""!==$state.previous.name?$state.go($state.previous.name):$state.go("listForms")},function(error){$rootScope.user=Auth.ensureHasCurrentUser(User),$scope.user=$rootScope.user,$scope.error=error,console.log("loginError: "+error)})},$scope.signup=function(){console.log($scope.credentials),User.signup($scope.credentials).then(function(response){console.log("signup-success"),$state.go("signup-success")},function(error){console.log("Error: "),console.log(error),error?($scope.error=error,console.log(error)):console.log("No response received")})}}]),angular.module("users").controller("PasswordController",["$scope","$stateParams","$state","User",function($scope,$stateParams,$state,User){$scope.error="",$scope.askForPasswordReset=function(){User.askForPasswordReset($scope.credentials).then(function(response){$scope.success=response.message,$scope.credentials=null},function(error){$scope.error=error,$scope.credentials=null})},$scope.resetUserPassword=function(){$scope.success=$scope.error=null,User.resetPassword($scope.passwordDetails,$stateParams.token).then(function(response){$scope.success=response.message,$scope.passwordDetails=null,$state.go("reset-success")},function(error){$scope.error=error.message||error,$scope.passwordDetails=null})}}]),angular.module("users").controller("SettingsController",["$scope","$rootScope","$http","$state","Users",function($scope,$rootScope,$http,$state,Users){$scope.user=$rootScope.user,$scope.hasConnectedAdditionalSocialAccounts=function(provider){for(var i in $scope.user.additionalProvidersData)return!0;return!1},$scope.isConnectedSocialAccount=function(provider){return $scope.user.provider===provider||$scope.user.additionalProvidersData&&$scope.user.additionalProvidersData[provider]},$scope.removeUserSocialAccount=function(provider){$scope.success=$scope.error=null,$http["delete"]("/users/accounts",{params:{provider:provider}}).success(function(response){$scope.success=!0,$scope.user=response}).error(function(response){$scope.error=response.message})},$scope.updateUserProfile=function(isValid){if(isValid){$scope.success=$scope.error=null;var user=new Users($scope.user);user.$update(function(response){$scope.success=!0,$scope.user=response},function(response){$scope.error=response.data.message})}else $scope.submitted=!0},$scope.changeUserPassword=function(){$scope.success=$scope.error=null,$http.post("/users/password",$scope.passwordDetails).success(function(response){$scope.success=!0,$scope.passwordDetails=null}).error(function(response){$scope.error=response.message})}}]),angular.module("users").controller("VerifyController",["$scope","$state","$rootScope","User","Auth","$stateParams",function($scope,$state,$rootScope,User,Auth,$stateParams){$scope.isResetSent=!1,$scope.credentials={},$scope.error="",$scope.resendVerifyEmail=function(){User.resendVerifyEmail($scope.credentials.email).then(function(response){console.log(response),$scope.success=response.message,$scope.credentials=null,$scope.isResetSent=!0},function(error){$scope.error=error,$scope.credentials.email=null,$scope.isResetSent=!1})},$scope.validateVerifyToken=function(){$stateParams.token&&(console.log($stateParams.token),User.validateVerifyToken($stateParams.token).then(function(response){console.log("Success: "+response.message),$scope.success=response.message,$scope.isResetSent=!0,$scope.credentials.email=null},function(error){console.log("Error: "+error.message),$scope.isResetSent=!1,$scope.error=error,$scope.credentials.email=null}))}}]),angular.module("users").factory("Auth",["$window",function($window){var userState={isLoggedIn:!1},service={_currentUser:null,get currentUser(){return this._currentUser},ensureHasCurrentUser:function(User){return service._currentUser&&service._currentUser.username?(console.log("Using local current user."),service._currentUser):$window.user?(console.log("Using cached current user."),service._currentUser=$window.user,service._currentUser):(console.log("Fetching current user from the server."),void User.getCurrent().then(function(user){return service._currentUser=user,userState.isLoggedIn=!0,$window.user=service._currentUser,service._currentUser},function(response){return userState.isLoggedIn=!1,service._currentUser=null,$window.user=null,console.log("User.getCurrent() err",response),null}))},isAuthenticated:function(){return!!service._currentUser},getUserState:function(){return userState},login:function(new_user){userState.isLoggedIn=!0,service._currentUser=new_user},logout:function(){$window.user=null,userState.isLoggedIn=!1,service._currentUser=null}};return service}]),angular.module("users").service("Authorizer",["APP_PERMISSIONS","USER_ROLES",function(APP_PERMISSIONS,USER_ROLES){return function(user){return{canAccess:function(permissions){var i,len,permission;for(angular.isArray(permissions)||(permissions=[permissions]),i=0,len=permissions.length;len>i;i++){if(permission=permissions[i],null===APP_PERMISSIONS[permission])throw"Bad permission value";if(!user||!user.roles)return!1;switch(permission){case APP_PERMISSIONS.viewAdminSettings:case APP_PERMISSIONS.editAdminSettings:return user.roles.indexOf(USER_ROLES.admin)>-1;case APP_PERMISSIONS.viewPrivateForm:case APP_PERMISSIONS.editForm:return user.roles.indexOf(USER_ROLES.admin)>-1||user.roles.indexOf(USER_ROLES.normal)>-1}}return!1}}}}]),angular.module("users").factory("User",["$window","$q","$timeout","$http","$state",function($window,$q,$timeout,$http,$state){var userService={getCurrent:function(){var deferred=$q.defer();return $http.get("/users/me").success(function(response){deferred.resolve(response)}).error(function(){deferred.reject("User's session has expired")}),deferred.promise},login:function(credentials){var deferred=$q.defer();return $http.post("/auth/signin",credentials).success(function(response){deferred.resolve(response)}).error(function(error){deferred.reject(error.message||error)}),deferred.promise},logout:function(){var deferred=$q.defer();return $http.get("/auth/signout").success(function(response){deferred.resolve(null)}).error(function(error){deferred.reject(error.message||error)}),deferred.promise},signup:function(credentials){var deferred=$q.defer();return $http.post("/auth/signup",credentials).success(function(response){deferred.resolve(response)}).error(function(error){deferred.reject(error.message||error)}),deferred.promise},resendVerifyEmail:function(_email){var deferred=$q.defer();return $http.post("/auth/verify",{email:_email}).success(function(response){deferred.resolve(response)}).error(function(error){deferred.reject(error.message||error)}),deferred.promise},validateVerifyToken:function(token){var validTokenRe=/^([A-Za-z0-9]{48})$/g;if(!validTokenRe.test(token))throw new Error("Error token: "+token+" is not a valid verification token");var deferred=$q.defer();return $http.get("/auth/verify/"+token).success(function(response){deferred.resolve(response)}).error(function(error){deferred.reject(error)}),deferred.promise},resetPassword:function(passwordDetails,token){var deferred=$q.defer();return $http.get("/auth/password/"+token,passwordDetails).success(function(response){deferred.resolve()}).error(function(error){deferred.reject(error.message||error)}),deferred.promise},askForPasswordReset:function(credentials){var deferred=$q.defer();return $http.post("/auth/forgot",credentials).success(function(response){deferred.resolve(response)}).error(function(error){deferred.reject(error.message||error)}),deferred.promise}};return userService}]),angular.module("users").factory("Users",["$resource",function($resource){return $resource("users",{},{update:{method:"PUT"}})}]); |