Merge pull request #938 from owncloud/fix_minor_files_annoyances

Fix minor files annoyances
This commit is contained in:
Thomas Tanghus 2013-01-08 15:02:06 -08:00
commit dae8f15f9f
7 changed files with 83 additions and 56 deletions

View File

@ -21,14 +21,14 @@
#new>ul>li { height:20px; margin:.3em; padding-left:2em; padding-bottom:0.1em; #new>ul>li { height:20px; margin:.3em; padding-left:2em; padding-bottom:0.1em;
background-repeat:no-repeat; cursor:pointer; } background-repeat:no-repeat; cursor:pointer; }
#new>ul>li>p { 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 { #upload {
height:27px; padding:0; margin-left:0.2em; overflow:hidden; height:27px; padding:0; margin-left:0.2em; overflow:hidden;
} }
#upload a { #upload a {
position:relative; display:block; width:100%; height:27px; 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-image:url('%webroot%/core/img/actions/upload.svg');
background-repeat:no-repeat; background-repeat:no-repeat;
background-position:7px 6px; background-position:7px 6px;
@ -39,7 +39,7 @@
left:0; top:0; width:28px; height:27px; padding:0; left:0; top:0; width:28px; height:27px; padding:0;
font-size:1em; font-size:1em;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; -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; } #uploadprogresswrapper { position:absolute; right:13.5em; top:0em; }

View File

