solid-ui 2.4.14-bbf45639 → 2.4.14-bbf45639-e81d3e08
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/LICENSE.md +0 -0
- package/README.md +0 -0
- package/lib/acl/access-controller.d.ts +0 -0
- package/lib/acl/access-controller.d.ts.map +0 -0
- package/lib/acl/access-controller.js +441 -334
- package/lib/acl/access-controller.js.map +1 -1
- package/lib/acl/access-groups.d.ts +0 -0
- package/lib/acl/access-groups.d.ts.map +0 -0
- package/lib/acl/access-groups.js +495 -348
- package/lib/acl/access-groups.js.map +1 -1
- package/lib/acl/acl-control.d.ts +0 -0
- package/lib/acl/acl-control.d.ts.map +0 -0
- package/lib/acl/acl-control.js +198 -168
- package/lib/acl/acl-control.js.map +1 -1
- package/lib/acl/acl.d.ts +0 -0
- package/lib/acl/acl.d.ts.map +0 -0
- package/lib/acl/acl.js +463 -446
- package/lib/acl/acl.js.map +1 -1
- package/lib/acl/add-agent-buttons.d.ts +0 -0
- package/lib/acl/add-agent-buttons.d.ts.map +0 -0
- package/lib/acl/add-agent-buttons.js +515 -318
- package/lib/acl/add-agent-buttons.js.map +1 -1
- package/lib/acl/index.d.ts +0 -0
- package/lib/acl/index.d.ts.map +0 -0
- package/lib/acl/index.js +35 -27
- package/lib/acl/index.js.map +1 -1
- package/lib/acl/styles.d.ts +0 -0
- package/lib/acl/styles.d.ts.map +0 -0
- package/lib/acl/styles.js +90 -84
- package/lib/acl/styles.js.map +1 -1
- package/lib/acl/types.d.ts +0 -0
- package/lib/acl/types.d.ts.map +0 -0
- package/lib/acl/types.js +4 -5
- package/lib/acl/types.js.map +1 -1
- package/lib/authn/authSession.d.ts +0 -0
- package/lib/authn/authSession.d.ts.map +0 -0
- package/lib/authn/authSession.js +21 -14
- package/lib/authn/authSession.js.map +1 -1
- package/lib/authn/authn.d.ts +0 -0
- package/lib/authn/authn.d.ts.map +0 -0
- package/lib/authn/authn.js +1935 -1391
- package/lib/authn/authn.js.map +1 -1
- package/lib/authn/config-default.js +0 -0
- package/lib/authn/config-default.js.map +0 -0
- package/lib/authn/index.d.ts +0 -0
- package/lib/authn/index.d.ts.map +0 -0
- package/lib/authn/index.js +37 -26
- package/lib/authn/index.js.map +1 -1
- package/lib/authn/signup.js +0 -0
- package/lib/authn/signup.js.map +0 -0
- package/lib/authn/types.d.ts +0 -0
- package/lib/authn/types.d.ts.map +0 -0
- package/lib/authn/types.js +4 -1
- package/lib/authn/types.js.map +1 -1
- package/lib/chat/bookmarks.js +0 -0
- package/lib/chat/bookmarks.js.map +0 -0
- package/lib/chat/dateFolder.js +0 -0
- package/lib/chat/dateFolder.js.map +0 -0
- package/lib/chat/infinite.js +0 -0
- package/lib/chat/infinite.js.map +0 -0
- package/lib/chat/message.js +0 -0
- package/lib/chat/message.js.map +0 -0
- package/lib/chat/messageTools.js +0 -0
- package/lib/chat/messageTools.js.map +0 -0
- package/lib/chat/thread.js +0 -0
- package/lib/chat/thread.js.map +0 -0
- package/lib/create/create.d.ts +0 -0
- package/lib/create/create.d.ts.map +0 -0
- package/lib/create/create.js +214 -209
- package/lib/create/create.js.map +1 -1
- package/lib/create/index.d.ts +0 -0
- package/lib/create/index.d.ts.map +0 -0
- package/lib/create/index.js +10 -4
- package/lib/create/index.js.map +1 -1
- package/lib/create/types.d.ts +0 -0
- package/lib/create/types.d.ts.map +0 -0
- package/lib/create/types.js +4 -1
- package/lib/create/types.js.map +1 -1
- package/lib/debug.d.ts +0 -0
- package/lib/debug.d.ts.map +0 -0
- package/lib/debug.js +28 -30
- package/lib/debug.js.map +1 -1
- package/lib/folders.js +0 -0
- package/lib/folders.js.map +0 -0
- package/lib/footer/index.d.ts +0 -0
- package/lib/footer/index.d.ts.map +0 -0
- package/lib/footer/index.js +126 -109
- package/lib/footer/index.js.map +1 -1
- package/lib/footer/styleMap.d.ts +0 -0
- package/lib/footer/styleMap.d.ts.map +0 -0
- package/lib/footer/styleMap.js +11 -7
- package/lib/footer/styleMap.js.map +1 -1
- package/lib/header/empty-profile.d.ts +0 -0
- package/lib/header/empty-profile.d.ts.map +0 -0
- package/lib/header/empty-profile.js +6 -2
- package/lib/header/empty-profile.js.map +1 -1
- package/lib/header/index.d.ts +0 -0
- package/lib/header/index.d.ts.map +0 -0
- package/lib/header/index.js +361 -285
- package/lib/header/index.js.map +1 -1
- package/lib/header/styleMap.d.ts +0 -0
- package/lib/header/styleMap.d.ts.map +0 -0
- package/lib/header/styleMap.js +132 -116
- package/lib/header/styleMap.js.map +1 -1
- package/lib/iconBase.d.ts +0 -0
- package/lib/iconBase.d.ts.map +0 -0
- package/lib/iconBase.js +30 -23
- package/lib/iconBase.js.map +1 -1
- package/lib/icons/solid_logo.d.ts +0 -0
- package/lib/icons/solid_logo.d.ts.map +0 -0
- package/lib/icons/solid_logo.js +0 -0
- package/lib/icons/solid_logo.js.map +1 -1
- package/lib/index.d.ts +0 -0
- package/lib/index.d.ts.map +0 -0
- package/lib/index.js +207 -103
- package/lib/index.js.map +1 -1
- package/lib/jss/index.d.ts +0 -0
- package/lib/jss/index.d.ts.map +0 -0
- package/lib/jss/index.js +30 -21
- package/lib/jss/index.js.map +1 -1
- package/lib/log.d.ts +0 -0
- package/lib/log.d.ts.map +0 -0
- package/lib/log.js +131 -83
- package/lib/log.js.map +1 -1
- package/lib/logic.d.ts +0 -0
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +73 -82
- package/lib/logic.js.map +1 -1
- package/lib/matrix/index.d.ts +0 -0
- package/lib/matrix/index.d.ts.map +0 -0
- package/lib/matrix/index.js +10 -4
- package/lib/matrix/index.js.map +1 -1
- package/lib/matrix/matrix.d.ts +0 -0
- package/lib/matrix/matrix.d.ts.map +0 -0
- package/lib/matrix/matrix.js +237 -210
- package/lib/matrix/matrix.js.map +1 -1
- package/lib/matrix/types.d.ts +0 -0
- package/lib/matrix/types.d.ts.map +0 -0
- package/lib/matrix/types.js +4 -1
- package/lib/matrix/types.js.map +1 -1
- package/lib/media/index.d.ts +0 -0
- package/lib/media/index.d.ts.map +0 -0
- package/lib/media/index.js +11 -5
- package/lib/media/index.js.map +1 -1
- package/lib/media/media-capture.d.ts +0 -0
- package/lib/media/media-capture.d.ts.map +0 -0
- package/lib/media/media-capture.js +181 -187
- package/lib/media/media-capture.js.map +1 -1
- package/lib/messageArea.js +0 -0
- package/lib/messageArea.js.map +0 -0
- package/lib/noun_Camera_1618446_000000.js +0 -0
- package/lib/noun_Camera_1618446_000000.js.map +0 -0
- package/lib/ns.js +0 -0
- package/lib/ns.js.map +0 -0
- package/lib/pad.d.ts +0 -0
- package/lib/pad.d.ts.map +0 -0
- package/lib/pad.js +954 -794
- package/lib/pad.js.map +1 -1
- package/lib/participation.d.ts +0 -0
- package/lib/participation.d.ts.map +0 -0
- package/lib/participation.js +199 -170
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +0 -0
- package/lib/preferences.js.map +0 -0
- package/lib/stories/decorators.js +0 -0
- package/lib/stories/decorators.js.map +0 -0
- package/lib/style.js +0 -0
- package/lib/style.js.map +0 -0
- package/lib/table.js +0 -0
- package/lib/table.js.map +0 -0
- package/lib/tabs.d.ts +0 -0
- package/lib/tabs.d.ts.map +0 -0
- package/lib/tabs.js +342 -235
- package/lib/tabs.js.map +1 -1
- package/lib/typings.d.js +0 -0
- package/lib/typings.d.js.map +0 -0
- package/lib/utils/headerFooterHelpers.d.ts +0 -0
- package/lib/utils/headerFooterHelpers.d.ts.map +0 -0
- package/lib/utils/headerFooterHelpers.js +155 -130
- package/lib/utils/headerFooterHelpers.js.map +1 -1
- package/lib/utils/index.js +0 -0
- package/lib/utils/index.js.map +0 -0
- package/lib/utils/label.d.ts +0 -0
- package/lib/utils/label.d.ts.map +0 -0
- package/lib/utils/label.js +113 -121
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.d.ts +0 -0
- package/lib/versionInfo.d.ts.map +0 -0
- package/lib/versionInfo.js +28 -23
- package/lib/versionInfo.js.map +1 -1
- package/lib/webpack-bundle.js +16324 -31
- package/lib/webpack-bundle.js.map +1 -1
- package/lib/widgets/buttons/iconLinks.d.ts +0 -0
- package/lib/widgets/buttons/iconLinks.d.ts.map +0 -0
- package/lib/widgets/buttons/iconLinks.js +30 -19
- package/lib/widgets/buttons/iconLinks.js.map +1 -1
- package/lib/widgets/buttons.d.ts +0 -0
- package/lib/widgets/buttons.d.ts.map +0 -0
- package/lib/widgets/buttons.js +1113 -935
- package/lib/widgets/buttons.js.map +1 -1
- package/lib/widgets/dragAndDrop.js +0 -0
- package/lib/widgets/dragAndDrop.js.map +0 -0
- package/lib/widgets/error.d.ts +0 -0
- package/lib/widgets/error.d.ts.map +0 -0
- package/lib/widgets/error.js +24 -18
- package/lib/widgets/error.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteBar.d.ts +0 -0
- package/lib/widgets/forms/autocomplete/autocompleteBar.d.ts.map +0 -0
- package/lib/widgets/forms/autocomplete/autocompleteBar.js +325 -234
- package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteField.d.ts +0 -0
- package/lib/widgets/forms/autocomplete/autocompleteField.d.ts.map +0 -0
- package/lib/widgets/forms/autocomplete/autocompleteField.js +280 -249
- package/lib/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.d.ts +0 -0
- package/lib/widgets/forms/autocomplete/autocompletePicker.d.ts.map +0 -0
- package/lib/widgets/forms/autocomplete/autocompletePicker.js +497 -317
- package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/lib/widgets/forms/autocomplete/language.d.ts +0 -0
- package/lib/widgets/forms/autocomplete/language.d.ts.map +0 -0
- package/lib/widgets/forms/autocomplete/language.js +214 -160
- package/lib/widgets/forms/autocomplete/language.js.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.d.ts +0 -0
- package/lib/widgets/forms/autocomplete/publicData.d.ts.map +0 -0
- package/lib/widgets/forms/autocomplete/publicData.js +725 -489
- package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/lib/widgets/forms/basic.d.ts +0 -0
- package/lib/widgets/forms/basic.d.ts.map +0 -0
- package/lib/widgets/forms/basic.js +239 -208
- package/lib/widgets/forms/basic.js.map +1 -1
- package/lib/widgets/forms/comment.d.ts +0 -0
- package/lib/widgets/forms/comment.d.ts.map +0 -0
- package/lib/widgets/forms/comment.js +48 -48
- package/lib/widgets/forms/comment.js.map +1 -1
- package/lib/widgets/forms/fieldFunction.d.ts +0 -0
- package/lib/widgets/forms/fieldFunction.d.ts.map +0 -0
- package/lib/widgets/forms/fieldFunction.js +50 -31
- package/lib/widgets/forms/fieldFunction.js.map +1 -1
- package/lib/widgets/forms/fieldParams.d.ts +0 -0
- package/lib/widgets/forms/fieldParams.d.ts.map +0 -0
- package/lib/widgets/forms/fieldParams.js +81 -102
- package/lib/widgets/forms/fieldParams.js.map +1 -1
- package/lib/widgets/forms/formStyle.d.ts +0 -0
- package/lib/widgets/forms/formStyle.d.ts.map +0 -0
- package/lib/widgets/forms/formStyle.js +50 -52
- package/lib/widgets/forms/formStyle.js.map +1 -1
- package/lib/widgets/forms.js +0 -0
- package/lib/widgets/forms.js.map +0 -0
- package/lib/widgets/index.js +0 -0
- package/lib/widgets/index.js.map +0 -0
- package/lib/widgets/peoplePicker.js +0 -0
- package/lib/widgets/peoplePicker.js.map +0 -0
- package/lib/widgets/widgetHelpers.d.ts +0 -0
- package/lib/widgets/widgetHelpers.d.ts.map +0 -0
- package/lib/widgets/widgetHelpers.js +30 -18
- package/lib/widgets/widgetHelpers.js.map +1 -1
- package/package.json +6 -6
package/lib/widgets/buttons.js
CHANGED
|
@@ -1,203 +1,248 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
13
7
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
exports.
|
|
8
|
+
exports.addStyleSheet = addStyleSheet;
|
|
9
|
+
exports.allClassURIs = allClassURIs;
|
|
10
|
+
exports.askName = askName;
|
|
11
|
+
exports.attachmentList = attachmentList;
|
|
12
|
+
exports.button = button;
|
|
13
|
+
exports.cancelButton = cancelButton;
|
|
14
|
+
exports.clearElement = clearElement;
|
|
15
|
+
exports.complain = complain;
|
|
16
|
+
exports.continueButton = continueButton;
|
|
17
|
+
exports.createLinkDiv = createLinkDiv;
|
|
18
|
+
exports.createNameDiv = createNameDiv;
|
|
19
|
+
exports.defaultAnnotationStore = defaultAnnotationStore;
|
|
20
|
+
exports.deleteButtonWithCheck = deleteButtonWithCheck;
|
|
21
|
+
exports.extractLogURI = extractLogURI;
|
|
22
|
+
exports.faviconOrDefault = faviconOrDefault;
|
|
23
|
+
exports.fileUploadButtonDiv = fileUploadButtonDiv;
|
|
24
|
+
exports.findImage = findImage;
|
|
25
|
+
exports.findImageFromURI = findImageFromURI;
|
|
26
|
+
exports.formatDateTime = formatDateTime;
|
|
27
|
+
exports.iconForClass = void 0;
|
|
28
|
+
exports.imagesOf = imagesOf;
|
|
29
|
+
exports.index = void 0;
|
|
30
|
+
exports.isAudio = isAudio;
|
|
31
|
+
exports.isImage = isImage;
|
|
32
|
+
exports.isVideo = isVideo;
|
|
33
|
+
exports.linkButton = linkButton;
|
|
34
|
+
exports.openHrefInOutlineMode = openHrefInOutlineMode;
|
|
35
|
+
exports.personTR = void 0;
|
|
36
|
+
exports.propertyTriage = propertyTriage;
|
|
37
|
+
exports.refreshTree = refreshTree;
|
|
38
|
+
exports.removeButton = removeButton;
|
|
39
|
+
exports.renderAsDiv = renderAsDiv;
|
|
40
|
+
exports.renderAsRow = renderAsRow;
|
|
41
|
+
exports.selectorPanel = selectorPanel;
|
|
42
|
+
exports.selectorPanelRefresh = selectorPanelRefresh;
|
|
43
|
+
exports.setImage = setImage;
|
|
44
|
+
exports.setName = setName;
|
|
45
|
+
exports.shortDate = shortDate;
|
|
46
|
+
exports.shortTime = shortTime;
|
|
47
|
+
exports.timestamp = timestamp;
|
|
48
|
+
|
|
49
|
+
var _rdflib = require("rdflib");
|
|
50
|
+
|
|
51
|
+
var _iconBase = require("../iconBase");
|
|
52
|
+
|
|
53
|
+
var ns = _interopRequireWildcard(require("../ns"));
|
|
54
|
+
|
|
55
|
+
var style = _interopRequireWildcard(require("../style"));
|
|
56
|
+
|
|
57
|
+
var debug = _interopRequireWildcard(require("../debug"));
|
|
58
|
+
|
|
59
|
+
var _log = require("../log");
|
|
60
|
+
|
|
61
|
+
var _jss = require("../jss");
|
|
62
|
+
|
|
63
|
+
var _dragAndDrop = require("./dragAndDrop");
|
|
64
|
+
|
|
65
|
+
var _logic = require("../logic");
|
|
66
|
+
|
|
67
|
+
var utils = _interopRequireWildcard(require("../utils"));
|
|
68
|
+
|
|
69
|
+
var _error = require("./error");
|
|
70
|
+
|
|
71
|
+
var _widgetHelpers = require("./widgetHelpers");
|
|
72
|
+
|
|
73
|
+
var _iconLinks = require("./buttons/iconLinks");
|
|
74
|
+
|
|
75
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
76
|
+
|
|
77
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
78
|
+
|
|
23
79
|
/* Buttons
|
|
24
80
|
*/
|
|
25
|
-
|
|
26
|
-
var iconBase_1 = require("../iconBase");
|
|
27
|
-
var ns = __importStar(require("../ns"));
|
|
28
|
-
var style = __importStar(require("../style"));
|
|
29
|
-
var debug = __importStar(require("../debug"));
|
|
30
|
-
var log_1 = require("../log");
|
|
31
|
-
var jss_1 = require("../jss");
|
|
32
|
-
var dragAndDrop_1 = require("./dragAndDrop");
|
|
33
|
-
var logic_1 = require("../logic");
|
|
34
|
-
var utils = __importStar(require("../utils"));
|
|
35
|
-
var error_1 = require("./error");
|
|
36
|
-
var widgetHelpers_1 = require("./widgetHelpers");
|
|
37
|
-
var iconLinks_1 = require("./buttons/iconLinks");
|
|
81
|
+
|
|
38
82
|
/**
|
|
39
83
|
* UI Widgets such as buttons
|
|
40
84
|
* @packageDocumentation
|
|
41
85
|
*/
|
|
86
|
+
|
|
42
87
|
/* global alert */
|
|
43
|
-
var iconBase =
|
|
88
|
+
var iconBase = _iconBase.icons.iconBase;
|
|
44
89
|
var cancelIconURI = iconBase + 'noun_1180156.svg'; // black X
|
|
90
|
+
|
|
45
91
|
var checkIconURI = iconBase + 'noun_1180158.svg'; // green checkmark; Continue
|
|
92
|
+
|
|
46
93
|
function getStatusArea(context) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
94
|
+
var box = context && context.statusArea || context && context.div || null;
|
|
95
|
+
if (box) return box;
|
|
96
|
+
var dom = context && context.dom;
|
|
97
|
+
|
|
98
|
+
if (!dom && typeof document !== 'undefined') {
|
|
99
|
+
dom = document;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (dom) {
|
|
103
|
+
var body = dom.getElementsByTagName('body')[0];
|
|
104
|
+
box = dom.createElement('div');
|
|
105
|
+
body.insertBefore(box, body.firstElementChild);
|
|
106
|
+
|
|
107
|
+
if (context) {
|
|
108
|
+
context.statusArea = box;
|
|
62
109
|
}
|
|
63
|
-
|
|
110
|
+
|
|
111
|
+
return box;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return null;
|
|
64
115
|
}
|
|
65
116
|
/**
|
|
66
117
|
* Display an error message block
|
|
67
118
|
*/
|
|
119
|
+
|
|
120
|
+
|
|
68
121
|
function complain(context, err) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
ele.appendChild((0, error_1.errorMessageBlock)((context && context.dom) || document, err));
|
|
75
|
-
else
|
|
76
|
-
alert(err);
|
|
122
|
+
if (!err) return; // only if error
|
|
123
|
+
|
|
124
|
+
var ele = getStatusArea(context);
|
|
125
|
+
debug.log('Complaint: ' + err);
|
|
126
|
+
if (ele) ele.appendChild((0, _error.errorMessageBlock)(context && context.dom || document, err));else alert(err);
|
|
77
127
|
}
|
|
78
|
-
exports.complain = complain;
|
|
79
128
|
/**
|
|
80
129
|
* Remove all the children of an HTML element
|
|
81
130
|
*/
|
|
131
|
+
|
|
132
|
+
|
|
82
133
|
function clearElement(ele) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
134
|
+
while (ele.firstChild) {
|
|
135
|
+
ele.removeChild(ele.firstChild);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return ele;
|
|
87
139
|
}
|
|
88
|
-
exports.clearElement = clearElement;
|
|
89
140
|
/**
|
|
90
141
|
* To figure out the log URI from the full URI used to invoke the reasoner
|
|
91
142
|
*/
|
|
143
|
+
|
|
144
|
+
|
|
92
145
|
function extractLogURI(fullURI) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
146
|
+
var logPos = fullURI.search(/logFile=/);
|
|
147
|
+
var rulPos = fullURI.search(/&rulesFile=/);
|
|
148
|
+
return fullURI.substring(logPos + 8, rulPos);
|
|
96
149
|
}
|
|
97
|
-
exports.extractLogURI = extractLogURI;
|
|
98
150
|
/**
|
|
99
151
|
* By default, converts e.g. '2020-02-19T19:35:28.557Z' to '19:35'
|
|
100
152
|
* if today is 19 Feb 2020, and to 'Feb 19' if not.
|
|
101
153
|
* @@@ TODO This needs to be changed to local time
|
|
102
154
|
* @param noTime Return a string like 'Feb 19' even if it's today.
|
|
103
155
|
*/
|
|
156
|
+
|
|
157
|
+
|
|
104
158
|
function shortDate(str, noTime) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
'Jul',
|
|
115
|
-
'Aug',
|
|
116
|
-
'Sep',
|
|
117
|
-
'Oct',
|
|
118
|
-
'Nov',
|
|
119
|
-
'Dec'
|
|
120
|
-
];
|
|
121
|
-
try {
|
|
122
|
-
var nowZ = new Date().toISOString();
|
|
123
|
-
// var nowZ = $rdf.term(now).value
|
|
124
|
-
// var n = now.getTimezoneOffset() // Minutes
|
|
125
|
-
if (str.slice(0, 10) === nowZ.slice(0, 10) && !noTime) {
|
|
126
|
-
return str.slice(11, 16);
|
|
127
|
-
}
|
|
128
|
-
if (str.slice(0, 4) === nowZ.slice(0, 4)) {
|
|
129
|
-
return (month[parseInt(str.slice(5, 7), 10) - 1] +
|
|
130
|
-
' ' +
|
|
131
|
-
parseInt(str.slice(8, 10), 10));
|
|
132
|
-
}
|
|
133
|
-
return str.slice(0, 10);
|
|
159
|
+
if (!str) return '???';
|
|
160
|
+
var month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
var nowZ = new Date().toISOString(); // var nowZ = $rdf.term(now).value
|
|
164
|
+
// var n = now.getTimezoneOffset() // Minutes
|
|
165
|
+
|
|
166
|
+
if (str.slice(0, 10) === nowZ.slice(0, 10) && !noTime) {
|
|
167
|
+
return str.slice(11, 16);
|
|
134
168
|
}
|
|
135
|
-
|
|
136
|
-
|
|
169
|
+
|
|
170
|
+
if (str.slice(0, 4) === nowZ.slice(0, 4)) {
|
|
171
|
+
return month[parseInt(str.slice(5, 7), 10) - 1] + ' ' + parseInt(str.slice(8, 10), 10);
|
|
137
172
|
}
|
|
173
|
+
|
|
174
|
+
return str.slice(0, 10);
|
|
175
|
+
} catch (e) {
|
|
176
|
+
return 'shortdate:' + e;
|
|
177
|
+
}
|
|
138
178
|
}
|
|
139
|
-
exports.shortDate = shortDate;
|
|
140
179
|
/**
|
|
141
180
|
* Format a date and time
|
|
142
181
|
* @param date for instance `new Date()`
|
|
143
182
|
* @param format for instance '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}'
|
|
144
183
|
* @returns for instance '2000-01-15T23:14:23.002'
|
|
145
184
|
*/
|
|
185
|
+
|
|
186
|
+
|
|
146
187
|
function formatDateTime(date, format) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
})
|
|
157
|
-
|
|
188
|
+
return format.split('{').map(function (s) {
|
|
189
|
+
var k = s.split('}')[0];
|
|
190
|
+
var width = {
|
|
191
|
+
Milliseconds: 3,
|
|
192
|
+
FullYear: 4
|
|
193
|
+
};
|
|
194
|
+
var d = {
|
|
195
|
+
Month: 1
|
|
196
|
+
};
|
|
197
|
+
return s ? ('000' + (date['get' + k]() + (d[k] || 0))).slice(-(width[k] || 2)) + s.split('}')[1] : '';
|
|
198
|
+
}).join('');
|
|
158
199
|
}
|
|
159
|
-
exports.formatDateTime = formatDateTime;
|
|
160
200
|
/**
|
|
161
201
|
* Get a string representation of the current time
|
|
162
202
|
* @returns for instance '2000-01-15T23:14:23.002'
|
|
163
203
|
*/
|
|
204
|
+
|
|
205
|
+
|
|
164
206
|
function timestamp() {
|
|
165
|
-
|
|
207
|
+
return formatDateTime(new Date(), '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
|
|
166
208
|
}
|
|
167
|
-
exports.timestamp = timestamp;
|
|
168
209
|
/**
|
|
169
210
|
* Get a short string representation of the current time
|
|
170
211
|
* @returns for instance '23:14:23.002'
|
|
171
212
|
*/
|
|
213
|
+
|
|
214
|
+
|
|
172
215
|
function shortTime() {
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// ///////////////////// Handy UX widgets
|
|
216
|
+
return formatDateTime(new Date(), '{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
|
|
217
|
+
} // ///////////////////// Handy UX widgets
|
|
218
|
+
|
|
177
219
|
/**
|
|
178
220
|
* Sets the best name we have and looks up a better one
|
|
179
221
|
*/
|
|
222
|
+
|
|
223
|
+
|
|
180
224
|
function setName(element, x) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
225
|
+
var kb = _logic.store;
|
|
226
|
+
|
|
227
|
+
var findName = function findName(x) {
|
|
228
|
+
var name = kb.any(x, ns.vcard('fn')) || kb.any(x, ns.foaf('name')) || kb.any(x, ns.vcard('organization-name'));
|
|
229
|
+
return name ? name.value : null;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
var name = x.sameTerm(ns.foaf('Agent')) ? 'Everyone' : findName(x);
|
|
233
|
+
element.textContent = name || utils.label(x);
|
|
234
|
+
|
|
235
|
+
if (!name && x.uri) {
|
|
236
|
+
if (!kb.fetcher) {
|
|
237
|
+
throw new Error('kb has no fetcher');
|
|
238
|
+
} // Note this is only a fetch, not a lookUP of all sameAs etc
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
kb.fetcher.nowOrWhenFetched(x.doc(), undefined, function (_ok) {
|
|
242
|
+
element.textContent = findName(x) || utils.label(x); // had: (ok ? '' : '? ') +
|
|
243
|
+
});
|
|
244
|
+
}
|
|
199
245
|
}
|
|
200
|
-
exports.setName = setName;
|
|
201
246
|
/**
|
|
202
247
|
* Set of suitable images
|
|
203
248
|
* See also [[findImage]]
|
|
@@ -215,97 +260,104 @@ exports.setName = setName;
|
|
|
215
260
|
* * ns.foaf('depiction')
|
|
216
261
|
|
|
217
262
|
*/
|
|
263
|
+
|
|
264
|
+
|
|
218
265
|
function imagesOf(x, kb) {
|
|
219
|
-
|
|
220
|
-
.each(x, ns.sioc('avatar'))
|
|
221
|
-
.concat(kb.each(x, ns.foaf('img')))
|
|
222
|
-
.concat(kb.each(x, ns.vcard('logo')))
|
|
223
|
-
.concat(kb.each(x, ns.vcard('hasPhoto')))
|
|
224
|
-
.concat(kb.each(x, ns.vcard('photo')))
|
|
225
|
-
.concat(kb.each(x, ns.foaf('depiction')));
|
|
266
|
+
return kb.each(x, ns.sioc('avatar')).concat(kb.each(x, ns.foaf('img'))).concat(kb.each(x, ns.vcard('logo'))).concat(kb.each(x, ns.vcard('hasPhoto'))).concat(kb.each(x, ns.vcard('photo'))).concat(kb.each(x, ns.foaf('depiction')));
|
|
226
267
|
}
|
|
227
|
-
exports.imagesOf = imagesOf;
|
|
228
268
|
/**
|
|
229
269
|
* Best logo or avatar or photo etc to represent someone or some group etc
|
|
230
270
|
*/
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
var iconForClass = {
|
|
274
|
+
// Potentially extendable by other apps, panes, etc
|
|
275
|
+
// Relative URIs to the iconBase
|
|
276
|
+
'solid:AppProviderClass': 'noun_144.svg',
|
|
277
|
+
// @@ classs name should not contain 'Class'
|
|
278
|
+
'solid:AppProvider': 'noun_15177.svg',
|
|
279
|
+
// @@
|
|
280
|
+
'solid:Pod': 'noun_Cabinet_1434380.svg',
|
|
281
|
+
'vcard:Group': 'noun_339237.svg',
|
|
282
|
+
'vcard:Organization': 'noun_143899.svg',
|
|
283
|
+
'vcard:Individual': 'noun_15059.svg',
|
|
284
|
+
'schema:Person': 'noun_15059.svg',
|
|
285
|
+
'foaf:Person': 'noun_15059.svg',
|
|
286
|
+
'foaf:Agent': 'noun_98053.svg',
|
|
287
|
+
'acl:AuthenticatedAgent': 'noun_99101.svg',
|
|
288
|
+
'prov:SoftwareAgent': 'noun_Robot_849764.svg',
|
|
289
|
+
// Bot
|
|
290
|
+
'vcard:AddressBook': 'noun_15695.svg',
|
|
291
|
+
'trip:Trip': 'noun_581629.svg',
|
|
292
|
+
'meeting:LongChat': 'noun_1689339.svg',
|
|
293
|
+
'meeting:Meeting': 'noun_66617.svg',
|
|
294
|
+
'meeting:Project': 'noun_1036577.svg',
|
|
295
|
+
'ui:Form': 'noun_122196.svg',
|
|
296
|
+
'rdfs:Class': 'class-rectangle.svg',
|
|
297
|
+
// For RDF developers
|
|
298
|
+
'rdf:Property': 'property-diamond.svg',
|
|
299
|
+
'owl:Ontology': 'noun_classification_1479198.svg',
|
|
300
|
+
'wf:Tracker': 'noun_122196.svg',
|
|
301
|
+
'wf:Task': 'noun_17020_gray-tick.svg',
|
|
302
|
+
'wf:Open': 'noun_17020_sans-tick.svg',
|
|
303
|
+
'wf:Closed': 'noun_17020.svg'
|
|
258
304
|
};
|
|
259
305
|
/**
|
|
260
306
|
* Returns the origin of the URI of a NamedNode
|
|
261
307
|
*/
|
|
308
|
+
|
|
309
|
+
exports.iconForClass = iconForClass;
|
|
310
|
+
|
|
262
311
|
function tempSite(x) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
312
|
+
// use only while one in rdflib fails with origins 2019
|
|
313
|
+
var str = x.uri.split('#')[0];
|
|
314
|
+
var p = str.indexOf('//');
|
|
315
|
+
if (p < 0) throw new Error('This URI does not have a web site part (origin)');
|
|
316
|
+
var q = str.indexOf('/', p + 2);
|
|
317
|
+
|
|
318
|
+
if (q < 0) {
|
|
319
|
+
// no third slash?
|
|
320
|
+
return str.slice(0) + '/'; // Add slash to a bare origin
|
|
321
|
+
} else {
|
|
322
|
+
return str.slice(0, q + 1);
|
|
323
|
+
}
|
|
276
324
|
}
|
|
277
325
|
/**
|
|
278
326
|
* Find an image for this thing as a class
|
|
279
327
|
*/
|
|
328
|
+
|
|
329
|
+
|
|
280
330
|
function findImageFromURI(x) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
return null;
|
|
331
|
+
var iconDir = iconBase; // Special cases from URI scheme:
|
|
332
|
+
|
|
333
|
+
if (typeof x !== 'string' && x.uri) {
|
|
334
|
+
if (x.uri.split('/').length === 4 && !x.uri.split('/')[1] && !x.uri.split('/')[3]) {
|
|
335
|
+
return iconDir + 'noun_15177.svg'; // App -- this is an origin
|
|
336
|
+
} // Non-HTTP URI types imply types
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
if (x.uri.startsWith('message:') || x.uri.startsWith('mid:')) {
|
|
340
|
+
// message: is apple bug-- should be mid:
|
|
341
|
+
return iconDir + 'noun_480183.svg'; // envelope noun_567486
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (x.uri.startsWith('mailto:')) {
|
|
345
|
+
return iconDir + 'noun_567486.svg'; // mailbox - an email desitination
|
|
346
|
+
} // For HTTP(s) documents, we could look at the MIME type if we know it.
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
if (x.uri.startsWith('https:') && x.uri.indexOf('#') < 0) {
|
|
350
|
+
return tempSite(x) + 'favicon.ico'; // was x.site().uri + ...
|
|
351
|
+
// Todo: make the document icon a fallback for if the favicon does not exist
|
|
352
|
+
// todo: pick up a possible favicon for the web page itself from a link
|
|
353
|
+
// was: return iconDir + 'noun_681601.svg' // document - under solid assumptions
|
|
305
354
|
}
|
|
306
|
-
|
|
355
|
+
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return iconDir + 'noun_10636_grey.svg'; // Grey Circle - some thing
|
|
307
360
|
}
|
|
308
|
-
exports.findImageFromURI = findImageFromURI;
|
|
309
361
|
/**
|
|
310
362
|
* Find something we have as explicit image data for the thing
|
|
311
363
|
* See also [[imagesOf]]
|
|
@@ -323,224 +375,260 @@ exports.findImageFromURI = findImageFromURI;
|
|
|
323
375
|
* * ns.vcard('photo')
|
|
324
376
|
* * ns.foaf('depiction')
|
|
325
377
|
*/
|
|
378
|
+
|
|
379
|
+
|
|
326
380
|
function findImage(thing) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
kb.any(thing, ns.vcard('photo')) ||
|
|
337
|
-
kb.any(thing, ns.foaf('depiction'));
|
|
338
|
-
return image ? image.uri : null;
|
|
381
|
+
var kb = _logic.store;
|
|
382
|
+
var iconDir = iconBase;
|
|
383
|
+
|
|
384
|
+
if (thing.sameTerm(ns.foaf('Agent')) || thing.sameTerm(ns.rdf('Resource'))) {
|
|
385
|
+
return iconDir + 'noun_98053.svg'; // Globe
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
var image = kb.any(thing, ns.sioc('avatar')) || kb.any(thing, ns.foaf('img')) || kb.any(thing, ns.vcard('logo')) || kb.any(thing, ns.vcard('hasPhoto')) || kb.any(thing, ns.vcard('photo')) || kb.any(thing, ns.foaf('depiction'));
|
|
389
|
+
return image ? image.uri : null;
|
|
339
390
|
}
|
|
340
|
-
exports.findImage = findImage;
|
|
341
391
|
/**
|
|
342
392
|
* Do the best you can with the data available
|
|
343
393
|
*
|
|
344
394
|
* @return {Boolean} Are we happy with this icon?
|
|
345
395
|
* Sets src AND STYLE of the image.
|
|
346
396
|
*/
|
|
397
|
+
|
|
398
|
+
|
|
347
399
|
function trySetImage(element, thing, iconForClassMap) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
400
|
+
var kb = _logic.store;
|
|
401
|
+
var explitImage = findImage(thing);
|
|
402
|
+
|
|
403
|
+
if (explitImage) {
|
|
404
|
+
element.setAttribute('src', explitImage);
|
|
405
|
+
return true;
|
|
406
|
+
} // This is one of the classes we know about - the class itself?
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
var typeIcon = iconForClassMap[thing.uri];
|
|
410
|
+
|
|
411
|
+
if (typeIcon) {
|
|
412
|
+
element.setAttribute('src', typeIcon);
|
|
413
|
+
element.style = style.classIconStyle; // element.style.border = '0.1em solid green;'
|
|
414
|
+
// element.style.backgroundColor = '#eeffee' // pale green
|
|
415
|
+
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
var schemeIcon = findImageFromURI(thing);
|
|
420
|
+
|
|
421
|
+
if (schemeIcon) {
|
|
422
|
+
element.setAttribute('src', schemeIcon);
|
|
423
|
+
return true; // happy with this -- don't look it up
|
|
424
|
+
} // Do we have a generic icon for something in any class its in?
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
var types = kb.findTypeURIs(thing);
|
|
428
|
+
|
|
429
|
+
for (var typeURI in types) {
|
|
430
|
+
if (iconForClassMap[typeURI]) {
|
|
431
|
+
element.setAttribute('src', iconForClassMap[typeURI]);
|
|
432
|
+
return false; // maybe we can do better
|
|
375
433
|
}
|
|
376
|
-
|
|
377
|
-
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
element.setAttribute('src', iconBase + 'noun_10636_grey.svg'); // Grey Circle - some thing
|
|
437
|
+
|
|
438
|
+
return false; // we can do better
|
|
378
439
|
}
|
|
379
440
|
/**
|
|
380
441
|
* ToDo: Also add icons for *properties* like home, work, email, range, domain, comment,
|
|
381
442
|
*/
|
|
443
|
+
|
|
444
|
+
|
|
382
445
|
function setImage(element, thing) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
400
|
-
});
|
|
446
|
+
// 20191230a
|
|
447
|
+
var kb = _logic.store;
|
|
448
|
+
var iconForClassMap = {};
|
|
449
|
+
|
|
450
|
+
for (var k in iconForClass) {
|
|
451
|
+
var pref = k.split(':')[0];
|
|
452
|
+
var id = k.split(':')[1];
|
|
453
|
+
var theClass = ns[pref](id);
|
|
454
|
+
iconForClassMap[theClass.uri] = _rdflib.uri.join(iconForClass[k], iconBase);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
var happy = trySetImage(element, thing, iconForClassMap);
|
|
458
|
+
|
|
459
|
+
if (!happy && thing.uri) {
|
|
460
|
+
if (!kb.fetcher) {
|
|
461
|
+
throw new Error('kb has no fetcher');
|
|
401
462
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
463
|
+
|
|
464
|
+
kb.fetcher.nowOrWhenFetched(thing.doc(), undefined, function (ok) {
|
|
465
|
+
if (ok) {
|
|
466
|
+
trySetImage(element, thing, iconForClassMap);
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
} // If a web page, then a favicon, with a fallback to ???
|
|
405
471
|
// See, e.g., http://stackoverflow.com/questions/980855/inputting-a-default-image
|
|
472
|
+
|
|
473
|
+
|
|
406
474
|
function faviconOrDefault(dom, x) {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
475
|
+
var image = dom.createElement('img');
|
|
476
|
+
image.style = style.iconStyle;
|
|
477
|
+
|
|
478
|
+
var isOrigin = function isOrigin(x) {
|
|
479
|
+
if (!x.uri) return false;
|
|
480
|
+
var parts = x.uri.split('/');
|
|
481
|
+
return parts.length === 3 || parts.length === 4 && parts[3] === '';
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
image.setAttribute('src', iconBase + (isOrigin(x) ? 'noun_15177.svg' : 'noun_681601.svg') // App symbol vs document
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
if (x.uri && x.uri.startsWith('https:') && x.uri.indexOf('#') < 0) {
|
|
488
|
+
var res = dom.createElement('object'); // favico with a fallback of a default image if no favicon
|
|
489
|
+
|
|
490
|
+
res.setAttribute('data', tempSite(x) + 'favicon.ico');
|
|
491
|
+
res.setAttribute('type', 'image/x-icon');
|
|
492
|
+
res.appendChild(image); // fallback
|
|
493
|
+
|
|
494
|
+
return res;
|
|
495
|
+
} else {
|
|
496
|
+
setImage(image, x);
|
|
497
|
+
return image;
|
|
498
|
+
}
|
|
428
499
|
}
|
|
429
|
-
exports.faviconOrDefault = faviconOrDefault;
|
|
430
500
|
/* Two-option dialog pop-up
|
|
431
501
|
*/
|
|
502
|
+
|
|
503
|
+
|
|
432
504
|
function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunction) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
505
|
+
function removePopup() {
|
|
506
|
+
refererenceElement.parentElement.removeChild(refererenceElement);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function removePopupAndDoDeletion() {
|
|
510
|
+
removePopup();
|
|
511
|
+
deleteFunction();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
var popup = dom.createElement('div');
|
|
515
|
+
popup.style = style.confirmPopupStyle;
|
|
516
|
+
popup.style.position = 'absolute';
|
|
517
|
+
popup.style.top = '-1em'; // try leaving original button clear
|
|
518
|
+
|
|
519
|
+
popup.style.display = 'grid';
|
|
520
|
+
popup.style.gridTemplateColumns = 'auto auto';
|
|
521
|
+
var affirm = dom.createElement('div');
|
|
522
|
+
affirm.style.gridColumn = '1/2';
|
|
523
|
+
affirm.style.gridRow = '1'; // @@ sigh; TS. could pass number in fact
|
|
524
|
+
|
|
525
|
+
var cancel = dom.createElement('div');
|
|
526
|
+
cancel.style.gridColumn = '1/2';
|
|
527
|
+
cancel.style.gridRow = '2';
|
|
528
|
+
var xButton = cancelButton(dom, removePopup);
|
|
529
|
+
popup.appendChild(xButton);
|
|
530
|
+
xButton.style.gridColumn = '1';
|
|
531
|
+
xButton.style.gridRow = '2';
|
|
532
|
+
var cancelPrompt = popup.appendChild(dom.createElement('button'));
|
|
533
|
+
cancelPrompt.style = style.buttonStyle;
|
|
534
|
+
cancelPrompt.style.gridRow = '2';
|
|
535
|
+
cancelPrompt.style.gridColumn = '2';
|
|
536
|
+
cancelPrompt.textContent = 'Cancel'; // @@ I18n
|
|
537
|
+
|
|
538
|
+
var affirmIcon = button(dom, _iconBase.icons.iconBase + 'noun_925021.svg', 'Delete it'); // trashcan
|
|
539
|
+
|
|
540
|
+
popup.appendChild(affirmIcon);
|
|
541
|
+
affirmIcon.style.gridRow = '1';
|
|
542
|
+
affirmIcon.style.gridColumn = '1';
|
|
543
|
+
var sureButtonElt = popup.appendChild(dom.createElement('button'));
|
|
544
|
+
sureButtonElt.style = style.buttonStyle;
|
|
545
|
+
sureButtonElt.style.gridRow = '1';
|
|
546
|
+
sureButtonElt.style.gridColumn = '2';
|
|
547
|
+
sureButtonElt.textContent = prompt;
|
|
548
|
+
popup.appendChild(sureButtonElt);
|
|
549
|
+
affirmIcon.addEventListener('click', removePopupAndDoDeletion);
|
|
550
|
+
sureButtonElt.addEventListener('click', removePopupAndDoDeletion); // xButton.addEventListener('click', removePopup)
|
|
551
|
+
|
|
552
|
+
cancelPrompt.addEventListener('click', removePopup);
|
|
553
|
+
return popup;
|
|
476
554
|
}
|
|
477
555
|
/**
|
|
478
556
|
* Delete button with a check you really mean it
|
|
479
557
|
* @@ Supress check if command key held down?
|
|
480
558
|
*/
|
|
559
|
+
|
|
560
|
+
|
|
481
561
|
function deleteButtonWithCheck(dom, container, noun, deleteFunction) {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
562
|
+
function createPopup() {
|
|
563
|
+
var refererenceElement = dom.createElement('div');
|
|
564
|
+
container.insertBefore(refererenceElement, deleteButton);
|
|
565
|
+
refererenceElement.style.position = 'relative'; // Needed as reference for popup
|
|
566
|
+
|
|
567
|
+
refererenceElement.appendChild(renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunction));
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
var minusIconURI = iconBase + 'noun_2188_red.svg'; // white minus in red #cc0000 circle
|
|
571
|
+
|
|
572
|
+
var deleteButton = dom.createElement('img');
|
|
573
|
+
deleteButton.setAttribute('src', minusIconURI);
|
|
574
|
+
deleteButton.setAttribute('style', style.smallButtonStyle); // @@tsc - would set deleteButton.style
|
|
575
|
+
|
|
576
|
+
deleteButton.style["float"] = 'right'; // Historically this has alwaus floated right
|
|
577
|
+
|
|
578
|
+
var prompt = 'Remove this ' + noun;
|
|
579
|
+
deleteButton.title = prompt; // @@ In an ideal world, make use of hover an accessibility option
|
|
580
|
+
|
|
581
|
+
deleteButton.classList.add('hoverControlHide');
|
|
582
|
+
deleteButton.addEventListener('click', createPopup);
|
|
583
|
+
container.classList.add('hoverControl');
|
|
584
|
+
container.appendChild(deleteButton);
|
|
585
|
+
deleteButton.setAttribute('data-testid', 'deleteButtonWithCheck');
|
|
586
|
+
return deleteButton; // or button div? caller may change size of image
|
|
502
587
|
}
|
|
503
|
-
exports.deleteButtonWithCheck = deleteButtonWithCheck;
|
|
504
588
|
/**
|
|
505
589
|
* Get the button style, based on options.
|
|
506
590
|
* See https://design.inrupt.com/atomic-core/?cat=Atoms#Buttons
|
|
507
591
|
*/
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
function getButtonStyle() {
|
|
595
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
596
|
+
// default to primary color
|
|
597
|
+
var color = options.buttonColor === 'Secondary' ? '#01c9ea' : '#7c4dff';
|
|
598
|
+
var backgroundColor = color;
|
|
599
|
+
var fontColor = '#ffffff';
|
|
600
|
+
var borderColor = color; // default to primary color
|
|
601
|
+
|
|
602
|
+
var hoverBackgroundColor = options.buttonColor === 'Secondary' ? '#37cde6' : '#9f7dff';
|
|
603
|
+
var hoverFontColor = fontColor;
|
|
604
|
+
|
|
605
|
+
if (options.needsBorder) {
|
|
606
|
+
backgroundColor = '#ffffff';
|
|
607
|
+
fontColor = color;
|
|
608
|
+
borderColor = color;
|
|
609
|
+
hoverBackgroundColor = color;
|
|
610
|
+
hoverFontColor = backgroundColor;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
return {
|
|
614
|
+
'background-color': "".concat(backgroundColor),
|
|
615
|
+
color: "".concat(fontColor),
|
|
616
|
+
'font-family': 'Raleway, Roboto, sans-serif',
|
|
617
|
+
'border-radius': '0.25em',
|
|
618
|
+
'border-color': "".concat(borderColor),
|
|
619
|
+
border: '1px solid',
|
|
620
|
+
cursor: 'pointer',
|
|
621
|
+
'font-size': '.8em',
|
|
622
|
+
'text-decoration': 'none',
|
|
623
|
+
padding: '0.5em 4em',
|
|
624
|
+
transition: '0.25s all ease-in-out',
|
|
625
|
+
outline: 'none',
|
|
626
|
+
'&:hover': {
|
|
627
|
+
'background-color': "".concat(hoverBackgroundColor),
|
|
628
|
+
color: "".concat(hoverFontColor),
|
|
629
|
+
transition: '0.25s all ease-in-out'
|
|
524
630
|
}
|
|
525
|
-
|
|
526
|
-
'background-color': "".concat(backgroundColor),
|
|
527
|
-
color: "".concat(fontColor),
|
|
528
|
-
'font-family': 'Raleway, Roboto, sans-serif',
|
|
529
|
-
'border-radius': '0.25em',
|
|
530
|
-
'border-color': "".concat(borderColor),
|
|
531
|
-
border: '1px solid',
|
|
532
|
-
cursor: 'pointer',
|
|
533
|
-
'font-size': '.8em',
|
|
534
|
-
'text-decoration': 'none',
|
|
535
|
-
padding: '0.5em 4em',
|
|
536
|
-
transition: '0.25s all ease-in-out',
|
|
537
|
-
outline: 'none',
|
|
538
|
-
'&:hover': {
|
|
539
|
-
'background-color': "".concat(hoverBackgroundColor),
|
|
540
|
-
color: "".concat(hoverFontColor),
|
|
541
|
-
transition: '0.25s all ease-in-out'
|
|
542
|
-
}
|
|
543
|
-
};
|
|
631
|
+
};
|
|
544
632
|
}
|
|
545
633
|
/* Make a button
|
|
546
634
|
*
|
|
@@ -551,32 +639,42 @@ function getButtonStyle(options) {
|
|
|
551
639
|
*
|
|
552
640
|
* @returns <dDomElement> - the button
|
|
553
641
|
*/
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
function button(dom, iconURI, text, handler) {
|
|
645
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
646
|
+
buttonColor: 'Primary',
|
|
647
|
+
needsBorder: false
|
|
648
|
+
};
|
|
649
|
+
var button = dom.createElement('button');
|
|
650
|
+
button.setAttribute('type', 'button'); // button.innerHTML = text // later, user preferences may make text preferred for some
|
|
651
|
+
|
|
652
|
+
if (iconURI) {
|
|
653
|
+
var img = button.appendChild(dom.createElement('img'));
|
|
654
|
+
img.setAttribute('src', iconURI);
|
|
655
|
+
img.setAttribute('style', 'width: 2em; height: 2em;'); // trial and error. 2em disappears
|
|
656
|
+
|
|
657
|
+
img.title = text;
|
|
658
|
+
button.setAttribute('style', style.buttonStyle);
|
|
659
|
+
} else {
|
|
660
|
+
button.textContent = text.toLocaleUpperCase();
|
|
661
|
+
|
|
662
|
+
var _style = getButtonStyle(options);
|
|
663
|
+
|
|
664
|
+
var _getClasses = (0, _jss.getClasses)(dom.head, {
|
|
665
|
+
textButton: _style
|
|
666
|
+
}),
|
|
667
|
+
classes = _getClasses.classes;
|
|
668
|
+
|
|
669
|
+
button.classList.add(classes.textButton);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
if (handler) {
|
|
673
|
+
button.addEventListener('click', handler, false);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
return button;
|
|
578
677
|
}
|
|
579
|
-
exports.button = button;
|
|
580
678
|
/* Make a cancel button
|
|
581
679
|
*
|
|
582
680
|
* @param dom - the DOM document object
|
|
@@ -584,10 +682,11 @@ exports.button = button;
|
|
|
584
682
|
*
|
|
585
683
|
* @returns <dDomElement> - the button
|
|
586
684
|
*/
|
|
685
|
+
|
|
686
|
+
|
|
587
687
|
function cancelButton(dom, handler) {
|
|
588
|
-
|
|
688
|
+
return button(dom, cancelIconURI, 'Cancel', handler);
|
|
589
689
|
}
|
|
590
|
-
exports.cancelButton = cancelButton;
|
|
591
690
|
/* Make a continue button
|
|
592
691
|
*
|
|
593
692
|
* @param dom - the DOM document object
|
|
@@ -595,374 +694,415 @@ exports.cancelButton = cancelButton;
|
|
|
595
694
|
*
|
|
596
695
|
* @returns <dDomElement> - the button
|
|
597
696
|
*/
|
|
697
|
+
|
|
698
|
+
|
|
598
699
|
function continueButton(dom, handler) {
|
|
599
|
-
|
|
700
|
+
return button(dom, checkIconURI, 'Continue', handler);
|
|
600
701
|
}
|
|
601
|
-
exports.continueButton = continueButton;
|
|
602
702
|
/* Grab a name for a new thing
|
|
603
703
|
*
|
|
604
704
|
* Form to get the name of a new thing before we create it
|
|
605
705
|
* @params theClass Misspelt to avoid clashing with the JavaScript keyword
|
|
606
706
|
* @returns: a promise of (a name or null if cancelled)
|
|
607
707
|
*/
|
|
708
|
+
|
|
709
|
+
|
|
608
710
|
function askName(dom, kb, container, predicate, theClass, noun) {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
711
|
+
// eslint-disable-next-line promise/param-names
|
|
712
|
+
return new Promise(function (resolve, _reject) {
|
|
713
|
+
var form = dom.createElement('div'); // form is broken as HTML behaviour can resurface on js error
|
|
714
|
+
// classLabel = utils.label(ns.vcard('Individual'))
|
|
715
|
+
|
|
716
|
+
predicate = predicate || ns.foaf('name'); // eg 'name' in user's language
|
|
717
|
+
|
|
718
|
+
noun = noun || (theClass ? utils.label(theClass) : ' '); // eg 'folder' in users's language
|
|
719
|
+
|
|
720
|
+
var prompt = noun + ' ' + utils.label(predicate) + ': ';
|
|
721
|
+
form.appendChild(dom.createElement('p')).textContent = prompt;
|
|
722
|
+
var namefield = dom.createElement('input');
|
|
723
|
+
namefield.setAttribute('type', 'text');
|
|
724
|
+
namefield.setAttribute('size', '100');
|
|
725
|
+
namefield.setAttribute('maxLength', '2048'); // No arbitrary limits
|
|
726
|
+
|
|
727
|
+
namefield.setAttribute('style', style.textInputStyle);
|
|
728
|
+
namefield.select(); // focus next user input
|
|
729
|
+
|
|
730
|
+
form.appendChild(namefield);
|
|
731
|
+
container.appendChild(form); // namefield.focus()
|
|
732
|
+
|
|
733
|
+
function gotName() {
|
|
734
|
+
form.parentNode.removeChild(form);
|
|
735
|
+
resolve(namefield.value.trim());
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
namefield.addEventListener('keyup', function (e) {
|
|
739
|
+
if (e.keyCode === 13) {
|
|
740
|
+
gotName();
|
|
741
|
+
}
|
|
742
|
+
}, false);
|
|
743
|
+
form.appendChild(dom.createElement('br'));
|
|
744
|
+
form.appendChild(cancelButton(dom, function (_event) {
|
|
745
|
+
form.parentNode.removeChild(form);
|
|
746
|
+
resolve(null);
|
|
747
|
+
}));
|
|
748
|
+
form.appendChild(continueButton(dom, function (_event) {
|
|
749
|
+
gotName();
|
|
750
|
+
}));
|
|
751
|
+
namefield.focus();
|
|
752
|
+
}); // Promise
|
|
645
753
|
}
|
|
646
|
-
exports.askName = askName;
|
|
647
754
|
/**
|
|
648
755
|
* A TR to represent a draggable person, etc in a list
|
|
649
756
|
*
|
|
650
757
|
* pred is unused param at the moment
|
|
651
758
|
*/
|
|
652
|
-
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
var personTR = renderAsRow; // The legacy name is used in a lot of places
|
|
762
|
+
|
|
763
|
+
exports.personTR = personTR;
|
|
764
|
+
|
|
653
765
|
function renderAsRow(dom, pred, obj, options) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
766
|
+
var tr = dom.createElement('tr');
|
|
767
|
+
options = options || {}; // tr.predObj = [pred.uri, obj.uri] moved to acl-control
|
|
768
|
+
|
|
769
|
+
var td1 = tr.appendChild(dom.createElement('td'));
|
|
770
|
+
var td2 = tr.appendChild(dom.createElement('td'));
|
|
771
|
+
var td3 = tr.appendChild(dom.createElement('td')); // const image = td1.appendChild(dom.createElement('img'))
|
|
772
|
+
|
|
773
|
+
var image = options.image || faviconOrDefault(dom, obj);
|
|
774
|
+
td1.setAttribute('style', 'vertical-align: middle; width:2.5em; padding:0.5em; height: 2.5em;');
|
|
775
|
+
td2.setAttribute('style', 'vertical-align: middle; text-align:left;');
|
|
776
|
+
td3.setAttribute('style', 'vertical-align: middle; width:2em; padding:0.5em; height: 4em;');
|
|
777
|
+
td1.appendChild(image);
|
|
778
|
+
|
|
779
|
+
if (options.title) {
|
|
780
|
+
td2.textContent = options.title;
|
|
781
|
+
} else {
|
|
782
|
+
setName(td2, obj); // This is async
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
if (options.deleteFunction) {
|
|
786
|
+
deleteButtonWithCheck(dom, td3, options.noun || 'one', options.deleteFunction);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
if (obj.uri) {
|
|
790
|
+
// blank nodes need not apply
|
|
791
|
+
if (options.link !== false) {
|
|
792
|
+
var anchor = td3.appendChild((0, _iconLinks.linkIcon)(dom, obj));
|
|
793
|
+
anchor.classList.add('HoverControlHide');
|
|
794
|
+
td3.appendChild(dom.createElement('br'));
|
|
674
795
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}
|
|
682
|
-
if (options.draggable !== false) {
|
|
683
|
-
// default is on
|
|
684
|
-
image.setAttribute('draggable', 'false'); // Stop the image being dragged instead - just the TR
|
|
685
|
-
(0, dragAndDrop_1.makeDraggable)(tr, obj);
|
|
686
|
-
}
|
|
796
|
+
|
|
797
|
+
if (options.draggable !== false) {
|
|
798
|
+
// default is on
|
|
799
|
+
image.setAttribute('draggable', 'false'); // Stop the image being dragged instead - just the TR
|
|
800
|
+
|
|
801
|
+
(0, _dragAndDrop.makeDraggable)(tr, obj);
|
|
687
802
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
;
|
|
806
|
+
tr.subject = obj;
|
|
807
|
+
return tr;
|
|
691
808
|
}
|
|
692
|
-
exports.renderAsRow = renderAsRow;
|
|
693
809
|
/* A helper function for renderAsDiv
|
|
694
810
|
* creates the NameDiv for the person
|
|
695
811
|
* Note: could not move it to the helper file because they call exported functions
|
|
696
812
|
* from buttons
|
|
697
813
|
* @internal exporting this only for unit tests
|
|
698
814
|
*/
|
|
815
|
+
|
|
816
|
+
|
|
699
817
|
function createNameDiv(dom, div, title, obj) {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
818
|
+
var nameDiv = div.appendChild(dom.createElement('div'));
|
|
819
|
+
|
|
820
|
+
if (title) {
|
|
821
|
+
nameDiv.textContent = title;
|
|
822
|
+
} else {
|
|
823
|
+
setName(nameDiv, obj); // This is async
|
|
824
|
+
}
|
|
707
825
|
}
|
|
708
|
-
exports.createNameDiv = createNameDiv;
|
|
709
826
|
/* A helper function for renderAsDiv
|
|
710
827
|
* creates the linkDiv for the person
|
|
711
828
|
* Note: could not move it to the helper file because they call exported functions
|
|
712
829
|
* from buttons
|
|
713
830
|
* @internal exporting this only for unit tests
|
|
714
831
|
*/
|
|
832
|
+
|
|
833
|
+
|
|
715
834
|
function createLinkDiv(dom, div, obj, options) {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
835
|
+
var linkDiv = div.appendChild(dom.createElement('div'));
|
|
836
|
+
linkDiv.setAttribute('style', style.linkDivStyle);
|
|
837
|
+
|
|
838
|
+
if (options.deleteFunction) {
|
|
839
|
+
deleteButtonWithCheck(dom, linkDiv, options.noun || 'one', options.deleteFunction);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
if (obj.uri) {
|
|
843
|
+
// blank nodes need not apply
|
|
844
|
+
if (options.link !== false) {
|
|
845
|
+
(0, _iconLinks.createLinkForURI)(dom, linkDiv, obj);
|
|
727
846
|
}
|
|
847
|
+
|
|
848
|
+
(0, _dragAndDrop.makeDraggable)(div, obj);
|
|
849
|
+
}
|
|
728
850
|
}
|
|
729
|
-
exports.createLinkDiv = createLinkDiv;
|
|
730
851
|
/**
|
|
731
852
|
* A Div to represent a draggable person, etc in a list
|
|
732
853
|
* configurable to add an onClick listener
|
|
733
854
|
*/
|
|
855
|
+
|
|
856
|
+
|
|
734
857
|
function renderAsDiv(dom, obj, options) {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
return
|
|
858
|
+
var div = dom.createElement('div');
|
|
859
|
+
div.setAttribute('style', style.renderAsDivStyle);
|
|
860
|
+
options = options || {};
|
|
861
|
+
var image = options.image || faviconOrDefault(dom, obj);
|
|
862
|
+
(0, _widgetHelpers.createImageDiv)(dom, div, image);
|
|
863
|
+
createNameDiv(dom, div, options.title, obj);
|
|
864
|
+
createLinkDiv(dom, div, obj, options);
|
|
865
|
+
|
|
866
|
+
if (options.clickable && options.onClickFunction) {
|
|
867
|
+
(0, _widgetHelpers.addClickListenerToElement)(div, options.onClickFunction);
|
|
868
|
+
} // to be compatible with the SolidOS table layout
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
if (options.wrapInATR) {
|
|
872
|
+
var tr = (0, _widgetHelpers.wrapDivInATR)(dom, div, obj);
|
|
873
|
+
return tr;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
return div;
|
|
751
877
|
}
|
|
752
|
-
exports.renderAsDiv = renderAsDiv;
|
|
753
878
|
/**
|
|
754
879
|
* Refresh a DOM tree recursively
|
|
755
880
|
*/
|
|
881
|
+
|
|
882
|
+
|
|
756
883
|
function refreshTree(root) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
884
|
+
if (root.refresh) {
|
|
885
|
+
root.refresh();
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
for (var i = 0; i < root.children.length; i++) {
|
|
890
|
+
refreshTree(root.children[i]);
|
|
891
|
+
}
|
|
764
892
|
}
|
|
765
|
-
|
|
893
|
+
/**
|
|
894
|
+
* Options argument for [[attachmentList]] function
|
|
895
|
+
*/
|
|
896
|
+
|
|
897
|
+
|
|
766
898
|
/**
|
|
767
899
|
* Component that displays a list of resources, for instance
|
|
768
900
|
* the attachments of a message, or the various documents related
|
|
769
901
|
* to a meeting.
|
|
770
902
|
* Accepts dropping URLs onto it to add attachments to it.
|
|
771
903
|
*/
|
|
772
|
-
function attachmentList(dom, subject, div
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
kb.updater.update((0, rdflib_1.st)(subject, predicate, target, doc), [], function (uri, ok, errorBody, _xhr) {
|
|
780
|
-
if (ok) {
|
|
781
|
-
refresh();
|
|
782
|
-
}
|
|
783
|
-
else {
|
|
784
|
-
complain(undefined, 'Error deleting one: ' + errorBody);
|
|
785
|
-
}
|
|
786
|
-
});
|
|
787
|
-
};
|
|
788
|
-
function createNewRow(target) {
|
|
789
|
-
var theTarget = target;
|
|
790
|
-
var opt = { noun: noun };
|
|
791
|
-
if (modify) {
|
|
792
|
-
opt.deleteFunction = function () {
|
|
793
|
-
deleteAttachment(theTarget);
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
return (0, exports.personTR)(dom, predicate, target, opt);
|
|
904
|
+
function attachmentList(dom, subject, div) {
|
|
905
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
906
|
+
|
|
907
|
+
// options = options || {}
|
|
908
|
+
var deleteAttachment = function deleteAttachment(target) {
|
|
909
|
+
if (!kb.updater) {
|
|
910
|
+
throw new Error('kb has no updater');
|
|
797
911
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
912
|
+
|
|
913
|
+
kb.updater.update((0, _rdflib.st)(subject, predicate, target, doc), [], function (uri, ok, errorBody, _xhr) {
|
|
914
|
+
if (ok) {
|
|
915
|
+
refresh();
|
|
916
|
+
} else {
|
|
917
|
+
complain(undefined, 'Error deleting one: ' + errorBody);
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
function createNewRow(target) {
|
|
923
|
+
var theTarget = target;
|
|
924
|
+
var opt = {
|
|
925
|
+
noun: noun
|
|
802
926
|
};
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
ins.push((0, rdflib_1.st)(subject, predicate, target, doc));
|
|
809
|
-
});
|
|
810
|
-
if (!kb.updater) {
|
|
811
|
-
throw new Error('kb has no updater');
|
|
812
|
-
}
|
|
813
|
-
kb.updater.update([], ins, function (uri, ok, errorBody, _xhr) {
|
|
814
|
-
if (ok) {
|
|
815
|
-
refresh();
|
|
816
|
-
}
|
|
817
|
-
else {
|
|
818
|
-
complain(undefined, 'Error adding one: ' + errorBody);
|
|
819
|
-
}
|
|
820
|
-
});
|
|
927
|
+
|
|
928
|
+
if (modify) {
|
|
929
|
+
opt.deleteFunction = function () {
|
|
930
|
+
deleteAttachment(theTarget);
|
|
931
|
+
};
|
|
821
932
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
933
|
+
|
|
934
|
+
return personTR(dom, predicate, target, opt);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
var refresh = function refresh() {
|
|
938
|
+
var things = kb.each(subject, predicate);
|
|
939
|
+
things.sort();
|
|
940
|
+
utils.syncTableToArray(attachmentTable, things, createNewRow);
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
function droppedURIHandler(uris) {
|
|
944
|
+
var ins = [];
|
|
945
|
+
uris.forEach(function (u) {
|
|
946
|
+
var target = (0, _rdflib.sym)(u); // Attachment needs text label to disinguish I think not icon.
|
|
947
|
+
|
|
948
|
+
debug.log('Dropped on attachemnt ' + u); // icon was: iconBase + 'noun_25830.svg'
|
|
949
|
+
|
|
950
|
+
ins.push((0, _rdflib.st)(subject, predicate, target, doc));
|
|
951
|
+
});
|
|
952
|
+
|
|
953
|
+
if (!kb.updater) {
|
|
954
|
+
throw new Error('kb has no updater');
|
|
840
955
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
var
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
(0, dragAndDrop_1.makeDropTarget)(attachmentLeft, droppedURIHandler, fhandler); // just the outer won't do it
|
|
869
|
-
if (options.uploadFolder) { // Addd an explicit file upload button as well
|
|
870
|
-
var buttonDiv = fileUploadButtonDiv(dom, droppedFileHandler);
|
|
871
|
-
attachmentLeft.appendChild(buttonDiv);
|
|
872
|
-
// buttonDiv.children[1].style = buttonStyle
|
|
956
|
+
|
|
957
|
+
kb.updater.update([], ins, function (uri, ok, errorBody, _xhr) {
|
|
958
|
+
if (ok) {
|
|
959
|
+
refresh();
|
|
960
|
+
} else {
|
|
961
|
+
complain(undefined, 'Error adding one: ' + errorBody);
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
function droppedFileHandler(files) {
|
|
967
|
+
var _options$uploadFolder, _options$uploadFolder2;
|
|
968
|
+
|
|
969
|
+
(0, _dragAndDrop.uploadFiles)(kb.fetcher, files, (_options$uploadFolder = options.uploadFolder) === null || _options$uploadFolder === void 0 ? void 0 : _options$uploadFolder.uri, // Files
|
|
970
|
+
(_options$uploadFolder2 = options.uploadFolder) === null || _options$uploadFolder2 === void 0 ? void 0 : _options$uploadFolder2.uri, // Pictures
|
|
971
|
+
function (theFile, destURI) {
|
|
972
|
+
var ins = [(0, _rdflib.st)(subject, predicate, kb.sym(destURI), doc)];
|
|
973
|
+
|
|
974
|
+
if (!kb.updater) {
|
|
975
|
+
throw new Error('kb has no updater');
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
kb.updater.update([], ins, function (uri, ok, errorBody, _xhr) {
|
|
979
|
+
if (ok) {
|
|
980
|
+
refresh();
|
|
981
|
+
} else {
|
|
982
|
+
complain(undefined, 'Error adding link to uploaded file: ' + errorBody);
|
|
873
983
|
}
|
|
984
|
+
});
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
var doc = options.doc || subject.doc();
|
|
989
|
+
if (options.modify === undefined) options.modify = true;
|
|
990
|
+
var modify = options.modify;
|
|
991
|
+
var promptIcon = options.promptIcon || iconBase + 'noun_748003.svg'; // target
|
|
992
|
+
// const promptIcon = options.promptIcon || (iconBase + 'noun_25830.svg') // paperclip
|
|
993
|
+
|
|
994
|
+
var predicate = options.predicate || ns.wf('attachment');
|
|
995
|
+
var noun = options.noun || 'attachment';
|
|
996
|
+
var kb = _logic.store;
|
|
997
|
+
var attachmentOuter = div.appendChild(dom.createElement('table'));
|
|
998
|
+
attachmentOuter.setAttribute('style', 'margin-top: 1em; margin-bottom: 1em;');
|
|
999
|
+
var attachmentOne = attachmentOuter.appendChild(dom.createElement('tr'));
|
|
1000
|
+
var attachmentLeft = attachmentOne.appendChild(dom.createElement('td'));
|
|
1001
|
+
var attachmentRight = attachmentOne.appendChild(dom.createElement('td'));
|
|
1002
|
+
var attachmentTable = attachmentRight.appendChild(dom.createElement('table'));
|
|
1003
|
+
attachmentTable.appendChild(dom.createElement('tr')) // attachmentTableTop
|
|
1004
|
+
;
|
|
1005
|
+
attachmentOuter.refresh = refresh; // Participate in downstream changes
|
|
1006
|
+
// ;(attachmentTable as any).refresh = refresh <- outer should be best?
|
|
1007
|
+
|
|
1008
|
+
refresh();
|
|
1009
|
+
|
|
1010
|
+
if (modify) {
|
|
1011
|
+
// const buttonStyle = 'width; 2em; height: 2em; margin: 0.5em; padding: 0.1em;'
|
|
1012
|
+
var paperclip = button(dom, promptIcon, 'Drop attachments here'); // paperclip.style = buttonStyle // @@ needed? default has white background
|
|
1013
|
+
|
|
1014
|
+
attachmentLeft.appendChild(paperclip);
|
|
1015
|
+
var fhandler = options.uploadFolder ? droppedFileHandler : null;
|
|
1016
|
+
(0, _dragAndDrop.makeDropTarget)(paperclip, droppedURIHandler, fhandler); // beware missing the wire of the paparclip!
|
|
1017
|
+
|
|
1018
|
+
(0, _dragAndDrop.makeDropTarget)(attachmentLeft, droppedURIHandler, fhandler); // just the outer won't do it
|
|
1019
|
+
|
|
1020
|
+
if (options.uploadFolder) {
|
|
1021
|
+
// Addd an explicit file upload button as well
|
|
1022
|
+
var buttonDiv = fileUploadButtonDiv(dom, droppedFileHandler);
|
|
1023
|
+
attachmentLeft.appendChild(buttonDiv); // buttonDiv.children[1].style = buttonStyle
|
|
874
1024
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
// /////////////////////////////////////////////////////////////////////////////
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
return attachmentOuter;
|
|
1028
|
+
} // /////////////////////////////////////////////////////////////////////////////
|
|
1029
|
+
|
|
879
1030
|
/**
|
|
880
1031
|
* Event Handler for links within solid apps.
|
|
881
1032
|
*
|
|
882
1033
|
* Note that native links have constraints in Firefox, they
|
|
883
1034
|
* don't work with local files for instance (2011)
|
|
884
1035
|
*/
|
|
1036
|
+
|
|
1037
|
+
|
|
885
1038
|
function openHrefInOutlineMode(e) {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
else {
|
|
906
|
-
debug.log('ERROR: Can\'t access outline manager in this config');
|
|
907
|
-
}
|
|
908
|
-
// dom.outlineManager.GotoSubject(store.sym(uri), true, undefined, true, undefined)
|
|
1039
|
+
e.preventDefault();
|
|
1040
|
+
e.stopPropagation();
|
|
1041
|
+
var target = utils.getTarget(e);
|
|
1042
|
+
var uri = target.getAttribute('href');
|
|
1043
|
+
if (!uri) return debug.log('openHrefInOutlineMode: No href found!\n');
|
|
1044
|
+
var dom = window.document;
|
|
1045
|
+
|
|
1046
|
+
if (dom.outlineManager) {
|
|
1047
|
+
// @@ TODO Remove the use of document as a global object
|
|
1048
|
+
;
|
|
1049
|
+
dom.outlineManager.GotoSubject(_logic.store.sym(uri), true, undefined, true, undefined);
|
|
1050
|
+
} else if (window && window.panes && window.panes.getOutliner) {
|
|
1051
|
+
// @@ TODO Remove the use of window as a global object
|
|
1052
|
+
;
|
|
1053
|
+
window.panes.getOutliner().GotoSubject(_logic.store.sym(uri), true, undefined, true, undefined);
|
|
1054
|
+
} else {
|
|
1055
|
+
debug.log('ERROR: Can\'t access outline manager in this config');
|
|
1056
|
+
} // dom.outlineManager.GotoSubject(store.sym(uri), true, undefined, true, undefined)
|
|
1057
|
+
|
|
909
1058
|
}
|
|
910
|
-
exports.openHrefInOutlineMode = openHrefInOutlineMode;
|
|
911
1059
|
/**
|
|
912
1060
|
* Make a URI in the Tabulator.org annotation store out of the URI of the thing to be annotated.
|
|
913
1061
|
*
|
|
914
1062
|
* @@ Todo: make it a personal preference.
|
|
915
1063
|
*/
|
|
1064
|
+
|
|
1065
|
+
|
|
916
1066
|
function defaultAnnotationStore(subject) {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
return undefined;
|
|
931
|
-
s = s.slice(0, slash);
|
|
932
|
-
}
|
|
933
|
-
return logic_1.store.sym('http://tabulator.org/wiki/annnotation/' + s);
|
|
1067
|
+
if (subject.uri === undefined) return undefined;
|
|
1068
|
+
var s = subject.uri;
|
|
1069
|
+
if (s.slice(0, 7) !== 'http://') return undefined;
|
|
1070
|
+
s = s.slice(7); // Remove
|
|
1071
|
+
|
|
1072
|
+
var hash = s.indexOf('#');
|
|
1073
|
+
if (hash >= 0) s = s.slice(0, hash); // Strip trailing
|
|
1074
|
+
else {
|
|
1075
|
+
var slash = s.lastIndexOf('/');
|
|
1076
|
+
if (slash < 0) return undefined;
|
|
1077
|
+
s = s.slice(0, slash);
|
|
1078
|
+
}
|
|
1079
|
+
return _logic.store.sym('http://tabulator.org/wiki/annnotation/' + s);
|
|
934
1080
|
}
|
|
935
|
-
exports.defaultAnnotationStore = defaultAnnotationStore;
|
|
936
1081
|
/**
|
|
937
1082
|
* Retrieve all RDF class URIs from solid-ui's RDF store
|
|
938
1083
|
* @returns an object `ret` such that `Object.keys(ret)` is
|
|
939
1084
|
* the list of all class URIs.
|
|
940
1085
|
*/
|
|
1086
|
+
|
|
1087
|
+
|
|
941
1088
|
function allClassURIs() {
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
.each(undefined, ns.rdf('type'), ns.rdfs('Class'))
|
|
959
|
-
.forEach(function (c) {
|
|
960
|
-
if (c.value)
|
|
961
|
-
set[c.value] = true;
|
|
962
|
-
});
|
|
963
|
-
return set;
|
|
1089
|
+
var set = {};
|
|
1090
|
+
|
|
1091
|
+
_logic.store.statementsMatching(undefined, ns.rdf('type'), undefined).forEach(function (st) {
|
|
1092
|
+
if (st.object.value) set[st.object.value] = true;
|
|
1093
|
+
});
|
|
1094
|
+
|
|
1095
|
+
_logic.store.statementsMatching(undefined, ns.rdfs('subClassOf'), undefined).forEach(function (st) {
|
|
1096
|
+
if (st.object.value) set[st.object.value] = true;
|
|
1097
|
+
if (st.subject.value) set[st.subject.value] = true;
|
|
1098
|
+
});
|
|
1099
|
+
|
|
1100
|
+
_logic.store.each(undefined, ns.rdf('type'), ns.rdfs('Class')).forEach(function (c) {
|
|
1101
|
+
if (c.value) set[c.value] = true;
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
return set;
|
|
964
1105
|
}
|
|
965
|
-
exports.allClassURIs = allClassURIs;
|
|
966
1106
|
/**
|
|
967
1107
|
* Figuring which properties we know about
|
|
968
1108
|
*
|
|
@@ -974,75 +1114,85 @@ exports.allClassURIs = allClassURIs;
|
|
|
974
1114
|
* TODO: move to diff module? Not really a button.
|
|
975
1115
|
* @param {Store} kb The quadstore to be searched.
|
|
976
1116
|
*/
|
|
1117
|
+
|
|
1118
|
+
|
|
977
1119
|
function propertyTriage(kb) {
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
} // If nothing discovered, then could be either:
|
|
998
|
-
var ps = kb.each(undefined, ns.rdf('type'), ns.rdf('Property'));
|
|
999
|
-
for (var i = 0; i < ps.length; i++) {
|
|
1000
|
-
var p = ps[i].toNT();
|
|
1001
|
-
if (!op[p] && !dp[p]) {
|
|
1002
|
-
dp[p] = true;
|
|
1003
|
-
op[p] = true;
|
|
1004
|
-
nu++;
|
|
1005
|
-
}
|
|
1120
|
+
var possibleProperties = {}; // if (possibleProperties === undefined) possibleProperties = {}
|
|
1121
|
+
// const kb = store
|
|
1122
|
+
|
|
1123
|
+
var dp = {};
|
|
1124
|
+
var op = {};
|
|
1125
|
+
var no = 0;
|
|
1126
|
+
var nd = 0;
|
|
1127
|
+
var nu = 0;
|
|
1128
|
+
var pi = kb.predicateIndex; // One entry for each pred
|
|
1129
|
+
|
|
1130
|
+
for (var p in pi) {
|
|
1131
|
+
var object = pi[p][0].object;
|
|
1132
|
+
|
|
1133
|
+
if (object.termType === 'Literal') {
|
|
1134
|
+
dp[p] = true;
|
|
1135
|
+
nd++;
|
|
1136
|
+
} else {
|
|
1137
|
+
op[p] = true;
|
|
1138
|
+
no++;
|
|
1006
1139
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1140
|
+
} // If nothing discovered, then could be either:
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
var ps = kb.each(undefined, ns.rdf('type'), ns.rdf('Property'));
|
|
1144
|
+
|
|
1145
|
+
for (var i = 0; i < ps.length; i++) {
|
|
1146
|
+
var _p = ps[i].toNT();
|
|
1147
|
+
|
|
1148
|
+
if (!op[_p] && !dp[_p]) {
|
|
1149
|
+
dp[_p] = true;
|
|
1150
|
+
op[_p] = true;
|
|
1151
|
+
nu++;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
possibleProperties.op = op;
|
|
1156
|
+
possibleProperties.dp = dp;
|
|
1157
|
+
(0, _log.info)("propertyTriage: ".concat(no, " non-lit, ").concat(nd, " literal. ").concat(nu, " unknown."));
|
|
1158
|
+
return possibleProperties;
|
|
1011
1159
|
}
|
|
1012
|
-
exports.propertyTriage = propertyTriage;
|
|
1013
1160
|
/**
|
|
1014
1161
|
* General purpose widgets
|
|
1015
1162
|
*/
|
|
1163
|
+
|
|
1016
1164
|
/**
|
|
1017
1165
|
* A button for jumping
|
|
1018
1166
|
*/
|
|
1167
|
+
|
|
1168
|
+
|
|
1019
1169
|
function linkButton(dom, object) {
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1170
|
+
var b = dom.createElement('button');
|
|
1171
|
+
b.setAttribute('type', 'button');
|
|
1172
|
+
b.textContent = 'Goto ' + utils.label(object);
|
|
1173
|
+
b.addEventListener('click', function (_event) {
|
|
1174
|
+
// b.parentNode.removeChild(b)
|
|
1175
|
+
;
|
|
1176
|
+
dom.outlineManager.GotoSubject(object, true, undefined, true, undefined);
|
|
1177
|
+
}, true);
|
|
1178
|
+
return b;
|
|
1029
1179
|
}
|
|
1030
|
-
exports.linkButton = linkButton;
|
|
1031
1180
|
/**
|
|
1032
1181
|
* A button to remove some other element from the page
|
|
1033
1182
|
*/
|
|
1183
|
+
|
|
1184
|
+
|
|
1034
1185
|
function removeButton(dom, element) {
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
// Description text area
|
|
1186
|
+
var b = dom.createElement('button');
|
|
1187
|
+
b.setAttribute('type', 'button');
|
|
1188
|
+
b.textContent = '✕'; // MULTIPLICATION X
|
|
1189
|
+
|
|
1190
|
+
b.addEventListener('click', function (_event) {
|
|
1191
|
+
;
|
|
1192
|
+
element.parentNode.removeChild(element);
|
|
1193
|
+
}, true);
|
|
1194
|
+
return b;
|
|
1195
|
+
} // Description text area
|
|
1046
1196
|
//
|
|
1047
1197
|
// Make a box to demand a description or display existing one
|
|
1048
1198
|
//
|
|
@@ -1057,6 +1207,7 @@ exports.removeButton = removeButton;
|
|
|
1057
1207
|
//
|
|
1058
1208
|
// These are for selecting different modes, sources,styles, etc.
|
|
1059
1209
|
//
|
|
1210
|
+
|
|
1060
1211
|
/*
|
|
1061
1212
|
buttons.headerButtons = function (dom, kb, name, words) {
|
|
1062
1213
|
const box = dom.createElement('table')
|
|
@@ -1077,105 +1228,115 @@ buttons.headerButtons = function (dom, kb, name, words) {
|
|
|
1077
1228
|
//
|
|
1078
1229
|
// @param inverse means this is the object rather than the subject
|
|
1079
1230
|
//
|
|
1231
|
+
|
|
1232
|
+
|
|
1080
1233
|
function selectorPanel(dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
|
|
1081
|
-
|
|
1234
|
+
return selectorPanelRefresh(dom.createElement('div'), dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback);
|
|
1082
1235
|
}
|
|
1083
|
-
|
|
1236
|
+
|
|
1084
1237
|
function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
var f = exports.index.twoLine.widgetForClass(type);
|
|
1102
|
-
// eslint-disable-next-line prefer-const
|
|
1103
|
-
item = f(dom, x);
|
|
1104
|
-
item.setAttribute('style', style0);
|
|
1105
|
-
var nav = dom.createElement('div');
|
|
1106
|
-
nav.setAttribute('class', 'hideTillHover'); // See tabbedtab.css
|
|
1107
|
-
nav.setAttribute('style', 'float:right; width:10%');
|
|
1108
|
-
var a = dom.createElement('a');
|
|
1109
|
-
a.setAttribute('href', x.uri);
|
|
1110
|
-
a.setAttribute('style', 'float:right');
|
|
1111
|
-
nav.appendChild(a).textContent = '>';
|
|
1112
|
-
box.appendChild(nav);
|
|
1113
|
-
var iconDiv = dom.createElement('div');
|
|
1114
|
-
iconDiv.setAttribute('style', (inverse ? 'float:left;' : 'float:right;') + ' width:30px;');
|
|
1115
|
-
image = dom.createElement('img');
|
|
1116
|
-
setStyle();
|
|
1117
|
-
iconDiv.appendChild(image);
|
|
1118
|
-
box.appendChild(iconDiv);
|
|
1119
|
-
item.addEventListener('click', function (event) {
|
|
1120
|
-
if (selected === item) {
|
|
1121
|
-
// deselect
|
|
1122
|
-
item.setAttribute('style', style0);
|
|
1123
|
-
selected = null;
|
|
1124
|
-
}
|
|
1125
|
-
else {
|
|
1126
|
-
if (selected)
|
|
1127
|
-
selected.setAttribute('style', style0);
|
|
1128
|
-
item.setAttribute('style', style0 + 'background-color: #ccc; color:black;');
|
|
1129
|
-
selected = item;
|
|
1130
|
-
}
|
|
1131
|
-
callbackFunction(x, event, selected === item);
|
|
1132
|
-
setStyle();
|
|
1133
|
-
}, false);
|
|
1134
|
-
image.addEventListener('click', function (event) {
|
|
1135
|
-
linkCallback(x, event, inverse, setStyle);
|
|
1136
|
-
}, false);
|
|
1137
|
-
box.appendChild(item);
|
|
1138
|
-
return box;
|
|
1238
|
+
var style0 = 'border: 0.1em solid #ddd; border-bottom: none; width: 95%; height: 2em; padding: 0.5em;';
|
|
1239
|
+
var selected = null;
|
|
1240
|
+
list.innerHTML = '';
|
|
1241
|
+
|
|
1242
|
+
var refreshItem = function refreshItem(box, x) {
|
|
1243
|
+
// Scope to hold item and x
|
|
1244
|
+
var item; // eslint-disable-next-line prefer-const
|
|
1245
|
+
|
|
1246
|
+
var image;
|
|
1247
|
+
|
|
1248
|
+
var setStyle = function setStyle() {
|
|
1249
|
+
var already = inverse ? kb.each(undefined, predicate, x) : kb.each(x, predicate);
|
|
1250
|
+
iconDiv.setAttribute('class', already.length === 0 ? 'hideTillHover' : ''); // See tabbedtab.css
|
|
1251
|
+
|
|
1252
|
+
image.setAttribute('src', options.connectIcon || iconBase + 'noun_25830.svg');
|
|
1253
|
+
image.setAttribute('title', already.length ? already.length : 'attach');
|
|
1139
1254
|
};
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1255
|
+
|
|
1256
|
+
var f = index.twoLine.widgetForClass(type); // eslint-disable-next-line prefer-const
|
|
1257
|
+
|
|
1258
|
+
item = f(dom, x);
|
|
1259
|
+
item.setAttribute('style', style0);
|
|
1260
|
+
var nav = dom.createElement('div');
|
|
1261
|
+
nav.setAttribute('class', 'hideTillHover'); // See tabbedtab.css
|
|
1262
|
+
|
|
1263
|
+
nav.setAttribute('style', 'float:right; width:10%');
|
|
1264
|
+
var a = dom.createElement('a');
|
|
1265
|
+
a.setAttribute('href', x.uri);
|
|
1266
|
+
a.setAttribute('style', 'float:right');
|
|
1267
|
+
nav.appendChild(a).textContent = '>';
|
|
1268
|
+
box.appendChild(nav);
|
|
1269
|
+
var iconDiv = dom.createElement('div');
|
|
1270
|
+
iconDiv.setAttribute('style', (inverse ? 'float:left;' : 'float:right;') + ' width:30px;');
|
|
1271
|
+
image = dom.createElement('img');
|
|
1272
|
+
setStyle();
|
|
1273
|
+
iconDiv.appendChild(image);
|
|
1274
|
+
box.appendChild(iconDiv);
|
|
1275
|
+
item.addEventListener('click', function (event) {
|
|
1276
|
+
if (selected === item) {
|
|
1277
|
+
// deselect
|
|
1278
|
+
item.setAttribute('style', style0);
|
|
1279
|
+
selected = null;
|
|
1280
|
+
} else {
|
|
1281
|
+
if (selected) selected.setAttribute('style', style0);
|
|
1282
|
+
item.setAttribute('style', style0 + 'background-color: #ccc; color:black;');
|
|
1283
|
+
selected = item;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
callbackFunction(x, event, selected === item);
|
|
1287
|
+
setStyle();
|
|
1288
|
+
}, false);
|
|
1289
|
+
image.addEventListener('click', function (event) {
|
|
1290
|
+
linkCallback(x, event, inverse, setStyle);
|
|
1291
|
+
}, false);
|
|
1292
|
+
box.appendChild(item);
|
|
1293
|
+
return box;
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
for (var i = 0; i < possible.length; i++) {
|
|
1297
|
+
var box = dom.createElement('div');
|
|
1298
|
+
list.appendChild(box);
|
|
1299
|
+
refreshItem(box, possible[i]);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
return list;
|
|
1303
|
+
} // ###########################################################################
|
|
1149
1304
|
//
|
|
1150
1305
|
// Small compact views of things
|
|
1151
1306
|
//
|
|
1152
|
-
|
|
1153
|
-
|
|
1307
|
+
|
|
1308
|
+
|
|
1309
|
+
var index = {}; // ///////////////////////////////////////////////////////////////////////////
|
|
1154
1310
|
// We need these for anything which is a subject of an attachment.
|
|
1155
1311
|
//
|
|
1156
1312
|
// These should be moved to type-dependeent UI code. Related panes maybe
|
|
1313
|
+
|
|
1314
|
+
exports.index = index;
|
|
1315
|
+
|
|
1157
1316
|
function twoLineDefault(dom, x) {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1317
|
+
// Default
|
|
1318
|
+
var box = dom.createElement('div');
|
|
1319
|
+
box.textContent = utils.label(x);
|
|
1320
|
+
return box;
|
|
1162
1321
|
}
|
|
1163
1322
|
/**
|
|
1164
1323
|
* Find a function that can create a widget for a given class
|
|
1165
1324
|
* @param c The RDF class for which we want a widget generator function
|
|
1166
1325
|
*/
|
|
1326
|
+
|
|
1327
|
+
|
|
1167
1328
|
function twoLineWidgetForClass(c) {
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1329
|
+
var widget = index.twoLine[c.uri];
|
|
1330
|
+
var kb = _logic.store;
|
|
1331
|
+
if (widget) return widget;
|
|
1332
|
+
var sup = kb.findSuperClassesNT(c);
|
|
1333
|
+
|
|
1334
|
+
for (var cl in sup) {
|
|
1335
|
+
widget = index.twoLine[kb.fromNT(cl).uri];
|
|
1336
|
+
if (widget) return widget;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
return index.twoLine[''];
|
|
1179
1340
|
}
|
|
1180
1341
|
/**
|
|
1181
1342
|
* Display a transaction
|
|
@@ -1184,20 +1345,26 @@ function twoLineWidgetForClass(c) {
|
|
|
1184
1345
|
* * ns.qu('date) -> a literal
|
|
1185
1346
|
* * ns.qu('amount') -> a literal
|
|
1186
1347
|
*/
|
|
1348
|
+
|
|
1349
|
+
|
|
1187
1350
|
function twoLineTransaction(dom, x) {
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1351
|
+
var failed = '';
|
|
1352
|
+
|
|
1353
|
+
var enc = function enc(p) {
|
|
1354
|
+
var y = _logic.store.any(x, ns.qu(p));
|
|
1355
|
+
|
|
1356
|
+
if (!y) failed += '@@ No value for ' + p + '! ';
|
|
1357
|
+
return y ? utils.escapeForXML(y.value) : '?'; // @@@@
|
|
1358
|
+
};
|
|
1359
|
+
|
|
1360
|
+
var box = dom.createElement('table');
|
|
1361
|
+
box.innerHTML = "\n <tr>\n <td colspan=\"2\"> ".concat(enc('payee'), "</td>\n < /tr>\n < tr >\n <td>").concat(enc('date').slice(0, 10), "</td>\n <td style = \"text-align: right;\">").concat(enc('amount'), "</td>\n </tr>");
|
|
1362
|
+
|
|
1363
|
+
if (failed) {
|
|
1364
|
+
box.innerHTML = "\n <tr>\n <td><a href=\"".concat(utils.escapeForXML(x.uri), "\">").concat(utils.escapeForXML(failed), "</a></td>\n </tr>");
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
return box;
|
|
1201
1368
|
}
|
|
1202
1369
|
/**
|
|
1203
1370
|
* Display a trip
|
|
@@ -1206,68 +1373,76 @@ function twoLineTransaction(dom, x) {
|
|
|
1206
1373
|
* * ns.cal('dtstart') -> a literal
|
|
1207
1374
|
* * ns.cal('dtend') -> a literal
|
|
1208
1375
|
*/
|
|
1376
|
+
|
|
1377
|
+
|
|
1209
1378
|
function twoLineTrip(dom, x) {
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1379
|
+
var enc = function enc(p) {
|
|
1380
|
+
var y = _logic.store.any(x, p);
|
|
1381
|
+
|
|
1382
|
+
return y ? utils.escapeForXML(y.value) : '?';
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
var box = dom.createElement('table');
|
|
1386
|
+
box.innerHTML = "\n <tr>\n <td colspan=\"2\">".concat(enc(ns.dc('title')), "</td>\n </tr>\n <tr style=\"color: #777\">\n <td>").concat(enc(ns.cal('dtstart')), "</td>\n <td>").concat(enc(ns.cal('dtend')), "</td>\n </tr>");
|
|
1387
|
+
return box;
|
|
1217
1388
|
}
|
|
1218
1389
|
/**
|
|
1219
1390
|
* Stick a stylesheet link the document if not already there
|
|
1220
1391
|
*/
|
|
1392
|
+
|
|
1393
|
+
|
|
1221
1394
|
function addStyleSheet(dom, href) {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
}
|
|
1395
|
+
var links = dom.querySelectorAll('link');
|
|
1396
|
+
|
|
1397
|
+
for (var i = 0; i < links.length; i++) {
|
|
1398
|
+
if ((links[i].getAttribute('rel') || '') === 'stylesheet' && (links[i].getAttribute('href') || '') === href) {
|
|
1399
|
+
return;
|
|
1228
1400
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
// Figure (or guess) whether this is an image, etc
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
var link = dom.createElement('link');
|
|
1404
|
+
link.setAttribute('rel', 'stylesheet');
|
|
1405
|
+
link.setAttribute('type', 'text/css');
|
|
1406
|
+
link.setAttribute('href', href);
|
|
1407
|
+
dom.getElementsByTagName('head')[0].appendChild(link);
|
|
1408
|
+
} // Figure (or guess) whether this is an image, etc
|
|
1237
1409
|
//
|
|
1410
|
+
|
|
1411
|
+
|
|
1238
1412
|
function isAudio(file) {
|
|
1239
|
-
|
|
1413
|
+
return isImage(file, 'audio');
|
|
1240
1414
|
}
|
|
1241
|
-
|
|
1415
|
+
|
|
1242
1416
|
function isVideo(file) {
|
|
1243
|
-
|
|
1417
|
+
return isImage(file, 'video');
|
|
1244
1418
|
}
|
|
1245
|
-
exports.isVideo = isVideo;
|
|
1246
1419
|
/**
|
|
1247
1420
|
*
|
|
1248
1421
|
*/
|
|
1422
|
+
|
|
1423
|
+
|
|
1249
1424
|
function isImage(file, kind) {
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1425
|
+
var dcCLasses = {
|
|
1426
|
+
audio: 'http://purl.org/dc/dcmitype/Sound',
|
|
1427
|
+
image: 'http://purl.org/dc/dcmitype/Image',
|
|
1428
|
+
video: 'http://purl.org/dc/dcmitype/MovingImage'
|
|
1429
|
+
};
|
|
1430
|
+
var what = kind || 'image'; // See https://github.com/linkeddata/rdflib.js/blob/e367d5088c/src/formula.ts#L554
|
|
1431
|
+
//
|
|
1432
|
+
|
|
1433
|
+
var typeURIs = _logic.store.findTypeURIs(file); // See https://github.com/linkeddata/rdflib.js/blob/d5000f/src/utils-js.js#L14
|
|
1434
|
+
// e.g.'http://www.w3.org/ns/iana/media-types/audio'
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
var prefix = _rdflib.Util.mediaTypeClass(what + '/*').uri.split('*')[0];
|
|
1438
|
+
|
|
1439
|
+
for (var t in typeURIs) {
|
|
1440
|
+
if (t.startsWith(prefix)) return true;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
if (dcCLasses[what] in typeURIs) return true;
|
|
1444
|
+
return false;
|
|
1269
1445
|
}
|
|
1270
|
-
exports.isImage = isImage;
|
|
1271
1446
|
/**
|
|
1272
1447
|
* File upload button
|
|
1273
1448
|
* @param dom The DOM aka document
|
|
@@ -1276,39 +1451,42 @@ exports.isImage = isImage;
|
|
|
1276
1451
|
* The input is hidden, as it is uglky - the user clicks on the nice icons and fires the input.
|
|
1277
1452
|
*/
|
|
1278
1453
|
// See https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications
|
|
1454
|
+
|
|
1455
|
+
|
|
1279
1456
|
function fileUploadButtonDiv(dom, droppedFileHandler) {
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
alert('Sorry no files .. internal error?');
|
|
1294
|
-
}
|
|
1295
|
-
}, false);
|
|
1296
|
-
input.style = 'display:none';
|
|
1297
|
-
var buttonElt = div.appendChild(button(dom, iconBase + 'noun_Upload_76574_000000.svg', 'Upload files', function (_event) {
|
|
1298
|
-
input.click();
|
|
1299
|
-
}));
|
|
1300
|
-
(0, dragAndDrop_1.makeDropTarget)(buttonElt, null, droppedFileHandler); // Can also just drop on button
|
|
1301
|
-
return div;
|
|
1302
|
-
}
|
|
1303
|
-
exports.fileUploadButtonDiv = fileUploadButtonDiv;
|
|
1304
|
-
exports.index = {
|
|
1305
|
-
line: { // Approx 80em
|
|
1306
|
-
},
|
|
1307
|
-
twoLine: {
|
|
1308
|
-
'': twoLineDefault,
|
|
1309
|
-
'http://www.w3.org/2000/10/swap/pim/qif#Transaction': twoLineTransaction,
|
|
1310
|
-
'http://www.w3.org/ns/pim/trip#Trip': twoLineTrip,
|
|
1311
|
-
widgetForClass: twoLineWidgetForClass
|
|
1457
|
+
var div = dom.createElement('div');
|
|
1458
|
+
var input = div.appendChild(dom.createElement('input'));
|
|
1459
|
+
input.setAttribute('type', 'file');
|
|
1460
|
+
input.setAttribute('multiple', 'true');
|
|
1461
|
+
input.addEventListener('change', function (event) {
|
|
1462
|
+
debug.log('File drop event: ', event);
|
|
1463
|
+
|
|
1464
|
+
if (event.files) {
|
|
1465
|
+
droppedFileHandler(event.files);
|
|
1466
|
+
} else if (event.target && event.target.files) {
|
|
1467
|
+
droppedFileHandler(event.target.files);
|
|
1468
|
+
} else {
|
|
1469
|
+
alert('Sorry no files .. internal error?');
|
|
1312
1470
|
}
|
|
1471
|
+
}, false);
|
|
1472
|
+
input.style = 'display:none';
|
|
1473
|
+
var buttonElt = div.appendChild(button(dom, iconBase + 'noun_Upload_76574_000000.svg', 'Upload files', function (_event) {
|
|
1474
|
+
input.click();
|
|
1475
|
+
}));
|
|
1476
|
+
(0, _dragAndDrop.makeDropTarget)(buttonElt, null, droppedFileHandler); // Can also just drop on button
|
|
1477
|
+
|
|
1478
|
+
return div;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
exports.index = index = {
|
|
1482
|
+
line: {// Approx 80em
|
|
1483
|
+
},
|
|
1484
|
+
twoLine: {
|
|
1485
|
+
// Approx 40em * 2.4em
|
|
1486
|
+
'': twoLineDefault,
|
|
1487
|
+
'http://www.w3.org/2000/10/swap/pim/qif#Transaction': twoLineTransaction,
|
|
1488
|
+
'http://www.w3.org/ns/pim/trip#Trip': twoLineTrip,
|
|
1489
|
+
widgetForClass: twoLineWidgetForClass
|
|
1490
|
+
}
|
|
1313
1491
|
};
|
|
1314
1492
|
//# sourceMappingURL=buttons.js.map
|