Skip to content

Commit

Permalink
Fix for chrome escape key, also fixes unbind issue with file manager …
Browse files Browse the repository at this point in the history
…after escaping

closes #122
closes #121
  • Loading branch information
DaneEveritt committed Oct 6, 2016
1 parent 1512c73 commit 5356ee3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions resources/views/server/js/filemanager/actions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,24 @@ 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);
} else {
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'));
Expand All @@ -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())
Expand All @@ -164,6 +165,7 @@ class ActionsClass {
}).popover('show');
}).always(() => {
inputLoader.remove();
ContextMenu.unbind().run();
});
});
}
Expand Down

0 comments on commit 5356ee3

Please sign in to comment.