aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2013-01-08 15:02:06 -0800
committerThomas Tanghus <thomas@tanghus.net>2013-01-08 15:02:06 -0800
commitdae8f15f9fcbba4308c6db8ec3bd78c4aa659fad (patch)
tree9d266fd7c3420770a4b519acd8f7edb23fb342a1
parentb69328e1d1f0888c2541e3f0be27e534f980adb4 (diff)
parent7b9e6d2f2ce1503b113017db4dbe43c68da0101b (diff)
downloadnextcloud-server-dae8f15f9fcbba4308c6db8ec3bd78c4aa659fad.tar.gz
nextcloud-server-dae8f15f9fcbba4308c6db8ec3bd78c4aa659fad.zip
Merge pull request #938 from owncloud/fix_minor_files_annoyances
Fix minor files annoyances
-rw-r--r--apps/files/css/files.css6
-rw-r--r--apps/files/js/filelist.js10
-rw-r--r--apps/files/js/files.js100
-rw-r--r--apps/files/templates/index.php8
-rw-r--r--core/css/styles.css2
-rw-r--r--core/js/config.js2
-rw-r--r--core/js/js.js13
7 files changed, 84 insertions, 57 deletions
diff --git a/apps/files/css/files.css b/apps/files/css/files.css
index 99c39f0acdb..36a1e5c954b 100644
--- a/apps/files/css/files.css
+++ b/apps/files/css/files.css
@@ -21,14 +21,14 @@
#new>ul>li { height:20px; margin:.3em; padding-left:2em; padding-bottom:0.1em;
background-repeat:no-repeat; cursor:pointer; }
#new>ul>li>p { cursor:pointer; }
-#new>ul>li>input { padding:0.3em; margin:-0.3em; }
+#new>ul>li>form>input { padding:0.3em; margin:-0.3em; }
#upload {
height:27px; padding:0; margin-left:0.2em; overflow:hidden;
}
#upload a {
position:relative; display:block; width:100%; height:27px;
- cursor:pointer; z-index:1000;
+ cursor:pointer; z-index:10;
background-image:url('%webroot%/core/img/actions/upload.svg');
background-repeat:no-repeat;
background-position:7px 6px;
@@ -39,7 +39,7 @@
left:0; top:0; width:28px; height:27px; padding:0;
font-size:1em;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0;
- z-index:-1; position:relative; cursor:pointer; overflow:hidden;
+ z-index:20; position:relative; cursor:pointer; overflow:hidden;
}
#uploadprogresswrapper { position:absolute; right:13.5em; top:0em; }
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 22d701d8ff9..66697bbbf56 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -151,8 +151,7 @@ var FileList={
var newname=input.val();
if (!Files.isFileNameValid(newname)) {
return false;
- }
- if (newname != name) {
+ } else if (newname != name) {
if (FileList.checkName(name, newname, false)) {
newname = name;
} else {
@@ -185,6 +184,13 @@ var FileList={
td.children('a.name').show();
return false;
});
+ input.keyup(function(event){
+ if (event.keyCode == 27) {
+ tr.data('renaming',false);
+ form.remove();
+ td.children('a.name').show();
+ }
+ });
input.click(function(event){
event.stopPropagation();
event.preventDefault();
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index ba2495eb728..bb298431e84 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -26,19 +26,19 @@ Files={
});
procesSelection();
},
- isFileNameValid:function (name) {
- if (name === '.') {
- $('#notification').text(t('files', "'.' is an invalid file name."));
- $('#notification').fadeIn();
- return false;
- }
- if (name.length == 0) {
- $('#notification').text(t('files', "File name cannot be empty."));
- $('#notification').fadeIn();
- return false;
- }
-
- // check for invalid characters
+ isFileNameValid:function (name) {
+ if (name === '.') {
+ $('#notification').text(t('files', '\'.\' is an invalid file name.'));
+ $('#notification').fadeIn();
+ return false;
+ }
+ if (name.length == 0) {
+ $('#notification').text(t('files', 'File name cannot be empty.'));
+ $('#notification').fadeIn();
+ return false;
+ }
+
+ // check for invalid characters
var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
for (var i = 0; i < invalid_characters.length; i++) {
if (name.indexOf(invalid_characters[i]) != -1) {
@@ -246,12 +246,12 @@ $(document).ready(function() {
}
});
}else{
- var dropTarget = $(e.originalEvent.target).closest('tr');
- if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder
- var dirName = dropTarget.attr('data-file')
- }
+ var dropTarget = $(e.originalEvent.target).closest('tr');
+ if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder
+ var dirName = dropTarget.attr('data-file')
+ }
- var date=new Date();
+ var date=new Date();
if(files){
for(var i=0;i<files.length;i++){
if(files[i].size>0){
@@ -304,9 +304,9 @@ $(document).ready(function() {
var jqXHR = $('#file_upload_start').fileupload('send', {files: files[i],
formData: function(form) {
var formArray = form.serializeArray();
- // array index 0 contains the max files size
- // array index 1 contains the request token
- // array index 2 contains the directory
+ // array index 0 contains the max files size
+ // array index 1 contains the request token
+ // array index 2 contains the directory
formArray[2]['value'] = dirName;
return formArray;
}}).success(function(result, textStatus, jqXHR) {
@@ -317,13 +317,14 @@ $(document).ready(function() {
$('#notification').fadeIn();
}
var file=response[0];
- // TODO: this doesn't work if the file name has been changed server side
+ // TODO: this doesn't work if the file name has been changed server side
delete uploadingFiles[dirName][file.name];
- if ($.assocArraySize(uploadingFiles[dirName]) == 0) {
- delete uploadingFiles[dirName];
- }
+ if ($.assocArraySize(uploadingFiles[dirName]) == 0) {
+ delete uploadingFiles[dirName];
+ }
+ //TODO update file upload size limit
- var uploadtext = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName).find('.uploadtext')
+ var uploadtext = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName).find('.uploadtext')
var currentUploads = parseInt(uploadtext.attr('currentUploads'));
currentUploads -= 1;
uploadtext.attr('currentUploads', currentUploads);
@@ -351,6 +352,7 @@ $(document).ready(function() {
} else {
uploadtext.text(t('files', '{count} files uploading', {count: currentUploads}));
}
+ delete uploadingFiles[dirName][fileName];
$('#notification').hide();
$('#notification').text(t('files', 'Upload cancelled.'));
$('#notification').fadeIn();
@@ -374,8 +376,10 @@ $(document).ready(function() {
if(size==t('files','Pending')){
$('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
}
+ //TODO update file upload size limit
FileList.loadingDone(file.name, file.id);
} else {
+ Files.cancelUpload(this.files[0].name);
$('#notification').text(t('files', response.data.message));
$('#notification').fadeIn();
$('#fileList > tr').not('[data-mime]').fadeOut();
@@ -384,6 +388,7 @@ $(document).ready(function() {
})
.error(function(jqXHR, textStatus, errorThrown) {
if(errorThrown === 'abort') {
+ Files.cancelUpload(this.files[0].name);
$('#notification').hide();
$('#notification').text(t('files', 'Upload cancelled.'));
$('#notification').fadeIn();
@@ -404,8 +409,10 @@ $(document).ready(function() {
if(size==t('files','Pending')){
$('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
}
+ //TODO update file upload size limit
FileList.loadingDone(file.name, file.id);
} else {
+ //TODO Files.cancelUpload(/*where do we get the filename*/);
$('#notification').text(t('files', response.data.message));
$('#notification').fadeIn();
$('#fileList > tr').not('[data-mime]').fadeOut();
@@ -446,7 +453,7 @@ $(document).ready(function() {
// http://stackoverflow.com/a/6700/11236
var size = 0, key;
for (key in obj) {
- if (obj.hasOwnProperty(key)) size++;
+ if (obj.hasOwnProperty(key)) size++;
}
return size;
};
@@ -489,7 +496,7 @@ $(document).ready(function() {
$('#new').removeClass('active');
$('#new li').each(function(i,element){
if($(element).children('p').length==0){
- $(element).children('input').remove();
+ $(element).children('form').remove();
$(element).append('<p>'+$(element).data('text')+'</p>');
}
});
@@ -508,7 +515,7 @@ $(document).ready(function() {
$('#new li').each(function(i,element){
if($(element).children('p').length==0){
- $(element).children('input').remove();
+ $(element).children('form').remove();
$(element).append('<p>'+$(element).data('text')+'</p>');
}
});
@@ -517,23 +524,32 @@ $(document).ready(function() {
var text=$(this).children('p').text();
$(this).data('text',text);
$(this).children('p').remove();
+ var form=$('<form></form>');
var input=$('<input>');
- $(this).append(input);
+ form.append(input);
+ $(this).append(form);
input.focus();
- input.change(function(){
- if (type != 'web' && !Files.isFileNameValid($(this).val())) {
- return;
- } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') {
- $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud'));
+ form.submit(function(event){
+ event.stopPropagation();
+ event.preventDefault();
+ var newname=input.val();
+ if(type == 'web' && newname.length == 0) {
+ $('#notification').text(t('files', 'URL cannot be empty.'));
$('#notification').fadeIn();
- return;
+ return false;
+ } else if (type != 'web' && !Files.isFileNameValid(newname)) {
+ return false;
+ } else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') {
+ $('#notification').text(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud'));
+ $('#notification').fadeIn();
+ return false;
}
if (FileList.lastAction) {
FileList.lastAction();
}
- var name = getUniqueName($(this).val());
- if (name != $(this).val()) {
- FileList.checkName(name, $(this).val(), true);
+ var name = getUniqueName(newname);
+ if (newname != name) {
+ FileList.checkName(name, newname, true);
var hidden = true;
} else {
var hidden = false;
@@ -577,7 +593,7 @@ $(document).ready(function() {
break;
case 'web':
if(name.substr(0,8)!='https://' && name.substr(0,7)!='http://'){
- name='http://'.name;
+ name='http://'+name;
}
var localName=name;
if(localName.substr(localName.length-1,1)=='/'){//strip /
@@ -616,8 +632,8 @@ $(document).ready(function() {
});
break;
}
- var li=$(this).parent();
- $(this).remove();
+ var li=form.parent();
+ form.remove();
li.append('<p>'+li.data('text')+'</p>');
$('#new>a').click();
});
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php
index edf048c7e13..2e0772443f2 100644
--- a/apps/files/templates/index.php
+++ b/apps/files/templates/index.php
@@ -14,7 +14,8 @@
data-type='web'><p><?php echo $l->t('From link');?></p></li>
</ul>
</div>
- <div id="upload" class="button">
+ <div id="upload" class="button"
+ title="<?php echo $l->t('Upload') . ' max. '.$_['uploadMaxHumanFilesize'] ?>">
<form data-upload-id='1'
id="data-upload-form"
class="file_upload_form"
@@ -31,10 +32,7 @@
value="(max <?php echo $_['uploadMaxHumanFilesize']; ?>)">
<input type="hidden" name="dir" value="<?php echo $_['dir'] ?>" id="dir">
<input type="file" id="file_upload_start" name='files[]'/>
- <a href="#" class="svg" onclick="return false;"
- title="<?php echo $l->t('Upload') . ' max. '.$_['uploadMaxHumanFilesize'] ?>"></a>
-
- <iframe name="file_upload_target_1" class="file_upload_target" src=""></iframe>
+ <a href="#" class="svg" onclick="return false;"></a>
</form>
</div>
<div id="uploadprogresswrapper">
diff --git a/core/css/styles.css b/core/css/styles.css
index 376e3a2f49b..496320561f8 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -56,7 +56,7 @@ input[type="checkbox"]:hover+label, input[type="checkbox"]:focus+label { color:#
/* BUTTONS */
input[type="submit"], input[type="button"], button, .button, #quota, div.jp-progress, select, .pager li a {
width:auto; padding:.4em;
- background-color:rgba(230,230,230,.5); font-weight:bold; color:#555; text-shadow:#fff 0 1px 0; border:1px solid rgba(180,180,180,.5); cursor:pointer;
+ background-color:rgba(230,230,230,.5); font-weight:bold; color:#555; text-shadow:#fff 0 1px 0; border:1px solid #bbb; border:1px solid rgba(180,180,180,.5); cursor:pointer;
-moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset;
-moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em;
}
diff --git a/core/js/config.js b/core/js/config.js
index f7a29276f7d..563df4e6632 100644
--- a/core/js/config.js
+++ b/core/js/config.js
@@ -50,6 +50,6 @@ OC.AppConfig={
},
deleteApp:function(app){
OC.AppConfig.postCall('deleteApp',{app:app});
- },
+ }
};
//TODO OC.Preferences
diff --git a/core/js/js.js b/core/js/js.js
index 610950995db..95889ac8a27 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -343,8 +343,15 @@ if(typeof localStorage !=='undefined' && localStorage !== null){
return localStorage.setItem(OC.localStorage.namespace+name,JSON.stringify(item));
},
getItem:function(name){
- if(localStorage.getItem(OC.localStorage.namespace+name)===null){return null;}
- return JSON.parse(localStorage.getItem(OC.localStorage.namespace+name));
+ var item = localStorage.getItem(OC.localStorage.namespace+name);
+ if(item===null) {
+ return null;
+ } else if (typeof JSON === 'undefined') {
+ //fallback to jquery for IE6/7/8
+ return $.parseJSON(item);
+ } else {
+ return JSON.parse(item);
+ }
}
};
}else{
@@ -615,7 +622,7 @@ $(document).ready(function(){
$('.jp-controls .jp-previous').tipsy({gravity:'nw', fade:true, live:true});
$('.jp-controls .jp-next').tipsy({gravity:'n', fade:true, live:true});
$('.password .action').tipsy({gravity:'se', fade:true, live:true});
- $('#upload a').tipsy({gravity:'w', fade:true});
+ $('#upload').tipsy({gravity:'w', fade:true});
$('.selectedActions a').tipsy({gravity:'s', fade:true, live:true});
$('a.delete').tipsy({gravity: 'e', fade:true, live:true});
$('a.action').tipsy({gravity:'s', fade:true, live:true});