Skip to content

Commit

Permalink
Use functions for tutorial steps
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-c committed Mar 20, 2013
1 parent c335d70 commit 9076a61
Showing 1 changed file with 31 additions and 34 deletions.
65 changes: 31 additions & 34 deletions app/lib/tutorial_steps.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,32 @@ $ = require 'jqueryify'
Step::defaultButton = translate 'classify.tutorial.continueButton'

inline = (string) ->
string = string.replace '\n\n', '_NEWLINE_', 'g'
string = string.replace '\n', ' ', 'g'
string = string.replace '_NEWLINE_', '\n', 'g'
string
string.split('\n\n').join '<br /><br />'

module.exports = [
new Step
header: inline translate 'classify.tutorial.welcomeHeader'
content: inline translate 'classify.tutorial.welcome'
header: -> inline translate {p: 'classify.tutorial.welcomeHeader'}
content: -> inline translate {p: 'classify.tutorial.welcome'}

new Step
header: inline translate 'classify.tutorial.trapsHeader'
content: inline translate 'classify.tutorial.traps'
header: -> inline translate {p: 'classify.tutorial.trapsHeader'}
content: -> inline translate {p: 'classify.tutorial.traps'}
attachment: x: 'left', margin: -10, to: '.subject-viewer', at: x: 'right'
focus: '.subject-viewer'
block: 'button[name="finish"]'
className: 'arrow left'

new Step
header: inline translate 'classify.tutorial.taskHeader'
content: inline translate 'classify.tutorial.task'
header: -> inline translate {p: 'classify.tutorial.taskHeader'}
content: -> inline translate {p: 'classify.tutorial.task'}
attachment: x: 'right', margin: -10, to: '.animal-selector', at: x: 'left'
focus: '.animal-selector'
block: '.animal-selector'
className: 'arrow right'

new Step
header: inline translate 'classify.tutorial.chooseAntelopeHeader'
content: inline translate 'classify.tutorial.chooseAntelope'
header: -> inline translate {p: 'classify.tutorial.chooseAntelopeHeader'}
content: -> inline translate {p: 'classify.tutorial.chooseAntelope'}
nextOn: click: 'button[value="likeAntelopeDeer"]'
attachment: x: 'right', margin: 10, to: 'button[name="characteristic"][value="like"]', at: x: 'left'
className: 'arrow right'
Expand All @@ -47,50 +44,50 @@ module.exports = [
@toHighlight.css 'background-color': ''

new Step
header: inline translate 'classify.tutorial.chooseSolidHeader'
content: inline translate 'classify.tutorial.chooseSolid'
header: -> inline translate {p: 'classify.tutorial.chooseSolidHeader'}
content: -> inline translate {p: 'classify.tutorial.chooseSolid'}
nextOn: click: 'button[value="patternSolid"]'
attachment: x: 'right', margin: 10, to: 'button[name="characteristic"][value="pattern"]', at: x: 'left'
className: 'arrow right'

new Step
header: inline translate 'classify.tutorial.chooseCurlyHeader'
content: inline translate 'classify.tutorial.chooseCurly'
header: -> inline translate {p: 'classify.tutorial.chooseCurlyHeader'}
content: -> inline translate {p: 'classify.tutorial.chooseCurly'}
nextOn: click: 'button[value="hornsCurly"]'
attachment: y: 'top', margin: 10, to: 'button[name="characteristic"][value="horns"]', at: y: 'bottom'
className: 'arrow up'

new Step
header: inline translate 'classify.tutorial.chooseWildebeestHeader'
content: inline translate 'classify.tutorial.chooseWildebeest'
header: -> inline translate {p: 'classify.tutorial.chooseWildebeestHeader'}
content: -> inline translate {p: 'classify.tutorial.chooseWildebeest'}
nextOn: click: '[data-animal="wildebeest"]'
attachment: y: 'top', to: '[data-animal="wildebeest"]', at: y: 'bottom'
className: 'arrow up'

new Step
header: inline translate 'classify.tutorial.confirmWildebeestHeader'
content: inline translate 'classify.tutorial.confirmWildebeest'
header: -> inline translate {p: 'classify.tutorial.confirmWildebeestHeader'}
content: -> inline translate {p: 'classify.tutorial.confirmWildebeest'}
attachment: x: 'right', to: '.animal-details .image-changer', at: x: 'left'
className: 'arrow right'

new Step
header: inline translate 'classify.tutorial.identifyWildebeestHeader'
content: inline translate 'classify.tutorial.identifyWildebeest'
header: -> inline translate {p: 'classify.tutorial.identifyWildebeestHeader'}
content: -> inline translate {p: 'classify.tutorial.identifyWildebeest'}
attachment: x: 'right', margin: 10, to: '.animal-details .options', at: x: 'left'
className: 'arrow right'
nextOn: click: 'button[name="identify"]'

new Step
header: inline translate 'classify.tutorial.findZebrasHeader'
content: inline translate 'classify.tutorial.findZebras'
header: -> inline translate {p: 'classify.tutorial.findZebrasHeader'}
content: -> inline translate {p: 'classify.tutorial.findZebras'}
attachment: x: 'left', margin: -10, to: '.subject-viewer', at: x: 'right'
focus: '.subject-viewer'
block: 'button[name="finish"]'
className: 'arrow left'

new Step
header: inline translate 'classify.tutorial.typeZebraHeader'
content: inline translate 'classify.tutorial.typeZebra'
header: -> inline translate {p: 'classify.tutorial.typeZebraHeader'}
content: -> inline translate {p: 'classify.tutorial.typeZebra'}
attachment: x: 'right', margin: 10, to: '.animal-selector .search', at: x: 'left'
className: 'arrow right'
nextOn: {} # This is handled by onEnter.
Expand All @@ -106,28 +103,28 @@ module.exports = [
tutorial.next()

new Step
header: inline translate 'classify.tutorial.clickZebraHeader'
content: inline translate 'classify.tutorial.clickZebra'
header: -> inline translate {p: 'classify.tutorial.clickZebraHeader'}
content: -> inline translate {p: 'classify.tutorial.clickZebra'}
attachment: x: 'right', margin: 10, to: '[data-animal="zebra"]', at: x: 'left'
nextOn: click: '[data-animal="zebra"]'
className: 'arrow right'

new Step
header: inline translate 'classify.tutorial.confirmZebraHeader'
content: inline translate 'classify.tutorial.confirmZebra'
header: -> inline translate {p: 'classify.tutorial.confirmZebraHeader'}
content: -> inline translate {p: 'classify.tutorial.confirmZebra'}
attachment: x: 'right', to: '.animal-details .image-changer', at: x: 'left'
className: 'arrow right'

new Step
header: inline translate 'classify.tutorial.identifyZebraHeader'
content: inline translate 'classify.tutorial.identifyZebra'
header: -> inline translate {p: 'classify.tutorial.identifyZebraHeader'}
content: -> inline translate {p: 'classify.tutorial.identifyZebra'}
attachment: x: 'right', margin: 10, to: '.animal-details .options', at: x: 'left'
nextOn: click: 'button[name="identify"]'
className: 'arrow right'

new Step
header: inline translate 'classify.tutorial.finishHeader'
content: inline translate 'classify.tutorial.finish'
header: -> inline translate {p: 'classify.tutorial.finishHeader'}
content: -> inline translate {p: 'classify.tutorial.finish'}
attachment: y: 'bottom', margin: 10, to: 'button[name="finish"]', at: y: 'top'
className: 'arrow down'
nextOn: click: 'button[name="finish"]'
Expand Down

0 comments on commit 9076a61

Please sign in to comment.