<commit_before>Spine = require 'Spine'
$ = require 'jQuery'
{delay, translate} = require 'util'

class Tutorial extends Spine.Controller
	steps: null

	className: 'tutorial'
	message: null
	underlay: null

	current = -1

	constructor: ->
		super
		@steps ?= []

		@underlay = $('<div></div>')
		@underlay.addClass 'underlay'

		@underlay.appendTo @el

		@message = $('<div></div>')
		@message.addClass 'message'

		@message.appendTo @el

	start: =>
		@message.add(@underlay).css display: ''
		@current = -1
		@next()

	next: (e) =>
		e?.stopPropagation?()

		if ~@current then @steps[@current].leave @

		@current += 1
		if @steps[@current]
			@steps[@current].enter @
		else
			@message.add(@underlay).css display: 'none'

class Tutorial.Step
	style: null
	className: ''
	arrows: '' # "{top|right|bottom|left}-{top|right|bottom|left}"
	content: ''
	modal: false
	nextOn: null

	continueParagraph: null

	constructor: (params) ->
		@[param] = value for param, value of params

	enter: (tutorial) =>
		both = tutorial.message.add tutorial.underlay

		tutorial.message.html @content

		if @nextOn
			$(window).on event, selector, tutorial.next for event, selector of @nextOn
		else
			buttonsHolder = $('<div class="continue"></div>')
			continueButtons = translate 'tutorialContinue', 'button'
			buttonsHolder.append continueButtons
			tutorial.message.append buttonsHolder
			tutorial.message.on 'click', '.continue button', tutorial.next

		tutorial.message.css @style
		if @modal then both.addClass 'modal'
		delay 333, => both.addClass @className

	leave: (tutorial) =>
		both = tutorial.message.add tutorial.underlay

		tutorial.message.html ''

		if @nextOn
			$(window).off event, selector, tutorial.next for event, selector of @nextOn
		else
			tutorial.message.off 'click', '.continue button', tutorial.next

		tutorial.message.css prop: '' for prop of @style
		both.removeClass 'modal'
		both.removeClass @className

exports = Tutorial<commit_msg>IE8 tutorial fix<commit_after>Spine = require 'Spine'
$ = require 'jQuery'
{delay, translate} = require 'util'

class Tutorial extends Spine.Controller
	steps: null

	className: 'tutorial'
	message: null
	underlay: null

	current = -1

	constructor: ->
		super
		@steps ?= []

		@underlay = $('<div></div>')
		@underlay.addClass 'underlay'

		@underlay.appendTo @el

		@message = $('<div></div>')
		@message.addClass 'message'

		@message.appendTo @el

	start: =>
		@message.add(@underlay).css display: ''
		@current = -1
		@next()

	next: (e) =>
		e?.stopPropagation?()

		if ~@current then @steps[@current].leave @

		@current += 1
		if @steps[@current]
			@steps[@current].enter @
		else
			@message.add(@underlay).css display: 'none'

class Tutorial.Step
	style: null
	className: ''
	arrows: '' # "{top|right|bottom|left}-{top|right|bottom|left}"
	content: ''
	modal: false
	nextOn: null

	continueParagraph: null

	constructor: (params) ->
		@[param] = value for param, value of params

	enter: (tutorial) =>
		both = tutorial.message.add tutorial.underlay

		tutorial.message.html @content

		if @nextOn
			$(document).on event, selector, tutorial.next for event, selector of @nextOn
		else
			buttonsHolder = $('<div class="continue"></div>')
			continueButtons = translate 'tutorialContinue', 'button'
			buttonsHolder.append continueButtons
			tutorial.message.append buttonsHolder
			tutorial.message.on 'click', '.continue button', tutorial.next

		tutorial.message.css @style
		if @modal then both.addClass 'modal'
		delay 333, => both.addClass @className

	leave: (tutorial) =>
		both = tutorial.message.add tutorial.underlay

		tutorial.message.html ''

		if @nextOn
			$(document).off event, selector, tutorial.next for event, selector of @nextOn
		else
			tutorial.message.off 'click', '.continue button', tutorial.next

		tutorial.message.css prop: '' for prop of @style
		both.removeClass 'modal'
		both.removeClass @className

exports = Tutorial
{'fraction_non_alphanumeric': 0.1423106350420811, 'fraction_numerical': 0.0033154807447079828, 'mean_word_length': 4.086900129701686, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '652524', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1251, 'n_words': 329}