@zakkzhang/tw5-graph 1.6.4
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 +65 -0
- package/package.json +39 -0
- package/plugins/graph/DefaultColourMappings.multids +8 -0
- package/plugins/graph/ViewTemplateBodyFilter/graph.tid +5 -0
- package/plugins/graph/ViewTemplateBodyFilter/properties.tid +5 -0
- package/plugins/graph/edges/fields/list.tid +7 -0
- package/plugins/graph/edges/fields/tags.tid +7 -0
- package/plugins/graph/edges/functions/links.tid +8 -0
- package/plugins/graph/edges/functions/transcludes.tid +8 -0
- package/plugins/graph/fieldtypes/filter.js +212 -0
- package/plugins/graph/fieldtypes/list.js +31 -0
- package/plugins/graph/fieldtypes/title.js +27 -0
- package/plugins/graph/filterrunprefixes/cache.js +118 -0
- package/plugins/graph/filters/gettyped.js +26 -0
- package/plugins/graph/graphengine.js +38 -0
- package/plugins/graph/icon.tid +16 -0
- package/plugins/graph/images/drag.tid +13 -0
- package/plugins/graph/macros/action.addedge.tid +16 -0
- package/plugins/graph/macros/edges.typed.tid +54 -0
- package/plugins/graph/macros/graph.view.tid +24 -0
- package/plugins/graph/macros/node.default.tid +9 -0
- package/plugins/graph/macros/nodes.neighbors.tid +62 -0
- package/plugins/graph/macros/nodes.writable.tid +37 -0
- package/plugins/graph/macros/properties.persistent.tid +27 -0
- package/plugins/graph/macros/properties.popup.tid +76 -0
- package/plugins/graph/macros/properties.river.tid +27 -0
- package/plugins/graph/macros/properties.settings.tid +56 -0
- package/plugins/graph/macros/properties.stack.tid +17 -0
- package/plugins/graph/macros/tiddlywiki.files +17 -0
- package/plugins/graph/plugin.info +14 -0
- package/plugins/graph/presettypes/edges/fields.tid +18 -0
- package/plugins/graph/presettypes/edges/functions.tid +5 -0
- package/plugins/graph/presettypes/nodes/stack.tid +6 -0
- package/plugins/graph/propertytypes/actions.js +15 -0
- package/plugins/graph/propertytypes/boolean.js +23 -0
- package/plugins/graph/propertytypes/enum.js +25 -0
- package/plugins/graph/propertytypes/image.js +140 -0
- package/plugins/graph/propertytypes/number.js +24 -0
- package/plugins/graph/propertytypes/string.js +13 -0
- package/plugins/graph/propertytypes/tiddlywiki.files +17 -0
- package/plugins/graph/readme.tid +5 -0
- package/plugins/graph/relink/attributes.js +52 -0
- package/plugins/graph/relink/attributes.multids +19 -0
- package/plugins/graph/relink/configprefix.js +76 -0
- package/plugins/graph/relink/fieldedgeprefix.js +39 -0
- package/plugins/graph/relink/fields.multids +11 -0
- package/plugins/graph/relink/graphprefix.js +28 -0
- package/plugins/graph/relink/operators.multids +3 -0
- package/plugins/graph/relink/propertyfields.js +81 -0
- package/plugins/graph/relink/utils.js +99 -0
- package/plugins/graph/settings.tid +13 -0
- package/plugins/graph/startup/messages.js +46 -0
- package/plugins/graph/stylesheets/base.css.tid +263 -0
- package/plugins/graph/stylesheets/fullscreen/core.css +11 -0
- package/plugins/graph/stylesheets/fullscreen/core.css.meta +3 -0
- package/plugins/graph/stylesheets/fullscreen.css.tid +46 -0
- package/plugins/graph/stylesheets/popup.css.tid +107 -0
- package/plugins/graph/subfilters.tid +23 -0
- package/plugins/graph/tags/GraphToolbar.tid +2 -0
- package/plugins/graph/tags/SettingsTab.tid +2 -0
- package/plugins/graph/tags/Template.tid +2 -0
- package/plugins/graph/tags/ViewEditTemplate.tid +2 -0
- package/plugins/graph/templates/live-graph.tid +34 -0
- package/plugins/graph/templates/standard-graph.tid +40 -0
- package/plugins/graph/ui/Buttons/center.tid +38 -0
- package/plugins/graph/ui/Buttons/export.tid +65 -0
- package/plugins/graph/ui/Buttons/fullscreen.tid +35 -0
- package/plugins/graph/ui/Buttons/settings.tid +28 -0
- package/plugins/graph/ui/Buttons/tiddlywiki.files +16 -0
- package/plugins/graph/ui/EditTemplate/Edges.tid +22 -0
- package/plugins/graph/ui/EditTemplate/Neighbors.tid +35 -0
- package/plugins/graph/ui/EditTemplate/Nodes.tid +12 -0
- package/plugins/graph/ui/EditTemplate/Popups.tid +27 -0
- package/plugins/graph/ui/EditTemplate/Properties.tid +21 -0
- package/plugins/graph/ui/EditTemplate/tiddlywiki.files +16 -0
- package/plugins/graph/ui/Modals/NewPropertySet.tid +20 -0
- package/plugins/graph/ui/Modals/NewView.tid +20 -0
- package/plugins/graph/ui/Modals/Select.tid +72 -0
- package/plugins/graph/ui/Modals/SelectField.tid +21 -0
- package/plugins/graph/ui/Modals/SelectTiddler.tid +15 -0
- package/plugins/graph/ui/Modals/Tiddler.tid +22 -0
- package/plugins/graph/ui/Modals/TiddlerHeader.tid +15 -0
- package/plugins/graph/ui/PropertyTypes/boolean.tid +11 -0
- package/plugins/graph/ui/PropertyTypes/color.tid +5 -0
- package/plugins/graph/ui/PropertyTypes/enum.tid +15 -0
- package/plugins/graph/ui/PropertyTypes/number.tid +17 -0
- package/plugins/graph/ui/Settings/Engine.tid +23 -0
- package/plugins/graph/ui/Settings/Graphs/EditTemplate.tid +52 -0
- package/plugins/graph/ui/Settings/Graphs.tid +49 -0
- package/plugins/graph/ui/Settings/Properties/ObjectsTypeTemplate.tid +44 -0
- package/plugins/graph/ui/Settings/Properties.tid +14 -0
- package/plugins/graph/ui/Settings/Toolbar.tid +5 -0
- package/plugins/graph/ui/SideBar/Graph.tid +77 -0
- package/plugins/graph/ui/Toolbars/GraphToolbar.tid +15 -0
- package/plugins/graph/ui/ViewTemplate/graph-object.tid +13 -0
- package/plugins/graph/ui/ViewTemplate/graph.tid +11 -0
- package/plugins/graph/ui/ViewTemplate/properties.tid +80 -0
- package/plugins/graph/ui/grouped-tabs.tid +109 -0
- package/plugins/graph/ui/selector.tid +74 -0
- package/plugins/graph/utils.js +148 -0
- package/plugins/graph/widgets/action-delay.js +72 -0
- package/plugins/graph/widgets/action-modal.js +121 -0
- package/plugins/graph/widgets/action-typed.js +56 -0
- package/plugins/graph/widgets/action-with.js +70 -0
- package/plugins/graph/widgets/boundingbox.js +126 -0
- package/plugins/graph/widgets/fieldTranscriber.js +98 -0
- package/plugins/graph/widgets/fieldtranscriber/filter.js +93 -0
- package/plugins/graph/widgets/fieldtranscriber/json.js +34 -0
- package/plugins/graph/widgets/fieldtranscriber/plain.js +11 -0
- package/plugins/graph/widgets/graphobject.js +120 -0
- package/plugins/graph/widgets/messagerelay.js +115 -0
- package/plugins/graph/widgets/properties.js +131 -0
- package/plugins/graph/widgets/subclass/edge.js +47 -0
- package/plugins/graph/widgets/subclass/graph.js +424 -0
- package/plugins/graph/widgets/subclass/node.js +44 -0
- package/plugins/graph/widgets/tiddlywiki.files +43 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*\
|
|
2
|
+
|
|
3
|
+
Base-class widget that provides standard functionality for all "graph objects",
|
|
4
|
+
such as nodes or edges.
|
|
5
|
+
|
|
6
|
+
\*/
|
|
7
|
+
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
|
11
|
+
var utils = require("../utils.js");
|
|
12
|
+
|
|
13
|
+
var ObjectWidget = function(parseTreeNode, options) {};
|
|
14
|
+
|
|
15
|
+
ObjectWidget.prototype = new Widget();
|
|
16
|
+
|
|
17
|
+
ObjectWidget.prototype.render = function(parent, nextSibling) {
|
|
18
|
+
this.parentDomNode = parent;
|
|
19
|
+
this.parentPropertiesWidget = utils.getParentProperties(this, this.graphObjectType);
|
|
20
|
+
this.computeAttributes();
|
|
21
|
+
this.execute();
|
|
22
|
+
this.computeParents();
|
|
23
|
+
this.renderChildren(parent, nextSibling);
|
|
24
|
+
this.properties = this.refreshProperties();
|
|
25
|
+
// We're new, so we're changed. Announce ourselves when asked.
|
|
26
|
+
this.changed = true;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
ObjectWidget.prototype.refresh = function(changedTiddlers) {
|
|
30
|
+
var changedAttributes = this.computeAttributes();
|
|
31
|
+
// Did our parents experience a change?
|
|
32
|
+
var possibleChanges = this.computeParents();
|
|
33
|
+
// Did our own properties change?
|
|
34
|
+
for (var attribute in changedAttributes) {
|
|
35
|
+
possibleChanges = true;
|
|
36
|
+
}
|
|
37
|
+
// No properties have overtly changed, but maybe they changed covertly...
|
|
38
|
+
if (!possibleChanges && utils.refreshProperties(this.properties, this, this.graphObjectType, changedTiddlers)) {
|
|
39
|
+
possibleChanges = true;
|
|
40
|
+
// We short-circuit this because we have a property that said it's for
|
|
41
|
+
// sure different.
|
|
42
|
+
this.changed = true;
|
|
43
|
+
}
|
|
44
|
+
if (possibleChanges) {
|
|
45
|
+
this.execute();
|
|
46
|
+
this.properties = this.refreshProperties();
|
|
47
|
+
this.changed = true;
|
|
48
|
+
}
|
|
49
|
+
return this.refreshChildren(changedTiddlers) || this.changed;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
ObjectWidget.prototype.allowActionPropagation = function() {
|
|
53
|
+
return false;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
ObjectWidget.prototype.refreshProperties = function() {
|
|
57
|
+
var newProperties = Object.create(null);
|
|
58
|
+
this.setCustomProperties(newProperties);
|
|
59
|
+
for (var key in this.attributes) {
|
|
60
|
+
if (key.charAt(0) !== "$") {
|
|
61
|
+
var value = this.attributes[key];
|
|
62
|
+
if (value) {
|
|
63
|
+
newProperties[key] = this.attributes[key];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (var i = 0; i < this.applicableParents.length; i++) {
|
|
68
|
+
var widget = this.applicableParents[i];
|
|
69
|
+
for (var property in widget.properties) {
|
|
70
|
+
if (!Object.hasOwnProperty.call(newProperties, property)) {
|
|
71
|
+
newProperties[property] = widget.properties[property];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return newProperties;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
ObjectWidget.prototype.catchGraphEvent = function(graphEvent, triggeringWidget, variables) {
|
|
79
|
+
var actions = this.attributes[graphEvent.type];
|
|
80
|
+
if (actions) {
|
|
81
|
+
triggeringWidget.invokeActionString(actions, triggeringWidget, graphEvent.event, variables);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
ObjectWidget.prototype.computeParents = function() {
|
|
88
|
+
var index = 0;
|
|
89
|
+
var changed = false;
|
|
90
|
+
var list = this.applicableParents = this.applicableParents || [];
|
|
91
|
+
this.traversePropertyWidgets(function(widget) {
|
|
92
|
+
if (list[index] !== widget) {
|
|
93
|
+
list[index] = widget;
|
|
94
|
+
changed = true;
|
|
95
|
+
} else if (widget.propertiesChanged) {
|
|
96
|
+
changed = true;
|
|
97
|
+
}
|
|
98
|
+
index++;
|
|
99
|
+
});
|
|
100
|
+
if (index !== list.length) {
|
|
101
|
+
list.length = index;
|
|
102
|
+
changed = true;
|
|
103
|
+
}
|
|
104
|
+
return changed;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Explore for any $properties which might apply to this. Can be overridden.
|
|
109
|
+
*/
|
|
110
|
+
ObjectWidget.prototype.traversePropertyWidgets = function(method) {
|
|
111
|
+
var widget = this.parentPropertiesWidget;
|
|
112
|
+
while (widget !== null) {
|
|
113
|
+
if (widget.filterFunc([this.id], widget).length > 0) {
|
|
114
|
+
method(widget);
|
|
115
|
+
}
|
|
116
|
+
widget = widget.parentPropertiesWidget;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
exports.graphobject = ObjectWidget;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*\
|
|
2
|
+
|
|
3
|
+
Widget for relaying emitted messages to other parts of the widget.
|
|
4
|
+
This allows buttons for a graph to exist outside of that graph.
|
|
5
|
+
|
|
6
|
+
\*/
|
|
7
|
+
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
|
11
|
+
var utils = require("../utils.js");
|
|
12
|
+
|
|
13
|
+
// Relayed is used to avoid infinite loops. Once an event is relayed,
|
|
14
|
+
// it puts itself in this object under the relay name, so it can't be
|
|
15
|
+
// relayed again through that name
|
|
16
|
+
var relayed = Object.create(null);
|
|
17
|
+
|
|
18
|
+
var RelayWidget = function(parseTreeNode, options) {
|
|
19
|
+
this.initialise(parseTreeNode, options);
|
|
20
|
+
utils.registerForGarbageCollection(this);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
RelayWidget.prototype = new Widget();
|
|
24
|
+
|
|
25
|
+
RelayWidget.prototype.render = function(parent, nextSibling) {
|
|
26
|
+
this.parentDomNode = parent;
|
|
27
|
+
this.computeAttributes();
|
|
28
|
+
this.execute();
|
|
29
|
+
this.renderChildren(parent, nextSibling);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
RelayWidget.prototype.execute = function() {
|
|
33
|
+
this.relayName = this.getAttribute("name");
|
|
34
|
+
this.relayTo = this.getAttribute("to");
|
|
35
|
+
if (this.relayName) {
|
|
36
|
+
var register = this.wiki.relayRegister = this.wiki.relayRegister || Object.create(null);
|
|
37
|
+
register[this.relayName] = register[this.relayName] || [];
|
|
38
|
+
register[this.relayName].push(this);
|
|
39
|
+
}
|
|
40
|
+
this.makeChildWidgets();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
RelayWidget.prototype.refresh = function(changedTiddlers) {
|
|
44
|
+
var changedAttributes = this.computeAttributes();
|
|
45
|
+
var changed = false;
|
|
46
|
+
if (changedAttributes.name) {
|
|
47
|
+
this.garbageCollect();
|
|
48
|
+
this.refreshSelf();
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (changedAttributes.to) {
|
|
52
|
+
this.relayTo = this.getAttribute("to");
|
|
53
|
+
changed = true;
|
|
54
|
+
}
|
|
55
|
+
return this.refreshChildren(changedTiddlers) || changed;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
RelayWidget.prototype.dispatchEvent = function(event) {
|
|
59
|
+
var register = this.wiki.relayRegister;
|
|
60
|
+
if (this.relayTo
|
|
61
|
+
&& register
|
|
62
|
+
&& register[this.relayTo]
|
|
63
|
+
&& relayed[this.relayTo] !== event) {
|
|
64
|
+
relayed[this.relayTo] = event;
|
|
65
|
+
var targets = register[this.relayTo];
|
|
66
|
+
for (var i = 0; i < targets.length; i++) {
|
|
67
|
+
var target = targets[i];
|
|
68
|
+
if (!target.isGarbage()) {
|
|
69
|
+
targets[i].dispatchEvent(event);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
return Widget.prototype.dispatchEvent.call(this, event);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
RelayWidget.prototype.isGarbage = function() {
|
|
78
|
+
var root = rootWidget(this);
|
|
79
|
+
return root !== $tw.rootWidget;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
RelayWidget.prototype.garbageCollect = function() {
|
|
83
|
+
if (this.relayName) {
|
|
84
|
+
var register = this.wiki.relayRegister[this.relayName];
|
|
85
|
+
for (var i = 0; i < register.length; i++) {
|
|
86
|
+
if (register[i] === this) {
|
|
87
|
+
// Remove this from the register
|
|
88
|
+
register.splice(i, 1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
this.relayName = undefined;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
function rootWidget(relay) {
|
|
96
|
+
var parent = relay.parentWidget;
|
|
97
|
+
while (parent) {
|
|
98
|
+
var i = 0;
|
|
99
|
+
for (; i < parent.children.length; i++) {
|
|
100
|
+
if (parent.children[i] === relay) {
|
|
101
|
+
// Confirmed that the parent still owns this child
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (i == parent.children.length) {
|
|
106
|
+
// Ownership was not confirmed
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
relay = parent;
|
|
110
|
+
parent = relay.parentWidget;
|
|
111
|
+
}
|
|
112
|
+
return relay;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
exports.messagerelay = RelayWidget;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*\
|
|
2
|
+
|
|
3
|
+
Widget for setting properties on graph objects.
|
|
4
|
+
|
|
5
|
+
\*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
|
10
|
+
var utils = require("../utils.js");
|
|
11
|
+
var Engines = $tw.modules.getModulesByTypeAsHashmap("graphengine");
|
|
12
|
+
var PropertyTypes = $tw.modules.getModulesByTypeAsHashmap("graphpropertytype");
|
|
13
|
+
|
|
14
|
+
var Properties = function(parseTreeNode, options) {
|
|
15
|
+
this.initialise(parseTreeNode, options);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Properties.prototype = new Widget();
|
|
19
|
+
|
|
20
|
+
Properties.prototype.graphPropertiesWidget = true;
|
|
21
|
+
|
|
22
|
+
Properties.prototype.render = function(parent, nextSibling) {
|
|
23
|
+
this.parentDomNode = parent;
|
|
24
|
+
this.computeAttributes();
|
|
25
|
+
this.execute();
|
|
26
|
+
this.renderChildren(parent, nextSibling);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
Properties.prototype.execute = function() {
|
|
30
|
+
this.type = this.getAttribute("$for", "nodes");
|
|
31
|
+
this.parentPropertiesWidget = utils.getParentProperties(this, this.type);
|
|
32
|
+
this.filter = this.getAttribute("$filter");
|
|
33
|
+
this.properties = this.getProperties();
|
|
34
|
+
this.filterFunc = this.filter? this.wiki.compileFilter(this.filter): function(source) { return source; };
|
|
35
|
+
this.makeChildWidgets();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Properties.prototype.refresh = function(changedTiddlers) {
|
|
39
|
+
var changedAttributes = this.computeAttributes();
|
|
40
|
+
this.propertiesChanged = false;
|
|
41
|
+
if (changedAttributes["$for"]) {
|
|
42
|
+
// If the $for changed, we need to refocus to the different object type.
|
|
43
|
+
this.refreshSelf();
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (propertiesChanged(changedAttributes)
|
|
47
|
+
|| utils.refreshProperties(this.properties, this, this.type, changedTiddlers)
|
|
48
|
+
|| changedAttributes["$tiddler"]
|
|
49
|
+
|| changedAttributes["$field"]
|
|
50
|
+
|| (this.dataTiddler
|
|
51
|
+
&& changedTiddlers[this.dataTiddler]
|
|
52
|
+
&& this.rawData !== getTiddlerString(this.wiki, this.dataTiddler, this.field))) {
|
|
53
|
+
// Our styling attributes have changed, so everything this $style
|
|
54
|
+
// affects needs to refresh.
|
|
55
|
+
this.properties = this.getProperties();
|
|
56
|
+
this.propertiesChanged = true;
|
|
57
|
+
}
|
|
58
|
+
// If we have a filterFunc, we need to worry about whether this style
|
|
59
|
+
// applies to a different subset of its children objects or not.
|
|
60
|
+
if (changedAttributes["$filter"]) {
|
|
61
|
+
this.filter = this.getAttribute("$filter");
|
|
62
|
+
this.filterFunc = this.filter? this.wiki.compileFilter(this.filter): function(source) { return source; };
|
|
63
|
+
}
|
|
64
|
+
return this.refreshChildren(changedTiddlers) || this.propertiesChanged;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Properties.prototype.getProperties = function() {
|
|
68
|
+
this.field = this.getAttribute("$field");
|
|
69
|
+
this.dataTiddler = this.getAttribute("$tiddler");
|
|
70
|
+
if (!this.dataTiddler && this.field) {
|
|
71
|
+
this.dataTiddler = this.getVariable("currentTiddler");
|
|
72
|
+
}
|
|
73
|
+
var styleObject = Object.create(null);
|
|
74
|
+
if (this.dataTiddler) {
|
|
75
|
+
var data;
|
|
76
|
+
// We recall the actual raw data string so
|
|
77
|
+
// we can see whether it changes later on.
|
|
78
|
+
this.rawData = getTiddlerString(this.wiki, this.dataTiddler, this.field);
|
|
79
|
+
if (!this.field || this.field === "text") {
|
|
80
|
+
data = this.wiki.getTiddlerData(this.dataTiddler);
|
|
81
|
+
} else {
|
|
82
|
+
try {
|
|
83
|
+
data = this.rawData? JSON.parse(this.rawData): {};
|
|
84
|
+
} catch {
|
|
85
|
+
data = {};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (var entry in data) {
|
|
89
|
+
var datum = data[entry];
|
|
90
|
+
// We only accept non-empty values
|
|
91
|
+
if (datum && typeof datum === "string") {
|
|
92
|
+
styleObject[entry] = datum;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
for (var name in this.attributes) {
|
|
97
|
+
if (name.charAt(0) !== '$' && this.attributes[name]) {
|
|
98
|
+
styleObject[name] = this.attributes[name];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return styleObject;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
function getTiddlerString(wiki, title, field) {
|
|
105
|
+
var tiddler = wiki.getTiddler(title);
|
|
106
|
+
return tiddler && tiddler.getFieldString(field || "text");
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
Properties.prototype.catchGraphEvent = function(graphEvent, target, variables) {
|
|
110
|
+
if (graphEvent.objectType === this.type
|
|
111
|
+
&& this.filterFunc([target.id], this).length > 0) {
|
|
112
|
+
var actions = this.properties[graphEvent.type];
|
|
113
|
+
if (actions) {
|
|
114
|
+
variables.targetTiddler = graphEvent.id;
|
|
115
|
+
this.invokeActionString(actions, this, graphEvent.event, variables);
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
function propertiesChanged(changedAttributes) {
|
|
123
|
+
for (var name in changedAttributes) {
|
|
124
|
+
if (name.charAt(0) !== "$") {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
exports.properties = Properties;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*\
|
|
2
|
+
|
|
3
|
+
Widget for creating edges within graphs.
|
|
4
|
+
|
|
5
|
+
\*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
var nextId = 1;
|
|
10
|
+
|
|
11
|
+
exports.baseClass = "graphobject";
|
|
12
|
+
exports.name = "edge";
|
|
13
|
+
// These are object properties that will get added to the variable context
|
|
14
|
+
// when action strings are invoked.
|
|
15
|
+
exports.actionContext = ["id", "fromTiddler", "toTiddler"];
|
|
16
|
+
|
|
17
|
+
exports.constructor = function(parseTreeNode, options) {
|
|
18
|
+
this.initialise(parseTreeNode, options);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var EdgeWidget = exports.prototype = {};
|
|
22
|
+
|
|
23
|
+
EdgeWidget.graphObjectType = "edges";
|
|
24
|
+
|
|
25
|
+
EdgeWidget.execute = function() {
|
|
26
|
+
this.id = this.getAttribute("$id");
|
|
27
|
+
if (!this.id) {
|
|
28
|
+
// We do this instead of using getAttribute's default arg
|
|
29
|
+
// so we don't increment unecessarily, and maybe reuse
|
|
30
|
+
// the same auto-id if this edge refreshes Self. This'll give better
|
|
31
|
+
// results when updating the graph. It's a CHANGED edge, not a new one.
|
|
32
|
+
this.counter = this.counter || nextId++;
|
|
33
|
+
this.id = "$:/edge/" + this.counter;
|
|
34
|
+
}
|
|
35
|
+
this.fromTiddler = this.getAttribute("$from", this.getVariable("currentTiddler"));
|
|
36
|
+
this.toTiddler = this.getAttribute("$to", this.getVariable("toTiddler"));
|
|
37
|
+
this.makeChildWidgets();
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
EdgeWidget.setCustomProperties = function(properties) {
|
|
41
|
+
if (this.fromTiddler) {
|
|
42
|
+
properties.from = this.fromTiddler;
|
|
43
|
+
}
|
|
44
|
+
if (this.toTiddler) {
|
|
45
|
+
properties.to = this.toTiddler;
|
|
46
|
+
}
|
|
47
|
+
};
|