From 21300bb0305080c7cf3642aab3d08c2b35cddca8 Mon Sep 17 00:00:00 2001 From: ClemDee Date: Tue, 11 Jun 2019 17:40:13 +0200 Subject: [PATCH 1/7] Add temporary folder custom color in drive --- .jshintignore | 2 +- www/{kanban => common}/jscolor.js | 0 www/common/translations/messages.json | 1 + www/drive/inner.js | 49 +++++++++++++++++++++++++-- www/kanban/inner.js | 4 +-- 5 files changed, 51 insertions(+), 5 deletions(-) rename www/{kanban => common}/jscolor.js (100%) diff --git a/.jshintignore b/.jshintignore index d243f9260..3dce1dfc9 100644 --- a/.jshintignore +++ b/.jshintignore @@ -21,7 +21,7 @@ www/pad/mediatag-plugin-dialog.js www/pad/disable-base64.js www/kanban/jkanban.js -www/kanban/jscolor.js +www/common/jscolor.js www/common/media-tag-nacl.min.js diff --git a/www/kanban/jscolor.js b/www/common/jscolor.js similarity index 100% rename from www/kanban/jscolor.js rename to www/common/jscolor.js diff --git a/www/common/translations/messages.json b/www/common/translations/messages.json index 693f65053..c40472c58 100644 --- a/www/common/translations/messages.json +++ b/www/common/translations/messages.json @@ -385,6 +385,7 @@ "fc_newfolder": "New folder", "fc_newsharedfolder": "New shared folder", "fc_rename": "Rename", + "fc_color": "Change color", "fc_open": "Open", "fc_open_ro": "Open (read-only)", "fc_delete": "Move to trash", diff --git a/www/drive/inner.js b/www/drive/inner.js index 43b351690..645519691 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -17,6 +17,8 @@ define([ '/bower_components/chainpad-listmap/chainpad-listmap.js', '/customize/messages.js', + '/common/jscolor.js', + 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'less!/drive/app-drive.less', @@ -78,6 +80,7 @@ define([ var faShared = 'fa-shhare-alt'; var faReadOnly = 'fa-eye'; var faRename = 'fa-pencil'; + var faColor = 'fa-palette'; var faTrash = 'fa-trash'; var faDelete = 'fa-eraser'; var faProperties = 'fa-database'; @@ -329,6 +332,10 @@ define([ 'tabindex': '-1', 'data-icon': faRename, }, Messages.fc_rename)), + h('li', h('a.cp-app-drive-context-color.dropdown-item.cp-app-drive-context-editable', { + 'tabindex': '-1', + 'data-icon': faColor, + }, Messages.fc_color)), h('li', h('a.cp-app-drive-context-delete.dropdown-item.cp-app-drive-context-editable', { 'tabindex': '-1', 'data-icon': faTrash, @@ -814,6 +821,32 @@ define([ },0); }; + + var pickFolderColor = function ($element, currentColor, cb) { + var jscolorL; + $element[0]._jscLinkedInstance = undefined; + var onchange = function (color) { + cb("#" + color.toString()); + }; + if (APP.colorPicker) { APP.colorPicker.hide(); } + jscolorL = new window.jscolor($element[0], {showOnClick: false, onFineChange: onchange, valueElement:undefined, styleElement:undefined}); + APP.colorPicker = jscolorL; + jscolorL.fromString(currentColor); + jscolorL.show(); + }; + + var getFolderColor = function ($element) { + if ($element.length === 0) { return; } + return $element.find(".cp-app-drive-icon-folder").css("color") || "#000"; + }; + + var setFolderColor = function ($element, color) { + if ($element.length === 0) { return; } + $element.find(".cp-app-drive-icon-folder").css("color", color); + // TODO : save color in folder metadata + }; + + var filterContextMenu = function (type, paths) { if (!paths || paths.length === 0) { logError('no paths'); } @@ -860,6 +893,7 @@ define([ } if ($element.is('.cp-app-drive-element-file')) { // No folder in files + hide.push('color'); hide.push('newfolder'); if ($element.is('.cp-app-drive-element-readonly')) { hide.push('open'); // Remove open 'edit' mode @@ -932,7 +966,7 @@ define([ show = ['newfolder', 'newsharedfolder', 'newdoc']; break; case 'tree': - show = ['open', 'openro', 'download', 'share', 'rename', 'delete', 'deleteowned', 'removesf', + show = ['open', 'openro', 'download', 'share', 'rename', 'color', 'delete', 'deleteowned', 'removesf', 'newfolder', 'properties', 'hashtag']; break; case 'default': @@ -1376,6 +1410,9 @@ define([ $element.on('mousedown', function (e) { e.stopPropagation(); + if (APP.colorPicker) { + APP.colorPicker.hide(); + } }); // Add drop handlers if we are not in the trash and if the element is a folder @@ -2333,7 +2370,7 @@ define([ var roClass = typeof(ro) === 'undefined' ? ' cp-app-drive-element-noreadonly' : ro ? ' cp-app-drive-element-readonly' : ''; var $element = $('
  • ', { - 'class': 'cp-app-drive-element cp-app-drive-element-row' + roClass + 'class': 'cp-app-drive-element cp-app-drive-element-row' + roClass }); $element.prepend($icon).dblclick(function () { openFile(id); @@ -3188,6 +3225,14 @@ define([ if (paths.length !== 1) { return; } displayRenameInput(paths[0].element, paths[0].path); } + if ($(this).hasClass("cp-app-drive-context-color")) { + var currentColor = getFolderColor(paths[0].element); + pickFolderColor(paths[0].element, currentColor, function (color) { + paths.forEach(function (p) { + setFolderColor(p.element, color); + }); + }); + } else if($(this).hasClass("cp-app-drive-context-delete")) { if (!APP.loggedIn) { return void deletePaths(paths); diff --git a/www/kanban/inner.js b/www/kanban/inner.js index 279e30362..29a4d9c88 100644 --- a/www/kanban/inner.js +++ b/www/kanban/inner.js @@ -10,7 +10,7 @@ define([ '/common/modes.js', '/customize/messages.js', '/kanban/jkanban.js', - '/kanban/jscolor.js', + '/common/jscolor.js', 'css!/kanban/jkanban.css', 'less!/kanban/app-kanban.less' @@ -281,7 +281,7 @@ define([ //return; } kanban.inEditMode = true; - // create a form to enter element + // create a form to enter element var boardId = $(el.parentNode.parentNode).attr("data-id"); var $item = $('
    ', {'class': 'kanban-item'}); var $input = getInput().val(name).appendTo($item); From e9598de655056ce39aaac1ce665fcbdfe92514ab Mon Sep 17 00:00:00 2001 From: ClemDee Date: Tue, 18 Jun 2019 10:44:27 +0200 Subject: [PATCH 2/7] Add folder metadata and folder color --- www/common/outer/async-store.js | 1 + www/common/outer/userObject.js | 22 ++++++++++++++++++ www/common/proxy-manager.js | 40 +++++++++++++++++++++++++++++++++ www/common/userObject.js | 23 ++++++++++++++++++- www/drive/inner.js | 24 ++++++++++++++------ 5 files changed, 102 insertions(+), 8 deletions(-) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 39aac9b54..a775638e8 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1622,6 +1622,7 @@ define([ }; if (!proxy.settings) { proxy.settings = {}; } var manager = store.manager = ProxyManager.create(proxy.drive, { + onSync: onSync, edPublic: proxy.edPublic, pin: pin, unpin: unpin, diff --git a/www/common/outer/userObject.js b/www/common/outer/userObject.js index 12771fd92..e67dd5f01 100644 --- a/www/common/outer/userObject.js +++ b/www/common/outer/userObject.js @@ -375,6 +375,19 @@ define([ } }; + exp.setFolderData = function (path, key, value, cb) { + var folder = exp.find(path); + if (!exp.isFolder(folder) || exp.isSharedFolder(folder)) { return; } + if (!exp.hasFolderData(folder)) { + var hashKey = "000" + Hash.createChannelId().slice(0, -3); + folder[hashKey] = { + metadata: true + }; + } + exp.getFolderData(folder)[key] = value; + cb(); + }; + /** * INTEGRITY CHECK */ @@ -493,7 +506,16 @@ define([ var fixRoot = function (elem) { if (typeof(files[ROOT]) !== "object") { debug("ROOT was not an object"); files[ROOT] = {}; } var element = elem || files[ROOT]; + var nbMetadataFolders = 0; for (var el in element) { + if (exp.isFolderData(element[el])) { + if (nbMetadataFolders !== 0) { + debug("Multiple metadata files in folder"); + delete element[el]; + } + nbMetadataFolders++; + continue; + } if (!exp.isFile(element[el], true) && !exp.isFolder(element[el])) { debug("An element in ROOT was not a folder nor a file. ", element[el]); delete element[el]; diff --git a/www/common/proxy-manager.js b/www/common/proxy-manager.js index a933da776..017a403bb 100644 --- a/www/common/proxy-manager.js +++ b/www/common/proxy-manager.js @@ -567,6 +567,22 @@ define([ } resolved.userObject.rename(resolved.path, data.newName, cb); }; + var _setFolderData = function (Env, data, cb) { + data = data || {}; + var resolved = _resolvePath(Env, data.path); + if (!resolved || !resolved.userObject) { return void cb({error: 'E_NOTFOUND'}); } + if (!resolved.id) { + var el = Env.user.userObject.find(resolved.path); + if (Env.user.userObject.isSharedFolder(el) && Env.folders[el]) { + Env.user.proxy[UserObject.SHARED_FOLDERS][el][data.key] = data.value; + return void Env.onSync(cb); + } + } + resolved.userObject.setFolderData(resolved.path, data.key, data.value, function () { + Env.onSync(cb); + }); + + }; var onCommand = function (Env, cmdData, cb) { var cmd = cmdData.cmd; var data = cmdData.data || {}; @@ -585,6 +601,8 @@ define([ _emptyTrash(Env, data, cb); break; case 'rename': _rename(Env, data, cb); break; + case 'setFolderData': + _setFolderData(Env, data, cb); break; default: cb(); } @@ -799,6 +817,7 @@ define([ var Env = { pinPads: data.pin, unpinPads: data.unpin, + onSync: data.onSync, loadSharedFolder: data.loadSharedFolder, cfg: uoConfig, edPublic: data.edPublic, @@ -905,6 +924,12 @@ define([ } }, cb); }; + var setFolderDataInner = function (Env, data, cb) { + return void Env.sframeChan.query("Q_DRIVE_USEROBJECT", { + cmd: "setFolderData", + data: data + }, cb); + }; /* Tools */ @@ -989,6 +1014,19 @@ define([ return obj; }; + var getFolderData = function (Env, path) { + var resolved = _resolvePath(Env, path); + if (!resolved || !resolved.userObject) { return {}; } + if (!resolved.id) { + var el = Env.user.userObject.find(resolved.path); + if (Env.user.userObject.isSharedFolder(el)) { + return getSharedFolderData(Env, el); + } + } + var folder = resolved.userObject.find(resolved.path); + return resolved.userObject.getFolderData(folder); + }; + var isInSharedFolder = _isInSharedFolder; /* Generic: doesn't need access to a proxy */ @@ -1068,6 +1106,7 @@ define([ addSharedFolder: callWithEnv(addSharedFolderInner), delete: callWithEnv(deleteInner), restore: callWithEnv(restoreInner), + setFolderData: callWithEnv(setFolderDataInner), // Tools getFileData: callWithEnv(getFileData), find: callWithEnv(find), @@ -1081,6 +1120,7 @@ define([ findFile: callWithEnv(findFile), findChannels: callWithEnv(findChannels), getSharedFolderData: callWithEnv(getSharedFolderData), + getFolderData: callWithEnv(getFolderData), isInSharedFolder: callWithEnv(isInSharedFolder), getUserObjectPath: callWithEnv(getUserObjectPath), isDuplicateOwned: callWithEnv(isDuplicateOwned), diff --git a/www/common/userObject.js b/www/common/userObject.js index 1a2229d40..5cf532438 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -91,6 +91,9 @@ define([ ((typeof(files[OLD_FILES_DATA]) !== "undefined" || allowStr) && typeof(element) === "string"); }; + var isFolderData = exp.isFolderData = function (element) { + return typeof(element) === "object" && element.metadata === true; + }; exp.isReadOnlyFile = function (element) { if (!isFile(element)) { return false; } @@ -101,6 +104,7 @@ define([ }; var isFolder = exp.isFolder = function (element) { + if (isFolderData(element)) { return false; } return typeof(element) === "object" || isSharedFolder(element); }; exp.isFolderEmpty = function (element) { @@ -144,12 +148,29 @@ define([ return file; }; + exp.hasFolderData = function (folder) { + for (var el in folder) { + if(isFolderData(folder[el])) { + return true; + } + } + }; + // Get data from AllFiles (Cryptpad_RECENTPADS) var getFileData = exp.getFileData = function (file) { if (!file) { return; } return files[FILES_DATA][file] || {}; }; + exp.getFolderData = function (folder) { + for (var el in folder) { + if(isFolderData(folder[el])) { + return folder[el]; + } + } + return {}; + }; + // Data from filesData var getTitle = exp.getTitle = function (file, type) { if (isSharedFolder(file)) { @@ -231,7 +252,7 @@ define([ for (var e in root) { if (isFile(root[e]) || isSharedFolder(root[e])) { if(arr.indexOf(root[e]) === -1) { arr.push(root[e]); } - } else { + } else if (!isFolderData(root[e])) { getFilesRecursively(root[e], arr); } } diff --git a/www/drive/inner.js b/www/drive/inner.js index 645519691..398bc12de 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -835,15 +835,19 @@ define([ jscolorL.show(); }; - var getFolderColor = function ($element) { - if ($element.length === 0) { return; } - return $element.find(".cp-app-drive-icon-folder").css("color") || "#000"; + var getFolderColor = function (path) { + if (path.length === 0) { return; } + return manager.getFolderData(path).color || "#000"; }; - var setFolderColor = function ($element, color) { + var setFolderColor = function ($element, path, color) { if ($element.length === 0) { return; } $element.find(".cp-app-drive-icon-folder").css("color", color); - // TODO : save color in folder metadata + manager.setFolderData({ + path: path, + key: "color", + value: color + }, function () {}); }; @@ -877,6 +881,7 @@ define([ // Can't rename or delete root elements hide.push('delete'); hide.push('rename'); + hide.push('color'); } if (!$element.is('.cp-app-drive-element-owned')) { hide.push('deleteowned'); @@ -1578,9 +1583,11 @@ define([ if (isSharedFolder) { liClass = 'cp-app-drive-element-folder cp-app-drive-element'; $icon = $sharedFolderIcon.clone(); + $icon.css("color", getFolderColor(path.concat(elPath))); } else if (isFolder) { liClass = 'cp-app-drive-element-folder cp-app-drive-element'; $icon = manager.isFolderEmpty(root[key]) ? $folderEmptyIcon.clone() : $folderIcon.clone(); + $icon.css("color", getFolderColor(path.concat(elPath))); } var $element = $('
  • ', { draggable: true, @@ -2871,6 +2878,7 @@ define([ var createTreeElement = function (name, $icon, path, draggable, droppable, collapsable, active, isSharedFolder) { var $name = $('', { 'class': 'cp-app-drive-element' }).text(name); + $icon.css("color", isSharedFolder ? getFolderColor(path.slice(0, -1)) : getFolderColor(path)); var $collapse; if (collapsable) { $collapse = $expandIcon.clone(); @@ -2930,6 +2938,7 @@ define([ var $rootIcon = manager.isFolderEmpty(files[ROOT]) ? (isRootOpened ? $folderOpenedEmptyIcon : $folderEmptyIcon) : (isRootOpened ? $folderOpenedIcon : $folderIcon); + $rootIcon.css("color", getFolderColor([ROOT])); // XXX allow t omodify color of root ? var $rootElement = createTreeElement(ROOT_NAME, $rootIcon.clone(), [ROOT], false, true, true, isRootOpened); if (!manager.hasSubfolder(root)) { $rootElement.find('.cp-app-drive-icon-expcol').css('visibility', 'hidden'); @@ -3226,11 +3235,12 @@ define([ displayRenameInput(paths[0].element, paths[0].path); } if ($(this).hasClass("cp-app-drive-context-color")) { - var currentColor = getFolderColor(paths[0].element); + var currentColor = getFolderColor(paths[0].path); pickFolderColor(paths[0].element, currentColor, function (color) { paths.forEach(function (p) { - setFolderColor(p.element, color); + setFolderColor(p.element, p.path, color); }); + refresh(); // makes imgs overview flicker in drive }); } else if($(this).hasClass("cp-app-drive-context-delete")) { From 1901127534f7a73c015ce9786646f71178604baf Mon Sep 17 00:00:00 2001 From: ClemDee Date: Tue, 18 Jun 2019 16:55:42 +0200 Subject: [PATCH 3/7] Fix palette icon of context menu in drive --- www/drive/inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index 2d39a5e31..b2ddb6355 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -80,7 +80,7 @@ define([ var faShared = 'fa-shhare-alt'; var faReadOnly = 'fa-eye'; var faRename = 'fa-pencil'; - var faColor = 'fa-palette'; + var faColor = 'cptools-palette'; var faTrash = 'fa-trash'; var faDelete = 'fa-eraser'; var faProperties = 'fa-database'; From e0a79928f496cceb2f99bb95237c9f7548213426 Mon Sep 17 00:00:00 2001 From: ClemDee Date: Wed, 19 Jun 2019 11:47:32 +0200 Subject: [PATCH 4/7] Change color picker to palette --- www/drive/app-drive.less | 68 +++++++++++++++++++++++++++++++++++++--- www/drive/inner.js | 51 +++++++++++++++++++++--------- 2 files changed, 99 insertions(+), 20 deletions(-) diff --git a/www/drive/app-drive.less b/www/drive/app-drive.less index 5bbebe172..41e59983f 100644 --- a/www/drive/app-drive.less +++ b/www/drive/app-drive.less @@ -179,6 +179,64 @@ } } + .cp-app-drive-color-picker { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + align-items: center; + + .cp-app-drive-color-picker-color { + position: relative; + width: 50px; + height: 50px; + margin: 5px; + display: inline-block; + cursor: pointer; + &.cp-app-drive-no-color { + position: relative; + width: 40px; + height: 40px; + margin: 10px; + border: 1px solid #444; + border-radius: 2px; + background-color: white; + overflow: hidden; + &::before { + content: ""; + position: absolute; + top: -1px; left: 0; + width: 200%; + border: 1px solid #666; + transform-origin: top left; + -ms-transform-origin: top left; + transform: rotate(45deg); + -ms-transform: rotate(45deg); + -webkit-transform: rotate(45deg); + } + } + + .cp-app-drive-icon-folder { + position: absolute; + font-size: 50px; + } + + .fa-check { + position: absolute; + top: 40%; left: 35%; + color: transparent; + } + &.cp-app-drive-current-color > .fa-check { + color: white; + } + + } + } + + + + + /* TREE */ @@ -873,7 +931,7 @@ text-align: left; display: flex; flex-direction: row; - + .cp-app-drive-path-inner { display: flex; flex-flow: row-reverse; @@ -894,19 +952,19 @@ overflow: hidden; text-overflow: ellipsis; transition: all 0.15s; - + &:first-child { flex-shrink: 1; } - + &.cp-app-drive-path-separator { color: #ccc; } - + &.cp-app-drive-path-collapse { position: relative; } - + &:hover { &:not(.cp-app-drive-path-separator) { background-color: darken(@colortheme_drive-bg, 15%); diff --git a/www/drive/inner.js b/www/drive/inner.js index b2ddb6355..51ee1d855 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -869,16 +869,41 @@ define([ var pickFolderColor = function ($element, currentColor, cb) { - var jscolorL; - $element[0]._jscLinkedInstance = undefined; - var onchange = function (color) { - cb("#" + color.toString()); - }; - if (APP.colorPicker) { APP.colorPicker.hide(); } - jscolorL = new window.jscolor($element[0], {showOnClick: false, onFineChange: onchange, valueElement:undefined, styleElement:undefined}); - APP.colorPicker = jscolorL; - jscolorL.fromString(currentColor); - jscolorL.show(); + var colors = ["none", "#f23c38", "#ff0073", "#da0eba", "#9d00ac", "#6c19b3", "#4a42b1", "#3d8af0", "#30a0f1", "#1fb9d1", "#009686", "#45b354", "#84c750", "#c6e144", "#faf147", "#fbc423", "#fc9819", "#fd5227", "#775549", "#9c9c9c", "#607a89"]; + var colorsElements = []; + var currentElement = null; + for (var i in colors) { + var element; + if (i === "0") { + element = h("span.cp-app-drive-color-picker-color.cp-app-drive-no-color"); + $(element).on("click", function (e) { + cb(""); + }); + colorsElements.push(element); + } + else { + element = h("span.cp-app-drive-color-picker-color", [ + h("span.cptools-folder.cptools.cp-app-drive-icon-folder.cp-app-drive-content-icon"), + h("span.fa.fa-check") + ]); + $(element).css("color", colors[i]); + if (colors[i] === currentColor) { + currentElement = element; + $(element).addClass("cp-app-drive-current-color"); + } + (function (color, element) { + $(element).on("click", function (e) { + $(currentElement).removeClass("cp-app-drive-current-color"); + currentElement = element; + $(element).addClass("cp-app-drive-current-color"); + cb(color); + }); + })(colors[i], element) + colorsElements.push(element); + } + } + var content = h("div.cp-app-drive-color-picker", colorsElements); + UI.alert(content); }; var getFolderColor = function (path) { @@ -3383,15 +3408,11 @@ define([ } if ($(this).hasClass("cp-app-drive-context-color")) { var currentColor = getFolderColor(paths[0].path); - var to; pickFolderColor(paths[0].element, currentColor, function (color) { paths.forEach(function (p) { setFolderColor(p.element, p.path, color); }); - clearTimeout(to); - to = setTimeout(function () { - refresh(); // makes imgs overview flicker in drive - }, 300); + refresh(); // makes imgs overview flicker in drive }); } else if($(this).hasClass("cp-app-drive-context-delete")) { From 0d3a9b5e40b966a2be2d55873ef073edefdede1d Mon Sep 17 00:00:00 2001 From: ClemDee Date: Wed, 19 Jun 2019 14:21:26 +0200 Subject: [PATCH 5/7] Please jslint --- www/drive/inner.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index 51ee1d855..44c00dcf1 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -872,11 +872,12 @@ define([ var colors = ["none", "#f23c38", "#ff0073", "#da0eba", "#9d00ac", "#6c19b3", "#4a42b1", "#3d8af0", "#30a0f1", "#1fb9d1", "#009686", "#45b354", "#84c750", "#c6e144", "#faf147", "#fbc423", "#fc9819", "#fd5227", "#775549", "#9c9c9c", "#607a89"]; var colorsElements = []; var currentElement = null; - for (var i in colors) { + colors.forEach(function (color, i) { + var element; - if (i === "0") { + if (i === 0) { element = h("span.cp-app-drive-color-picker-color.cp-app-drive-no-color"); - $(element).on("click", function (e) { + $(element).on("click", function () { cb(""); }); colorsElements.push(element); @@ -891,17 +892,15 @@ define([ currentElement = element; $(element).addClass("cp-app-drive-current-color"); } - (function (color, element) { - $(element).on("click", function (e) { - $(currentElement).removeClass("cp-app-drive-current-color"); - currentElement = element; - $(element).addClass("cp-app-drive-current-color"); - cb(color); - }); - })(colors[i], element) + $(element).on("click", function () { + $(currentElement).removeClass("cp-app-drive-current-color"); + currentElement = element; + $(element).addClass("cp-app-drive-current-color"); + cb(color); + }); colorsElements.push(element); } - } + }); var content = h("div.cp-app-drive-color-picker", colorsElements); UI.alert(content); }; From 7bfb62d5aea0fe67f7665f4134e378e334df72da Mon Sep 17 00:00:00 2001 From: ClemDee Date: Wed, 19 Jun 2019 14:35:56 +0200 Subject: [PATCH 6/7] Fix default color check in palette --- www/drive/app-drive.less | 6 +++++- www/drive/inner.js | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/www/drive/app-drive.less b/www/drive/app-drive.less index 41e59983f..6b638aafe 100644 --- a/www/drive/app-drive.less +++ b/www/drive/app-drive.less @@ -207,13 +207,17 @@ position: absolute; top: -1px; left: 0; width: 200%; - border: 1px solid #666; + border: 1px solid #bbb; transform-origin: top left; -ms-transform-origin: top left; transform: rotate(45deg); -ms-transform: rotate(45deg); -webkit-transform: rotate(45deg); } + &.cp-app-drive-current-color > .fa-check { + top: 35%; left: 35%; + color: black; + } } .cp-app-drive-icon-folder { diff --git a/www/drive/inner.js b/www/drive/inner.js index 44c00dcf1..9bc285a0d 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -876,8 +876,17 @@ define([ var element; if (i === 0) { - element = h("span.cp-app-drive-color-picker-color.cp-app-drive-no-color"); + element = h("span.cp-app-drive-color-picker-color.cp-app-drive-no-color", [ + h("span.fa.fa-check") + ]); + if (currentColor === "") { + currentElement = element; + $(element).addClass("cp-app-drive-current-color"); + } $(element).on("click", function () { + $(currentElement).removeClass("cp-app-drive-current-color"); + currentElement = element; + $(element).addClass("cp-app-drive-current-color"); cb(""); }); colorsElements.push(element); @@ -907,7 +916,7 @@ define([ var getFolderColor = function (path) { if (path.length === 0) { return; } - return manager.getFolderData(path).color || "#000"; + return manager.getFolderData(path).color || ""; }; var setFolderColor = function ($element, path, color) { From 4d752c993352c1c7262e4df17c0a0ac0808b4016 Mon Sep 17 00:00:00 2001 From: ClemDee Date: Wed, 19 Jun 2019 15:08:30 +0200 Subject: [PATCH 7/7] Small fixes --- www/drive/inner.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index 9bc285a0d..f7011fa50 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -1509,9 +1509,6 @@ define([ $element.on('mousedown', function (e) { e.stopPropagation(); - if (APP.colorPicker) { - APP.colorPicker.hide(); - } }); // Add drop handlers if we are not in the trash and if the element is a folder @@ -3114,7 +3111,6 @@ define([ var $rootIcon = manager.isFolderEmpty(files[ROOT]) ? (isRootOpened ? $folderOpenedEmptyIcon : $folderEmptyIcon) : (isRootOpened ? $folderOpenedIcon : $folderIcon); - $rootIcon.css("color", getFolderColor([ROOT])); // XXX allow t omodify color of root ? var $rootElement = createTreeElement(ROOT_NAME, $rootIcon.clone(), [ROOT], false, true, true, isRootOpened); if (!manager.hasSubfolder(root)) { $rootElement.find('.cp-app-drive-icon-expcol').css('visibility', 'hidden'); @@ -3420,7 +3416,7 @@ define([ paths.forEach(function (p) { setFolderColor(p.element, p.path, color); }); - refresh(); // makes imgs overview flicker in drive + refresh(); }); } else if($(this).hasClass("cp-app-drive-context-delete")) {