nodebb-theme-persona 11.3.40 → 11.4.0

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.
Files changed (212) hide show
  1. package/.eslintrc +2 -2
  2. package/README.md +14 -14
  3. package/languages/de/persona.json +3 -3
  4. package/languages/en-GB/persona.json +9 -2
  5. package/languages/en-US/persona.json +2 -2
  6. package/languages/fr/persona.json +3 -3
  7. package/languages/pl/persona.json +3 -3
  8. package/languages/pt-PT/persona.json +2 -2
  9. package/languages/tr/persona.json +4 -4
  10. package/languages/zh-CN/persona.json +4 -4
  11. package/less/bootstrap/.csscomb.json +297 -297
  12. package/less/bootstrap/.csslintrc +19 -19
  13. package/less/bootstrap/alerts.less +73 -73
  14. package/less/bootstrap/badges.less +66 -66
  15. package/less/bootstrap/bootstrap.less +50 -50
  16. package/less/bootstrap/breadcrumbs.less +26 -26
  17. package/less/bootstrap/button-groups.less +243 -243
  18. package/less/bootstrap/buttons.less +160 -160
  19. package/less/bootstrap/carousel.less +269 -269
  20. package/less/bootstrap/close.less +34 -34
  21. package/less/bootstrap/code.less +69 -69
  22. package/less/bootstrap/component-animations.less +33 -33
  23. package/less/bootstrap/forms.less +574 -574
  24. package/less/bootstrap/glyphicons.less +305 -305
  25. package/less/bootstrap/grid.less +84 -84
  26. package/less/bootstrap/input-groups.less +166 -166
  27. package/less/bootstrap/jumbotron.less +50 -50
  28. package/less/bootstrap/labels.less +64 -64
  29. package/less/bootstrap/list-group.less +124 -124
  30. package/less/bootstrap/media.less +61 -61
  31. package/less/bootstrap/mixins/alerts.less +14 -14
  32. package/less/bootstrap/mixins/background-variant.less +8 -8
  33. package/less/bootstrap/mixins/border-radius.less +18 -18
  34. package/less/bootstrap/mixins/buttons.less +52 -52
  35. package/less/bootstrap/mixins/center-block.less +7 -7
  36. package/less/bootstrap/mixins/clearfix.less +22 -22
  37. package/less/bootstrap/mixins/forms.less +85 -85
  38. package/less/bootstrap/mixins/gradients.less +59 -59
  39. package/less/bootstrap/mixins/grid-framework.less +91 -91
  40. package/less/bootstrap/mixins/grid.less +122 -122
  41. package/less/bootstrap/mixins/hide-text.less +21 -21
  42. package/less/bootstrap/mixins/image.less +33 -33
  43. package/less/bootstrap/mixins/labels.less +12 -12
  44. package/less/bootstrap/mixins/list-group.less +29 -29
  45. package/less/bootstrap/mixins/nav-divider.less +10 -10
  46. package/less/bootstrap/mixins/nav-vertical-align.less +9 -9
  47. package/less/bootstrap/mixins/opacity.less +8 -8
  48. package/less/bootstrap/mixins/pagination.less +23 -23
  49. package/less/bootstrap/mixins/panels.less +24 -24
  50. package/less/bootstrap/mixins/progress-bar.less +10 -10
  51. package/less/bootstrap/mixins/reset-filter.less +8 -8
  52. package/less/bootstrap/mixins/resize.less +6 -6
  53. package/less/bootstrap/mixins/responsive-visibility.less +15 -15
  54. package/less/bootstrap/mixins/size.less +10 -10
  55. package/less/bootstrap/mixins/tab-focus.less +9 -9
  56. package/less/bootstrap/mixins/table-row.less +28 -28
  57. package/less/bootstrap/mixins/text-emphasis.less +8 -8
  58. package/less/bootstrap/mixins/text-overflow.less +8 -8
  59. package/less/bootstrap/mixins/vendor-prefixes.less +227 -227
  60. package/less/bootstrap/mixins.less +39 -39
  61. package/less/bootstrap/modals.less +150 -150
  62. package/less/bootstrap/navbar.less +660 -660
  63. package/less/bootstrap/navs.less +242 -242
  64. package/less/bootstrap/normalize.less +427 -427
  65. package/less/bootstrap/pager.less +54 -54
  66. package/less/bootstrap/pagination.less +88 -88
  67. package/less/bootstrap/panels.less +265 -265
  68. package/less/bootstrap/popovers.less +135 -135
  69. package/less/bootstrap/print.less +107 -107
  70. package/less/bootstrap/progress-bars.less +87 -87
  71. package/less/bootstrap/responsive-embed.less +35 -35
  72. package/less/bootstrap/responsive-utilities.less +194 -194
  73. package/less/bootstrap/scaffolding.less +161 -161
  74. package/less/bootstrap/tables.less +234 -234
  75. package/less/bootstrap/theme.less +273 -273
  76. package/less/bootstrap/thumbnails.less +36 -36
  77. package/less/bootstrap/tooltip.less +102 -102
  78. package/less/bootstrap/type.less +302 -302
  79. package/less/bootstrap/utilities.less +55 -55
  80. package/less/bootstrap/variables.less +861 -861
  81. package/less/bootstrap/wells.less +29 -29
  82. package/less/bootstrap-flipped.css +1550 -1550
  83. package/less/categories.less +235 -235
  84. package/less/flags.less +42 -42
  85. package/less/footer.less +17 -17
  86. package/less/ip-blacklist.less +6 -6
  87. package/less/keyframes.less +152 -152
  88. package/less/modules/composer-default.less +16 -16
  89. package/less/modules/cookie-consent.less +12 -12
  90. package/less/modules/fab.less +32 -32
  91. package/less/modules/morph.less +268 -268
  92. package/less/modules/necro-post.less +8 -8
  93. package/less/modules/nprogress.less +80 -80
  94. package/less/modules/usercard.less +64 -64
  95. package/less/noscript.less +82 -82
  96. package/less/notifications.less +37 -37
  97. package/less/outgoing.less +8 -8
  98. package/less/persona.less +47 -47
  99. package/less/post-queue.less +19 -19
  100. package/less/register.less +75 -75
  101. package/less/rtl.less +132 -132
  102. package/less/tags.less +36 -36
  103. package/less/users.less +72 -72
  104. package/less/variables.less +6 -6
  105. package/lib/controllers.js +22 -0
  106. package/library.js +29 -3
  107. package/package.json +1 -1
  108. package/plugin.json +2 -0
  109. package/public/.eslintrc +2 -2
  110. package/public/modules/autohidingnavbar.js +220 -220
  111. package/public/persona.js +9 -29
  112. package/public/settings.js +53 -0
  113. package/templates/account/blocks.tpl +34 -34
  114. package/templates/account/categories.tpl +28 -28
  115. package/templates/account/consent.tpl +68 -68
  116. package/templates/account/edit/email.tpl +30 -30
  117. package/templates/account/edit/password.tpl +31 -31
  118. package/templates/account/edit/username.tpl +29 -29
  119. package/templates/account/followers.tpl +16 -16
  120. package/templates/account/following.tpl +16 -16
  121. package/templates/account/groups.tpl +16 -16
  122. package/templates/account/info.tpl +187 -187
  123. package/templates/account/posts.tpl +18 -18
  124. package/templates/account/sessions.tpl +31 -31
  125. package/templates/account/theme.tpl +27 -0
  126. package/templates/account/topics.tpl +30 -30
  127. package/templates/account/uploads.tpl +42 -42
  128. package/templates/admin/plugins/persona.tpl +28 -28
  129. package/templates/alert.tpl +15 -15
  130. package/templates/categories.tpl +31 -31
  131. package/templates/category.tpl +62 -62
  132. package/templates/chats.tpl +16 -16
  133. package/templates/flags/list.tpl +71 -71
  134. package/templates/footer.tpl +18 -18
  135. package/templates/groups/details.tpl +272 -272
  136. package/templates/groups/list.tpl +46 -46
  137. package/templates/groups/members.tpl +8 -8
  138. package/templates/ip-blacklist.tpl +55 -55
  139. package/templates/modules/taskbar.tpl +2 -2
  140. package/templates/modules/usercard.tpl +36 -36
  141. package/templates/notifications.tpl +64 -64
  142. package/templates/partials/acceptTos.tpl +8 -8
  143. package/templates/partials/account/category-item.tpl +22 -22
  144. package/templates/partials/account/header.tpl +46 -46
  145. package/templates/partials/breadcrumbs.tpl +18 -18
  146. package/templates/partials/buttons/newTopic.tpl +15 -15
  147. package/templates/partials/categories/item.tpl +46 -46
  148. package/templates/partials/categories/lastpost.tpl +26 -26
  149. package/templates/partials/categories/link.tpl +10 -10
  150. package/templates/partials/category/sort.tpl +14 -14
  151. package/templates/partials/category/subcategory.tpl +17 -17
  152. package/templates/partials/category/tags.tpl +4 -4
  153. package/templates/partials/category/tools.tpl +80 -80
  154. package/templates/partials/category/watch.tpl +22 -22
  155. package/templates/partials/category-filter-content.tpl +16 -16
  156. package/templates/partials/category-filter-right.tpl +2 -2
  157. package/templates/partials/category-filter.tpl +2 -2
  158. package/templates/partials/category-selector-right.tpl +2 -2
  159. package/templates/partials/category-selector.tpl +2 -2
  160. package/templates/partials/change_owner_modal.tpl +22 -22
  161. package/templates/partials/chats/dropdown.tpl +33 -33
  162. package/templates/partials/chats/messages.tpl +6 -6
  163. package/templates/partials/chats/recent_room.tpl +24 -24
  164. package/templates/partials/chats-menu.tpl +40 -40
  165. package/templates/partials/cookie-consent.tpl +4 -4
  166. package/templates/partials/delete_posts_modal.tpl +18 -18
  167. package/templates/partials/fork_thread_modal.tpl +21 -21
  168. package/templates/partials/groups/list.tpl +20 -20
  169. package/templates/partials/groups/memberlist.tpl +39 -39
  170. package/templates/partials/merge_topics_modal.tpl +57 -57
  171. package/templates/partials/modals/flag_modal.tpl +44 -44
  172. package/templates/partials/modals/manage_room.tpl +10 -10
  173. package/templates/partials/modals/manage_room_users.tpl +6 -6
  174. package/templates/partials/modals/post_history.tpl +36 -36
  175. package/templates/partials/modals/rename_room.tpl +3 -3
  176. package/templates/partials/modals/votes_modal.tpl +10 -10
  177. package/templates/partials/move_thread_modal.tpl +16 -16
  178. package/templates/partials/paginator.tpl +44 -44
  179. package/templates/partials/post_bar.tpl +20 -20
  180. package/templates/partials/posts_list.tpl +7 -7
  181. package/templates/partials/quick-search-results.tpl +30 -30
  182. package/templates/partials/slideout-menu.tpl +4 -4
  183. package/templates/partials/tags_list.tpl +4 -4
  184. package/templates/partials/thread_tools.tpl +7 -7
  185. package/templates/partials/topic/badge.tpl +4 -4
  186. package/templates/partials/topic/deleted-message.tpl +10 -10
  187. package/templates/partials/topic/navigation-post.tpl +11 -11
  188. package/templates/partials/topic/necro-post.tpl +2 -2
  189. package/templates/partials/topic/post-menu.tpl +4 -4
  190. package/templates/partials/topic/post.tpl +104 -104
  191. package/templates/partials/topic/quickreply.tpl +25 -25
  192. package/templates/partials/topic/reply-button.tpl +26 -26
  193. package/templates/partials/topic/selection-tooltip.tpl +2 -2
  194. package/templates/partials/topic/sort.tpl +9 -9
  195. package/templates/partials/topic/stats.tpl +11 -11
  196. package/templates/partials/topic/tags.tpl +4 -4
  197. package/templates/partials/topic/watch.tpl +20 -20
  198. package/templates/partials/users_list.tpl +39 -39
  199. package/templates/partials/users_list_menu.tpl +10 -10
  200. package/templates/popular.tpl +61 -61
  201. package/templates/post-queue.tpl +82 -82
  202. package/templates/recent.tpl +51 -51
  203. package/templates/reset.tpl +23 -23
  204. package/templates/reset_code.tpl +41 -41
  205. package/templates/tag.tpl +35 -35
  206. package/templates/tags.tpl +30 -30
  207. package/templates/top.tpl +61 -61
  208. package/templates/tos.tpl +4 -4
  209. package/templates/unread.tpl +49 -49
  210. package/templates/users.tpl +47 -47
  211. package/theme.json +6 -6
  212. package/theme.less +1 -1
