Drive rename: save pads and folders name on click, cancel with Esc.
This commit is contained in:
parent
f7002a0bf7
commit
e1c02fd8a4
@ -245,7 +245,13 @@ define([
|
|||||||
if (!$container.length) { return; }
|
if (!$container.length) { return; }
|
||||||
$container.html('');
|
$container.html('');
|
||||||
};
|
};
|
||||||
var removeInput = function () {
|
var removeInput = function (cancel) {
|
||||||
|
if (!cancel && $iframe.find('.element-row > input').length === 1) {
|
||||||
|
var $input = $iframe.find('.element-row > input');
|
||||||
|
filesOp.renameElement($input.data('path'), $input.val(), function () {
|
||||||
|
refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
$iframe.find('.element-row > input').remove();
|
$iframe.find('.element-row > input').remove();
|
||||||
$iframe.find('.element-row > span:hidden').removeAttr('style');
|
$iframe.find('.element-row > span:hidden').removeAttr('style');
|
||||||
};
|
};
|
||||||
@ -306,13 +312,17 @@ define([
|
|||||||
var $input = $('<input>', {
|
var $input = $('<input>', {
|
||||||
placeholder: name,
|
placeholder: name,
|
||||||
value: name
|
value: name
|
||||||
});
|
}).data('path', path);
|
||||||
$input.on('keyup', function (e) {
|
$input.on('keyup', function (e) {
|
||||||
if (e.which === 13) {
|
if (e.which === 13) {
|
||||||
removeInput();
|
removeInput(true);
|
||||||
filesOp.renameElement(path, $input.val(), function () {
|
filesOp.renameElement(path, $input.val(), function () {
|
||||||
refresh();
|
refresh();
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.which === 27) {
|
||||||
|
removeInput(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//$element.parent().append($input);
|
//$element.parent().append($input);
|
||||||
@ -1812,12 +1822,12 @@ define([
|
|||||||
$(ifrw).on('click', function (e) {
|
$(ifrw).on('click', function (e) {
|
||||||
if (e.which !== 1) { return ; }
|
if (e.which !== 1) { return ; }
|
||||||
removeSelected(e);
|
removeSelected(e);
|
||||||
removeInput(e);
|
removeInput();
|
||||||
module.hideMenu(e);
|
module.hideMenu(e);
|
||||||
hideNewButton();
|
hideNewButton();
|
||||||
});
|
});
|
||||||
$(ifrw).on('drag drop', function (e) {
|
$(ifrw).on('drag drop', function (e) {
|
||||||
removeInput(e);
|
removeInput();
|
||||||
module.hideMenu(e);
|
module.hideMenu(e);
|
||||||
});
|
});
|
||||||
$(ifrw).on('mouseup drop', function (e) {
|
$(ifrw).on('mouseup drop', function (e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user