Class: Node

GoBrain. Node

new GoBrain.Node(node)

GoBrain.Core/src/node.js, line 1

An HTMLElement wrapper, adding convenience functionality used to manipulate the element.

An HTMLElement wrapper, adding convenience functionality used to manipulate the element.

Name Type Description
node HTMLElement

The element to work against.

Members

SettingsString

Properties:
Name Type Default Description
DataPrefix String data-internal-gobrain-

This namespace is prepended to all attributes set with the .data() function.

Methods

addClass(clazz){GoBrain.Node}

GoBrain.Core/src/node.js, line 38

Adds a css class if it doesn't already exist.

Adds a css class if it doesn't already exist.

Name Type Description
clazz String

The class to add.

Returns:
Type Description
GoBrain.Node

addEventListener(event, handler, options){GoBrain.Node}

GoBrain.Core/src/node.js, line 54

Adds an event listener.

Adds an event listener.

Name Type Description
event String

Event to listen to.

handler function

Handler to invoke when event occurs.

options Boolean | Object

Options to use to add the event handler. If boolean, whether or not to add handler as passive, if supported.

Returns:
Type Description
GoBrain.Node

appendChild(child){GoBrain.Node}

GoBrain.Core/src/node.js, line 84

Appends a child node/element.

Appends a child node/element.

Name Type Description
child GoBrain.Node | HTMLElement

The child to append.

Returns:
Type Description
GoBrain.Node

attribute(attribute, value){GoBrain.Node|String}

GoBrain.Core/src/node.js, line 100

Gets or sets or removes node attribute.

Gets or sets or removes node attribute.

Name Type Description
attribute String

The name of the attribute.

value String optional

The value of the attribute.

Returns:
Type Description
GoBrain.Node | String

children(){Array.<GoBrain.Node>}

GoBrain.Core/src/node.js, line 127

Gets children of node.

Gets children of node.

Returns:
Type Description
Array.<GoBrain.Node>

content(content){GoBrain.Node|*}

GoBrain.Core/src/node.js, line 144

Gets or sets node content.

Gets or sets node content.

Name Type Description
content * optional

The content to set.

Returns:
Type Description
GoBrain.Node | *

context(){HTMLElement}

GoBrain.Core/src/node.js, line 182

Gets the element that the node instance was created with.

Gets the element that the node instance was created with.

Returns:
Type Description
HTMLElement

css(styles){GoBrain.Node}

GoBrain.Core/src/node.js, line 193

Sets node style properties.

Sets node style properties.

Name Type Description
styles Object.<String, *>

The style properties to set.

Returns:
Type Description
GoBrain.Node

data(property, value){GoBrain.Node|String}

GoBrain.Core/src/node.js, line 244

Gets or sets data attribute.

Gets or sets data attribute.

Name Type Description
property String

The name of the data attribute.

value String optional

The value of the data attribute.

Returns:
Type Description
GoBrain.Node | String

getNodeByClass(clazz){GoBrain.Node|null}

GoBrain.Core/src/node.js, line 266

Gets first node beneath node that has a matching css class.

Gets first node beneath node that has a matching css class.

Name Type Description
clazz String

The class to look for.

Returns:
Type Description
GoBrain.Node | null

getNodeById(id){GoBrain.Node|null}

GoBrain.Core/src/node.js, line 280

Gets first node beneath node that has a matching id.

Gets first node beneath node that has a matching id.

Name Type Description
id String

The id to look for.

Returns:
Type Description
GoBrain.Node | null

getNodesByAttributeAndValue(attribute, value){Array.<GoBrain.Node>}

GoBrain.Core/src/node.js, line 294

Gets all nodes beneath node that have a matching attribute value pair.

Gets all nodes beneath node that have a matching attribute value pair.

Name Type Description
attribute String

The attribute to look for.

value String

The attribute value to look for.

Returns:
Type Description
Array.<GoBrain.Node>

getNodesByClass(clazz){Array.<GoBrain.Node>}

GoBrain.Core/src/node.js, line 313

Gets all nodes beneath node that have a matching css class.

Gets all nodes beneath node that have a matching css class.

Name Type Description
clazz String

The class to look for.

Returns:
Type Description
Array.<GoBrain.Node>

getNodesById(id){Array.<GoBrain.Node>}

GoBrain.Core/src/node.js, line 331

Gets all nodes beneath node that have a matching id.

Gets all nodes beneath node that have a matching id.

Name Type Description
id String

The id to look for.

Returns:
Type Description
Array.<GoBrain.Node>

hasAncestor(ancestor){Boolean}

GoBrain.Core/src/node.js, line 349

Checks if the node has a specific element as ancestor.

Checks if the node has a specific element as ancestor.

Name Type Description
ancestor GoBrain.Node | HTMLElement

The potential ancestor to check against.

Returns:
Type Description
Boolean

hasAttribute(attribute){Boolean}

GoBrain.Core/src/node.js, line 365

Checks if the node has a specific attribute.

Checks if the node has a specific attribute.

Name Type Description
attribute String

The attribute to look for.

Returns:
Type Description
Boolean

hasChild(child){Boolean}

GoBrain.Core/src/node.js, line 381

