stickykit-rails 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/stickykit/rails.rb +8 -0
- data/lib/stickykit/rails/version.rb +5 -0
- data/stickykit-rails.gemspec +21 -0
- data/vendor/assets/javascripts/jquery.sticky-kit.js +251 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b9e90226561658b10ed191231a20fe925078d709
|
4
|
+
data.tar.gz: 0358e10ce8b0bd965eec89227651ca6b5ddeeeac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0638c4c2485e52c97bf34d94d8fbca4686c521097182264918656cc4f8c06875561637eaeae928e7cd7faed65f3983e416fa09a2997a0c944794bd6dbf43f876
|
7
|
+
data.tar.gz: e73ba96cae291f9c4fff16b162e4c24ae84aa38d1fab55b73f6c381d713d92fd431d76064e9b6eff3a4c177c3fb1ae13c0f515368228d1380115c82ad356dfd1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Emile Silvis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Stickykit::Rails
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'stickykit-rails'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install stickykit-rails
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/stickykit-rails/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'stickykit/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "stickykit-rails"
|
8
|
+
spec.version = Stickykit::Rails::VERSION
|
9
|
+
spec.authors = ["Emile Silvis"]
|
10
|
+
spec.email = ["emile@silvis.co.za"]
|
11
|
+
spec.summary = %q{Sticky-kit for the Rails asset pipeline.}
|
12
|
+
spec.description = %q{Sticky-kit is a jQuery plugin that makes it easy to do sticky sidebars. This gem gives you Sticky-kit for the Rails asset pipeline.}
|
13
|
+
spec.homepage = "https://github.com/emilesilvis/stickykit-rails"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
end
|
@@ -0,0 +1,251 @@
|
|
1
|
+
// Generated by CoffeeScript 1.9.2
|
2
|
+
|
3
|
+
/**
|
4
|
+
@license Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | http://leafo.net
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function() {
|
8
|
+
var $, win;
|
9
|
+
|
10
|
+
$ = this.jQuery || window.jQuery;
|
11
|
+
|
12
|
+
win = $(window);
|
13
|
+
|
14
|
+
$.fn.stick_in_parent = function(opts) {
|
15
|
+
var doc, elm, enable_bottoming, fn, i, inner_scrolling, len, manual_spacer, offset_top, parent_selector, recalc_every, sticky_class;
|
16
|
+
if (opts == null) {
|
17
|
+
opts = {};
|
18
|
+
}
|
19
|
+
sticky_class = opts.sticky_class, inner_scrolling = opts.inner_scrolling, recalc_every = opts.recalc_every, parent_selector = opts.parent, offset_top = opts.offset_top, manual_spacer = opts.spacer, enable_bottoming = opts.bottoming;
|
20
|
+
if (offset_top == null) {
|
21
|
+
offset_top = 0;
|
22
|
+
}
|
23
|
+
if (parent_selector == null) {
|
24
|
+
parent_selector = void 0;
|
25
|
+
}
|
26
|
+
if (inner_scrolling == null) {
|
27
|
+
inner_scrolling = true;
|
28
|
+
}
|
29
|
+
if (sticky_class == null) {
|
30
|
+
sticky_class = "is_stuck";
|
31
|
+
}
|
32
|
+
doc = $(document);
|
33
|
+
if (enable_bottoming == null) {
|
34
|
+
enable_bottoming = true;
|
35
|
+
}
|
36
|
+
fn = function(elm, padding_bottom, parent_top, parent_height, top, height, el_float, detached) {
|
37
|
+
var bottomed, detach, fixed, last_pos, last_scroll_height, offset, parent, recalc, recalc_and_tick, recalc_counter, spacer, tick;
|
38
|
+
if (elm.data("sticky_kit")) {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
elm.data("sticky_kit", true);
|
42
|
+
last_scroll_height = doc.height();
|
43
|
+
parent = elm.parent();
|
44
|
+
if (parent_selector != null) {
|
45
|
+
parent = parent.closest(parent_selector);
|
46
|
+
}
|
47
|
+
if (!parent.length) {
|
48
|
+
throw "failed to find stick parent";
|
49
|
+
}
|
50
|
+
fixed = false;
|
51
|
+
bottomed = false;
|
52
|
+
spacer = manual_spacer != null ? manual_spacer && elm.closest(manual_spacer) : $("<div />");
|
53
|
+
if (spacer) {
|
54
|
+
spacer.css('position', elm.css('position'));
|
55
|
+
}
|
56
|
+
recalc = function() {
|
57
|
+
var border_top, padding_top, restore;
|
58
|
+
if (detached) {
|
59
|
+
return;
|
60
|
+
}
|
61
|
+
last_scroll_height = doc.height();
|
62
|
+
border_top = parseInt(parent.css("border-top-width"), 10);
|
63
|
+
padding_top = parseInt(parent.css("padding-top"), 10);
|
64
|
+
padding_bottom = parseInt(parent.css("padding-bottom"), 10);
|
65
|
+
parent_top = parent.offset().top + border_top + padding_top;
|
66
|
+
parent_height = parent.height();
|
67
|
+
if (fixed) {
|
68
|
+
fixed = false;
|
69
|
+
bottomed = false;
|
70
|
+
if (manual_spacer == null) {
|
71
|
+
elm.insertAfter(spacer);
|
72
|
+
spacer.detach();
|
73
|
+
}
|
74
|
+
elm.css({
|
75
|
+
position: "",
|
76
|
+
top: "",
|
77
|
+
width: "",
|
78
|
+
bottom: ""
|
79
|
+
}).removeClass(sticky_class);
|
80
|
+
restore = true;
|
81
|
+
}
|
82
|
+
top = elm.offset().top - (parseInt(elm.css("margin-top"), 10) || 0) - offset_top;
|
83
|
+
height = elm.outerHeight(true);
|
84
|
+
el_float = elm.css("float");
|
85
|
+
if (spacer) {
|
86
|
+
spacer.css({
|
87
|
+
width: elm.outerWidth(true),
|
88
|
+
height: height,
|
89
|
+
display: elm.css("display"),
|
90
|
+
"vertical-align": elm.css("vertical-align"),
|
91
|
+
"float": el_float
|
92
|
+
});
|
93
|
+
}
|
94
|
+
if (restore) {
|
95
|
+
return tick();
|
96
|
+
}
|
97
|
+
};
|
98
|
+
recalc();
|
99
|
+
if (height === parent_height) {
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
last_pos = void 0;
|
103
|
+
offset = offset_top;
|
104
|
+
recalc_counter = recalc_every;
|
105
|
+
tick = function() {
|
106
|
+
var css, delta, recalced, scroll, will_bottom, win_height;
|
107
|
+
if (detached) {
|
108
|
+
return;
|
109
|
+
}
|
110
|
+
recalced = false;
|
111
|
+
if (recalc_counter != null) {
|
112
|
+
recalc_counter -= 1;
|
113
|
+
if (recalc_counter <= 0) {
|
114
|
+
recalc_counter = recalc_every;
|
115
|
+
recalc();
|
116
|
+
recalced = true;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
if (!recalced && doc.height() !== last_scroll_height) {
|
120
|
+
recalc();
|
121
|
+
recalced = true;
|
122
|
+
}
|
123
|
+
scroll = win.scrollTop();
|
124
|
+
if (last_pos != null) {
|
125
|
+
delta = scroll - last_pos;
|
126
|
+
}
|
127
|
+
last_pos = scroll;
|
128
|
+
if (fixed) {
|
129
|
+
if (enable_bottoming) {
|
130
|
+
will_bottom = scroll + height + offset > parent_height + parent_top;
|
131
|
+
if (bottomed && !will_bottom) {
|
132
|
+
bottomed = false;
|
133
|
+
elm.css({
|
134
|
+
position: "fixed",
|
135
|
+
bottom: "",
|
136
|
+
top: offset
|
137
|
+
}).trigger("sticky_kit:unbottom");
|
138
|
+
}
|
139
|
+
}
|
140
|
+
if (scroll < top) {
|
141
|
+
fixed = false;
|
142
|
+
offset = offset_top;
|
143
|
+
if (manual_spacer == null) {
|
144
|
+
if (el_float === "left" || el_float === "right") {
|
145
|
+
elm.insertAfter(spacer);
|
146
|
+
}
|
147
|
+
spacer.detach();
|
148
|
+
}
|
149
|
+
css = {
|
150
|
+
position: "",
|
151
|
+
width: "",
|
152
|
+
top: ""
|
153
|
+
};
|
154
|
+
elm.css(css).removeClass(sticky_class).trigger("sticky_kit:unstick");
|
155
|
+
}
|
156
|
+
if (inner_scrolling) {
|
157
|
+
win_height = win.height();
|
158
|
+
if (height + offset_top > win_height) {
|
159
|
+
if (!bottomed) {
|
160
|
+
offset -= delta;
|
161
|
+
offset = Math.max(win_height - height, offset);
|
162
|
+
offset = Math.min(offset_top, offset);
|
163
|
+
if (fixed) {
|
164
|
+
elm.css({
|
165
|
+
top: offset + "px"
|
166
|
+
});
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
} else {
|
172
|
+
if (scroll > top) {
|
173
|
+
fixed = true;
|
174
|
+
css = {
|
175
|
+
position: "fixed",
|
176
|
+
top: offset
|
177
|
+
};
|
178
|
+
css.width = elm.css("box-sizing") === "border-box" ? elm.outerWidth() + "px" : elm.width() + "px";
|
179
|
+
elm.css(css).addClass(sticky_class);
|
180
|
+
if (manual_spacer == null) {
|
181
|
+
elm.after(spacer);
|
182
|
+
if (el_float === "left" || el_float === "right") {
|
183
|
+
spacer.append(elm);
|
184
|
+
}
|
185
|
+
}
|
186
|
+
elm.trigger("sticky_kit:stick");
|
187
|
+
}
|
188
|
+
}
|
189
|
+
if (fixed && enable_bottoming) {
|
190
|
+
if (will_bottom == null) {
|
191
|
+
will_bottom = scroll + height + offset > parent_height + parent_top;
|
192
|
+
}
|
193
|
+
if (!bottomed && will_bottom) {
|
194
|
+
bottomed = true;
|
195
|
+
if (parent.css("position") === "static") {
|
196
|
+
parent.css({
|
197
|
+
position: "relative"
|
198
|
+
});
|
199
|
+
}
|
200
|
+
return elm.css({
|
201
|
+
position: "absolute",
|
202
|
+
bottom: padding_bottom,
|
203
|
+
top: "auto"
|
204
|
+
}).trigger("sticky_kit:bottom");
|
205
|
+
}
|
206
|
+
}
|
207
|
+
};
|
208
|
+
recalc_and_tick = function() {
|
209
|
+
recalc();
|
210
|
+
return tick();
|
211
|
+
};
|
212
|
+
detach = function() {
|
213
|
+
detached = true;
|
214
|
+
win.off("touchmove", tick);
|
215
|
+
win.off("scroll", tick);
|
216
|
+
win.off("resize", recalc_and_tick);
|
217
|
+
$(document.body).off("sticky_kit:recalc", recalc_and_tick);
|
218
|
+
elm.off("sticky_kit:detach", detach);
|
219
|
+
elm.removeData("sticky_kit");
|
220
|
+
elm.css({
|
221
|
+
position: "",
|
222
|
+
bottom: "",
|
223
|
+
top: "",
|
224
|
+
width: ""
|
225
|
+
});
|
226
|
+
parent.position("position", "");
|
227
|
+
if (fixed) {
|
228
|
+
if (manual_spacer == null) {
|
229
|
+
if (el_float === "left" || el_float === "right") {
|
230
|
+
elm.insertAfter(spacer);
|
231
|
+
}
|
232
|
+
spacer.remove();
|
233
|
+
}
|
234
|
+
return elm.removeClass(sticky_class);
|
235
|
+
}
|
236
|
+
};
|
237
|
+
win.on("touchmove", tick);
|
238
|
+
win.on("scroll", tick);
|
239
|
+
win.on("resize", recalc_and_tick);
|
240
|
+
$(document.body).on("sticky_kit:recalc", recalc_and_tick);
|
241
|
+
elm.on("sticky_kit:detach", detach);
|
242
|
+
return setTimeout(tick, 0);
|
243
|
+
};
|
244
|
+
for (i = 0, len = this.length; i < len; i++) {
|
245
|
+
elm = this[i];
|
246
|
+
fn($(elm));
|
247
|
+
}
|
248
|
+
return this;
|
249
|
+
};
|
250
|
+
|
251
|
+
}).call(this);
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stickykit-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emile Silvis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Sticky-kit is a jQuery plugin that makes it easy to do sticky sidebars.
|
42
|
+
This gem gives you Sticky-kit for the Rails asset pipeline.
|
43
|
+
email:
|
44
|
+
- emile@silvis.co.za
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/stickykit/rails.rb
|
55
|
+
- lib/stickykit/rails/version.rb
|
56
|
+
- stickykit-rails.gemspec
|
57
|
+
- vendor/assets/javascripts/jquery.sticky-kit.js
|
58
|
+
homepage: https://github.com/emilesilvis/stickykit-rails
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Sticky-kit for the Rails asset pipeline.
|
82
|
+
test_files: []
|