nodebb-theme-persona 14.0.13 → 14.0.14
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.
- package/.eslintrc +2 -2
- package/README.md +20 -20
- package/lib/controllers.js +24 -24
- package/package.json +1 -1
- package/plugin.json +20 -20
- package/public/.eslintrc +2 -2
- package/public/admin.js +15 -15
- package/public/modules/autohidingnavbar.js +220 -220
- package/public/modules/taskbar.js +65 -65
- package/public/settings.js +53 -53
- package/scss/footer.scss +16 -16
- package/scss/keyframes.scss +152 -152
- package/scss/modules/composer.scss +20 -20
- package/scss/modules/cookie-consent.scss +12 -12
- package/scss/modules/fab.scss +32 -32
- package/scss/modules/morph.scss +268 -268
- package/scss/modules/necro-post.scss +8 -8
- package/scss/modules/nprogress.scss +80 -80
- package/scss/modules/taskbar.scss +160 -160
- package/scss/modules/user-menu.scss +7 -7
- package/scss/modules/usercard.scss +64 -64
- package/scss/noscript.scss +80 -80
- package/scss/overrides.scss +39 -39
- package/scss/posts_list.scss +127 -127
- package/scss/tags.scss +10 -10
- package/scss/topics_list.scss +16 -16
- package/scss/variables.scss +6 -6
- package/templates/account/info.tpl +291 -291
- package/templates/account/sessions.tpl +31 -31
- package/templates/account/theme.tpl +25 -25
- package/templates/admin/plugins/persona.tpl +24 -24
- package/templates/footer.tpl +11 -11
- package/templates/groups/members.tpl +5 -5
- package/templates/modules/taskbar.tpl +2 -2
- package/templates/modules/usercard.tpl +36 -36
- package/templates/partials/breadcrumbs.tpl +18 -18
- package/templates/partials/categories/link.tpl +10 -10
- package/templates/partials/category/tags.tpl +3 -3
- package/templates/partials/cookie-consent.tpl +4 -4
- package/templates/partials/groups/memberlist.tpl +42 -42
- package/templates/partials/header/search.tpl +24 -24
- package/templates/partials/paginator.tpl +44 -44
- package/templates/partials/posts_list.tpl +7 -7
- package/templates/partials/toast.tpl +19 -19
- package/templates/partials/topic/event.tpl +12 -12
- package/templates/partials/topic/navigation-post.tpl +11 -11
- package/templates/partials/topic/necro-post.tpl +2 -2
- package/templates/partials/topic/post.tpl +3 -3
- package/templates/partials/topic/reply-button.tpl +26 -26
- package/templates/partials/topic/selection-tooltip.tpl +2 -2
- package/templates/partials/users_list.tpl +14 -14
- package/templates/search.tpl +47 -47
package/.eslintrc
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "nodebb/lib"
|
|
1
|
+
{
|
|
2
|
+
"extends": "nodebb/lib"
|
|
3
3
|
}
|
package/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
Persona theme for NodeBB
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
The Persona theme is the default theme for NodeBB for versions spanning v0.7.1 through to v2.x
|
|
5
|
-
|
|
6
|
-
For the v3.x release line, Persona will be a supported theme bundled with NodeBB, but will not be active by default.
|
|
7
|
-
|
|
8
|
-
## Issues
|
|
9
|
-
|
|
10
|
-
Issues are now tracked in [the main project issue tracker](https://github.com/NodeBB/NodeBB/issues?q=is%3Aopen+is%3Aissue+label%3Athemes).
|
|
11
|
-
|
|
12
|
-
## Addons
|
|
13
|
-
|
|
14
|
-
[Recent Cards](https://github.com/psychobunny/nodebb-plugin-recent-cards)
|
|
15
|
-
|
|
16
|
-
## Screenshots
|
|
17
|
-
|
|
18
|
-

|
|
19
|
-
|
|
20
|
-

|
|
1
|
+
Persona theme for NodeBB
|
|
2
|
+
====================
|
|
3
|
+
|
|
4
|
+
The Persona theme is the default theme for NodeBB for versions spanning v0.7.1 through to v2.x
|
|
5
|
+
|
|
6
|
+
For the v3.x release line, Persona will be a supported theme bundled with NodeBB, but will not be active by default.
|
|
7
|
+
|
|
8
|
+
## Issues
|
|
9
|
+
|
|
10
|
+
Issues are now tracked in [the main project issue tracker](https://github.com/NodeBB/NodeBB/issues?q=is%3Aopen+is%3Aissue+label%3Athemes).
|
|
11
|
+
|
|
12
|
+
## Addons
|
|
13
|
+
|
|
14
|
+
[Recent Cards](https://github.com/psychobunny/nodebb-plugin-recent-cards)
|
|
15
|
+
|
|
16
|
+
## Screenshots
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+

|
package/lib/controllers.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const accountHelpers = require.main.require('./src/controllers/accounts/helpers');
|
|
4
|
-
const helpers = require.main.require('./src/controllers/helpers');
|
|
5
|
-
|
|
6
|
-
const Controllers = module.exports;
|
|
7
|
-
|
|
8
|
-
Controllers.renderAdminPage = (req, res) => {
|
|
9
|
-
res.render('admin/plugins/persona', {
|
|
10
|
-
title: 'Persona Theme',
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
Controllers.renderThemeSettings = async (req, res, next) => {
|
|
15
|
-
const userData = await accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, req.query);
|
|
16
|
-
if (!userData) {
|
|
17
|
-
return next();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
userData.title = '[[themes/persona:settings.title]]';
|
|
21
|
-
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: `/user/${userData.userslug}` }, { text: '[[themes/persona:settings.title]]' }]);
|
|
22
|
-
|
|
23
|
-
res.render('account/theme', userData);
|
|
24
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const accountHelpers = require.main.require('./src/controllers/accounts/helpers');
|
|
4
|
+
const helpers = require.main.require('./src/controllers/helpers');
|
|
5
|
+
|
|
6
|
+
const Controllers = module.exports;
|
|
7
|
+
|
|
8
|
+
Controllers.renderAdminPage = (req, res) => {
|
|
9
|
+
res.render('admin/plugins/persona', {
|
|
10
|
+
title: 'Persona Theme',
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Controllers.renderThemeSettings = async (req, res, next) => {
|
|
15
|
+
const userData = await accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, req.query);
|
|
16
|
+
if (!userData) {
|
|
17
|
+
return next();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
userData.title = '[[themes/persona:settings.title]]';
|
|
21
|
+
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: `/user/${userData.userslug}` }, { text: '[[themes/persona:settings.title]]' }]);
|
|
22
|
+
|
|
23
|
+
res.render('account/theme', userData);
|
|
24
|
+
};
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "nodebb-theme-persona",
|
|
3
|
-
"hooks": [
|
|
4
|
-
{ "hook": "filter:widgets.getAreas", "method": "defineWidgetAreas" },
|
|
5
|
-
{ "hook": "filter:config.get", "method": "getThemeConfig" },
|
|
6
|
-
{ "hook": "static:app.load", "method": "init" },
|
|
7
|
-
{ "hook": "filter:admin.header.build", "method": "addAdminNavigation" },
|
|
8
|
-
{ "hook": "filter:user.profileMenu", "method": "addProfileItem" }
|
|
9
|
-
],
|
|
10
|
-
"scripts": [
|
|
11
|
-
"public/modules/autohidingnavbar.js",
|
|
12
|
-
"public/persona.js"
|
|
13
|
-
],
|
|
14
|
-
"modules": {
|
|
15
|
-
"../admin/plugins/persona.js": "public/admin.js",
|
|
16
|
-
"persona/taskbar.js": "public/modules/taskbar.js",
|
|
17
|
-
"persona/mobile-menu.js": "public/modules/mobile-menu.js",
|
|
18
|
-
"../client/account/theme.js": "public/settings.js"
|
|
19
|
-
},
|
|
20
|
-
"languages": "languages"
|
|
1
|
+
{
|
|
2
|
+
"id": "nodebb-theme-persona",
|
|
3
|
+
"hooks": [
|
|
4
|
+
{ "hook": "filter:widgets.getAreas", "method": "defineWidgetAreas" },
|
|
5
|
+
{ "hook": "filter:config.get", "method": "getThemeConfig" },
|
|
6
|
+
{ "hook": "static:app.load", "method": "init" },
|
|
7
|
+
{ "hook": "filter:admin.header.build", "method": "addAdminNavigation" },
|
|
8
|
+
{ "hook": "filter:user.profileMenu", "method": "addProfileItem" }
|
|
9
|
+
],
|
|
10
|
+
"scripts": [
|
|
11
|
+
"public/modules/autohidingnavbar.js",
|
|
12
|
+
"public/persona.js"
|
|
13
|
+
],
|
|
14
|
+
"modules": {
|
|
15
|
+
"../admin/plugins/persona.js": "public/admin.js",
|
|
16
|
+
"persona/taskbar.js": "public/modules/taskbar.js",
|
|
17
|
+
"persona/mobile-menu.js": "public/modules/mobile-menu.js",
|
|
18
|
+
"../client/account/theme.js": "public/settings.js"
|
|
19
|
+
},
|
|
20
|
+
"languages": "languages"
|
|
21
21
|
}
|
package/public/.eslintrc
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "nodebb/public"
|
|
1
|
+
{
|
|
2
|
+
"extends": "nodebb/public"
|
|
3
3
|
}
|
package/public/admin.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
define('admin/plugins/persona', ['settings'], function (Settings) {
|
|
4
|
-
var ACP = {};
|
|
5
|
-
|
|
6
|
-
ACP.init = function () {
|
|
7
|
-
Settings.load('persona', $('.persona-settings'));
|
|
8
|
-
|
|
9
|
-
$('#save').on('click', function () {
|
|
10
|
-
Settings.save('persona', $('.persona-settings'));
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
return ACP;
|
|
15
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
define('admin/plugins/persona', ['settings'], function (Settings) {
|
|
4
|
+
var ACP = {};
|
|
5
|
+
|
|
6
|
+
ACP.init = function () {
|
|
7
|
+
Settings.load('persona', $('.persona-settings'));
|
|
8
|
+
|
|
9
|
+
$('#save').on('click', function () {
|
|
10
|
+
Settings.save('persona', $('.persona-settings'));
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return ACP;
|
|
15
|
+
});
|
|
@@ -1,221 +1,221 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Bootstrap Auto-Hiding Navbar - v4.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
|
-
navbarOffset: 0
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function AutoHidingNavbar(element, options) {
|
|
31
|
-
this.element = $(element);
|
|
32
|
-
this.settings = $.extend({}, defaults, options);
|
|
33
|
-
this._defaults = defaults;
|
|
34
|
-
this._name = pluginName;
|
|
35
|
-
this.init();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function hide(autoHidingNavbar) {
|
|
39
|
-
if (!_visible) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
autoHidingNavbar.element.addClass('navbar-hidden').animate({
|
|
44
|
-
top: -1 * parseInt(autoHidingNavbar.element.css('height'), 10) + autoHidingNavbar.settings.navbarOffset
|
|
45
|
-
}, {
|
|
46
|
-
queue: false,
|
|
47
|
-
duration: autoHidingNavbar.settings.animationDuration
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
$('.dropdown.open .dropdown-toggle, .dropdown.show .dropdown-toggle', autoHidingNavbar.element).dropdown('toggle');
|
|
52
|
-
}
|
|
53
|
-
catch(e) {}
|
|
54
|
-
|
|
55
|
-
_visible = false;
|
|
56
|
-
|
|
57
|
-
autoHidingNavbar.element.trigger('hide.autoHidingNavbar');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function show(autoHidingNavbar) {
|
|
61
|
-
if (_visible) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
autoHidingNavbar.element.removeClass('navbar-hidden').animate({
|
|
66
|
-
top: 0
|
|
67
|
-
}, {
|
|
68
|
-
queue: false,
|
|
69
|
-
duration: autoHidingNavbar.settings.animationDuration
|
|
70
|
-
});
|
|
71
|
-
_visible = true;
|
|
72
|
-
|
|
73
|
-
autoHidingNavbar.element.trigger('show.autoHidingNavbar');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function detectState(autoHidingNavbar) {
|
|
77
|
-
var scrollTop = $window.scrollTop(),
|
|
78
|
-
scrollDelta = scrollTop - _previousScrollTop;
|
|
79
|
-
|
|
80
|
-
_previousScrollTop = scrollTop;
|
|
81
|
-
|
|
82
|
-
if (scrollDelta < 0) {
|
|
83
|
-
if (_visible) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (autoHidingNavbar.settings.showOnUpscroll || scrollTop <= _hideOffset) {
|
|
88
|
-
show(autoHidingNavbar);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else if (scrollDelta > 0) {
|
|
92
|
-
if (!_visible) {
|
|
93
|
-
if (autoHidingNavbar.settings.showOnBottom && scrollTop + _windowHeight === $document.height()) {
|
|
94
|
-
show(autoHidingNavbar);
|
|
95
|
-
}
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (scrollTop >= _hideOffset) {
|
|
100
|
-
hide(autoHidingNavbar);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function scrollHandler(autoHidingNavbar) {
|
|
107
|
-
if (autoHidingNavbar.settings.disableAutohide) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
_lastScrollHandlerRun = new Date().getTime();
|
|
112
|
-
|
|
113
|
-
detectState(autoHidingNavbar);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function bindEvents(autoHidingNavbar) {
|
|
117
|
-
$document.on('scroll.' + pluginName, function() {
|
|
118
|
-
if (new Date().getTime() - _lastScrollHandlerRun > _throttleDelay) {
|
|
119
|
-
scrollHandler(autoHidingNavbar);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
clearTimeout(_scrollThrottleTimer);
|
|
123
|
-
_scrollThrottleTimer = setTimeout(function() {
|
|
124
|
-
scrollHandler(autoHidingNavbar);
|
|
125
|
-
}, _throttleDelay);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
$window.on('resize.' + pluginName, function() {
|
|
130
|
-
clearTimeout(_resizeThrottleTimer);
|
|
131
|
-
_resizeThrottleTimer = setTimeout(function() {
|
|
132
|
-
_windowHeight = $window.height();
|
|
133
|
-
}, _throttleDelay);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function unbindEvents() {
|
|
138
|
-
$document.off('.' + pluginName);
|
|
139
|
-
|
|
140
|
-
$window.off('.' + pluginName);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
AutoHidingNavbar.prototype = {
|
|
144
|
-
init: function() {
|
|
145
|
-
this.elements = {
|
|
146
|
-
navbar: this.element
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
this.setDisableAutohide(this.settings.disableAutohide);
|
|
150
|
-
this.setShowOnUpscroll(this.settings.showOnUpscroll);
|
|
151
|
-
this.setShowOnBottom(this.settings.showOnBottom);
|
|
152
|
-
this.setHideOffset(this.settings.hideOffset);
|
|
153
|
-
this.setAnimationDuration(this.settings.animationDuration);
|
|
154
|
-
|
|
155
|
-
_hideOffset = this.settings.hideOffset === 'auto' ? parseInt(this.element.css('height'), 10) : this.settings.hideOffset;
|
|
156
|
-
bindEvents(this);
|
|
157
|
-
|
|
158
|
-
return this.element;
|
|
159
|
-
},
|
|
160
|
-
setDisableAutohide: function(value) {
|
|
161
|
-
this.settings.disableAutohide = value;
|
|
162
|
-
return this.element;
|
|
163
|
-
},
|
|
164
|
-
setShowOnUpscroll: function(value) {
|
|
165
|
-
this.settings.showOnUpscroll = value;
|
|
166
|
-
return this.element;
|
|
167
|
-
},
|
|
168
|
-
setShowOnBottom: function(value) {
|
|
169
|
-
this.settings.showOnBottom = value;
|
|
170
|
-
return this.element;
|
|
171
|
-
},
|
|
172
|
-
setHideOffset: function(value) {
|
|
173
|
-
this.settings.hideOffset = value;
|
|
174
|
-
return this.element;
|
|
175
|
-
},
|
|
176
|
-
setAnimationDuration: function(value) {
|
|
177
|
-
this.settings.animationDuration = value;
|
|
178
|
-
return this.element;
|
|
179
|
-
},
|
|
180
|
-
show: function() {
|
|
181
|
-
show(this);
|
|
182
|
-
return this.element;
|
|
183
|
-
},
|
|
184
|
-
hide: function() {
|
|
185
|
-
hide(this);
|
|
186
|
-
return this.element;
|
|
187
|
-
},
|
|
188
|
-
destroy: function() {
|
|
189
|
-
unbindEvents(this);
|
|
190
|
-
show(this);
|
|
191
|
-
$.data(this, 'plugin_' + pluginName, null);
|
|
192
|
-
return this.element;
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
$.fn[pluginName] = function(options) {
|
|
197
|
-
var args = arguments;
|
|
198
|
-
|
|
199
|
-
if (options === undefined || typeof options === 'object') {
|
|
200
|
-
return this.each(function() {
|
|
201
|
-
if (!$.data(this, 'plugin_' + pluginName)) {
|
|
202
|
-
$.data(this, 'plugin_' + pluginName, new AutoHidingNavbar(this, options));
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
|
|
206
|
-
var returns;
|
|
207
|
-
|
|
208
|
-
this.each(function() {
|
|
209
|
-
var instance = $.data(this, 'plugin_' + pluginName);
|
|
210
|
-
|
|
211
|
-
if (instance instanceof AutoHidingNavbar && typeof instance[options] === 'function') {
|
|
212
|
-
returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
return returns !== undefined ? returns : this;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
};
|
|
220
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Bootstrap Auto-Hiding Navbar - v4.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
|
+
navbarOffset: 0
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function AutoHidingNavbar(element, options) {
|
|
31
|
+
this.element = $(element);
|
|
32
|
+
this.settings = $.extend({}, defaults, options);
|
|
33
|
+
this._defaults = defaults;
|
|
34
|
+
this._name = pluginName;
|
|
35
|
+
this.init();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function hide(autoHidingNavbar) {
|
|
39
|
+
if (!_visible) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
autoHidingNavbar.element.addClass('navbar-hidden').animate({
|
|
44
|
+
top: -1 * parseInt(autoHidingNavbar.element.css('height'), 10) + autoHidingNavbar.settings.navbarOffset
|
|
45
|
+
}, {
|
|
46
|
+
queue: false,
|
|
47
|
+
duration: autoHidingNavbar.settings.animationDuration
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
$('.dropdown.open .dropdown-toggle, .dropdown.show .dropdown-toggle', autoHidingNavbar.element).dropdown('toggle');
|
|
52
|
+
}
|
|
53
|
+
catch(e) {}
|
|
54
|
+
|
|
55
|
+
_visible = false;
|
|
56
|
+
|
|
57
|
+
autoHidingNavbar.element.trigger('hide.autoHidingNavbar');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function show(autoHidingNavbar) {
|
|
61
|
+
if (_visible) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
autoHidingNavbar.element.removeClass('navbar-hidden').animate({
|
|
66
|
+
top: 0
|
|
67
|
+
}, {
|
|
68
|
+
queue: false,
|
|
69
|
+
duration: autoHidingNavbar.settings.animationDuration
|
|
70
|
+
});
|
|
71
|
+
_visible = true;
|
|
72
|
+
|
|
73
|
+
autoHidingNavbar.element.trigger('show.autoHidingNavbar');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function detectState(autoHidingNavbar) {
|
|
77
|
+
var scrollTop = $window.scrollTop(),
|
|
78
|
+
scrollDelta = scrollTop - _previousScrollTop;
|
|
79
|
+
|
|
80
|
+
_previousScrollTop = scrollTop;
|
|
81
|
+
|
|
82
|
+
if (scrollDelta < 0) {
|
|
83
|
+
if (_visible) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (autoHidingNavbar.settings.showOnUpscroll || scrollTop <= _hideOffset) {
|
|
88
|
+
show(autoHidingNavbar);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (scrollDelta > 0) {
|
|
92
|
+
if (!_visible) {
|
|
93
|
+
if (autoHidingNavbar.settings.showOnBottom && scrollTop + _windowHeight === $document.height()) {
|
|
94
|
+
show(autoHidingNavbar);
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (scrollTop >= _hideOffset) {
|
|
100
|
+
hide(autoHidingNavbar);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function scrollHandler(autoHidingNavbar) {
|
|
107
|
+
if (autoHidingNavbar.settings.disableAutohide) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
_lastScrollHandlerRun = new Date().getTime();
|
|
112
|
+
|
|
113
|
+
detectState(autoHidingNavbar);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function bindEvents(autoHidingNavbar) {
|
|
117
|
+
$document.on('scroll.' + pluginName, function() {
|
|
118
|
+
if (new Date().getTime() - _lastScrollHandlerRun > _throttleDelay) {
|
|
119
|
+
scrollHandler(autoHidingNavbar);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
clearTimeout(_scrollThrottleTimer);
|
|
123
|
+
_scrollThrottleTimer = setTimeout(function() {
|
|
124
|
+
scrollHandler(autoHidingNavbar);
|
|
125
|
+
}, _throttleDelay);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
$window.on('resize.' + pluginName, function() {
|
|
130
|
+
clearTimeout(_resizeThrottleTimer);
|
|
131
|
+
_resizeThrottleTimer = setTimeout(function() {
|
|
132
|
+
_windowHeight = $window.height();
|
|
133
|
+
}, _throttleDelay);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function unbindEvents() {
|
|
138
|
+
$document.off('.' + pluginName);
|
|
139
|
+
|
|
140
|
+
$window.off('.' + pluginName);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
AutoHidingNavbar.prototype = {
|
|
144
|
+
init: function() {
|
|
145
|
+
this.elements = {
|
|
146
|
+
navbar: this.element
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
this.setDisableAutohide(this.settings.disableAutohide);
|
|
150
|
+
this.setShowOnUpscroll(this.settings.showOnUpscroll);
|
|
151
|
+
this.setShowOnBottom(this.settings.showOnBottom);
|
|
152
|
+
this.setHideOffset(this.settings.hideOffset);
|
|
153
|
+
this.setAnimationDuration(this.settings.animationDuration);
|
|
154
|
+
|
|
155
|
+
_hideOffset = this.settings.hideOffset === 'auto' ? parseInt(this.element.css('height'), 10) : this.settings.hideOffset;
|
|
156
|
+
bindEvents(this);
|
|
157
|
+
|
|
158
|
+
return this.element;
|
|
159
|
+
},
|
|
160
|
+
setDisableAutohide: function(value) {
|
|
161
|
+
this.settings.disableAutohide = value;
|
|
162
|
+
return this.element;
|
|
163
|
+
},
|
|
164
|
+
setShowOnUpscroll: function(value) {
|
|
165
|
+
this.settings.showOnUpscroll = value;
|
|
166
|
+
return this.element;
|
|
167
|
+
},
|
|
168
|
+
setShowOnBottom: function(value) {
|
|
169
|
+
this.settings.showOnBottom = value;
|
|
170
|
+
return this.element;
|
|
171
|
+
},
|
|
172
|
+
setHideOffset: function(value) {
|
|
173
|
+
this.settings.hideOffset = value;
|
|
174
|
+
return this.element;
|
|
175
|
+
},
|
|
176
|
+
setAnimationDuration: function(value) {
|
|
177
|
+
this.settings.animationDuration = value;
|
|
178
|
+
return this.element;
|
|
179
|
+
},
|
|
180
|
+
show: function() {
|
|
181
|
+
show(this);
|
|
182
|
+
return this.element;
|
|
183
|
+
},
|
|
184
|
+
hide: function() {
|
|
185
|
+
hide(this);
|
|
186
|
+
return this.element;
|
|
187
|
+
},
|
|
188
|
+
destroy: function() {
|
|
189
|
+
unbindEvents(this);
|
|
190
|
+
show(this);
|
|
191
|
+
$.data(this, 'plugin_' + pluginName, null);
|
|
192
|
+
return this.element;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
$.fn[pluginName] = function(options) {
|
|
197
|
+
var args = arguments;
|
|
198
|
+
|
|
199
|
+
if (options === undefined || typeof options === 'object') {
|
|
200
|
+
return this.each(function() {
|
|
201
|
+
if (!$.data(this, 'plugin_' + pluginName)) {
|
|
202
|
+
$.data(this, 'plugin_' + pluginName, new AutoHidingNavbar(this, options));
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
|
|
206
|
+
var returns;
|
|
207
|
+
|
|
208
|
+
this.each(function() {
|
|
209
|
+
var instance = $.data(this, 'plugin_' + pluginName);
|
|
210
|
+
|
|
211
|
+
if (instance instanceof AutoHidingNavbar && typeof instance[options] === 'function') {
|
|
212
|
+
returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
return returns !== undefined ? returns : this;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
};
|
|
220
|
+
|
|
221
221
|
})(jQuery, window, document);
|