Commit 747611ea by Harry Rein Committed by GitHub

Merge pull request #16168 from edx/HarryRein/LEARNER-2332-reviews-speed-up

Add loading icon to reviews page.
parents 4fa81352 271f3c9f
...@@ -360,5 +360,18 @@ ...@@ -360,5 +360,18 @@
.course-reviews-tool { .course-reviews-tool {
margin: ($baseline * 2) ($baseline * 3); margin: ($baseline * 2) ($baseline * 3);
position: relative; position: relative;
text-align: center;
min-height: 300px;
.fa.fa-spinner {
@include left(50%);
font-size: 2rem;
margin-top: $baseline*3;
position: absolute;
}
iframe {
display: block !important;
}
} }
} }
...@@ -11,21 +11,32 @@ export class CourseTalkReviews { // eslint-disable-line import/prefer-default-e ...@@ -11,21 +11,32 @@ export class CourseTalkReviews { // eslint-disable-line import/prefer-default-e
// Initialize page to the read reviews view // Initialize page to the read reviews view
self.currentSrc = options.readSrc; self.currentSrc = options.readSrc;
$.getScript(options.readSrc); $.getScript(options.readSrc, () => { // eslint-disable-line func-names
$('iframe').load(() => {
$(options.loadIcon).hide();
});
});
$courseTalkToggleReadWriteReviews.text(toWriteBtnText); $courseTalkToggleReadWriteReviews.text(toWriteBtnText);
$courseTalkToggleReadWriteReviews.on('click', () => { $courseTalkToggleReadWriteReviews.on('click', () => {
const switchToReadView = self.currentSrc === options.writeSrc;
// Cache js file for future button clicks // Cache js file for future button clicks
$.ajaxSetup({ cache: true }); $.ajaxSetup({ cache: true });
// Show the loading icon
$(options.loadIcon).show();
// Update toggle button text
const newBtnText = switchToReadView ? toWriteBtnText : toReadBtnText;
$courseTalkToggleReadWriteReviews.text(newBtnText);
// Toggle the new coursetalk script object // Toggle the new coursetalk script object
const switchToReadView = self.currentSrc === options.writeSrc;
self.currentSrc = switchToReadView ? options.readSrc : options.writeSrc; self.currentSrc = switchToReadView ? options.readSrc : options.writeSrc;
$.getScript(self.currentSrc); $.getScript(self.currentSrc, () => { // eslint-disable-line func-names
$('iframe').load(() => {
// Toggle button text on switch to the other view $(options.loadIcon).hide();
const newText = switchToReadView ? toWriteBtnText : toReadBtnText; });
$courseTalkToggleReadWriteReviews.text(newText); });
}); });
} }
} }
...@@ -12,6 +12,7 @@ from openedx.features.course_experience import SHOW_REVIEWS_TOOL_FLAG ...@@ -12,6 +12,7 @@ from openedx.features.course_experience import SHOW_REVIEWS_TOOL_FLAG
% if SHOW_REVIEWS_TOOL_FLAG.is_enabled(course.id): % if SHOW_REVIEWS_TOOL_FLAG.is_enabled(course.id):
<div class="coursetalk-read-reviews"> <div class="coursetalk-read-reviews">
<span class="fa fa-spinner fa-spin" aria-hidden="true"></span>
## Coursetalk Widget ## Coursetalk Widget
<div id="ct-custom-read-review-widget" data-provider="${platform_key}" data-course="${course.id}"></div> <div id="ct-custom-read-review-widget" data-provider="${platform_key}" data-course="${course.id}"></div>
</div> </div>
...@@ -20,6 +21,7 @@ from openedx.features.course_experience import SHOW_REVIEWS_TOOL_FLAG ...@@ -20,6 +21,7 @@ from openedx.features.course_experience import SHOW_REVIEWS_TOOL_FLAG
<%static:webpack entry="CourseTalkReviews"> <%static:webpack entry="CourseTalkReviews">
new CourseTalkReviews({ new CourseTalkReviews({
toggleButton: '.toggle-read-write-reviews', toggleButton: '.toggle-read-write-reviews',
loadIcon: '.coursetalk-read-reviews .fa.fa-spinner',
readSrc: "${settings.COURSE_TALK_READ_ONLY_SOURCE | n, js_escaped_string}", readSrc: "${settings.COURSE_TALK_READ_ONLY_SOURCE | n, js_escaped_string}",
writeSrc: "${settings.COURSE_TALK_WRITE_ONLY_SOURCE | n, js_escaped_string}" writeSrc: "${settings.COURSE_TALK_WRITE_ONLY_SOURCE | n, js_escaped_string}"
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment