change course_validation endpoint to support option to get data for only graded assignments and add ability to scroll to elements on the course outline page

This commit is contained in:
Michael Roytman
2018-06-26 15:11:21 -04:00
parent a66675dc8f
commit 92c816966d
4 changed files with 85 additions and 22 deletions

View File

@@ -18,6 +18,18 @@ define([
'click .button-toggle-expand-collapse': 'toggleExpandCollapse'
},
/**
* keep a running timeout counter of 5,000 milliseconds
* for finding an element; see afterRender and scrollToElement function
*/
findElementPollingTimeout: 5000,
/**
* used as the delay parameter to setTimeout in scrollToElement
* function for polling for an element
*/
pollingDelay: 100,
options: {
collapsedClass: 'is-collapsed'
},
@@ -90,6 +102,32 @@ define([
return $.Deferred().resolve().promise();
},
afterRender: function() {
this.scrollToElement();
},
/**
* recursively poll for element specified by the URL fragment
* at 100 millisecond intervals until element is found or
* Polling is reached
*/
scrollToElement: function () {
this.findElementPollingTimeout -= this.pollingDelay;
const elementID = window.location.hash.replace("#", "");
if (this.findElementPollingTimeout > 0) {
if (elementID) {
const element = document.getElementById(elementID);
if (element) {
element.scrollIntoView();
} else {
setTimeout(this.scrollToElement, this.pollingDelay);
}
}
}
},
hasContent: function() {
return this.model.hasChildren();
},