Trim file name

This commit is contained in:
OVSharova 2022-01-11 03:35:54 +03:00
parent 09b6079ed4
commit c482be11c8

View file

@ -124,7 +124,7 @@ define([
'<div class="btn-slot" id="slot-btn-dt-redo"></div>' + '<div class="btn-slot" id="slot-btn-dt-redo"></div>' +
'</div>' + '</div>' +
'<div class="lr-separator" id="id-box-doc-name">' + '<div class="lr-separator" id="id-box-doc-name">' +
// '<label id="title-doc-name" />' + // '<label id="title-doc-name" /></label>' +
'<input id="title-doc-name" /></input>' + '<input id="title-doc-name" /></input>' +
'</div>' + '</div>' +
'<label id="title-user-name"></label>' + '<label id="title-user-name"></label>' +
@ -356,6 +356,20 @@ define([
me.btnOptions.updateHint(me.tipViewSettings); me.btnOptions.updateHint(me.tipViewSettings);
} }
function onFocusDocName(e){
var me = this;
if(me.options.isNotTrimAfterPoint) return;
var name = me.labelDocName.val();
var idx = name.lastIndexOf('.');
if (idx>0)
name = name.substring(0, idx);
_.delay(function(){
me.labelDocName.val(name);
},100);
}
function onDocNameKeyDown(e) { function onDocNameKeyDown(e) {
var me = this; var me = this;
@ -369,11 +383,12 @@ define([
msg: (new Common.Views.RenameDialog).txtInvalidName + "*+:\"<>?|\/" msg: (new Common.Views.RenameDialog).txtInvalidName + "*+:\"<>?|\/"
, callback: function() { , callback: function() {
_.delay(function() { _.delay(function() {
me.options.isNotTrimAfterPoint = true;
me.labelDocName.focus(); me.labelDocName.focus();
}, 50); }, 50);
} }
}); });
me.api.asc_wopi_renameFile(name);
me.labelDocName.blur(); me.labelDocName.blur();
}) })
} else { } else {
@ -635,8 +650,9 @@ define([
if ( this.labelDocName ) { if ( this.labelDocName ) {
this.labelDocName.val( value ); this.labelDocName.val( value );
// this.labelDocName.attr('size', value.length); // this.labelDocName.attr('size', value.length);
this.setCanRename(this.options.canRename);
this.setCanRename(true); //this.setCanRename(true);
} }
return value; return value;
@ -696,8 +712,9 @@ define([
label.on({ label.on({
'keydown': onDocNameKeyDown.bind(this), 'keydown': onDocNameKeyDown.bind(this),
'focus': onFocusDocName.bind(this),
'blur': function (e) { 'blur': function (e) {
me.options.isNotTrimAfterPoint =false;
} }
}); });