olay-rails 0.1.4 → 0.1.5
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 +4 -4
- data/lib/olay/rails/version.rb +2 -2
- data/vendor/assets/javascripts/olay.js +45 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA512:
|
3
|
-
|
4
|
-
|
3
|
+
data.tar.gz: 3114549633c5e25c242a848201f9462cada5a8f54470ecf30cee395add7c6d49598a8186d67902336010a8d0478f34b1d6311e1f3ba6e7c9fa86a024072a73dc
|
4
|
+
metadata.gz: ca99747b6a1f88fd8e8797d573e3ef0c25c37f71ccc7c2aa18df2c97fc055ae21f771369839947cc65ecdf0e46b522fc5db5bf89a52ac2ab5d84dd02a6fb1fa8
|
5
5
|
SHA1:
|
6
|
-
|
7
|
-
|
6
|
+
data.tar.gz: a5fa72dd98c53d38d620bbb98a6481f2765c8ee7
|
7
|
+
metadata.gz: 4447c9c9feae298e14a42cce37bc46a3c8e3018a
|
data/lib/olay/rails/version.rb
CHANGED
@@ -16,13 +16,25 @@
|
|
16
16
|
}
|
17
17
|
});
|
18
18
|
|
19
|
+
// This private function will be used to stop event propagation in $content.
|
20
|
+
var stopPropagation = function (ev) { ev.stopPropagation(); };
|
21
|
+
|
19
22
|
// Create the `Olay` constructor.
|
20
23
|
//
|
21
24
|
// ```js
|
22
25
|
// var olay = new Olay('Howdy!', {duration: 5000});
|
23
26
|
// ```js
|
24
27
|
var Olay = window.Olay = function (el, options) {
|
28
|
+
|
29
|
+
// Extend the instance with its options.
|
25
30
|
for (var name in options) this[name] = options[name];
|
31
|
+
|
32
|
+
// Store a bound `hide` to be used for callbacks. This is also used to
|
33
|
+
// ensure event callbacks can be removed consistently.
|
34
|
+
var self = this;
|
35
|
+
this._hide = function () { return self.hide(); };
|
36
|
+
|
37
|
+
// Create the necessary DOM nodes.
|
26
38
|
this.$container = $('<div>')
|
27
39
|
.addClass('js-olay-container')
|
28
40
|
.addClass(this.transition)
|
@@ -36,8 +48,10 @@
|
|
36
48
|
this.$content = $('<div>')
|
37
49
|
.addClass('js-olay-content')
|
38
50
|
.attr({role: 'alertdialog', 'aria-label': this.ariaLabel})
|
39
|
-
.
|
40
|
-
|
51
|
+
.on('click', '.js-olay-hide', this._hide))));
|
52
|
+
|
53
|
+
// Finally, set the element.
|
54
|
+
this.setElement(el);
|
41
55
|
};
|
42
56
|
|
43
57
|
// Define `prototype` properties and methods for `Olay`.
|
@@ -62,6 +76,13 @@
|
|
62
76
|
// Should the olay be hidden when there is a click outside the content box?
|
63
77
|
hideOnClick: true,
|
64
78
|
|
79
|
+
// Preserve the DOM data and events for this olay. If this is set to `true`,
|
80
|
+
// be sure to either set it to `false` before your final `hide` call, or
|
81
|
+
// after your final `hide` call invoke `destroy()` after your transition.
|
82
|
+
// Failure to do this will cause memory leaks. When `preserve` is set to
|
83
|
+
// `false` this is handled automaticaly.
|
84
|
+
preserve: false,
|
85
|
+
|
65
86
|
// Show the olay.
|
66
87
|
show: function () {
|
67
88
|
var inDom = $.contains($('body')[0], this.$container[0]);
|
@@ -73,19 +94,17 @@
|
|
73
94
|
// this will apply the end result of the transition instantly, which is
|
74
95
|
// not desirable in a transition...
|
75
96
|
this.$container.data('olay', this).height();
|
76
|
-
this.$container.addClass('js-olay-show');
|
77
|
-
|
78
|
-
var hide = function () { self.hide(); };
|
79
|
-
this.$content.on('click', '.js-olay-hide', hide);
|
97
|
+
this.$container.addClass('js-olay-show').off('click', this._hide);
|
98
|
+
this.$content.off('click', stopPropagation);
|
80
99
|
if (this.hideOnClick) {
|
81
|
-
this.$container.click(
|
82
|
-
this.$content.click(
|
100
|
+
this.$container.click(this._hide);
|
101
|
+
this.$content.click(stopPropagation);
|
83
102
|
}
|
84
103
|
this.$el.trigger('show');
|
85
104
|
var duration = this.duration;
|
86
105
|
if (!duration) return this;
|
87
106
|
duration += this.transitionDuration;
|
88
|
-
this._timeout = setTimeout(
|
107
|
+
this._timeout = setTimeout(this._hide, duration);
|
89
108
|
return this;
|
90
109
|
},
|
91
110
|
|
@@ -95,7 +114,6 @@
|
|
95
114
|
if (!this.$container.hasClass('js-olay-show')) return;
|
96
115
|
clearTimeout(this._timeout);
|
97
116
|
this.$container.removeClass('js-olay-show');
|
98
|
-
this.$el.trigger('hide');
|
99
117
|
var duration = this.transitionDuration;
|
100
118
|
if (!duration) return this._remove();
|
101
119
|
var self = this;
|
@@ -103,6 +121,19 @@
|
|
103
121
|
return this;
|
104
122
|
},
|
105
123
|
|
124
|
+
// Use this method to set or update `$el`.
|
125
|
+
setElement: function (el) {
|
126
|
+
this.$content.empty().append(this.$el = el instanceof $ ? el : $(el));
|
127
|
+
},
|
128
|
+
|
129
|
+
// Completely remove the `$container` element and its children and all of
|
130
|
+
// the associated data and events. This will only ever need to be called if
|
131
|
+
// the `preserve` option is `true` to prevent memory leaks.
|
132
|
+
destroy: function () {
|
133
|
+
this.$container.remove();
|
134
|
+
return this;
|
135
|
+
},
|
136
|
+
|
106
137
|
// Append `$container` to the DOM. Used internally.
|
107
138
|
_append: function () {
|
108
139
|
var $body = $('body');
|
@@ -123,9 +154,9 @@
|
|
123
154
|
return this;
|
124
155
|
},
|
125
156
|
|
126
|
-
// Detach
|
157
|
+
// Detach and optionally remove `$container` from the DOM. Used internally.
|
127
158
|
_remove: function () {
|
128
|
-
this.$container.
|
159
|
+
this.$container.detach();
|
129
160
|
this._$active.attr('tabindex', 0).focus().removeAttr('tabindex');
|
130
161
|
var $olays = $('.js-olay-container');
|
131
162
|
($olays.length ? $olays.last() : $('body').removeClass('js-olay-visible'))
|
@@ -134,6 +165,8 @@
|
|
134
165
|
$t.attr('tabindex', $t.data('olayTabindex'))
|
135
166
|
.removeData('olayTabindex');
|
136
167
|
});
|
168
|
+
this.$el.trigger('hide');
|
169
|
+
if (!this.preserve) this.destroy();
|
137
170
|
return this;
|
138
171
|
}
|
139
172
|
};
|
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.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Casey Foster
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2013-03-
|
13
|
+
date: 2013-03-07 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
prerelease: false
|
@@ -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.
|
25
|
+
description: Places Olay 0.1.5 in the Rails asset pipeline.
|
26
26
|
email:
|
27
27
|
- c@sey.me
|
28
28
|
executables: []
|