summaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2023-06-30 11:19:21 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-07-05 16:20:34 +0200
commite3bac437c225f28bc6a9ca34c4fc33c936b00513 (patch)
treed58c9153cff230cf4850092f84aeafa19de448ed /apps/files/js
parent7929ad4a9303d4f184e56f95fc89347519a164e4 (diff)
downloadnextcloud-server-e3bac437c225f28bc6a9ca34c4fc33c936b00513.tar.gz
nextcloud-server-e3bac437c225f28bc6a9ca34c4fc33c936b00513.zip
chore: remove old favorites view
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/favoritesfilelist.js102
-rw-r--r--apps/files/js/favoritesplugin.js120
-rw-r--r--apps/files/js/merged-index.json2
-rw-r--r--apps/files/js/navigation.js347
-rw-r--r--apps/files/js/tagsplugin.js78
5 files changed, 0 insertions, 649 deletions
diff --git a/apps/files/js/favoritesfilelist.js b/apps/files/js/favoritesfilelist.js
deleted file mode 100644
index 2c6b3c63e15..00000000000
--- a/apps/files/js/favoritesfilelist.js
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
- *
- * This file is licensed under the Affero General Public License version 3
- * or later.
- *
- * See the COPYING-README file.
- *
- */
-
-// HACK: this piece needs to be loaded AFTER the files app (for unit tests)
-window.addEventListener('DOMContentLoaded', function() {
- (function(OCA) {
- /**
- * @class OCA.Files.FavoritesFileList
- * @augments OCA.Files.FavoritesFileList
- *
- * @classdesc Favorites file list.
- * Displays the list of files marked as favorites
- *
- * @param $el container element with existing markup for the .files-controls
- * and a table
- * @param [options] map of options, see other parameters
- */
- var FavoritesFileList = function($el, options) {
- this.initialize($el, options);
- };
- FavoritesFileList.prototype = _.extend({}, OCA.Files.FileList.prototype,
- /** @lends OCA.Files.FavoritesFileList.prototype */ {
- id: 'favorites',
- appName: t('files','Favorites'),
-
- _clientSideSort: true,
- _allowSelection: false,
-
- /**
- * @private
- */
- initialize: function($el, options) {
- OCA.Files.FileList.prototype.initialize.apply(this, arguments);
- if (this.initialized) {
- return;
- }
- OC.Plugins.attach('OCA.Files.FavoritesFileList', this);
- },
-
- updateEmptyContent: function() {
- var dir = this.getCurrentDirectory();
- if (dir === '/') {
- // root has special permissions
- this.$el.find('.emptyfilelist.emptycontent').toggleClass('hidden', !this.isEmpty);
- this.$el.find('.files-filestable thead th').toggleClass('hidden', this.isEmpty);
- }
- else {
- OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments);
- }
- },
-
- getDirectoryPermissions: function() {
- return OC.PERMISSION_READ | OC.PERMISSION_DELETE;
- },
-
- updateStorageStatistics: function() {
- // no op because it doesn't have
- // storage info like free space / used space
- },
-
- reload: function() {
- this.showMask();
- if (this._reloadCall?.abort) {
- this._reloadCall.abort();
- }
-
- // there is only root
- this._setCurrentDir('/', false);
-
- this._reloadCall = this.filesClient.getFilteredFiles(
- {
- favorite: true
- },
- {
- properties: this._getWebdavProperties()
- }
- );
- var callBack = this.reloadCallback.bind(this);
- return this._reloadCall.then(callBack, callBack);
- },
-
- reloadCallback: function(status, result) {
- if (result) {
- // prepend empty dir info because original handler
- result.unshift({});
- }
-
- return OCA.Files.FileList.prototype.reloadCallback.call(this, status, result);
- },
- });
-
- OCA.Files.FavoritesFileList = FavoritesFileList;
- })(OCA);
-});
-
diff --git a/apps/files/js/favoritesplugin.js b/apps/files/js/favoritesplugin.js
deleted file mode 100644
index 5964d71a469..00000000000
--- a/apps/files/js/favoritesplugin.js
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
- *
- * This file is licensed under the Affero General Public License version 3
- * or later.
- *
- * See the COPYING-README file.
- *
- */
-
-(function(OCA) {
- /**
- * Registers the favorites file list from the files app sidebar.
- *
- * @namespace OCA.Files.FavoritesPlugin
- */
- OCA.Files.FavoritesPlugin = {
- name: 'Favorites',
-
- /**
- * @type OCA.Files.FavoritesFileList
- */
- favoritesFileList: null,
-
- attach: function() {
- var self = this;
- $('#app-content-favorites').on('show.plugin-favorites', function(e) {
- self.showFileList($(e.target));
- });
- $('#app-content-favorites').on('hide.plugin-favorites', function() {
- self.hideFileList();
- });
- },
-
- detach: function() {
- if (this.favoritesFileList) {
- this.favoritesFileList.destroy();
- OCA.Files.fileActions.off('setDefault.plugin-favorites', this._onActionsUpdated);
- OCA.Files.fileActions.off('registerAction.plugin-favorites', this._onActionsUpdated);
- $('#app-content-favorites').off('.plugin-favorites');
- this.favoritesFileList = null;
- }
- },
-
- showFileList: function($el) {
- if (!this.favoritesFileList) {
- this.favoritesFileList = this._createFavoritesFileList($el);
- }
- return this.favoritesFileList;
- },
-
- hideFileList: function() {
- if (this.favoritesFileList) {
- this.favoritesFileList.$fileList.empty();
- }
- },
-
- /**
- * Creates the favorites file list.
- *
- * @param $el container for the file list
- * @return {OCA.Files.FavoritesFileList} file list
- */
- _createFavoritesFileList: function($el) {
- var fileActions = this._createFileActions();
- // register favorite list for sidebar section
- return new OCA.Files.FavoritesFileList(
- $el, {
- fileActions: fileActions,
- // The file list is created when a "show" event is handled,
- // so it should be marked as "shown" like it would have been
- // done if handling the event with the file list already
- // created.
- shown: true
- }
- );
- },
-
- _createFileActions: function() {
- // inherit file actions from the files app
- var fileActions = new OCA.Files.FileActions();
- // note: not merging the legacy actions because legacy apps are not
- // compatible with the sharing overview and need to be adapted first
- fileActions.registerDefaultActions();
- fileActions.merge(OCA.Files.fileActions);
-
- if (!this._globalActionsInitialized) {
- // in case actions are registered later
- this._onActionsUpdated = _.bind(this._onActionsUpdated, this);
- OCA.Files.fileActions.on('setDefault.plugin-favorites', this._onActionsUpdated);
- OCA.Files.fileActions.on('registerAction.plugin-favorites', this._onActionsUpdated);
- this._globalActionsInitialized = true;
- }
-
- // when the user clicks on a folder, redirect to the corresponding
- // folder in the files app instead of opening it directly
- fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) {
- OCA.Files.App.setActiveView('files', {silent: true});
- OCA.Files.App.fileList.changeDirectory(OC.joinPaths(context.$file.attr('data-path'), filename), true, true);
- });
- fileActions.setDefault('dir', 'Open');
- return fileActions;
- },
-
- _onActionsUpdated: function(ev) {
- if (ev.action) {
- this.favoritesFileList.fileActions.registerAction(ev.action);
- } else if (ev.defaultAction) {
- this.favoritesFileList.fileActions.setDefault(
- ev.defaultAction.mime,
- ev.defaultAction.name
- );
- }
- }
- };
-
-})(OCA);
-
-OC.Plugins.register('OCA.Files.App', OCA.Files.FavoritesPlugin);
-
diff --git a/apps/files/js/merged-index.json b/apps/files/js/merged-index.json
index 2b7d6ec7d6d..38b36c16896 100644
--- a/apps/files/js/merged-index.json
+++ b/apps/files/js/merged-index.json
@@ -4,8 +4,6 @@
"detailfileinfoview.js",
"detailsview.js",
"detailtabview.js",
- "favoritesfilelist.js",
- "favoritesplugin.js",
"file-upload.js",
"fileactions.js",
"fileactionsmenu.js",
diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js
deleted file mode 100644
index d7ae7dd7fee..00000000000
--- a/apps/files/js/navigation.js
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * @Copyright 2014 Vincent Petry <pvince81@owncloud.com>
- *
- * @author Vincent Petry
- * @author Felix Nüsse <felix.nuesse@t-online.de>
- *
- *
- * This file is licensed under the Affero General Public License version 3
- * or later.
- *
- * See the COPYING-README file.
- *
- */
-
-(function () {
-
- /**
- * @class OCA.Files.Navigation
- * @classdesc Navigation control for the files app sidebar.
- *
- * @param $el element containing the navigation
- */
- var Navigation = function ($el) {
- this.initialize($el);
- };
-
- /**
- * @memberof OCA.Files
- */
- Navigation.prototype = {
-
- /**
- * Currently selected item in the list
- */
- _activeItem: null,
-
- /**
- * Currently selected container
- */
- $currentContent: null,
-
- /**
- * Key for the quick-acces-list
- */
- $quickAccessListKey: 'sublist-favorites',
- /**
- * Initializes the navigation from the given container
- *
- * @private
- * @param $el element containing the navigation
- */
- initialize: function ($el) {
- this.$el = $el;
- this._activeItem = null;
- this.$currentContent = null;
- this._setupEvents();
-
- this.setInitialQuickaccessSettings();
- },
-
- /**
- * Setup UI events
- */
- _setupEvents: function () {
- this.$el.on('click', 'li a', _.bind(this._onClickItem, this));
- this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this));
-
- var trashBinElement = $('.nav-trashbin');
- trashBinElement.droppable({
- over: function (event, ui) {
- trashBinElement.addClass('dropzone-background');
- },
- out: function (event, ui) {
- trashBinElement.removeClass('dropzone-background');
- },
- activate: function (event, ui) {
- var element = trashBinElement.find('a').first();
- element.addClass('nav-icon-trashbin-starred').removeClass('nav-icon-trashbin');
- },
- deactivate: function (event, ui) {
- var element = trashBinElement.find('a').first();
- element.addClass('nav-icon-trashbin').removeClass('nav-icon-trashbin-starred');
- },
- drop: function (event, ui) {
- trashBinElement.removeClass('dropzone-background');
-
- var $selectedFiles = $(ui.draggable);
-
- // FIXME: when there are a lot of selected files the helper
- // contains only a subset of them; the list of selected
- // files should be gotten from the file list instead to
- // ensure that all of them are removed.
- var item = ui.helper.find('tr');
- for (var i = 0; i < item.length; i++) {
- $selectedFiles.trigger('droppedOnTrash', item[i].getAttribute('data-file'), item[i].getAttribute('data-dir'));
- }
- }
- });
- },
-
- /**
- * Returns the container of the currently active app.
- *
- * @return app container
- */
- getActiveContainer: function () {
- return this.$currentContent;
- },
-
- /**
- * Returns the currently active item
- *
- * @return item ID
- */
- getActiveItem: function () {
- return this._activeItem;
- },
-
- /**
- * Switch the currently selected item, mark it as selected and
- * make the content container visible, if any.
- *
- * @param string itemId id of the navigation item to select
- * @param array options "silent" to not trigger event
- */
- setActiveItem: function (itemId, options) {
- var currentItem = this.$el.find('li[data-id="' + itemId + '"]');
- var itemDir = currentItem.data('dir');
- var itemView = currentItem.data('view');
- var oldItemId = this._activeItem;
- if (itemId === this._activeItem) {
- if (!options || !options.silent) {
- this.$el.trigger(
- new $.Event('itemChanged', {
- itemId: itemId,
- previousItemId: oldItemId,
- dir: itemDir,
- view: itemView
- })
- );
- }
- return;
- }
- this.$el.find('li a').removeClass('active').removeAttr('aria-current');
- if (this.$currentContent) {
- this.$currentContent.addClass('hidden');
- this.$currentContent.trigger(jQuery.Event('hide'));
- }
- this._activeItem = itemId;
- currentItem.children('a').addClass('active').attr('aria-current', 'page');
- this.$currentContent = $('#app-content-' + (typeof itemView === 'string' && itemView !== '' ? itemView : itemId));
- this.$currentContent.removeClass('hidden');
- if (!options || !options.silent) {
- this.$currentContent.trigger(jQuery.Event('show', {
- itemId: itemId,
- previousItemId: oldItemId,
- dir: itemDir,
- view: itemView
- }));
- this.$el.trigger(
- new $.Event('itemChanged', {
- itemId: itemId,
- previousItemId: oldItemId,
- dir: itemDir,
- view: itemView
- })
- );
- }
- },
-
- /**
- * Returns whether a given item exists
- */
- itemExists: function (itemId) {
- return this.$el.find('li[data-id="' + itemId + '"]').length;
- },
-
- /**
- * Event handler for when clicking on an item.
- */
- _onClickItem: function (ev) {
- var $target = $(ev.target);
- var itemId = $target.closest('li').attr('data-id');
- if (!_.isUndefined(itemId)) {
- this.setActiveItem(itemId);
- }
- ev.preventDefault();
- },
-
- /**
- * Event handler for clicking a button
- */
- _onClickMenuButton: function (ev) {
- var $target = $(ev.target);
- var $menu = $target.parent('li');
- var itemId = $target.closest('button').attr('id');
-
- var collapsibleToggles = [];
- var dotmenuToggles = [];
-
- if ($menu.hasClass('collapsible') && $menu.data('expandedstate')) {
- $menu.toggleClass('open');
- var targetAriaExpanded = $target.attr('aria-expanded');
- if (targetAriaExpanded === 'false') {
- $target.attr('aria-expanded', 'true');
- } else if (targetAriaExpanded === 'true') {
- $target.attr('aria-expanded', 'false');
- }
- $menu.toggleAttr('data-expanded', 'true', 'false');
- var show = $menu.hasClass('open') ? 1 : 0;
- var key = $menu.data('expandedstate');
- $.post(OC.generateUrl("/apps/files/api/v1/toggleShowFolder/" + key), {show: show});
- }
-
- dotmenuToggles.forEach(function foundToggle (item) {
- if (item[0] === ("#" + itemId)) {
- document.getElementById(item[1]).classList.toggle('open');
- }
- });
-
- ev.preventDefault();
- },
-
- /**
- * Sort initially as setup of sidebar for QuickAccess
- */
- setInitialQuickaccessSettings: function () {
- var quickAccessKey = this.$quickAccessListKey;
- var quickAccessMenu = document.getElementById(quickAccessKey);
- if (quickAccessMenu) {
- var list = quickAccessMenu.getElementsByTagName('li');
- this.QuickSort(list, 0, list.length - 1);
- }
-
- var favoritesListElement = $(quickAccessMenu).parent();
- favoritesListElement.droppable({
- over: function (event, ui) {
- favoritesListElement.addClass('dropzone-background');
- },
- out: function (event, ui) {
- favoritesListElement.removeClass('dropzone-background');
- },
- activate: function (event, ui) {
- var element = favoritesListElement.find('a').first();
- element.addClass('nav-icon-favorites-starred').removeClass('nav-icon-favorites');
- },
- deactivate: function (event, ui) {
- var element = favoritesListElement.find('a').first();
- element.addClass('nav-icon-favorites').removeClass('nav-icon-favorites-starred');
- },
- drop: function (event, ui) {
- favoritesListElement.removeClass('dropzone-background');
-
- var $selectedFiles = $(ui.draggable);
-
- if (ui.helper.find('tr').size() === 1) {
- var $tr = $selectedFiles.closest('tr');
- if ($tr.attr("data-favorite")) {
- return;
- }
- $selectedFiles.trigger('droppedOnFavorites', $tr.attr('data-file'));
- } else {
- // FIXME: besides the issue described for dropping on
- // the trash bin, for favoriting it is not possible to
- // use the data from the helper; due to some bugs the
- // tags are not always added to the selected files, and
- // thus that data can not be accessed through the helper
- // to prevent triggering the favorite action on an
- // already favorited file (which would remove it from
- // favorites).
- OC.Notification.showTemporary(t('files', 'You can only favorite a single file or folder at a time'));
- }
- }
- });
- },
-
- /**
- * Sorting-Algorithm for QuickAccess
- */
- QuickSort: function (list, start, end) {
- var lastMatch;
- if (list.length > 1) {
- lastMatch = this.quicksort_helper(list, start, end);
- if (start < lastMatch - 1) {
- this.QuickSort(list, start, lastMatch - 1);
- }
- if (lastMatch < end) {
- this.QuickSort(list, lastMatch, end);
- }
- }
- },
-
- /**
- * Sorting-Algorithm-Helper for QuickAccess
- */
- quicksort_helper: function (list, start, end) {
- var pivot = Math.floor((end + start) / 2);
- var pivotElement = this.getCompareValue(list, pivot);
- var i = start;
- var j = end;
-
- while (i <= j) {
- while (this.getCompareValue(list, i) < pivotElement) {
- i++;
- }
- while (this.getCompareValue(list, j) > pivotElement) {
- j--;
- }
- if (i <= j) {
- this.swap(list, i, j);
- i++;
- j--;
- }
- }
- return i;
- },
-
- /**
- * Sorting-Algorithm-Helper for QuickAccess
- * This method allows easy access to the element which is sorted by.
- */
- getCompareValue: function (nodes, int, strategy) {
- return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase();
- },
-
- /**
- * Sorting-Algorithm-Helper for QuickAccess
- * This method allows easy swapping of elements.
- */
- swap: function (list, j, i) {
- var before = function(node, insertNode) {
- node.parentNode.insertBefore(insertNode, node);
- }
- before(list[i], list[j]);
- before(list[j], list[i]);
- }
-
- };
-
- OCA.Files.Navigation = Navigation;
-
-})();
-
-
-
-
-
diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js
index cda188803db..78bd7eec557 100644
--- a/apps/files/js/tagsplugin.js
+++ b/apps/files/js/tagsplugin.js
@@ -52,82 +52,6 @@
$favoriteMarkEl.toggleClass('permanent', state);
}
- /**
- * Remove Item from Quickaccesslist
- *
- * @param {String} appfolder folder to be removed
- */
- function removeFavoriteFromList (appfolder) {
- var quickAccessList = 'sublist-favorites';
- var listULElements = document.getElementById(quickAccessList);
- if (!listULElements) {
- return;
- }
-
- var apppath=appfolder;
- if(appfolder.startsWith("//")){
- apppath=appfolder.substring(1, appfolder.length);
- }
-
- $(listULElements).find('[data-dir="' + _.escape(apppath) + '"]').remove();
-
- if (listULElements.childElementCount === 0) {
- var collapsibleButton = $(listULElements).parent().find('button.collapse');
- collapsibleButton.hide();
- $("#button-collapse-parent-favorites").removeClass('collapsible');
- }
- }
-
- /**
- * Add Item to Quickaccesslist
- *
- * @param {String} appfolder folder to be added
- */
- function addFavoriteToList (appfolder) {
- var quickAccessList = 'sublist-favorites';
- var listULElements = document.getElementById(quickAccessList);
- if (!listULElements) {
- return;
- }
- 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 + '&view=files');
-
- var innerTagA = document.createElement('A');
- innerTagA.setAttribute("href", url);
- innerTagA.setAttribute("class", "nav-icon-files svg");
- innerTagA.innerHTML = _.escape(appName);
-
- var length = listLIElements.length + 1;
- var innerTagLI = document.createElement('li');
- innerTagLI.setAttribute("data-id", apppath.replace('/', '-'));
- innerTagLI.setAttribute("data-dir", apppath);
- innerTagLI.setAttribute("data-view", 'files');
- 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 = $(listULElements).parent().find('button.collapse');
- collapsibleButton.show();
- $(listULElements).parent().addClass('collapsible');
- } else {
- listLIElements[listLIElements.length - 1].after(innerTagLI);
- }
- }
- }
- );
- }
-
OCA.Files = OCA.Files || {};
/**
@@ -205,12 +129,10 @@
if (isFavorite) {
// remove tag from list
tags = _.without(tags, OC.TAG_FAVORITE);
- removeFavoriteFromList(dir + '/' + fileName);
// vue compatibility
window._nc_event_bus.emit('files:favorites:removed', node)
} else {
tags.push(OC.TAG_FAVORITE);
- addFavoriteToList(dir + '/' + fileName);
// vue compatibility
window._nc_event_bus.emit('files:favorites:added', node)
}