Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
9846db91
Commit
9846db91
authored
Jan 17, 2015
by
ujvari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove annotator.notification
parent
4e247f6d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
96 deletions
+31
-96
notification.coffee
h/static/scripts/annotator/notification.coffee
+0
-92
flash-service.coffee
h/static/scripts/flash-service.coffee
+31
-4
No files found.
h/static/scripts/annotator/notification.coffee
deleted
100644 → 0
View file @
4e247f6d
Annotator
=
Annotator
||
{}
# Public: A simple notification system that can be used to display information,
# warnings and errors to the user. Display of notifications are controlled
# cmpletely by CSS by adding/removing the @options.classes.show class. This
# allows styling/animation using CSS rather than hardcoding styles.
class
Annotator
.
Notification
extends
Delegator
# Sets events to be bound to the @element.
events
:
"click"
:
"hide"
# Default options.
options
:
html
:
"<div class='annotator-notice'></div>"
classes
:
show
:
"annotator-notice-show"
info
:
"annotator-notice-info"
success
:
"annotator-notice-success"
error
:
"annotator-notice-error"
# Public: Creates an instance of Notification and appends it to the
# document body.
#
# options - The following options can be provided.
# classes - A Object literal of classes used to determine state.
# html - An HTML string used to create the notification.
#
# Examples
#
# # Displays a notification with the text "Hello World"
# notification = new Annotator.Notification
# notification.show("Hello World")
#
# Returns
constructor
:
(
options
)
->
super
$
(
@
options
.
html
).
appendTo
(
document
.
body
)[
0
],
options
# Public: Displays the annotation with message and optional status. The
# message will hide itself after 5 seconds or if the user clicks on it.
#
# message - A message String to display (HTML will be escaped).
# status - A status constant. This will apply a class to the element for
# styling. (default: Annotator.Notification.INFO)
#
# Examples
#
# # Displays a notification with the text "Hello World"
# notification.show("Hello World")
#
# # Displays a notification with the text "An error has occurred"
# notification.show("An error has occurred", Annotator.Notification.ERROR)
#
# Returns itself.
show
:
(
message
,
status
=
Annotator
.
Notification
.
INFO
)
=>
@
currentStatus
=
status
$
(
@
element
)
.
addClass
(
@
options
.
classes
.
show
)
.
addClass
(
@
options
.
classes
[
@
currentStatus
])
.
html
(
Util
.
escape
(
message
||
""
))
setTimeout
this
.
hide
,
5000
this
# Public: Hides the notification.
#
# Examples
#
# # Hides the notification.
# notification.hide()
#
# Returns itself.
hide
:
=>
@
currentStatus
?=
Annotator
.
Notification
.
INFO
$
(
@
element
)
.
removeClass
(
@
options
.
classes
.
show
)
.
removeClass
(
@
options
.
classes
[
@
currentStatus
])
this
# Constants for controlling the display of the notification. Each constant
# adds a different class to the Notification#element.
Annotator
.
Notification
.
INFO
=
'show'
Annotator
.
Notification
.
SUCCESS
=
'success'
Annotator
.
Notification
.
ERROR
=
'error'
# Attach notification methods to the Annotation object on document ready.
$
(
->
notification
=
new
Annotator
.
Notification
Annotator
.
showNotification
=
notification
.
show
Annotator
.
hideNotification
=
notification
.
hide
)
h/static/scripts/flash-service.coffee
View file @
9846db91
class
Notification
extends
Annotator
.
Notification
escape
=
(
html
)
->
html
.
replace
(
/&(?!\w+;)/g
,
'&'
)
.
replace
(
/</g
,
'<'
)
.
replace
(
/>/g
,
'>'
)
.
replace
(
/"/g
,
'"'
)
class
Notification
# Default options.
options
:
html
:
"<div class='annotator-notice'></div>"
classes
:
show
:
"annotator-notice-show"
info
:
"annotator-notice-info"
success
:
"annotator-notice-success"
error
:
"annotator-notice-error"
@
INFO
:
'info'
@
ERROR
:
'error'
@
SUCCESS
:
'success'
constructor
:
(
options
)
->
element
=
$
(
@
options
.
html
).
hide
()[
0
]
Annotator
.
Delegator
.
call
(
this
,
element
,
options
)
@
element
=
$
(
element
)
@
options
=
$
.
extend
(
true
,
{},
@
options
,
options
)
# Retain the fat arrow binding despite skipping the super-class constructor
# XXX: replace with _appendElement override when we move to Annotator v2.
show
:
(
message
,
status
=
Notification
.
INFO
)
=>
super
@
currentStatus
=
status
$
(
@
element
)
.
addClass
(
@
options
.
classes
.
show
)
.
addClass
(
@
options
.
classes
[
@
currentStatus
])
.
html
(
escape
(
message
||
""
))
setTimeout
@
hide
,
5000
@
element
.
prependTo
(
document
.
body
).
slideDown
()
hide
:
=>
super
@
currentStatus
?=
Annotator
.
Notification
.
INFO
$
(
@
element
)
.
removeClass
(
@
options
.
classes
.
show
)
.
removeClass
(
@
options
.
classes
[
@
currentStatus
])
@
element
.
slideUp
=>
@
element
.
remove
()
...
...
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