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