Skip to content

Commit

Permalink
Fixed multiple initialization bug #3
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsfy committed Jul 15, 2016
1 parent 41e2923 commit 2933cb5
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions cytoscape-undo-redo.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,20 @@
};


var isInitialized = false;
// design implementation
cytoscape("core", "undoRedo", function (options, dontInit) {
cy = this;



function getScratch() {
if (!cy.scratch("_undoRedo")) {
cy.scratch("_undoRedo", { });

}
return cy.scratch("_undoRedo")
}

if (options) {
for (var key in options)
if (_instance.options.hasOwnProperty(key))
Expand All @@ -58,10 +68,12 @@

}

if (!isInitialized && !dontInit) {
if (_instance.options.keyboardShortcuts) {
if (!getScratch().isInitialized && !dontInit) {
if (_instance.options.keyboardShortcuts && !getScratch().isKeyboardShortcutsSet) {
var sh = _instance.options.keyboardShortcuts;
setKeyboardShortcuts(sh.ctrl_z, sh.ctrl_y, sh.ctrl_shift_z);
getScratch().isKeyboardShortcutsSet = true;

} else
setKeyboardShortcuts(false, false, false);
var defActions = defaultActions();
Expand All @@ -70,8 +82,7 @@


setDragUndo(_instance.options.undoableDrag);

isInitialized = true;
getScratch().isInitialized = true
}

_instance.options.ready();
Expand Down

0 comments on commit 2933cb5

Please sign in to comment.