solid-ui 2.6.1-05fb7cc → 2.6.1-07db096
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/acl/access-controller.js +38 -93
- package/dist/acl/access-controller.js.map +1 -1
- package/dist/acl/access-groups.d.ts +2 -2
- package/dist/acl/access-groups.d.ts.map +1 -1
- package/dist/acl/access-groups.js +62 -111
- package/dist/acl/access-groups.js.map +1 -1
- package/dist/acl/acl-control.js +22 -66
- package/dist/acl/acl-control.js.map +1 -1
- package/dist/acl/acl.js +53 -108
- package/dist/acl/acl.js.map +1 -1
- package/dist/acl/add-agent-buttons.js +29 -72
- package/dist/acl/add-agent-buttons.js.map +1 -1
- package/dist/acl/index.js +25 -28
- package/dist/acl/index.js.map +1 -1
- package/dist/acl/types.js +1 -2
- package/dist/acl/types.js.map +1 -1
- package/dist/chat/keys.js +36 -78
- package/dist/chat/keys.js.map +1 -1
- package/dist/chat/signature.js +15 -23
- package/dist/chat/signature.js.map +1 -1
- package/dist/create/create.js +15 -54
- package/dist/create/create.js.map +1 -1
- package/dist/create/index.js +3 -6
- package/dist/create/index.js.map +1 -1
- package/dist/create/types.js +1 -2
- package/dist/debug.d.ts.map +1 -1
- package/dist/debug.js +4 -14
- package/dist/debug.js.map +1 -1
- package/dist/footer/index.js +13 -18
- package/dist/footer/index.js.map +1 -1
- package/dist/header/empty-profile.js +1 -4
- package/dist/header/empty-profile.js.map +1 -1
- package/dist/header/index.js +54 -99
- package/dist/header/index.js.map +1 -1
- package/dist/iconBase.js +5 -8
- package/dist/iconBase.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -108
- package/dist/index.js.map +1 -1
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +19 -36
- package/dist/log.js.map +1 -1
- package/dist/login/login.js +92 -144
- package/dist/login/login.js.map +1 -1
- package/dist/matrix/index.js +3 -6
- package/dist/matrix/index.js.map +1 -1
- package/dist/matrix/matrix.js +5 -41
- package/dist/matrix/matrix.js.map +1 -1
- package/dist/matrix/types.js +1 -2
- package/dist/media/index.js +4 -7
- package/dist/media/index.js.map +1 -1
- package/dist/media/media-capture.js +13 -50
- package/dist/media/media-capture.js.map +1 -1
- package/dist/pad.js +80 -100
- package/dist/pad.js.map +1 -1
- package/dist/participation.d.ts.map +1 -1
- package/dist/participation.js +43 -87
- package/dist/participation.js.map +1 -1
- package/dist/solid-ui.esm.js +24 -42
- package/dist/solid-ui.esm.js.map +1 -1
- package/dist/solid-ui.esm.min.js +3 -3
- package/dist/solid-ui.esm.min.js.map +1 -1
- package/dist/solid-ui.js +23 -44
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +8 -8
- package/dist/solid-ui.min.js.map +1 -1
- package/dist/tabs.js +18 -28
- package/dist/tabs.js.map +1 -1
- package/dist/utils/headerFooterHelpers.d.ts.map +1 -1
- package/dist/utils/headerFooterHelpers.js +19 -27
- package/dist/utils/headerFooterHelpers.js.map +1 -1
- package/dist/utils/keyHelpers/accessData.js +16 -60
- package/dist/utils/keyHelpers/accessData.js.map +1 -1
- package/dist/utils/keyHelpers/acl.js +11 -49
- package/dist/utils/keyHelpers/acl.js.map +1 -1
- package/dist/utils/keyHelpers/otherHelpers.js +6 -12
- package/dist/utils/keyHelpers/otherHelpers.js.map +1 -1
- package/dist/utils/label.js +22 -61
- package/dist/utils/label.js.map +1 -1
- package/dist/versionInfo.js +3 -5
- package/dist/versionInfo.js.map +1 -1
- package/dist/widgets/buttons/iconLinks.js +4 -9
- package/dist/widgets/buttons/iconLinks.js.map +1 -1
- package/dist/widgets/buttons.js +146 -221
- package/dist/widgets/buttons.js.map +1 -1
- package/dist/widgets/error.d.ts +12 -0
- package/dist/widgets/error.d.ts.map +1 -1
- package/dist/widgets/error.js +8 -15
- package/dist/widgets/error.js.map +1 -1
- package/dist/widgets/forms/autocomplete/autocompleteBar.js +21 -60
- package/dist/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
- package/dist/widgets/forms/autocomplete/autocompleteField.js +33 -69
- package/dist/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
- package/dist/widgets/forms/autocomplete/autocompletePicker.js +22 -62
- package/dist/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/dist/widgets/forms/autocomplete/language.js +21 -64
- package/dist/widgets/forms/autocomplete/language.js.map +1 -1
- package/dist/widgets/forms/autocomplete/publicData.js +81 -128
- package/dist/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/dist/widgets/forms/basic.js +37 -46
- package/dist/widgets/forms/basic.js.map +1 -1
- package/dist/widgets/forms/comment.js +10 -16
- package/dist/widgets/forms/comment.js.map +1 -1
- package/dist/widgets/forms/fieldFunction.js +10 -15
- package/dist/widgets/forms/fieldFunction.js.map +1 -1
- package/dist/widgets/forms/fieldParams.js +21 -27
- package/dist/widgets/forms/fieldParams.js.map +1 -1
- package/dist/widgets/forms/formStyle.d.ts.map +1 -1
- package/dist/widgets/forms/formStyle.js +10 -17
- package/dist/widgets/forms/formStyle.js.map +1 -1
- package/dist/widgets/widgetHelpers.js +5 -11
- package/dist/widgets/widgetHelpers.js.map +1 -1
- package/package.json +7 -8
package/dist/widgets/buttons.js
CHANGED
|
@@ -1,99 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.index = exports.personTR = exports.iconForClass = void 0;
|
|
40
|
-
exports.complain = complain;
|
|
41
|
-
exports.clearElement = clearElement;
|
|
42
|
-
exports.extractLogURI = extractLogURI;
|
|
43
|
-
exports.shortDate = shortDate;
|
|
44
|
-
exports.formatDateTime = formatDateTime;
|
|
45
|
-
exports.timestamp = timestamp;
|
|
46
|
-
exports.shortTime = shortTime;
|
|
47
|
-
exports.setName = setName;
|
|
48
|
-
exports.imagesOf = imagesOf;
|
|
49
|
-
exports.findImageFromURI = findImageFromURI;
|
|
50
|
-
exports.findImage = findImage;
|
|
51
|
-
exports.setImage = setImage;
|
|
52
|
-
exports.faviconOrDefault = faviconOrDefault;
|
|
53
|
-
exports.deleteButtonWithCheck = deleteButtonWithCheck;
|
|
54
|
-
exports.button = button;
|
|
55
|
-
exports.cancelButton = cancelButton;
|
|
56
|
-
exports.continueButton = continueButton;
|
|
57
|
-
exports.askName = askName;
|
|
58
|
-
exports.renderAsRow = renderAsRow;
|
|
59
|
-
exports.createNameDiv = createNameDiv;
|
|
60
|
-
exports.createLinkDiv = createLinkDiv;
|
|
61
|
-
exports.renderAsDiv = renderAsDiv;
|
|
62
|
-
exports.refreshTree = refreshTree;
|
|
63
|
-
exports.attachmentList = attachmentList;
|
|
64
|
-
exports.openHrefInOutlineMode = openHrefInOutlineMode;
|
|
65
|
-
exports.defaultAnnotationStore = defaultAnnotationStore;
|
|
66
|
-
exports.allClassURIs = allClassURIs;
|
|
67
|
-
exports.propertyTriage = propertyTriage;
|
|
68
|
-
exports.linkButton = linkButton;
|
|
69
|
-
exports.removeButton = removeButton;
|
|
70
|
-
exports.selectorPanel = selectorPanel;
|
|
71
|
-
exports.selectorPanelRefresh = selectorPanelRefresh;
|
|
72
|
-
exports.addStyleSheet = addStyleSheet;
|
|
73
|
-
exports.isAudio = isAudio;
|
|
74
|
-
exports.isVideo = isVideo;
|
|
75
|
-
exports.isImage = isImage;
|
|
76
|
-
exports.fileUploadButtonDiv = fileUploadButtonDiv;
|
|
77
1
|
/* Buttons
|
|
78
2
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
3
|
+
import { st, sym, uri, Util } from 'rdflib';
|
|
4
|
+
import { icons } from '../iconBase';
|
|
5
|
+
import ns from '../ns';
|
|
6
|
+
import { style } from '../style';
|
|
7
|
+
import * as debug from '../debug';
|
|
8
|
+
import { info } from '../log';
|
|
9
|
+
import { uploadFiles, makeDraggable, makeDropTarget } from './dragAndDrop';
|
|
10
|
+
import { store } from 'solid-logic';
|
|
11
|
+
import * as utils from '../utils';
|
|
12
|
+
import { errorMessageBlock } from './error';
|
|
13
|
+
import { addClickListenerToElement, createImageDiv, wrapDivInATR } from './widgetHelpers';
|
|
14
|
+
import { linkIcon, createLinkForURI } from './buttons/iconLinks';
|
|
91
15
|
/**
|
|
92
16
|
* UI Widgets such as buttons
|
|
93
17
|
* @packageDocumentation
|
|
94
18
|
*/
|
|
95
19
|
/* global alert */
|
|
96
|
-
const { iconBase } =
|
|
20
|
+
const { iconBase } = icons;
|
|
97
21
|
const cancelIconURI = iconBase + 'noun_1180156.svg'; // black X
|
|
98
22
|
const checkIconURI = iconBase + 'noun_1180158.svg'; // green checkmark; Continue
|
|
99
23
|
function getStatusArea(context) {
|
|
@@ -118,20 +42,20 @@ function getStatusArea(context) {
|
|
|
118
42
|
/**
|
|
119
43
|
* Display an error message block
|
|
120
44
|
*/
|
|
121
|
-
function complain(context, err) {
|
|
45
|
+
export function complain(context, err) {
|
|
122
46
|
if (!err)
|
|
123
47
|
return; // only if error
|
|
124
48
|
const ele = getStatusArea(context);
|
|
125
49
|
debug.log('Complaint: ' + err);
|
|
126
50
|
if (ele)
|
|
127
|
-
ele.appendChild(
|
|
51
|
+
ele.appendChild(errorMessageBlock((context && context.dom) || document, err));
|
|
128
52
|
else
|
|
129
53
|
alert(err);
|
|
130
54
|
}
|
|
131
55
|
/**
|
|
132
56
|
* Remove all the children of an HTML element
|
|
133
57
|
*/
|
|
134
|
-
function clearElement(ele) {
|
|
58
|
+
export function clearElement(ele) {
|
|
135
59
|
while (ele.firstChild) {
|
|
136
60
|
ele.removeChild(ele.firstChild);
|
|
137
61
|
}
|
|
@@ -140,7 +64,7 @@ function clearElement(ele) {
|
|
|
140
64
|
/**
|
|
141
65
|
* To figure out the log URI from the full URI used to invoke the reasoner
|
|
142
66
|
*/
|
|
143
|
-
function extractLogURI(fullURI) {
|
|
67
|
+
export function extractLogURI(fullURI) {
|
|
144
68
|
const logPos = fullURI.search(/logFile=/);
|
|
145
69
|
const rulPos = fullURI.search(/&rulesFile=/);
|
|
146
70
|
return fullURI.substring(logPos + 8, rulPos);
|
|
@@ -151,7 +75,7 @@ function extractLogURI(fullURI) {
|
|
|
151
75
|
* @@@ TODO This needs to be changed to local time
|
|
152
76
|
* @param noTime Return a string like 'Feb 19' even if it's today.
|
|
153
77
|
*/
|
|
154
|
-
function shortDate(str, noTime) {
|
|
78
|
+
export function shortDate(str, noTime) {
|
|
155
79
|
if (!str)
|
|
156
80
|
return '???';
|
|
157
81
|
const month = [
|
|
@@ -192,7 +116,7 @@ function shortDate(str, noTime) {
|
|
|
192
116
|
* @param format for instance '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}'
|
|
193
117
|
* @returns for instance '2000-01-15T23:14:23.002'
|
|
194
118
|
*/
|
|
195
|
-
function formatDateTime(date, format) {
|
|
119
|
+
export function formatDateTime(date, format) {
|
|
196
120
|
return format
|
|
197
121
|
.split('{')
|
|
198
122
|
.map(function (s) {
|
|
@@ -209,29 +133,29 @@ function formatDateTime(date, format) {
|
|
|
209
133
|
* Get a string representation of the current time
|
|
210
134
|
* @returns for instance '2000-01-15T23:14:23.002'
|
|
211
135
|
*/
|
|
212
|
-
function timestamp() {
|
|
136
|
+
export function timestamp() {
|
|
213
137
|
return formatDateTime(new Date(), '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
|
|
214
138
|
}
|
|
215
139
|
/**
|
|
216
140
|
* Get a short string representation of the current time
|
|
217
141
|
* @returns for instance '23:14:23.002'
|
|
218
142
|
*/
|
|
219
|
-
function shortTime() {
|
|
143
|
+
export function shortTime() {
|
|
220
144
|
return formatDateTime(new Date(), '{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
|
|
221
145
|
}
|
|
222
146
|
// ///////////////////// Handy UX widgets
|
|
223
147
|
/**
|
|
224
148
|
* Sets the best name we have and looks up a better one
|
|
225
149
|
*/
|
|
226
|
-
function setName(element, x) {
|
|
227
|
-
const kb =
|
|
150
|
+
export function setName(element, x) {
|
|
151
|
+
const kb = store;
|
|
228
152
|
const findName = function (x) {
|
|
229
|
-
const name = kb.any(x,
|
|
230
|
-
kb.any(x,
|
|
231
|
-
kb.any(x,
|
|
153
|
+
const name = kb.any(x, ns.vcard('fn')) ||
|
|
154
|
+
kb.any(x, ns.foaf('name')) ||
|
|
155
|
+
kb.any(x, ns.vcard('organization-name'));
|
|
232
156
|
return name ? name.value : null;
|
|
233
157
|
};
|
|
234
|
-
const name = x.sameTerm(
|
|
158
|
+
const name = x.sameTerm(ns.foaf('Agent')) ? 'Everyone' : findName(x);
|
|
235
159
|
element.textContent = name || utils.label(x);
|
|
236
160
|
if (!name && x.uri) {
|
|
237
161
|
if (!kb.fetcher) {
|
|
@@ -260,19 +184,19 @@ function setName(element, x) {
|
|
|
260
184
|
* * ns.foaf('depiction')
|
|
261
185
|
|
|
262
186
|
*/
|
|
263
|
-
function imagesOf(x, kb) {
|
|
187
|
+
export function imagesOf(x, kb) {
|
|
264
188
|
return kb
|
|
265
|
-
.each(x,
|
|
266
|
-
.concat(kb.each(x,
|
|
267
|
-
.concat(kb.each(x,
|
|
268
|
-
.concat(kb.each(x,
|
|
269
|
-
.concat(kb.each(x,
|
|
270
|
-
.concat(kb.each(x,
|
|
189
|
+
.each(x, ns.sioc('avatar'))
|
|
190
|
+
.concat(kb.each(x, ns.foaf('img')))
|
|
191
|
+
.concat(kb.each(x, ns.vcard('logo')))
|
|
192
|
+
.concat(kb.each(x, ns.vcard('hasPhoto')))
|
|
193
|
+
.concat(kb.each(x, ns.vcard('photo')))
|
|
194
|
+
.concat(kb.each(x, ns.foaf('depiction')));
|
|
271
195
|
}
|
|
272
196
|
/**
|
|
273
197
|
* Best logo or avatar or photo etc to represent someone or some group etc
|
|
274
198
|
*/
|
|
275
|
-
|
|
199
|
+
export const iconForClass = {
|
|
276
200
|
// Potentially extendable by other apps, panes, etc
|
|
277
201
|
// Relative URIs to the iconBase
|
|
278
202
|
'solid:AppProviderClass': 'noun_144.svg', // @@ classs name should not contain 'Class'
|
|
@@ -321,7 +245,7 @@ function tempSite(x) {
|
|
|
321
245
|
/**
|
|
322
246
|
* Find an image for this thing as a class
|
|
323
247
|
*/
|
|
324
|
-
function findImageFromURI(x) {
|
|
248
|
+
export function findImageFromURI(x) {
|
|
325
249
|
const iconDir = iconBase;
|
|
326
250
|
// Special cases from URI scheme:
|
|
327
251
|
if (typeof x !== 'string' && x.uri) {
|
|
@@ -366,18 +290,18 @@ function findImageFromURI(x) {
|
|
|
366
290
|
* * ns.vcard('photo')
|
|
367
291
|
* * ns.foaf('depiction')
|
|
368
292
|
*/
|
|
369
|
-
function findImage(thing) {
|
|
370
|
-
const kb =
|
|
293
|
+
export function findImage(thing) {
|
|
294
|
+
const kb = store;
|
|
371
295
|
const iconDir = iconBase;
|
|
372
|
-
if (thing.sameTerm(
|
|
296
|
+
if (thing.sameTerm(ns.foaf('Agent')) || thing.sameTerm(ns.rdf('Resource'))) {
|
|
373
297
|
return iconDir + 'noun_98053.svg'; // Globe
|
|
374
298
|
}
|
|
375
|
-
const image = kb.any(thing,
|
|
376
|
-
kb.any(thing,
|
|
377
|
-
kb.any(thing,
|
|
378
|
-
kb.any(thing,
|
|
379
|
-
kb.any(thing,
|
|
380
|
-
kb.any(thing,
|
|
299
|
+
const image = kb.any(thing, ns.sioc('avatar')) ||
|
|
300
|
+
kb.any(thing, ns.foaf('img')) ||
|
|
301
|
+
kb.any(thing, ns.vcard('logo')) ||
|
|
302
|
+
kb.any(thing, ns.vcard('hasPhoto')) ||
|
|
303
|
+
kb.any(thing, ns.vcard('photo')) ||
|
|
304
|
+
kb.any(thing, ns.foaf('depiction'));
|
|
381
305
|
return image ? image.uri : null;
|
|
382
306
|
}
|
|
383
307
|
/**
|
|
@@ -387,7 +311,7 @@ function findImage(thing) {
|
|
|
387
311
|
* Sets src AND STYLE of the image.
|
|
388
312
|
*/
|
|
389
313
|
function trySetImage(element, thing, iconForClassMap) {
|
|
390
|
-
const kb =
|
|
314
|
+
const kb = store;
|
|
391
315
|
const explitImage = findImage(thing);
|
|
392
316
|
if (explitImage) {
|
|
393
317
|
element.setAttribute('src', explitImage);
|
|
@@ -397,7 +321,7 @@ function trySetImage(element, thing, iconForClassMap) {
|
|
|
397
321
|
const typeIcon = iconForClassMap[thing.uri];
|
|
398
322
|
if (typeIcon) {
|
|
399
323
|
element.setAttribute('src', typeIcon);
|
|
400
|
-
element.style =
|
|
324
|
+
element.style = style.classIconStyle;
|
|
401
325
|
// element.style.border = '0.1em solid green;'
|
|
402
326
|
// element.style.backgroundColor = '#eeffee' // pale green
|
|
403
327
|
return true;
|
|
@@ -421,14 +345,14 @@ function trySetImage(element, thing, iconForClassMap) {
|
|
|
421
345
|
/**
|
|
422
346
|
* ToDo: Also add icons for *properties* like home, work, email, range, domain, comment,
|
|
423
347
|
*/
|
|
424
|
-
function setImage(element, thing) {
|
|
425
|
-
const kb =
|
|
348
|
+
export function setImage(element, thing) {
|
|
349
|
+
const kb = store;
|
|
426
350
|
const iconForClassMap = {};
|
|
427
|
-
for (const k in
|
|
351
|
+
for (const k in iconForClass) {
|
|
428
352
|
const pref = k.split(':')[0];
|
|
429
353
|
const id = k.split(':')[1];
|
|
430
|
-
const theClass =
|
|
431
|
-
iconForClassMap[theClass.uri] =
|
|
354
|
+
const theClass = ns[pref](id);
|
|
355
|
+
iconForClassMap[theClass.uri] = uri.join(iconForClass[k], iconBase);
|
|
432
356
|
}
|
|
433
357
|
const happy = trySetImage(element, thing, iconForClassMap);
|
|
434
358
|
if (!happy && thing.uri) {
|
|
@@ -444,9 +368,9 @@ function setImage(element, thing) {
|
|
|
444
368
|
}
|
|
445
369
|
// If a web page, then a favicon, with a fallback to ???
|
|
446
370
|
// See, e.g., http://stackoverflow.com/questions/980855/inputting-a-default-image
|
|
447
|
-
function faviconOrDefault(dom, x) {
|
|
371
|
+
export function faviconOrDefault(dom, x) {
|
|
448
372
|
const image = dom.createElement('img');
|
|
449
|
-
image.style =
|
|
373
|
+
image.style = style.iconStyle;
|
|
450
374
|
const isOrigin = function (x) {
|
|
451
375
|
if (!x.uri)
|
|
452
376
|
return false;
|
|
@@ -478,7 +402,7 @@ function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunctio
|
|
|
478
402
|
deleteFunction();
|
|
479
403
|
}
|
|
480
404
|
const popup = dom.createElement('div');
|
|
481
|
-
popup.style =
|
|
405
|
+
popup.style = style.confirmPopupStyle;
|
|
482
406
|
popup.style.position = 'absolute';
|
|
483
407
|
popup.style.top = '-1em'; // try leaving original button clear
|
|
484
408
|
popup.style.display = 'grid';
|
|
@@ -494,16 +418,16 @@ function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunctio
|
|
|
494
418
|
xButton.style.gridColumn = '1';
|
|
495
419
|
xButton.style.gridRow = '2';
|
|
496
420
|
const cancelPrompt = popup.appendChild(dom.createElement('button'));
|
|
497
|
-
cancelPrompt.style =
|
|
421
|
+
cancelPrompt.style = style.buttonStyle;
|
|
498
422
|
cancelPrompt.style.gridRow = '2';
|
|
499
423
|
cancelPrompt.style.gridColumn = '2';
|
|
500
424
|
cancelPrompt.textContent = 'Cancel'; // @@ I18n
|
|
501
|
-
const affirmIcon = button(dom,
|
|
425
|
+
const affirmIcon = button(dom, icons.iconBase + 'noun_925021.svg', 'Delete it'); // trashcan
|
|
502
426
|
popup.appendChild(affirmIcon);
|
|
503
427
|
affirmIcon.style.gridRow = '1';
|
|
504
428
|
affirmIcon.style.gridColumn = '1';
|
|
505
429
|
const sureButtonElt = popup.appendChild(dom.createElement('button'));
|
|
506
|
-
sureButtonElt.style =
|
|
430
|
+
sureButtonElt.style = style.buttonStyle;
|
|
507
431
|
sureButtonElt.style.gridRow = '1';
|
|
508
432
|
sureButtonElt.style.gridColumn = '2';
|
|
509
433
|
sureButtonElt.textContent = prompt;
|
|
@@ -518,7 +442,7 @@ function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunctio
|
|
|
518
442
|
* Delete button with a check you really mean it
|
|
519
443
|
* @@ Supress check if command key held down?
|
|
520
444
|
*/
|
|
521
|
-
function deleteButtonWithCheck(dom, container, noun, deleteFunction) {
|
|
445
|
+
export function deleteButtonWithCheck(dom, container, noun, deleteFunction) {
|
|
522
446
|
function createPopup() {
|
|
523
447
|
const refererenceElement = dom.createElement('div');
|
|
524
448
|
container.insertBefore(refererenceElement, deleteButton);
|
|
@@ -528,7 +452,7 @@ function deleteButtonWithCheck(dom, container, noun, deleteFunction) {
|
|
|
528
452
|
const minusIconURI = iconBase + 'noun_2188_red.svg'; // white minus in red #cc0000 circle
|
|
529
453
|
const deleteButton = dom.createElement('img');
|
|
530
454
|
deleteButton.setAttribute('src', minusIconURI);
|
|
531
|
-
deleteButton.setAttribute('style',
|
|
455
|
+
deleteButton.setAttribute('style', style.smallButtonStyle); // @@tsc - would set deleteButton.style
|
|
532
456
|
deleteButton.style.float = 'right'; // Historically this has alwaus floated right
|
|
533
457
|
const prompt = 'Remove this ' + noun;
|
|
534
458
|
deleteButton.title = prompt;
|
|
@@ -549,7 +473,7 @@ function deleteButtonWithCheck(dom, container, noun, deleteFunction) {
|
|
|
549
473
|
*
|
|
550
474
|
* @returns <dDomElement> - the button
|
|
551
475
|
*/
|
|
552
|
-
function button(dom, iconURI, text, handler, options = { buttonColor: 'Primary', needsBorder: false }) {
|
|
476
|
+
export function button(dom, iconURI, text, handler, options = { buttonColor: 'Primary', needsBorder: false }) {
|
|
553
477
|
const button = dom.createElement('button');
|
|
554
478
|
button.setAttribute('type', 'button');
|
|
555
479
|
// button.innerHTML = text // later, user preferences may make text preferred for some
|
|
@@ -558,60 +482,60 @@ function button(dom, iconURI, text, handler, options = { buttonColor: 'Primary',
|
|
|
558
482
|
img.setAttribute('src', iconURI);
|
|
559
483
|
img.setAttribute('style', 'width: 2em; height: 2em;'); // trial and error. 2em disappears
|
|
560
484
|
img.title = text;
|
|
561
|
-
button.setAttribute('style',
|
|
485
|
+
button.setAttribute('style', style.buttonStyle);
|
|
562
486
|
}
|
|
563
487
|
else {
|
|
564
488
|
button.textContent = text.toLocaleUpperCase();
|
|
565
489
|
button.onmouseover = function () {
|
|
566
490
|
if (options.buttonColor === 'Secondary') {
|
|
567
491
|
if (options.needsBorder) {
|
|
568
|
-
button.setAttribute('style',
|
|
492
|
+
button.setAttribute('style', style.secondaryButtonNoBorderHover);
|
|
569
493
|
}
|
|
570
494
|
else {
|
|
571
|
-
button.setAttribute('style',
|
|
495
|
+
button.setAttribute('style', style.secondaryButtonHover);
|
|
572
496
|
}
|
|
573
497
|
}
|
|
574
498
|
else {
|
|
575
499
|
if (options.needsBorder) {
|
|
576
|
-
button.setAttribute('style',
|
|
500
|
+
button.setAttribute('style', style.primaryButtonNoBorderHover);
|
|
577
501
|
}
|
|
578
502
|
else {
|
|
579
|
-
button.setAttribute('style',
|
|
503
|
+
button.setAttribute('style', style.primaryButtonHover);
|
|
580
504
|
}
|
|
581
505
|
}
|
|
582
506
|
};
|
|
583
507
|
button.onmouseout = function () {
|
|
584
508
|
if (options.buttonColor === 'Secondary') {
|
|
585
509
|
if (options.needsBorder) {
|
|
586
|
-
button.setAttribute('style',
|
|
510
|
+
button.setAttribute('style', style.secondaryButtonNoBorder);
|
|
587
511
|
}
|
|
588
512
|
else {
|
|
589
|
-
button.setAttribute('style',
|
|
513
|
+
button.setAttribute('style', style.secondaryButton);
|
|
590
514
|
}
|
|
591
515
|
}
|
|
592
516
|
else {
|
|
593
517
|
if (options.needsBorder) {
|
|
594
|
-
button.setAttribute('style',
|
|
518
|
+
button.setAttribute('style', style.primaryButtonNoBorder);
|
|
595
519
|
}
|
|
596
520
|
else {
|
|
597
|
-
button.setAttribute('style',
|
|
521
|
+
button.setAttribute('style', style.primaryButton);
|
|
598
522
|
}
|
|
599
523
|
}
|
|
600
524
|
};
|
|
601
525
|
if (options.buttonColor === 'Secondary') {
|
|
602
526
|
if (options.needsBorder) {
|
|
603
|
-
button.setAttribute('style',
|
|
527
|
+
button.setAttribute('style', style.secondaryButtonNoBorder);
|
|
604
528
|
}
|
|
605
529
|
else {
|
|
606
|
-
button.setAttribute('style',
|
|
530
|
+
button.setAttribute('style', style.secondaryButton);
|
|
607
531
|
}
|
|
608
532
|
}
|
|
609
533
|
else {
|
|
610
534
|
if (options.needsBorder) {
|
|
611
|
-
button.setAttribute('style',
|
|
535
|
+
button.setAttribute('style', style.primaryButtonNoBorder);
|
|
612
536
|
}
|
|
613
537
|
else {
|
|
614
|
-
button.setAttribute('style',
|
|
538
|
+
button.setAttribute('style', style.primaryButton);
|
|
615
539
|
}
|
|
616
540
|
}
|
|
617
541
|
}
|
|
@@ -627,7 +551,7 @@ function button(dom, iconURI, text, handler, options = { buttonColor: 'Primary',
|
|
|
627
551
|
*
|
|
628
552
|
* @returns <dDomElement> - the button
|
|
629
553
|
*/
|
|
630
|
-
function cancelButton(dom, handler) {
|
|
554
|
+
export function cancelButton(dom, handler) {
|
|
631
555
|
const b = button(dom, cancelIconURI, 'Cancel', handler);
|
|
632
556
|
if (b.firstChild) { // sigh for tsc
|
|
633
557
|
b.firstChild.style.opacity = '0.3'; // Black X is too harsh: current language is grey X
|
|
@@ -641,7 +565,7 @@ function cancelButton(dom, handler) {
|
|
|
641
565
|
*
|
|
642
566
|
* @returns <dDomElement> - the button
|
|
643
567
|
*/
|
|
644
|
-
function continueButton(dom, handler) {
|
|
568
|
+
export function continueButton(dom, handler) {
|
|
645
569
|
return button(dom, checkIconURI, 'Continue', handler);
|
|
646
570
|
}
|
|
647
571
|
/* Grab a name for a new thing
|
|
@@ -650,11 +574,11 @@ function continueButton(dom, handler) {
|
|
|
650
574
|
* @params theClass Misspelt to avoid clashing with the JavaScript keyword
|
|
651
575
|
* @returns: a promise of (a name or null if cancelled)
|
|
652
576
|
*/
|
|
653
|
-
function askName(dom, kb, container, predicate, theClass, noun) {
|
|
577
|
+
export function askName(dom, kb, container, predicate, theClass, noun) {
|
|
654
578
|
return new Promise(function (resolve, _reject) {
|
|
655
579
|
const form = dom.createElement('div'); // form is broken as HTML behaviour can resurface on js error
|
|
656
580
|
// classLabel = utils.label(ns.vcard('Individual'))
|
|
657
|
-
predicate = predicate ||
|
|
581
|
+
predicate = predicate || ns.foaf('name'); // eg 'name' in user's language
|
|
658
582
|
noun = noun || (theClass ? utils.label(theClass) : ' '); // eg 'folder' in users's language
|
|
659
583
|
const prompt = noun + ' ' + utils.label(predicate) + ': ';
|
|
660
584
|
form.appendChild(dom.createElement('p')).textContent = prompt;
|
|
@@ -662,7 +586,7 @@ function askName(dom, kb, container, predicate, theClass, noun) {
|
|
|
662
586
|
namefield.setAttribute('type', 'text');
|
|
663
587
|
namefield.setAttribute('size', '100');
|
|
664
588
|
namefield.setAttribute('maxLength', '2048'); // No arbitrary limits
|
|
665
|
-
namefield.setAttribute('style',
|
|
589
|
+
namefield.setAttribute('style', style.textInputStyle);
|
|
666
590
|
namefield.select(); // focus next user input
|
|
667
591
|
form.appendChild(namefield);
|
|
668
592
|
container.appendChild(form);
|
|
@@ -692,8 +616,8 @@ function askName(dom, kb, container, predicate, theClass, noun) {
|
|
|
692
616
|
*
|
|
693
617
|
* pred is unused param at the moment
|
|
694
618
|
*/
|
|
695
|
-
|
|
696
|
-
function renderAsRow(dom, pred, obj, options) {
|
|
619
|
+
export const personTR = renderAsRow; // The legacy name is used in a lot of places
|
|
620
|
+
export function renderAsRow(dom, pred, obj, options) {
|
|
697
621
|
const tr = dom.createElement('tr');
|
|
698
622
|
options = options || {};
|
|
699
623
|
// tr.predObj = [pred.uri, obj.uri] moved to acl-control
|
|
@@ -718,14 +642,14 @@ function renderAsRow(dom, pred, obj, options) {
|
|
|
718
642
|
if (obj.uri) {
|
|
719
643
|
// blank nodes need not apply
|
|
720
644
|
if (options.link !== false) {
|
|
721
|
-
const anchor = td3.appendChild(
|
|
645
|
+
const anchor = td3.appendChild(linkIcon(dom, obj));
|
|
722
646
|
anchor.classList.add('HoverControlHide');
|
|
723
647
|
td3.appendChild(dom.createElement('br'));
|
|
724
648
|
}
|
|
725
649
|
if (options.draggable !== false) {
|
|
726
650
|
// default is on
|
|
727
651
|
image.setAttribute('draggable', 'false'); // Stop the image being dragged instead - just the TR
|
|
728
|
-
|
|
652
|
+
makeDraggable(tr, obj);
|
|
729
653
|
}
|
|
730
654
|
}
|
|
731
655
|
;
|
|
@@ -738,7 +662,7 @@ function renderAsRow(dom, pred, obj, options) {
|
|
|
738
662
|
* from buttons
|
|
739
663
|
* @internal exporting this only for unit tests
|
|
740
664
|
*/
|
|
741
|
-
function createNameDiv(dom, div, title, obj) {
|
|
665
|
+
export function createNameDiv(dom, div, title, obj) {
|
|
742
666
|
const nameDiv = div.appendChild(dom.createElement('div'));
|
|
743
667
|
if (title) {
|
|
744
668
|
nameDiv.textContent = title;
|
|
@@ -753,38 +677,38 @@ function createNameDiv(dom, div, title, obj) {
|
|
|
753
677
|
* from buttons
|
|
754
678
|
* @internal exporting this only for unit tests
|
|
755
679
|
*/
|
|
756
|
-
function createLinkDiv(dom, div, obj, options) {
|
|
680
|
+
export function createLinkDiv(dom, div, obj, options) {
|
|
757
681
|
const linkDiv = div.appendChild(dom.createElement('div'));
|
|
758
|
-
linkDiv.setAttribute('style',
|
|
682
|
+
linkDiv.setAttribute('style', style.linkDivStyle);
|
|
759
683
|
if (options.deleteFunction) {
|
|
760
684
|
deleteButtonWithCheck(dom, linkDiv, options.noun || 'one', options.deleteFunction);
|
|
761
685
|
}
|
|
762
686
|
if (obj.uri) {
|
|
763
687
|
// blank nodes need not apply
|
|
764
688
|
if (options.link !== false) {
|
|
765
|
-
|
|
689
|
+
createLinkForURI(dom, linkDiv, obj);
|
|
766
690
|
}
|
|
767
|
-
|
|
691
|
+
makeDraggable(div, obj);
|
|
768
692
|
}
|
|
769
693
|
}
|
|
770
694
|
/**
|
|
771
695
|
* A Div to represent a draggable person, etc in a list
|
|
772
696
|
* configurable to add an onClick listener
|
|
773
697
|
*/
|
|
774
|
-
function renderAsDiv(dom, obj, options) {
|
|
698
|
+
export function renderAsDiv(dom, obj, options) {
|
|
775
699
|
const div = dom.createElement('div');
|
|
776
|
-
div.setAttribute('style',
|
|
700
|
+
div.setAttribute('style', style.renderAsDivStyle);
|
|
777
701
|
options = options || {};
|
|
778
702
|
const image = options.image || faviconOrDefault(dom, obj);
|
|
779
|
-
|
|
703
|
+
createImageDiv(dom, div, image);
|
|
780
704
|
createNameDiv(dom, div, options.title, obj);
|
|
781
705
|
createLinkDiv(dom, div, obj, options);
|
|
782
706
|
if (options.clickable && options.onClickFunction) {
|
|
783
|
-
|
|
707
|
+
addClickListenerToElement(div, options.onClickFunction);
|
|
784
708
|
}
|
|
785
709
|
// to be compatible with the SolidOS table layout
|
|
786
710
|
if (options.wrapInATR) {
|
|
787
|
-
const tr =
|
|
711
|
+
const tr = wrapDivInATR(dom, div, obj);
|
|
788
712
|
return tr;
|
|
789
713
|
}
|
|
790
714
|
return div;
|
|
@@ -792,7 +716,7 @@ function renderAsDiv(dom, obj, options) {
|
|
|
792
716
|
/**
|
|
793
717
|
* Refresh a DOM tree recursively
|
|
794
718
|
*/
|
|
795
|
-
function refreshTree(root) {
|
|
719
|
+
export function refreshTree(root) {
|
|
796
720
|
if (root.refresh) {
|
|
797
721
|
root.refresh();
|
|
798
722
|
return;
|
|
@@ -807,13 +731,13 @@ function refreshTree(root) {
|
|
|
807
731
|
* to a meeting.
|
|
808
732
|
* Accepts dropping URLs onto it to add attachments to it.
|
|
809
733
|
*/
|
|
810
|
-
function attachmentList(dom, subject, div, options = {}) {
|
|
734
|
+
export function attachmentList(dom, subject, div, options = {}) {
|
|
811
735
|
// options = options || {}
|
|
812
736
|
const deleteAttachment = function (target) {
|
|
813
737
|
if (!kb.updater) {
|
|
814
738
|
throw new Error('kb has no updater');
|
|
815
739
|
}
|
|
816
|
-
kb.updater.update(
|
|
740
|
+
kb.updater.update(st(subject, predicate, target, doc), [], function (uri, ok, errorBody, _xhr) {
|
|
817
741
|
if (ok) {
|
|
818
742
|
refresh();
|
|
819
743
|
}
|
|
@@ -830,7 +754,7 @@ function attachmentList(dom, subject, div, options = {}) {
|
|
|
830
754
|
deleteAttachment(theTarget);
|
|
831
755
|
};
|
|
832
756
|
}
|
|
833
|
-
return
|
|
757
|
+
return personTR(dom, predicate, target, opt);
|
|
834
758
|
}
|
|
835
759
|
const refresh = function () {
|
|
836
760
|
const things = kb.each(subject, predicate);
|
|
@@ -840,9 +764,9 @@ function attachmentList(dom, subject, div, options = {}) {
|
|
|
840
764
|
function droppedURIHandler(uris) {
|
|
841
765
|
const ins = [];
|
|
842
766
|
uris.forEach(function (u) {
|
|
843
|
-
const target =
|
|
767
|
+
const target = sym(u); // Attachment needs text label to disinguish I think not icon.
|
|
844
768
|
debug.log('Dropped on attachemnt ' + u); // icon was: iconBase + 'noun_25830.svg'
|
|
845
|
-
ins.push(
|
|
769
|
+
ins.push(st(subject, predicate, target, doc));
|
|
846
770
|
});
|
|
847
771
|
if (!kb.updater) {
|
|
848
772
|
throw new Error('kb has no updater');
|
|
@@ -857,10 +781,11 @@ function attachmentList(dom, subject, div, options = {}) {
|
|
|
857
781
|
});
|
|
858
782
|
}
|
|
859
783
|
function droppedFileHandler(files) {
|
|
860
|
-
|
|
861
|
-
options.uploadFolder
|
|
784
|
+
var _a, _b;
|
|
785
|
+
uploadFiles(kb.fetcher, files, (_a = options.uploadFolder) === null || _a === void 0 ? void 0 : _a.uri, // Files
|
|
786
|
+
(_b = options.uploadFolder) === null || _b === void 0 ? void 0 : _b.uri, // Pictures
|
|
862
787
|
function (theFile, destURI) {
|
|
863
|
-
const ins = [
|
|
788
|
+
const ins = [st(subject, predicate, kb.sym(destURI), doc)];
|
|
864
789
|
if (!kb.updater) {
|
|
865
790
|
throw new Error('kb has no updater');
|
|
866
791
|
}
|
|
@@ -880,9 +805,9 @@ function attachmentList(dom, subject, div, options = {}) {
|
|
|
880
805
|
const modify = options.modify;
|
|
881
806
|
const promptIcon = options.promptIcon || iconBase + 'noun_748003.svg'; // target
|
|
882
807
|
// const promptIcon = options.promptIcon || (iconBase + 'noun_25830.svg') // paperclip
|
|
883
|
-
const predicate = options.predicate ||
|
|
808
|
+
const predicate = options.predicate || ns.wf('attachment');
|
|
884
809
|
const noun = options.noun || 'attachment';
|
|
885
|
-
const kb =
|
|
810
|
+
const kb = store;
|
|
886
811
|
const attachmentOuter = div.appendChild(dom.createElement('table'));
|
|
887
812
|
attachmentOuter.setAttribute('style', 'margin-top: 1em; margin-bottom: 1em;');
|
|
888
813
|
const attachmentOne = attachmentOuter.appendChild(dom.createElement('tr'));
|
|
@@ -900,8 +825,8 @@ function attachmentList(dom, subject, div, options = {}) {
|
|
|
900
825
|
// paperclip.style = buttonStyle // @@ needed? default has white background
|
|
901
826
|
attachmentLeft.appendChild(paperclip);
|
|
902
827
|
const fhandler = options.uploadFolder ? droppedFileHandler : null;
|
|
903
|
-
|
|
904
|
-
|
|
828
|
+
makeDropTarget(paperclip, droppedURIHandler, fhandler); // beware missing the wire of the paparclip!
|
|
829
|
+
makeDropTarget(attachmentLeft, droppedURIHandler, fhandler); // just the outer won't do it
|
|
905
830
|
if (options.uploadFolder) { // Addd an explicit file upload button as well
|
|
906
831
|
const buttonDiv = fileUploadButtonDiv(dom, droppedFileHandler);
|
|
907
832
|
attachmentLeft.appendChild(buttonDiv);
|
|
@@ -917,7 +842,7 @@ function attachmentList(dom, subject, div, options = {}) {
|
|
|
917
842
|
* Note that native links have constraints in Firefox, they
|
|
918
843
|
* don't work with local files for instance (2011)
|
|
919
844
|
*/
|
|
920
|
-
function openHrefInOutlineMode(e) {
|
|
845
|
+
export function openHrefInOutlineMode(e) {
|
|
921
846
|
e.preventDefault();
|
|
922
847
|
e.stopPropagation();
|
|
923
848
|
const target = utils.getTarget(e);
|
|
@@ -929,14 +854,14 @@ function openHrefInOutlineMode(e) {
|
|
|
929
854
|
// @@ TODO Remove the use of document as a global object
|
|
930
855
|
// TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
931
856
|
;
|
|
932
|
-
dom.outlineManager.GotoSubject(
|
|
857
|
+
dom.outlineManager.GotoSubject(store.sym(uri), true, undefined, true, undefined);
|
|
933
858
|
}
|
|
934
859
|
else if (window && window.panes && window.panes.getOutliner) {
|
|
935
860
|
// @@ TODO Remove the use of window as a global object
|
|
936
861
|
;
|
|
937
862
|
window.panes
|
|
938
863
|
.getOutliner()
|
|
939
|
-
.GotoSubject(
|
|
864
|
+
.GotoSubject(store.sym(uri), true, undefined, true, undefined);
|
|
940
865
|
}
|
|
941
866
|
else {
|
|
942
867
|
debug.log('ERROR: Can\'t access outline manager in this config');
|
|
@@ -948,7 +873,7 @@ function openHrefInOutlineMode(e) {
|
|
|
948
873
|
*
|
|
949
874
|
* @@ Todo: make it a personal preference.
|
|
950
875
|
*/
|
|
951
|
-
function defaultAnnotationStore(subject) {
|
|
876
|
+
export function defaultAnnotationStore(subject) {
|
|
952
877
|
if (subject.uri === undefined)
|
|
953
878
|
return undefined;
|
|
954
879
|
let s = subject.uri;
|
|
@@ -965,31 +890,31 @@ function defaultAnnotationStore(subject) {
|
|
|
965
890
|
return undefined;
|
|
966
891
|
s = s.slice(0, slash);
|
|
967
892
|
}
|
|
968
|
-
return
|
|
893
|
+
return store.sym('http://tabulator.org/wiki/annnotation/' + s);
|
|
969
894
|
}
|
|
970
895
|
/**
|
|
971
896
|
* Retrieve all RDF class URIs from solid-ui's RDF store
|
|
972
897
|
* @returns an object `ret` such that `Object.keys(ret)` is
|
|
973
898
|
* the list of all class URIs.
|
|
974
899
|
*/
|
|
975
|
-
function allClassURIs() {
|
|
900
|
+
export function allClassURIs() {
|
|
976
901
|
const set = {};
|
|
977
|
-
|
|
978
|
-
.statementsMatching(undefined,
|
|
902
|
+
store
|
|
903
|
+
.statementsMatching(undefined, ns.rdf('type'), undefined)
|
|
979
904
|
.forEach(function (st) {
|
|
980
905
|
if (st.object.value)
|
|
981
906
|
set[st.object.value] = true;
|
|
982
907
|
});
|
|
983
|
-
|
|
984
|
-
.statementsMatching(undefined,
|
|
908
|
+
store
|
|
909
|
+
.statementsMatching(undefined, ns.rdfs('subClassOf'), undefined)
|
|
985
910
|
.forEach(function (st) {
|
|
986
911
|
if (st.object.value)
|
|
987
912
|
set[st.object.value] = true;
|
|
988
913
|
if (st.subject.value)
|
|
989
914
|
set[st.subject.value] = true;
|
|
990
915
|
});
|
|
991
|
-
|
|
992
|
-
.each(undefined,
|
|
916
|
+
store
|
|
917
|
+
.each(undefined, ns.rdf('type'), ns.rdfs('Class'))
|
|
993
918
|
.forEach(function (c) {
|
|
994
919
|
if (c.value)
|
|
995
920
|
set[c.value] = true;
|
|
@@ -1007,7 +932,7 @@ function allClassURIs() {
|
|
|
1007
932
|
* TODO: move to diff module? Not really a button.
|
|
1008
933
|
* @param {Store} kb The quadstore to be searched.
|
|
1009
934
|
*/
|
|
1010
|
-
function propertyTriage(kb) {
|
|
935
|
+
export function propertyTriage(kb) {
|
|
1011
936
|
const possibleProperties = {};
|
|
1012
937
|
// if (possibleProperties === undefined) possibleProperties = {}
|
|
1013
938
|
// const kb = store
|
|
@@ -1028,7 +953,7 @@ function propertyTriage(kb) {
|
|
|
1028
953
|
no++;
|
|
1029
954
|
}
|
|
1030
955
|
} // If nothing discovered, then could be either:
|
|
1031
|
-
const ps = kb.each(undefined,
|
|
956
|
+
const ps = kb.each(undefined, ns.rdf('type'), ns.rdf('Property'));
|
|
1032
957
|
for (let i = 0; i < ps.length; i++) {
|
|
1033
958
|
const p = ps[i].toNT();
|
|
1034
959
|
if (!op[p] && !dp[p]) {
|
|
@@ -1039,7 +964,7 @@ function propertyTriage(kb) {
|
|
|
1039
964
|
}
|
|
1040
965
|
possibleProperties.op = op;
|
|
1041
966
|
possibleProperties.dp = dp;
|
|
1042
|
-
|
|
967
|
+
info(`propertyTriage: ${no} non-lit, ${nd} literal. ${nu} unknown.`);
|
|
1043
968
|
return possibleProperties;
|
|
1044
969
|
}
|
|
1045
970
|
/**
|
|
@@ -1048,7 +973,7 @@ function propertyTriage(kb) {
|
|
|
1048
973
|
/**
|
|
1049
974
|
* A button for jumping
|
|
1050
975
|
*/
|
|
1051
|
-
function linkButton(dom, object) {
|
|
976
|
+
export function linkButton(dom, object) {
|
|
1052
977
|
const b = dom.createElement('button');
|
|
1053
978
|
b.setAttribute('type', 'button');
|
|
1054
979
|
b.textContent = 'Goto ' + utils.label(object);
|
|
@@ -1063,7 +988,7 @@ function linkButton(dom, object) {
|
|
|
1063
988
|
/**
|
|
1064
989
|
* A button to remove some other element from the page
|
|
1065
990
|
*/
|
|
1066
|
-
function removeButton(dom, element) {
|
|
991
|
+
export function removeButton(dom, element) {
|
|
1067
992
|
const b = dom.createElement('button');
|
|
1068
993
|
b.setAttribute('type', 'button');
|
|
1069
994
|
b.textContent = '✕'; // MULTIPLICATION X
|
|
@@ -1108,10 +1033,10 @@ buttons.headerButtons = function (dom, kb, name, words) {
|
|
|
1108
1033
|
//
|
|
1109
1034
|
// @param inverse means this is the object rather than the subject
|
|
1110
1035
|
//
|
|
1111
|
-
function selectorPanel(dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
|
|
1036
|
+
export function selectorPanel(dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
|
|
1112
1037
|
return selectorPanelRefresh(dom.createElement('div'), dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback);
|
|
1113
1038
|
}
|
|
1114
|
-
function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
|
|
1039
|
+
export function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
|
|
1115
1040
|
const style0 = 'border: 0.1em solid #ddd; border-bottom: none; width: 95%; height: 2em; padding: 0.5em;';
|
|
1116
1041
|
let selected = null;
|
|
1117
1042
|
list.innerHTML = '';
|
|
@@ -1128,7 +1053,7 @@ function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible,
|
|
|
1128
1053
|
image.setAttribute('src', options.connectIcon || iconBase + 'noun_25830.svg');
|
|
1129
1054
|
image.setAttribute('title', already.length ? already.length : 'attach');
|
|
1130
1055
|
};
|
|
1131
|
-
const f =
|
|
1056
|
+
const f = index.twoLine.widgetForClass(type);
|
|
1132
1057
|
// eslint-disable-next-line prefer-const
|
|
1133
1058
|
item = f(dom, x);
|
|
1134
1059
|
item.setAttribute('style', style0);
|
|
@@ -1178,7 +1103,7 @@ function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible,
|
|
|
1178
1103
|
//
|
|
1179
1104
|
// Small compact views of things
|
|
1180
1105
|
//
|
|
1181
|
-
|
|
1106
|
+
export let index = {};
|
|
1182
1107
|
// ///////////////////////////////////////////////////////////////////////////
|
|
1183
1108
|
// We need these for anything which is a subject of an attachment.
|
|
1184
1109
|
//
|
|
@@ -1194,17 +1119,17 @@ function twoLineDefault(dom, x) {
|
|
|
1194
1119
|
* @param c The RDF class for which we want a widget generator function
|
|
1195
1120
|
*/
|
|
1196
1121
|
function twoLineWidgetForClass(c) {
|
|
1197
|
-
let widget =
|
|
1198
|
-
const kb =
|
|
1122
|
+
let widget = index.twoLine[c.uri];
|
|
1123
|
+
const kb = store;
|
|
1199
1124
|
if (widget)
|
|
1200
1125
|
return widget;
|
|
1201
1126
|
const sup = kb.findSuperClassesNT(c);
|
|
1202
1127
|
for (const cl in sup) {
|
|
1203
|
-
widget =
|
|
1128
|
+
widget = index.twoLine[kb.fromNT(cl).uri];
|
|
1204
1129
|
if (widget)
|
|
1205
1130
|
return widget;
|
|
1206
1131
|
}
|
|
1207
|
-
return
|
|
1132
|
+
return index.twoLine[''];
|
|
1208
1133
|
}
|
|
1209
1134
|
/**
|
|
1210
1135
|
* Display a transaction
|
|
@@ -1216,7 +1141,7 @@ function twoLineWidgetForClass(c) {
|
|
|
1216
1141
|
function twoLineTransaction(dom, x) {
|
|
1217
1142
|
let failed = '';
|
|
1218
1143
|
const enc = function (p) {
|
|
1219
|
-
const y =
|
|
1144
|
+
const y = store.any(x, ns.qu(p));
|
|
1220
1145
|
if (!y)
|
|
1221
1146
|
failed += '@@ No value for ' + p + '! ';
|
|
1222
1147
|
return y ? utils.escapeForXML(y.value) : '?'; // @@@@
|
|
@@ -1247,24 +1172,24 @@ function twoLineTransaction(dom, x) {
|
|
|
1247
1172
|
*/
|
|
1248
1173
|
function twoLineTrip(dom, x) {
|
|
1249
1174
|
const enc = function (p) {
|
|
1250
|
-
const y =
|
|
1175
|
+
const y = store.any(x, p);
|
|
1251
1176
|
return y ? utils.escapeForXML(y.value) : '?';
|
|
1252
1177
|
};
|
|
1253
1178
|
const box = dom.createElement('table');
|
|
1254
1179
|
box.innerHTML = `
|
|
1255
1180
|
<tr>
|
|
1256
|
-
<td colspan="2">${enc(
|
|
1181
|
+
<td colspan="2">${enc(ns.dc('title'))}</td>
|
|
1257
1182
|
</tr>
|
|
1258
1183
|
<tr style="color: #777">
|
|
1259
|
-
<td>${enc(
|
|
1260
|
-
<td>${enc(
|
|
1184
|
+
<td>${enc(ns.cal('dtstart'))}</td>
|
|
1185
|
+
<td>${enc(ns.cal('dtend'))}</td>
|
|
1261
1186
|
</tr>`;
|
|
1262
1187
|
return box;
|
|
1263
1188
|
}
|
|
1264
1189
|
/**
|
|
1265
1190
|
* Stick a stylesheet link the document if not already there
|
|
1266
1191
|
*/
|
|
1267
|
-
function addStyleSheet(dom, href) {
|
|
1192
|
+
export function addStyleSheet(dom, href) {
|
|
1268
1193
|
const links = dom.querySelectorAll('link');
|
|
1269
1194
|
for (let i = 0; i < links.length; i++) {
|
|
1270
1195
|
if ((links[i].getAttribute('rel') || '') === 'stylesheet' &&
|
|
@@ -1280,16 +1205,16 @@ function addStyleSheet(dom, href) {
|
|
|
1280
1205
|
}
|
|
1281
1206
|
// Figure (or guess) whether this is an image, etc
|
|
1282
1207
|
//
|
|
1283
|
-
function isAudio(file) {
|
|
1208
|
+
export function isAudio(file) {
|
|
1284
1209
|
return isImage(file, 'audio');
|
|
1285
1210
|
}
|
|
1286
|
-
function isVideo(file) {
|
|
1211
|
+
export function isVideo(file) {
|
|
1287
1212
|
return isImage(file, 'video');
|
|
1288
1213
|
}
|
|
1289
1214
|
/**
|
|
1290
1215
|
*
|
|
1291
1216
|
*/
|
|
1292
|
-
function isImage(file, kind) {
|
|
1217
|
+
export function isImage(file, kind) {
|
|
1293
1218
|
const dcCLasses = {
|
|
1294
1219
|
audio: 'http://purl.org/dc/dcmitype/Sound',
|
|
1295
1220
|
image: 'http://purl.org/dc/dcmitype/Image',
|
|
@@ -1298,10 +1223,10 @@ function isImage(file, kind) {
|
|
|
1298
1223
|
const what = kind || 'image';
|
|
1299
1224
|
// See https://github.com/linkeddata/rdflib.js/blob/e367d5088c/src/formula.ts#L554
|
|
1300
1225
|
//
|
|
1301
|
-
const typeURIs =
|
|
1226
|
+
const typeURIs = store.findTypeURIs(file);
|
|
1302
1227
|
// See https://github.com/linkeddata/rdflib.js/blob/d5000f/src/utils-js.js#L14
|
|
1303
1228
|
// e.g.'http://www.w3.org/ns/iana/media-types/audio'
|
|
1304
|
-
const prefix =
|
|
1229
|
+
const prefix = Util.mediaTypeClass(what + '/*').uri.split('*')[0];
|
|
1305
1230
|
for (const t in typeURIs) {
|
|
1306
1231
|
if (t.startsWith(prefix))
|
|
1307
1232
|
return true;
|
|
@@ -1318,7 +1243,7 @@ function isImage(file, kind) {
|
|
|
1318
1243
|
* The input is hidden, as it is uglky - the user clicks on the nice icons and fires the input.
|
|
1319
1244
|
*/
|
|
1320
1245
|
// See https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications
|
|
1321
|
-
function fileUploadButtonDiv(dom, droppedFileHandler) {
|
|
1246
|
+
export function fileUploadButtonDiv(dom, droppedFileHandler) {
|
|
1322
1247
|
const div = dom.createElement('div');
|
|
1323
1248
|
const input = div.appendChild(dom.createElement('input'));
|
|
1324
1249
|
input.setAttribute('type', 'file');
|
|
@@ -1339,10 +1264,10 @@ function fileUploadButtonDiv(dom, droppedFileHandler) {
|
|
|
1339
1264
|
const buttonElt = div.appendChild(button(dom, iconBase + 'noun_Upload_76574_000000.svg', 'Upload files', _event => {
|
|
1340
1265
|
input.click();
|
|
1341
1266
|
}));
|
|
1342
|
-
|
|
1267
|
+
makeDropTarget(buttonElt, null, droppedFileHandler); // Can also just drop on button
|
|
1343
1268
|
return div;
|
|
1344
1269
|
}
|
|
1345
|
-
|
|
1270
|
+
index = {
|
|
1346
1271
|
line: { // Approx 80em
|
|
1347
1272
|
},
|
|
1348
1273
|
twoLine: {
|