Pass storage_url and token values as parameters to StudentNotes init.

LMS-2848
This commit is contained in:
Usman Khalid
2014-06-20 20:43:57 +05:00
parent f253f9a784
commit d36e00d4a5
3 changed files with 8 additions and 33 deletions

View File

@@ -13,10 +13,9 @@ class StudentNotes
$(el).data('notes-instance', @)
# Initializes annotations on a container element in response to an init event.
onInitNotes: (event, uri=null) =>
onInitNotes: (event, uri=null, storage_url=null, token=null) =>
event.stopPropagation()
storeConfig = @getStoreConfig uri
found = @targets.some (target) -> target is event.target
# Get uri
@@ -47,10 +46,10 @@ class StudentNotes
return user.id if user and user.id
user
auth:
tokenUrl: location.protocol+'//'+location.host+"/token?course_id="+courseid
token: token
store:
prefix: 'http://catch.aws.af.cm/annotator'
prefix: storage_url
annotationData: uri:uri
@@ -88,33 +87,6 @@ class StudentNotes
else
@targets.push(event.target)
# Returns a JSON config object that can be passed to the annotator Store plugin
getStoreConfig: (uri) ->
prefix = @getPrefix()
if uri is null
uri = @getURIPath()
storeConfig =
prefix: prefix
loadFromSearch:
uri: uri
limit: 0
annotationData:
uri: uri
storeConfig
# Returns the API endpoint for the annotation store
getPrefix: () ->
re = /^(\/courses\/[^/]+\/[^/]+\/[^/]+)/
match = re.exec(@getURIPath())
prefix = (if match then match[1] else '')
return "#{prefix}/notes/api"
# Returns the URI path of the current page for filtering annotations
getURIPath: () ->
window.location.href.toString().split(window.location.host)[1]
# Enable notes by default on the document root.
# To initialize annotations on a container element in the document:
#