Fix for chrome escape key, also fixes unbind issue with file manager after escaping

closes #122
closes #121
This commit is contained in:
Dane Everitt 2016-10-06 17:53:28 -04:00
parent 1512c73bb5
commit 5356ee379e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -98,12 +98,12 @@ class ActionsClass {
const inputLoader = nameBlock.find('.input-loader'); const inputLoader = nameBlock.find('.input-loader');
inputField.focus(); inputField.focus();
inputField.on('blur keypress', e => { inputField.on('blur keydown', e => {
// Save Field // Save Field
if ( if (
(e.type === 'keypress' && e.which === 27) (e.type === 'keydown' && e.which === 27)
|| e.type === 'blur' || e.type === 'blur'
|| (e.type === 'keypress' && e.which === 13 && currentName === inputField.val()) || (e.type === 'keydown' && e.which === 13 && currentName === inputField.val())
) { ) {
if (!_.isEmpty(currentLink)) { if (!_.isEmpty(currentLink)) {
nameBlock.html(currentLink); nameBlock.html(currentLink);
@ -111,13 +111,11 @@ class ActionsClass {
nameBlock.html(currentName); nameBlock.html(currentName);
} }
inputField.remove(); inputField.remove();
ContextMenu.run(); ContextMenu.unbind().run();
return; return;
} }
if (e.type === 'keypress' && e.which !== 13) return; if (e.type === 'keydown' && e.which !== 13) return;
console.log('did not');
inputLoader.show(); inputLoader.show();
const currentPath = decodeURIComponent(nameBlock.data('path')); const currentPath = decodeURIComponent(nameBlock.data('path'));
@ -138,7 +136,10 @@ class ActionsClass {
}).done(data => { }).done(data => {
nameBlock.attr('data-name', inputField.val()); nameBlock.attr('data-name', inputField.val());
if (!_.isEmpty(currentLink)) { if (!_.isEmpty(currentLink)) {
const newLink = currentLink.attr('href').substr(0, currentLink.attr('href').lastIndexOf('/')) + '/' + inputField.val(); let newLink = currentLink.attr('href');
if (nameBlock.parent().data('type') !== 'folder') {
newLink = newLink.substr(0, newLink.lastIndexOf('/')) + '/' + inputField.val();
}
currentLink.attr('href', newLink); currentLink.attr('href', newLink);
nameBlock.html( nameBlock.html(
currentLink.html(inputField.val()) currentLink.html(inputField.val())
@ -164,6 +165,7 @@ class ActionsClass {
}).popover('show'); }).popover('show');
}).always(() => { }).always(() => {
inputLoader.remove(); inputLoader.remove();
ContextMenu.unbind().run();
}); });
}); });
} }