From ffca6417a8d6219d58356dca32c20332a0b38db2 Mon Sep 17 00:00:00 2001 From: ClemDee <clement.desableau@xwiki.com> Date: Mon, 3 Jun 2019 11:12:26 +0200 Subject: [PATCH 1/8] Add path feedback on hover --- www/drive/app-drive.less | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/www/drive/app-drive.less b/www/drive/app-drive.less index 3554306e8..421950730 100644 --- a/www/drive/app-drive.less +++ b/www/drive/app-drive.less @@ -874,17 +874,24 @@ font-size: @colortheme_app-font-size; padding: 0 5px; border: 0; - background: darken(@colortheme_drive-bg, 10%); + background: darken(@colortheme_drive-bg, 7%); color: @colortheme_drive-color; box-sizing: border-box; transition: all 0.15s; &.cp-app-drive-path-separator { color: #ccc; } - &.cp-app-drive-path-lickable { - cursor: pointer; - &:hover { - background: darken(@colortheme_drive-bg, 15%); + &:hover { + &:not(.cp-app-drive-path-separator) { + background-color: darken(@colortheme_drive-bg, 15%); + text-decoration: underline; + cursor: pointer; + } + & ~ .cp-app-drive-path-element { + background-color: darken(@colortheme_drive-bg, 15%); + } + & ~ .cp-app-drive-path-element:not(.cp-app-drive-path-separator) { + text-decoration: underline; } } } From 4017dd7db9f0ba522a6d38edb88c6b8ae3dd2c0c Mon Sep 17 00:00:00 2001 From: ClemDee <clement.desableau@xwiki.com> Date: Mon, 3 Jun 2019 11:37:28 +0200 Subject: [PATCH 2/8] Set cursor to pointer when hovering toolbar button --- customize.dist/src/less2/include/dropdown.less | 1 - customize.dist/src/less2/include/toolbar.less | 4 ---- 2 files changed, 5 deletions(-) diff --git a/customize.dist/src/less2/include/dropdown.less b/customize.dist/src/less2/include/dropdown.less index e937142e3..7c316a33a 100644 --- a/customize.dist/src/less2/include/dropdown.less +++ b/customize.dist/src/less2/include/dropdown.less @@ -22,7 +22,6 @@ } * { .tools_unselectable(); - cursor: default; } } diff --git a/customize.dist/src/less2/include/toolbar.less b/customize.dist/src/less2/include/toolbar.less index aa0f9c6f5..ff588ff77 100644 --- a/customize.dist/src/less2/include/toolbar.less +++ b/customize.dist/src/less2/include/toolbar.less @@ -909,9 +909,6 @@ } button { position: relative; - &.fa-bell-o { - cursor: default; - } .cp-dropdown-button-title { position: absolute; bottom: 0; @@ -998,7 +995,6 @@ span { text-align: center; width: 100%; - cursor: default; font-size: 32px; display: inline-flex; justify-content: center; From 0c66c194664bf818d52749fe024b4ece4a54f0d0 Mon Sep 17 00:00:00 2001 From: ClemDee <clement.desableau@xwiki.com> Date: Wed, 5 Jun 2019 10:36:58 +0200 Subject: [PATCH 3/8] Add pathname collapse for long path in drive --- www/drive/app-drive.less | 71 ++++++++++++++++++++++++++-------------- www/drive/inner.js | 71 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 114 insertions(+), 28 deletions(-) diff --git a/www/drive/app-drive.less b/www/drive/app-drive.less index 421950730..2abda3f70 100644 --- a/www/drive/app-drive.less +++ b/www/drive/app-drive.less @@ -861,37 +861,58 @@ width: auto; overflow: hidden; white-space: nowrap; - display: flex; - flex-flow: row-reverse; flex-shrink: 1; min-width: 50px; max-width: 100%; text-align: left; - .cp-app-drive-path-element { - display: inline-block; - height: @variables_bar-height; - line-height: @variables_bar-height; - font-size: @colortheme_app-font-size; - padding: 0 5px; - border: 0; - background: darken(@colortheme_drive-bg, 7%); - color: @colortheme_drive-color; - box-sizing: border-box; - transition: all 0.15s; - &.cp-app-drive-path-separator { - color: #ccc; - } - &:hover { - &:not(.cp-app-drive-path-separator) { - background-color: darken(@colortheme_drive-bg, 15%); - text-decoration: underline; - cursor: pointer; + display: flex; + flex-direction: row; + + .cp-app-drive-path-inner { + display: flex; + flex-flow: row-reverse; + flex-grow: 1; + + .cp-app-drive-path-element { + display: inline-block; + flex-shrink: 0; + max-width: 100%; + height: @variables_bar-height; + line-height: @variables_bar-height; + font-size: @colortheme_app-font-size; + padding: 0 5px; + border: 0; + background: darken(@colortheme_drive-bg, 7%); + color: @colortheme_drive-color; + box-sizing: border-box; + overflow: hidden; + text-overflow: ellipsis; + transition: all 0.15s; + + &:first-child { + flex-shrink: 1; } - & ~ .cp-app-drive-path-element { - background-color: darken(@colortheme_drive-bg, 15%); + + &.cp-app-drive-path-separator { + color: #ccc; } - & ~ .cp-app-drive-path-element:not(.cp-app-drive-path-separator) { - text-decoration: underline; + + &.cp-app-drive-path-collapse { + position: relative; + } + + &:hover { + &:not(.cp-app-drive-path-separator) { + background-color: darken(@colortheme_drive-bg, 15%); + text-decoration: underline; + cursor: pointer; + } + & ~ .cp-app-drive-path-element { + background-color: darken(@colortheme_drive-bg, 15%); + } + & ~ .cp-app-drive-path-element:not(.cp-app-drive-path-separator) { + text-decoration: underline; + } } } } diff --git a/www/drive/inner.js b/www/drive/inner.js index 43b351690..ae1d8350f 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -1610,6 +1610,60 @@ define([ } return title; }; */ + + var drivePathOverflowing = function () { + var $container = $(".cp-app-drive-path"); + if ($container.length) { + $container.css("overflow", "hidden"); + var overflown = $container[0].scrollWidth > $container[0].clientWidth; + $container.css("overflow", ""); + return overflown; + } + }; + + var collapseDrivePath = function () { + var $container = $(".cp-app-drive-path-inner"); + var $spanCollapse = $(".cp-app-drive-path-collapse"); + $spanCollapse.css("display", "none"); + + var $pathElements = $container.find(".cp-app-drive-path-element"); + $pathElements.not($spanCollapse).css("display", ""); + + if (drivePathOverflowing()) { + var collapseLevel = 0; + var removeOverflowElement = function () { + if (drivePathOverflowing()) { + if ($pathElements.length === 3) { + return false; + } + collapseLevel++; + if ($($pathElements.get(-2)).is(".cp-app-drive-path-separator")) { + $($pathElements.get(-2)).css("display", "none"); + $pathElements = $pathElements.not($pathElements.get(-2)); + } + $($pathElements.get(-2)).css("display", "none"); + $pathElements = $pathElements.not($pathElements.get(-2)); + return true; + } + }; + + while (removeOverflowElement()) {} + $spanCollapse.css("display", ""); + removeOverflowElement(); + + $spanCollapse.attr("title", getLastOpenedFolder().slice(0, collapseLevel).join(" / ").replace("root", ROOT_NAME)); + $spanCollapse[0].onclick = function () { + APP.displayDirectory(getLastOpenedFolder().slice(0, collapseLevel)); + }; + } + }; + + window.addEventListener("resize", collapseDrivePath); + var treeResizeObserver = new MutationObserver(collapseDrivePath); + treeResizeObserver.observe($("#cp-app-drive-tree")[0], {"attributes": true}); + var toolbarButtonAdditionObserver = new MutationObserver(collapseDrivePath); + $(function () { toolbarButtonAdditionObserver.observe($("#cp-app-drive-toolbar")[0], {"childList": true, "subtree": true}); }); + var getPrettyName = function (name) { var pName; @@ -1639,6 +1693,9 @@ define([ var el = isVirtual ? undefined : manager.find(path); path = path[0] === SEARCH ? path.slice(0,1) : path; + var $inner = $('<div>', {'class': 'cp-app-drive-path-inner'}); + $container.prepend($inner); + var skipNext = false; // When encountering a shared folder, skip a key in the path path.forEach(function (p, idx) { if (skipNext) { skipNext = false; return; } @@ -1671,13 +1728,21 @@ define([ var $span2 = $('<span>', { 'class': 'cp-app-drive-path-element cp-app-drive-path-separator' }).text(' / '); - $container.prepend($span2); + $inner.prepend($span2); } - - $span.text(name).prependTo($container); + $span.text(name).prependTo($inner); }); + + var $spanCollapse = $('<span>', { + 'class': 'cp-app-drive-path-element cp-app-drive-path-collapse' + }).text(' ... '); + $inner.append($spanCollapse); + + collapseDrivePath(); }; + + var createInfoBox = function (path) { var $box = $('<div>', {'class': 'cp-app-drive-content-info-box'}); var msg; From a1163798decb46a717a5f9032fdb9f4ccddaa2a3 Mon Sep 17 00:00:00 2001 From: ClemDee <clement.desableau@xwiki.com> Date: Wed, 5 Jun 2019 12:00:05 +0200 Subject: [PATCH 4/8] History button now close history panel when it is open in drive --- www/common/common-ui-elements.js | 19 +++++++++++++------ www/drive/app-drive.less | 3 +++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 68921594b..463108671 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -791,16 +791,23 @@ define([ button = $('<span>'); break; } + var active = $(".cp-toolbar-history:visible").length !== 0; button = $('<button>', { - title: Messages.historyButton, + title: active ? Messages.history_closeTitle : Messages.historyButton, 'class': "fa fa-history cp-toolbar-icon-history", }).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.historyText)); + button.toggleClass("active", active); if (data.histConfig) { - button - .click(common.prepareFeedback(type)) - .on('click', function () { - common.getHistory(data.histConfig); - }); + if (active) { + button.click(function () { $(".cp-toolbar-history-close").trigger("click"); }); + } + else { + button + .click(common.prepareFeedback(type)) + .on('click', function () { + common.getHistory(data.histConfig); + }); + } } break; case 'more': diff --git a/www/drive/app-drive.less b/www/drive/app-drive.less index 2abda3f70..b329b5154 100644 --- a/www/drive/app-drive.less +++ b/www/drive/app-drive.less @@ -770,6 +770,9 @@ .cp-toolbar-icon-history { float: right; + &.active { + background-color: rgba(0, 0, 255, 0.2); + } .cp-toolbar-drawer-element { display: none; } From 16477bd15b610631ff0abf581294930c39265974 Mon Sep 17 00:00:00 2001 From: ClemDee <clement.desableau@xwiki.com> Date: Thu, 6 Jun 2019 11:41:35 +0200 Subject: [PATCH 5/8] Fix toolbar collapse in drive --- www/drive/inner.js | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index ae1d8350f..b6c2a51c4 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -1610,6 +1610,25 @@ define([ } return title; }; */ + + + var getPrettyName = function (name) { + var pName; + switch (name) { + case ROOT: pName = ROOT_NAME; break; + case TRASH: pName = TRASH_NAME; break; + case TEMPLATE: pName = TEMPLATE_NAME; break; + case FILES_DATA: pName = FILES_DATA_NAME; break; + case SEARCH: pName = SEARCH_NAME; break; + case RECENT: pName = RECENT_NAME; break; + case OWNED: pName = OWNED_NAME; break; + case TAGS: pName = TAGS_NAME; break; + case SHARED_FOLDER: pName = SHARED_FOLDER_NAME; break; + default: pName = name; + } + return pName; + }; + var drivePathOverflowing = function () { var $container = $(".cp-app-drive-path"); @@ -1629,11 +1648,11 @@ define([ var $pathElements = $container.find(".cp-app-drive-path-element"); $pathElements.not($spanCollapse).css("display", ""); - if (drivePathOverflowing()) { + if (currentPath.length > 1 && drivePathOverflowing()) { var collapseLevel = 0; var removeOverflowElement = function () { if (drivePathOverflowing()) { - if ($pathElements.length === 3) { + if ($pathElements.length <= 3) { return false; } collapseLevel++; @@ -1647,11 +1666,13 @@ define([ } }; - while (removeOverflowElement()) {} + currentPath.every(removeOverflowElement); $spanCollapse.css("display", ""); removeOverflowElement(); - $spanCollapse.attr("title", getLastOpenedFolder().slice(0, collapseLevel).join(" / ").replace("root", ROOT_NAME)); + var tipPath = currentPath.slice(0, collapseLevel); + tipPath[0] = getPrettyName(tipPath[0]); + $spanCollapse.attr("title", tipPath.join(" / ")); $spanCollapse[0].onclick = function () { APP.displayDirectory(getLastOpenedFolder().slice(0, collapseLevel)); }; @@ -1665,23 +1686,6 @@ define([ $(function () { toolbarButtonAdditionObserver.observe($("#cp-app-drive-toolbar")[0], {"childList": true, "subtree": true}); }); - var getPrettyName = function (name) { - var pName; - switch (name) { - case ROOT: pName = ROOT_NAME; break; - case TRASH: pName = TRASH_NAME; break; - case TEMPLATE: pName = TEMPLATE_NAME; break; - case FILES_DATA: pName = FILES_DATA_NAME; break; - case SEARCH: pName = SEARCH_NAME; break; - case RECENT: pName = RECENT_NAME; break; - case OWNED: pName = OWNED_NAME; break; - case TAGS: pName = TAGS_NAME; break; - case SHARED_FOLDER: pName = SHARED_FOLDER_NAME; break; - default: pName = name; - } - return pName; - }; - // Create the title block with the "parent folder" button var createTitle = function ($container, path, noStyle) { if (!path || path.length === 0) { return; } From 639407056a4d8f86ad2b6c2fe05af65f4808fab5 Mon Sep 17 00:00:00 2001 From: ClemDee <clement.desableau@xwiki.com> Date: Fri, 7 Jun 2019 10:55:54 +0200 Subject: [PATCH 6/8] Fix toolbar collapse for shared folders --- www/drive/inner.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index b6c2a51c4..a0c5d6921 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -1648,7 +1648,8 @@ define([ var $pathElements = $container.find(".cp-app-drive-path-element"); $pathElements.not($spanCollapse).css("display", ""); - if (currentPath.length > 1 && drivePathOverflowing()) { + var oneFolder = currentPath.length > 1 + (currentPath[0] === SHARED_FOLDER); + if (oneFolder && drivePathOverflowing()) { var collapseLevel = 0; var removeOverflowElement = function () { if (drivePathOverflowing()) { From 26ef1e5769ae504677a9824ac7d7dd6c4fa39263 Mon Sep 17 00:00:00 2001 From: yflory <yann.flory@xwiki.com> Date: Fri, 7 Jun 2019 11:05:15 +0200 Subject: [PATCH 7/8] Fix infinite loop when trying to display an invalid category in the drive --- www/drive/inner.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index b6c2a51c4..7302f9bd1 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -2697,25 +2697,29 @@ define([ // NOTE: Elements in the trash are not using the same storage structure as the others var _displayDirectory = function (path, force) { APP.hideMenu(); + if (!APP.editable) { debug("Read-only mode"); } if (!appStatus.isReady && !force) { return; } - // Only Trash and Root are available in not-owned files manager - if (!path || displayedCategories.indexOf(path[0]) === -1) { - log(Messages.fm_categoryError); - currentPath = [ROOT]; - _displayDirectory(currentPath); - return; + if (!path || path.length === 0) { + // Only Trash and Root are available in not-owned files manager + if (!path || displayedCategories.indexOf(path[0]) === -1) { + log(Messages.fm_categoryError); + } + if (!APP.loggedIn && APP.newSharedFolder) { + // ANON_SHARED_FOLDER + path = [SHARED_FOLDER, ROOT]; + } else { + path = [ROOT]; + } } + appStatus.ready(false); currentPath = path; var s = $content.scrollTop() || 0; $content.html(""); sel.$selectBox = $('<div>', {'class': 'cp-app-drive-content-select-box'}) .appendTo($content); - if (!path || path.length === 0) { - path = [ROOT]; - } var isInRoot = manager.isPathIn(path, [ROOT]); var inTrash = manager.isPathIn(path, [TRASH]); var isTrashRoot = manager.comparePath(path, [TRASH]); @@ -2726,6 +2730,10 @@ define([ var isTags = path[0] === TAGS; // ANON_SHARED_FOLDER var isSharedFolder = path[0] === SHARED_FOLDER && APP.newSharedFolder; + if (isSharedFolder && path.length < 2) { + path = [SHARED_FOLDER, 'root']; + currentPath = path; + } var root = isVirtual ? undefined : manager.find(path); if (manager.isSharedFolder(root)) { From 473cbcd1b68cf493112fc90855e7191307a01cfe Mon Sep 17 00:00:00 2001 From: yflory <yann.flory@xwiki.com> Date: Fri, 7 Jun 2019 11:13:46 +0200 Subject: [PATCH 8/8] Fix drive toolbar new line bug --- www/drive/app-drive.less | 1 + 1 file changed, 1 insertion(+) diff --git a/www/drive/app-drive.less b/www/drive/app-drive.less index b329b5154..9f275cd8e 100644 --- a/www/drive/app-drive.less +++ b/www/drive/app-drive.less @@ -823,6 +823,7 @@ padding-left: 10px; } .cp-app-drive-toolbar-leftside { + flex-shrink: 0; & > span { height: 100%; margin: 0;