Cleanup and simplify JS code
Change-Id: I393e22763c1a1d18878026bf459b747b150429fb
diff --git a/dev/js/src/vc/chooseitem.js b/dev/js/src/vc/chooseitem.js
index 5dc42b3..9f6fc06 100644
--- a/dev/js/src/vc/chooseitem.js
+++ b/dev/js/src/vc/chooseitem.js
@@ -82,7 +82,7 @@
// Connect action
li["onclick"] = this.onclick.bind(this);
- li.appendChild(document.createTextNode(this._name));
+ li.addT(this._name);
return this._element = li;
}
}
diff --git a/dev/js/src/vc/choosemenu.js b/dev/js/src/vc/choosemenu.js
index 2ecb3b7..84f6ae9 100644
--- a/dev/js/src/vc/choosemenu.js
+++ b/dev/js/src/vc/choosemenu.js
@@ -6,8 +6,8 @@
return {
create : function (params) {
return Object.create(menuClass)
- .upgradeTo(this)
- ._init(itemClass, undefined, undefined, params);
+ .upgradeTo(this)
+ ._init(itemClass, undefined, undefined, params);
},
/**
@@ -15,7 +15,7 @@
*/
release : function (id, name) {
if (this._cb !== undefined)
- this._cb(id, name);
+ this._cb(id, name);
}
};
});
diff --git a/dev/js/src/vc/doc.js b/dev/js/src/vc/doc.js
index 87b7057..f3e5559 100644
--- a/dev/js/src/vc/doc.js
+++ b/dev/js/src/vc/doc.js
@@ -9,20 +9,9 @@
'util'
], function (jsonldClass, rewriteListClass, stringValClass) {
- /*
- var fieldMenu = menuClass.create([
- ['Titel', 'title', 'string'],
- ['Untertitel', 'subTitle', 'string'],
- ['Veröffentlichungsdatum', 'pubDate', 'date'],
- ['Autor', 'author', 'string']
- ]);
-
- fieldMenu.limit(5);
- */
-
_validRegexMatchRE = new RegExp("^(?:eq|ne)$");
- var loc = KorAP.Locale;
+ const loc = KorAP.Locale;
loc.EMPTY = loc.EMPTY || '⋯';
return {
@@ -85,16 +74,14 @@
var k = this.key();
if (loc['VC_' + k] !== undefined)
k = loc['VC_' + k];
- this._keyE.appendChild(document.createTextNode(k));
+ this._keyE.addT(k);
};
// Added match operator
this._matchopE = document.createElement('span');
this._matchopE.setAttribute('data-type', this.type());
this._matchopE.setAttribute('class', 'match');
- this._matchopE.appendChild(
- document.createTextNode(this.matchop())
- );
+ this._matchopE.addT(this.matchop());
// Change matchop
this._matchopE.addEventListener(
@@ -107,10 +94,10 @@
this._valueE.setAttribute('data-type', this.type());
this._valueE.setAttribute('class', 'value');
if (this.value()) {
- this._valueE.appendChild(document.createTextNode(this.value()));
+ this._valueE.addT(this.value());
}
else {
- this._valueE.appendChild(document.createTextNode(loc.EMPTY));
+ this._valueE.addT(loc.EMPTY);
};
// Change value
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index da1f6ab..58926f2 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -13,11 +13,11 @@
unspecClass,
docClass) {
- var _validGroupOpRE = new RegExp("^(?:and|or)$");
+ const _validGroupOpRE = new RegExp("^(?:and|or)$");
- var loc = KorAP.Locale;
+ const loc = KorAP.Locale;
- var docGroupClass = {
+ const docGroupClass = {
_ldType : "docGroup",
create : function (parent, json) {
@@ -25,33 +25,33 @@
obj._operands = [];
obj.fromJson(json);
if (parent !== undefined)
- obj._parent = parent;
+ obj._parent = parent;
return obj;
},
newAfter : function (obj) {
for (var i = 0; i < this._operands.length; i++) {
- if (this._operands[i] === obj) {
- var operand = unspecClass.create(this);
- this._operands.splice(i + 1, 0, operand);
- return this.update();
- };
+ if (this._operands[i] === obj) {
+ var operand = unspecClass.create(this);
+ this._operands.splice(i + 1, 0, operand);
+ return this.update();
+ };
};
},
// The doc is already set in the group
_duplicate : function (operand) {
if (operand.ldType() !== 'doc')
- return null;
+ return null;
for (var i = 0; i < this._operands.length; i++) {
- var op = this.getOperand(i);
- if (op.ldType() === 'doc'
- && operand.key() === op.key()
- && operand.matchop() === op.matchop()
- && operand.value() === op.value()) {
- return op;
- };
+ var op = this.getOperand(i);
+ if (op.ldType() === 'doc'
+ && operand.key() === op.key()
+ && operand.matchop() === op.matchop()
+ && operand.value() === op.value()) {
+ return op;
+ };
};
return null;
},
@@ -61,75 +61,75 @@
// Append unspecified object
if (operand === undefined) {
- // Be aware of cyclic structures!
- operand = unspecClass.create(this);
- this._operands.push(operand);
- return operand;
+ // Be aware of cyclic structures!
+ operand = unspecClass.create(this);
+ this._operands.push(operand);
+ return operand;
};
switch (operand["@type"]) {
-
+
case undefined:
- // No @type defined
- if (operand["ldType"] !== undefined) {
- if (operand.ldType() !== 'doc' &&
- operand.ldType() !== 'docGroup') {
- KorAP.log(812, "Operand not supported in document group");
- return;
- };
+ // No @type defined
+ if (operand["ldType"] !== undefined) {
+ if (operand.ldType() !== 'doc' &&
+ operand.ldType() !== 'docGroup') {
+ KorAP.log(812, "Operand not supported in document group");
+ return;
+ };
- // Be aware of cyclic structures!
- operand.parent(this);
+ // Be aware of cyclic structures!
+ operand.parent(this);
- var dupl = this._duplicate(operand);
- if (dupl === null) {
- this._operands.push(operand);
- return operand;
- };
- return dupl;
- };
+ var dupl = this._duplicate(operand);
+ if (dupl === null) {
+ this._operands.push(operand);
+ return operand;
+ };
+ return dupl;
+ };
- KorAP.log(701, "JSON-LD group has no @type attribute");
- return;
+ KorAP.log(701, "JSON-LD group has no @type attribute");
+ return;
case "koral:doc":
- // Be aware of cyclic structures!
- var doc = docClass.create(this, operand);
- if (doc === undefined)
- return;
- var dupl = this._duplicate(doc);
- if (dupl === null) {
- this._operands.push(doc);
- return doc;
- };
- return dupl;
+ // Be aware of cyclic structures!
+ var doc = docClass.create(this, operand);
+ if (doc === undefined)
+ return;
+ var dupl = this._duplicate(doc);
+ if (dupl === null) {
+ this._operands.push(doc);
+ return doc;
+ };
+ return dupl;
case "koral:docGroup":
- // Be aware of cyclic structures!
- var docGroup = docGroupClass.create(this, operand);
- if (docGroup === undefined)
- return;
+ // Be aware of cyclic structures!
+ var docGroup = docGroupClass.create(this, operand);
+ if (docGroup === undefined)
+ return;
- // Flatten group
- if (docGroup.operation() === this.operation()) {
- for (var op in docGroup.operands()) {
- op = docGroup.getOperand(op);
- var dupl = this._duplicate(op);
- if (dupl === null) {
- this._operands.push(op);
- op.parent(this);
- };
- };
- docGroup._operands = [];
- docGroup.destroy();
- return this;
- };
- this._operands.push(docGroup);
- return docGroup;
+ // Flatten group
+ if (docGroup.operation() === this.operation()) {
+ for (var op in docGroup.operands()) {
+ op = docGroup.getOperand(op);
+ var dupl = this._duplicate(op);
+ if (dupl === null) {
+ this._operands.push(op);
+ op.parent(this);
+ };
+ };
+ docGroup._operands = [];
+ docGroup.destroy();
+ return this;
+ };
+ this._operands.push(docGroup);
+ return docGroup;
default:
- KorAP.log(812, "Operand not supported in document group");
- return;
+ KorAP.log(812, "Operand not supported in document group");
+ return;
};
},
@@ -137,30 +137,30 @@
// There is only one operand in group
if (this._operands.length === 1) {
-
- var parent = this.parent();
- var op = this.getOperand(0);
-
- // This will prevent destruction of
- // the operand
- this._operands = [];
+
+ var parent = this.parent();
+ var op = this.getOperand(0);
+
+ // This will prevent destruction of
+ // the operand
+ this._operands = [];
- // Parent is a group
- if (parent.ldType() !== null)
- return parent.replaceOperand(this, op).update();
+ // Parent is a group
+ if (parent.ldType() !== null)
+ return parent.replaceOperand(this, op).update();
- // Parent is vc
- else {
- this.destroy();
- // Cyclic madness
- parent.root(op);
- op.parent(parent);
- return parent.root();
- };
+ // Parent is vc
+ else {
+ this.destroy();
+ // Cyclic madness
+ parent.root(op);
+ op.parent(parent);
+ return parent.root();
+ };
};
if (this._element === undefined)
- return this;
+ return this;
var group = this._element;
group.setAttribute('data-operation', this.operation());
@@ -169,16 +169,16 @@
// Append operands
for (var i = 0; i < this._operands.length; i++) {
- group.appendChild(
- this.getOperand(i).element()
- );
+ group.appendChild(
+ this.getOperand(i).element()
+ );
};
// Set operators
var op = this.operators(
- this.operation() == 'and' ? false : true,
- this.operation() == 'or' ? false : true,
- true
+ this.operation() == 'and' ? false : true,
+ this.operation() == 'or' ? false : true,
+ true
);
group.appendChild(op.element());
@@ -188,7 +188,7 @@
element : function () {
if (this._element !== undefined)
- return this._element;
+ return this._element;
this._element = document.createElement('div');
this._element.setAttribute('class', 'docGroup');
@@ -201,13 +201,13 @@
operation : function (op) {
if (arguments.length === 1) {
- if (_validGroupOpRE.test(op)) {
- this._op = op;
- }
- else {
- KorAP.log(810, "Unknown operation type");
- return;
- };
+ if (_validGroupOpRE.test(op)) {
+ this._op = op;
+ }
+ else {
+ KorAP.log(810, "Unknown operation type");
+ return;
+ };
};
return this._op || 'and';
},
@@ -224,36 +224,36 @@
replaceOperand : function (oldOp, newOp) {
for (var i = 0; i < this._operands.length; i++) {
- if (this._operands[i] === oldOp) {
-
- // Just insert a doc or ...
- if (newOp.ldType() === "doc" ||
- newOp.ldType() === "non" ||
- // ... insert a group of a different operation
- // (i.e. "and" in "or"/"or" in "and")
- newOp.operation() != this.operation()) {
- this._operands[i] = newOp;
- newOp.parent(this);
- }
+ if (this._operands[i] === oldOp) {
+
+ // Just insert a doc or ...
+ if (newOp.ldType() === "doc" ||
+ newOp.ldType() === "non" ||
+ // ... insert a group of a different operation
+ // (i.e. "and" in "or"/"or" in "and")
+ newOp.operation() != this.operation()) {
+ this._operands[i] = newOp;
+ newOp.parent(this);
+ }
- // Flatten group
- else {
- // Remove old group
- this._operands.splice(i, 1);
+ // Flatten group
+ else {
+ // Remove old group
+ this._operands.splice(i, 1);
- // Inject new operands
- for (var op in newOp.operands().reverse()) {
- op = newOp.getOperand(op);
- this._operands.splice(i, 0, op);
- op.parent(this);
- };
- // Prevent destruction of operands
- newOp._operands = [];
- newOp.destroy();
- };
- oldOp.destroy();
- return this;
- }
+ // Inject new operands
+ for (var op in newOp.operands().reverse()) {
+ op = newOp.getOperand(op);
+ this._operands.splice(i, 0, op);
+ op.parent(this);
+ };
+ // Prevent destruction of operands
+ newOp._operands = [];
+ newOp.destroy();
+ };
+ oldOp.destroy();
+ return this;
+ }
};
return false;
},
@@ -261,16 +261,16 @@
// Delete operand from group
delOperand : function (obj) {
for (var i = 0; i < this._operands.length; i++) {
- if (this._operands[i] === obj) {
-
- // Delete identified operand
- this._operands.splice(i,1);
+ if (this._operands[i] === obj) {
+
+ // Delete identified operand
+ this._operands.splice(i,1);
- // Destroy object for cyclic references
- obj.destroy();
+ // Destroy object for cyclic references
+ obj.destroy();
- return this;
- };
+ return this;
+ };
};
// Operand not found
@@ -280,17 +280,17 @@
// Deserialize from json
fromJson : function (json) {
if (json === undefined)
- return this;
+ return this;
if (json["@type"] === undefined) {
- KorAP.log(701, "JSON-LD group has no @type attribute");
- return;
+ KorAP.log(701, "JSON-LD group has no @type attribute");
+ return;
};
if (json["operation"] === undefined ||
- typeof json["operation"] !== 'string') {
- KorAP.log(811, "Document group expects operation");
- return;
+ typeof json["operation"] !== 'string') {
+ KorAP.log(811, "Document group expects operation");
+ return;
};
var operation = json["operation"];
@@ -298,15 +298,15 @@
this.operation(operation.replace(/^operation:/,''));
if (json["operands"] === undefined ||
- !(json["operands"] instanceof Array)) {
- KorAP.log(704, "Operation needs operand list")
- return;
+ !(json["operands"] instanceof Array)) {
+ KorAP.log(704, "Operation needs operand list")
+ return;
};
// Add all documents
for (var i in json["operands"]) {
- var operand = json["operands"][i];
- this.append(operand);
+ var operand = json["operands"][i];
+ this.append(operand);
};
return this;
@@ -315,32 +315,32 @@
toJson : function () {
var opArray = new Array();
for (var i = 0; i < this._operands.length; i++) {
- if (this._operands[i].ldType() !== 'non')
- opArray.push(this._operands[i].toJson());
+ if (this._operands[i].ldType() !== 'non')
+ opArray.push(this._operands[i].toJson());
};
return {
- "@type" : "koral:" + this.ldType(),
- "operation" : "operation:" + this.operation(),
- "operands" : opArray
+ "@type" : "koral:" + this.ldType(),
+ "operation" : "operation:" + this.operation(),
+ "operands" : opArray
};
},
toQuery : function (brackets) {
var list = this._operands
- .filter(function (op) {
- return op.ldType() !== 'non';
- })
- .map(function (op) {
- return (op.ldType() === 'docGroup') ?
- op.toQuery(true) :
- op.toQuery();
- });
+ .filter(function (op) {
+ return op.ldType() !== 'non';
+ })
+ .map(function (op) {
+ return (op.ldType() === 'docGroup') ?
+ op.toQuery(true) :
+ op.toQuery();
+ });
if (list.length === 1)
- return list.join('');
+ return list.join('');
else {
- var str = list.join(this.operation() === 'or' ? ' | ' : ' & ');
- return brackets ? '(' + str + ')' : str;
+ var str = list.join(this.operation() === 'or' ? ' | ' : ' & ');
+ return brackets ? '(' + str + ')' : str;
};
}
};
diff --git a/dev/js/src/vc/item.js b/dev/js/src/vc/item.js
index c05fbad..d2c6fc1 100644
--- a/dev/js/src/vc/item.js
+++ b/dev/js/src/vc/item.js
@@ -1,7 +1,7 @@
// Field menu item
define(['menu/item', 'util'], function (itemClass) {
- var loc = KorAP.Locale;
+ const loc = KorAP.Locale;
return {
@@ -14,14 +14,14 @@
*/
create : function (params) {
return Object.create(itemClass)
- .upgradeTo(this)
- ._init(params);
+ .upgradeTo(this)
+ ._init(params);
},
// Initialize item object
_init : function (params) {
if (params[0] === undefined)
- throw new Error("Missing parameters");
+ throw new Error("Missing parameters");
this._key = params[0];
this._type = params[1];
@@ -40,8 +40,8 @@
*/
onclick : function (e) {
this.menu().release(
- this._key,
- this._type
+ this._key,
+ this._type
);
e.halt();
},
@@ -76,7 +76,7 @@
// already defined
if (this._element !== undefined)
- return this._element;
+ return this._element;
// Create list item
var li = document.createElement("li");
@@ -86,7 +86,7 @@
// Connect action
li["onclick"] = this.onclick.bind(this);
- li.appendChild(document.createTextNode(this._name));
+ li.addT(this._name);
return this._element = li;
}
};
diff --git a/dev/js/src/vc/menu.js b/dev/js/src/vc/menu.js
index af4f8e1..6a242e2 100644
--- a/dev/js/src/vc/menu.js
+++ b/dev/js/src/vc/menu.js
@@ -2,6 +2,7 @@
* Menu showing all key fields.
*/
define(['menu', 'vc/item', 'vc/prefix'], function (menuClass, itemClass, prefixClass) {
+
return {
create : function (params) {
var obj = Object.create(menuClass)
diff --git a/dev/js/src/vc/operators.js b/dev/js/src/vc/operators.js
index 41ab744..842fbc1 100644
--- a/dev/js/src/vc/operators.js
+++ b/dev/js/src/vc/operators.js
@@ -3,7 +3,7 @@
*/
define(['util'], function () {
- var loc = KorAP.Locale;
+ const loc = KorAP.Locale;
loc.DEL = loc.DEL || '×';
@@ -22,26 +22,26 @@
// Check that the action differs from the type
if (ref.operation() === type)
- return;
+ return;
if (parent.ldType() !== null) {
- return parent.newAfter(ref);
+ return parent.newAfter(ref);
}
else {
- // The group is on root - wrap
- return ref.wrapOnRoot();
+ // The group is on root - wrap
+ return ref.wrapOnRoot();
};
}
else if (ref.ldType() === 'doc') {
if (parent.ldType() === null) {
- return ref.wrapOnRoot(type);
+ return ref.wrapOnRoot(type);
}
else if (parent.operation() === type) {
- return parent.newAfter(ref);
+ return parent.newAfter(ref);
}
else {
- return ref.wrap(type);
+ return ref.wrap(type);
};
};
};
@@ -83,7 +83,7 @@
update : function () {
// Init the element
if (this._element === undefined)
- return this.element();
+ return this.element();
var op = this._element;
@@ -94,31 +94,26 @@
// Add and button
if (this._and === true) {
- var andE = document.createElement('span');
- andE.setAttribute('class', 'and');
- andE.addEventListener('click', KorAP._and, false);
- andE.appendChild(
- document.createTextNode(loc.AND)
- );
- op.appendChild(andE);
+ var andE = op.addE('span');
+ andE.setAttribute('class', 'and');
+ andE.addEventListener('click', KorAP._and, false);
+ andE.addT(loc.AND);
};
// Add or button
if (this._or === true) {
- var orE = document.createElement('span');
- orE.setAttribute('class', 'or');
- orE.addEventListener('click', KorAP._or, false);
- orE.appendChild(document.createTextNode(loc.OR));
- op.appendChild(orE);
+ var orE = op.addE('span');
+ orE.setAttribute('class', 'or');
+ orE.addEventListener('click', KorAP._or, false);
+ orE.addT(loc.OR);
};
// Add delete button
if (this._del === true) {
- var delE = document.createElement('span');
- delE.setAttribute('class', 'delete');
- delE.appendChild(document.createTextNode(loc.DEL));
- delE.addEventListener('click', KorAP._delete, false);
- op.appendChild(delE);
+ var delE = op.addE('span');
+ delE.setAttribute('class', 'delete');
+ delE.addT(loc.DEL);
+ delE.addEventListener('click', KorAP._delete, false);
};
return op;
@@ -127,7 +122,7 @@
// Be aware! This may be cyclic
parent : function (obj) {
if (arguments.length === 1)
- this._parent = obj;
+ this._parent = obj;
return this._parent;
},
@@ -135,7 +130,7 @@
// Return existing element
if (this._element !== undefined)
- return this._element;
+ return this._element;
this._element = document.createElement('div');
this._element.classList.add('operators', 'button-group');
@@ -147,19 +142,19 @@
and : function (bool) {
if (arguments.length === 1)
- this._and = _bool(bool);
+ this._and = _bool(bool);
return this._and;
},
or : function (bool) {
if (arguments.length === 1)
- this._or = _bool(bool);
+ this._or = _bool(bool);
return this._or;
},
del : function (bool) {
if (arguments.length === 1)
- this._del = _bool(bool);
+ this._del = _bool(bool);
return this._del;
}
};
diff --git a/dev/js/src/vc/rewrite.js b/dev/js/src/vc/rewrite.js
index b577f14..eeec713 100644
--- a/dev/js/src/vc/rewrite.js
+++ b/dev/js/src/vc/rewrite.js
@@ -4,7 +4,8 @@
define(['vc/jsonld', 'util'], function (jsonldClass) {
// injection, modification, and deletion should probably be enough
- var _validRewriteOpRE = new RegExp("^(operation:)?(?:injec|inser|modifica|dele)tion|override$");
+ const _validRewriteOpRE =
+ new RegExp("^(operation:)?(?:injec|inser|modifica|dele)tion|override$");
return {
// Construction method
diff --git a/dev/js/src/vc/rewritelist.js b/dev/js/src/vc/rewritelist.js
index af3c05a..cec95ff 100644
--- a/dev/js/src/vc/rewritelist.js
+++ b/dev/js/src/vc/rewritelist.js
@@ -1,47 +1,52 @@
-define(['vc/jsonld', 'vc/rewrite'], function (jsonldClass, rewriteClass) {
+define(['vc/jsonld', 'vc/rewrite','util'], function (jsonldClass, rewriteClass) {
return {
// Construction method
create : function (json) {
var obj = Object(jsonldClass).
- create().
- upgradeTo(this).
- fromJson(json);
+ create().
+ upgradeTo(this).
+ fromJson(json);
return obj;
},
+
+
+ /**
+ * Deserialize from KoralQuery
+ */
fromJson : function (json) {
this._list = new Array();
for (var i = 0; i < json.length; i++) {
- this._list.push(
- rewriteClass.create(json[i])
- );
+ this._list.push(
+ rewriteClass.create(json[i])
+ );
};
return this;
},
+
+ /**
+ * Get element.
+ */
element : function () {
if (this._element !== undefined)
- return this._element;
+ return this._element;
this._element = document.createElement('div');
this._element.setAttribute('class', 'rewrite');
for (var x in this._list) {
- var rewrite = this._list[x];
- var span = document.createElement('span');
+ var rewrite = this._list[x];
+ var span = document.createElement('span');
- // Set class attribute
- span.setAttribute('class', rewrite.operation());
+ // Set class attribute
+ span.setAttribute('class', rewrite.operation());
- // Append source information
- span.appendChild(document.createTextNode(rewrite.src()));
+ // Append source information
+ span.addT(rewrite.src());
- // Append scope information
- if (rewrite.scope() !== undefined) {
- span.appendChild(
- document.createTextNode(
- ': ' + rewrite.scope()
- )
- );
- };
- this._element.appendChild(span);
+ // Append scope information
+ if (rewrite.scope() !== undefined) {
+ span.addT(': ' + rewrite.scope());
+ };
+ this._element.appendChild(span);
};
return this._element;
}
diff --git a/dev/js/src/vc/stringval.js b/dev/js/src/vc/stringval.js
index 1cebde4..bd3a65c 100644
--- a/dev/js/src/vc/stringval.js
+++ b/dev/js/src/vc/stringval.js
@@ -1,7 +1,7 @@
/**
* Add string values to the virtual collection
*/
-define({
+define(['util'], {
/**
* Create new string value helper.
@@ -118,16 +118,12 @@
cl.add('regex');
// Add input field
- this._input = e.appendChild(
- document.createElement('input')
- );
+ this._input = e.addE('input');
if (this.value() !== undefined)
this._input.value = this.value();
// Add regex button
- var re = e.appendChild(
- document.createElement('div')
- );
+ var re = e.addE('div');
re.addEventListener(
'click',
function (ev) {
@@ -136,7 +132,7 @@
}.bind(this),
true
);
- re.appendChild(document.createTextNode('RE'));
+ re.addT('RE');
// If the focus is not on the text field anymore,
// delegate focus to
diff --git a/dev/js/src/vc/unspecified.js b/dev/js/src/vc/unspecified.js
index 31101ef..daa7c88 100644
--- a/dev/js/src/vc/unspecified.js
+++ b/dev/js/src/vc/unspecified.js
@@ -23,10 +23,10 @@
*/
create : function (parent) {
var obj = Object.create(jsonldClass).
- upgradeTo(this);
+ upgradeTo(this);
if (parent !== undefined)
- obj._parent = parent;
+ obj._parent = parent;
return obj;
},
@@ -38,24 +38,24 @@
// Not replaceable
if (this._parent === undefined)
- return null;
+ return null;
// Set JSON-LD type
var newDoc = docClass.create(this._parent, {
- "@type" : "koral:doc",
- "value" : "",
- "key" : v
+ "@type" : "koral:doc",
+ "value" : "",
+ "key" : v
});
// Unspecified document on root
if (this._parent.ldType() === null) {
- this._parent.root(newDoc);
- this.destroy();
+ this._parent.root(newDoc);
+ this.destroy();
}
// Unspecified document in group
else {
- this._parent.replaceOperand(this, newDoc);
+ this._parent.replaceOperand(this, newDoc);
};
this._parent.update();
return newDoc;
@@ -68,13 +68,13 @@
update : function () {
if (this._element === undefined)
- return this.element();
+ return this.element();
// Remove element content
- _removeChildren(this._element);
+ _removeChildren(this._element);
var ellipsis = document.createElement('span');
- ellipsis.appendChild(document.createTextNode(loc.EMPTY));
+ ellipsis.addT(loc.EMPTY);
// Click on empty criterion
ellipsis.addEventListener('click', this.onclick.bind(this));
@@ -86,15 +86,15 @@
// Set operators
if (this._parent !== undefined && this.parent().ldType() !== null) {
- var op = this.operators(
- false,
- false,
- true
- );
-
- this._element.appendChild(
- op.element()
- );
+ var op = this.operators(
+ false,
+ false,
+ true
+ );
+
+ this._element.appendChild(
+ op.element()
+ );
};
return this.element();
@@ -106,7 +106,7 @@
*/
element : function () {
if (this._element !== undefined)
- return this._element;
+ return this._element;
this._element = document.createElement('div');
this._element.setAttribute('class', 'doc unspecified');
this.update();
@@ -123,17 +123,17 @@
// Add key menu element at the correct position
this._element.insertBefore(
- menu.element(),
- this._element.firstChild
+ menu.element(),
+ this._element.firstChild
);
var that = this;
// Set released method
menu.released(function (key, type) {
- // Set chosen key and type - will return a doc
- that.key(key).type(type).update();
- this.hide();
+ // Set chosen key and type - will return a doc
+ that.key(key).type(type).update();
+ this.hide();
});
menu.show();