Checks if the node has a specific element as first level child.

Checks if the node has a specific element as first level child.

Name Type Description
child GoBrain.Node | HTMLElement

The potential child to check against.

Returns:
Type Description
Boolean

hasClass(clazz){Boolean}

GoBrain.Core/src/node.js, line 397

Checks if the node has a specific css class.

Checks if the node has a specific css class.

Name Type Description
clazz String

The css class to look for.

Returns:
Type Description
Boolean

hasDescendant(descendant){Boolean}

GoBrain.Core/src/node.js, line 423

Checks if the node has a specific element as descendant.

Checks if the node has a specific element as descendant.

Name Type Description
descendant GoBrain.Node | HTMLElement

The potential descendant to check against.

Returns:
Type Description
Boolean

height(value){GoBrain.Node|Number}

GoBrain.Core/src/node.js, line 450

Gets or sets the node height.

Gets or sets the node height.

Name Type Description
value Number | String optional

The new height.

Returns:
Type Description
GoBrain.Node | Number

hide(){GoBrain.Node}

GoBrain.Core/src/node.js, line 473

Hides the node.

Hides the node.

Returns:
Type Description
GoBrain.Node

innerContent(content){GoBrain.Node|*}

GoBrain.Core/src/node.js, line 492

Gets or sets node inner content.

Gets or sets node inner content.

Name Type Description
content * optional

The content to set.

Returns:
Type Description
GoBrain.Node | *

insertAfter(element){GoBrain.Node}

GoBrain.Core/src/node.js, line 514

Inserts a node/element after the node.

Inserts a node/element after the node.

Name Type Description
element GoBrain.Node | HTMLElement

The node element to insert.

Returns:
Type Description
GoBrain.Node

insertBefore(element){GoBrain.Node}

GoBrain.Core/src/node.js, line 530

Inserts a node/element before the node.

Inserts a node/element before the node.

Name Type Description
element GoBrain.Node | HTMLElement

The node element to insert.

Returns:
Type Description
GoBrain.Node

matches(selector){Boolean}

GoBrain.Core/src/node.js, line 546

Checks if the node matches a selector.

Checks if the node matches a selector.

Name Type Description
selector String

The selector to check against.

Returns:
Type Description
Boolean

nextSibling(){GoBrain.Node|null}

GoBrain.Core/src/node.js, line 581

Gets the node's next sibling.

Gets the node's next sibling.

Returns:
Type Description
GoBrain.Node | null

parent(){GoBrain.Node}

GoBrain.Core/src/node.js, line 596

Gets the node's parent node.

Gets the node's parent node.

Returns:
Type Description
GoBrain.Node

previousSibling(){GoBrain.Node|null}

GoBrain.Core/src/node.js, line 611

Gets the node's previous sibling.

Gets the node's previous sibling.

Returns:
Type Description
GoBrain.Node | null

query(query){Array.<GoBrain.Node>}

GoBrain.Core/src/node.js, line 626

Gets all nodes beneath node that have a matching query.

Gets all nodes beneath node that have a matching query.

Name Type Description
query String

The query to look for.

Returns:
Type Description
Array.<GoBrain.Node>

remove(){null}

GoBrain.Core/src/node.js, line 644

Removes the node.

Removes the node.

Returns:
Type Description
null

removeChild(child){GoBrain.Node}

GoBrain.Core/src/node.js, line 661

Removes a child from the node.

Removes a child from the node.

Name Type Description
child GoBrain.Node | HTMLElement

The child to remove.

Returns:
Type Description
GoBrain.Node

removeClass(clazz){GoBrain.Node}

GoBrain.Core/src/node.js, line 677

Removes a css class from the node.

Removes a css class from the node.

Name Type Description
clazz String

The css class to remove.

Returns:
Type Description
GoBrain.Node

removeEventListener(event, handler, options){GoBrain.Node}

GoBrain.Core/src/node.js, line 695

Removes an event listener.

Removes an event listener.

Name Type Description
event String

Event to remove listener from.

handler function

Handler to remove.

options Boolean | Object

Options to use to remove the event handler. If boolean, whether or not to remove passive handler, if supported.

Returns:
Type Description
GoBrain.Node

show(){GoBrain.Node}

GoBrain.Core/src/node.js, line 725

Shows the node.

Shows the node.

Returns:
Type Description
GoBrain.Node

style(property, value){GoBrain.Node|*}

GoBrain.Core/src/node.js, line 740

Gets or sets a node style property.

Gets or sets a node style property.

Name Type Description
property String

The style property name.

value * optional

The style property value.

Returns:
Type Description
GoBrain.Node | *

toggleClass(clazz){GoBrain.Node}

GoBrain.Core/src/node.js, line 797

Toggles a css class, if the node has the class it will be removed otherwise it will be added.

Toggles a css class, if the node has the class it will be removed otherwise it will be added.

Name Type Description
clazz String

The css class to toggle.

Returns:
Type Description
GoBrain.Node

width(value){GoBrain.Node|Number}

GoBrain.Core/src/node.js, line 817

Gets or sets the node width.

Gets or sets the node width.

Name Type Description
value Number | String optional

The new width.

Returns:
Type Description
GoBrain.Node | Number