Class: Detail

Psynth. Detail

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
Name Type Argument Default Description
type string <optional>
comment The type of Detail this is. Can be 'comment','link','video','image'.
name string <optional>
The name of this Detail. This is not currently used for anything on the front end.
uid string <optional>
A unique identifier for this Detail. Defaults to a global unique id.
anchor_uid string The uid for the object this Detail is anchored to.
anchor_type string The type of object this Detail is anchored to. Currently supported are 'rel' and 'node'
content string The content of this Detail.
x number The x-coordinate of this Detail in Pixels. Assumes web-standard grid with (0,0) at (top,left).
y number The y-coordinate of this Detail in Pixels. Assumes web-standard grid with (0,0) at (top,left).
Source:
Examples

Direct use of Constructor

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);

Adding to an existing object

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
Source:

anchor_uid :string

The uid of the object this Detail is anchored to.
Type:
  • string
Source:

content :string

The content of this Detail.
Type:
  • string
Source:

created :boolean

Indicates whether this Detail has been created yet in the server.
Type:
  • boolean
Default Value:
  • false
Source:

graph :Psynth.Graph

The Graph to which this Detail belongs.
Type:
Source:

name :string

The name of this Detail. Not currently used for anything on the front end.
Type:
  • string
Source:

type :string

The type of Detail this. 'comment', 'link', 'image', 'video'
Type:
  • string
Default Value:
  • 'comment'
Source:

uid :string

A unique identifier for this Detail. This is what is indexed at Graph#details, {@link Node#details}, and Link#details
Type:
  • string
Source:

x :number

The x-coordinate of this Detail in Pixels. Assumes web-standard grid with (0,0) at (top,left).
Type:
  • number
Source:

y :number

The y-coordinate of this Detail in Pixels. Assumes web-standard grid with (0,0) at (top,left).
Type:
  • number
Source:

Methods

anchor() → {Psynth.Node|Psynth.Link|Number}

Returns the Node or Link that this Detail is anchored to. Returns -1 if the anchor is invalid.
Source:
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.
Source:
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.
Source:
Example
d.content = "www.opensecrets.org";
d.y += 20;
d.update();