Commit 1b4341c9 by Muhammad Shoaib

moved the scroll event in the proctored_exam_view. js file

parent 49cc3eff
......@@ -5,16 +5,4 @@ $(function() {
model: new ProctoredExamModel()
});
proctored_exam_view.render();
// show the timer bar when the window scrolls.
$(window).scroll(function() {
if ($(this).scrollTop() > 60){
$(".proctored_exam_status").addClass('fixed');
$(".wrapper-course-material").css('margin-top', '58px');
}
else {
$(".proctored_exam_status").removeClass('fixed');
$(".wrapper-course-material").css('margin-top', '0');
}
});
});
......@@ -8,7 +8,9 @@ var edx = edx || {};
edx.coursware.proctored_exam.ProctoredExamView = Backbone.View.extend({
initialize: function (options) {
_.bindAll(this, "detectScroll");
this.$el = options.el;
this.timerBarTopPosition = this.$el.position().top;
this.model = options.model;
this.templateId = options.proctored_template;
this.template = null;
......@@ -43,6 +45,17 @@ var edx = edx || {};
/* will call into the rendering */
this.model.fetch();
},
detectScroll: function(event) {
if ($(event.currentTarget).scrollTop() > this.timerBarTopPosition) {
$(".proctored_exam_status").addClass('fixed');
$(".wrapper-course-material").css('margin-top', '58px');
}
else {
$(".proctored_exam_status").removeClass('fixed');
$(".wrapper-course-material").css('margin-top', '0');
}
},
modelChanged: function () {
// if we are a proctored exam, then we need to alert user that he/she
// should not be navigating around the courseware
......@@ -67,6 +80,9 @@ var edx = edx || {};
this.model.get('time_remaining_seconds') > 0 &&
this.model.get('attempt_status') !== 'error'
) {
// add callback on scroll event
$(window).bind('scroll', this.detectScroll);
var html = this.template(this.model.toJSON());
this.$el.html(html);
this.$el.show();
......@@ -92,6 +108,10 @@ var edx = edx || {};
});
//$('.proctored-exam-action-stop').css('cursor', 'pointer');
}
else {
// remove callback on scroll event
$(window).unbind('scroll', this.detectScroll);
}
}
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