diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py
index b58a0a5df0..03961b27e1 100644
--- a/lms/djangoapps/courseware/views/views.py
+++ b/lms/djangoapps/courseware/views/views.py
@@ -1682,7 +1682,8 @@ def render_xblock(request, usage_key_string, check_if_enrolled=True):
'staff_access': bool(request.user.has_perm(VIEW_XQA_INTERFACE, course)),
'xqa_server': settings.FEATURES.get('XQA_SERVER', 'http://your_xqa_server.com'),
'display_reset_dates_banner': display_reset_dates_banner,
- 'web_app_course_url': reverse(COURSE_HOME_VIEW_NAME, args=[course.id])
+ 'web_app_course_url': reverse(COURSE_HOME_VIEW_NAME, args=[course.id]),
+ 'is_learning_mfe': request.META.get('HTTP_REFERER', '').startswith(settings.LEARNING_MICROFRONTEND_URL),
}
return render_to_response('courseware/courseware-chromeless.html', context)
diff --git a/lms/static/js/edxnotes/views/notes_visibility_factory.js b/lms/static/js/edxnotes/views/notes_visibility_factory.js
index b7c1051622..80d9b54fc8 100644
--- a/lms/static/js/edxnotes/views/notes_visibility_factory.js
+++ b/lms/static/js/edxnotes/views/notes_visibility_factory.js
@@ -12,13 +12,17 @@
errorMessage: gettext('An error has occurred. Make sure that you are connected to the Internet, and then try refreshing the page.'),
initialize: function(options) {
- _.bindAll(this, 'onSuccess', 'onError', 'keyDownToggleHandler');
+ _.bindAll(this, 'onSuccess', 'onError', 'keyDownToggleHandler', 'receiveMessage');
this.visibility = options.visibility;
this.visibilityUrl = options.visibilityUrl;
+
this.label = this.$('.utility-control-label');
this.actionLink = this.$('.action-toggle-notes');
this.actionLink.removeClass('is-disabled');
this.actionToggleMessage = this.$('.action-toggle-message');
+ if (options.hideUI) {
+ $(window).on('message', this.receiveMessage);
+ }
this.notification = new Annotator.Notification();
$(document).on('keydown.edxnotes:togglenotes', this.keyDownToggleHandler);
},
@@ -28,6 +32,18 @@
Backbone.View.prototype.remove.call(this);
},
+ receiveMessage: function(event) {
+ var data = event.originalEvent.data;
+ if (data === 'tools.toggleNotes') {
+ event.preventDefault();
+ this.visibility = !this.visibility;
+ if (this.visibility) {
+ this.enableNotes();
+ } else {
+ this.disableNotes();
+ }
+ }
+ },
toggleHandler: function(event) {
event.preventDefault();
this.visibility = !this.visibility;
@@ -94,11 +110,12 @@
});
return {
- ToggleVisibilityView: function(visibility, visibilityUrl) {
+ ToggleVisibilityView: function(visibility, visibilityUrl, hideUI) {
return new ToggleVisibilityView({
el: $('.edx-notes-visibility').get(0),
visibility: visibility,
- visibilityUrl: visibilityUrl
+ visibilityUrl: visibilityUrl,
+ hideUI: hideUI
});
},
VisibilityDecorator: VisibilityDecorator
diff --git a/lms/templates/courseware/courseware-chromeless.html b/lms/templates/courseware/courseware-chromeless.html
index eedb182ffb..5e6d5c23f4 100644
--- a/lms/templates/courseware/courseware-chromeless.html
+++ b/lms/templates/courseware/courseware-chromeless.html
@@ -46,29 +46,23 @@ ${static.get_page_title_breadcrumbs(course_name())}
<%static:css group='style-student-notes'/>
% endif
-
-
+
+
-
+
${HTML(fragment.head_html())}
-
+% if is_learning_mfe:
+ ## If this chromeless view is in an iframe in the learning microfrontend app
+ ## then add a base tag in the head (of the iframe document) to force links
+ ## in this iframe to navigate the parent window.
+