Keep plugin state in state manager (fixes #201)
Change-Id: If4a5305f3e41f1fcac4a47afeba613b3106c69fa
diff --git a/dev/js/src/plugin/server.js b/dev/js/src/plugin/server.js
index b95d830..bdc4873 100644
--- a/dev/js/src/plugin/server.js
+++ b/dev/js/src/plugin/server.js
@@ -14,13 +14,7 @@
KorAP.Panel = KorAP.Panel || {};
const d = document;
-
- // State manager undefined
- const states = KorAP.States ? KorAP.States :
-
- // Not serialized state manager
- stateManagerClass.create(document.createElement('input'));
-
+
// Contains all servicess to address with
// messages to them
var services = {};
@@ -75,6 +69,11 @@
this._q = d.getElementById("q-field")
this._cutoff = d.getElementById("q-cutoff-field");
+ // State manager undefined
+ this._states = KorAP.States ? KorAP.States :
+ // Not serialized state manager
+ stateManagerClass.create(document.createElement('input'));
+
return this;
},
@@ -246,7 +245,7 @@
// Accept a "value" list here for toggling, which should
// also allow for "rolling" through states via CSS classes
// as 'toggle-true', 'toggle-false' etc.
- let state = states.newState(
+ let state = that._states.newState(
(onClick["state"] ? onClick["state"] : name),
[true, false],
onClick["default"]
@@ -651,7 +650,7 @@
// Return states object
states : function () {
- return states;
+ return this._states;
},
// Destructor, just for testing scenarios