new Detail(params)
Creates a Detail object. Although this constructor can be used directly, it's better to use it from Psynth.Node#addDetail or Psynth.Link#addDetail.
By using these methods, the Detail gets its anchor_uid and anchor_type automatically. It is also automatically added to the Graph.
Additionally, there are useful defaults for the x and y properties that can only be accessed by adding a detail directly to the object.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object |
Properties
|
Examples
var d = new Psynth.Detail({anchor_uid: n.uid,
anchor_type: 'Node',
x: n.x+n.radius+10,
y: n.y+n.radius+30,
type: 'link',
content: 'http://psymphonic.com'});
g.addDetail(d);
var d = n.addDetail({content: 'http://psymphonic.com', type: 'link'});
Members
-
anchor_type :string
-
The type of object this Detail is anchored to. 'node', 'rel'
Type:
- string
-
anchor_uid :string
-
The uid of the object this Detail is anchored to.
Type:
- string
-
content :string
-
The content of this Detail.
Type:
- string
-
created :boolean
-
Indicates whether this Detail has been created yet in the server.
Type:
- boolean
-
graph :Psynth.Graph
-
The Graph to which this Detail belongs.
Type:
-
name :string
-
The name of this Detail. Not currently used for anything on the front end.
Type:
- string
-
type :string
-
The type of Detail this. 'comment', 'link', 'image', 'video'
Type:
- string
-
uid :string
-
A unique identifier for this Detail. This is what is indexed at Graph#details, {@link Node#details}, and Link#details
Type:
- string
-
x :number
-
The x-coordinate of this Detail in Pixels. Assumes web-standard grid with (0,0) at (top,left).
Type:
- number
-
y :number
-
The y-coordinate of this Detail in Pixels. Assumes web-standard grid with (0,0) at (top,left).
Type:
- number
Methods
-
anchor() → {Psynth.Node|Psynth.Link|Number}
-
Returns:
- Type
- Psynth.Node | Psynth.Link | Number
Example
console.log(d.anchor().name);
-
object() → {simpleDetail}
-
Formats the Detail as a JSON-serializable object which contains all necessary information. This is mostly used internally to prepare queries for the server.
Returns:
object- Type
- simpleDetail
Example
var q = d.object(); q.query = "newdetail"; g.queue(q);
-
update(callback)
-
Updates the information for this Detail on the server. This allows you to make multiple edits to a Link while only making 1 server call.
Parameters:
Name Type Argument Description callback
function <optional>
An optional function to handle the server response. Example
d.content = "www.opensecrets.org"; d.y += 20; d.update();