Fix CSS for Virtual Collection Builder
diff --git a/dev/js/src/util.js b/dev/js/src/util.js
index b3bb423..f3df4fc 100644
--- a/dev/js/src/util.js
+++ b/dev/js/src/util.js
@@ -41,6 +41,21 @@
KorAP.API = KorAP.API || {};
KorAP.Locale = KorAP.Locale || {};
+ var loc = KorAP.Locale;
+ loc.OR = loc.OR || 'or';
+ loc.AND = loc.AND || 'and';
+
+ // Add new stylesheet object lazily to document
+ KorAP.newStyleSheet = function () {
+ if (KorAP._sheet === undefined) {
+ var sElem = document.createElement('style');
+ document.head.appendChild(sElem);
+ KorAP._sheet = sElem.sheet;
+ };
+ return KorAP._sheet;
+ };
+
+
// Default log message
KorAP.log = KorAP.log || function (type, msg) {
console.log(type + ": " + msg);
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index 65ac5ca..4598275 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -38,13 +38,13 @@
], function (unspecDocClass, docClass, docGroupClass) {
"use strict";
+ // ???
KorAP._validStringMatchRE = new RegExp("^(?:eq|ne|contains|excludes)$");
- // KorAP._validRegexMatchRE = new RegExp("^(?:eq|ne)$");
KorAP._validDateMatchRE = new RegExp("^[lg]?eq$");
KorAP._validDateRE = new RegExp("^(?:\\d{4})(?:-\\d\\d(?:-\\d\\d)?)?$");
- // KorAP._validGroupOpRE = new RegExp("^(?:and|or)$");
- // KorAP._quote = new RegExp("([\"\\\\])", 'g');
+ KorAP._overrideStyles = false;
+ var loc = KorAP.Locale;
/**
* Virtual Collection
@@ -54,8 +54,36 @@
return null;
},
+ _init : function () {
+ if (!KorAP._overrideStyles) {
+ var sheet = KorAP.newStyleSheet();
+
+ // Add css rule for OR operations
+ sheet.insertRule(
+ '.vc .docGroup[data-operation=or] > .doc::before,' +
+ '.vc .docGroup[data-operation=or] > .docGroup::before ' +
+ '{ content: "' + loc.OR + '" }',
+ 0
+ );
+
+ // Add css rule for AND operations
+ sheet.insertRule(
+ '.vc .docGroup[data-operation=and] > .doc::before,' +
+ '.vc .docGroup[data-operation=and] > .docGroup::before ' +
+ '{ content: "' + loc.AND + '" }',
+ 1
+ );
+
+ console.log(sheet);
+
+ KorAP._overrideStyles = true;
+ };
+
+ return this;
+ },
+
create : function () {
- return Object.create(this);
+ return Object.create(this)._init();
},
clean : function () {
@@ -67,7 +95,7 @@
},
render : function (json) {
- var obj = Object.create(this);
+ var obj = Object.create(this)._init();
if (json !== undefined) {
// Root object
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index 5e5f010..0db4b4c 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -12,6 +12,8 @@
var _validGroupOpRE = new RegExp("^(?:and|or)$");
+ var loc = KorAP.Locale;
+
var docGroupClass = {
_ldType : "docGroup",
diff --git a/dev/js/src/vc/operators.js b/dev/js/src/vc/operators.js
index 9b0ebd1..91f009f 100644
--- a/dev/js/src/vc/operators.js
+++ b/dev/js/src/vc/operators.js
@@ -4,8 +4,6 @@
define(['util'], function () {
var loc = KorAP.Locale;
- loc.AND = loc.AND || 'and';
- loc.OR = loc.OR || 'or';
loc.DEL = loc.DEL || '×';