olay-rails 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA512:
3
- data.tar.gz: d922b625d2399db9fd9bc1b07fe3961000174b0baf3e59a7b45a1c75970a9e67be5a79054f086c6383d2225b67276933e54c37173d582a16c7a35c19a95b135a
4
- metadata.gz: 67f7e9b7f7cef9e074b5c1c89e256874cb642a8fc01d85a1e936a40e9a749b3a8313c26acfcbea55ad30bbd66ecdbd665405065f531ab3cbdf00e541470ec9c4
3
+ data.tar.gz: 5b642a78813dbad0b298734f7ee2d19e6ed7cb5590dc819d098f3dbd03834e92de05e999e5266e0a2a6c90ea68f9c18e5859b5cc21aadb46378a831118a62b85
4
+ metadata.gz: c81b19768914cdcf0dfe1abb7ce806b37804b1f10c389bd59015d9a4602e49e8c631645f5fac30c377e2b452f4321944d7a009342c8735f46ddee5bad9489a1e
5
5
  SHA1:
6
- data.tar.gz: 9e1869334061f37dcd966ecb4dd2bec62f1273f7
7
- metadata.gz: e0f758ec192a8b16e759de4a89a230264fcc4626
6
+ data.tar.gz: 7a8c03371b6f7a35e301f3db345170309781dc23
7
+ metadata.gz: 854ad8f089a4b6757cf8ff9ed0efbd06aa99f477
@@ -1,6 +1,6 @@
1
1
  module Olay
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  module Rails
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
6
6
  end
@@ -4,6 +4,13 @@
4
4
  // Store a local reference to jQuery.
5
5
  var $ = window.jQuery;
6
6
 
7
+ // This private function will be used to stop event propagation in $content.
8
+ var stopPropagation = function (ev) { ev.stopPropagation(); };
9
+
10
+ // Selector for tabbable elements.
11
+ var tabbable = 'a[href], area[href], :input, iframe, object, embed, ' +
12
+ '*[tabindex], *[contenteditable]';
13
+
7
14
  // Listen for keydown events.
8
15
  $(document).keydown(function (ev) {
9
16
  var $olay = $('.js-olay-container').last();
@@ -14,19 +21,8 @@
14
21
  for (var i = 0, l = keys.length; i < l; ++i) {
15
22
  if (which === keys[i]) return olay.hide() && false;
16
23
  }
17
- if (which === 9) {
18
- setTimeout(function () {
19
- if (!$olay.find(':focus').length) {
20
- $(':focus').blur();
21
- $olay.find(':input').first().focus();
22
- }
23
- }, 0);
24
- }
25
24
  });
26
25
 
27
- // This private function will be used to stop event propagation in $content.
28
- var stopPropagation = function (ev) { ev.stopPropagation(); };
29
-
30
26
  // Create the `Olay` constructor.
31
27
  //
32
28
  // ```js
@@ -151,6 +147,12 @@
151
147
  $olays.length && active === $body[0] ?
152
148
  $olays.last() :
153
149
  $(active);
150
+ $(tabbable).each(function () {
151
+ var $t = $(this);
152
+ if ('olayTabindex' in $t.data()) return;
153
+ $t.data('olayTabindex', $t.attr('tabindex') || null)
154
+ .attr('tabindex', -1);
155
+ });
154
156
  $body.addClass('js-olay-visible').append(this.$container);
155
157
  this.$content.attr('tabindex', 0).focus().removeAttr('tabindex');
156
158
  return this;
@@ -161,7 +163,12 @@
161
163
  this.$container.detach();
162
164
  this._$active.attr('tabindex', 0).focus().removeAttr('tabindex');
163
165
  var $olays = $('.js-olay-container');
164
- if (!$olays.length) $('body').removeClass('js-olay-visible');
166
+ ($olays.length ? $olays.last() : $('body').removeClass('js-olay-visible'))
167
+ .find(tabbable).each(function () {
168
+ var $t = $(this);
169
+ $t.attr('tabindex', $t.data('olayTabindex'))
170
+ .removeData('olayTabindex');
171
+ });
165
172
  this.$el.trigger('hide');
166
173
  if (!this.preserve) this.destroy();
167
174
  return this;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: olay-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Casey Foster
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: "3.1"
23
23
  type: :runtime
24
24
  version_requirements: *id001
25
- description: Places Olay 0.1.6 in the Rails asset pipeline.
25
+ description: Places Olay 0.1.7 in the Rails asset pipeline.
26
26
  email:
27
27
  - c@sey.me
28
28
  executables: []