From 29609212be9903a8bcebd6781a4e7450b95f48e6 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 31 Aug 2023 16:34:57 +0200 Subject: [PATCH 01/87] Reorder DOM based on visual order in toolbar #1198 --- customize.dist/src/less2/include/toolbar.less | 42 ------ www/common/toolbar.js | 124 +++++++++--------- www/file/inner.js | 14 +- 3 files changed, 67 insertions(+), 113 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar.less b/customize.dist/src/less2/include/toolbar.less index b1eb49887..18599951c 100644 --- a/customize.dist/src/less2/include/toolbar.less +++ b/customize.dist/src/less2/include/toolbar.less @@ -439,13 +439,6 @@ screen and (max-height: 500px) { flex-wrap: wrap; height: @toolbar_line-height; - .cp-pad-not-pinned { - line-height: 32px; - flex: unset; - padding: 0; - align-self: auto; - margin: 0 5px; - } .cp-toolbar-top-filler { height: 32px; } @@ -578,41 +571,6 @@ position: relative; width: 100%; - .cp-pad-not-pinned { - order: 4; - flex: 1; - - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - - line-height: @toolbar_top-height; - padding: 0; - margin: 0 5px; - font-size: @colortheme_app-font-size; - color: @cp_toolbar-warn; - .cp-pnp-msg { - padding-left: 5px; - font-family: @colortheme_font; - font-size: @colortheme_app-font-size; - a { - font-size: @colortheme_app-font-size; - font-family: @colortheme_font; - font-weight: bold; - color: @cp_toolbar-warn; - &:hover { - text-decoration: underline; - } - } - @media screen and (max-width: (@browser_media-not-big)) { - display: none; - } - } - @media screen and (max-width: (@browser_media-not-big)) { - overflow: visible; - max-width: 20px; - } - } .cp-toolbar-top-filler { height: @toolbar_top-height; display: inline-block; diff --git a/www/common/toolbar.js b/www/common/toolbar.js index c1595cd2c..227aba017 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -61,6 +61,50 @@ MessengerUI, Messages, Pages) { return 'cp-toolbar-uid-' + String(Math.random()).substring(2); }; + var observeChildren = function ($content) { + var reorderDOM = Util.throttle(function ($content, observer) { + if (!$content.length) { return; } + + // List all children based on their "order" property + var map = {}; + $content[0].childNodes.forEach((node) => { + try { + if (!node.attributes) { return; } + var order = getComputedStyle(node).getPropertyValue("order"); + var a = map[order] = map[order] || []; + a.push(node); + } catch (e) { console.error(e, node); } + }); + + // Disconnect the observer while we're reordering to avoid infinite loop + observer.disconnect(); + Object.keys(map).sort(function (a, b) { + return Number(a) - Number(b); + }).forEach(function (k) { + var arr = map[k]; + // Reorder + arr.forEach(function (node) { + $content.append(node); + }); + }); + observer.start(); + }, 100); + + let observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.addedNodes.length) { + reorderDOM($content, observer); + } + }); + }); + observer.start = function () { + observer.observe($content[0], { + childList: true + }); + }; + observer.start(); + }; + var createRealtimeToolbar = function (config) { if (!config.$container) { return; } var $container = config.$container; @@ -103,10 +147,7 @@ MessengerUI, Messages, Pages) { h('i.fa.fa-file-o'), h('span.cp-button-name', Messages.toolbar_file) ])).appendTo($file).hide(); - var $drawerContent = $('
', { - 'class': DRAWER_CLS, - 'tabindex': 1 - }).hide(); + var $drawerContent = $(h('div.'+ DRAWER_CLS, {tabindex: 1})).hide(); UI.createDrawer($drawer, $drawerContent); } @@ -776,58 +817,6 @@ MessengerUI, Messages, Pages) { return $titleContainer; }; - var createUnpinnedWarning0 = function (toolbar, config) { - if (true) { return; } // stub this call since it won't make it into the next release - if (Common.isLoggedIn()) { return; } - var pd = config.metadataMgr.getPrivateData(); - var o = pd.origin; - var cid = pd.channel; - Common.sendAnonRpcMsg('IS_CHANNEL_PINNED', cid, function (x) { - if (x.error || !Array.isArray(x.response)) { return void console.log(x); } - if (x.response[0] === true) { - $('.cp-pad-not-pinned').remove(); - return; - } - - if (typeof(ApiConfig.inactiveTime) !== 'number') { - $('.cp-pad-not-pinned').remove(); - return; - } - - if ($('.cp-pad-not-pinned').length) { return; } - var pnpTitle = Messages._getKey('padNotPinnedVariable', ['','','','', ApiConfig.inactiveTime]); - var pnpMsg = Messages._getKey('padNotPinnedVariable', [ - '', - '', - '', - ApiConfig.inactiveTime - ]); - var $msg = $('', { - 'class': 'cp-pad-not-pinned' - }).append([ - $('', {'class': 'fa fa-exclamation-triangle', 'title': pnpTitle}), - $('', {'class': 'cp-pnp-msg'}).append(pnpMsg) - ]); - $msg.find('a.cp-pnp-login').click(function (ev) { - ev.preventDefault(); - Common.setLoginRedirect('login'); - }); - $msg.find('a.cp-pnp-register').click(function (ev) { - ev.preventDefault(); - Common.setLoginRedirect('register'); - }); - $('.cp-toolbar-top').append($msg); - //UI.addTooltips(); - }); - }; - - var createUnpinnedWarning = function (toolbar, config) { - config.metadataMgr.onChange(function () { - createUnpinnedWarning0(toolbar, config); - }); - createUnpinnedWarning0(toolbar, config); - }; var createPageTitle = function (toolbar, config) { if (!config.pageTitle) { return; } @@ -840,9 +829,13 @@ MessengerUI, Messages, Pages) { var $hoverable = $('', {'class': 'cp-toolbar-title-hoverable'}).appendTo($titleContainer); // Buttons - $('', { + var $b = $('', { 'class': 'cp-toolbar-title-value cp-toolbar-title-value-page' }).appendTo($hoverable).text(config.pageTitle); + + toolbar.updatePageTitle = function (title) { + $b.text(title); + }; }; var createLinkToMain = function (toolbar, config) { @@ -1328,6 +1321,17 @@ MessengerUI, Messages, Pages) { toolbar.$drawer = $toolbar.find('.'+Bar.constants.drawer); toolbar.$top = $toolbar.find('.'+Bar.constants.top); toolbar.$history = $toolbar.find('.'+Bar.constants.history); + toolbar.$user = $toolbar.find('.'+Bar.constants.userAdmin); + + observeChildren(toolbar.$drawer); + observeChildren(toolbar.$bottomL); + observeChildren(toolbar.$bottomM); + observeChildren(toolbar.$bottomR); + observeChildren(toolbar.$top); + observeChildren(toolbar.$user); + if (config.$contentContainer) { + observeChildren(config.$contentContainer); + } toolbar.$userAdmin = $toolbar.find('.'+Bar.constants.userAdmin); @@ -1342,14 +1346,10 @@ MessengerUI, Messages, Pages) { tb['title'] = createTitle; tb['pageTitle'] = createPageTitle; //tb['request'] = createRequest; - tb['lag'] = $.noop; tb['spinner'] = createSpinner; - tb['state'] = $.noop; tb['limit'] = createLimit; // TODO - tb['upgrade'] = $.noop; tb['newpad'] = createNewPad; tb['useradmin'] = createUserAdmin; - tb['unpinnedWarning'] = createUnpinnedWarning; tb['notifications'] = createNotifications; tb['maintenance'] = createMaintenance; @@ -1359,7 +1359,7 @@ MessengerUI, Messages, Pages) { 'chat', 'collapse', 'userlist', 'title', 'useradmin', 'spinner', - 'newpad', 'share', 'access', 'limit', 'unpinnedWarning', + 'newpad', 'share', 'access', 'limit', 'notifications' ], {}); }; diff --git a/www/file/inner.js b/www/file/inner.js index 00e0a2fa9..b635b3e50 100644 --- a/www/file/inner.js +++ b/www/file/inner.js @@ -55,7 +55,7 @@ define([ } var Title = common.createTitle({}); - var displayed = ['useradmin', 'newpad', 'limit', 'upgrade', 'notifications']; + var displayed = ['useradmin', 'newpad', 'limit', 'upgrade', 'notifications', 'pageTitle']; if (!uploadMode) { displayed.push('fileshare'); displayed.push('access'); @@ -64,12 +64,9 @@ define([ displayed: displayed, $container: $bar, metadataMgr: metadataMgr, + pageTitle: Messages.upload_title, sfCommon: common, }; - if (uploadMode) { - displayed.push('pageTitle'); - configTb.pageTitle = Messages.upload_title; - } var toolbar = APP.toolbar = Toolbar.create(configTb); if (!uploadMode) { @@ -136,10 +133,9 @@ define([ common.setPadAttribute('fileType', metadata.type); } - toolbar.addElement(['pageTitle'], { - pageTitle: title, - title: Title.getTitleConfig(), - }); + if (toolbar.updatePageTitle) { + toolbar.updatePageTitle(title); + } toolbar.$drawer.append(common.createButton('forget', true)); toolbar.$drawer.append(common.createButton('properties', true)); if (common.isLoggedIn()) { From 784a833a0f6d784fd3889f87425850bc158ba3c5 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 4 Sep 2023 12:03:37 +0200 Subject: [PATCH 02/87] Fix CkEditor issue with toolbar reordering --- www/common/toolbar.js | 1 + 1 file changed, 1 insertion(+) diff --git a/www/common/toolbar.js b/www/common/toolbar.js index 227aba017..19bb768ca 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -82,6 +82,7 @@ MessengerUI, Messages, Pages) { return Number(a) - Number(b); }).forEach(function (k) { var arr = map[k]; + if (!Number(k)) { return; } // No need to "append" if order is 0 // Reorder arr.forEach(function (node) { $content.append(node); From 1f6b1169938fa47628fdb910e89aefc4d72a0660 Mon Sep 17 00:00:00 2001 From: daria Date: Mon, 4 Sep 2023 16:09:32 +0300 Subject: [PATCH 03/87] user menu can be accessed using the keyboard on firefox #1209 --- www/common/common-ui-elements.js | 35 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index a8992250c..dfeaa8049 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1539,11 +1539,14 @@ define([ $el.appendTo($innerblock); if (typeof(o.action) === 'function') { - $el.click(function (e) { - var close = o.action(e); - if (close) { hide(); } + $el.on('click keydown', function (e) { + if (e.type === 'click' || (e.type === 'keydown' && e.keyCode === 13)) { + var close = o.action(e); + if (close) { hide(); } + } }); } + }); }; setOptions(config.options); @@ -1821,7 +1824,7 @@ define([ if (accountName && !AppConfig.disableProfile) { options.push({ tag: 'a', - attributes: {'class': 'cp-toolbar-menu-profile fa fa-user-circle'}, + attributes: {'class': 'cp-toolbar-menu-profile fa fa-user-circle','tabindex': '0'}, content: h('span', Messages.profileButton), action: function () { if (padType) { @@ -1836,7 +1839,8 @@ define([ options.push({ tag: 'a', attributes: { - 'class': 'fa fa-hdd-o' + 'class': 'fa fa-hdd-o', + 'tabindex': '0' }, content: h('span', Messages.type.drive), action: function () { @@ -1848,7 +1852,8 @@ define([ options.push({ tag: 'a', attributes: { - 'class': 'fa fa-users' + 'class': 'fa fa-users', + 'tabindex': '0' }, content: h('span', Messages.type.teams), action: function () { @@ -1861,6 +1866,7 @@ define([ tag: 'a', attributes: { 'class': 'fa fa-calendar', + 'tabindex': '0' }, content: h('span', Messages.calendar), action: function () { @@ -1872,7 +1878,8 @@ define([ options.push({ tag: 'a', attributes: { - 'class': 'fa fa-address-book' + 'class': 'fa fa-address-book', + 'tabindex': '0' }, content: h('span', Messages.type.contacts), action: function () { @@ -1883,7 +1890,7 @@ define([ if (padType !== 'settings') { options.push({ tag: 'a', - attributes: {'class': 'cp-toolbar-menu-settings fa fa-cog'}, + attributes: {'class': 'cp-toolbar-menu-settings fa fa-cog','tabindex': '0'}, content: h('span', Messages.settingsButton), action: function () { if (padType) { @@ -1900,7 +1907,7 @@ define([ if (priv.edPublic && Array.isArray(Config.adminKeys) && Config.adminKeys.indexOf(priv.edPublic) !== -1) { options.push({ tag: 'a', - attributes: {'class': 'cp-toolbar-menu-admin fa fa-cogs'}, + attributes: {'class': 'cp-toolbar-menu-admin fa fa-cogs','tabindex': '0'}, content: h('span', Messages.adminPage || 'Admin'), action: function () { if (padType) { @@ -1940,6 +1947,7 @@ define([ tag: 'a', attributes: { 'class': 'cp-toolbar-about fa fa-info', + 'tabindex': '0' }, content: h('span', Messages.user_about), action: function () { @@ -1950,7 +1958,8 @@ define([ options.push({ tag: 'a', attributes: { - 'class': 'fa fa-home' + 'class': 'fa fa-home', + 'tabindex': '0' }, content: h('span', Messages.homePage), action: function () { @@ -1991,7 +2000,8 @@ define([ options.push({ tag: 'a', attributes: { - 'class': 'fa fa-gift' + 'class': 'fa fa-gift', + 'tabindex': '0' }, content: h('span', Messages.crowdfunding_button2), action: function () { @@ -2022,6 +2032,7 @@ define([ tag: 'a', attributes: { 'class': 'cp-toolbar-menu-logout-everywhere fa fa-plug', + 'tabindex': '0' }, content: h('span', Messages.logoutEverywhere), action: function () { @@ -2035,7 +2046,7 @@ define([ }); options.push({ tag: 'a', - attributes: {'class': 'cp-toolbar-menu-logout fa fa-sign-out'}, + attributes: {'class': 'cp-toolbar-menu-logout fa fa-sign-out','tabindex': '0'}, content: h('span', Messages.logoutButton), action: function () { Common.logout(function () { From bd6de021e2df8d3956c707374bd4495ba6d449ce Mon Sep 17 00:00:00 2001 From: daria Date: Tue, 5 Sep 2023 14:42:42 +0300 Subject: [PATCH 04/87] added focus to toolbar elements #1206 user menu can be also accessed on other browsers #1209 --- customize.dist/src/less2/include/toolbar.less | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar.less b/customize.dist/src/less2/include/toolbar.less index 18599951c..118fa8288 100644 --- a/customize.dist/src/less2/include/toolbar.less +++ b/customize.dist/src/less2/include/toolbar.less @@ -363,12 +363,14 @@ * { outline-width: 0; &:focus { - outline-width: 0; + outline-width: 1rem; + // color shows on chrome/edge, but not firefox + outline-color: grey; // XXX temporary color to change } } box-sizing: border-box; - padding: 0px; + padding: 0; display: flex; flex-wrap: wrap; justify-content: space-between; @@ -1219,3 +1221,4 @@ } } + From 71ec6d50f92c44c4ce9586bf68b082dbac270ff2 Mon Sep 17 00:00:00 2001 From: daria Date: Tue, 5 Sep 2023 15:52:17 +0300 Subject: [PATCH 05/87] `Open Notification panel` can be accessed with the keyboard #1201 --- customize.dist/src/less2/include/drive.less | 6 +++--- www/common/toolbar.js | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/customize.dist/src/less2/include/drive.less b/customize.dist/src/less2/include/drive.less index 4fea4e43a..afb77243e 100644 --- a/customize.dist/src/less2/include/drive.less +++ b/customize.dist/src/less2/include/drive.less @@ -128,9 +128,9 @@ } } - div:focus { - outline: none; - } + //div:focus { + // outline: none; + //} .fa { font-family: FontAwesome; diff --git a/www/common/toolbar.js b/www/common/toolbar.js index 19bb768ca..3ad574b40 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -1068,9 +1068,11 @@ MessengerUI, Messages, Pages) { var createNotifications = function (toolbar, config) { var $notif = toolbar.$top.find('.'+NOTIFICATIONS_CLS).show(); - var openNotifsApp = h('div.cp-notifications-gotoapp', h('p', Messages.openNotificationsApp || "Open notifications App")); - $(openNotifsApp).click(function () { - Common.openURL("/notifications/"); + var openNotifsApp = h('div.cp-notifications-gotoapp',{ tabindex: '0' }, h('p', Messages.openNotificationsApp || "Open notifications App")); + $(openNotifsApp).on('click keypress', function (event) { + if (event.type === 'click' || (event.type === 'keypress' && event.which === 13)) { + Common.openURL("/notifications/"); + } }); var div = h('div.cp-notifications-container', [ h('div.cp-notifications-empty', Messages.notifications_empty) From 154a550b3e9eb93f914b462a971e94db9bee2259 Mon Sep 17 00:00:00 2001 From: daria Date: Tue, 5 Sep 2023 16:04:42 +0300 Subject: [PATCH 06/87] `Allow notifications` can be accessed with the keyboard #1201 --- www/common/toolbar.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/www/common/toolbar.js b/www/common/toolbar.js index 3ad574b40..98d4531f6 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -1082,15 +1082,18 @@ MessengerUI, Messages, Pages) { var metadataMgr = config.metadataMgr; var privateData = metadataMgr.getPrivateData(); if (!privateData.notifications) { - var allowNotif = h('div.cp-notifications-gotoapp', h('p', Messages.allowNotifications)); + var allowNotif = h('div.cp-notifications-gotoapp',{ tabindex: '0' }, h('p', Messages.allowNotifications)); pads_options.unshift(h("hr")); pads_options.unshift(allowNotif); - var $allow = $(allowNotif).click(function () { - Common.getSframeChannel().event('Q_ASK_NOTIFICATION', null, function (e, allow) { - if (!allow) { return; } - $(allowNotif).remove(); - }); + $(allowNotif).on('click keypress', function (event) { + if (event.type === 'click' || (event.type === 'keypress' && event.which === 13)) { + Common.getSframeChannel().event('Q_ASK_NOTIFICATION', null, function (e, allow) { + if (!allow) { return; } + $(allowNotif).remove(); + }); + } }); + var onChange = function () { var privateData = metadataMgr.getPrivateData(); if (!privateData.notifications) { return; } From c8c46d11985a0e0e316de51e05fa86996704a62c Mon Sep 17 00:00:00 2001 From: daria Date: Tue, 5 Sep 2023 16:36:12 +0300 Subject: [PATCH 07/87] notifications can be accessed with the keyboard #1201 --- www/common/sframe-common-mailbox.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/www/common/sframe-common-mailbox.js b/www/common/sframe-common-mailbox.js index 4b9fd9e85..625fc2f07 100644 --- a/www/common/sframe-common-mailbox.js +++ b/www/common/sframe-common-mailbox.js @@ -85,13 +85,17 @@ define([ }); } var order = -Math.floor((Util.find(data, ['content', 'msg', 'ctime']) || 0) / 1000); + const tabIndexValue = data.content.isDismissible ? undefined : '0'; notif = h('div.cp-notification', { style: 'order:'+order+';', 'data-hash': data.content.hash }, [ avatar, - h('div.cp-notification-content', - h('p', formatData(data))) + h('div.cp-notification-content', { + tabindex: tabIndexValue + }, [ + h('p', formatData(data)) + ]) ]); if (typeof(data.content.getFormatText) === "function") { @@ -108,16 +112,24 @@ define([ } if (data.content.isClickable) { - $(notif).find('.cp-notification-content').addClass("cp-clickable") - .click(data.content.handler); + $(notif).find('.cp-notification-content').addClass("cp-clickable").on('click keypress', function (event) { + if (event.type === 'click' || (event.type === 'keypress' && event.which === 13)) { + data.content.handler(); + } + }); } if (data.content.isDismissible) { var dismissIcon = h('span.fa.fa-times'); var dismiss = h('div.cp-notification-dismiss', { - title: Messages.notifications_dismiss + title: Messages.notifications_dismiss, + tabindex: '0' }, dismissIcon); $(dismiss).addClass("cp-clickable") - .click(data.content.dismissHandler); + .on('click keypress', function (event) { + if (event.type === 'click' || (event.type === 'keypress' && event.which === 13)) { + data.content.dismissHandler(); + } + }); $(notif).append(dismiss); } return notif; From dfa2da23071cd618ebff8b64b577b8124af36519 Mon Sep 17 00:00:00 2001 From: daria Date: Thu, 14 Sep 2023 15:26:27 +0300 Subject: [PATCH 08/87] changed `div` to `ul` #1192 --- www/common/drive-ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 11908cf38..0cc70ed12 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -3452,7 +3452,7 @@ define([ // Create the ghost icon to add pads/folders var createNewPadIcons = function ($block, isInRoot) { - var $container = $('
'); + var $container = $('