]> source.dussan.org Git - nextcloud-server.git/commitdiff
peselect filename without extension on rename
authorJörn Friedrich Dreyer <jfd@butonic.de>
Mon, 13 May 2013 13:54:45 +0000 (15:54 +0200)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Mon, 13 May 2013 13:54:45 +0000 (15:54 +0200)
apps/files/js/filelist.js
core/js/js.js

index b1e9a885063e735d1f394a0750c4922bce4ebbb7..c24d1fd8244dd124d781e41f140cae700b6bb528 100644 (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();
index d85e6d88f8aed5529840b2a10875b98745596ab3..3cb4d3dd151582915626c2363dc106b4a7de1fc3 100644 (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