abraham 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6e2b0fdbb25af11f86da525702df7f8c2d9464367eb54498293eca7241f84eb
4
- data.tar.gz: 22ef247ce7aafbd7a3ca924e2276e1b4e72177e88a8220918f642f98d299de41
3
+ metadata.gz: 025f51bb1380ebbd7c172d43d66b79ca4b68fdb4eb4af6940364fff44b282176
4
+ data.tar.gz: a791c10896b5f002e1aa5daa8edccd2ec810a4479aeccac4a5d8b28a52795c5d
5
5
  SHA512:
6
- metadata.gz: 32d4be8a289fba23b74c39c6179167835f74951f70e4744b5bf1a15bc88d0c4583d8027469e09b98e4789ebdbca59b7565a9f634d167a86941414255916ee7c5
7
- data.tar.gz: 2daafd2638b951436faf4b904ecf4aeb57c73034a3783debc77337b67de3dc7bd3ec037f2c4e31e05d08e7a6cc56e3959ac9a6eb6ea534306a18a944535b4fa3
6
+ metadata.gz: 4e6f5e3fae2acca16748c5ace7c7fde3436e3aab72604c3e35030d5488ec389fd4903ff53a63dbdc4fe473a554853860a6d6f05e8a126bd49d7ae15f71c573b4
7
+ data.tar.gz: 816fb772c290eb0504885b2e93f21d952e7322bf87c05ca3332d57c6ff81fb1e5062a93824d5d087b142c05e4efab6af2f01fdbbc12623b9b3740acb82cc4a7d
data/README.md CHANGED
@@ -17,6 +17,7 @@ Abraham makes it easy to show guided tours to users of your Rails application. W
17
17
  ## Requirements
18
18
 
19
19
  * Abraham needs to know the current user to track tour views, e.g. `current_user` from Devise.
20
+ * If you are using a different method to identify who is currently logged in, you can, for example, add an alias to make it work. Assuming you have a method `current_foo` to identify your currenly logged-in user, you can add `alias_method 'current_user', 'current_foo'` in the place you define `current_foo`.
20
21
  * Abraham is tested on Rails 5.2, 6.0, and 6.1
21
22
 
22
23
  ## Installation
@@ -131,6 +132,8 @@ Abraham takes care of which buttons should appear with each step:
131
132
  * "Exit" and "Next" buttons on intermediate steps
132
133
  * "Done" button on the last step
133
134
 
135
+ See below for how to define custom buttons.
136
+
134
137
  When you specify an `attachTo` element, use the `placement` option to choose where the callout should appear relative to that element:
135
138
 
136
139
  * `bottom` / `bottom center`
@@ -181,6 +184,29 @@ This tour will not start automatically; instead, use the `Abraham.startTour` met
181
184
  </script>
182
185
  ```
183
186
 
187
+ ### Custom buttons
188
+
189
+ You can define custom buttons in a step like so:
190
+
191
+ ```
192
+ my_tour:
193
+ steps:
194
+ 1:
195
+ text: "Welcome to my custom button tour"
196
+ buttons:
197
+ 1:
198
+ text: 'Show this to me later'
199
+ action: 'cancel'
200
+ classes: 'custom-button shepherd-button-secondary'
201
+ 2:
202
+ text: 'Finish now'
203
+ action: 'complete'
204
+ classes: 'custom-button'
205
+ ```
206
+
207
+ * `action` is one of the Shepherd tour method names, i.e. `cancel`, `next`, or `complete`
208
+ * `classes` are the CSS class names you want applied to the button
209
+
184
210
  ### Testing your tours
185
211
 
186
212
  Abraham loads tour definitions once when you start your server. Restart your server to see tour changes.
@@ -29,22 +29,28 @@
29
29
  <% end %>
30
30
  text: "<%= step['text'] %>",
31
31
  <% if step.key?('attachTo') %>
32
- attachTo: { element: "<%= step['attachTo']['element'] %>", on: "<%= step['attachTo']['placement'] %>" },
32
+ attachTo: { element: "<%= escape_javascript(step['attachTo']['element'].html_safe) %>", on: "<%= step['attachTo']['placement'] %>" },
33
33
  showOn: function() {
34
34
  // Only display this step if its selector is present
35
- return document.querySelector("<%= step['attachTo']['element'] %>") ? true : false
35
+ return document.querySelector("<%= escape_javascript(step['attachTo']['element'].html_safe) %>") ? true : false
36
36
  },
37
37
  <% end %>
38
38
  buttons: [
39
- <% if index == steps.size - 1 %>
40
- { text: '<%= t('abraham.done') %>', action: Abraham.tours["<%= tour_name %>"].complete }
39
+ <% if step.key?('buttons') %>
40
+ <% step['buttons'].each do |button| %>
41
+ { text: '<%= button[1]['text'] %>', action: Abraham.tours["<%= tour_name %>"].<%= button[1]['action'] %>, classes: '<%= button[1]['classes'] %>' },
42
+ <% end %>
41
43
  <% else %>
42
- <% if index == 0 %>
43
- { text: '<%= t('abraham.later') %>', action: Abraham.tours["<%= tour_name %>"].cancel, classes: 'shepherd-button-secondary' },
44
- { text: '<%= t('abraham.continue') %>', action: Abraham.tours["<%= tour_name %>"].next }
44
+ <% if index == steps.size - 1 %>
45
+ { text: '<%= t('abraham.done') %>', action: Abraham.tours["<%= tour_name %>"].complete }
45
46
  <% else %>
46
- { text: '<%= t('abraham.exit') %>', action: Abraham.tours["<%= tour_name %>"].cancel, classes: 'shepherd-button-secondary' },
47
- { text: '<%= t('abraham.next') %>', action: Abraham.tours["<%= tour_name %>"].next }
47
+ <% if index == 0 %>
48
+ { text: '<%= t('abraham.later') %>', action: Abraham.tours["<%= tour_name %>"].cancel, classes: 'shepherd-button-secondary' },
49
+ { text: '<%= t('abraham.continue') %>', action: Abraham.tours["<%= tour_name %>"].next }
50
+ <% else %>
51
+ { text: '<%= t('abraham.exit') %>', action: Abraham.tours["<%= tour_name %>"].cancel, classes: 'shepherd-button-secondary' },
52
+ { text: '<%= t('abraham.next') %>', action: Abraham.tours["<%= tour_name %>"].next }
53
+ <% end %>
48
54
  <% end %>
49
55
  <% end %>
50
56
  ]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Abraham
4
- VERSION = "2.4.0"
4
+ VERSION = "2.5.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abraham
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Abbett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-17 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sassc-rails