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:
Calen Pennington
2013-12-13 07:47:21 -05:00
parent 0f8919a6ba
commit 49217ebe8b
19 changed files with 122 additions and 124 deletions

View 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()