Commit 7e6d4ee1 authored by Randall Leeds's avatar Randall Leeds

Stack notifications at the top

Close #479
parent b2489932
...@@ -222,24 +222,15 @@ $input-border-radius: 2px; ...@@ -222,24 +222,15 @@ $input-border-radius: 2px;
//FLASH/TOAST/ALERTS/////////////////////////////// //FLASH/TOAST/ALERTS///////////////////////////////
.annotator-notice { .annotator-notice {
@include border-radius(.1em); @include border-radius(.1em);
@include smallshadow; @include box-shadow(inset 2px 1px 1px hsla(0, 0%, 0%, .1));
@include single-transition(opacity, .2s); @include single-transition(opacity, .2s);
padding: .3em;
font-family: $sansFontFamily; font-family: $sansFontFamily;
border: solid 1px; line-height: 29px;
bottom: 18%;
left: 50%;
margin-left: -15%;
opacity: 0; opacity: 0;
pointer-events: none;
position: fixed;
text-align: center; text-align: center;
width: 30%;
z-index: 2000;
&.show, &.annotator-notice-show { &.show, &.annotator-notice-show {
opacity: .8; opacity: 1;
pointer-events: initial;
} }
} }
......
...@@ -1216,7 +1216,7 @@ h3.stream { ...@@ -1216,7 +1216,7 @@ h3.stream {
padding-bottom: 2em; padding-bottom: 2em;
width: 100%; width: 100%;
text-align: center; text-align: center;
position: fixed; position: absolute;
top: 29px; top: 29px;
right: 0; right: 0;
z-index: 4; z-index: 4;
......
...@@ -5,7 +5,6 @@ class FlashProvider ...@@ -5,7 +5,6 @@ class FlashProvider
error: [] error: []
success: [] success: []
notice: null notice: null
timeout: null
constructor: -> constructor: ->
# Configure notification classes # Configure notification classes
...@@ -15,31 +14,22 @@ class FlashProvider ...@@ -15,31 +14,22 @@ class FlashProvider
SUCCESS: 'success' SUCCESS: 'success'
_process: -> _process: ->
@timeout = null
for q, msgs of @queues for q, msgs of @queues
if msgs.length if msgs.length
msg = msgs.shift() msg = msgs.shift()
unless q then [q, msg] = msg unless q then [q, msg] = msg
if annotator.isOpen() or not annotator.host notice = new Hypothesis.Notification()
notice = Annotator.showNotification msg, q notice.show(msg, q)
@timeout = this._wait => notice.element.hide().slideDown()
this._process() this._wait =>
else notice.element.slideUp ->
annotator.host.notify notice.element.remove()
method: "showNotification"
params:
message: msg
type: q
@timeout = this._wait =>
annotator.host.notify
method: "removeNotification"
this._process()
break break
_flash: (queue, messages) -> _flash: (queue, messages) ->
if @queues[queue]? if @queues[queue]?
@queues[queue] = @queues[queue]?.concat messages @queues[queue] = @queues[queue]?.concat messages
this._process() unless @timeout? this._process()
$get: ['$timeout', ($timeout) -> $get: ['$timeout', ($timeout) ->
this._wait = (cb) -> $timeout cb, 5000 this._wait = (cb) -> $timeout cb, 5000
......
...@@ -265,8 +265,6 @@ class Annotator.Guest extends Annotator ...@@ -265,8 +265,6 @@ class Annotator.Guest extends Annotator
# Are we allowed to create annotations? Return false if we can't. # Are we allowed to create annotations? Return false if we can't.
unless @canAnnotate unless @canAnnotate
#@Annotator.showNotification "You are already editing an annotation!",
# @Annotator.Notification.INFO
return false return false
# Do we really want to make this selection? # Do we really want to make this selection?
...@@ -446,7 +444,7 @@ class Annotator.Guest extends Annotator ...@@ -446,7 +444,7 @@ class Annotator.Guest extends Annotator
# We have to clear the selection. # We have to clear the selection.
# (Annotator does this automatically by focusing on # (Annotator does this automatically by focusing on
# one of the input fields in the editor.) # one of the input fields in the editor.)
@Annotator.util.getGlobal().getSelection().removeAllRanges() Annotator.util.getGlobal().getSelection().removeAllRanges()
onSetTool: (name) -> onSetTool: (name) ->
switch name switch name
......
...@@ -36,16 +36,6 @@ class Annotator.Host extends Annotator.Guest ...@@ -36,16 +36,6 @@ class Annotator.Host extends Annotator.Guest
# Scan the document # Scan the document
this.scanDocument "Host initialized" this.scanDocument "Host initialized"
# Save this reference to the Annotator class, so it's available
# later, even if someone has deleted the original reference
@Annotator = Annotator
# Configure notification classes
Annotator.$.extend Annotator.Notification,
INFO: 'info'
ERROR: 'error'
SUCCESS: 'success'
_setupXDM: (options) -> _setupXDM: (options) ->
channel = super channel = super
...@@ -99,18 +89,6 @@ class Annotator.Host extends Annotator.Guest ...@@ -99,18 +89,6 @@ class Annotator.Host extends Annotator.Guest
Math.max.apply(Math, all) Math.max.apply(Math, all)
) )
.bind('showNotification', (ctx, n) =>
@_pendingNotice = @Annotator.showNotification n.message, n.type
)
.bind('removeNotification', =>
# work around Annotator.Notification not removing classes
return unless @_pendingNotice?
for _, klass of @_pendingNotice.options.classes
@_pendingNotice.element.removeClass klass
delete @_pendingNotice
)
_setupDragEvents: -> _setupDragEvents: ->
el = document.createElementNS 'http://www.w3.org/1999/xhtml', 'canvas' el = document.createElementNS 'http://www.w3.org/1999/xhtml', 'canvas'
el.width = el.height = 1 el.width = el.height = 1
......
...@@ -631,6 +631,17 @@ class Hypothesis extends Annotator ...@@ -631,6 +631,17 @@ class Hypothesis extends Annotator
return @element.injector().get('drafts').discard() return @element.injector().get('drafts').discard()
class Hypothesis.Notification extends Annotator.Notification
constructor: (options) ->
element = $(@options.html).prependTo('body')[0]
Annotator.Delegator.call(this, element, options)
# Retain the fat arrow binding despite skipping the super-class constructor
# XXX: replace with _appendElement override when we move to Annotator v2.
show: => super
hide: => super
class AuthenticationProvider class AuthenticationProvider
constructor: -> constructor: ->
@actions = @actions =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment