summaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorfnuesse <felix.nuesse@t-online.de>2018-06-27 10:40:32 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-07-12 16:49:39 +0200
commitc9995de2db2072960144163d62e2507e393d32b6 (patch)
treefda20d08557ae40604a799e45de35ddbcb313d0e /apps/files/js
parent55ebdc9344dc8edb665491bf89595f406cfc4d62 (diff)
downloadnextcloud-server-c9995de2db2072960144163d62e2507e393d32b6.tar.gz
nextcloud-server-c9995de2db2072960144163d62e2507e393d32b6.zip
Added drop-animation to sortable-list
Signed-off-by: fnuesse <felix.nuesse@t-online.de> Added icon-change on drag Signed-off-by: fnuesse <felix.nuesse@t-online.de> Fixed Navbar-closing in app when favorites-list is toggled on mobile Signed-off-by: fnuesse <felix.nuesse@t-online.de> Refactored Code Signed-off-by: fnuesse <felix.nuesse@t-online.de> Changed to alphabetical sorting Signed-off-by: fnuesse <felix.nuesse@t-online.de> Fixed deletion of folder with identical names Signed-off-by: fnuesse <felix.nuesse@t-online.de> Removed ability to add files to the quickaccess Signed-off-by: fnuesse <felix.nuesse@t-online.de> Fixed wrong path-generation when added from favorites-star Signed-off-by: fnuesse <felix.nuesse@t-online.de> Removed Element from navbar when favorite-star in detailview is toggled off Signed-off-by: fnuesse <felix.nuesse@t-online.de> Changed Quota-Text to prevent boundarybreaks Reverted last commit
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/navigation.js69
-rw-r--r--apps/files/js/tagsplugin.js44
2 files changed, 77 insertions, 36 deletions
diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js
index 799e265bdff..207f9b1c206 100644
--- a/apps/files/js/navigation.js
+++ b/apps/files/js/navigation.js
@@ -49,7 +49,7 @@
* alphabet
*
*/
- $sortingStrategy: 'customorder',
+ $sortingStrategy: 'alphabet',
/**
* Key for the quick-acces-list
@@ -66,8 +66,12 @@
this._activeItem = null;
this.$currentContent = null;
this._setupEvents();
- this.setInitialQuickaccessSettings();
+ var scope=this;
+ $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/SortingStrategy"), function (data, status) {
+ scope.$sortingStrategy=data;
+ scope.setInitialQuickaccessSettings();
+ });
},
@@ -162,7 +166,7 @@
* Event handler for when dragging an item
*/
_setOnDrag: function () {
- var scope=this;
+ var scope = this;
var element = $("#sublist-favorites");
$(function () {
if (document.getElementById(scope.$quickAccessListKey.toString()).hasAttribute("draggable")) {
@@ -172,30 +176,54 @@
scroll: false,
zIndex: 0,
opacity: 0.5,
- delay: 150,
tolerance: "pointer",
- start:function(event, ui){
+ //revert: 0.05,
+ //delay: 150,
+ start: function (event, ui) {
//Fix for offset
- ui.helper[0].style.left ='0px';
+ ui.helper[0].style.left = '0px';
+
+ //Change Icon while dragging
+ var list = document.getElementById(scope.$quickAccessListKey).getElementsByTagName('li');
+ for (var j = 0; j < list.length; j++) {
+ if (!(typeof list[j].getElementsByTagName('a')[0] === 'undefined')) {
+ list[j].getElementsByTagName('a')[0].classList.remove("nav-icon-files");
+ list[j].getElementsByTagName('a')[0].classList.add('icon-menu');
+ }
+ }
},
- stop: function( event, ui ) {
+ stop: function (event, ui) {
//Clean up offset
ui.item.removeAttr("style");
+
+ //Change Icon back after dragging
+ var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li');
+ for (var j = 0; j < list.length; j++) {
+ if (!(typeof list[j].getElementsByTagName('a')[0] === 'undefined')) {
+ list[j].getElementsByTagName('a')[0].classList.add("nav-icon-files");
+ list[j].getElementsByTagName('a')[0].classList.remove('icon-menu');
+ }
+ }
},
update: function (event, ui) {
var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li');
- var string=[];
+ var string = [];
for (var j = 0; j < list.length; j++) {
- var Object = {id:j, name:scope.getCompareValue(list,j,'alphabet') };
+ var Object = {
+ id: j,
+ name: scope.getCompareValue(list, j, 'alphabet')
+ };
string.push(Object);
}
- var resultorder=JSON.stringify(string);
- $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/CustomSortingOrder"),{
- order: resultorder}, function (data, status) {});
+ var resultorder = JSON.stringify(string);
+ $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/CustomSortingOrder"), {
+ order: resultorder
+ }, function (data, status) {
+ });
}
});
- }else{
- if(scope.$sortingStrategy === 'customorder'){
+ } else {
+ if (scope.$sortingStrategy === 'customorder') {
scope.$sortingStrategy = 'datemodified';
}
}
@@ -220,13 +248,12 @@
// and the parent, which should be toggled at the first arrayindex.
dotmenuToggles.push(["#dotmenu-button-favorites", "dotmenu-content-favorites"]);
-
collapsibleToggles.forEach(function foundToggle (item) {
if (item[0] === ("#" + itemId)) {
$(item[1]).toggleClass('open');
- var show=1;
- if(!$(item[1]).hasClass('open')){
- show=0;
+ var show = 1;
+ if (!$(item[1]).hasClass('open')) {
+ show = 0;
}
$.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/showList"), {show: show}, function (data, status) {
});
@@ -269,7 +296,6 @@
scope.reverse(list);
});
-
} else if (this.$sortingStrategy === 'alphabet') {
sort = true;
} else if (this.$sortingStrategy === 'date') {
@@ -277,7 +303,7 @@
} else if (this.$sortingStrategy === 'customorder') {
var scope = this;
$.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/CustomSortingOrder"), function (data, status) {
- var ordering=JSON.parse(data);
+ var ordering = JSON.parse(data);
for (var i = 0; i < ordering.length; i++) {
for (var j = 0; j < list.length; j++) {
if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === ordering[i].name.toLowerCase()) {
@@ -287,7 +313,6 @@
}
scope.QuickSort(list, 0, list.length - 1);
});
-
sort = false;
}
@@ -357,7 +382,7 @@
return nodes[int].getAttribute('folderPosition').toLowerCase();
} else if (strategy === 'datemodified') {
return nodes[int].getAttribute('mtime');
- }else if (strategy === 'customorder') {
+ } else if (strategy === 'customorder') {
return nodes[int].getAttribute('folderPosition');
}
return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase();
diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js
index 853874f4e83..3a1378cc9ad 100644
--- a/apps/files/js/tagsplugin.js
+++ b/apps/files/js/tagsplugin.js
@@ -73,10 +73,14 @@
var collapsibleButtonId = 'button-collapse-favorites';
var listULElements = document.getElementById(quickAccessList);
var listLIElements = listULElements.getElementsByTagName('li');
- var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length);
+
+ var apppath=appfolder;
+ if(appfolder.startsWith("//")){
+ apppath=appfolder.substring(1, appfolder.length);
+ }
for (var i = 0; i <= listLIElements.length - 1; i++) {
- if (appName === listLIElements[i].getElementsByTagName('a')[0].innerHTML) {
+ if (listLIElements[i].getElementsByTagName('a')[0].href.endsWith("dir=" + apppath)) {
listLIElements[i].remove();
}
}
@@ -100,29 +104,40 @@
var listLIElements = listULElements.getElementsByTagName('li');
var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length);
+ var apppath=appfolder;
+
+ if(appfolder.startsWith("//")){
+ apppath=appfolder.substring(1, appfolder.length);
+ }
+ var url=OC.generateUrl('/apps/files/?dir=')+apppath;
+
var innerTagA = document.createElement('A');
- innerTagA.setAttribute("href", OC.generateUrl('/apps/files/?dir=') + appfolder);
+ innerTagA.setAttribute("href", url);
innerTagA.setAttribute("class", "nav-icon-files svg");
innerTagA.innerHTML = appName;
var length = listLIElements.length + 1;
var innerTagLI = document.createElement('li');
- innerTagLI.setAttribute("data-id", OC.generateUrl('/apps/files/?dir=') + appfolder);
+ innerTagLI.setAttribute("data-id", url);
innerTagLI.setAttribute("class", "nav-" + appName);
innerTagLI.setAttribute("folderpos", length.toString());
innerTagLI.appendChild(innerTagA);
+ $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/NodeType"),{folderpath: apppath}, function (data, status) {
+ if (data === "dir") {
+ if (listULElements.childElementCount <= 0) {
+ listULElements.appendChild(innerTagLI);
+ var collapsibleButton = document.getElementById(collapsibleButtonId);
+ collapsibleButton.style.display = '';
- if (listULElements.childElementCount <= 0) {
- listULElements.appendChild(innerTagLI);
- var collapsibleButton = document.getElementById(collapsibleButtonId);
- collapsibleButton.style.display = '';
-
- $("#button-collapse-parent-favorites").addClass('collapsible');
- } else {
- listLIElements[listLIElements.length - 1].after(innerTagLI);
- }
+ $("#button-collapse-parent-favorites").addClass('collapsible');
+ } else {
+ listLIElements[listLIElements.length - 1].after(innerTagLI);
+ }
+ }
+ }
+ );
}
OCA.Files = OCA.Files || {};
@@ -327,6 +342,7 @@
});
}
};
-})(OCA);
+})
+(OCA);
OC.Plugins.register('OCA.Files.FileList', OCA.Files.TagsPlugin);