summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2017-11-08 17:54:38 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2017-11-08 17:54:38 +0100
commit694a96d93816f93e487f0d5ce69e3e27e29702e8 (patch)
tree5c336b92b27c43d7ae185be7bb6341fbcffa40cc /apps/files
parent41210c8cf17a07add79e25149c37b23c0c30e35a (diff)
downloadnextcloud-server-694a96d93816f93e487f0d5ce69e3e27e29702e8.tar.gz
nextcloud-server-694a96d93816f93e487f0d5ce69e3e27e29702e8.zip
Fixed some more test and loop fix
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/js/breadcrumb.js26
-rw-r--r--apps/files/tests/js/breadcrumbSpec.js4
2 files changed, 17 insertions, 13 deletions
diff --git a/apps/files/js/breadcrumb.js b/apps/files/js/breadcrumb.js
index 526cada113a..da536f9de9f 100644
--- a/apps/files/js/breadcrumb.js
+++ b/apps/files/js/breadcrumb.js
@@ -34,6 +34,8 @@
var BreadCrumb = function(options){
this.$el = $('<div class="breadcrumb"></div>');
this.$menu = $('<div class="popovermenu menu-center"><ul></ul></div>');
+
+ this.crumbSelector = '.crumb:not(.hidden):not(.crumbhome):not(.crumbmenu)';
options = options || {};
if (options.onClick) {
this.onClick = options.onClick;
@@ -84,7 +86,6 @@
},
setDirectoryInfo: function(dirInfo) {
- console.log(dirInfo);
if (dirInfo !== this.dirInfo) {
this.dirInfo = dirInfo;
this.render();
@@ -264,7 +265,7 @@
var totalWidth = 0;
for (var i = 0; i < this.breadcrumbs.length; i++ ) {
var $crumb = $(this.breadcrumbs[i]);
- if(!$crumb.hasClass('hidden') || ignoreHidden) {
+ if(!$crumb.hasClass('hidden') || ignoreHidden === true) {
totalWidth += $crumb.width();
}
}
@@ -275,11 +276,10 @@
* Hide the middle crumb
*/
_hideCrumb: function() {
- var selector = '.crumb:not(.hidden):not(.crumbhome):not(.crumbmenu)';
- var length = this.$el.find(selector).length;
+ var length = this.$el.find(this.crumbSelector).length;
// Get the middle one floored down
var elmt = Math.floor(length / 2 - 0.5);
- this.$el.find(selector+':eq('+elmt+')').addClass('hidden');
+ this.$el.find(this.crumbSelector+':eq('+elmt+')').addClass('hidden');
},
/**
@@ -287,7 +287,7 @@
*/
_getCrumbElement: function() {
var hidden = this.$el.find('.crumb.hidden').length;
- var shown = this.$el.find('.crumb:not(.hidden):not(.crumbhome):not(.crumbmenu)').length;
+ var shown = this.$el.find(this.crumbSelector).length;
// Get the outer one with priority to the highest
var elmt = (1 - shown % 2) * (hidden - 1);
return this.$el.find('.crumb.hidden:eq('+elmt+')');
@@ -327,6 +327,12 @@
},
_resize: function() {
+
+ if (this.breadcrumbs.length <= 2) {
+ // home & menu
+ return;
+ }
+
// Used for testing since this.$el.parent fails
if (!this.availableWidth) {
this.usedWidth = this.$el.parent().width();
@@ -334,12 +340,10 @@
this.usedWidth = this.availableWidth;
}
- if (this.breadcrumbs.length <= 1) {
- return;
- }
-
// If container is smaller than content
- while (this.getTotalWidth() > this.usedWidth) {
+ // AND if there are crumbs left to hide
+ while (this.getTotalWidth() > this.usedWidth
+ && this.$el.find(this.crumbSelector).length > 0) {
this._hideCrumb();
}
// If container is bigger than content + element to be shown
diff --git a/apps/files/tests/js/breadcrumbSpec.js b/apps/files/tests/js/breadcrumbSpec.js
index c04b0f18035..b9075265ca5 100644
--- a/apps/files/tests/js/breadcrumbSpec.js
+++ b/apps/files/tests/js/breadcrumbSpec.js
@@ -156,7 +156,7 @@ describe('OCA.Files.BreadCrumb tests', function() {
onDrop: handler
});
bc.setDirectory('/one/two/three/four');
- expect(droppableStub.calledOnce).toEqual(true);
+ expect(droppableStub.calledOnce).toEqual(false);
expect(droppableStub.getCall(0).args[0].drop).toBeDefined();
// simulate drop
@@ -169,7 +169,7 @@ describe('OCA.Files.BreadCrumb tests', function() {
});
});
describe('Resizing', function() {
- var bc, dummyDir, widths, oldUpdateTotalWidth;
+ var bc, dummyDir, widths;
beforeEach(function() {
dummyDir = '/short name/longer name/looooooooooooonger/' +