var vendor = angular.module( 'vendor', [ 'ngImgCrop', 'ui.router', 'ngDialog', 'uixRating', 'uixInput', 'localytics.directives', 'ui.bootstrap', 'ui.bootstrap.rating', 'angular-svg-round-progress', 'autocomplete', 'ngClipboard', 'ngSanitize', 'ngFileUpload', 'ngNotify', 'angular-tour.tour', 'angular-sortable-view', 'MassAutoComplete', 'ngMap', 'summernote', '720kb.datepicker', 'rw.moneymask', ]); var dialogDuration=5000; vendor.config(['$stateProvider','$urlRouterProvider','$httpProvider','$locationProvider',function($stateProvider,$urlRouterProvider,$httpProvider,$locationProvider) { // For any unmatched url, redirect to /state1 $urlRouterProvider.otherwise('/not-found'); $urlRouterProvider.rule(function ($i, $location) { var path = $location.path(), normalized = path.toLowerCase(); if (path != normalized) return normalized; }); delete $httpProvider.defaults.headers.common["X-Requested-With"]; $httpProvider.defaults.useXDomain = true; $locationProvider.html5Mode(true); var homeTemplate = RELEASE_VERSION.split('-')[1]; if(homeTemplate==('_'+SUBDOMAIN)){ var homePageStyle = homeTemplate; } else { var homePageStyle = (homeTemplate==4)?homeTemplate:RELEASE_VERSION.split('-')[2]; } // Now set up the states $stateProvider .state('calculator', { url: "/calculator", //abstract:true, templateUrl: baseURL+"/partials/home-page-templates/home"+RELEASE_VERSION.split('-')[2]+".html", // controller:"homeCtrl" }) .state('home', { url: "/", //abstract:true, templateUrl: baseURL+"/partials/home-page-templates/home"+homePageStyle+".html", // controller:"homeCtrl" }).state('change-password', { url: "/changepassword/{authToken:.*}", templateUrl: baseURL+"/partials/home-page-templates/home"+homePageStyle+".html", // controller:"homeCtrl" }).state('recovery', { url: "/recoverpassword", templateUrl: baseURL+"/partials/home-page-templates/home"+homePageStyle+".html", // controller:"homeCtrl" }).state('signout', { url: "/signout", templateUrl: baseURL+"/partials/home-page-templates/home"+homePageStyle+".html", // controller:"homeCtrl" }).state('signin', { url: "/signin", templateUrl: baseURL+"/partials/home-page-templates/home"+homePageStyle+".html", // controller:"homeCtrl" }).state('dashboard', { url: "/dashboard", templateUrl: baseURL+"/partials/dashboard.html", controller:"dashboardCtrl" }).state('applications', { url: "/applications", templateUrl: baseURL+"/partials/applications.html", controller:"applicationCtrl" }).state('new-application', { url: "/new-application", templateUrl: baseURL+"/partials/new-application.html", controller:"NewApplicationController" }).state('create-new-application', { url: "/create-new-application", templateUrl: baseURL+"/partials/create-new-application.html", controller:"NewApplicationController" }).state('email-application', { url: "/email-application", templateUrl: baseURL+"/partials/email-application.html", controller:"NewApplicationController" }).state('list-mail-account', { url: "/mail-accounts/{OAuthToken:.*}", templateUrl: baseURL+"/partials/mail-account-list.html", controller:"mailAccountAppCtrl" }).state('view-partial', { url: "/view-partial/:PartialAppUID", templateUrl: baseURL+"/partials/new-application.html", controller:"NewApplicationController" }).state('verify-account', { url: "/verification/{authToken:.*}", templateUrl: baseURL+"/partials/Verification.html", controller:"VerificationController" }).state('review-application', { url: "/review-application", templateUrl: baseURL+"/partials/new-application.html", controller:"NewApplicationController" }).state('partial-application', { url: "/partial-application", templateUrl: baseURL+"/partials/partial-application.html", controller:"partialAppCtrl" }).state('load-partial-application', { url: "/applications/viewpartial/{partialAppUID:.*}", template: "", controller:"partialAppCtrl" }).state('share-application', { url: "/share-application/:ApplicationNumber", templateUrl: baseURL+"/partials/share-application.html", controller:"shareApplicationController" }).state('company-user', { url: "/company-user", templateUrl: baseURL+"/partials/company-user.html", controller:"companyUserCtrl" }).state('invited-users', { url: "/invited-users", templateUrl: baseURL+"/partials/invited-users.html", controller:"companyUserCtrl" }).state('company-user-details', { url: "/company-user-details", templateUrl: baseURL+"/partials/phone-view/company-user-details.html", controller:"companyUserCtrl" }).state('plan-details', { url: "/plan-details", templateUrl: baseURL+"/partials/phone-view/plan-details.html", controller:"PlanCtrl" }).state('contacts', { url: "/contacts", templateUrl: baseURL+"/partials/contacts.html", controller:"contactUsCtrl" }).state('reports', { url: "/reports", templateUrl: baseURL+"/partials/reports.html", controller:"reportCtrl" }).state('borrower', { url: "/borrower", templateUrl: baseURL+"/partials/borrower.html", controller:"borrowerCtrl" }).state('create-account', { abstract:true, url: "/create-account", templateUrl: baseURL+"/partials/create-account.html", controller:"NewApplicationController" }).state('create-account.ca-your-business', { url: "/your-business", templateUrl: baseURL+"/partials/ca-view/ca-your-business.html", controller:"SignUpApplicationController", data : { wizardTab: 2 } }).state('create-account.ca-your-details', { url: "/your-details", templateUrl: baseURL+"/partials/ca-view/ca-your-details.html", controller:"SignUpApplicationController", data : { wizardTab: 3 } }).state('create-account.ca-create-account', { url: "{linkSource:.*}", templateUrl: baseURL+"/partials/ca-view/ca-create-account.html", controller:"SignUpApplicationController", data : { wizardTab: 1 } }).state('application-submited', { url: "/application-submited", templateUrl: baseURL+"/partials/Thank-you.html", controller:"SignUpApplicationController", }).state('custom-quote-estimate', { url: "/custom-quote-estimate", templateUrl: baseURL+"/partials/custom-quote-estimate.html", // controller:"SignUpApplicationController", }).state('custom-quote', { url: "/custom-quote/:proposalID", templateUrl: baseURL+"/partials/custom-quote.html", // controller:"SignUpApplicationController", }).state('custom-quote-with-loandata', { url: "/custom-quote/:Amount/:tenure", templateUrl: baseURL+"/partials/custom-quote.html", // controller:"SignUpApplicationController", }).state('monthly-quote', { url: "/monthly-quote/:Amount/:tenure", templateUrl: baseURL+"/partials/custom-quote.html", // controller:"SignUpApplicationController", }).state('apply-now', { url: "/custom-quote/apply-now/:proposalID", templateUrl: baseURL+"/partials/custom-quote.html", // controller:"SignUpApplicationController", }).state('program-list', { url: "/programs/:action", templateUrl: baseURL+"/partials/partner/program.html", controller:"programListCtrl" }).state('manage-vendor', { url: "/manage-vendor", templateUrl: baseURL+"/partials/partner/manage-vendor.html", controller:"ProgramCtrl" }).state('associate-vendor', { url: "/associate-vendor", templateUrl: baseURL+"/partials/partner/associate-vendor.html", controller:"ProgramCtrl" }).state('vendor-application-details', { url: "/vendor-application-details", templateUrl: baseURL+"/partials/partner/application-details-vendor.html", controller:"ProgramCtrl" }).state('thank-you', { url: "/thank-you", templateUrl: baseURL+"/partials/thank-you.html", controller:"loginCtrl" }).state('register-company', { url: "/register-company", templateUrl: baseURL+"/partials/company-register.html", }).state('404', { url: "/not-found", templateUrl: baseURL+"/404.html", controller:"missingController" }).state('proposal-dashboard', { url: "/proposal-dashboard", templateUrl: baseURL+"/partials/proposal-dashboard.html", controller:"proposalDashboardAppCtrl" }).state('program-dashboard', { url: "/program-dashboard", templateUrl: baseURL+"/partials/program-dashboard.html", controller:"programDashboardAppCtrl" }).state('create-proposal', { url: "/create-proposal", abstract:true, templateUrl: baseURL+"/partials/create-proposal.html", controller:"createProposalAppCtrl" }).state('create-proposal.proposal-create-tab', { url: "/proposal-create-tab", templateUrl: baseURL+"/partials/proposal-view/proposal-create-tab.html", //controller:"createProposalAppCtrl" data : { wizardTab: 1 } }).state('create-proposal.proposal-allowed-configuration-tab', { url: "/proposal-allowed-configuration-tab", templateUrl: baseURL+"/partials/proposal-view/proposal-allowed-configuration-tab.html", //controller:"createProposalAppCtrl" data : { wizardTab: 2 } }).state('create-proposal.proposal-select-leads-tab', { url: "/proposal-select-leads", templateUrl: baseURL+"/partials/proposal-view/proposal-select-leads-tab.html", //controller:"createProposalAppCtrl" data : { wizardTab: 3 } }) .state('create-proposal.proposal-review-send-tab', { url: "/proposal-review-send", templateUrl: baseURL+"/partials/proposal-view/proposal-review-send-tab.html", //controller:"createProposalAppCtrl" data : { wizardTab: 5 } }).state('create-proposal.proposal-select-template-tab', { url: "/proposal-select-template", templateUrl: baseURL+"/partials/proposal-view/proposal-select-template-tab.html", //controller:"createProposalAppCtrl" data : { wizardTab: 4 } }).state('proposal-status', { url: "/proposal-status/:ProposalGUID", templateUrl: baseURL+"/partials/proposal-view/proposal-status.html", controller:"proposalLeadAppCtrl" }).state('unsubscribe', { url: "/unsubscribe/:Email", templateUrl: baseURL+"/partials/unsubscribe.html", controller:"unsubscribeCtrl" }).state('decline-proposal', { url: "/decline-proposal/:ProposalLeadID", templateUrl: baseURL+"/partials/decline-proposal.html", // controller:"declineProposalCtrl" }).state('program', { abstract:true, url: "/program/:action", templateUrl: baseURL+"/partials/partner/view-program.html", controller:"ProgramCtrl" }).state('program.details', { url: "", templateUrl: baseURL+"/partials/add-program-wizard/add-program-details-view.html", data : { wizardTab: 1 } }).state('program.config', { url: "/config", templateUrl: baseURL+"/partials/add-program-wizard/add-program-table-view.html", data : { wizardTab: 2 } }).state('program.vendor-allocation', { url: "/vendor-allocation", templateUrl: baseURL+"/partials/add-program-wizard/vendor-allocation.html", data : { wizardTab: 3 } }).state('program.manage-teams', { url: "/manage-teams", templateUrl: baseURL+"/partials/add-program-wizard/manage-program-team.html", data : { wizardTab: 4 } }).state('program.required-document', { url: "/required-document", templateUrl: baseURL+"/partials/add-program-wizard/required-document.html", data : { wizardTab: 4 } }).state('routing-rule', { url: "/routing-rule", templateUrl: baseURL+"/partials/routing-rules.html", controller:"RoutingCtrl" }).state('invitation', { url: "/invitation", templateUrl: baseURL+"/partials/invitation.html", controller:"invitationCtrl" }) .state('manage-template', { url: "/manage-template", templateUrl: baseURL+"/partials/manage-template.html", controller:"manageTemplate" }) .state('change-plan', { url: "/plan1", templateUrl: baseURL+"/partials/change-plan.html", controller:"PlanCtrl" }).state('plan', { url: "/plan", templateUrl: baseURL+"/partials/plan.html", controller:"PlanCtrl" }) .state('show-module-data',{ url: "/show-module-data", templateUrl: baseURL+"/partials/show-module-data.html", controller: "PlanCtrl" }) .state('preferences-1',{ url: "/preferences-1", templateUrl: baseURL+"/partials/new-home-pages/1.html", controller: "preferencesCtrl" }) .state('borrower-view-rate',{ url: "/borrower-view-rate", templateUrl: baseURL+"/partials/borrower-view-rate.html", controller:"NewApplicationController" }) .state('financing-offers',{ url: "/financing-offers", templateUrl: baseURL+"/partials/financing-offers.html" }) .state('additional-information',{ url: "/additional-information", templateUrl: baseURL+"/partials/additional-information.html", controller: "additionalFieldsCtrl", }) .state('application-denial',{ url: "/application-denial", templateUrl: baseURL+"/partials/application-denial.html", controller: "appDenialCtrl", }) .state('e-com-homepage',{ url: "/e-com-homepage", templateUrl: baseURL+"/partials/e-com-homepage.html", controller: "ecommerceCtrl" }) .state('e-com-listing',{ url: "/e-com-listing", templateUrl: baseURL+"/partials/e-com-listing.html", controller: "ecommerceCtrl" }) .state('e-com-detail',{ url: "/e-com-detail", templateUrl: baseURL+"/partials/e-com-detail.html", controller: "ecommerceCtrl" }) .state('e-com-cart',{ url: "/e-com-cart", templateUrl: baseURL+"/partials/e-com-cart.html", controller: "ecommerceCtrl" }) .state('app-details',{ url: "/app-details/:activeTab/:ApplicationNumber", templateUrl: baseURL+"/partials/application.html", controller: "appDetailsCtrlNew" }) .state('lender-profile',{ url: "/lender-profile", templateUrl: baseURL+"/partials/lender-profile.html", controller: "LenderProfileController" }) .state('lender-homepage',{ url: "/lender-homepage", templateUrl: baseURL+"/partials/lender-homepage.html", }) .state('add-deal',{ abstract:true, url: "/add-deal/:action", templateUrl: baseURL+"/partials/add-deal.html", controller:"DealCtrl" }) .state('add-deal.generalinfo',{ url: "generalinfo", templateUrl: baseURL+"/partials/add-deal-general-information.html", data : { wizardTab: 1 }, }) .state('syndication-desk',{ url: "/syndication-desk", templateUrl: baseURL+"/partials/syndication-desk.html", controller:"DealCtrl" }) .state('add-deal-manual',{ url: "/add-deal-manual/:DealUID", templateUrl: baseURL+"/partials/add-deal-manual.html", controller: "DealCtrl" }) .state('edit-deal',{ abstract:true, url: "/edit-deal/generalinfo/:DealUID", templateUrl: baseURL+"/partials/add-deal.html", controller:"DealCtrl" }) .state('edit-deal.generalinfo',{ url: "", templateUrl: baseURL+"/partials/add-deal-general-information.html", data : { wizardTab: 1 }, controller: "DealOptionsController" }) .state('edit-deal.documents',{ url: "/documents", templateUrl: baseURL+"/partials/add-deal-documents.html", data : { wizardTab: 2 }, }) .state('edit-deal-manual',{ url: "/edit-deal-manual/:DealUID", templateUrl: baseURL+"/partials/add-deal-manual.html", controller:"DealCtrl" }) .state('deal',{ url: "/deal/:DealUID", templateUrl: baseURL+"/partials/view-deal.html", controller: "DealCtrl" }) .state('deal-link', { url: "/deal/:link/:DealUID", templateUrl: baseURL+"/partials/view-deal.html", controller:"DealCtrl" }) .state('alert',{ url: "/alert", templateUrl: baseURL+"/partials/alert.html", controller: "applicationCtrl" }) .state('alert-new',{ url: "/alert-new", templateUrl: baseURL+"/partials/alert-new.html", controller: "applicationCtrl" }) .state('network',{ url: "/network", templateUrl: baseURL+"/partials/network.html", controller: "applicationCtrl" }).state('connections-new', { url: "/connections-new", templateUrl: baseURL+"/partials/connections-new.html", controller:"applicationCtrl" }).state('inbox',{ url: "/inbox/:ChatRoomID", templateUrl: baseURL+"/partials/inbox.html", controller: "InboxController" }).state('entityMessage',{ url: "/inbox/:entityType/:entityID", templateUrl: baseURL+"/partials/inbox.html", controller: "InboxController" }).state('user-profile',{ url: "/user-profile", templateUrl: baseURL+"/partials/user-profile.html", controller: "userProfileCtrl" }).state('permitted-actions',{ url: "/permitted-actions", templateUrl: baseURL+"/partials/permitted-actions.html", controller: "PermittedActionsController" }).state('custom-url-page',{ url: "/custom-url-page", templateUrl: baseURL+"/partials/custom-url-page.html", controller: "CustomURLController" }).state('set-configuration', { url: "/set-configuration", templateUrl: baseURL+"/partials/set-configuration.html", controller:"SetConfigurationController" }).state('no-permission', { url: "/no-permission", templateUrl: baseURL+"/partials/no-permission.html", // controller:"SetConfigurationController" }).state('profile-document-repository', { url: "/profile-document-repository", templateUrl: baseURL+"/partials/profile-document-repository.html", // controller:"SetConfigurationController" }).state('admin-documents', { url: "/admin-documents", templateUrl: baseURL+"/partials/admin-documents-repository.html", // controller:"SetConfigurationController" }).state('view-pool',{ url: "/deal-pool/:DealTabFlag/:PoolUID", templateUrl: baseURL+"/partials/deal-pool/view-pool.html", controller: "DealPoolController" }).state('add-pool',{ url: "/add-pool", templateUrl: baseURL+"/partials/deal-pool/add-pool.html", controller: "DealPoolDraftController" }).state('upload-pool',{ url: "/upload-pool/:DraftID", templateUrl: baseURL+"/partials/deal-pool/upload-pool.html", controller: "DealPoolDraftController" }).state('select-deal',{ url: "/select-deal/:DraftID", templateUrl: baseURL+"/partials/deal-pool/upload-pool.html", controller: "DealPoolDraftController" }).state('edit-select-deal',{ url: "/edit-deal-pool/:PoolUID", templateUrl: baseURL+"/partials/deal-pool/upload-pool.html", controller: "DealPoolDraftController" }).state('pool',{ url: "/pool", templateUrl: baseURL+"/partials/deal-pool/pool.html", controller: "DealPoolsController" }).state('resources', { url: "/resources", templateUrl: baseURL+"/partials/resources.html", controller:"resourcesCtrl" }); }]) .config(['$compileProvider', function ($compileProvider) { $compileProvider.debugInfoEnabled(location.protocol!=='https:'); }]) .config(['$sceDelegateProvider',function($sceDelegateProvider) { $sceDelegateProvider.resourceUrlWhitelist([ // Allow same origin resource loads. 'self', // Allow loading from our assets domain. Notice the difference between * and **. location.protocol+'//api.'+MASTER_DOMAIN+'/api/**', location.protocol+'//assets.'+MASTER_DOMAIN+'/**' ]); }]) .run(['$rootScope','ngDialog','appInfo','$location','$timeout','$state','Storage','ngNotify','$q',function($rootScope,ngDialog,appInfo,$location,$timeout,$state,Storage,ngNotify,$q){ $rootScope.baseURL=baseURL; $rootScope.masterDomain=MASTER_DOMAIN; $rootScope.masterCompany=MASTER_COMPANY; $rootScope.siteURL=appInfo.siteUrl; $rootScope.imageServerURL=IMAGE_SERVER_PATH; $rootScope.maxDisplayPages=(window.innerWidth>767)?6:3; $rootScope.RELEASE_VERSION=RELEASE_VERSION; $rootScope.pow=Math.pow; $rootScope.round=Math.round; $rootScope.parseFloat=parseFloat; $rootScope.editorOptions = { toolbar: [ ['edit',['undo','redo']], // ['headline', ['style']], ['style', ['bold', 'italic', 'underline', /*'superscript', 'subscript',*/ 'strikethrough', 'clear']], // ['fontface', ['fontname']], ['textsize', ['fontsize']], // ['fontclr', ['color']], ['alignment', ['ul', 'ol', 'paragraph', 'lineheight']], // ['height', ['height']], // ['table', ['table']], ['insert', ['link','picture','video','hr']], ['view', ['fullscreen', 'codeview']], ['help', ['help']] ] }; $rootScope.ApplicationFlowOptions = [ { 'key':'Selfcredit', 'value':'Apps w/ self credit score - Customer does not choose Lender Programs' }, { 'key':'Selfcreditwithchooselender', 'value':'Apps w/ self credit score - Customer choose Lender Programs' }, { 'key':'Experianwithchooselender', 'value':'Apps w/ experian integration - Customer Choose Lender Programs' }, { 'key':'Experian', 'value':'Apps w/ experian integration - Customer does not choose Lender Programs' }, ]; $rootScope.TimeFormat = [ { 'key':'D', 'value':'Days' }, { 'key':'W', 'value':'Week' }, { 'key':'M', 'value':'Month' }, { 'key':'Y', 'value':'Year' }, ]; $rootScope.Page={ Title : 'Finance Exchange', zipBeingPrepared : [], Loading: [], isZipBeingProcessed: function(item){ return this.zipBeingPrepared.indexOf(item+'.zip')>-1; }, trackLoading: function(item){ var i=this.Loading.indexOf(item); if(i===-1) this.Loading.push(item); if(this.toggleLoading) this.toggleLoading(this.Loading); }, untrackLoading: function(item){ var i=this.Loading.indexOf(item); if(i>-1) { this.Loading.splice(i,1); if(this.toggleLoading) this.toggleLoading(this.Loading); } } }; $rootScope.showToasterMessage=function(label,msg,callback,Notification){ toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": true, "positionClass": "toast-top-left", "preventDuplicates": false, "onclick":_.isFunction(callback)?callback:null, "showDuration": "300", "hideDuration": "1000", "Notification":Notification, "timeOut": "20000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" }; Command: toastr[label](msg); } $rootScope.showFlashMessage=function(label,msg){ ngNotify.set(msg, { theme: 'pure', position: 'top', type: label, sticky: true, button: true, html: false }); setTimeout(function () { ngNotify.dismiss(); }, dialogDuration); } $rootScope.Page.trackLoading('view'); $rootScope.colorPresets=[ ['#4697CE','#40AC42'], ['#40AC42','#4697CE'], ['#00D5C3','#374258'], ['#FE6B67','#465568'], ['#CD7710','#4D4D4F'], ['#B654D5', '#11091E'], ['#FE5654', '#3F5371'], ['#EFBD23', '#9E9E9E'], ['#61365B', '#A7789F'], ['#93D932', '#666666'] ]; // get Current year for footer $rootScope.currentYear = (new Date()).getFullYear(); $rootScope.updateUI = function(){ if ($rootScope.CompanyPreferences.BackgroundImage) { $rootScope.myBgImg = { "background-image": 'url(' + IMAGE_SERVER_PATH +$rootScope.CompanyPreferences.BackgroundImage + ')', "background-size": 'cover', "background-repeat": 'no-repeat', "background-position": 'center center' }; } if($rootScope.CompanyPreferences.BetaSiteThemeSettings){ with($rootScope.CompanyPreferences.BetaSiteThemeSettings){ hex = color1.replace('#',''); opacity = 70; r = parseInt(hex.substring(0,2), 16); g = parseInt(hex.substring(2,4), 16); b = parseInt(hex.substring(4,6), 16); result = 'rgba('+r+','+g+','+b+','+opacity/100+')'; $rootScope.myStyle1 = {"background-color":color1}; $rootScope.myStyle2 = {"background-color":color2}; $rootScope.myStyle3 = {"color":color1}; $rootScope.myStyle4 = {"border-left-color":color1}; $rootScope.myStyle5 = {"border-color":result}; $rootScope.myStyle6 = {"color":color2} angular.element(".ca-active,.ca-complete").css("background-color",color1).find(".arrow-right,.arrow-right").css("border-left-color",color1); var cssRules='.pagination > li > a {color:'+color1+';background:#FFF;}\n'; cssRules+='.pagination > li.active > a ,.pagination > li.active:hover > a {color:#FFF;background:'+color1+';}\n'; setThemeSpecificRules(cssRules); } } } $rootScope.changeTheme=function(colorPresetID,tempUpdate){ var color1=$rootScope.colorPresets[colorPresetID-1][0]; var color2=$rootScope.colorPresets[colorPresetID-1][1]; if (!tempUpdate) { var reqData={ "SetCompanyPreferences": { "UIsettings": {"color1":color1,"color2":color2,"color3":color1,"color4":color1,"color5":color1}, "LoginSessionKey": $rootScope.SignIn.LoginSessionKey } }; appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ $rootScope.showFlashMessage('success',response.Message); $rootScope.CompanyPreferences.BetaSiteThemeSettings={"color1":color1,"color2":color2,"color3":color1,"color4":color1,"color5":color1}; Storage.setItem('CompanyPreferences',$rootScope.CompanyPreferences); $rootScope.updateUI(); } else { $rootScope.showFlashMessage('error',response.Message); } }); } else { $rootScope.updateUI(); } }; $rootScope.Page.trackLoading('company-preferences'); if(typeof(Storage) !== "undefined") { $rootScope.SignIn=Storage.getItem('SignIn'); $rootScope.uaInfo=Storage.getItem('uaInfo'); var EmuData=Storage.getEmulationData(); $rootScope.CompanyPreferences=Storage.getItem('CompanyPreferences'); if($rootScope.uaInfo && $rootScope.CompanyPreferences){ if(RELEASE_VERSION==Storage.getItem('RELEASE_VERSION') && $rootScope.CompanyPreferences.ModifiedDate==COMPANY_DATA){ $rootScope.persistentMessage=Storage.getItem('persistentMessage'); $rootScope.CompanyPreferences=Storage.getItem('CompanyPreferences'); $timeout(function(){ if(_.isFunction($rootScope.postCompanyLoad)) $rootScope.postCompanyLoad(); },500); // if($rootScope.SignIn) // appInfo.getSocketData(); if(!EmuData || !EmuData.emulate || EmuData.emulate.LoginKeyword){ appInfo.getFundingProgram(function(){ $timeout(function(){ $rootScope.$emit('company-loaded', { source : 'cache' }); $rootScope.Page.untrackLoading('company-preferences'); },500); },false,{ ProgramID:$rootScope.CompanyPreferences.DefaultProgramID, UsingDefault:TRUE }); } $rootScope.Page.Title = $rootScope.CompanyPreferences.CompanyName; $rootScope.updateUI(); } else { $rootScope.CompanyPreferences=$rootScope.SignIn=$rootScope.uaInfo=null; Storage.clear(); } } } if(!$rootScope.uaInfo || $rootScope.CompanyPreferences){ var reqData={"GetUserAgentID":{ "Resolution":screen.width+'x'+screen.height }}; appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ $rootScope.uaInfo=response.Data; $rootScope.uaInfo.ClientTZDIFF=getClientTimezoneName(); Storage.setItem('uaInfo',$rootScope.uaInfo); Storage.setItem('RELEASE_VERSION',RELEASE_VERSION); } /* Get Company Info */ if(EmuData && EmuData.emulate){ if($rootScope.SignIn) $rootScope.EmulatedMode.UserID=$rootScope.SignIn.UserDetails.UserID; var reqData={"GetCompanyPreferences":{ "CompanyID":EmuData.emulate.CompanyID }}; } else var reqData={"GetCompanyPreferences":{ "Alias":SUBDOMAIN }}; appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ $rootScope.CompanyPreferences=response.Data; $rootScope.Page.Title = $rootScope.CompanyPreferences.CompanyName; if($rootScope.CompanyPreferences.BetaSiteThemeSettings){ $rootScope.updateUI(); } if(!EmuData || !EmuData.emulate || EmuData.emulate.LoginKeyword){ appInfo.getFundingProgram(function(){ $rootScope.$emit('company-loaded', { source : 'service' }); },false,{ ProgramID:$rootScope.CompanyPreferences.DefaultProgramID, UsingDefault:TRUE }); } if(_.isFunction($rootScope.postCompanyLoad)) $rootScope.postCompanyLoad(); if(!EmuData) Storage.setItem('CompanyPreferences',$rootScope.CompanyPreferences); else Storage.removeItem('uaInfo'); $rootScope.Page.untrackLoading('company-preferences'); if(!_.isUndefined($rootScope.SignIn) && $rootScope.SignIn){ appInfo.getCompanyPermissions(function(response){ if($rootScope.Page.Loading.indexOf('view')!=-1){ $location.path(response.Data.landingPage); } },{}); } } }); }); } //change checkbox color as per theme $rootScope.$on('$stateChangeStart',function(event, current) { var menu=''; var allowVisitor=false; var allowedRoles=[]; $rootScope.showFooter=true; $rootScope.Page.trackLoading(current.name); switch(current.name) { case 'dashboard': menu='dashboardTab'; allowedRoles=[1,2,3,5,6]; /*Old One*/ // allowedRoles=[2,5]; break; case 'inbox': case 'entityMessage': menu='messageTab'; allowedRoles=[1,2,3,4,5,6]; /*Old One*/// allowedRoles=[2,3,5]; break; case 'custom-url-page': menu='custompageTab'; allowedRoles=[1,2,4,3,5,6]; /*Old One*/// allowedRoles=[2,3,5]; break; case 'no-permission': allowedRoles=[1,2,3,4,5,6,7]; break; case 'add-deal': case 'add-deal.generalinfo': case 'add-deal.documents': case 'syndication-desk': case 'add-deal-manual': case 'add-deal-files': case 'edit-deal': case 'edit-deal.generalinfo': case 'edit-deal.documents': case 'deal-link': case 'edit-deal-manual': case 'deal': menu='dealTab'; allowedRoles=[1,2,3,5,6]; break; case 'view-pool': case 'add-pool': case 'upload-pool': case 'select-deal': case 'edit-select-deal': case 'pool': menu='poolTab'; allowedRoles=[1,2,3,5,6]; break; case 'change-plan': case 'show-module-data': case 'plan': // menu='dashboardTab'; allowedRoles=[1,2,3,5,6]; /*Old One*/// allowedRoles=[2,5,6]; break; case 'reports': menu='reportTab'; allowedRoles=[1,2,3,5,6]; /*Old One*/// allowedRoles=[2,5]; break; case 'partial-application': menu='partialApplicationTab'; allowedRoles=[1,2,3,5,6]; /*Old One*/// allowedRoles=[2,5,3,4]; break; case 'company-user': case 'invited-users': case 'company-user-details': case 'set-configuration': case 'plan-details': menu='companyUsersTab'; allowedRoles=[1,2,3,5,6]; /*Old One*/// allowedRoles=[6,2,5]; break; case 'contacts': menu='contactsTab'; allowedRoles=[1,2,3,5,6]; /*Old One*/// allowedRoles=[2,3,5]; break; case 'borrower': menu='borrowerTab'; allowedRoles=[1,2,3,5,6]; /*Old One*/// allowedRoles=[2,5,6]; break; case 'new-application': case 'resources': case 'view-partial': case 'email-application': case 'create-new-application': menu='partial-application'; allowedRoles=[2,5,4,3,6]; break; case 'signout': case 'change-password': $rootScope.showFooter=false; case '404': allowedRoles=[2,5,3,4,6]; allowVisitor=true; break; case 'program': case 'program.details': case 'program.config': case 'program.manage-teams': case 'program.required-document': case 'program.vendor-allocation': case 'program-list': menu='programTab'; /*Old One*/// allowedRoles=[2,5,3]; allowedRoles=[1,2,3,5,6]; break; case 'programs-request': menu='programTab'; /*Old One*/// allowedRoles=[2,5,3]; allowedRoles=[1,2,3,5,6]; case 'manage-vendor': menu='manage-vendor'; /*Old One*/// allowedRoles=[2,5]; allowedRoles=[1,2,3,5,6]; break; case 'vendor-application-details': menu='program'; /*Old One*/// allowedRoles=[2,5,3]; allowedRoles=[1,2,3,5,6]; break; case 'list-mail-account': case 'share-application': menu='applicationTab'; /*Old One*/// allowedRoles=[2,5,3]; allowedRoles=[1,2,3,5,6]; break; case 'proposal-dashboard': menu='proposalTab'; /*Old One*/// allowedRoles=[2,3,4,5]; allowedRoles=[1,2,3,4,5,6]; break; case 'program-dashboard': case 'routing-rule': menu='programTab'; allowedRoles=[2,3,5,6]; break; case 'invitation': menu='invitationTab'; allowedRoles=[2,5,3,6]; break; case 'create-proposal': case 'create-proposal.proposal-create-tab': case 'create-proposal.proposal-select-leads-tab': case 'create-proposal.proposal-select-template-tab': case 'create-proposal.proposal-allowed-configuration-tab': case 'create-proposal.proposal-review-send-tab': case 'proposal-status': case 'manage-template': menu='proposalTab'; /*Old One*/// allowedRoles=[2,3,5]; allowedRoles=[1,2,3,4,5,6]; break; case 'create-account.ca-create-account': case 'create-account.ca-your-business': case 'create-account.ca-your-details': case 'custom-quote': case 'custom-quote-with-loandata': case 'custom-quote-estimate': case 'monthly-quote': case 'apply-now': case 'additional-information': case 'review-application': case 'load-partial-application': case 'vendor-partial-application': case 'application-submited': case 'borrower-view-rate': case 'financing-offers': case 'lender-homepage': case 'messages': case 'alert': case 'alert-new': case 'network': menu='new-application'; /*Old One*/// allowedRoles=[4,5,3,2]; allowedRoles=[1,2,3,4,5,6]; allowVisitor=true; break; case 'verify-account': case 'application-denial': allowedRoles=[2,3,5,4]; allowVisitor=true; break; case 'home': case 'home3': case 'signin': case 'recovery': case 'calculator': allowVisitor=true; $rootScope.showFooter=false; break; case 'unsubscribe': case 'decline-proposal': allowedRoles=[4,6]; allowVisitor=true; $rootScope.showFooter=false; break; case 'add-vendor-details': case 'add-vendor-details.contact-details-tab': case 'add-vendor-details.your-business-tab': case 'add-vendor-details.select-theme-tab': case 'add-vendor-details.add-teams-tab': case 'preferences-1': case 'additional-information': case 'e-com-homepage': case 'e-com-listing': case 'e-com-detail': case 'e-com-cart': allowedRoles=[5,2,6]; break; case 'applications': case 'connections-new': menu='applicationTab'; case 'app-details': case 'user-profile': case 'permitted-actions': case 'lender-profile': case 'profile-document-repository': case 'admin-documents': allowedRoles=[1,2,3,4,5,6,7]; break; } if(!allowVisitor && (typeof $rootScope.SignIn == 'undefined' || $rootScope.SignIn==null)){ event.preventDefault(); $rootScope.$evalAsync(function() { $location.path('/signin'); }); $rootScope.Page.Referer=$location.path(); if(!Storage.getItem('emulate')) $rootScope.showFlashMessage('info','You must login to access this link.'); $rootScope.Page.untrackLoading(current.name); } else if($rootScope.SignIn && allowedRoles.indexOf($rootScope.SignIn.UserDetails.UserTypeID)==-1){ event.preventDefault(); $rootScope.$evalAsync(function() { // $location.path('/applications'); }); if(current.name!='home') $rootScope.showFlashMessage('error','You are not authorized to access this link.'); $rootScope.Page.untrackLoading(current.name); } $rootScope.setUI=function() { var highlightMenu=$('#'+menu).parent(); if(highlightMenu.is('li')) highlightMenu.addClass('active').siblings().removeClass('active'); else setTimeout(function(){ $('#'+menu).parent().addClass('active').siblings().removeClass('active'); },1000); if(!$rootScope.CompanyPreferences.BetaSiteThemeSettings) return; var color=$rootScope.myStyle1?$rootScope.myStyle1.background:'#000'; function tabcolor(){ if($(window).width()<760){ $('.ca-active > .arrow-right,.ca-complete > .arrow-right').css('border-left-color','rgba(0, 0, 0, 0)'); $('.ca-active > .arrow-right,.ca-complete > .arrow-right').css('border-top-color',color); }else{ $('.ca-active > .arrow-right,.ca-complete > .arrow-right').css('border-top-color','rgba(0, 0, 0, 0)'); $('.ca-active > .arrow-right,.ca-complete > .arrow-right').css('border-left-color',color); } } if(current.data && current.data.wizardTab){ $('.list-inline > li').removeClass('ca-active'); $('.ca-head-'+current.data.wizardTab).addClass('ca-active').removeClass('ca-complete').prevAll().addClass('ca-complete'); tabcolor(); $(window).resize(function(){ tabcolor(); }); } switch(color){ case '#0088CC': $rootScope.radioClass ='changed1'; break; case '#FE6B67': $rootScope.radioClass = 'changed2'; break; case '#40AC42': $rootScope.radioClass = 'changed3'; break; case '#00D5C3': $rootScope.radioClass = 'changed4'; break; } $('.squaredOne').find('label').addClass($rootScope.radioClass); $('.squaredOneRadio').find('label').addClass($rootScope.radioClass); $('.squaredOneRadio').on('click',function(e){ var radio = $(this).find('input[type="radio"]:checked') if(radio){ $(this).css('border','1px solid ' + color) $('.squaredOneRadio').not(this).css('border','1px solid #d2d2d2'); } }) //apply theme to homepage ribbon var backgroundColor = $rootScope.myStyle1.background; var addRibboncolor = function(){ $('.ribbon-left-top-triangle').css('border-right-color',backgroundColor); $('.ribbon-left-bottom-triangle').css('border-right-color',backgroundColor); $('.ribbon-right-top-triangle').css('border-left-color',backgroundColor); $('.ribbon-right-bottom-triangle').css('border-left-color',backgroundColor); } switch(backgroundColor){ case '#0088CC': $timeout(function(){ addRibboncolor(); },300); break; case '#40AC42': $timeout(function(){ addRibboncolor(); },300); break; case '#00D5C3': $timeout(function(){ addRibboncolor(); },300); break; case '#FE6B67': $timeout(function(){ addRibboncolor(); },300); break; } } $rootScope.$on('$viewContentLoaded',function(){ if($rootScope.CompanyPreferences) $rootScope.setUI(); else $rootScope.$on('company-loaded',$rootScope.setUI); $rootScope.Page.untrackLoading('view'); }); //display appropriate next/prev links in create-proposal $rootScope.currentName = current.name; }); $rootScope.getColor= function(row){ var rowNo=(typeof row == 'number')?row:row.rowIndex; var colors=['#9358AC','#FFB848','#40AC42','#4697CE','#847F9F','#00B7C5']; return (typeof colors[rowNo] != 'undefined')?colors[rowNo]:colors[rowNo-7]; } $rootScope.getInitials=function(strName){ if(strName){ var arrWords=strName.split(' '); var initailsStr=''; for(var i in arrWords){ initailsStr+=arrWords[i].charAt(0); } return initailsStr.slice(0,2).toUpperCase(); } } $rootScope.forgetPasswordLink=function(Email){ $rootScope.loading=true; var reqData={ "RecoverPassword": { "Value": Email, "Type": "Username", "Alias": $rootScope.CompanyPreferences.Alias } }; appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ $rootScope.showFlashMessage('success','Mail has been sent'); } else { $rootScope.showFlashMessage('error',response.Message); } $rootScope.loading=false; }); } $rootScope.changePassword=function(){ var CompanyName = $rootScope.CompanyPreferences.CompanyName.replace(/^[+]+|[+]+$|[+]+/g, " ").trim(); if(checkstatus('frmChangePassword')){ var dlgScope=this.ChangePassword; if(dlgScope.newPassword==dlgScope.retypePassword){ reqData={ "ChangePassword": { "NewPassword": dlgScope.newPassword, "CompanyName": CompanyName } }; if($rootScope.SignIn){ reqData.ChangePassword.LoginSessionKey= $rootScope.SignIn.LoginSessionKey; reqData.ChangePassword.Password= dlgScope.oldPassword; } else { reqData.ChangePassword.VerificationCode= this.$parent.authToken; } dlgScope.loading=true; appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ ngDialog.close(); var message='Password updated successfully.'; message+=(!$rootScope.SignIn)?' Please login to continue.':''; $rootScope.showFlashMessage('success',message); if(!$rootScope.SignIn){ $location.path('/'); } if($rootScope.SignIn.ChangePassword === true){ $location.path('/SignOut'); } } else { $rootScope.showFlashMessage('error',response.Message); } dlgScope.loading=false; }); } else { $rootScope.showFlashMessage('error','Password and Confirm Password does not match.'); } } } $rootScope.ucfirst = function(string){ return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); } $rootScope.validateUpload=function(f,ModuleName){ var fileSizeLimit = 5242880; var fileSizeLimitInMB = "5 MB"; if(!_.isUndefined(ModuleName) && ModuleName=='Deal') { fileSizeLimit = 104857600; var fileSizeLimitInMB = "100 MB"; }/*console.log(fileSizeLimitInMB,fileSizeLimit,ModuleName);return;*/ if(f.size==0 || f.size>fileSizeLimit){ $rootScope.showFlashMessage('error',"Please select valid image file maximum "+fileSizeLimitInMB); return false; } return true; } $rootScope.updateLogo=function(e){ if(e.target.files && e.target.files.length){ var reqData={ "UploadFile": { "ModuleName": 'CompanyLogo', "LoginSessionKey": $rootScope.SignIn.LoginSessionKey, "File": e.target.files[0] } }; appInfo.uploadFile(reqData).then(function(response){ var msgType='error'; if(response.ResponseCode==200){ $rootScope.CompanyPreferences.Logo=response.Data.MediaURL; msgType='success'; } $rootScope.showFlashMessage(msgType,response.Message); }); } } // new service $rootScope.updateBackgroundImage = function (e) { if (e.target.files && e.target.files.length) { var reqData = { "UploadFile": { "ModuleName": 'CompanyBackGroundImage', "LoginSessionKey": $rootScope.SignIn.LoginSessionKey, "File": e.target.files[0] } }; appInfo.uploadFile(reqData).then(function (response) { var msgType = 'error'; if (response.ResponseCode == 200) { $rootScope.CompanyPreferences.BackgroundImage = response.Data.MediaURL; msgType = 'success'; } $rootScope.showFlashMessage(msgType, response.Message); }); } } $rootScope.ngConfirm=function(message,successcallback,failedcallback){ $rootScope.confirmMessage=message; ngDialog.openConfirm({ template: baseURL+"/partials/confirmDialog.html", // className: 'ngdialog-theme-default' }).then(function (value) { if(_.isFunction(successcallback)) successcallback(); },function (reason) { if(_.isFunction(failedcallback)) failedcallback(); }); } $rootScope.showDeclineRejectPopup=function($scope,appStatus){ appInfo.getMarkerFlags(function(){ // var showClose=true; var showClose=false; // if($scope.ApplicationDetails.ApplicationStatus.StatusID==22) // if($scope.ApplicationStatusID==22) // { // showClose=false; // } $scope.Application={ unapproveStatusFlags:'', unapproveComment:'' }; if($rootScope.SignIn.UserDetails.UserTypeID==4) { $scope.statusFlags=$rootScope.markerFlags.BorrowerDeclined; $scope.flag=false; }else { if($scope.appStatus=appStatus){ $scope.statusFlags=$rootScope.markerFlags.DeclineApplication; $scope.flag=true; } else { $scope.statusFlags=$rootScope.markerFlags.UnapproveDocument; $scope.flag=false; } } ngDialog.open({ template: $rootScope.baseURL+'/partials/dlg-StatusUpdate.html', className:'ng-popup ngdialog-theme-default', scope:$scope, closeByEscape:false, closeByDocument:false, showClose: showClose }); }); } $rootScope.backToAdmin=function(){ location.href="/backToAdmin"; } $rootScope.setRemoveDefaultForExperian = function(callback,Parameters){ var reqData={ "SetRemoveDefaultForExperian": Parameters } appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ $rootScope.showFlashMessage('success',response.Message); } else { $rootScope.showFlashMessage('error',response.Message); } if(typeof callback != 'undefined') callback(); }); } /* Start - Third Party AddOns */ $rootScope.verifySeal=function() { var bgHeight = "600"; var bgWidth = "593"; var url = "https://secure.comodo.com/ttb_searcher/trustlogo?v_querytype=W&v_shortname=SC5&v_search=finexchange.com&x=6&y=5"; // window.open(url,'SealVerfication','menubar=no,toolbar=no,personalbar=no,location=yes,status=no,resizable=yes,fullscreen=no,scrollbars=no,width=' + bgWidth + ',height=' + bgHeight); // TrustLogo("https://signup.finexchange.com/vendorbeta/img/comodo_secure_seal_113x59_transp.png", "CL1", "none"); }; if((["financeapp.com","finexchange.com","finappdev.com"].indexOf(MASTER_DOMAIN)!=-1) && !$rootScope.SignIn){ (function(d,s,i,r) { if (d.getElementById(i)){return;} var n=d.createElement(s),e=d.getElementsByTagName(s)[0]; n.id=i;n.src='//js.hs-analytics.net/analytics/'+(Math.ceil(new Date()/r)*r)+'/546929.js'; e.parentNode.insertBefore(n, e); })(document,"script","hs-analytics",300000); __lc = {license : 5732301}; // (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ // (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), // m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) // })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); // ga('create', 'UA-57045915-1', 'auto'); // ga('send', 'pageview'); /*Facebook Pixel Code - Start*/ !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n; n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, document,'script','https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '1552639241668050', { em: 'insert_email_variable,' }); fbq('track', 'PageView'); /*Facebook Pixel Code - End*/ var trackcmp_email = ''; var trackcmp = document.createElement("script"); trackcmp.async = true; trackcmp.type = 'text/javascript'; trackcmp.src = '//trackcmp.net/visit?actid=65797692&e='+encodeURIComponent(trackcmp_email)+'&r='+encodeURIComponent(document.referrer)+'&u='+encodeURIComponent(window.location.href); var trackcmp_s = document.getElementsByTagName("script"); if (trackcmp_s.length) { trackcmp_s[0].parentNode.appendChild(trackcmp); } else { var trackcmp_h = document.getElementsByTagName("head"); trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp); } (function(h,o,t,j,a,r){ h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)}; h._hjSettings={hjid:744443,hjsv:6}; a=o.getElementsByTagName('head')[0]; r=o.createElement('script');r.async=1; r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv; a.appendChild(r); })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv='); window.__lc = window.__lc || {}; window.__lc.license = 5732301; (function() { var lc = document.createElement('script'); lc.type = 'text/javascript'; lc.async = true; lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js'; // var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(lc, s); })(); } /* End - Third Party AddOns */ if($rootScope.CompanyPreferences) getCompanyMetaData(); else $rootScope.$on('company-loaded',getCompanyMetaData); function getCompanyMetaData(){ /*Google Analytics Code - Start*/ var GoogleAnalyticsTrackingID = $rootScope.CompanyPreferences.GoogleAnalyticsTrackingID?$rootScope.CompanyPreferences.GoogleAnalyticsTrackingID:'UA-57045915-2'; (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', GoogleAnalyticsTrackingID, 'auto'); ga('send', 'pageview'); /*Google Analytics Code - End*/ } $rootScope.setRequestedLoanFromURL=function($scope){ if(['custom-quote-with-loandata','monthly-quote'].indexOf($state.current.name)!=-1){ for(var i in $scope.appliedProgram.Terms){ if($scope.appliedProgram.Terms[i].Term == $state.params.tenure){ $scope.LoanData.FinanceTenure = $scope.appliedProgram.Terms[i]; } } $scope.LoanData.FinanceAmount = $state.params.Amount; } } $rootScope.newPartialApplication = function(){ $rootScope.custompartialApp = 'custom-partialApp'; $location.path('/custom-quote/'); } $rootScope.newApplication=function(requestedFlow,callback){ if ($rootScope.SignIn) { var reqData={ "FetchPreviousAppData": { "LoginSessionKey": $rootScope.SignIn.LoginSessionKey, "ResolutionID":$rootScope.uaInfo.ResolutionID, "UserAgentID":$rootScope.uaInfo.UserAgentID, "RequestedFlow":requestedFlow, } }; appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ PartialApplication=response.Data; if($state.current.name=='monthly-quote'){ PartialApplication.fixedAmount=true; PartialApplication.LoanData.ApplicationHome.FinanceAmount=parseFloat($state.params.Amount); PartialApplication.LoanData.ApplicationHome.FinanceTenure=parseInt($state.params.tenure); } Storage.setItem('PartialApplications',PartialApplication); if($rootScope.hideEMI) delete $rootScope.hideEMI; if(!requestedFlow) $location.path('/custom-quote/'); if(_.isFunction(callback)) callback(); } else { $rootScope.showFlashMessage('error',response.Message); } }); } } $rootScope.isFunction=_.isFunction; $rootScope.uploadshow = function(){ $rootScope.uploadVisible = true; $rootScope.addfolderVisible = false; $rootScope.shareVisible = false; $rootScope.moveCopyVisible = false; } $rootScope.addfoldershow =function(){ $rootScope.FolderData = {}; $rootScope.addfolderVisible = true; $rootScope.uploadVisible = false; $rootScope.shareVisible = false; $rootScope.moveCopyVisible = false; } $rootScope.shareShow =function(){ $rootScope.shareVisible = true; $rootScope.addfolderVisible = false; $rootScope.uploadVisible = false; $rootScope.moveCopyVisible = false; } $rootScope.moveCopyshow =function(){ $rootScope.moveCopyVisible = true; $rootScope.shareVisible = false; $rootScope.addfolderVisible = false; $rootScope.uploadVisible = false; $rootScope.getFolderList(); } $rootScope.uploadhide = function () { $rootScope.uploadVisible = false; $rootScope.selectedFiles = $rootScope.Page.documents.parentFolder = []; $rootScope.addfolderVisible = false; $rootScope.shareVisible = false; $rootScope.moveCopyVisible = false; } $rootScope.selectAddFiles = function(callback){ var currentFileItem=this.fileItem; if(currentFileItem.checkedFile) { $rootScope.Page.documents.selectedFiles.push(this.fileItem); $rootScope.Page.documents.selectedFileIds.push(this.fileItem.FolderID); } else{ for(var i in $rootScope.Page.documents.selectedFiles){ if($rootScope.Page.documents.selectedFiles[i].FolderID == currentFileItem.FolderID){ $rootScope.Page.documents.selectedFiles.splice(i,1); } } for(var i in $rootScope.Page.documents.selectedFileIds){ if($rootScope.Page.documents.selectedFileIds[i] == currentFileItem.FolderID){ $rootScope.Page.documents.selectedFileIds.splice(i,1); } } } if(callback) callback(); } $rootScope.goToFolder= function(breadCrumbIndex){ var currentFileItem = this.fileItem; if(_.isUndefined(breadCrumbIndex)){ $rootScope.Page.documents.FolderName.push(currentFileItem); $rootScope.refreshFileList(currentFileItem); } else if($rootScope.Page.documents.FolderName.length!=breadCrumbIndex+1){ $rootScope.refreshFileList(currentFileItem); $rootScope.Page.documents.FolderName.splice(breadCrumbIndex+1,$rootScope.Page.documents.FolderName.length-breadCrumbIndex); } } $rootScope.toggleDocumentSharing=function(){ var reqData = { "ShareDocument":{ "LoginSessionKey":$rootScope.SignIn.LoginSessionKey, "selectedFileIDs":$rootScope.Page.documents.selectedFileIds, "ModuleName": $rootScope.Page.documents.ModuleName, "UserID":this.access.UserID, "GrantAccess":this.access.isShared } } // console.log(reqData); appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ $rootScope.showFlashMessage('success', "Access granted successfully."); } else $rootScope.showFlashMessage('error', response.Message); }); } $rootScope.UpdateDocumentName=function(){ if(this.fileItem.edit) { var fileItem=this.fileItem; if(fileItem.OldDocName!=fileItem.ImageName) { var reqData={ "UpdateDocumentName": { "LoginSessionKey": $rootScope.SignIn.LoginSessionKey, "DocumentName": fileItem.ImageName+'.'+fileItem.ImageExt, "MediaID": fileItem.MediaID, "ModuleName": $rootScope.Page.documents.ModuleName } }; appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200) { $rootScope.showFlashMessage('success',response.Message); fileItem.edit=FALSE; } else { $rootScope.showFlashMessage('error',response.Message); } }); fileItem.ImageName+='.'+fileItem.ImageExt; } } else { var a = this.fileItem.ImageName.split("."); if(_.isUndefined(this.fileItem.ImageExt) && (!a.length === 1 || !( a[0] === "" && a.length === 2 )) ) { this.fileItem.ImageExt=a.pop(); this.fileItem.OldDocName=this.fileItem.ImageName; this.fileItem.ImageName=this.fileItem.ImageName.replace('.'+this.fileItem.ImageExt,''); this.fileItem.edit=TRUE; } else { //this.fileItem.ImageExt=a.pop(); this.fileItem.OldDocName=this.fileItem.ImageName; this.fileItem.ImageName=this.fileItem.ImageName.replace('.'+this.fileItem.ImageExt,''); this.fileItem.edit=TRUE; } } } $rootScope.SeeRecordData ={maxDisplayPages: '10'}; $rootScope.refreshFileList=function(filterData){ if(!filterData){ $rootScope.Page.documents.FolderName = []; } if(!$rootScope.requestFileUnderProcess){ $rootScope.Page.trackLoading('documents-list'); var reqData = { "GetFileList": { "LoginSessionKey": $rootScope.SignIn.LoginSessionKey, "PageNo": $rootScope.Page.documents.filter.currentPage, "ClientTZDIFF": $rootScope.uaInfo.ClientTZDIFF, "ModuleEntityID": $rootScope.Page.documents.ModuleEntityID, "ModuleName": $rootScope.Page.documents.ModuleName, "SeeRecords": $rootScope.SeeRecordData.maxDisplayPages } }; $rootScope.requestFileUnderProcess = true; if(filterData){ reqData.GetFileList.Filter = {ParentID:filterData.FolderID}; } $rootScope.Page.documents.files=[]; $rootScope.Page.documents.totalFiles=0; appInfo.getServerData(reqData).then(function(response){ $rootScope.Page.untrackLoading('documents-list'); if(response.ResponseCode==200){ $rootScope.requestFileUnderProcess = false; if(response.Data){ pagingData=[]; $rootScope.Page.documents.selectedFiles=[]; $rootScope.Page.documents.files=response.Data.Filesandfolders; $rootScope.Page.documents.filter.currentPage = pagingData.currentPage=response.Data.Paginator.current_page; pagingData.totalPage=response.Data.Paginator.total_pages; pagingData.totalRecord = $rootScope.Page.documents.totalFiles=response.Data.Paginator.total_filesandfolders; pagingData.numPerPage = $rootScope.SeeRecordData.maxDisplayPages?$rootScope.SeeRecordData.maxDisplayPages:10; $rootScope.showingApplicationtext = appInfo.getPaginationData(pagingData); } } else { $rootScope.showFlashMessage('error',response.Message); } }); } } $rootScope.createDocumentFolder =function(){ var reqData = { "createDocumentFolder":{ "LoginSessionKey":$rootScope.SignIn.LoginSessionKey, "FolderName":$rootScope.FolderData.FolderName, "EntityID": $rootScope.Page.documents.ModuleEntityID, "ModuleName": $rootScope.Page.documents.ModuleName } } appInfo.getServerData(reqData).then(function (response) { if (response.ResponseCode == 200) { $rootScope.showFlashMessage('success', response.Message); $rootScope.addfolderVisible=false; $rootScope.getFolderList(); $rootScope.refreshFileList(); } else { $rootScope.showFlashMessage('error', response.Message); } }); } $rootScope.getFolderList = function(){ $rootScope.showPlusButton = TRUE; var reqData = { "GetFolderList":{ "LoginSessionKey":$rootScope.SignIn.LoginSessionKey, "CreatedBy":$rootScope.SignIn.UserDetails.UserID, "EntityID": $rootScope.Page.documents.ModuleEntityID, "ModuleName": $rootScope.Page.documents.ModuleName } } appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ if(response.Data) $rootScope.folderList = response.Data.List; else $rootScope.folderList = []; } }); } var uploadFileCurrentIndex=0; $rootScope.uploadDocument = function (files,errFiles,requiredDocumentType, callback) { var promises = []; $rootScope.FolderData = {'FolderID':null}; if($rootScope.Page.documents.FolderName.length>0){ var folderLength = $rootScope.Page.documents.FolderName.length-1; $rootScope.FolderData.FolderID = $rootScope.Page.documents.FolderName[folderLength].FolderID; } if ((files.length > 0)) { $rootScope.isAttachementUploading = true; var failedFiles=0; angular.forEach(files, function (fileToUpload, key) { (function (file, fileIndex) { $rootScope.Page.documents.DocumentsData['file-' + fileIndex] = file; $rootScope.Page.documents.DealDocumentsCount = Object.keys($rootScope.Page.documents.DocumentsData).length; var reqData = { "UploadFile": { "EntityID": $rootScope.Page.documents.ModuleEntityID, "ModuleName": $rootScope.Page.documents.ModuleName, "LoginSessionKey": $rootScope.SignIn.LoginSessionKey, "File": file, "FolderID": $rootScope.FolderData.FolderID } }; /*Code for getting ApplicationDocumentID - Start*/ if(requiredDocumentType) { reqData.UploadFile.ApplicationDocumentID = requiredDocumentType.ApplicationDocumentID; } /*Code for getting ApplicationDocumentID - End*/ $rootScope.Page.documents.documentBeingUploaded=file.name; var promise = appInfo.CallUploadFilesApi(reqData, function (response) { if (response.ResponseCode == 200) { $rootScope.Page.documents.DocumentsData['file-' + fileIndex]['data'] = response.Data.Media; $rootScope.Page.documents.DocumentsData['file-' + fileIndex].progress = true; if(_.isFunction($rootScope.Page.documents.postSingleUploadSuccessCallback)) $rootScope.Page.documents.postSingleUploadSuccessCallback(response); if(typeof callback != 'undefined') callback(); } else { delete $rootScope.Page.documents.DocumentsData['file-' + fileIndex]; $rootScope.Page.documents.DealDocumentsCount = Object.keys($rootScope.Page.documents.DocumentsData).length; $rootScope.showFlashMessage('error', response.Message); failedFiles++; $rootScope.Page.documents.documentBeingUploaded=false; } }, function (response) { delete $rootScope.Page.documents.DocumentsData['file-' + fileIndex]; failedFiles++; $rootScope.Page.documents.documentBeingUploaded=false; $rootScope.Page.documents.DealDocumentsCount = Object.keys($rootScope.Page.documents.DocumentsData).length; }, function (evt) { $rootScope.Page.documents.DocumentsData['file-' + fileIndex].progress = evt.uploadPercentage; } ); promises.push(promise); })(fileToUpload, uploadFileCurrentIndex); uploadFileCurrentIndex++; }); $q.all(promises).then(function (data) { $rootScope.TotalFilesize=null; angular.forEach($rootScope.Page.documents.files, function (FileData, key) { $rootScope.TotalFilesize = $rootScope.TotalFilesize+FileData.Size; }); //call api to notify user var reqData = { "SendFileNotification":{ "LoginSessionKey":$rootScope.SignIn.LoginSessionKey, "FileSize":$rootScope.TotalFilesize, "EntityID":$rootScope.Page.documents.ModuleEntityID } } // console.log(reqData); appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ //$rootScope.showFlashMessage('success', "Uploaded successfully."); } else { } //$rootScope.showFlashMessage('error', response.Message); }); //call api to notify user $rootScope.isAttachementUploading = false; $rootScope.currentPage=1; $rootScope.uploading=false; if(!failedFiles) { $rootScope.showFlashMessage('success', "Files uploaded successfully."); $rootScope.refreshFileList($rootScope.FolderData); if(_.isFunction($rootScope.Page.documents.postUploadSuccessCallback)) $rootScope.Page.documents.postUploadSuccessCallback(data); } else { $rootScope.showFlashMessage('error', "File upload failed."); } }); } else { $rootScope.uploading=false; var msg = ''; angular.forEach(errFiles, function (errFile, key) { msg += '\n' + errFile.$errorMessages; promises.push(makeResolvedPromise(msg)); }); $q.all(promises).then(function (data) { $rootScope.showFlashMessage('success', msg); }); } }; $rootScope.selectParentFolder = function(parentData){ $rootScope.Page.documents.parentFolder = parentData; // console.log($scope.selectedFiles); } $rootScope.copyAndMoveData = function(event){ var reqData = { "CopyAndMoveData":{ "LoginSessionKey":$rootScope.SignIn.LoginSessionKey, "Event":event, "selectedFiles":$rootScope.Page.documents.selectedFiles, "parentFolder":$rootScope.Page.documents.parentFolder } } // console.log(reqData); appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ if(event=='Copy') $rootScope.showFlashMessage('success', "File copied successfully."); $rootScope.refreshFileList(_.last($rootScope.Page.documents.FolderName)); $rootScope.uploadhide(); $rootScope.Page.documents.selectedFiles=[]; } else $rootScope.showFlashMessage('error', response.Message); }); } $rootScope.removeRequiredDocument=function(){ var MediaID = this.fileItem.MediaID; var FolderID = this.fileItem.FolderID; var Index = this.$index; $rootScope.ngConfirm('Are you sure you want to remove this document ?',function(){ var reqData={ "RemoveDocuments": { "MediaID": MediaID, "LoginSessionKey": $rootScope.SignIn.LoginSessionKey, "FolderID":FolderID, "ModuleEntityID": $rootScope.Page.documents.ModuleEntityID, "ModuleName": $rootScope.Page.documents.ModuleName, } }; appInfo.getServerData(reqData).then(function(response){ if(response.ResponseCode==200){ $rootScope.showFlashMessage('success',response.Message); $rootScope.refreshFileList(); if($rootScope.Page.documents.removeCallback) $rootScope.Page.documents.removeCallback(); } }); }); } $rootScope.downloadDocumentsZip = function () { appInfo.getZip({ "ModuleEntityID": $rootScope.Page.documents.ModuleEntityID, "ModuleName": $rootScope.Page.documents.ModuleName, },function(response){ if(response.ResponseCode!=200){ $rootScope.showFlashMessage('error',response.Message); } else { $rootScope.Page.zipDialog=ngDialog.open({ template: $rootScope.baseURL+'/partials/dlg-templates/dlg-zipDownloadPopup.html', className: 'ng-popup ngdialog-theme-default differ-modal-container', scope: $rootScope }); $rootScope.Page.zipBeingPrepared.push($rootScope.Page.documents.zipName+'.zip'); } }); } $rootScope.retryLiveConnection=function(){ $timeout.cancel(appInfo.liveConnection.attemptTimer); $timeout.cancel(appInfo.liveConnection.countdownTimer); appInfo.liveConnection.init(); } //number of List Items in navigation bar $timeout(function(){$rootScope.noOfLi = $('#navigation').find('ul').children('li').length},500); //tooltip alignment fix for partial-aaplication (function(){ $(document).on('click','#launch-sp',function(e){ var tooltips = $('.assign-sp'); var l = tooltips.length; var h = $(tooltips[l-1]).height(); var loc = $location.path(); if(loc === "/partial-application"){ if(l > 4){ if(h < 104){ $(tooltips[l-1]).attr("style","top: -16px !important"); $(tooltips[l-2]).attr("style","top: -16px !important"); $(tooltips[l-3]).attr("style","top: -16px !important"); } if(h < 156 && h > 104){ $(tooltips[l-1]).attr("style","top: -174px !important"); $(tooltips[l-2]).attr("style","top: -174px !important"); $(tooltips[l-3]).attr("style","top: -174px !important"); } } else if(l < 4){ if(h < 104){ $(tooltips[l-1]).attr("style","top: -16px !important"); $(tooltips[l-2]).attr("style","top: -16px !important"); $(tooltips[l-3]).attr("style","top: -16px !important"); } if(h < 156 && h > 104){ $(tooltips[l-1]).attr("style","top: -174px !important"); $(tooltips[l-2]).attr("style","top: -174px !important"); $(tooltips[l-3]).attr("style","top: -174px !important"); } } } }) })(); }]) .config(['ngClipProvider', function(ngClipProvider) { ngClipProvider.setPath("//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.6/ZeroClipboard.swf"); }]); angular.module('ngClipboard', []). provider('ngClip', function() { var self = this; this.path = '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.6/ZeroClipboard.swf'; return { setPath: function(newPath) { self.path = newPath; }, setConfig: function(config) { self.config = config; }, $get: function() { return { path: self.path, config: self.config }; } }; }). run(['ngClip', function(ngClip) { var config = { swfPath: ngClip.path, trustedDomains: ["*"], allowScriptAccess: "always", forceHandCursor: true, }; ZeroClipboard.config(angular.extend(config,ngClip.config || {})); }]). directive('clipCopy', ['ngClip', function (ngClip) { return { scope: { clipCopy: '&', clipClick: '&', clipClickFallback: '&' }, restrict: 'A', link: function (scope, element, attrs) { // Bind a fallback function if flash is unavailable if (ZeroClipboard.isFlashUnusable()) { element.bind('click', function($event) { // Execute the expression with local variables `$event` and `copy` scope.$apply(scope.clipClickFallback({ $event: $event, copy: scope.$eval(scope.clipCopy) })); }); return; } // Create the client object var client = new ZeroClipboard(element); if (attrs.clipCopy === "") { scope.clipCopy = function(scope) { return element[0].previousElementSibling.innerText; }; } client.on( 'ready', function(readyEvent) { client.on('copy', function (event) { var clipboard = event.clipboardData; clipboard.setData(attrs.clipCopyMimeType || 'text/plain', scope.$eval(scope.clipCopy)); }); client.on( 'aftercopy', function(event) { if (angular.isDefined(attrs.clipClick)) { scope.$apply(scope.clipClick); } }); scope.$on('$destroy', function() { client.destroy(); }); }); } }; }])