diff options
author | fnuesse <felix.nuesse@t-online.de> | 2018-06-18 11:13:52 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-07-12 16:49:38 +0200 |
commit | 9cd4b53a51c6b1ed4835df5976f7310b6fb3f75f (patch) | |
tree | 86e8d81d046045f59f368c6df61775f8b0b22e0f | |
parent | ce05cb371b044d08b45b49303f76d23a7fe84875 (diff) | |
download | nextcloud-server-9cd4b53a51c6b1ed4835df5976f7310b6fb3f75f.tar.gz nextcloud-server-9cd4b53a51c6b1ed4835df5976f7310b6fb3f75f.zip |
Added responsive folderadding
Signed-off-by: fnuesse <felix.nuesse@t-online.de>
Added collapsible to quickaccesslist
Signed-off-by: fnuesse <felix.nuesse@t-online.de>
Refactored Code
Signed-off-by: fnuesse <felix.nuesse@t-online.de>
-rw-r--r-- | apps/files/js/navigation.js | 16 | ||||
-rw-r--r-- | apps/files/js/tagsplugin.js | 65 | ||||
-rw-r--r-- | apps/files/lib/Controller/ViewController.php | 1 | ||||
-rw-r--r-- | apps/files/templates/appnavigation.php | 20 |
4 files changed, 91 insertions, 11 deletions
diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index cf4de7d61e5..04c9143581c 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -143,6 +143,16 @@ _onClickMenuButton: function(ev) { var $target = $(ev.target); var itemId = $target.closest('button').attr('id'); + var qaSelector= '#quickaccess-list'; + + if(itemId==='button-collapseQuickAccess'){ + $.get(OC.generateUrl("/apps/files/api/v1/showquickaccess"), {show: document.getElementById('enableQuickAccess').checked}, function(data, status){ + }); + $("#quickaccess-list" ).toggle('open'); + var dotmenu = document.getElementById("quickaccess-list"); + dotmenu.style.display=''; + } + if(itemId==='button-favorites'){ document.getElementById('menu-favorites').classList.toggle('open'); } @@ -160,10 +170,10 @@ var itemId = $(ev.target).closest('input').attr('id'); var list = document.getElementById(qaKey).getElementsByTagName('li'); - if(itemId==='enableQuickAccess'){ + if(itemId==='enableQuickAccess' ){ $.get(OC.generateUrl("/apps/files/api/v1/showquickaccess"), {show: document.getElementById('enableQuickAccess').checked}, function(data, status){ }); - $(qaSelector ).toggle(); + $(qaSelector).toggle('open'); document.getElementById('menu-favorites').classList.toggle('open'); } @@ -290,7 +300,7 @@ */ getCompareValue: function(nodes, int){ if(this.sortingStrategy==='alphabet'){ - ; return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase() + return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); }else if(this.sortingStrategy==='date'){ return nodes[int].getAttribute('folderPos').toLowerCase(); } diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index b174aa7d766..8cdc26ab3bb 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -62,6 +62,68 @@ $favoriteMarkEl.toggleClass('permanent', state); } + /** + * Remove Item from Quickaccesslist + * + * @param {String} $appfolder folder to be removed + */ + function removeFavoriteFromList(appfolder) { + + var qaKey= 'quickaccess-list'; + var listUL = document.getElementById(qaKey); + var list = listUL.getElementsByTagName('li'); + var appname=appfolder.substring(appfolder.lastIndexOf("/")+1, appfolder.length); + + for(var i = 0; i <= list.length-1; i++) { + if(appname === list[i].getElementsByTagName('a')[0].innerHTML){ + list[i].remove(); + } + } + + if(listUL.childElementCount==0){ + var dotmenu = document.getElementById("quickaccessbutton"); + dotmenu.style.display='none'; + } + } + + /** + * Add Item to Quickaccesslist + * + * @param {String} $appfolder folder to be added + */ + function addFavoriteToList(appfolder) { + var qaKey= 'quickaccess-list'; + var listUL = document.getElementById(qaKey); + var list = listUL.getElementsByTagName('li'); + + var appname=appfolder.substring(appfolder.lastIndexOf("/")+1, appfolder.length); + + var a = document.createElement('A'); + a.setAttribute("href","/cloud/index.php/apps/files/?dir="+appfolder); + a.setAttribute("class","nav-icon-files svg"); + a.innerHTML=appname; + + var len=list.length+1; + var li = document.createElement('li'); + li.setAttribute("data-id", "/cloud/index.php/apps/files/?dir="+appfolder); + li.setAttribute("class", "nav-"+appname); + li.setAttribute("folderpos", len.toString()); + li.appendChild(a); + + + if(listUL.childElementCount<=0){ + listUL.appendChild(li); + var dotmenu = document.getElementById("quickaccessbutton"); + dotmenu.style.display=''; + }else{ + list[list.length-1].after(li); + } + + //list[list.length-1].after(li); + //document.getElementById('menu-favorites').classList.toggle('open'); + //this.QuickSort(list, 0, list.length - 1); + } + OCA.Files = OCA.Files || {}; /** @@ -121,6 +183,7 @@ var fileInfo = context.fileList.files[$file.index()]; var dir = context.dir || context.fileList.getCurrentDirectory(); var tags = $file.attr('data-tags'); + if (_.isUndefined(tags)) { tags = ''; } @@ -130,8 +193,10 @@ if (isFavorite) { // remove tag from list tags = _.without(tags, OC.TAG_FAVORITE); + removeFavoriteFromList(dir + '/' + fileName); } else { tags.push(OC.TAG_FAVORITE); + addFavoriteToList(dir + '/' + fileName); } // pre-toggle the star diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 936f09154dd..c218063f979 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -189,6 +189,7 @@ class ViewController extends Controller { 'id' => 'favorites', 'appname' => 'files', 'script' => 'simplelist.php', + 'classes' => 'collapsible', 'enableQuickaccess' => $expanded, 'quickaccessSortingStrategy' => $sorting, 'quickaccessSortingReverse' => $reverseListSetting, diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 1488bee40d9..5f1baafaf8a 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -7,18 +7,22 @@ ?> <li data-id="<?php p(isset($item['href']) ? $item['href'] : $item['id']) ?>" - class="nav-<?php p($item['id']) ?> <?php p($item['classes']) ?> <?php p($pinned===1?'first-pinned':'') ?>" + class="nav-<?php p($item['id']) ?> <?php p($item['classes']) ?> <?php p($pinned===1?'first-pinned':'') ?> <?php if($item['enableQuickaccess']=='true'){ ?> open<?php } ?>" <?php if(isset($item['folderPosition'])){ ?> folderPos="<?php p($item['folderPosition']);?>"<?php } ?>> + <?php if($item['id']=='favorites'){?> + <button id="button-collapseQuickAccess" class="collapse"></button><?php } ?> + <a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>" class="nav-icon-<?php p($item['icon'] !== '' ? $item['icon'] : $item['id']) ?> svg"><?php p($item['name']);?></a> <?php if($item['id']=='favorites'){?> - - <div class="app-navigation-entry-utils" <?php if($item['favoritescount']==0){ ?> style="display: none"<?php } ?>> - <ul> - <li class="app-navigation-entry-utils-menu-button svg"><button id="button-<?php p($item['id']) ?>"></button></li> - </ul> - </div> + <div id="quickaccessbutton" class="app-navigation-entry-utils" <?php if($item['favoritescount']==0){ ?> style="display: none"<?php } ?>> + <ul> + <li class="app-navigation-entry-utils-menu-button svg"> + <button id="button-<?php p($item['id']) ?>"></button> + </li> + </ul> + </div> <div class="app-navigation-entry-menu" id="menu-<?php p($item['id']) ?>"> <ul> <li> @@ -47,7 +51,7 @@ </li> </ul> </div> - <ul id="quickaccess-list" <?php if($item['enableQuickaccess']=='false'){ ?> style="display: none"<?php } ?>> + <ul id="quickaccess-list" > <?php /*This fixes the styleerrors if no favorites are set*/ if($item['favoritescount']==0){?></ul><?php } ?> <?php } ?> |