Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions anno.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 26 additions & 4 deletions src/anno.litcoffee
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,24 @@ Note: whatever you return from your `onShow` function will be passed into the `o

_returnFromOnShow = null

onComplete: (anno) ->

Complete is called when an anno chain reaches the end.

complete: () ->
@hide()
@onComplete(this)
return this

Dismissed is called when a user effectively ends a tour by clicking on the overlay background.

onDismissed: (anno) ->

dismissed: () ->
@hide()
@onDismissed(this)
return this

Hiding is done in two stages so that you can re-use one overlay element for a long chain of Anno's.

hide: () ->
Expand Down Expand Up @@ -345,7 +363,8 @@ Semi-transparent overlay and other effects
click( (evt) => @overlayClick.call(this, this, evt) )

overlayClassName: '' # TODO talk about .anno-hidden
overlayClick: (anno, evt) -> anno.hide()

overlayClick: (anno, evt) -> anno.dismissed()

hideOverlay: () ->
$('.anno-overlay').addClass 'anno-hidden'
Expand Down Expand Up @@ -558,7 +577,10 @@ Buttons
return $("<button class='anno-btn'></button>").
html( @textFn(anno) ).
addClass( @className ).
click( (evt) => @click.call(anno, anno, evt) )
click( (evt) => {
evt.preventDefault();
@click.call(anno, anno, evt)
})

textFn: (anno) ->
if @text? then @text
Expand All @@ -576,14 +598,14 @@ fat arrow.
if anno._chainNext?
anno.switchToChainNext()
else
anno.hide()
anno.complete()

These are some handy presets that you can use by adding `AnnoButton.NextButton` to your Anno object's
`buttons` list.

@NextButton: new AnnoButton({ text: 'Next' , click: () -> @switchToChainNext() })

@DoneButton: new AnnoButton({ text: 'Done' , click: () -> @hide() })
@DoneButton: new AnnoButton({ text: 'Done' , click: () -> @complete() })

@BackButton: new AnnoButton(
text: 'Back'
Expand Down