package/library.js CHANGED
@@ -2,15 +2,23 @@
2
2
 
3
3
  const meta = require.main.require('./src/meta');
4
4
  const user = require.main.require('./src/user');
5
+ const translator = require.main.require('./src/translator');
6
+
7
+ const controllers = require('./lib/controllers');
5
8
 
6
9
  const library = module.exports;
7
10
 
8
11
  library.init = async function (params) {
9
12
  const { router, middleware } = params;
10
13
  const routeHelpers = require.main.require('./src/routes/helpers');
11
- routeHelpers.setupAdminPageRoute(router, '/admin/plugins/persona', middleware, [], (req, res) => {
12
- res.render('admin/plugins/persona', {});
13
- });
14
+ routeHelpers.setupAdminPageRoute(router, '/admin/plugins/persona', middleware, [], controllers.renderAdminPage);
15
+
16
+ routeHelpers.setupPageRoute(router, '/user/:userslug/theme', middleware, [
17
+ middleware.exposeUid,
18
+ middleware.ensureLoggedIn,
19
+ middleware.canViewUsers,
20
+ middleware.checkAccountPermissions,
21
+ ], controllers.renderThemeSettings);
14
22
  };
15
23
 
16
24
  library.addAdminNavigation = async function (header) {
@@ -22,6 +30,24 @@ library.addAdminNavigation = async function (header) {
22
30
  return header;
23
31
  };
24
32
 
33
+ library.addProfileItem = async (data) => {
34
+ data.links.push({
35
+ id: 'theme',
36
+ route: 'theme',
37
+ icon: 'fa-paint-brush',
38
+ name: await translator.translate('[[persona:settings.title]]'),
39
+ visibility: {
40
+ self: true,
41
+ other: false,
42
+ moderator: false,
43
+ globalMod: false,
44
+ admin: false,
45
+ },
46
+ });
47
+
48
+ return data;
49
+ };
50
+
25
51
  library.defineWidgetAreas = async function (areas) {
26
52
  const locations = ['header', 'sidebar', 'footer'];
27
53
  const templates = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-theme-persona",
3
- "version": "11.3.40",
3
+ "version": "11.4.0",
4
4
  "nbbpm": {
5
5
  "compatibility": "^1.18.0"
6
6
  },
package/plugin.json CHANGED
@@ -5,10 +5,12 @@
5
5
  { "hook": "filter:config.get", "method": "getThemeConfig" },
6
6
  { "hook": "static:app.load", "method": "init" },
7
7
  { "hook": "filter:admin.header.build", "method": "addAdminNavigation" },
8
+ { "hook": "filter:user.profileMenu", "method": "addProfileItem" },
8
9
  { "hook": "filter:topic.build", "method": "addUserToTopic" }
9
10
  ],
10
11
  "scripts": [
11
12
  "public/persona.js",
13
+ "public/settings.js",
12
14
  "public/modules/autohidingnavbar.js",
13
15
  "public/modules/quickreply.js"
14
16
  ],
package/public/.eslintrc CHANGED
@@ -1,3 +1,3 @@
1
- {
2
- "extends": "nodebb/public"
1
+ {
2
+ "extends": "nodebb/public"
3
3
  }
@@ -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);
package/public/persona.js CHANGED
@@ -46,7 +46,14 @@ $(document).ready(function () {
46
46
  return;
47
47
  }
48
48
 
49
- require(['hooks'], (hooks) => {
49
+ require(['hooks', 'storage'], (hooks, Storage) => {
50
+ let preference = ['xs', 'sm'];
51
+
52
+ try {
53
+ preference = JSON.parse(Storage.getItem('persona:navbar:autohide'));
54
+ } catch (e) {
55
+ console.warn('[persona/settings] Unable to parse value for navbar autohiding');
56
+ }
50
57
  var env = utils.findBootstrapEnvironment();
51
58
  // if env didn't change don't destroy and recreate
52
59
  if (env === lastBSEnv) {
@@ -58,7 +65,7 @@ $(document).ready(function () {
58
65
  navbarEl.css('top', '');
59
66
 
60
67
  hooks.fire('filter:persona.configureNavbarHiding', {
61
- resizeEnvs: ['xs', 'sm'],
68
+ resizeEnvs: preference,
62
69
  }).then(({ resizeEnvs }) => {
63
70
  if (resizeEnvs.includes(env)) {
64
71
  navbarEl.autoHidingNavbar({
@@ -372,33 +379,6 @@ $(document).ready(function () {
372
379
  in: config.searchDefaultInQuick,
373
380
  },
374
381
  });
375
-
376
-
377
- // add a checkbox in the user settings page
378
- // so users can swap the sides the menus appear on
379
-
380
- function setupSetting() {
381
- if (ajaxify.data.template['account/settings'] && !document.getElementById('persona:menus:legacy-layout')) {
382
- require(['translator'], function (translator) {
383
- translator.translate('[[persona:mobile-menu-side]]', function (translated) {
384
- $('<div class="well checkbox"><label><input type="checkbox" id="persona:menus:legacy-layout"/><strong>' + translated + '</strong></label></div>')
385
- .appendTo('#content .account > .row > div:first-child')
386
- .find('input')
387
- .prop('checked', Storage.getItem('persona:menus:legacy-layout', 'true'))
388
- .change(function (e) {
389
- if (e.target.checked) {
390
- Storage.setItem('persona:menus:legacy-layout', 'true');
391
- } else {
392
- Storage.removeItem('persona:menus:legacy-layout');
393
- }
394
- });
395
- });
396
- });
397
- }
398
- }
399
-
400
- $(window).on('action:ajaxify.end', setupSetting);
401
- setupSetting();
402
382
  });
403
383
  }
404
384
 
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ define('forum/account/theme', ['forum/account/header', 'storage', 'settings', 'alerts'], function (header, Storage, settings, alerts) {
4
+ const Theme = {};
5
+
6
+ Theme.init = () => {
7
+ header.init();
8
+ Theme.setupForm();
9
+ };
10
+
11
+ Theme.setupForm = () => {
12
+ const saveEl = document.getElementById('save');
13
+ const formEl = document.getElementById('theme-settings');
14
+ const [sidebarSwapped, autohideNavbarEnvs] = [
15
+ !!Storage.getItem('persona:menus:legacy-layout'),
16
+ Storage.getItem('persona:navbar:autohide'),
17
+ ];
18
+
19
+ document.getElementById('persona:menus:legacy-layout').checked = sidebarSwapped;
20
+ try {
21
+ const parsed = JSON.parse(autohideNavbarEnvs);
22
+ parsed.forEach((env) => {
23
+ const optionEl = document.getElementById('persona:navbar:autohide').querySelector(`option[value="${env}"]`);
24
+ optionEl.selected = true;
25
+ });
26
+ } catch (e) {
27
+ console.warn(e);
28
+ }
29
+
30
+ if (saveEl) {
31
+ saveEl.addEventListener('click', () => {
32
+ const themeSettings = settings.helper.serializeForm($(formEl));
33
+ Object.keys(themeSettings).forEach((key) => {
34
+ if (key === 'persona:menus:legacy-layout') {
35
+ if (themeSettings[key] === 'on') {
36
+ Storage.setItem('persona:menus:legacy-layout', 'true');
37
+ } else {
38
+ Storage.removeItem('persona:menus:legacy-layout');
39
+ }
40
+
41
+ return;
42
+ }
43
+
44
+ Storage.setItem(key, themeSettings[key]);
45
+ });
46
+
47
+ alerts.success('[[success:settings-saved]]');
48
+ });
49
+ }
50
+ };
51
+
52
+ return Theme;
53
+ });