Merge pull request #3330 from owncloud/preselect_filename_on_rename

peselect filename without extension on rename
This commit is contained in:
Morris Jobke 2013-05-14 06:16:30 -07:00
commit 784f117ec2
2 changed files with 27 additions and 0 deletions

View File

@ -191,6 +191,13 @@ var FileList={
td.children('a.name').hide();
td.append(form);
input.focus();
//preselect input
var len = input.val().lastIndexOf('.');
if (len === -1) {
len = input.val().length;
}
input.selectRange(0,len);
form.submit(function(event){
event.stopPropagation();
event.preventDefault();

View File

@ -767,6 +767,26 @@ OC.set=function(name, value) {
context[tail]=value;
};
/**
* select a range in an input field
* @link http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area
* @param {type} start
* @param {type} end
*/
$.fn.selectRange = function(start, end) {
return this.each(function() {
if (this.setSelectionRange) {
this.focus();
this.setSelectionRange(start, end);
} else if (this.createTextRange) {
var range = this.createTextRange();
range.collapse(true);
range.moveEnd('character', end);
range.moveStart('character', start);
range.select();
}
});
};
/**
* Calls the server periodically every 15 mins to ensure that session doesnt