@patch-adams/plugin-feedback 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1020 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +331 -0
- package/dist/index.d.ts +331 -0
- package/dist/index.js +1009 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1009 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/config.ts
|
|
4
|
+
var IssueSubtypeSchema = z.object({
|
|
5
|
+
/** Unique identifier for the subtype */
|
|
6
|
+
id: z.string().min(1),
|
|
7
|
+
/** Display label for the subtype */
|
|
8
|
+
label: z.string().min(1)
|
|
9
|
+
});
|
|
10
|
+
var IssueTypeSchema = z.object({
|
|
11
|
+
/** Unique identifier for the issue type */
|
|
12
|
+
id: z.string().min(1),
|
|
13
|
+
/** Display label for the issue type */
|
|
14
|
+
label: z.string().min(1),
|
|
15
|
+
/** Optional subtypes that appear when this type is selected */
|
|
16
|
+
subtypes: z.array(IssueSubtypeSchema).optional()
|
|
17
|
+
});
|
|
18
|
+
var MetadataOptionsSchema = z.object({
|
|
19
|
+
/** Include the course ID from LRS bridge (if available) */
|
|
20
|
+
courseId: z.boolean().default(true),
|
|
21
|
+
/** Include the current lesson/page ID (URL hash or pathname) */
|
|
22
|
+
lessonId: z.boolean().default(true),
|
|
23
|
+
/** Include the browser user agent */
|
|
24
|
+
userAgent: z.boolean().default(true),
|
|
25
|
+
/** Include timestamp of submission */
|
|
26
|
+
timestamp: z.boolean().default(true),
|
|
27
|
+
/** Include the full current URL */
|
|
28
|
+
url: z.boolean().default(true)
|
|
29
|
+
});
|
|
30
|
+
var DEFAULT_ISSUE_TYPES = [
|
|
31
|
+
{
|
|
32
|
+
id: "content",
|
|
33
|
+
label: "Content Issue",
|
|
34
|
+
subtypes: [
|
|
35
|
+
{ id: "typo", label: "Typo / Grammar" },
|
|
36
|
+
{ id: "incorrect", label: "Incorrect Information" },
|
|
37
|
+
{ id: "unclear", label: "Unclear / Confusing" },
|
|
38
|
+
{ id: "outdated", label: "Outdated Content" }
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "technical",
|
|
43
|
+
label: "Technical Issue",
|
|
44
|
+
subtypes: [
|
|
45
|
+
{ id: "audio", label: "Audio Problem" },
|
|
46
|
+
{ id: "video", label: "Video Problem" },
|
|
47
|
+
{ id: "navigation", label: "Navigation Issue" },
|
|
48
|
+
{ id: "display", label: "Display / Layout Issue" }
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "suggestion",
|
|
53
|
+
label: "Suggestion"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "other",
|
|
57
|
+
label: "Other"
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
var FeedbackConfigSchema = z.object({
|
|
61
|
+
/** Whether the feedback plugin is enabled */
|
|
62
|
+
enabled: z.boolean().default(true),
|
|
63
|
+
// === Endpoint Configuration ===
|
|
64
|
+
/** API endpoint URL for submitting feedback (optional - if not set, logs to console) */
|
|
65
|
+
endpoint: z.string().url().optional(),
|
|
66
|
+
/** HTTP method for the endpoint (default: POST) */
|
|
67
|
+
method: z.enum(["POST", "PUT"]).default("POST"),
|
|
68
|
+
/** Additional headers to send with the request */
|
|
69
|
+
headers: z.record(z.string()).optional(),
|
|
70
|
+
// === Appearance ===
|
|
71
|
+
/** Position of the feedback tab (left or right side of screen) */
|
|
72
|
+
position: z.enum(["left", "right"]).default("right"),
|
|
73
|
+
/** Text displayed on the feedback tab */
|
|
74
|
+
tabText: z.string().default("Feedback"),
|
|
75
|
+
/** Background color of the feedback tab */
|
|
76
|
+
tabColor: z.string().default("#007bff"),
|
|
77
|
+
/** Text color of the feedback tab */
|
|
78
|
+
tabTextColor: z.string().default("#ffffff"),
|
|
79
|
+
/** Z-index for the feedback widget (default: 9999) */
|
|
80
|
+
zIndex: z.number().default(9999),
|
|
81
|
+
// === Form Fields ===
|
|
82
|
+
/** Show star rating field */
|
|
83
|
+
showRating: z.boolean().default(true),
|
|
84
|
+
/** Whether rating is required to submit */
|
|
85
|
+
ratingRequired: z.boolean().default(false),
|
|
86
|
+
/** Number of stars in the rating (default: 5) */
|
|
87
|
+
ratingStars: z.number().min(3).max(10).default(5),
|
|
88
|
+
/** Show issue type dropdown */
|
|
89
|
+
showIssueType: z.boolean().default(true),
|
|
90
|
+
/** Whether issue type is required to submit */
|
|
91
|
+
issueTypeRequired: z.boolean().default(false),
|
|
92
|
+
/** Available issue types (uses defaults if not provided) */
|
|
93
|
+
issueTypes: z.array(IssueTypeSchema).optional(),
|
|
94
|
+
/** Show comment textarea */
|
|
95
|
+
showComment: z.boolean().default(true),
|
|
96
|
+
/** Whether comment is required to submit */
|
|
97
|
+
commentRequired: z.boolean().default(false),
|
|
98
|
+
/** Maximum length for comments (default: 500) */
|
|
99
|
+
commentMaxLength: z.number().min(50).max(5e3).default(500),
|
|
100
|
+
/** Placeholder text for comment field (uses translation if not set) */
|
|
101
|
+
commentPlaceholder: z.string().optional(),
|
|
102
|
+
// === Language / i18n ===
|
|
103
|
+
/** Locale for UI text (en or fr) */
|
|
104
|
+
locale: z.enum(["en", "fr"]).default("en"),
|
|
105
|
+
/** Custom translations (overrides built-in translations) */
|
|
106
|
+
translations: z.record(z.string()).optional(),
|
|
107
|
+
// === Metadata ===
|
|
108
|
+
/** What metadata to include with feedback submissions */
|
|
109
|
+
includeMetadata: MetadataOptionsSchema.default({}),
|
|
110
|
+
// === Behavior ===
|
|
111
|
+
/** Auto-close modal after successful submission (default: true) */
|
|
112
|
+
autoClose: z.boolean().default(true),
|
|
113
|
+
/** Delay in ms before auto-closing after success (default: 2000) */
|
|
114
|
+
autoCloseDelay: z.number().min(500).max(1e4).default(2e3),
|
|
115
|
+
/** Enable debug logging (default: false) */
|
|
116
|
+
debug: z.boolean().default(false)
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// src/i18n/en.json
|
|
120
|
+
var en_default = {
|
|
121
|
+
title: "Send Feedback",
|
|
122
|
+
ratingLabel: "How would you rate this content?",
|
|
123
|
+
issueTypeLabel: "What type of feedback?",
|
|
124
|
+
selectIssueType: "Select type...",
|
|
125
|
+
subtypeLabel: "More specifically:",
|
|
126
|
+
selectSubtype: "Select...",
|
|
127
|
+
commentLabel: "Your feedback",
|
|
128
|
+
commentPlaceholder: "Please describe your feedback in detail...",
|
|
129
|
+
submit: "Send Feedback",
|
|
130
|
+
submitting: "Sending...",
|
|
131
|
+
thankYou: "Thank you for your feedback!",
|
|
132
|
+
errorSubmitting: "Failed to send feedback. Please try again.",
|
|
133
|
+
errorRequired: "Please fill in the required fields.",
|
|
134
|
+
characterCount: "{current}/{max}"
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// src/i18n/fr.json
|
|
138
|
+
var fr_default = {
|
|
139
|
+
title: "Envoyer un commentaire",
|
|
140
|
+
ratingLabel: "Comment \xE9valuez-vous ce contenu?",
|
|
141
|
+
issueTypeLabel: "Type de commentaire",
|
|
142
|
+
selectIssueType: "S\xE9lectionner...",
|
|
143
|
+
subtypeLabel: "Plus pr\xE9cis\xE9ment:",
|
|
144
|
+
selectSubtype: "S\xE9lectionner...",
|
|
145
|
+
commentLabel: "Votre commentaire",
|
|
146
|
+
commentPlaceholder: "Veuillez d\xE9crire votre commentaire en d\xE9tail...",
|
|
147
|
+
submit: "Envoyer",
|
|
148
|
+
submitting: "Envoi en cours...",
|
|
149
|
+
thankYou: "Merci pour votre commentaire!",
|
|
150
|
+
errorSubmitting: "\xC9chec de l'envoi. Veuillez r\xE9essayer.",
|
|
151
|
+
errorRequired: "Veuillez remplir les champs obligatoires.",
|
|
152
|
+
characterCount: "{current}/{max}"
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/i18n/index.ts
|
|
156
|
+
var translations = {
|
|
157
|
+
en: en_default,
|
|
158
|
+
fr: fr_default
|
|
159
|
+
};
|
|
160
|
+
function getTranslations(locale, overrides) {
|
|
161
|
+
const base = translations[locale] || translations.en;
|
|
162
|
+
if (overrides) {
|
|
163
|
+
return { ...base, ...overrides };
|
|
164
|
+
}
|
|
165
|
+
return base;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// src/widget.ts
|
|
169
|
+
function generateFeedbackWidget(config) {
|
|
170
|
+
const t = getTranslations(config.locale, config.translations);
|
|
171
|
+
const issueTypes = config.issueTypes || DEFAULT_ISSUE_TYPES;
|
|
172
|
+
return `
|
|
173
|
+
(function() {
|
|
174
|
+
'use strict';
|
|
175
|
+
|
|
176
|
+
// ============================================================================
|
|
177
|
+
// FEEDBACK WIDGET - Patch-Adams Plugin v1.0.0
|
|
178
|
+
// ============================================================================
|
|
179
|
+
|
|
180
|
+
var FEEDBACK = window.pa_patcher = window.pa_patcher || {};
|
|
181
|
+
FEEDBACK.feedback = {
|
|
182
|
+
version: '1.0.0',
|
|
183
|
+
isOpen: false,
|
|
184
|
+
rating: 0,
|
|
185
|
+
config: ${JSON.stringify({
|
|
186
|
+
endpoint: config.endpoint,
|
|
187
|
+
method: config.method,
|
|
188
|
+
headers: config.headers,
|
|
189
|
+
position: config.position,
|
|
190
|
+
showRating: config.showRating,
|
|
191
|
+
ratingRequired: config.ratingRequired,
|
|
192
|
+
ratingStars: config.ratingStars,
|
|
193
|
+
showIssueType: config.showIssueType,
|
|
194
|
+
issueTypeRequired: config.issueTypeRequired,
|
|
195
|
+
showComment: config.showComment,
|
|
196
|
+
commentRequired: config.commentRequired,
|
|
197
|
+
commentMaxLength: config.commentMaxLength,
|
|
198
|
+
autoClose: config.autoClose,
|
|
199
|
+
autoCloseDelay: config.autoCloseDelay,
|
|
200
|
+
debug: config.debug,
|
|
201
|
+
includeMetadata: config.includeMetadata
|
|
202
|
+
})},
|
|
203
|
+
translations: ${JSON.stringify(t)},
|
|
204
|
+
issueTypes: ${JSON.stringify(issueTypes)},
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
var FB = FEEDBACK.feedback;
|
|
208
|
+
|
|
209
|
+
function log() {
|
|
210
|
+
if (FB.config.debug) {
|
|
211
|
+
console.log.apply(console, ['[PA-Feedback]'].concat(Array.prototype.slice.call(arguments)));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ============================================================================
|
|
216
|
+
// DOM CREATION
|
|
217
|
+
// ============================================================================
|
|
218
|
+
|
|
219
|
+
function createWidget() {
|
|
220
|
+
var container = document.createElement('div');
|
|
221
|
+
container.id = 'pa-feedback-container';
|
|
222
|
+
container.className = 'pa-feedback-${config.position}';
|
|
223
|
+
container.innerHTML = buildWidgetHtml();
|
|
224
|
+
document.body.appendChild(container);
|
|
225
|
+
setupEventListeners();
|
|
226
|
+
log('Widget created');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function buildWidgetHtml() {
|
|
230
|
+
var html = '';
|
|
231
|
+
|
|
232
|
+
// Tab button
|
|
233
|
+
html += '<button id="pa-feedback-tab" class="pa-feedback-tab" aria-label="' + FB.translations.title + '">';
|
|
234
|
+
html += '<span class="pa-feedback-tab-text">${config.tabText}</span>';
|
|
235
|
+
html += '</button>';
|
|
236
|
+
|
|
237
|
+
// Modal
|
|
238
|
+
html += '<div id="pa-feedback-modal" class="pa-feedback-modal pa-feedback-hidden" role="dialog" aria-modal="true" aria-labelledby="pa-feedback-title">';
|
|
239
|
+
html += '<div class="pa-feedback-content">';
|
|
240
|
+
|
|
241
|
+
// Header
|
|
242
|
+
html += '<div class="pa-feedback-header">';
|
|
243
|
+
html += '<h3 id="pa-feedback-title">' + FB.translations.title + '</h3>';
|
|
244
|
+
html += '<button id="pa-feedback-close" class="pa-feedback-close" aria-label="Close">×</button>';
|
|
245
|
+
html += '</div>';
|
|
246
|
+
|
|
247
|
+
// Form
|
|
248
|
+
html += '<form id="pa-feedback-form">';
|
|
249
|
+
|
|
250
|
+
// Rating (if enabled)
|
|
251
|
+
${config.showRating ? `
|
|
252
|
+
html += '<div class="pa-feedback-field">';
|
|
253
|
+
html += '<label class="pa-feedback-label">' + FB.translations.ratingLabel + '${config.ratingRequired ? ' <span class="pa-feedback-required">*</span>' : ""}</label>';
|
|
254
|
+
html += '<div class="pa-feedback-stars" role="radiogroup" aria-label="Rating">';
|
|
255
|
+
for (var i = 1; i <= ${config.ratingStars}; i++) {
|
|
256
|
+
html += '<button type="button" class="pa-feedback-star" data-value="' + i + '" role="radio" aria-checked="false" aria-label="' + i + ' star">☆</button>';
|
|
257
|
+
}
|
|
258
|
+
html += '</div>';
|
|
259
|
+
html += '</div>';
|
|
260
|
+
` : ""}
|
|
261
|
+
|
|
262
|
+
// Issue Type (if enabled)
|
|
263
|
+
${config.showIssueType ? `
|
|
264
|
+
html += '<div class="pa-feedback-field">';
|
|
265
|
+
html += '<label class="pa-feedback-label" for="pa-feedback-issue-type">' + FB.translations.issueTypeLabel + '${config.issueTypeRequired ? ' <span class="pa-feedback-required">*</span>' : ""}</label>';
|
|
266
|
+
html += '<select id="pa-feedback-issue-type" class="pa-feedback-select">';
|
|
267
|
+
html += '<option value="">' + FB.translations.selectIssueType + '</option>';
|
|
268
|
+
FB.issueTypes.forEach(function(type) {
|
|
269
|
+
html += '<option value="' + type.id + '">' + type.label + '</option>';
|
|
270
|
+
});
|
|
271
|
+
html += '</select>';
|
|
272
|
+
html += '</div>';
|
|
273
|
+
|
|
274
|
+
// Subtype container (hidden by default)
|
|
275
|
+
html += '<div id="pa-feedback-subtype-field" class="pa-feedback-field pa-feedback-hidden">';
|
|
276
|
+
html += '<label class="pa-feedback-label" for="pa-feedback-subtype">' + FB.translations.subtypeLabel + '</label>';
|
|
277
|
+
html += '<select id="pa-feedback-subtype" class="pa-feedback-select">';
|
|
278
|
+
html += '<option value="">' + FB.translations.selectSubtype + '</option>';
|
|
279
|
+
html += '</select>';
|
|
280
|
+
html += '</div>';
|
|
281
|
+
` : ""}
|
|
282
|
+
|
|
283
|
+
// Comment (if enabled)
|
|
284
|
+
${config.showComment ? `
|
|
285
|
+
html += '<div class="pa-feedback-field">';
|
|
286
|
+
html += '<label class="pa-feedback-label" for="pa-feedback-comment">' + FB.translations.commentLabel + '${config.commentRequired ? ' <span class="pa-feedback-required">*</span>' : ""}</label>';
|
|
287
|
+
html += '<textarea id="pa-feedback-comment" class="pa-feedback-textarea" maxlength="${config.commentMaxLength}" placeholder="${config.commentPlaceholder || ""}" rows="4"></textarea>';
|
|
288
|
+
html += '<div class="pa-feedback-counter"><span id="pa-feedback-char-count">0</span>/${config.commentMaxLength}</div>';
|
|
289
|
+
html += '</div>';
|
|
290
|
+
` : ""}
|
|
291
|
+
|
|
292
|
+
// Error message area
|
|
293
|
+
html += '<div id="pa-feedback-error" class="pa-feedback-error pa-feedback-hidden"></div>';
|
|
294
|
+
|
|
295
|
+
// Submit button
|
|
296
|
+
html += '<button type="submit" id="pa-feedback-submit" class="pa-feedback-submit">';
|
|
297
|
+
html += '<span class="pa-feedback-submit-text">' + FB.translations.submit + '</span>';
|
|
298
|
+
html += '<span class="pa-feedback-submit-loading pa-feedback-hidden">' + FB.translations.submitting + '</span>';
|
|
299
|
+
html += '</button>';
|
|
300
|
+
|
|
301
|
+
html += '</form>';
|
|
302
|
+
|
|
303
|
+
// Success message
|
|
304
|
+
html += '<div id="pa-feedback-success" class="pa-feedback-success pa-feedback-hidden">';
|
|
305
|
+
html += '<div class="pa-feedback-checkmark">✓</div>';
|
|
306
|
+
html += '<p>' + FB.translations.thankYou + '</p>';
|
|
307
|
+
html += '</div>';
|
|
308
|
+
|
|
309
|
+
html += '</div>'; // content
|
|
310
|
+
html += '</div>'; // modal
|
|
311
|
+
|
|
312
|
+
return html;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// ============================================================================
|
|
316
|
+
// EVENT HANDLERS
|
|
317
|
+
// ============================================================================
|
|
318
|
+
|
|
319
|
+
function setupEventListeners() {
|
|
320
|
+
// Tab click
|
|
321
|
+
document.getElementById('pa-feedback-tab').addEventListener('click', toggleModal);
|
|
322
|
+
|
|
323
|
+
// Close button
|
|
324
|
+
document.getElementById('pa-feedback-close').addEventListener('click', closeModal);
|
|
325
|
+
|
|
326
|
+
// Form submit
|
|
327
|
+
document.getElementById('pa-feedback-form').addEventListener('submit', handleSubmit);
|
|
328
|
+
|
|
329
|
+
// Click outside to close
|
|
330
|
+
document.getElementById('pa-feedback-modal').addEventListener('click', function(e) {
|
|
331
|
+
if (e.target === this) closeModal();
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// Escape key to close
|
|
335
|
+
document.addEventListener('keydown', function(e) {
|
|
336
|
+
if (e.key === 'Escape' && FB.isOpen) closeModal();
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
${config.showRating ? `
|
|
340
|
+
// Star rating
|
|
341
|
+
var stars = document.querySelectorAll('.pa-feedback-star');
|
|
342
|
+
stars.forEach(function(star, index) {
|
|
343
|
+
star.addEventListener('click', function() {
|
|
344
|
+
FB.rating = index + 1;
|
|
345
|
+
updateStars();
|
|
346
|
+
});
|
|
347
|
+
star.addEventListener('mouseenter', function() {
|
|
348
|
+
highlightStars(index + 1);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
document.querySelector('.pa-feedback-stars').addEventListener('mouseleave', function() {
|
|
352
|
+
highlightStars(FB.rating);
|
|
353
|
+
});
|
|
354
|
+
` : ""}
|
|
355
|
+
|
|
356
|
+
${config.showIssueType ? `
|
|
357
|
+
// Issue type change
|
|
358
|
+
document.getElementById('pa-feedback-issue-type').addEventListener('change', updateSubtypes);
|
|
359
|
+
` : ""}
|
|
360
|
+
|
|
361
|
+
${config.showComment ? `
|
|
362
|
+
// Character counter
|
|
363
|
+
document.getElementById('pa-feedback-comment').addEventListener('input', updateCharCount);
|
|
364
|
+
` : ""}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function toggleModal() {
|
|
368
|
+
if (FB.isOpen) {
|
|
369
|
+
closeModal();
|
|
370
|
+
} else {
|
|
371
|
+
openModal();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function openModal() {
|
|
376
|
+
FB.isOpen = true;
|
|
377
|
+
document.getElementById('pa-feedback-modal').classList.remove('pa-feedback-hidden');
|
|
378
|
+
document.getElementById('pa-feedback-tab').classList.add('pa-feedback-tab-active');
|
|
379
|
+
log('Modal opened');
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function closeModal() {
|
|
383
|
+
FB.isOpen = false;
|
|
384
|
+
document.getElementById('pa-feedback-modal').classList.add('pa-feedback-hidden');
|
|
385
|
+
document.getElementById('pa-feedback-tab').classList.remove('pa-feedback-tab-active');
|
|
386
|
+
log('Modal closed');
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
${config.showRating ? `
|
|
390
|
+
function updateStars() {
|
|
391
|
+
var stars = document.querySelectorAll('.pa-feedback-star');
|
|
392
|
+
stars.forEach(function(star, index) {
|
|
393
|
+
var isFilled = index < FB.rating;
|
|
394
|
+
star.innerHTML = isFilled ? '★' : '☆';
|
|
395
|
+
star.classList.toggle('pa-feedback-star-filled', isFilled);
|
|
396
|
+
star.setAttribute('aria-checked', isFilled ? 'true' : 'false');
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function highlightStars(count) {
|
|
401
|
+
var stars = document.querySelectorAll('.pa-feedback-star');
|
|
402
|
+
stars.forEach(function(star, index) {
|
|
403
|
+
var isFilled = index < count;
|
|
404
|
+
star.innerHTML = isFilled ? '★' : '☆';
|
|
405
|
+
star.classList.toggle('pa-feedback-star-hover', isFilled && count > FB.rating);
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
` : ""}
|
|
409
|
+
|
|
410
|
+
${config.showIssueType ? `
|
|
411
|
+
function updateSubtypes() {
|
|
412
|
+
var typeSelect = document.getElementById('pa-feedback-issue-type');
|
|
413
|
+
var subtypeField = document.getElementById('pa-feedback-subtype-field');
|
|
414
|
+
var subtypeSelect = document.getElementById('pa-feedback-subtype');
|
|
415
|
+
var selectedType = typeSelect.value;
|
|
416
|
+
|
|
417
|
+
// Find the selected issue type
|
|
418
|
+
var issueType = FB.issueTypes.find(function(t) { return t.id === selectedType; });
|
|
419
|
+
|
|
420
|
+
if (issueType && issueType.subtypes && issueType.subtypes.length > 0) {
|
|
421
|
+
// Populate subtypes
|
|
422
|
+
subtypeSelect.innerHTML = '<option value="">' + FB.translations.selectSubtype + '</option>';
|
|
423
|
+
issueType.subtypes.forEach(function(subtype) {
|
|
424
|
+
subtypeSelect.innerHTML += '<option value="' + subtype.id + '">' + subtype.label + '</option>';
|
|
425
|
+
});
|
|
426
|
+
subtypeField.classList.remove('pa-feedback-hidden');
|
|
427
|
+
} else {
|
|
428
|
+
subtypeField.classList.add('pa-feedback-hidden');
|
|
429
|
+
subtypeSelect.value = '';
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
` : ""}
|
|
433
|
+
|
|
434
|
+
${config.showComment ? `
|
|
435
|
+
function updateCharCount() {
|
|
436
|
+
var textarea = document.getElementById('pa-feedback-comment');
|
|
437
|
+
var counter = document.getElementById('pa-feedback-char-count');
|
|
438
|
+
counter.textContent = textarea.value.length;
|
|
439
|
+
}
|
|
440
|
+
` : ""}
|
|
441
|
+
|
|
442
|
+
// ============================================================================
|
|
443
|
+
// FORM SUBMISSION
|
|
444
|
+
// ============================================================================
|
|
445
|
+
|
|
446
|
+
function validateForm() {
|
|
447
|
+
var errors = [];
|
|
448
|
+
|
|
449
|
+
${config.showRating && config.ratingRequired ? `
|
|
450
|
+
if (FB.rating === 0) {
|
|
451
|
+
errors.push('Rating is required');
|
|
452
|
+
}
|
|
453
|
+
` : ""}
|
|
454
|
+
|
|
455
|
+
${config.showIssueType && config.issueTypeRequired ? `
|
|
456
|
+
if (!document.getElementById('pa-feedback-issue-type').value) {
|
|
457
|
+
errors.push('Issue type is required');
|
|
458
|
+
}
|
|
459
|
+
` : ""}
|
|
460
|
+
|
|
461
|
+
${config.showComment && config.commentRequired ? `
|
|
462
|
+
if (!document.getElementById('pa-feedback-comment').value.trim()) {
|
|
463
|
+
errors.push('Comment is required');
|
|
464
|
+
}
|
|
465
|
+
` : ""}
|
|
466
|
+
|
|
467
|
+
return errors;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function collectFormData() {
|
|
471
|
+
var data = {};
|
|
472
|
+
|
|
473
|
+
${config.showRating ? `data.rating = FB.rating;` : ""}
|
|
474
|
+
${config.showIssueType ? `
|
|
475
|
+
data.issueType = document.getElementById('pa-feedback-issue-type').value || null;
|
|
476
|
+
data.issueSubtype = document.getElementById('pa-feedback-subtype').value || null;
|
|
477
|
+
` : ""}
|
|
478
|
+
${config.showComment ? `data.comment = document.getElementById('pa-feedback-comment').value.trim();` : ""}
|
|
479
|
+
|
|
480
|
+
// Add metadata
|
|
481
|
+
data.metadata = collectMetadata();
|
|
482
|
+
|
|
483
|
+
return data;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function collectMetadata() {
|
|
487
|
+
var meta = {};
|
|
488
|
+
var cfg = FB.config.includeMetadata;
|
|
489
|
+
|
|
490
|
+
if (cfg.courseId && window.pa_patcher && window.pa_patcher.lrs && window.pa_patcher.lrs.courseInfo) {
|
|
491
|
+
meta.courseId = window.pa_patcher.lrs.courseInfo.id;
|
|
492
|
+
meta.courseTitle = window.pa_patcher.lrs.courseInfo.title;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (cfg.lessonId) {
|
|
496
|
+
meta.lessonId = window.location.hash || window.location.pathname;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (cfg.userAgent) {
|
|
500
|
+
meta.userAgent = navigator.userAgent;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (cfg.timestamp) {
|
|
504
|
+
meta.timestamp = new Date().toISOString();
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (cfg.url) {
|
|
508
|
+
meta.url = window.location.href;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return meta;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function showError(message) {
|
|
515
|
+
var errorEl = document.getElementById('pa-feedback-error');
|
|
516
|
+
errorEl.textContent = message;
|
|
517
|
+
errorEl.classList.remove('pa-feedback-hidden');
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function hideError() {
|
|
521
|
+
document.getElementById('pa-feedback-error').classList.add('pa-feedback-hidden');
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function setSubmitting(isSubmitting) {
|
|
525
|
+
var submitBtn = document.getElementById('pa-feedback-submit');
|
|
526
|
+
var textEl = submitBtn.querySelector('.pa-feedback-submit-text');
|
|
527
|
+
var loadingEl = submitBtn.querySelector('.pa-feedback-submit-loading');
|
|
528
|
+
|
|
529
|
+
submitBtn.disabled = isSubmitting;
|
|
530
|
+
textEl.classList.toggle('pa-feedback-hidden', isSubmitting);
|
|
531
|
+
loadingEl.classList.toggle('pa-feedback-hidden', !isSubmitting);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function showSuccess() {
|
|
535
|
+
document.getElementById('pa-feedback-form').classList.add('pa-feedback-hidden');
|
|
536
|
+
document.getElementById('pa-feedback-success').classList.remove('pa-feedback-hidden');
|
|
537
|
+
|
|
538
|
+
if (FB.config.autoClose) {
|
|
539
|
+
setTimeout(function() {
|
|
540
|
+
closeModal();
|
|
541
|
+
resetForm();
|
|
542
|
+
}, FB.config.autoCloseDelay);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function resetForm() {
|
|
547
|
+
var form = document.getElementById('pa-feedback-form');
|
|
548
|
+
form.reset();
|
|
549
|
+
form.classList.remove('pa-feedback-hidden');
|
|
550
|
+
document.getElementById('pa-feedback-success').classList.add('pa-feedback-hidden');
|
|
551
|
+
hideError();
|
|
552
|
+
|
|
553
|
+
FB.rating = 0;
|
|
554
|
+
${config.showRating ? "updateStars();" : ""}
|
|
555
|
+
${config.showComment ? "updateCharCount();" : ""}
|
|
556
|
+
${config.showIssueType ? `
|
|
557
|
+
document.getElementById('pa-feedback-subtype-field').classList.add('pa-feedback-hidden');
|
|
558
|
+
` : ""}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
async function handleSubmit(e) {
|
|
562
|
+
e.preventDefault();
|
|
563
|
+
hideError();
|
|
564
|
+
|
|
565
|
+
// Validate
|
|
566
|
+
var errors = validateForm();
|
|
567
|
+
if (errors.length > 0) {
|
|
568
|
+
showError(FB.translations.errorRequired);
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// Collect data
|
|
573
|
+
var data = collectFormData();
|
|
574
|
+
log('Submitting:', data);
|
|
575
|
+
|
|
576
|
+
// Submit
|
|
577
|
+
setSubmitting(true);
|
|
578
|
+
|
|
579
|
+
try {
|
|
580
|
+
${config.endpoint ? `
|
|
581
|
+
var response = await fetch('${config.endpoint}', {
|
|
582
|
+
method: '${config.method}',
|
|
583
|
+
headers: Object.assign({
|
|
584
|
+
'Content-Type': 'application/json',
|
|
585
|
+
}, FB.config.headers || {}),
|
|
586
|
+
body: JSON.stringify(data),
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
if (!response.ok) {
|
|
590
|
+
throw new Error('HTTP ' + response.status);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
log('Submitted successfully');
|
|
594
|
+
` : `
|
|
595
|
+
// No endpoint configured - just log
|
|
596
|
+
console.log('[PA-Feedback] Feedback submitted:', data);
|
|
597
|
+
log('No endpoint configured, feedback logged to console');
|
|
598
|
+
`}
|
|
599
|
+
|
|
600
|
+
showSuccess();
|
|
601
|
+
} catch (err) {
|
|
602
|
+
log('Submit error:', err);
|
|
603
|
+
showError(FB.translations.errorSubmitting);
|
|
604
|
+
} finally {
|
|
605
|
+
setSubmitting(false);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// ============================================================================
|
|
610
|
+
// INITIALIZATION
|
|
611
|
+
// ============================================================================
|
|
612
|
+
|
|
613
|
+
function init() {
|
|
614
|
+
if (document.readyState === 'loading') {
|
|
615
|
+
document.addEventListener('DOMContentLoaded', createWidget);
|
|
616
|
+
} else {
|
|
617
|
+
createWidget();
|
|
618
|
+
}
|
|
619
|
+
log('Initialized');
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
init();
|
|
623
|
+
|
|
624
|
+
})();
|
|
625
|
+
`;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// src/styles.ts
|
|
629
|
+
function generateFeedbackStyles(config) {
|
|
630
|
+
const position = config.position;
|
|
631
|
+
const tabColor = config.tabColor;
|
|
632
|
+
const tabTextColor = config.tabTextColor;
|
|
633
|
+
const zIndex = config.zIndex;
|
|
634
|
+
return `
|
|
635
|
+
/* ============================================================================
|
|
636
|
+
FEEDBACK WIDGET STYLES - Patch-Adams Plugin v1.0.0
|
|
637
|
+
============================================================================ */
|
|
638
|
+
|
|
639
|
+
#pa-feedback-container {
|
|
640
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
641
|
+
font-size: 14px;
|
|
642
|
+
line-height: 1.5;
|
|
643
|
+
color: #333;
|
|
644
|
+
box-sizing: border-box;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
#pa-feedback-container *,
|
|
648
|
+
#pa-feedback-container *::before,
|
|
649
|
+
#pa-feedback-container *::after {
|
|
650
|
+
box-sizing: inherit;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/* Hidden utility class */
|
|
654
|
+
#pa-feedback-container .pa-feedback-hidden {
|
|
655
|
+
display: none !important;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/* ============================================================================
|
|
659
|
+
TAB BUTTON
|
|
660
|
+
============================================================================ */
|
|
661
|
+
|
|
662
|
+
#pa-feedback-tab {
|
|
663
|
+
position: fixed;
|
|
664
|
+
${position}: 0;
|
|
665
|
+
top: 50%;
|
|
666
|
+
transform: translateY(-50%) rotate(${position === "right" ? "-90deg" : "90deg"});
|
|
667
|
+
transform-origin: ${position === "right" ? "right center" : "left center"};
|
|
668
|
+
${position === "right" ? "right: -32px;" : "left: -32px;"}
|
|
669
|
+
z-index: ${zIndex};
|
|
670
|
+
background: ${tabColor};
|
|
671
|
+
color: ${tabTextColor};
|
|
672
|
+
border: none;
|
|
673
|
+
padding: 10px 20px;
|
|
674
|
+
font-size: 14px;
|
|
675
|
+
font-weight: 600;
|
|
676
|
+
cursor: pointer;
|
|
677
|
+
border-radius: ${position === "right" ? "0 0 8px 8px" : "8px 8px 0 0"};
|
|
678
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
679
|
+
transition: all 0.2s ease;
|
|
680
|
+
white-space: nowrap;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
#pa-feedback-tab:hover {
|
|
684
|
+
background: ${adjustColor(tabColor, -15)};
|
|
685
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
#pa-feedback-tab:focus {
|
|
689
|
+
outline: 2px solid ${tabColor};
|
|
690
|
+
outline-offset: 2px;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
#pa-feedback-tab.pa-feedback-tab-active {
|
|
694
|
+
background: ${adjustColor(tabColor, -20)};
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/* ============================================================================
|
|
698
|
+
MODAL
|
|
699
|
+
============================================================================ */
|
|
700
|
+
|
|
701
|
+
#pa-feedback-modal {
|
|
702
|
+
position: fixed;
|
|
703
|
+
${position}: 0;
|
|
704
|
+
top: 0;
|
|
705
|
+
width: 360px;
|
|
706
|
+
height: 100%;
|
|
707
|
+
z-index: ${zIndex + 1};
|
|
708
|
+
background: rgba(0, 0, 0, 0.3);
|
|
709
|
+
display: flex;
|
|
710
|
+
justify-content: flex-${position === "right" ? "end" : "start"};
|
|
711
|
+
animation: pa-feedback-fade-in 0.2s ease;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
@keyframes pa-feedback-fade-in {
|
|
715
|
+
from { opacity: 0; }
|
|
716
|
+
to { opacity: 1; }
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
#pa-feedback-container .pa-feedback-content {
|
|
720
|
+
width: 100%;
|
|
721
|
+
max-width: 360px;
|
|
722
|
+
height: 100%;
|
|
723
|
+
background: #fff;
|
|
724
|
+
box-shadow: ${position === "right" ? "-4px" : "4px"} 0 20px rgba(0, 0, 0, 0.15);
|
|
725
|
+
display: flex;
|
|
726
|
+
flex-direction: column;
|
|
727
|
+
animation: pa-feedback-slide-in 0.2s ease;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
@keyframes pa-feedback-slide-in {
|
|
731
|
+
from {
|
|
732
|
+
transform: translateX(${position === "right" ? "100%" : "-100%"});
|
|
733
|
+
}
|
|
734
|
+
to {
|
|
735
|
+
transform: translateX(0);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/* ============================================================================
|
|
740
|
+
HEADER
|
|
741
|
+
============================================================================ */
|
|
742
|
+
|
|
743
|
+
#pa-feedback-container .pa-feedback-header {
|
|
744
|
+
display: flex;
|
|
745
|
+
justify-content: space-between;
|
|
746
|
+
align-items: center;
|
|
747
|
+
padding: 16px 20px;
|
|
748
|
+
border-bottom: 1px solid #e5e5e5;
|
|
749
|
+
background: #fafafa;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
#pa-feedback-container .pa-feedback-header h3 {
|
|
753
|
+
margin: 0;
|
|
754
|
+
font-size: 18px;
|
|
755
|
+
font-weight: 600;
|
|
756
|
+
color: #222;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
#pa-feedback-container .pa-feedback-close {
|
|
760
|
+
background: none;
|
|
761
|
+
border: none;
|
|
762
|
+
font-size: 24px;
|
|
763
|
+
color: #666;
|
|
764
|
+
cursor: pointer;
|
|
765
|
+
padding: 4px 8px;
|
|
766
|
+
line-height: 1;
|
|
767
|
+
border-radius: 4px;
|
|
768
|
+
transition: all 0.15s ease;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
#pa-feedback-container .pa-feedback-close:hover {
|
|
772
|
+
background: #e5e5e5;
|
|
773
|
+
color: #333;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/* ============================================================================
|
|
777
|
+
FORM
|
|
778
|
+
============================================================================ */
|
|
779
|
+
|
|
780
|
+
#pa-feedback-form {
|
|
781
|
+
flex: 1;
|
|
782
|
+
overflow-y: auto;
|
|
783
|
+
padding: 20px;
|
|
784
|
+
display: flex;
|
|
785
|
+
flex-direction: column;
|
|
786
|
+
gap: 20px;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
#pa-feedback-container .pa-feedback-field {
|
|
790
|
+
display: flex;
|
|
791
|
+
flex-direction: column;
|
|
792
|
+
gap: 8px;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
#pa-feedback-container .pa-feedback-label {
|
|
796
|
+
font-weight: 500;
|
|
797
|
+
color: #444;
|
|
798
|
+
font-size: 14px;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
#pa-feedback-container .pa-feedback-required {
|
|
802
|
+
color: #dc3545;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/* ============================================================================
|
|
806
|
+
STAR RATING
|
|
807
|
+
============================================================================ */
|
|
808
|
+
|
|
809
|
+
#pa-feedback-container .pa-feedback-stars {
|
|
810
|
+
display: flex;
|
|
811
|
+
gap: 4px;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
#pa-feedback-container .pa-feedback-star {
|
|
815
|
+
background: none;
|
|
816
|
+
border: none;
|
|
817
|
+
font-size: 28px;
|
|
818
|
+
color: #ccc;
|
|
819
|
+
cursor: pointer;
|
|
820
|
+
padding: 4px;
|
|
821
|
+
line-height: 1;
|
|
822
|
+
transition: all 0.15s ease;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
#pa-feedback-container .pa-feedback-star:hover {
|
|
826
|
+
transform: scale(1.1);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
#pa-feedback-container .pa-feedback-star-filled,
|
|
830
|
+
#pa-feedback-container .pa-feedback-star-hover {
|
|
831
|
+
color: #ffc107;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/* ============================================================================
|
|
835
|
+
SELECT & TEXTAREA
|
|
836
|
+
============================================================================ */
|
|
837
|
+
|
|
838
|
+
#pa-feedback-container .pa-feedback-select {
|
|
839
|
+
width: 100%;
|
|
840
|
+
padding: 10px 12px;
|
|
841
|
+
font-size: 14px;
|
|
842
|
+
border: 1px solid #ddd;
|
|
843
|
+
border-radius: 6px;
|
|
844
|
+
background: #fff;
|
|
845
|
+
color: #333;
|
|
846
|
+
cursor: pointer;
|
|
847
|
+
transition: border-color 0.15s ease;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
#pa-feedback-container .pa-feedback-select:focus {
|
|
851
|
+
outline: none;
|
|
852
|
+
border-color: ${tabColor};
|
|
853
|
+
box-shadow: 0 0 0 3px ${hexToRgba(tabColor, 0.1)};
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
#pa-feedback-container .pa-feedback-textarea {
|
|
857
|
+
width: 100%;
|
|
858
|
+
padding: 12px;
|
|
859
|
+
font-size: 14px;
|
|
860
|
+
font-family: inherit;
|
|
861
|
+
border: 1px solid #ddd;
|
|
862
|
+
border-radius: 6px;
|
|
863
|
+
resize: vertical;
|
|
864
|
+
min-height: 100px;
|
|
865
|
+
transition: border-color 0.15s ease;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
#pa-feedback-container .pa-feedback-textarea:focus {
|
|
869
|
+
outline: none;
|
|
870
|
+
border-color: ${tabColor};
|
|
871
|
+
box-shadow: 0 0 0 3px ${hexToRgba(tabColor, 0.1)};
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
#pa-feedback-container .pa-feedback-textarea::placeholder {
|
|
875
|
+
color: #999;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
#pa-feedback-container .pa-feedback-counter {
|
|
879
|
+
text-align: right;
|
|
880
|
+
font-size: 12px;
|
|
881
|
+
color: #888;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/* ============================================================================
|
|
885
|
+
ERROR MESSAGE
|
|
886
|
+
============================================================================ */
|
|
887
|
+
|
|
888
|
+
#pa-feedback-container .pa-feedback-error {
|
|
889
|
+
background: #fee2e2;
|
|
890
|
+
color: #dc2626;
|
|
891
|
+
padding: 10px 14px;
|
|
892
|
+
border-radius: 6px;
|
|
893
|
+
font-size: 13px;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/* ============================================================================
|
|
897
|
+
SUBMIT BUTTON
|
|
898
|
+
============================================================================ */
|
|
899
|
+
|
|
900
|
+
#pa-feedback-container .pa-feedback-submit {
|
|
901
|
+
width: 100%;
|
|
902
|
+
padding: 12px 20px;
|
|
903
|
+
font-size: 16px;
|
|
904
|
+
font-weight: 600;
|
|
905
|
+
color: #fff;
|
|
906
|
+
background: ${tabColor};
|
|
907
|
+
border: none;
|
|
908
|
+
border-radius: 6px;
|
|
909
|
+
cursor: pointer;
|
|
910
|
+
transition: all 0.15s ease;
|
|
911
|
+
margin-top: auto;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
#pa-feedback-container .pa-feedback-submit:hover:not(:disabled) {
|
|
915
|
+
background: ${adjustColor(tabColor, -15)};
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
#pa-feedback-container .pa-feedback-submit:focus {
|
|
919
|
+
outline: 2px solid ${tabColor};
|
|
920
|
+
outline-offset: 2px;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
#pa-feedback-container .pa-feedback-submit:disabled {
|
|
924
|
+
opacity: 0.7;
|
|
925
|
+
cursor: not-allowed;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/* ============================================================================
|
|
929
|
+
SUCCESS MESSAGE
|
|
930
|
+
============================================================================ */
|
|
931
|
+
|
|
932
|
+
#pa-feedback-container .pa-feedback-success {
|
|
933
|
+
flex: 1;
|
|
934
|
+
display: flex;
|
|
935
|
+
flex-direction: column;
|
|
936
|
+
align-items: center;
|
|
937
|
+
justify-content: center;
|
|
938
|
+
padding: 40px 20px;
|
|
939
|
+
text-align: center;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
#pa-feedback-container .pa-feedback-checkmark {
|
|
943
|
+
width: 64px;
|
|
944
|
+
height: 64px;
|
|
945
|
+
background: #10b981;
|
|
946
|
+
color: #fff;
|
|
947
|
+
border-radius: 50%;
|
|
948
|
+
display: flex;
|
|
949
|
+
align-items: center;
|
|
950
|
+
justify-content: center;
|
|
951
|
+
font-size: 32px;
|
|
952
|
+
margin-bottom: 20px;
|
|
953
|
+
animation: pa-feedback-pop 0.3s ease;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
@keyframes pa-feedback-pop {
|
|
957
|
+
0% { transform: scale(0); }
|
|
958
|
+
50% { transform: scale(1.2); }
|
|
959
|
+
100% { transform: scale(1); }
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
#pa-feedback-container .pa-feedback-success p {
|
|
963
|
+
margin: 0;
|
|
964
|
+
font-size: 18px;
|
|
965
|
+
font-weight: 500;
|
|
966
|
+
color: #333;
|
|
967
|
+
}
|
|
968
|
+
`;
|
|
969
|
+
}
|
|
970
|
+
function adjustColor(hex, percent) {
|
|
971
|
+
hex = hex.replace(/^#/, "");
|
|
972
|
+
let r = parseInt(hex.substring(0, 2), 16);
|
|
973
|
+
let g = parseInt(hex.substring(2, 4), 16);
|
|
974
|
+
let b = parseInt(hex.substring(4, 6), 16);
|
|
975
|
+
r = Math.min(255, Math.max(0, r + r * percent / 100));
|
|
976
|
+
g = Math.min(255, Math.max(0, g + g * percent / 100));
|
|
977
|
+
b = Math.min(255, Math.max(0, b + b * percent / 100));
|
|
978
|
+
return "#" + Math.round(r).toString(16).padStart(2, "0") + Math.round(g).toString(16).padStart(2, "0") + Math.round(b).toString(16).padStart(2, "0");
|
|
979
|
+
}
|
|
980
|
+
function hexToRgba(hex, alpha) {
|
|
981
|
+
hex = hex.replace(/^#/, "");
|
|
982
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
983
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
984
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
985
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// src/index.ts
|
|
989
|
+
var feedbackPlugin = {
|
|
990
|
+
name: "feedback",
|
|
991
|
+
version: "1.0.0",
|
|
992
|
+
description: "Inject a feedback form widget into Rise courses for collecting user feedback",
|
|
993
|
+
configSchema: FeedbackConfigSchema,
|
|
994
|
+
generateCss(config) {
|
|
995
|
+
return {
|
|
996
|
+
after: generateFeedbackStyles(config)
|
|
997
|
+
};
|
|
998
|
+
},
|
|
999
|
+
generateJs(config) {
|
|
1000
|
+
return {
|
|
1001
|
+
after: generateFeedbackWidget(config)
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
var index_default = feedbackPlugin;
|
|
1006
|
+
|
|
1007
|
+
export { DEFAULT_ISSUE_TYPES, FeedbackConfigSchema, index_default as default, feedbackPlugin, generateFeedbackStyles, generateFeedbackWidget, getTranslations, translations };
|
|
1008
|
+
//# sourceMappingURL=index.js.map
|
|
1009
|
+
//# sourceMappingURL=index.js.map
|