summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-04-03 22:02:05 +0200
committerMorris Jobke <hey@morrisjobke.de>2014-04-03 22:02:05 +0200
commitbf7624fb255b7af534f5d6a740dd6dc9799cfc63 (patch)
tree8c61f56b8df1cd8118c92948a4432276efbfb4c3 /core
parent388142ecc6a3b1382858619e0fea6145c506ab5e (diff)
parentd1e78d7a6b7ff074bb972e0840ca8cdfe2403000 (diff)
downloadnextcloud-server-bf7624fb255b7af534f5d6a740dd6dc9799cfc63.tar.gz
nextcloud-server-bf7624fb255b7af534f5d6a740dd6dc9799cfc63.zip
Merge pull request #6968 from owncloud/files-ajaxload
Ajaxify files list for files + trashbin + public page
Diffstat (limited to 'core')
-rw-r--r--core/css/styles.css7
-rw-r--r--core/js/js.js33
-rw-r--r--core/js/oc-dialogs.js17
-rw-r--r--core/js/tests/specs/coreSpec.js67
4 files changed, 112 insertions, 12 deletions
diff --git a/core/css/styles.css b/core/css/styles.css
index 8a12057529d..f978eab7cac 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -283,6 +283,10 @@ input[type="submit"].enabled {
padding: 7px 10px
}
+#controls .button.hidden {
+ display: none;
+}
+
#content { position:relative; height:100%; width:100%; }
#content .hascontrols {
position: relative;
@@ -922,6 +926,9 @@ div.crumb {
background: url('../img/breadcrumb.svg') no-repeat right center;
height: 44px;
}
+div.crumb.hidden {
+ display: none;
+}
div.crumb a,
div.crumb span {
position: relative;
diff --git a/core/js/js.js b/core/js/js.js
index 302b6b4d9fa..9a3b2ee6a5d 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -159,6 +159,7 @@ function escapeHTML(s) {
* @param file The filename
* @param dir The directory the file is in - e.g. $('#dir').val()
* @return string
+* @deprecated use Files.getDownloadURL() instead
*/
function fileDownloadPath(dir, file) {
return OC.filePath('files', 'ajax', 'download.php')+'?files='+encodeURIComponent(file)+'&dir='+encodeURIComponent(dir);
@@ -371,6 +372,7 @@ var OC={
*/
parseQueryString:function(queryString){
var parts,
+ pos,
components,
result = {},
key,
@@ -378,12 +380,25 @@ var OC={
if (!queryString){
return null;
}
- if (queryString[0] === '?'){
- queryString = queryString.substr(1);
+ pos = queryString.indexOf('?');
+ if (pos >= 0){
+ queryString = queryString.substr(pos + 1);
}
- parts = queryString.split('&');
+ parts = queryString.replace(/\+/g, '%20').split('&');
for (var i = 0; i < parts.length; i++){
- components = parts[i].split('=');
+ // split on first equal sign
+ var part = parts[i]
+ pos = part.indexOf('=');
+ if (pos >= 0) {
+ components = [
+ part.substr(0, pos),
+ part.substr(pos + 1)
+ ]
+ }
+ else {
+ // key only
+ components = [part];
+ }
if (!components.length){
continue;
}
@@ -391,8 +406,14 @@ var OC={
if (!key){
continue;
}
- value = components[1];
- result[key] = value && decodeURIComponent(value);
+ // if equal sign was there, return string
+ if (components.length > 1) {
+ result[key] = decodeURIComponent(components[1]);
+ }
+ // no equal sign => null value
+ else {
+ result[key] = null;
+ }
}
return result;
},
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index d1bcb4659b8..6fc8d4d3523 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -294,7 +294,7 @@ var OCdialogs = {
conflict.find('.replacement .mtime').text(formatDate(replacement.lastModifiedDate));
}
var path = original.directory + '/' +original.name;
- Files.lazyLoadPreview(path, original.mime, function(previewpath){
+ Files.lazyLoadPreview(path, original.mimetype, function(previewpath){
conflict.find('.original .icon').css('background-image','url('+previewpath+')');
}, 96, 96, original.etag);
getCroppedPreview(replacement).then(
@@ -514,7 +514,7 @@ var OCdialogs = {
}
return $.getJSON(
- OC.filePath('files', 'ajax', 'rawlist.php'),
+ OC.filePath('files', 'ajax', 'list.php'),
{
dir: dir,
mimetypes: JSON.stringify(mimeType)
@@ -539,7 +539,7 @@ var OCdialogs = {
this.$filelist.empty().addClass('loading');
this.$filePicker.data('path', dir);
$.when(this._getFileList(dir, this.$filePicker.data('mimetype'))).then(function(response) {
- $.each(response.data, function(index, file) {
+ $.each(response.data.files, function(index, file) {
if (file.type === 'dir') {
dirs.push(file);
} else {
@@ -555,9 +555,16 @@ var OCdialogs = {
type: entry.type,
dir: dir,
filename: entry.name,
- date: OC.mtime2date(entry.mtime)
+ date: OC.mtime2date(Math.floor(entry.mtime / 1000))
});
- $li.find('img').attr('src', entry.mimetype_icon);
+ $li.find('img').attr('src', entry.icon);
+ if (entry.isPreviewAvailable) {
+ var urlSpec = {
+ file: dir + '/' + entry.name
+ };
+ var previewUrl = OC.generateUrl('/core/preview.png?') + $.param(urlSpec);
+ $li.find('img').attr('src', previewUrl);
+ }
self.$filelist.append($li);
});
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index 57ea5be8be0..94a397b7892 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -268,7 +268,72 @@ describe('Core base tests', function() {
// still nothing
expect(counter).toEqual(0);
});
-
+ });
+ describe('Parse query string', function() {
+ it('Parses query string from full URL', function() {
+ var query = OC.parseQueryString('http://localhost/stuff.php?q=a&b=x');
+ expect(query).toEqual({q: 'a', b: 'x'});
+ });
+ it('Parses query string from query part alone', function() {
+ var query = OC.parseQueryString('q=a&b=x');
+ expect(query).toEqual({q: 'a', b: 'x'});
+ });
+ it('Returns null hash when empty query', function() {
+ var query = OC.parseQueryString('');
+ expect(query).toEqual(null);
+ });
+ it('Returns empty hash when empty query with question mark', function() {
+ var query = OC.parseQueryString('?');
+ expect(query).toEqual({});
+ });
+ it('Decodes regular query strings', function() {
+ var query = OC.parseQueryString('a=abc&b=def');
+ expect(query).toEqual({
+ a: 'abc',
+ b: 'def'
+ });
+ });
+ it('Ignores empty parts', function() {
+ var query = OC.parseQueryString('&q=a&&b=x&');
+ expect(query).toEqual({q: 'a', b: 'x'});
+ });
+ it('Ignores lone equal signs', function() {
+ var query = OC.parseQueryString('&q=a&=&b=x&');
+ expect(query).toEqual({q: 'a', b: 'x'});
+ });
+ it('Includes extra equal signs in value', function() {
+ var query = OC.parseQueryString('u=a=x&q=a=b');
+ expect(query).toEqual({u: 'a=x', q: 'a=b'});
+ });
+ it('Decodes plus as space', function() {
+ var query = OC.parseQueryString('space+key=space+value');
+ expect(query).toEqual({'space key': 'space value'});
+ });
+ it('Decodes special characters', function() {
+ var query = OC.parseQueryString('unicode=%E6%B1%89%E5%AD%97');
+ expect(query).toEqual({unicode: '汉字'});
+ query = OC.parseQueryString('b=spaace%20value&space%20key=normalvalue&slash%2Fthis=amp%26ersand');
+ expect(query).toEqual({
+ b: 'spaace value',
+ 'space key': 'normalvalue',
+ 'slash/this': 'amp&ersand'
+ });
+ });
+ it('Decodes empty values', function() {
+ var query = OC.parseQueryString('keywithemptystring=&keywithnostring');
+ expect(query).toEqual({
+ 'keywithemptystring': '',
+ 'keywithnostring': null
+ });
+ });
+ it('Does not interpret data types', function() {
+ var query = OC.parseQueryString('booleanfalse=false&booleantrue=true&number=123');
+ expect(query).toEqual({
+ 'booleanfalse': 'false',
+ 'booleantrue': 'true',
+ 'number': '123'
+ });
+ });
});
describe('Generate Url', function() {
it('returns absolute urls', function() {