[Pkg-owncloud-commits] [owncloud] 02/90: Merge pull request #11524 from nazar-pc/patch-1

David Prévot taffit at moszumanska.debian.org
Fri Feb 6 21:10:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 913ad8634f17f0b8734ff0188aa1b6522959273b
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Thu Oct 16 11:21:49 2014 +0200

    Merge pull request #11524 from nazar-pc/patch-1
    
    Page size calculation based on real page height
---
 apps/files/js/filelist.js           | 10 ++++++----
 apps/files/js/files.js              |  2 +-
 apps/files/tests/js/filelistSpec.js |  7 ++++---
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index d08e77f..a78cecd 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -49,8 +49,10 @@
 		fileSummary: null,
 		initialized: false,
 
-		// number of files per page
-		pageSize: 20,
+		// number of files per page, calculated dynamically
+		pageSize: function() {
+			return Math.ceil(this.$container.height() / 50);
+		},
 
 		/**
 		 * Array of files in the current folder.
@@ -490,7 +492,7 @@
 		 */
 		_nextPage: function(animate) {
 			var index = this.$fileList.children().length,
-				count = this.pageSize,
+				count = this.pageSize(),
 				tr,
 				fileData,
 				newTrs = [],
@@ -1167,7 +1169,7 @@
 			// if there are less elements visible than one page
 			// but there are still pending elements in the array,
 			// then directly append the next page
-			if (lastIndex < this.files.length && lastIndex < this.pageSize) {
+			if (lastIndex < this.files.length && lastIndex < this.pageSize()) {
 				this._nextPage(true);
 			}
 
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 5fcf99d..df268fe 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -350,7 +350,7 @@ var createDragShadow = function(event) {
 	}
 
 	// do not show drag shadow for too many files
-	var selectedFiles = _.first(FileList.getSelectedFiles(), FileList.pageSize);
+	var selectedFiles = _.first(FileList.getSelectedFiles(), FileList.pageSize());
 	selectedFiles = _.sortBy(selectedFiles, FileList._fileInfoCompare);
 
 	if (!isDragSelected && selectedFiles.length === 1) {
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 86ba4d4..d6e3a65 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -20,7 +20,7 @@
 */
 
 describe('OCA.Files.FileList tests', function() {
-	var testFiles, alertStub, notificationStub, fileList;
+	var testFiles, alertStub, notificationStub, fileList, pageSizeStub;
 	var bcResizeStub;
 
 	/**
@@ -120,7 +120,7 @@ describe('OCA.Files.FileList tests', function() {
 			size: 250,
 			etag: '456'
 		}];
-
+		pageSizeStub = sinon.stub(OCA.Files.FileList.prototype, 'pageSize').returns(20);
 		fileList = new OCA.Files.FileList($('#app-content-files'));
 	});
 	afterEach(function() {
@@ -130,6 +130,7 @@ describe('OCA.Files.FileList tests', function() {
 		notificationStub.restore();
 		alertStub.restore();
 		bcResizeStub.restore();
+		pageSizeStub.restore();
 	});
 	describe('Getters', function() {
 		it('Returns the current directory', function() {
@@ -814,7 +815,7 @@ describe('OCA.Files.FileList tests', function() {
 			fileList.$fileList.on('fileActionsReady', handler);
 			fileList._nextPage();
 			expect(handler.calledOnce).toEqual(true);
-			expect(handler.getCall(0).args[0].$files.length).toEqual(fileList.pageSize);
+			expect(handler.getCall(0).args[0].$files.length).toEqual(fileList.pageSize());
 		});
 		it('does not trigger "fileActionsReady" event after single add with silent argument', function() {
 			var handler = sinon.stub();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list