fix undo on edit and edit icon hiding
This commit is contained in:
@@ -18,21 +18,26 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// toggle visibility of port up/down and edit controls
|
// toggle visibility of port up/down and edit controls
|
||||||
$('.nd_editable_cell').hover(function() {
|
|
||||||
$(this).children('.nd_hand_icon').toggle();
|
$('.nd_editable_cell').mouseenter(function() {
|
||||||
if ($(this).is(':focus')) {
|
$(this).children('.nd_hand_icon').show();
|
||||||
$(this).children('.nd_edit_icon').toggle(false); // ports
|
if (! $(this).is(':focus')) {
|
||||||
$(this).siblings('td').find('.nd_device_details_edit').toggle(false); // details
|
$(this).children('.nd_edit_icon').show(); // ports
|
||||||
|
$(this).siblings('td').find('.nd_device_details_edit').show(); // details
|
||||||
}
|
}
|
||||||
else {
|
});
|
||||||
$(this).children('.nd_edit_icon').toggle(); // ports
|
|
||||||
$(this).siblings('td').find('.nd_device_details_edit').toggle(); // details
|
$('.nd_editable_cell').mouseleave(function() {
|
||||||
|
$(this).children('.nd_hand_icon').hide();
|
||||||
|
if (! $(this).is(':focus')) {
|
||||||
|
$(this).children('.nd_edit_icon').hide(); // ports
|
||||||
|
$(this).siblings('td').find('.nd_device_details_edit').hide(); // details
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('[contenteditable=true]').focus(function() {
|
$('[contenteditable=true]').focus(function() {
|
||||||
$(this).children('.nd_edit_icon').toggle(false); // ports
|
$(this).children('.nd_edit_icon').hide(); // ports
|
||||||
$(this).siblings('td').find('.nd_device_details_edit').toggle(false); // details
|
$(this).siblings('td').find('.nd_device_details_edit').hide(); // details
|
||||||
});
|
});
|
||||||
|
|
||||||
// activity for port up/down control
|
// activity for port up/down control
|
||||||
@@ -43,20 +48,28 @@
|
|||||||
port_control(this); // save
|
port_control(this); // save
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var dirty = false;
|
||||||
|
|
||||||
// activity for contenteditable control
|
// activity for contenteditable control
|
||||||
$('[contenteditable=true]').keydown(function() {
|
$('[contenteditable=true]').keydown(function() {
|
||||||
var esc = event.which == 27,
|
var esc = event.which == 27,
|
||||||
nl = event.which == 13;
|
nl = event.which == 13;
|
||||||
|
|
||||||
if (esc) {
|
if (esc) {
|
||||||
document.execCommand('undo');
|
if (dirty) { document.execCommand('undo') }
|
||||||
$(this).blur();
|
$(this).blur();
|
||||||
|
dirty = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (nl) {
|
else if (nl) {
|
||||||
$(this).blur();
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
$(this).blur();
|
||||||
|
dirty = false;
|
||||||
port_control(this); // save
|
port_control(this); // save
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// activate tooltips
|
// activate tooltips
|
||||||
|
|||||||
Reference in New Issue
Block a user