Allow multiple client-side runtimes on a single page
Make XBlock client-side runtimes proper classes, so that handlerUrl can be defined in a per-runtime way, and we can have multiple runtimes on a single page. [LMS-1630][LMS-1421][LMS-1517]
This commit is contained in:
18
lms/static/coffee/src/xblock/lms.runtime.v1.coffee
Normal file
18
lms/static/coffee/src/xblock/lms.runtime.v1.coffee
Normal file
@@ -0,0 +1,18 @@
|
||||
@LmsRuntime = {}
|
||||
|
||||
class LmsRuntime.v1 extends XBlock.Runtime.v1
|
||||
handlerUrl: (element, handlerName, suffix, query, thirdparty) ->
|
||||
courseId = $(@element).data("course-id")
|
||||
usageId = $(@element).data("usage-id")
|
||||
handlerAuth = if thirdparty then "handler_noauth" else "handler"
|
||||
|
||||
uri = URI('/courses').segment(courseId)
|
||||
.segment('xblock')
|
||||
.segment(usageId)
|
||||
.segment(handlerAuth)
|
||||
.segment(handlerName)
|
||||
|
||||
if suffix? then uri.segment(suffix)
|
||||
if query? then uri.search(query)
|
||||
|
||||
uri.toString()
|
||||
Reference in New Issue
Block a user