blob: 9efd0079a1b5af9add68abc4c31613fec0e26284 [file] [log] [blame]
Nils Diewald0e6992a2015-04-14 20:13:52 +00001/**
2 * Unspecified criterion
3 */
4define(['vc/jsonld', 'vc/doc', 'util'], function (jsonldClass, docClass) {
5
6 var loc = KorAP.Locale;
7 loc.EMPTY = loc.EMPTY || '⋯';
8
9 return {
10 _ldType : "non",
11 create : function (parent) {
12 var obj = Object.create(jsonldClass).
13 upgradeTo(this);
14
15 if (parent !== undefined)
16 obj._parent = parent;
17
18 return obj;
19 },
20
21 // Set key - replace
22 key : function (v) {
23
24 // Not replaceable
25 if (this._parent === undefined)
26 return null;
27
28 // Set JSON-LD type
29 var newDoc = docClass.create(this._parent, {
30 "@type" : "koral:doc",
31 "value" : "",
32 "key" : v
33 });
34
35 // Unspecified document on root
36 if (this._parent.ldType() === null) {
37 this._parent.root(newDoc);
38 this.destroy();
39 }
40
41 // Unspecified document in group
42 else {
43 this._parent.replaceOperand(this, newDoc);
44 };
45 this._parent.update();
46 return newDoc;
47 },
48
49 update : function () {
50
51 if (this._element === undefined)
52 return this.element();
53
54 // Remove element content
55 _removeChildren(this._element);
56
57 var ellipsis = document.createElement('span');
58 ellipsis.appendChild(document.createTextNode(loc.EMPTY));
59 this._element.appendChild(ellipsis);
60
61 // Set ref - TODO: Cleanup!
62 this._element.refTo = this;
63
64 // Set operators
65 if (this._parent !== undefined && this.parent().ldType() !== null) {
66 var op = this.operators(
67 false,
68 false,
69 true
70 );
71
72 this._element.appendChild(
73 op.element()
74 );
75 };
76
77 return this.element();
78 },
79
80 element : function () {
81 if (this._element !== undefined)
82 return this._element;
83 this._element = document.createElement('div');
84 this._element.setAttribute('class', 'doc unspecified');
85 this.update();
86 return this._element;
87 },
88 };
89});