sticky-rails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +61 -0
- data/Rakefile +2 -0
- data/lib/sticky/rails.rb +8 -0
- data/lib/sticky/rails/version.rb +5 -0
- data/sticky-rails.gemspec +24 -0
- data/vendor/assets/javascripts/jquery.sticky.js +170 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3a2dc4af494c453e99705cb824d30a1a29531f38
|
4
|
+
data.tar.gz: 2d521516e53449363f24dca7bb58764715a7a3db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6b097844833ed741f00bd8b8cdfd6b2c8812853bebf826fd6b40a02ac6291de0d93fc14e308a09736e0ef962e4b75ad33c21bcb43120ceb45bbd56ebcf41af78
|
7
|
+
data.tar.gz: e861522294b55b5c3a0a0797acbe6d632f2e924da2304738932c856bcc2db80b803607e622707f3b1e28dc7e6bff2662f5c1909f4ff1efb5c7ac8a98f63215b9
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 navinspm
|
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,61 @@
|
|
1
|
+
Stickyjs Rails Gem - 1.0.0
|
2
|
+
|
3
|
+
jQuery sticky 1.0.0 - http://stickyjs.com/
|
4
|
+
|
5
|
+
sticky-rails Author: Navin Kumar, Copyright 2014 MIT license
|
6
|
+
|
7
|
+
Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
````
|
12
|
+
gem 'sticky-rails'
|
13
|
+
````
|
14
|
+
And then execute:
|
15
|
+
````
|
16
|
+
$ bundle install
|
17
|
+
````
|
18
|
+
Or install it yourself as:
|
19
|
+
````
|
20
|
+
$ gem install sticky-rails
|
21
|
+
````
|
22
|
+
Usage
|
23
|
+
|
24
|
+
Sticky is a jQuery plugin that gives you the ability to make any element on your page always stay visible. , so please check if you are using the jquery on your rails app
|
25
|
+
````
|
26
|
+
//= require jquery
|
27
|
+
````
|
28
|
+
Your app/assets/javascripts/application.js must appear like:
|
29
|
+
````
|
30
|
+
//= require jquery
|
31
|
+
//= require jquery_ujs
|
32
|
+
//= require sticky-rails
|
33
|
+
//= require_tree .
|
34
|
+
````
|
35
|
+
|
36
|
+
Basic Structure example from http://stickyjs.com/
|
37
|
+
````
|
38
|
+
<script>
|
39
|
+
$(document).ready(function(){
|
40
|
+
$("#sticker").sticky({topSpacing:0});
|
41
|
+
});
|
42
|
+
</script>
|
43
|
+
````
|
44
|
+
REMEMBER TO INITIALIZE IT!
|
45
|
+
|
46
|
+
If you are going to use coffee script:
|
47
|
+
````
|
48
|
+
$(document).ready ->
|
49
|
+
$("sticker").sticky()
|
50
|
+
````
|
51
|
+
Or just javascript:
|
52
|
+
````
|
53
|
+
$(document).ready(function(){
|
54
|
+
$("#sticker").sticky({topSpacing:0});
|
55
|
+
});
|
56
|
+
````
|
57
|
+
For more documentation please checkout the sticky-rails 4 repository here: https://github.com/garand/sticky
|
58
|
+
|
59
|
+
Gem Author
|
60
|
+
|
61
|
+
http://twitter.com/navinspm
|
data/Rakefile
ADDED
data/lib/sticky/rails.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sticky/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sticky-rails"
|
8
|
+
spec.version = Sticky::Rails::VERSION
|
9
|
+
spec.authors = ["navinspm"]
|
10
|
+
spec.email = ["navinspm@gmail.com"]
|
11
|
+
spec.summary = "Sticky( http://stickyjs.com ) is a jQuery plugin that gives you the ability to
|
12
|
+
make any element on your page always stay visible .This is gemmified version of sticky "
|
13
|
+
spec.description = ""
|
14
|
+
spec.homepage = "https://github.com/navinspm/sticky-rails"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
// Sticky Plugin v1.0.0 for jQuery
|
2
|
+
// =============
|
3
|
+
// Author: Anthony Garand
|
4
|
+
// Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk)
|
5
|
+
// Improvements by Leonardo C. Daronco (daronco)
|
6
|
+
// Created: 2/14/2011
|
7
|
+
// Date: 2/12/2012
|
8
|
+
// Website: http://labs.anthonygarand.com/sticky
|
9
|
+
// Description: Makes an element on the page stick on the screen as you scroll
|
10
|
+
// It will only set the 'top' and 'position' of your element, you
|
11
|
+
// might need to adjust the width in some cases.
|
12
|
+
|
13
|
+
(function($) {
|
14
|
+
var defaults = {
|
15
|
+
topSpacing: 0,
|
16
|
+
bottomSpacing: 0,
|
17
|
+
className: 'is-sticky',
|
18
|
+
wrapperClassName: 'sticky-wrapper',
|
19
|
+
center: false,
|
20
|
+
getWidthFrom: '',
|
21
|
+
responsiveWidth: false
|
22
|
+
},
|
23
|
+
$window = $(window),
|
24
|
+
$document = $(document),
|
25
|
+
sticked = [],
|
26
|
+
windowHeight = $window.height(),
|
27
|
+
scroller = function() {
|
28
|
+
var scrollTop = $window.scrollTop(),
|
29
|
+
documentHeight = $document.height(),
|
30
|
+
dwh = documentHeight - windowHeight,
|
31
|
+
extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
|
32
|
+
|
33
|
+
for (var i = 0; i < sticked.length; i++) {
|
34
|
+
var s = sticked[i],
|
35
|
+
elementTop = s.stickyWrapper.offset().top,
|
36
|
+
etse = elementTop - s.topSpacing - extra;
|
37
|
+
|
38
|
+
if (scrollTop <= etse) {
|
39
|
+
if (s.currentTop !== null) {
|
40
|
+
s.stickyElement
|
41
|
+
.css('position', '')
|
42
|
+
.css('top', '');
|
43
|
+
s.stickyElement.trigger('sticky-end', [s]).parent().removeClass(s.className);
|
44
|
+
s.currentTop = null;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
var newTop = documentHeight - s.stickyElement.outerHeight()
|
49
|
+
- s.topSpacing - s.bottomSpacing - scrollTop - extra;
|
50
|
+
if (newTop < 0) {
|
51
|
+
newTop = newTop + s.topSpacing;
|
52
|
+
} else {
|
53
|
+
newTop = s.topSpacing;
|
54
|
+
}
|
55
|
+
if (s.currentTop != newTop) {
|
56
|
+
s.stickyElement
|
57
|
+
.css('position', 'fixed')
|
58
|
+
.css('top', newTop);
|
59
|
+
|
60
|
+
if (typeof s.getWidthFrom !== 'undefined') {
|
61
|
+
s.stickyElement.css('width', $(s.getWidthFrom).width());
|
62
|
+
}
|
63
|
+
|
64
|
+
s.stickyElement.trigger('sticky-start', [s]).parent().addClass(s.className);
|
65
|
+
s.currentTop = newTop;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
},
|
70
|
+
resizer = function() {
|
71
|
+
windowHeight = $window.height();
|
72
|
+
|
73
|
+
for (var i = 0; i < sticked.length; i++) {
|
74
|
+
var s = sticked[i];
|
75
|
+
if (typeof s.getWidthFrom !== 'undefined' && s.responsiveWidth === true) {
|
76
|
+
s.stickyElement.css('width', $(s.getWidthFrom).width());
|
77
|
+
}
|
78
|
+
}
|
79
|
+
},
|
80
|
+
methods = {
|
81
|
+
init: function(options) {
|
82
|
+
var o = $.extend({}, defaults, options);
|
83
|
+
return this.each(function() {
|
84
|
+
var stickyElement = $(this);
|
85
|
+
|
86
|
+
var stickyId = stickyElement.attr('id');
|
87
|
+
var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName
|
88
|
+
var wrapper = $('<div></div>')
|
89
|
+
.attr('id', stickyId + '-sticky-wrapper')
|
90
|
+
.addClass(o.wrapperClassName);
|
91
|
+
stickyElement.wrapAll(wrapper);
|
92
|
+
|
93
|
+
if (o.center) {
|
94
|
+
stickyElement.parent().css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"});
|
95
|
+
}
|
96
|
+
|
97
|
+
if (stickyElement.css("float") == "right") {
|
98
|
+
stickyElement.css({"float":"none"}).parent().css({"float":"right"});
|
99
|
+
}
|
100
|
+
|
101
|
+
var stickyWrapper = stickyElement.parent();
|
102
|
+
stickyWrapper.css('height', stickyElement.outerHeight());
|
103
|
+
sticked.push({
|
104
|
+
topSpacing: o.topSpacing,
|
105
|
+
bottomSpacing: o.bottomSpacing,
|
106
|
+
stickyElement: stickyElement,
|
107
|
+
currentTop: null,
|
108
|
+
stickyWrapper: stickyWrapper,
|
109
|
+
className: o.className,
|
110
|
+
getWidthFrom: o.getWidthFrom,
|
111
|
+
responsiveWidth: o.responsiveWidth
|
112
|
+
});
|
113
|
+
});
|
114
|
+
},
|
115
|
+
update: scroller,
|
116
|
+
unstick: function(options) {
|
117
|
+
return this.each(function() {
|
118
|
+
var unstickyElement = $(this);
|
119
|
+
|
120
|
+
var removeIdx = -1;
|
121
|
+
for (var i = 0; i < sticked.length; i++)
|
122
|
+
{
|
123
|
+
if (sticked[i].stickyElement.get(0) == unstickyElement.get(0))
|
124
|
+
{
|
125
|
+
removeIdx = i;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
if(removeIdx != -1)
|
129
|
+
{
|
130
|
+
sticked.splice(removeIdx,1);
|
131
|
+
unstickyElement.unwrap();
|
132
|
+
unstickyElement.removeAttr('style');
|
133
|
+
}
|
134
|
+
});
|
135
|
+
}
|
136
|
+
};
|
137
|
+
|
138
|
+
// should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
|
139
|
+
if (window.addEventListener) {
|
140
|
+
window.addEventListener('scroll', scroller, false);
|
141
|
+
window.addEventListener('resize', resizer, false);
|
142
|
+
} else if (window.attachEvent) {
|
143
|
+
window.attachEvent('onscroll', scroller);
|
144
|
+
window.attachEvent('onresize', resizer);
|
145
|
+
}
|
146
|
+
|
147
|
+
$.fn.sticky = function(method) {
|
148
|
+
if (methods[method]) {
|
149
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
150
|
+
} else if (typeof method === 'object' || !method ) {
|
151
|
+
return methods.init.apply( this, arguments );
|
152
|
+
} else {
|
153
|
+
$.error('Method ' + method + ' does not exist on jQuery.sticky');
|
154
|
+
}
|
155
|
+
};
|
156
|
+
|
157
|
+
$.fn.unstick = function(method) {
|
158
|
+
if (methods[method]) {
|
159
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
160
|
+
} else if (typeof method === 'object' || !method ) {
|
161
|
+
return methods.unstick.apply( this, arguments );
|
162
|
+
} else {
|
163
|
+
$.error('Method ' + method + ' does not exist on jQuery.sticky');
|
164
|
+
}
|
165
|
+
|
166
|
+
};
|
167
|
+
$(function() {
|
168
|
+
setTimeout(scroller, 0);
|
169
|
+
});
|
170
|
+
})(jQuery);
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sticky-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- navinspm
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-25 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: ''
|
42
|
+
email:
|
43
|
+
- navinspm@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/sticky/rails.rb
|
54
|
+
- lib/sticky/rails/version.rb
|
55
|
+
- sticky-rails.gemspec
|
56
|
+
- vendor/assets/javascripts/jquery.sticky.js
|
57
|
+
homepage: https://github.com/navinspm/sticky-rails
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.2.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Sticky( http://stickyjs.com ) is a jQuery plugin that gives you the ability
|
81
|
+
to make any element on your page always stay visible .This is gemmified version
|
82
|
+
of sticky
|
83
|
+
test_files: []
|
84
|
+
has_rdoc:
|