|
14 | 14 | return str; |
15 | 15 | } |
16 | 16 |
|
| 17 | + var defaultLinks = [ |
| 18 | + { |
| 19 | + "text": "Terms and Conditions", |
| 20 | + "link": "https://termsandconditions.com", |
| 21 | + "textValue": "Terms and Conditions", |
| 22 | + "linkValue": "https://termsandconditions.com" |
| 23 | + }, |
| 24 | + { |
| 25 | + "text": "Privacy Policy", |
| 26 | + "link": "https://privacyPolicy.com", |
| 27 | + "textValue": "Privacy Policy", |
| 28 | + "linkValue": "https://privacyPolicy.com" |
| 29 | + } |
| 30 | + ]; |
| 31 | + |
17 | 32 | var consentLink = countlyVue.views.create({ |
18 | 33 | template: CV.T("/star-rating/templates/star-consent-link.html"), |
19 | 34 | props: { |
|
38 | 53 | this.$delete(this.links, index); |
39 | 54 | }, |
40 | 55 | onDelete: function(id) { |
41 | | - if (this.value.link.length > 1 && this.value.link.length <= this.maxLinks) { |
42 | | - this.value.link.splice(id, 1); |
| 56 | + if (this.value.links.length > 1 && this.value.links.length <= this.maxLinks) { |
| 57 | + this.value.links.splice(id, 1); |
43 | 58 | } |
44 | 59 | }, |
45 | 60 | add: function() { |
46 | | - this.value.link.push({ |
| 61 | + this.value.links.push({ |
47 | 62 | "text": "Another Link", |
48 | 63 | "link": "https://otherlink.com", |
49 | 64 | "textValue": "Another Link", |
|
53 | 68 | }, |
54 | 69 | computed: { |
55 | 70 | newLinkAllowed: function() { |
56 | | - return !this.readOnly && this.value.link.length < this.maxLinks; |
| 71 | + return !this.readOnly && this.value.links.length < this.maxLinks; |
57 | 72 | } |
58 | 73 | } |
59 | 74 | }); |
|
117 | 132 | // drawer event handlers |
118 | 133 | onConsentCheckbox: function(ev) { |
119 | 134 | if (!ev.links || ev.links.length < 1) { |
120 | | - ev.links = { |
121 | | - "link": [ |
122 | | - { |
123 | | - "text": "Terms and Conditions", |
124 | | - "link": "https://termsandconditions.com", |
125 | | - "textValue": "Terms and Conditions", |
126 | | - "linkValue": "https://termsandconditions.com" |
127 | | - }, |
128 | | - { |
129 | | - "text": "Privacy Policy", |
130 | | - "link": "https://privacyPolicy.com", |
131 | | - "textValue": "Privacy Policy", |
132 | | - "linkValue": "https://privacyPolicy.com" |
133 | | - } |
134 | | - ], |
135 | | - "finalText": "I agree to the Terms and Conditions and Privacy Policy.", |
136 | | - }; |
| 135 | + ev.links = defaultLinks; |
| 136 | + } |
| 137 | + |
| 138 | + if (typeof ev.finalText !== "string" || !ev.finalText) { |
| 139 | + ev.finalText = "I agree to the Terms and Conditions and Privacy Policy."; |
137 | 140 | } |
138 | 141 | }, |
139 | | - finalTxt: function(links) { |
140 | | - let finalText = links.finalText; |
| 142 | + finalTxt: function(links, inpFinalText) { |
| 143 | + var finalText = inpFinalText; |
141 | 144 |
|
142 | | - links.link.forEach(link => { |
143 | | - const regex = new RegExp(`\\b${link.textValue}\\b`, 'g'); |
144 | | - finalText = finalText.replace(regex, `<a href="${link.linkValue}" target="_blank">${link.textValue}</a>`); |
145 | | - }); |
| 145 | + if (links && !Array.isArray(links) && typeof links.finalText === 'string') { |
| 146 | + finalText = links.finalText; |
| 147 | + } |
| 148 | + else if (Array.isArray(links) && typeof finalText === 'string') { |
| 149 | + links.forEach(link => { |
| 150 | + const regex = new RegExp(`\\b${link.textValue}\\b`, 'g'); |
| 151 | + finalText = finalText.replace(regex, `<a href="${link.linkValue}" target="_blank">${link.textValue}</a>`); |
| 152 | + }); |
| 153 | + } |
146 | 154 |
|
147 | 155 | return finalText; |
148 | 156 | }, |
|
163 | 171 | onSubmit: function(submitted, done) { |
164 | 172 | var self = this; |
165 | 173 | if (submitted.links) { |
166 | | - submitted.finalText = submitted.links.finalText; |
167 | | - submitted.links = submitted.links.link; |
168 | | - submitted.links.forEach(function(link) { |
169 | | - var separator = link.linkValue.indexOf('?') !== -1 ? '&' : '?'; |
170 | | - link.linkValue = link.linkValue + separator + CLY_X_INT + '=1'; |
171 | | - delete link.text; |
172 | | - delete link.link; |
173 | | - }); |
| 174 | + if (!submitted.finalText && !Array.isArray(submitted.links) && submitted.links.finalText && Array.isArray(submitted.links.link)) { |
| 175 | + submitted.finalText = submitted.links.finalText; |
| 176 | + submitted.links = submitted.links.link; |
| 177 | + } |
| 178 | + |
| 179 | + if (Array.isArray(submitted.links)) { |
| 180 | + submitted.links.forEach(function(link) { |
| 181 | + var separator = link.linkValue.indexOf('?') !== -1 ? '&' : '?'; |
| 182 | + link.linkValue = link.linkValue + separator + CLY_X_INT + '=1'; |
| 183 | + delete link.text; |
| 184 | + delete link.link; |
| 185 | + }); |
| 186 | + } |
174 | 187 | } |
175 | 188 | if (this.logoFile !== "") { |
176 | 189 | submitted.logo = this.logoFile; |
|
861 | 874 | } |
862 | 875 | this.openDrawer("widget", { |
863 | 876 | consent: false, |
| 877 | + finalText: "I agree to the Terms and Conditions and Privacy Policy.", |
| 878 | + links: defaultLinks, |
864 | 879 | popup_header_text: 'What\'s your opinion about this page?', |
865 | 880 | popup_thanks_message: 'Thanks for your feedback!', |
866 | 881 | popup_button_callout: 'Submit Feedback', |
|
1141 | 1156 | } |
1142 | 1157 |
|
1143 | 1158 | } |
1144 | | - starRatingPlugin.editFeedbackWidget({ _id: this.widget._id, status: (state), target_pages: target_pages, targeting: finalizedTargeting }, function() { |
| 1159 | + starRatingPlugin.editFeedbackWidget({ _id: this.widget._id, status: (state), target_pages: target_pages, targeting: finalizedTargeting, links: this.widget.links }, function() { |
1145 | 1160 | self.widget.is_active = (state ? "true" : "false"); |
1146 | 1161 | self.widget.status = state; |
1147 | 1162 |
|
|
1186 | 1201 | } |
1187 | 1202 | link.linkValue = link.linkValue.replace(new RegExp('[?&]' + CLY_X_INT + '=[^&]*'), '').replace(/[?&]$/, ''); |
1188 | 1203 | }); |
1189 | | - this.widget.links = {"link": this.widget.links, "finalText": this.widget.finalText}; |
1190 | 1204 | } |
1191 | 1205 | else { |
1192 | 1206 | this.widget.links = { |
|
1230 | 1244 | if (!this.widget.trigger_size) { |
1231 | 1245 | this.widget.trigger_size = 'm'; |
1232 | 1246 | } |
1233 | | - if (!this.widget.status) { |
| 1247 | + if (typeof this.widget.status !== 'boolean') { |
1234 | 1248 | this.widget.status = true; |
1235 | 1249 | } |
1236 | 1250 | if (!this.widget.logo) { |
|
0 commit comments