Commit 59c6f04a by Muhammad Shoaib

Merge pull request #99 from edx/muhhshoaib/PHX-118-timer-bar-scroll-out-js

PHX-118 Javascript for the timer bar should be visible when scrolling the page
parents 617db2b2 ecb6902d
...@@ -8,7 +8,10 @@ var edx = edx || {}; ...@@ -8,7 +8,10 @@ var edx = edx || {};
edx.coursware.proctored_exam.ProctoredExamView = Backbone.View.extend({ edx.coursware.proctored_exam.ProctoredExamView = Backbone.View.extend({
initialize: function (options) { initialize: function (options) {
_.bindAll(this, "detectScroll");
this.$el = options.el; this.$el = options.el;
this.timerBarTopPosition = this.$el.position().top;
this.courseNavBarMarginTop = this.timerBarTopPosition - 3;
this.model = options.model; this.model = options.model;
this.templateId = options.proctored_template; this.templateId = options.proctored_template;
this.template = null; this.template = null;
...@@ -43,6 +46,17 @@ var edx = edx || {}; ...@@ -43,6 +46,17 @@ var edx = edx || {};
/* will call into the rendering */ /* will call into the rendering */
this.model.fetch(); this.model.fetch();
}, },
detectScroll: function(event) {
if ($(event.currentTarget).scrollTop() > this.timerBarTopPosition) {
$(".proctored_exam_status").addClass('is-fixed');
$(".wrapper-course-material").css('margin-top', this.courseNavBarMarginTop + 'px');
}
else {
$(".proctored_exam_status").removeClass('is-fixed');
$(".wrapper-course-material").css('margin-top', '0');
}
},
modelChanged: function () { modelChanged: function () {
// if we are a proctored exam, then we need to alert user that he/she // if we are a proctored exam, then we need to alert user that he/she
// should not be navigating around the courseware // should not be navigating around the courseware
...@@ -67,6 +81,9 @@ var edx = edx || {}; ...@@ -67,6 +81,9 @@ var edx = edx || {};
this.model.get('time_remaining_seconds') > 0 && this.model.get('time_remaining_seconds') > 0 &&
this.model.get('attempt_status') !== 'error' this.model.get('attempt_status') !== 'error'
) { ) {
// add callback on scroll event
$(window).bind('scroll', this.detectScroll);
var html = this.template(this.model.toJSON()); var html = this.template(this.model.toJSON());
this.$el.html(html); this.$el.html(html);
this.$el.show(); this.$el.show();
...@@ -92,6 +109,10 @@ var edx = edx || {}; ...@@ -92,6 +109,10 @@ var edx = edx || {};
}); });
}); });
} }
else {
// remove callback on scroll event
$(window).unbind('scroll', this.detectScroll);
}
} }
return this; return this;
}, },
......
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