@@ -27,102 +27,104 @@ appChallengeTerms = {
27
27
} ,
28
28
29
29
initDetail : function ( tcjwt ) {
30
- if ( app . isLoggedIn ( ) ) {
31
- app . setLoading ( ) ;
32
- $ . ajax ( {
33
- type : "GET" ,
34
- url : tcconfig . apiURL + "/terms/detail/" + termsOfUseID ,
35
- dataType : 'json' ,
36
- headers : {
37
- 'Authorization' : 'Bearer ' + tcjwt . replace ( / [ " ] / g, "" )
38
- } ,
39
- success : function ( data ) {
40
- $ ( ".formContent" ) . addClass ( "pageContent" ) ;
41
- if ( data . title ) {
42
- $ ( ".formContent .terms" ) . show ( ) ;
43
- $ ( ".formContent .warning" ) . hide ( ) ;
44
- $ ( ".overviewPageTitle" ) . text ( data [ "title" ] ) ;
45
- //Bugfix I-116354
46
- $ ( '#agreement-section' ) . removeClass ( 'hide' ) ;
47
-
48
- if ( data . agreeabilityType === 'Non-electronically-agreeable' ) {
49
- $ ( '#agreement-section' ) . addClass ( 'hide' ) ;
50
- $ ( '.loading' ) . hide ( ) ;
51
- $ ( ".termsText" ) . html ( data . text ) ;
52
- } else if ( data [ "agreeabilityType" ] !== "Electronically-agreeable" && typeof data [ "docusignTemplateId" ] !== "undefined" ) {
53
- //if DocuSign, get URL from docuSign API and output iframe
54
- $ ( '.agree-label' ) . hide ( ) ;
55
- $ ( '#termSubmit' ) . text ( 'Go Back' ) ;
56
- $ ( '.agreement' ) . removeClass ( 'notAgreed' ) ;
57
- var finalDest = escape ( tcconfig . mainURL + "/challenge-details/terms/" + challengeId + "?challenge-type=" + challengeType + "&cb=" + Math . random ( ) ) ;
58
- $ . ajax ( {
59
- url : tcconfig . apiURL + '/terms/docusign/viewURL' ,
60
- type : 'POST' ,
61
- data : {
62
- templateId : data [ "docusignTemplateId" ] ,
63
- returnUrl : tcconfig . mainURL + "/iframe-break/?dest=" + finalDest
64
- } ,
65
- cache : false ,
66
- beforeSend : function ( bxhr ) {
67
- bxhr . setRequestHeader ( 'Authorization' , 'Bearer ' + tcjwt . replace ( / [ " ] / g, "" ) ) ;
68
- } ,
69
- complete : function ( docuData ) {
70
- $ ( '.loading' ) . hide ( ) ;
71
- //output iframe when AJAX data returns
72
- var responseObj = docuData . responseJSON ;
73
- if ( typeof responseObj [ "recipientViewUrl" ] !== "undefined" ) {
74
- $ ( ".termsText" ) . html ( '<iframe class="termsFrame" src="' + responseObj [ "recipientViewUrl" ] + '"></iframe>' ) ;
75
- } else {
76
- //url not in data result, error
77
- $ ( ".formContent .terms" ) . hide ( ) ;
78
- $ ( ".formContent .warning" ) . text ( responseObj [ "description" ] ) ;
79
- $ ( ".formContent .warning" ) . show ( ) ;
80
- }
81
- } ,
82
- error : function ( jqXHR , textStatus , errorThrown ) {
83
- // Handle errors here
84
- $ ( ".termsText" ) . html ( 'Sorry, your request could not be completed at this time.' ) ;
85
- }
86
- } ) ;
87
- } else {
88
- $ ( '.loading' ) . hide ( ) ;
89
- //if not docuSign, output normal terms text
90
- $ ( ".termsText" ) . html ( data [ "text" ] ) ;
30
+ app . setLoading ( ) ;
31
+ $ . ajax ( {
32
+ type : "GET" ,
33
+ url : tcconfig . apiURL + "/terms/detail/" + termsOfUseID + ( app . isLoggedIn ( ) ? '' : '?noauth=true' ) ,
34
+ dataType : 'json' ,
35
+ headers : app . isLoggedIn ( ) ? {
36
+ 'Authorization' : 'Bearer ' + tcjwt . replace ( / [ " ] / g, "" )
37
+ } : { } ,
38
+ success : function ( data ) {
39
+ $ ( ".formContent" ) . addClass ( "pageContent" ) ;
40
+ if ( data . title ) {
41
+ $ ( ".formContent .terms" ) . show ( ) ;
42
+ $ ( ".formContent .warning" ) . hide ( ) ;
43
+ $ ( ".overviewPageTitle" ) . text ( data [ "title" ] ) ;
44
+ //Bugfix I-116354
45
+ $ ( '#agreement-section' ) . removeClass ( 'hide' ) ;
46
+
47
+ if ( data . agreeabilityType === 'Non-electronically-agreeable' ) {
48
+ $ ( '#agreement-section' ) . addClass ( 'hide' ) ;
49
+ $ ( '.loading' ) . hide ( ) ;
50
+ $ ( ".termsText" ) . html ( data . text ) ;
51
+ } else if ( data [ "agreeabilityType" ] !== "Electronically-agreeable" && typeof data [ "docusignTemplateId" ] !== "undefined" ) {
52
+ if ( ! app . isLoggedIn ( ) ) {
53
+ window . location . href = '/login?next=' + window . location . href ;
91
54
}
55
+ //if DocuSign, get URL from docuSign API and output iframe
56
+ $ ( '.agree-label' ) . hide ( ) ;
57
+ $ ( '#termSubmit' ) . text ( 'Go Back' ) ;
58
+ $ ( '.agreement' ) . removeClass ( 'notAgreed' ) ;
59
+ var finalDest = escape ( tcconfig . mainURL + "/challenge-details/terms/" + challengeId + "?challenge-type=" + challengeType + "&cb=" + Math . random ( ) ) ;
60
+ $ . ajax ( {
61
+ url : tcconfig . apiURL + '/terms/docusign/viewURL' ,
62
+ type : 'POST' ,
63
+ data : {
64
+ templateId : data [ "docusignTemplateId" ] ,
65
+ returnUrl : tcconfig . mainURL + "/iframe-break/?dest=" + finalDest
66
+ } ,
67
+ cache : false ,
68
+ beforeSend : function ( bxhr ) {
69
+ bxhr . setRequestHeader ( 'Authorization' , 'Bearer ' + tcjwt . replace ( / [ " ] / g, "" ) ) ;
70
+ } ,
71
+ complete : function ( docuData ) {
72
+ $ ( '.loading' ) . hide ( ) ;
73
+ //output iframe when AJAX data returns
74
+ var responseObj = docuData . responseJSON ;
75
+ if ( typeof responseObj [ "recipientViewUrl" ] !== "undefined" ) {
76
+ $ ( ".termsText" ) . html ( '<iframe class="termsFrame" src="' + responseObj [ "recipientViewUrl" ] + '"></iframe>' ) ;
77
+ } else {
78
+ //url not in data result, error
79
+ $ ( ".formContent .terms" ) . hide ( ) ;
80
+ $ ( ".formContent .warning" ) . text ( responseObj [ "description" ] ) ;
81
+ $ ( ".formContent .warning" ) . show ( ) ;
82
+ }
83
+ } ,
84
+ error : function ( jqXHR , textStatus , errorThrown ) {
85
+ // Handle errors here
86
+ $ ( ".termsText" ) . html ( 'Sorry, your request could not be completed at this time.' ) ;
87
+ }
88
+ } ) ;
92
89
} else {
93
90
$ ( '.loading' ) . hide ( ) ;
94
- $ ( ".formContent .terms" ) . hide ( ) ;
95
- $ ( ".formContent .warning" ) . text ( data [ "error" ] [ "details" ] ) ;
96
- $ ( ".formContent .warning" ) . show ( ) ;
91
+ //if not docuSign, output normal terms text
92
+ $ ( ".termsText" ) . html ( data [ "text" ] ) ;
97
93
}
98
- $ ( '#agree' ) . change ( function ( ) {
99
- if ( $ ( this ) . prop ( 'checked' ) ) {
100
- $ ( this ) . closest ( 'section.agreement' ) . removeClass ( 'notAgreed' ) ;
101
- } else {
102
- $ ( this ) . closest ( 'section.agreement' ) . addClass ( 'notAgreed' ) ;
103
- }
104
- } ) ;
105
- $ ( "#termSubmit" ) . click ( function ( ) {
106
- if ( $ ( this ) . parents ( ".notAgreed" ) . length === 0 ) {
107
- app . setLoading ( ) ;
108
- $ . ajax ( {
109
- type : "POST" ,
110
- url : tcconfig . apiURL + "/terms/" + termsOfUseID + "/agree" ,
111
- dataType : 'json' ,
112
- headers : {
113
- 'Authorization' : 'Bearer ' + tcjwt . replace ( / [ " ] / g, "" )
114
- } ,
115
- success : function ( data ) {
116
- window . location = tcconfig . mainURL + "/challenge-details/terms/" + challengeId + "?challenge-type=" + challengeType ;
117
- $ ( '.loading' ) . hide ( ) ;
118
- }
119
- } ) ;
120
- }
121
- } ) ;
94
+ } else {
95
+ $ ( '.loading' ) . hide ( ) ;
96
+ $ ( ".formContent .terms" ) . hide ( ) ;
97
+ $ ( ".formContent .warning" ) . text ( data [ "error" ] [ "details" ] ) ;
98
+ $ ( ".formContent .warning" ) . show ( ) ;
122
99
}
123
- } ) ;
124
- } else {
125
- $ ( '.actionLogin' ) . click ( ) ;
100
+ $ ( '#agree' ) . change ( function ( ) {
101
+ if ( $ ( this ) . prop ( 'checked' ) ) {
102
+ $ ( this ) . closest ( 'section.agreement' ) . removeClass ( 'notAgreed' ) ;
103
+ } else {
104
+ $ ( this ) . closest ( 'section.agreement' ) . addClass ( 'notAgreed' ) ;
105
+ }
106
+ } ) ;
107
+ $ ( "#termSubmit" ) . click ( function ( ) {
108
+ if ( $ ( this ) . parents ( ".notAgreed" ) . length === 0 ) {
109
+ app . setLoading ( ) ;
110
+ $ . ajax ( {
111
+ type : "POST" ,
112
+ url : tcconfig . apiURL + "/terms/" + termsOfUseID + "/agree" ,
113
+ dataType : 'json' ,
114
+ headers : {
115
+ 'Authorization' : 'Bearer ' + tcjwt . replace ( / [ " ] / g, "" )
116
+ } ,
117
+ success : function ( data ) {
118
+ window . location = tcconfig . mainURL + "/challenge-details/terms/" + challengeId + "?challenge-type=" + challengeType ;
119
+ $ ( '.loading' ) . hide ( ) ;
120
+ }
121
+ } ) ;
122
+ }
123
+ } ) ;
124
+ }
125
+ } ) ;
126
+ if ( ! app . isLoggedIn ( ) ) {
127
+ $ ( '#submitForm' ) . hide ( ) ;
126
128
}
127
129
} ,
128
130
0 commit comments