nodebb-theme-persona 13.0.19 → 13.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-theme-persona",
3
- "version": "13.0.19",
3
+ "version": "13.0.20",
4
4
  "nbbpm": {
5
5
  "compatibility": "^3.0.0"
6
6
  },
package/plugin.json CHANGED
@@ -15,6 +15,8 @@
15
15
  "modules": {
16
16
  "../admin/plugins/persona.js": "public/admin.js",
17
17
  "persona/quickreply.js": "public/modules/quickreply.js",
18
+ "persona/taskbar.js": "public/modules/taskbar.js",
19
+ "persona/mobile-menu.js": "public/modules/mobile-menu.js",
18
20
  "../client/account/theme.js": "public/settings.js"
19
21
  },
20
22
  "languages": "languages"
@@ -0,0 +1,185 @@
1
+ 'use strict';
2
+
3
+ define('persona/mobile-menu', [
4
+ 'pulling/build/pulling-drawer', 'storage', 'alerts', 'search',
5
+ ], function (
6
+ Pulling, Storage, alerts, search
7
+ ) {
8
+ const Menu = {};
9
+
10
+ Menu.init = function () {
11
+ if (!Pulling) {
12
+ return;
13
+ }
14
+
15
+ // initialization
16
+
17
+ const chatMenuVisible = app.user && parseInt(app.user.uid, 10);
18
+ let swapped = !!Storage.getItem('persona:menus:legacy-layout');
19
+ const margin = window.innerWidth;
20
+
21
+ if (swapped) {
22
+ $('#mobile-menu').removeClass('float-start');
23
+ $('#mobile-chats').addClass('float-start');
24
+ }
25
+
26
+ if (document.documentElement.getAttribute('data-dir') === 'rtl') {
27
+ swapped = !swapped;
28
+ }
29
+
30
+ const navSlideout = Pulling.create({
31
+ panel: document.getElementById('panel'),
32
+ menu: document.getElementById('menu'),
33
+ width: 256,
34
+ margin: margin,
35
+ side: swapped ? 'right' : 'left',
36
+ });
37
+ $('#menu').removeClass('hidden');
38
+
39
+ let chatsSlideout;
40
+ if (chatMenuVisible) {
41
+ chatsSlideout = Pulling.create({
42
+ panel: document.getElementById('panel'),
43
+ menu: document.getElementById('chats-menu'),
44
+ width: 256,
45
+ margin: margin,
46
+ side: swapped ? 'left' : 'right',
47
+ });
48
+ $('#chats-menu').removeClass('hidden');
49
+ }
50
+
51
+ // all menus
52
+
53
+ function closeOnClick() {
54
+ navSlideout.close();
55
+ if (chatsSlideout) { chatsSlideout.close(); }
56
+ }
57
+
58
+ function onBeforeOpen() {
59
+ document.documentElement.classList.add('slideout-open');
60
+ }
61
+
62
+ function onClose() {
63
+ $('#mobile-menu').blur();
64
+ document.documentElement.classList.remove('slideout-open');
65
+ $('#panel').off('click', closeOnClick);
66
+ }
67
+
68
+ $(window).on('resize action:ajaxify.start', function () {
69
+ navSlideout.close();
70
+ if (chatsSlideout) {
71
+ chatsSlideout.close();
72
+ }
73
+ });
74
+
75
+ navSlideout
76
+ .ignore('code, code *, .preventSlideout, .preventSlideout *')
77
+ .on('closed', onClose)
78
+ .on('beforeopen', onBeforeOpen)
79
+ .on('opened', function () {
80
+ $('#panel').one('click', closeOnClick);
81
+ });
82
+
83
+ if (chatMenuVisible) {
84
+ chatsSlideout
85
+ .ignore('code, code *, .preventSlideout, .preventSlideout *')
86
+ .on('closed', onClose)
87
+ .on('beforeopen', onBeforeOpen)
88
+ .on('opened', function () {
89
+ $('#panel').one('click', closeOnClick);
90
+ });
91
+ }
92
+
93
+ // left slideout navigation menu
94
+
95
+ $('#mobile-menu').on('click', function () {
96
+ navSlideout.enable().toggle();
97
+ });
98
+
99
+ if (chatMenuVisible) {
100
+ navSlideout.on('beforeopen', function () {
101
+ chatsSlideout.close();
102
+ chatsSlideout.disable();
103
+ }).on('closed', function () {
104
+ chatsSlideout.enable();
105
+ });
106
+ }
107
+
108
+ $('#menu [data-section="navigation"] ul').html(
109
+ $('#main-nav').html() +
110
+ ($('#logged-out-menu').html() || '')
111
+ );
112
+
113
+ $('#user-control-list').children().clone(true, true).appendTo($('#chats-menu [data-section="profile"] ul'));
114
+
115
+ socket.on('event:user_status_change', function (data) {
116
+ if (parseInt(data.uid, 10) === app.user.uid) {
117
+ app.updateUserStatus($('#chats-menu [component="user/status"]'), data.status);
118
+ navSlideout.close();
119
+ }
120
+ });
121
+
122
+ // right slideout notifications & chats menu
123
+
124
+ function loadNotificationsAndChats() {
125
+ require(['notifications', 'chat'], function (notifications, chat) {
126
+ const notifList = $('#chats-menu [data-section="notifications"] ul');
127
+ notifications.loadNotifications(notifList, function () {
128
+ notifList.find('.deco-none').removeClass('deco-none');
129
+ chat.loadChatsDropdown($('#chats-menu .chat-list'));
130
+ });
131
+ });
132
+ }
133
+
134
+ if (chatMenuVisible) {
135
+ $('#mobile-chats').removeClass('hidden').on('click', function () {
136
+ navSlideout.close();
137
+ chatsSlideout.enable().toggle();
138
+ });
139
+ $('#chats-menu').on('click', 'li[data-roomid]', function () {
140
+ chatsSlideout.close();
141
+ });
142
+
143
+ chatsSlideout
144
+ .on('opened', loadNotificationsAndChats)
145
+ .on('beforeopen', function () {
146
+ navSlideout.close().disable();
147
+ })
148
+ .on('closed', function () {
149
+ navSlideout.enable();
150
+ });
151
+ }
152
+
153
+ const searchInputEl = $('.navbar .navbar-search input[name="term"]');
154
+ const searchButton = $('.navbar .navbar-search button[type="button"]');
155
+ searchButton.off('click').on('click', function () {
156
+ if (!config.loggedIn && !app.user.privileges['search:content']) {
157
+ alerts.alert({
158
+ message: '[[error:search-requires-login]]',
159
+ timeout: 3000,
160
+ });
161
+ ajaxify.go('login');
162
+ return false;
163
+ }
164
+
165
+ searchButton.addClass('hidden');
166
+ searchInputEl.removeClass('hidden').focus();
167
+ return false;
168
+ });
169
+ searchInputEl.on('blur', function () {
170
+ searchInputEl.addClass('hidden');
171
+ searchButton.removeClass('hidden');
172
+ });
173
+ search.enableQuickSearch({
174
+ searchElements: {
175
+ inputEl: searchInputEl,
176
+ resultEl: $('.navbar .navbar-search .quick-search-container'),
177
+ },
178
+ searchOptions: {
179
+ in: config.searchDefaultInQuick,
180
+ },
181
+ });
182
+ };
183
+
184
+ return Menu;
185
+ });
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ define('persona/taskbar', [
4
+ 'hooks',
5
+ ], function (
6
+ hooks
7
+ ) {
8
+ const Taskbar = {};
9
+
10
+ Taskbar.init = function () {
11
+ hooks.on('filter:taskbar.push', (data) => {
12
+ data.options.className = 'taskbar-' + data.module;
13
+ if (data.module === 'composer') {
14
+ data.options.icon = 'fa-commenting-o';
15
+ } else if (data.module === 'chat') {
16
+ if (data.element.length && !data.element.hasClass('active')) {
17
+ increaseChatCount(data.element);
18
+ }
19
+ }
20
+ });
21
+ hooks.on('action:taskbar.pushed', (data) => {
22
+ if (data.module === 'chat') {
23
+ createChatIcon(data);
24
+ const elData = data.element.data();
25
+ if (elData && elData.options && !elData.options.isSelf) {
26
+ increaseChatCount(data.element);
27
+ }
28
+ }
29
+ });
30
+
31
+ socket.on('event:chats.markedAsRead', function (data) {
32
+ $('#taskbar [data-roomid="' + data.roomId + '"]')
33
+ .removeClass('new')
34
+ .attr('data-content', 0);
35
+ });
36
+
37
+ function createChatIcon(data) {
38
+ $.getJSON(config.relative_path + '/api/user/' + app.user.userslug + '/chats/' + data.options.roomId, function (chatObj) {
39
+ const el = $('#taskbar [data-uuid="' + data.uuid + '"] a');
40
+ el.parent('[data-uuid]').attr('data-roomId', data.options.roomId);
41
+
42
+ if (chatObj.users.length === 1) {
43
+ const user = chatObj.users[0];
44
+ el.find('i').remove();
45
+
46
+ if (user.picture) {
47
+ el.css('background-image', 'url(' + user.picture + ')');
48
+ el.css('background-size', 'cover');
49
+ } else {
50
+ el.css('background-color', user['icon:bgColor'])
51
+ .text(user['icon:text'])
52
+ .addClass('avatar');
53
+ }
54
+ }
55
+ });
56
+ }
57
+
58
+ function increaseChatCount(el) {
59
+ const count = (parseInt($(el).attr('data-content'), 10) || 0) + 1;
60
+ $(el).attr('data-content', count);
61
+ }
62
+ };
63
+
64
+ return Taskbar;
65
+ });
package/public/persona.js CHANGED
@@ -112,59 +112,9 @@ $(document).ready(function () {
112
112
  }
113
113
 
114
114
  function setupTaskbar() {
115
- require(['hooks'], (hooks) => {
116
- hooks.on('filter:taskbar.push', (data) => {
117
- data.options.className = 'taskbar-' + data.module;
118
- if (data.module === 'composer') {
119
- data.options.icon = 'fa-commenting-o';
120
- } else if (data.module === 'chat') {
121
- if (data.element.length && !data.element.hasClass('active')) {
122
- increaseChatCount(data.element);
123
- }
124
- }
125
- });
126
- hooks.on('action:taskbar.pushed', (data) => {
127
- if (data.module === 'chat') {
128
- createChatIcon(data);
129
- var elData = data.element.data();
130
- if (elData && elData.options && !elData.options.isSelf) {
131
- increaseChatCount(data.element);
132
- }
133
- }
134
- });
135
- });
136
-
137
- socket.on('event:chats.markedAsRead', function (data) {
138
- $('#taskbar [data-roomid="' + data.roomId + '"]')
139
- .removeClass('new')
140
- .attr('data-content', 0);
115
+ require(['persona/taskbar'], function (taskbar) {
116
+ taskbar.init();
141
117
  });
142
-
143
- function createChatIcon(data) {
144
- $.getJSON(config.relative_path + '/api/user/' + app.user.userslug + '/chats/' + data.options.roomId, function (chatObj) {
145
- var el = $('#taskbar [data-uuid="' + data.uuid + '"] a');
146
- el.parent('[data-uuid]').attr('data-roomId', data.options.roomId);
147
-
148
- if (chatObj.users.length === 1) {
149
- var user = chatObj.users[0];
150
- el.find('i').remove();
151
-
152
- if (user.picture) {
153
- el.css('background-image', 'url(' + user.picture + ')');
154
- el.css('background-size', 'cover');
155
- } else {
156
- el.css('background-color', user['icon:bgColor'])
157
- .text(user['icon:text'])
158
- .addClass('avatar');
159
- }
160
- }
161
- });
162
- }
163
-
164
- function increaseChatCount(el) {
165
- var count = (parseInt($(el).attr('data-content'), 10) || 0) + 1;
166
- $(el).attr('data-content', count);
167
- }
168
118
  }
169
119
 
170
120
  function setupEditedByIcon() {
@@ -196,182 +146,8 @@ $(document).ready(function () {
196
146
  }
197
147
 
198
148
  function setupMobileMenu() {
199
- if (!window.addEventListener) {
200
- return;
201
- }
202
-
203
- require(['pulling/build/pulling-drawer', 'storage', 'alerts', 'search'], function (Pulling, Storage, alerts, search) {
204
- if (!Pulling) {
205
- return;
206
- }
207
-
208
- // initialization
209
-
210
- var chatMenuVisible = app.user && parseInt(app.user.uid, 10);
211
- var swapped = !!Storage.getItem('persona:menus:legacy-layout');
212
- var margin = window.innerWidth;
213
-
214
- if (swapped) {
215
- $('#mobile-menu').removeClass('float-start');
216
- $('#mobile-chats').addClass('float-start');
217
- }
218
-
219
- if (document.documentElement.getAttribute('data-dir') === 'rtl') {
220
- swapped = !swapped;
221
- }
222
-
223
- var navSlideout = Pulling.create({
224
- panel: document.getElementById('panel'),
225
- menu: document.getElementById('menu'),
226
- width: 256,
227
- margin: margin,
228
- side: swapped ? 'right' : 'left',
229
- });
230
- $('#menu').removeClass('hidden');
231
-
232
- var chatsSlideout;
233
- if (chatMenuVisible) {
234
- chatsSlideout = Pulling.create({
235
- panel: document.getElementById('panel'),
236
- menu: document.getElementById('chats-menu'),
237
- width: 256,
238
- margin: margin,
239
- side: swapped ? 'left' : 'right',
240
- });
241
- $('#chats-menu').removeClass('hidden');
242
- }
243
-
244
- // all menus
245
-
246
- function closeOnClick() {
247
- navSlideout.close();
248
- if (chatsSlideout) { chatsSlideout.close(); }
249
- }
250
-
251
- function onBeforeOpen() {
252
- document.documentElement.classList.add('slideout-open');
253
- }
254
-
255
- function onClose() {
256
- $('#mobile-menu').blur();
257
- document.documentElement.classList.remove('slideout-open');
258
- $('#panel').off('click', closeOnClick);
259
- }
260
-
261
- $(window).on('resize action:ajaxify.start', function () {
262
- navSlideout.close();
263
- if (chatsSlideout) {
264
- chatsSlideout.close();
265
- }
266
- });
267
-
268
- navSlideout
269
- .ignore('code, code *, .preventSlideout, .preventSlideout *')
270
- .on('closed', onClose)
271
- .on('beforeopen', onBeforeOpen)
272
- .on('opened', function () {
273
- $('#panel').one('click', closeOnClick);
274
- });
275
-
276
- if (chatMenuVisible) {
277
- chatsSlideout
278
- .ignore('code, code *, .preventSlideout, .preventSlideout *')
279
- .on('closed', onClose)
280
- .on('beforeopen', onBeforeOpen)
281
- .on('opened', function () {
282
- $('#panel').one('click', closeOnClick);
283
- });
284
- }
285
-
286
- // left slideout navigation menu
287
-
288
- $('#mobile-menu').on('click', function () {
289
- navSlideout.enable().toggle();
290
- });
291
-
292
- if (chatMenuVisible) {
293
- navSlideout.on('beforeopen', function () {
294
- chatsSlideout.close();
295
- chatsSlideout.disable();
296
- }).on('closed', function () {
297
- chatsSlideout.enable();
298
- });
299
- }
300
-
301
- $('#menu [data-section="navigation"] ul').html(
302
- $('#main-nav').html() +
303
- ($('#logged-out-menu').html() || '')
304
- );
305
-
306
- $('#user-control-list').children().clone(true, true).appendTo($('#chats-menu [data-section="profile"] ul'));
307
-
308
- socket.on('event:user_status_change', function (data) {
309
- if (parseInt(data.uid, 10) === app.user.uid) {
310
- app.updateUserStatus($('#chats-menu [component="user/status"]'), data.status);
311
- navSlideout.close();
312
- }
313
- });
314
-
315
- // right slideout notifications & chats menu
316
-
317
- function loadNotificationsAndChats() {
318
- require(['notifications', 'chat'], function (notifications, chat) {
319
- const notifList = $('#chats-menu [data-section="notifications"] ul');
320
- notifications.loadNotifications(notifList, function () {
321
- notifList.find('.deco-none').removeClass('deco-none');
322
- chat.loadChatsDropdown($('#chats-menu .chat-list'));
323
- });
324
- });
325
- }
326
-
327
- if (chatMenuVisible) {
328
- $('#mobile-chats').removeClass('hidden').on('click', function () {
329
- navSlideout.close();
330
- chatsSlideout.enable().toggle();
331
- });
332
- $('#chats-menu').on('click', 'li[data-roomid]', function () {
333
- chatsSlideout.close();
334
- });
335
-
336
- chatsSlideout
337
- .on('opened', loadNotificationsAndChats)
338
- .on('beforeopen', function () {
339
- navSlideout.close().disable();
340
- })
341
- .on('closed', function () {
342
- navSlideout.enable();
343
- });
344
- }
345
-
346
- const searchInputEl = $('.navbar .navbar-search input[name="term"]');
347
- const searchButton = $('.navbar .navbar-search button[type="button"]');
348
- searchButton.off('click').on('click', function () {
349
- if (!config.loggedIn && !app.user.privileges['search:content']) {
350
- alerts.alert({
351
- message: '[[error:search-requires-login]]',
352
- timeout: 3000,
353
- });
354
- ajaxify.go('login');
355
- return false;
356
- }
357
-
358
- searchButton.addClass('hidden');
359
- searchInputEl.removeClass('hidden').focus();
360
- return false;
361
- });
362
- searchInputEl.on('blur', function () {
363
- searchInputEl.addClass('hidden');
364
- searchButton.removeClass('hidden');
365
- });
366
- search.enableQuickSearch({
367
- searchElements: {
368
- inputEl: searchInputEl,
369
- resultEl: $('.navbar .navbar-search .quick-search-container'),
370
- },
371
- searchOptions: {
372
- in: config.searchDefaultInQuick,
373
- },
374
- });
149
+ require(['persona/mobile-menu'], function (mobileMenu) {
150
+ mobileMenu.init();
375
151
  });
376
152
  }
377
153