@ -151,8 +151,7 @@ var FileList={
var newname=input.val(); var newname=input.val();
if (!Files.isFileNameValid(newname)) { if (!Files.isFileNameValid(newname)) {
return false; return false;
} } else if (newname != name) {
if (newname != name) {
if (FileList.checkName(name, newname, false)) { if (FileList.checkName(name, newname, false)) {
newname = name; newname = name;
} else { } else {
@ -185,6 +184,13 @@ var FileList={
td.children('a.name').show(); td.children('a.name').show();
return false; 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){ input.click(function(event){
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();

View File

@ -26,19 +26,19 @@ Files={
}); });
procesSelection(); procesSelection();
}, },
isFileNameValid:function (name) { isFileNameValid:function (name) {
if (name === '.') { if (name === '.') {
$('#notification').text(t('files', "'.' is an invalid file name.")); $('#notification').text(t('files', '\'.\' is an invalid file name.'));
$('#notification').fadeIn(); $('#notification').fadeIn();
return false; return false;
} }
if (name.length == 0) { if (name.length == 0) {
$('#notification').text(t('files', "File name cannot be empty.")); $('#notification').text(t('files', 'File name cannot be empty.'));
$('#notification').fadeIn(); $('#notification').fadeIn();
return false; return false;
} }
// check for invalid characters // check for invalid characters
var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
for (var i = 0; i < invalid_characters.length; i++) { for (var i = 0; i < invalid_characters.length; i++) {
if (name.indexOf(invalid_characters[i]) != -1) { if (name.indexOf(invalid_characters[i]) != -1) {
@ -246,12 +246,12 @@ $(document).ready(function() {
} }
}); });
}else{ }else{
var dropTarget = $(e.originalEvent.target).closest('tr'); var dropTarget = $(e.originalEvent.target).closest('tr');
if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder
var dirName = dropTarget.attr('data-file') var dirName = dropTarget.attr('data-file')
} }
var date=new Date(); var date=new Date();
if(files){ if(files){
for(var i=0;i<files.length;i++){ for(var i=0;i<files.length;i++){
if(files[i].size>0){ if(files[i].size>0){
@ -304,9 +304,9 @@ $(document).ready(function() {
var jqXHR = $('#file_upload_start').fileupload('send', {files: files[i], var jqXHR = $('#file_upload_start').fileupload('send', {files: files[i],
formData: function(form) { formData: function(form) {
var formArray = form.serializeArray(); var formArray = form.serializeArray();
// array index 0 contains the max files size // array index 0 contains the max files size
// array index 1 contains the request token // array index 1 contains the request token
// array index 2 contains the directory // array index 2 contains the directory
formArray[2]['value'] = dirName; formArray[2]['value'] = dirName;
return formArray; return formArray;
}}).success(function(result, textStatus, jqXHR) { }}).success(function(result, textStatus, jqXHR) {
@ -317,13 +317,14 @@ $(document).ready(function() {
$('#notification').fadeIn(); $('#notification').fadeIn();
} }
var file=response[0]; 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]; delete uploadingFiles[dirName][file.name];
if ($.assocArraySize(uploadingFiles[dirName]) == 0) { if ($.assocArraySize(uploadingFiles[dirName]) == 0) {
delete uploadingFiles[dirName]; 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')); var currentUploads = parseInt(uploadtext.attr('currentUploads'));
currentUploads -= 1; currentUploads -= 1;
uploadtext.attr('currentUploads', currentUploads); uploadtext.attr('currentUploads', currentUploads);
@ -351,6 +352,7 @@ $(document).ready(function() {
} else { } else {
uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); uploadtext.text(t('files', '{count} files uploading', {count: currentUploads}));
} }
delete uploadingFiles[dirName][fileName];
$('#notification').hide(); $('#notification').hide();
$('#notification').text(t('files', 'Upload cancelled.')); $('#notification').text(t('files', 'Upload cancelled.'));
$('#notification').fadeIn(); $('#notification').fadeIn();
@ -374,8 +376,10 @@ $(document).ready(function() {
if(size==t('files','Pending')){ if(size==t('files','Pending')){
$('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
} }
//TODO update file upload size limit
FileList.loadingDone(file.name, file.id); FileList.loadingDone(file.name, file.id);
} else { } else {
Files.cancelUpload(this.files[0].name);
$('#notification').text(t('files', response.data.message)); $('#notification').text(t('files', response.data.message));
$('#notification').fadeIn(); $('#notification').fadeIn();
$('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').fadeOut();
@ -384,6 +388,7 @@ $(document).ready(function() {
}) })
.error(function(jqXHR, textStatus, errorThrown) { .error(function(jqXHR, textStatus, errorThrown) {
if(errorThrown === 'abort') { if(errorThrown === 'abort') {
Files.cancelUpload(this.files[0].name);
$('#notification').hide(); $('#notification').hide();
$('#notification').text(t('files', 'Upload cancelled.')); $('#notification').text(t('files', 'Upload cancelled.'));
$('#notification').fadeIn(); $('#notification').fadeIn();
@ -404,8 +409,10 @@ $(document).ready(function() {
if(size==t('files','Pending')){ if(size==t('files','Pending')){
$('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
} }
//TODO update file upload size limit
FileList.loadingDone(file.name, file.id); FileList.loadingDone(file.name, file.id);
} else { } else {
//TODO Files.cancelUpload(/*where do we get the filename*/);
$('#notification').text(t('files', response.data.message)); $('#notification').text(t('files', response.data.message));
$('#notification').fadeIn(); $('#notification').fadeIn();
$('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').fadeOut();
@ -446,7 +453,7 @@ $(document).ready(function() {
// http://stackoverflow.com/a/6700/11236 // http://stackoverflow.com/a/6700/11236
var size = 0, key; var size = 0, key;
for (key in obj) { for (key in obj) {
if (obj.hasOwnProperty(key)) size++; if (obj.hasOwnProperty(key)) size++;
} }
return size; return size;
}; };
@ -489,7 +496,7 @@ $(document).ready(function() {
$('#new').removeClass('active'); $('#new').removeClass('active');
$('#new li').each(function(i,element){ $('#new li').each(function(i,element){
if($(element).children('p').length==0){ if($(element).children('p').length==0){
$(element).children('input').remove(); $(element).children('form').remove();
$(element).append('<p>'+$(element).data('text')+'</p>'); $(element).append('<p>'+$(element).data('text')+'</p>');
} }
}); });
@ -508,7 +515,7 @@ $(document).ready(function() {
$('#new li').each(function(i,element){ $('#new li').each(function(i,element){
if($(element).children('p').length==0){ if($(element).children('p').length==0){
$(element).children('input').remove(); $(element).children('form').remove();
$(element).append('<p>'+$(element).data('text')+'</p>'); $(element).append('<p>'+$(element).data('text')+'</p>');
} }
}); });
@ -517,23 +524,32 @@ $(document).ready(function() {
var text=$(this).children('p').text(); var text=$(this).children('p').text();
$(this).data('text',text); $(this).data('text',text);
$(this).children('p').remove(); $(this).children('p').remove();
var form=$('<form></form>');
var input=$('<input>'); var input=$('<input>');
$(this).append(input); form.append(input);
$(this).append(form);
input.focus(); input.focus();
input.change(function(){ form.submit(function(event){
if (type != 'web' && !Files.isFileNameValid($(this).val())) { event.stopPropagation();
return; event.preventDefault();
} else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { var newname=input.val();
$('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); if(type == 'web' && newname.length == 0) {
$('#notification').text(t('files', 'URL cannot be empty.'));
$('#notification').fadeIn(); $('#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) { if (FileList.lastAction) {
FileList.lastAction(); FileList.lastAction();
} }
var name = getUniqueName($(this).val()); var name = getUniqueName(newname);
if (name != $(this).val()) { if (newname != name) {
FileList.checkName(name, $(this).val(), true); FileList.checkName(name, newname, true);
var hidden = true; var hidden = true;
} else { } else {
var hidden = false; var hidden = false;
@ -577,7 +593,7 @@ $(document).ready(function() {
break; break;
case 'web': case 'web':
if(name.substr(0,8)!='https://' && name.substr(0,7)!='http://'){ if(name.substr(0,8)!='https://' && name.substr(0,7)!='http://'){
name='http://'.name; name='http://'+name;
} }
var localName=name; var localName=name;
if(localName.substr(localName.length-1,1)=='/'){//strip / if(localName.substr(localName.length-1,1)=='/'){//strip /
@ -616,8 +632,8 @@ $(document).ready(function() {
}); });
break; break;
} }
var li=$(this).parent(); var li=form.parent();
$(this).remove(); form.remove();
li.append('<p>'+li.data('text')+'</p>'); li.append('<p>'+li.data('text')+'</p>');
$('#new>a').click(); $('#new>a').click();
}); });

View File

@ -14,7 +14,8 @@
data-type='web'><p><?php echo $l->t('From link');?></p></li> data-type='web'><p><?php echo $l->t('From link');?></p></li>
</ul> </ul>
</div> </div>
<div id="upload" class="button"> <div id="upload" class="button"
title="<?php echo $l->t('Upload') . ' max. '.$_['uploadMaxHumanFilesize'] ?>">
<form data-upload-id='1' <form data-upload-id='1'
id="data-upload-form" id="data-upload-form"
class="file_upload_form" class="file_upload_form"
@ -31,10 +32,7 @@
value="(max <?php echo $_['uploadMaxHumanFilesize']; ?>)"> value="(max <?php echo $_['uploadMaxHumanFilesize']; ?>)">
<input type="hidden" name="dir" value="<?php echo $_['dir'] ?>" id="dir"> <input type="hidden" name="dir" value="<?php echo $_['dir'] ?>" id="dir">
<input type="file" id="file_upload_start" name='files[]'/> <input type="file" id="file_upload_start" name='files[]'/>
<a href="#" class="svg" onclick="return false;" <a href="#" class="svg" onclick="return false;"></a>
title="<?php echo $l->t('Upload') . ' max. '.$_['uploadMaxHumanFilesize'] ?>"></a>
<iframe name="file_upload_target_1" class="file_upload_target" src=""></iframe>
</form> </form>
</div> </div>
<div id="uploadprogresswrapper"> <div id="uploadprogresswrapper">

View File

@ -56,7 +56,7 @@ input[type="checkbox"]:hover+label, input[type="checkbox"]:focus+label { color:#
/* BUTTONS */ /* BUTTONS */
input[type="submit"], input[type="button"], button, .button, #quota, div.jp-progress, select, .pager li a { input[type="submit"], input[type="button"], button, .button, #quota, div.jp-progress, select, .pager li a {
width:auto; padding:.4em; 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-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; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em;
} }

View File

@ -50,6 +50,6 @@ OC.AppConfig={
}, },
deleteApp:function(app){ deleteApp:function(app){
OC.AppConfig.postCall('deleteApp',{app:app}); OC.AppConfig.postCall('deleteApp',{app:app});
}, }
}; };
//TODO OC.Preferences //TODO OC.Preferences

View File

@ -343,8 +343,15 @@ if(typeof localStorage !=='undefined' && localStorage !== null){
return localStorage.setItem(OC.localStorage.namespace+name,JSON.stringify(item)); return localStorage.setItem(OC.localStorage.namespace+name,JSON.stringify(item));
}, },
getItem:function(name){ getItem:function(name){
if(localStorage.getItem(OC.localStorage.namespace+name)===null){return null;} var item = localStorage.getItem(OC.localStorage.namespace+name);
return JSON.parse(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{ }else{
@ -615,7 +622,7 @@ $(document).ready(function(){
$('.jp-controls .jp-previous').tipsy({gravity:'nw', fade:true, live:true}); $('.jp-controls .jp-previous').tipsy({gravity:'nw', fade:true, live:true});
$('.jp-controls .jp-next').tipsy({gravity:'n', fade:true, live:true}); $('.jp-controls .jp-next').tipsy({gravity:'n', fade:true, live:true});
$('.password .action').tipsy({gravity:'se', 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}); $('.selectedActions a').tipsy({gravity:'s', fade:true, live:true});
$('a.delete').tipsy({gravity: 'e', fade:true, live:true}); $('a.delete').tipsy({gravity: 'e', fade:true, live:true});
$('a.action').tipsy({gravity:'s', fade:true, live:true}); $('a.action').tipsy({gravity:'s', fade:true, live:true});