Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
0574eb49
Commit
0574eb49
authored
Mar 25, 2013
by
Arthur Barrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initialize annotator on any element by note:init event
parent
71209989
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
33 deletions
+32
-33
lms/static/coffee/src/notes.coffee
+29
-30
lms/templates/static_htmlbook.html
+3
-3
No files found.
lms/static/coffee/src/notes.coffee
View file @
0574eb49
class
@
StudentNotes
class
StudentNotes
targets
:
[]
_debug
:
true
storeConfig
:
targets
:
[]
# elements with annotator() instances
prefix
:
''
annotationData
:
uri
:
''
constructor
:
()
->
constructor
:
(
$
,
el
)
->
@
storeConfig
=
console
.
log
'student notes init'
,
arguments
,
this
if
@
_debug
prefix
:
@
getPrefix
()
annotationData
:
uri
:
@
getURIPath
()
$
(
document
).
ready
(
@
init
)
if
$
(
el
).
data
(
'notes-ready'
)
isnt
'yes'
$
(
el
).
delegate
'*'
,
'notes:init'
:
@
onInitNotes
init
:
(
$
)
=>
$
(
el
).
data
(
'notes-ready'
,
'yes'
)
if
not
StudentNotes
.
ready
$
(
document
).
delegate
(
'*'
,
{
'notes:init'
:
@
onInitNotes
,
'notes:load'
:
@
onLoadNotes
})
StudentNotes
.
ready
=
true
onInitNotes
:
(
event
,
annotationData
=
null
)
=>
onInitNotes
:
(
event
,
annotationData
=
null
)
=>
found
=
(
target
for
target
in
@
targets
when
target
is
event
.
target
)
event
.
stopPropagation
(
)
storeConfig
=
$
.
extend
{},
@
storeConfig
found
=
@
targets
.
some
(
target
)
->
target
is
event
.
target
$
.
extend
(
storeConfig
.
annotationData
,
annotationData
)
if
annotationData
if
found
.
length
is
0
if
found
annotator
=
$
(
event
.
target
).
data
(
'annotator'
)
store
=
annotator
.
plugins
[
'Store'
]
store
.
options
.
annotationData
=
annotationData
if
annotationData
store
.
loadAnnotations
()
else
$
(
event
.
target
).
annotator
()
$
(
event
.
target
).
annotator
()
.
annotator
(
'addPlugin'
,
'Tags'
)
.
annotator
(
'addPlugin'
,
'Tags'
)
.
annotator
(
'addPlugin'
,
'Store'
,
storeConfig
)
.
annotator
(
'addPlugin'
,
'Store'
,
@
getStoreConfig
(
annotationData
))
@
targets
.
push
(
event
.
target
)
@
targets
.
push
(
event
.
target
)
onLoadNotes
:
(
event
)
=>
getStoreConfig
:
(
annotationData
)
->
if
event
.
target
in
@
targets
storeConfig
=
$
(
event
.
target
).
annotator
().
annotator
(
'loadAnnotations'
)
prefix
:
@
getPrefix
()
annotationData
:
uri
:
@
getURIPath
()
# defaults to current URI path
$
.
extend
storeConfig
.
annotationData
,
annotationData
if
annotationData
storeConfig
getPrefix
:
()
->
getPrefix
:
()
->
re
=
/^(\/courses\/[^/]+\/[^/]+\/[^/]+)/
re
=
/^(\/courses\/[^/]+\/[^/]+\/[^/]+)/
...
@@ -47,3 +43,5 @@ class @StudentNotes
...
@@ -47,3 +43,5 @@ class @StudentNotes
getURIPath
:
()
->
getURIPath
:
()
->
window
.
location
.
href
.
toString
().
split
(
window
.
location
.
host
)[
1
]
window
.
location
.
href
.
toString
().
split
(
window
.
location
.
host
)[
1
]
$
(
document
).
ready
(
$
)
->
new
StudentNotes
(
$
,
this
)
\ No newline at end of file
lms/templates/static_htmlbook.html
View file @
0574eb49
...
@@ -32,9 +32,9 @@
...
@@ -32,9 +32,9 @@
}
}
var
onComplete
=
function
(
url
)
{
var
onComplete
=
function
(
url
)
{
return
function
()
{
return
function
()
{
annotationData
=
{
'uri'
:
url
}
var
annotationData
=
{
'uri'
:
url
}
$
(
this
).
trigger
(
'notes:init'
,
[
annotationData
]);
$
(
'#viewerContainer'
).
trigger
(
'notes:init'
,
[
annotationData
]);
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment