/* * @Copyright 2014 Vincent Petry * * @author Vincent Petry * @author Felix NĂ¼sse * * * 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 trashElement=$('.nav-trashbin'); trashElement.droppable({ over: function( event, ui ) { trashElement.addClass('dropzone-background'); }, out: function( event, ui ) { trashElement.removeClass('dropzone-background'); }, activate: function( event, ui ) { var elem=trashElement.find('a').first(); elem.addClass('nav-icon-trashbin-starred').removeClass('nav-icon-trashbin'); }, deactivate: function( event, ui ) { var elem=trashElement.find('a').first(); elem.addClass('nav-icon-trashbin').removeClass('nav-icon-trashbin-starred'); }, drop: function( event, ui ) { var $selectedFiles = $(ui.draggable); if (ui.helper.find('tr').size()===1) { var $tr = $selectedFiles.closest('tr'); $selectedFiles.trigger('droppedOnTrash', $tr.attr('data-file'), $tr.attr('data-dir')); }else{ var item = ui.helper.find('tr'); for(var i=0; i 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; })();