forked from SolidOS/solid-panes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefaultPane.js
More file actions
119 lines (105 loc) · 4.97 KB
/
defaultPane.js
File metadata and controls
119 lines (105 loc) · 4.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* Default Pane
**
** This outline pane contains the properties which are
** normaly displayed to the user. See also: internalPane
** This pane hides the ones considered too low-level for the normal user.
*/
var UI = require('solid-ui')
module.exports = {
icon: UI.icons.originalIconBase + 'about.png',
name: 'default',
label: function(subject) { return 'about ';},
render: function(subject, dom) {
var filter = function(pred, inverse) {
if (typeof UI.panes.internal.predicates[pred.uri] !== 'undefined')
return false;
if (inverse && (pred.uri ==
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type")) return false;
return true;
}
//var doc = dom.wrappedJSObject; Jim? why-tim
// dump( doc );
var outliner = UI.panes.getOutliner(dom)
var kb = UI.store;
var outline = outliner; //@@
UI.log.info("@defaultPane.render, dom is now " + dom.location);
subject = kb.canon(subject);
var div = dom.createElement('div')
//var f = jq("<div></div>", doc);
//jq(div, doc).append(f);
//f.resource({subject:"http://web.mit.edu/jambo/www/foaf.rdf#jambo", predicate:"http://xmlns.com/foaf/0.1/knows"});
div.setAttribute('class', 'defaultPane')
// appendRemoveIcon(div, subject, div);
var plist = kb.statementsMatching(subject)
outliner.appendPropertyTRs(div, plist, false, filter)
plist = kb.statementsMatching(undefined, undefined, subject)
outliner.appendPropertyTRs(div, plist, true, filter)
if ((subject.termType == 'Literal') && (subject.value.slice(0,7) == 'http://'))
outliner.appendPropertyTRs(div,
[$rdf.st(kb.sym(subject.value), UI.ns.link('uri'), subject)],
true, filter)
if ((subject.termType == 'NamedNode' &&
kb.updater.editable(UI.rdf.Util.uri.docpart(subject.uri), kb))
|| (subject.termType == 'BlankNode'
&& kb.anyStatementMatching(subject)
&& kb.anyStatementMatching(subject).why
&& kb.anyStatementMatching(subject).why.uri
&& kb.updater.editable(kb.anyStatementMatching(subject).why.uri)
//check the document containing something about of the bnode @@ what about as object?
/*! && HCIoptions["bottom insert highlights"].enabled*/)) {
var holdingTr = dom.createElement('tr'); //these are to minimize required changes
var holdingTd = dom.createElement('td'); //in userinput.js
holdingTd.setAttribute('colspan','2');
holdingTd.setAttribute('notSelectable','true');
var img = dom.createElement('img');
img.src = UI.icons.originalIconBase + 'tango/22-list-add-new.png';
img.addEventListener('click', function add_new_tripleIconMouseDownListener(e) {
outliner.UserInput.addNewPredicateObject(e);
e.stopPropagation();
e.preventDefault();
return;
});
img.className='bottom-border-active';
//img.addEventListener('click', thisOutline.UserInput.addNewPredicateObject,false);
div.appendChild(holdingTr).appendChild(holdingTd).appendChild(img);
}
return div
},
sync: function(subject, dom, div) { // Untested and not the best way to do it
// This code was cut out of outline.js
// best way is to leave TRs there and add/delete any necessray extras
UI.log.info('Re-expand: '+div)
// try{table.replaceChild(expandedHeaderTR(subject),table.firstChild)}
// catch(e){} // kludge... Todo: remove this (seeAlso UserInput::clearInputAndSave)
var row, s
var expandedNodes = {}
var parent = div
for (row = parent.firstChild; row; row = row.nextSibling) { // Note which p,o pairs are exppanded
if (row.childNodes[1]
&& row.childNodes[1].firstChild.nodeName == 'TABLE') {
s = row.AJAR_statement
if (!expandedNodes[s.predicate.toString()]) {
expandedNodes[s.predicate.toString()] = {}
}
expandedNodes[s.predicate.toString()][s.object.toString()] =
row.childNodes[1].childNodes[1]
}
}
var table = propertyTable(subject, undefined, pane) // Re-build table
for (row = table.firstChild; row; row = row.nextSibling) {
s = row.AJAR_statement
if (s) {
if (expandedNodes[s.predicate.toString()]) {
var node =
expandedNodes[s.predicate.toString()][s.object.toString()]
if (node) {
row.childNodes[1].replaceChild(node,
row.childNodes[1].firstChild)
}
}
}
}
// do some other stuff here
}
};
// ends