Minor changes in the vc api
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 66bc081..cd0adfc 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -70,11 +70,37 @@
)
);
input.parentNode.insertBefore(vcname, input);
-
+
+ /**
+ * Toggle the Virtual Collection builder
+ */
+ var vc;
vcname.onclick = function () {
- var vc = vcClass.render(vcExample);
var view = document.getElementById('vc-view');
- view.appendChild(vc.element());
+
+ // The vc is visible
+ if (this.classList.contains('active')) {
+ view.removeChild(vc.element());
+ this.classList.remove('active');
+ }
+
+ // The vc is not visible
+ else {
+ // The vc is not rendered yet
+ if (vc === undefined) {
+ vc = vcClass.create([
+ ['title', 'string'],
+ ['subTitle', 'string'],
+ ['pubDate', 'date'],
+ ['author', 'string']
+ ]);
+
+ if (KorAP.currentVC !== undefined)
+ vc.fromJson(KorAP.currentVC);
+ };
+ view.appendChild(vc.element());
+ this.classList.add('active');
+ };
};
};