bootstrap-autohidingnavbar-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 +33 -0
- data/Rakefile +2 -0
- data/bootstrap-autohidingnavbar-rails.gemspec +25 -0
- data/lib/bootstrap-autohidingnavbar-rails.rb +9 -0
- data/lib/bootstrap/autohidingnavbar/rails.rb +9 -0
- data/lib/bootstrap/autohidingnavbar/rails/engine.rb +8 -0
- data/lib/bootstrap/autohidingnavbar/rails/version.rb +7 -0
- data/vendor/assets/javascripts/jquery.bootstrap-autohidingnavbar.js +213 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5f86994309542b75f6960576d2ff1949ec95276b
|
4
|
+
data.tar.gz: 4200d378d6558ce68d5bf73f814c8e912826bd30
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac9907b0bcc1c1dedd20a02074404b572572e639fd5006bd2e173c86427387b89a65a247a859d57ecc1bff2fe591e1535901e6805ce6f2e99c00021f3663597c
|
7
|
+
data.tar.gz: 221a8ca5aa7ba07efd50da76110cec9b2b830f47d95e25c75b5c00144f6ded978400fbbab47d43902938d48fbfa1bc7be1aa97314e03aef03857b4de14fb2eba
|
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 Navin Peiris
|
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,33 @@
|
|
1
|
+
# bootstrap-autohidingnavbar for Rails
|
2
|
+
|
3
|
+
[bootstrap-autohidingnavbar](http://www.virtuosoft.eu/code/bootstrap-autohidingnavbar/) is an extension for
|
4
|
+
Bootstrap's fixed navbar which hides the navbar while the page is scrolling downwards and shows it the other way.
|
5
|
+
See the plugin homepage for more details.
|
6
|
+
|
7
|
+
## Plugin versions
|
8
|
+
|
9
|
+
* bootstrap-autohidingnavbar Plugin v1.0.0
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'bootstrap-autohidingnavbar-rails'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Add the following to your `app/assets/javascripts/application.js`:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
//= require jquery.bootstrap-autohidingnavbar
|
25
|
+
```
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/navinpeiris/bootstrap-autohidingnavbar-rails/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bootstrap/autohidingnavbar/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'bootstrap-autohidingnavbar-rails'
|
8
|
+
spec.version = Bootstrap::AutoHidingNavbar::Rails::VERSION
|
9
|
+
spec.authors = ['Navin Peiris']
|
10
|
+
spec.email = ['navin.peiris@gmail.com']
|
11
|
+
spec.summary = %q{bootstrap-autohidingnavbar plugin for the Rails Asset Pipeline}
|
12
|
+
spec.description = %q{bootstrap-autohidingnavbar plugin for the Rails Asset Pipeline }
|
13
|
+
spec.homepage = 'https://github.com/navinpeiris/bootstrap-autohidingnavbar-rails'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'railties', '>= 3.1'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
/*
|
2
|
+
* Bootstrap Auto-Hiding Navbar - v1.0.0
|
3
|
+
* An extension for Bootstrap's fixed navbar which hides the navbar while the page is scrolling downwards and shows it the other way. The plugin is able to show/hide the navbar programmatically as well.
|
4
|
+
* http://www.virtuosoft.eu/code/bootstrap-autohidingnavbar/
|
5
|
+
*
|
6
|
+
* Made by István Ujj-Mészáros
|
7
|
+
* Under Apache License v2.0 License
|
8
|
+
*/
|
9
|
+
;(function($, window, document, undefined) {
|
10
|
+
var pluginName = 'autoHidingNavbar',
|
11
|
+
$window = $(window),
|
12
|
+
$document = $(document),
|
13
|
+
_scrollThrottleTimer = null,
|
14
|
+
_resizeThrottleTimer = null,
|
15
|
+
_throttleDelay = 70,
|
16
|
+
_lastScrollHandlerRun = 0,
|
17
|
+
_previousScrollTop = null,
|
18
|
+
_windowHeight = $window.height(),
|
19
|
+
_visible = true,
|
20
|
+
_hideOffset,
|
21
|
+
defaults = {
|
22
|
+
disableAutohide: false,
|
23
|
+
showOnUpscroll: true,
|
24
|
+
showOnBottom: true,
|
25
|
+
hideOffset: 'auto', // "auto" means the navbar height
|
26
|
+
animationDuration: 200
|
27
|
+
};
|
28
|
+
|
29
|
+
function AutoHidingNavbar(element, options) {
|
30
|
+
this.element = $(element);
|
31
|
+
this.settings = $.extend({}, defaults, options);
|
32
|
+
this._defaults = defaults;
|
33
|
+
this._name = pluginName;
|
34
|
+
this.init();
|
35
|
+
}
|
36
|
+
|
37
|
+
function hide(autoHidingNavbar) {
|
38
|
+
if (!_visible) {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
|
42
|
+
autoHidingNavbar.element.addClass('navbar-hidden').animate({
|
43
|
+
top: -autoHidingNavbar.element.height()
|
44
|
+
}, {
|
45
|
+
queue: false,
|
46
|
+
duration: autoHidingNavbar.settings.animationDuration
|
47
|
+
});
|
48
|
+
|
49
|
+
$('.dropdown.open .dropdown-toggle', autoHidingNavbar.element).dropdown('toggle');
|
50
|
+
|
51
|
+
_visible = false;
|
52
|
+
}
|
53
|
+
|
54
|
+
function show(autoHidingNavbar) {
|
55
|
+
if (_visible) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
|
59
|
+
autoHidingNavbar.element.removeClass('navbar-hidden').animate({
|
60
|
+
top: 0
|
61
|
+
}, {
|
62
|
+
queue: false,
|
63
|
+
duration: autoHidingNavbar.settings.animationDuration
|
64
|
+
});
|
65
|
+
_visible = true;
|
66
|
+
}
|
67
|
+
|
68
|
+
function detectState(autoHidingNavbar) {
|
69
|
+
var scrollTop = $window.scrollTop(),
|
70
|
+
scrollDelta = scrollTop - _previousScrollTop;
|
71
|
+
|
72
|
+
_previousScrollTop = scrollTop;
|
73
|
+
|
74
|
+
if (scrollDelta < 0) {
|
75
|
+
if (_visible) {
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
|
79
|
+
if (autoHidingNavbar.settings.showOnUpscroll || scrollTop <= _hideOffset) {
|
80
|
+
show(autoHidingNavbar);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
else if (scrollDelta > 0) {
|
84
|
+
if (!_visible) {
|
85
|
+
if (autoHidingNavbar.settings.showOnBottom && scrollTop + _windowHeight === $document.height()) {
|
86
|
+
show(autoHidingNavbar);
|
87
|
+
}
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
|
91
|
+
if (scrollTop >= _hideOffset) {
|
92
|
+
hide(autoHidingNavbar);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
}
|
97
|
+
|
98
|
+
function scrollHandler(autoHidingNavbar) {
|
99
|
+
if (autoHidingNavbar.settings.disableAutohide) {
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
|
103
|
+
_lastScrollHandlerRun = new Date().getTime();
|
104
|
+
|
105
|
+
detectState(autoHidingNavbar);
|
106
|
+
}
|
107
|
+
|
108
|
+
function bindEvents(autoHidingNavbar) {
|
109
|
+
$document.on('scroll.' + pluginName, function() {
|
110
|
+
if (new Date().getTime() - _lastScrollHandlerRun > _throttleDelay) {
|
111
|
+
scrollHandler(autoHidingNavbar);
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
clearTimeout(_scrollThrottleTimer);
|
115
|
+
_scrollThrottleTimer = setTimeout(function() {
|
116
|
+
scrollHandler(autoHidingNavbar);
|
117
|
+
}, _throttleDelay);
|
118
|
+
}
|
119
|
+
});
|
120
|
+
|
121
|
+
$window.on('resize.' + pluginName, function() {
|
122
|
+
clearTimeout(_resizeThrottleTimer);
|
123
|
+
_resizeThrottleTimer = setTimeout(function() {
|
124
|
+
_windowHeight = $window.height();
|
125
|
+
}, _throttleDelay);
|
126
|
+
});
|
127
|
+
}
|
128
|
+
|
129
|
+
function unbindEvents() {
|
130
|
+
$document.off('.' + pluginName);
|
131
|
+
|
132
|
+
$window.off('.' + pluginName);
|
133
|
+
}
|
134
|
+
|
135
|
+
AutoHidingNavbar.prototype = {
|
136
|
+
init: function() {
|
137
|
+
this.elements = {
|
138
|
+
navbar: this.element
|
139
|
+
};
|
140
|
+
|
141
|
+
this.setDisableAutohide(this.settings.disableAutohide);
|
142
|
+
this.setShowOnUpscroll(this.settings.showOnUpscroll);
|
143
|
+
this.setShowOnBottom(this.settings.showOnBottom);
|
144
|
+
this.setHideOffset(this.settings.hideOffset);
|
145
|
+
this.setAnimationDuration(this.settings.animationDuration);
|
146
|
+
|
147
|
+
_hideOffset = this.settings.hideOffset === 'auto' ? this.element.height() : this.settings.hideOffset;
|
148
|
+
bindEvents(this);
|
149
|
+
|
150
|
+
return this.element;
|
151
|
+
},
|
152
|
+
setDisableAutohide: function(value) {
|
153
|
+
this.settings.disableAutohide = value;
|
154
|
+
return this.element;
|
155
|
+
},
|
156
|
+
setShowOnUpscroll: function(value) {
|
157
|
+
this.settings.showOnUpscroll = value;
|
158
|
+
return this.element;
|
159
|
+
},
|
160
|
+
setShowOnBottom: function(value) {
|
161
|
+
this.settings.showOnBottom = value;
|
162
|
+
return this.element;
|
163
|
+
},
|
164
|
+
setHideOffset: function(value) {
|
165
|
+
this.settings.hideOffset = value;
|
166
|
+
return this.element;
|
167
|
+
},
|
168
|
+
setAnimationDuration: function(value) {
|
169
|
+
this.settings.animationDuration = value;
|
170
|
+
return this.element;
|
171
|
+
},
|
172
|
+
show: function() {
|
173
|
+
show(this);
|
174
|
+
return this.element;
|
175
|
+
},
|
176
|
+
hide: function() {
|
177
|
+
hide(this);
|
178
|
+
return this.element;
|
179
|
+
},
|
180
|
+
destroy: function() {
|
181
|
+
unbindEvents(this);
|
182
|
+
show(this);
|
183
|
+
$.data(this, 'plugin_' + pluginName, null);
|
184
|
+
return this.element;
|
185
|
+
}
|
186
|
+
};
|
187
|
+
|
188
|
+
$.fn[pluginName] = function(options) {
|
189
|
+
var args = arguments;
|
190
|
+
|
191
|
+
if (options === undefined || typeof options === 'object') {
|
192
|
+
return this.each(function() {
|
193
|
+
if (!$.data(this, 'plugin_' + pluginName)) {
|
194
|
+
$.data(this, 'plugin_' + pluginName, new AutoHidingNavbar(this, options));
|
195
|
+
}
|
196
|
+
});
|
197
|
+
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
|
198
|
+
var returns;
|
199
|
+
|
200
|
+
this.each(function() {
|
201
|
+
var instance = $.data(this, 'plugin_' + pluginName);
|
202
|
+
|
203
|
+
if (instance instanceof AutoHidingNavbar && typeof instance[options] === 'function') {
|
204
|
+
returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
|
205
|
+
}
|
206
|
+
});
|
207
|
+
|
208
|
+
return returns !== undefined ? returns : this;
|
209
|
+
}
|
210
|
+
|
211
|
+
};
|
212
|
+
|
213
|
+
})(jQuery, window, document);
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bootstrap-autohidingnavbar-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Navin Peiris
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: 'bootstrap-autohidingnavbar plugin for the Rails Asset Pipeline '
|
56
|
+
email:
|
57
|
+
- navin.peiris@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bootstrap-autohidingnavbar-rails.gemspec
|
68
|
+
- lib/bootstrap-autohidingnavbar-rails.rb
|
69
|
+
- lib/bootstrap/autohidingnavbar/rails.rb
|
70
|
+
- lib/bootstrap/autohidingnavbar/rails/engine.rb
|
71
|
+
- lib/bootstrap/autohidingnavbar/rails/version.rb
|
72
|
+
- vendor/assets/javascripts/jquery.bootstrap-autohidingnavbar.js
|
73
|
+
homepage: https://github.com/navinpeiris/bootstrap-autohidingnavbar-rails
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.2
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: bootstrap-autohidingnavbar plugin for the Rails Asset Pipeline
|
97
|
+
test_files: []
|