diff --git a/README.md b/README.md index fb8b6e5..7d09c7d 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,11 @@ Abraham takes care of which buttons should appear with each step: * "Exit" and "Next" buttons on intermediate steps * "Done" button on the last step +Abraham tries to be helpful when your tour steps attach to page elements that are missing: + +* If your first step is attached to a particular element, and that element is not present on the page, the tour won't start. ([#28](https://github.com/actmd/abraham/issues/28)) +* If your tour has an intermediate step attached to a missing element, Abraham will skip that step and automatically show the next. ([#6](https://github.com/actmd/abraham/issues/6)) + ### Testing your tours Abraham loads tour definitions once when you start your server. Restart your server to see tour changes. diff --git a/abraham.gemspec b/abraham.gemspec index 0d0da07..65c6fb8 100644 --- a/abraham.gemspec +++ b/abraham.gemspec @@ -22,4 +22,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'sqlite3' s.add_development_dependency 'rubocop' s.add_development_dependency 'listen' + s.add_development_dependency 'web-console' end diff --git a/app/views/application/_abraham.html.erb b/app/views/application/_abraham.html.erb index a743d5d..084124c 100644 --- a/app/views/application/_abraham.html.erb +++ b/app/views/application/_abraham.html.erb @@ -54,7 +54,13 @@ tour.start = function (start) { return function () { // Don't start the tour if the user dismissed it once this session - if (!Cookies.get('<%= abraham_cookie_prefix %>-<%= tour_name %>', {domain: '<%= abraham_domain %>'})) { + var tourMayStart = !Cookies.get('<%= abraham_cookie_prefix %>-<%= tour_name %>', {domain: '<%= abraham_domain %>'}); + <% if steps.first[1]['attachTo'] %> + // Don't start the tour if the first step's element is missing + tourMayStart = tourMayStart && document.querySelector("<%= steps.first[1]['attachTo']['element'] %>"); + <% end %> + + if (tourMayStart) { start(); } } diff --git a/lib/abraham/version.rb b/lib/abraham/version.rb index 785d9de..5540f8c 100644 --- a/lib/abraham/version.rb +++ b/lib/abraham/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Abraham - VERSION = "2.1.0" + VERSION = "2.1.1" end diff --git a/test/dummy/app/controllers/dashboard_controller.rb b/test/dummy/app/controllers/dashboard_controller.rb index aa4389d..1452282 100644 --- a/test/dummy/app/controllers/dashboard_controller.rb +++ b/test/dummy/app/controllers/dashboard_controller.rb @@ -2,6 +2,6 @@ class DashboardController < ApplicationController def home; end - def other; end + def missing; end end diff --git a/test/dummy/app/views/dashboard/missing.html.erb b/test/dummy/app/views/dashboard/missing.html.erb new file mode 100644 index 0000000..b2ce2e1 --- /dev/null +++ b/test/dummy/app/views/dashboard/missing.html.erb @@ -0,0 +1,5 @@ +