From aa7be96df89fb4fb27301ad59ab675a9c216ee97 Mon Sep 17 00:00:00 2001 From: zodern Date: Tue, 13 Oct 2015 14:29:07 -0500 Subject: [PATCH] auto continue after event when require.autoContinue = true --- .gitignore | 2 ++ tutorial.coffee | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index cee63fd..83b35cf 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ results npm-debug.log node_modules .build* + +.idea/* diff --git a/tutorial.coffee b/tutorial.coffee index 11cbfea..c594782 100644 --- a/tutorial.coffee +++ b/tutorial.coffee @@ -42,6 +42,7 @@ class @TutorialManager @buildActionDeps() buildActionDeps: -> + self = @ @actionDeps = [] for i, step of @steps if step.require @@ -57,9 +58,13 @@ class @TutorialManager # Bind validator dep in closure val = validator d = dep + autoContinue = step.require.autoContinue + stepIndex = self.steps.indexOf step return -> actionCompleted = if val then val.apply(this, arguments) else true if actionCompleted + if stepIndex == self.step && autoContinue + self.next() d.completed = true d.changed() )() @@ -147,9 +152,9 @@ class @TutorialManager elWidth = $el.outerWidth() || parseInt($el.attr("width")) elHeight = $el.outerHeight() || parseInt($el.attr("height")) offset = $el.offset() - + hull.top = Math.min(hull.top, offset.top) - hull.left = Math.min(hull.left, offset.left) + hull.left = Math.min(hull.left, offset.left) hull.bottom = Math.min(hull.bottom, $(window).height() - offset.top - elHeight) hull.right = Math.min(hull.right, $(window).width() - offset.left - elWidth)