|
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 | }); |
|
125 | 140 | // drawer event handlers |
126 | 141 | onConsentCheckbox: function(ev) { |
127 | 142 | if (!ev.links || ev.links.length < 1) { |
128 | | - ev.links = { |
129 | | - "link": [ |
130 | | - { |
131 | | - "text": "Terms and Conditions", |
132 | | - "link": "https://termsandconditions.com", |
133 | | - "textValue": "Terms and Conditions", |
134 | | - "linkValue": "https://termsandconditions.com" |
135 | | - }, |
136 | | - { |
137 | | - "text": "Privacy Policy", |
138 | | - "link": "https://privacyPolicy.com", |
139 | | - "textValue": "Privacy Policy", |
140 | | - "linkValue": "https://privacyPolicy.com" |
141 | | - } |
142 | | - ], |
143 | | - "finalText": "I agree to the Terms and Conditions and Privacy Policy.", |
144 | | - }; |
| 143 | + ev.links = defaultLinks; |
| 144 | + } |
| 145 | + |
| 146 | + if (typeof ev.finalText !== "string" || !ev.finalText) { |
| 147 | + ev.finalText = "I agree to the Terms and Conditions and Privacy Policy."; |
145 | 148 | } |
146 | 149 | }, |
147 | | - finalTxt: function(links) { |
148 | | - let finalText = links.finalText; |
| 150 | + finalTxt: function(links, inpFinalText) { |
| 151 | + var finalText = inpFinalText; |
149 | 152 |
|
150 | | - links.link.forEach(link => { |
151 | | - const regex = new RegExp(`\\b${link.textValue}\\b`, 'g'); |
152 | | - finalText = finalText.replace(regex, `<a href="${link.linkValue}" target="_blank">${link.textValue}</a>`); |
153 | | - }); |
| 153 | + if (links && !Array.isArray(links) && typeof links.finalText === 'string') { |
| 154 | + finalText = links.finalText; |
| 155 | + } |
| 156 | + else if (Array.isArray(links) && typeof finalText === 'string') { |
| 157 | + links.forEach(link => { |
| 158 | + const regex = new RegExp(`\\b${link.textValue}\\b`, 'g'); |
| 159 | + finalText = finalText.replace(regex, `<a href="${link.linkValue}" target="_blank">${link.textValue}</a>`); |
| 160 | + }); |
| 161 | + } |
154 | 162 |
|
155 | 163 | return finalText; |
156 | 164 | }, |
|
171 | 179 | onSubmit: function(submitted, done) { |
172 | 180 | var self = this; |
173 | 181 | if (submitted.links) { |
174 | | - submitted.finalText = submitted.links.finalText; |
175 | | - submitted.links = submitted.links.link; |
176 | | - submitted.links.forEach(function(link) { |
177 | | - var separator = link.linkValue.indexOf('?') !== -1 ? '&' : '?'; |
178 | | - link.linkValue = link.linkValue + separator + CLY_X_INT + '=1'; |
179 | | - delete link.text; |
180 | | - delete link.link; |
181 | | - }); |
| 182 | + if (!submitted.finalText && !Array.isArray(submitted.links) && submitted.links.finalText && Array.isArray(submitted.links.link)) { |
| 183 | + submitted.finalText = submitted.links.finalText; |
| 184 | + submitted.links = submitted.links.link; |
| 185 | + } |
| 186 | + |
| 187 | + if (Array.isArray(submitted.links)) { |
| 188 | + submitted.links.forEach(function(link) { |
| 189 | + var separator = link.linkValue.indexOf('?') !== -1 ? '&' : '?'; |
| 190 | + link.linkValue = link.linkValue + separator + CLY_X_INT + '=1'; |
| 191 | + delete link.text; |
| 192 | + delete link.link; |
| 193 | + }); |
| 194 | + } |
182 | 195 | } |
183 | 196 | if (this.logoFile !== "") { |
184 | 197 | submitted.logo = this.logoFile; |
|
892 | 905 | } |
893 | 906 | this.openDrawer("widget", { |
894 | 907 | consent: false, |
| 908 | + finalText: "I agree to the Terms and Conditions and Privacy Policy.", |
| 909 | + links: defaultLinks, |
895 | 910 | popup_header_text: 'What\'s your opinion about this page?', |
896 | 911 | popup_thanks_message: 'Thanks for your feedback!', |
897 | 912 | popup_button_callout: 'Submit Feedback', |
|
1172 | 1187 | } |
1173 | 1188 |
|
1174 | 1189 | } |
1175 | | - starRatingPlugin.editFeedbackWidget({ _id: this.widget._id, status: (state), target_pages: target_pages, targeting: finalizedTargeting }, function() { |
| 1190 | + starRatingPlugin.editFeedbackWidget({ _id: this.widget._id, status: (state), target_pages: target_pages, targeting: finalizedTargeting, links: this.widget.links }, function() { |
1176 | 1191 | self.widget.is_active = (state ? "true" : "false"); |
1177 | 1192 | self.widget.status = state; |
1178 | 1193 |
|
|
1217 | 1232 | } |
1218 | 1233 | link.linkValue = link.linkValue.replace(new RegExp('[?&]' + CLY_X_INT + '=[^&]*'), '').replace(/[?&]$/, ''); |
1219 | 1234 | }); |
1220 | | - this.widget.links = {"link": this.widget.links, "finalText": this.widget.finalText}; |
1221 | 1235 | } |
1222 | 1236 | else { |
1223 | 1237 | this.widget.links = { |
|
1261 | 1275 | if (!this.widget.trigger_size) { |
1262 | 1276 | this.widget.trigger_size = 'm'; |
1263 | 1277 | } |
1264 | | - if (!this.widget.status) { |
| 1278 | + if (typeof this.widget.status !== 'boolean') { |
1265 | 1279 | this.widget.status = true; |
1266 | 1280 | } |
1267 | 1281 | if (!this.widget.logo) { |
|
0 commit comments