Skip to content

Commit

Permalink
Removed keyboard listening from ext.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsfy committed Jul 25, 2016
1 parent 80d0422 commit cd4b982
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
28 changes: 2 additions & 26 deletions cytoscape-clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
var cy = this;

var options = {
clipboardSize: 0,
shortcuts: {
enabled: true,
undoable: true
}
clipboardSize: 0
};

$.extend(true, options, opts);
Expand Down Expand Up @@ -82,27 +78,7 @@
if (!initialized) {
initialized = true;
var ur;
var clipboard = {};
if (options.shortcuts.enabled) {
var undoable = options.shortcuts.undoable && (cy.undoRedo ? true : false);
if (undoable)
ur = cy.undoRedo({}, true);

document.addEventListener("keydown", function (e) {
if (e.ctrlKey && e.target.nodeName === 'BODY')
if (e.which == 67) // CTRL + C
_instance.copy(cy.$(":selected"));
else if (e.which == 86) // CTRL + V
if (undoable)
ur.do("paste");
else
_instance.paste();
else if (e.which == 65) {
cy.elements().select();
e.preventDefault();
}
});
}
var clipboard = {};

_instance = {
copy: function (eles, _id) {
Expand Down
11 changes: 11 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@
});
var cb = cy.clipboard();

document.addEventListener("keydown", function (e) {
if (e.ctrlKey && e.target.nodeName === 'BODY')
if (e.which == 67) // CTRL + C
cy.clipboard().copy(cy.$(":selected"));
else if (e.which == 86) // CTRL + V
ur.do("paste");
else if (e.which == 65) {
cy.elements().select();
e.preventDefault();
}
});
});
</script>
</head>
Expand Down

0 comments on commit cd4b982

Please sign in to comment.