Have questions? Stuck? Please check our FAQ for some common questions and answers.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This page is a work in progress.

ButtonService

ButtonService is an Angular Factory in the Widget module with the name button.js. It provides an API to create buttons, toggles, and radio button sets. To use these functions, see the documentation on injecting Angular services.

NameSummary
buttonCreates a button.
toggleCreates a toggle.
radioSetCreates a radio button set.

Function Descriptions

button

Creates a button – an element that executes a function when clicked.

Example UsageArgumentsReturn Value
bns.button(div, id, gid, cb, tooltip);

div - d3 selection of the div that the button will be in

id - globally unique button ID string

gid - the glyph ID string to be used for the button

cb - the function to be executed when the button is clicked

tooltip - (optional) string of tooltip to appear on hover

creates a button with the given information

returns an object with an API:

id - the string with the button ID

width - function that computes the width of the button plus padding in pixels as a number

An example of a button is the Reset pan / zoom button on the Topology View.

When clicked, the pan and zoom of the Topology View is reset to the default. This is an example of an "execute once" type of function, which is what buttons are for. Also shown is the tooltip.

toggle

Creates a toggle – an element that has state (selected or unselected) that executes a function on click.

Example UsageArgumentsReturn Value
bns.toggle(div, id, gid, initState, cb, tooltip);

div - d3 selection of the div that the toggle will be in

id - globally unique button ID string

gid - the glyph ID string to be used for the toggle

initState - whether the toggle should be "selected" or "unselected" to begin with. Truthy values will be active and falsy values will be inactive.

cb - the function to be executed when the toggle is clicked

tooltip - (optional) string of tooltip to appear on hover

creates a toggle with the given information

returns an object with an API:

id - the string with the button ID

width - function that computes the width of the toggle plus padding in pixels as a number

selected - function that returns whether the toggle is currently selected – true for selected, false for unselected

... more to come

 

radioSet

Creates a radio button set – set of one or more elements that have state (one is active at a time) that executes a function when one is clicked.

 

 

 

  • No labels