Module: deliteful/ProgressBar

deliteful/ProgressBar

require(["deliteful/ProgressBar"], function (ProgressBar) {
  new ProgressBar();
});

A widget that displays the completion progress of a task.

The progress is either indeterminate, indicating that progress is being made but that it is not clear how much more work remains to be done before the task is complete, or the progress is a number in the range zero to a maximum, giving the fraction of work that has so far been completed.

There are two properties that determine the current task completion represented by the element. The value property specifies how much of the task has been completed, and the max property specifies how much work the task requires in total. The units are arbitrary and not specified.

When the progress bar is determinate, a default message displays the percentage of progression. The property fractionDigits allows to specify the number of fraction digits to display. You can set a custom message using the message property, or override the method formatMessage to generate a dynamic custom message.

When the progress bar is indeterminate, use the message property to display a message.

Source:

Extends

Show inherited

Members

<protected> _started :boolean

Set to true when startup() has completed.

Type:
  • boolean
Inherited From:
Source:

baseClass :string

The name of the CSS class of this widget.

Type:
  • string
Default Value:
  • "d-progress-bar"
Source:

displayExtMsg :boolean

Allow to set an additional message. Depending on the theme it may not be displayed. For themes that display both messages, typically message is on one side and the additional message is on the other side. By default the additional message is in the form value/max. Ex: [65%........379/583] or [Loading......379/583]. You may customize it by overriding the method formatExtMsg.

Type:
  • boolean
Default Value:
  • false
Source:

<protected> focused :boolean

This widget or a widget it contains has focus, or is "active" because it was recently clicked.

Type:
  • boolean
Inherited From:
Default Value:
  • false
Source:

fractionDigits :number

Number of places to show on the default message displayed when the progress bar is determinate.

Type:
  • number
Default Value:
  • 0
Source:

max :number

A number which express the task as completed. The max property must be a valid positive floating-point number, otherwise it is converted to 1.0.

Type:
  • number
Default Value:
  • 1.0
Source:

message :string

Allow to specify/override the message on the progress bar whether it's determinate or indeterminate. The default behavior of the ProgressBar is to displays the percentage of completion when the state is determinate, and to display no message when state is indeterminate. You can override this with the message property. Set an empty string to restore the default behavior.

Type:
  • string
Default Value:
  • ""
Source:

<readonly> position :number

Indicates the relative position of the current value relative to the maximum value (max). If the progress bar is an indeterminate progress bar, then the position is −1. Otherwise, it is the result of dividing the current value by the maximum value.

Type:
  • number
Default Value:
  • -1
Source:

<protected> template :function

Value returned by delite/handlebars! or compatible template engine. Specifies how to build the widget DOM initially and also how to update the DOM when widget properties change.

Type:
  • function
Inherited From:
Source:

value :number

A number indicating the amount of completion of a task. The value property must be a valid floating-point number or NaN. Set the value to NaN to make the progress bar indeterminate. Set a value comprised between 0 and the max property to make the progress bar determinate. A value greater than max is converted to the max value. An invalid or negative value is converted to 0.

Type:
  • number
Default Value:
  • NaN
Source:

<protected, constant> widgetId :number

Unique id for this widget, separate from id attribute (which may or may not be set). Useful when widget creates subnodes that need unique id's.

Type:
  • number
Inherited From:
Source:

Methods

<protected> _get(name) → {*}

Internal helper for directly accessing an attribute value.

Directly get the value of an attribute on an object, bypassing any accessor getter. It is designed to be used by descendant class if they want to access the value in their custom getter before returning it.

Parameters:
Name Type Description
name string

Name of property.

Inherited From:
Source:
Returns:

Value of property.

Type
*

<protected> _onBlur()

This is where widgets do processing for when they stop being active, such as changing CSS classes. See onBlur() for more details.

Inherited From:
Source:

<protected> _onFocus()

This is where widgets do processing for when they are active, such as changing CSS classes. See onFocus() for more details.

Inherited From:
Source:

<protected> _parseAttr(name, value)

Helper for _mapAttributes(). Interpret a given attribute specified in markup, returning either:

  • undefined: ignore
  • {prop: prop, value: value}: set this[prop] = value
  • {event: event, callback: callback}: call this.on(event, callback);
Parameters:
Name Type Description
name string

Attribute name.

value string

Attribute value.

Inherited From:
Source:

<protected> _parseFunctionAttr(value, params)

Helper to parse function attribute in markup. Unlike _parsePrototypeAttr(), does not require a corresponding widget property. Functions can be specified as global variables or as inline javascript:

Parameters:
Name Type Description
value string

Value of the attribute.

params Array.<string>

When generating a function from inline javascript, give it these parameter names.

Inherited From:
Source:

<protected> _set(name, value)

Internal helper for directly setting a property value without calling the custom setter.

Directly change the value of an attribute on an object, bypassing any accessor setter. Also notifies callbacks registered via observe(). Custom setters should call _set to actually record the new value.

Parameters:
Name Type Description
name string

The property to set.

value *

Value to set the property to.

Inherited From:
Source:

<protected> attachedCallback()

Called when the widget is first inserted into the document. If widget is created programatically then app must call startup() to trigger this method.

Inherited From:
Source:

<protected> buildRendering()

Construct the UI for this widget, filling in subnodes and/or text inside of this. Most widgets will leverage delite/handlebars! to set template, rather than defining this method.

Inherited From:
Source:

computeProperties(newValues, oldValues)

Callback function to calculate computed properties upon property changes.

Parameters:
Name Type Description
newValues Object

The hash table of new property values, keyed by property names.

oldValues Object

The hash table of old property values, keyed by property names.

Inherited From:
Source:

<protected> createdCallback()

Kick off the life-cycle of a widget.

Calls a number of widget methods (preCreate(), buildRendering(), and postCreate()), some of which of you'll want to override.

Of course, adventurous developers could override createdCallback entirely, but this should only be done as a last resort.

Inherited From:
Source:

<protected> defer(fcn, delay) → {Object}

Wrapper to setTimeout to avoid deferred functions executing after the originating widget has been destroyed.

Parameters:
Name Type Description
fcn function

Function to be executed after specified delay (or 0ms if no delay specified).

delay number

Delay in ms, defaults to 0.

Inherited From:
Source:
Returns:

Handle with a remove method that deschedules the callback from being called.

Type
Object

deliver()

Synchronously deliver change records for computed properties and then UI rendering so that refreshingRendering() is called if there are pending change records.

Inherited From:
Source:

deliverComputing()

Synchronously deliver change records for computed properties so that refreshingComputing() is called if there are pending change records.

Inherited From:
Source:

destroy()

Destroy this widget and its descendants.

Inherited From:
Source:

discardChanges()

Discard change records.

Inherited From:
Source:

discardComputing()

Discard change records for computed properties.

Inherited From:
Source:

<protected> emit(type, eventObj) → {boolean}

Signal that a synthetic event occurred.

Emits an event of specified type, based on eventObj. Also calls onType() method, if present, and returns value from that method. Modifies eventObj by adding missing parameters (bubbles, cancelable, widget).

Parameters:
Name Type Argument Description
type string

Name of event.

eventObj Object <optional>

Properties to mix in to emitted event.

Inherited From:
Source:
Returns:

True if the event was not canceled, false if it was canceled.

Type
boolean
Example
myWidget.emit("query-success", {});

findCustomElements(root)

Search subtree under root returning custom elements found.

Parameters:
Name Type Argument Description
root Element <optional>

Node to search under.

Inherited From:
Source:

formatExtMsg(position, value, max) → {string}

Formats and returns the extra message to display when the property displayExtMsg is enabled. Returns a string formatted with "value/max". May be overridden to customize the extra message.

Parameters:
Name Type Description
position number

Position of the current value relative to the maximum value (from 0.0 to 1.0).

value number

The amount of completion of the task.

max number

The value that express the task is completed (maximum value).

Source:
Returns:

The extra message to display.

Type
string

formatMessage(position, value, max) → {string}

Formats and returns a message to display inside/beside the progress bar (depends on theme settings). If a custom message is specified with the message property, it is returned as-is. Otherwise if the progress bar is determined (value is not NaN), it returns the percentage of progression formatted in respect with fractionDigits. This method is called when the value and/or the max property changes. May be overridden to customize the message.

Parameters:
Name Type Description
position number

Position of the current value relative to the maximum value (from 0.0 to 1.0).

value number

The amount of completion of the task.

max number

The value that express the task is completed (maximum value).

Source:
Returns:

The message to display.

Type
string

getEnclosingWidget(node)

Returns the widget whose DOM tree contains the specified DOMNode, or null if the node is not contained within the DOM tree of any widget

Parameters:
Name Type Description
node Element
Inherited From:
Source:

getParent()

Returns the parent widget of this widget.

Inherited From:
Source:

<protected> isLeftToRight() → {boolean}

Return this widget's explicit or implicit orientation (true for LTR, false for RTL).

Inherited From:
Source:
Returns:
Type
boolean

mix(hash)

Set a hash of properties on a Stateful instance.

Parameters:
Name Type Description
hash Object

Hash of properties.

Inherited From:
Source:
Example
myObj.mix({
    foo: "Howdy",
    bar: 3
});

notifyCurrentValue(name)

Notify current value to observers. Handy to manually schedule invocation of observer callbacks when there is no change in value.

Parameters:
Name Type Description
name string

The property name.

Inherited From:
Source:

observe(callback) → {module:decor/Stateful.PropertyListObserver}

Observe for change in properties. Callback is called at the end of micro-task of changes with a hash table of old values keyed by changed property. Multiple changes to a property in a micro-task is squashed .

Parameters:
Name Type Description
callback function

The callback.

Inherited From:
Source:
Returns:

The observer that can be used to stop observation or synchronously deliver/discard pending change records.

Type
module:decor/Stateful.PropertyListObserver
Example
var stateful = new (dcl(Stateful, {
        foo: undefined,
        bar: undefined,
        baz: undefined
    }))({
        foo: 3,
        bar: 5,
        baz: 7
    });
stateful.observe(function (oldValues) {
    // oldValues is {foo: 3, bar: 5, baz: 7}
});
stateful.foo = 4;
stateful.bar = 6;
stateful.baz = 8;
stateful.foo = 6;
stateful.bar = 8;
stateful.baz = 10;

on(type, func, node) → {Object}

Call specified function when event occurs.

Note that the function is not run in any particular scope, so if (for example) you want it to run in the widget's scope you must do myWidget.on("click", myWidget.func.bind(myWidget)).

Parameters:
Name Type Argument Description
type string | function

Name of event (ex: "click") or extension event like touch.press.

func function

Callback function.

node Element <optional>

Element to attach handler to, defaults to this.

Inherited From:
Source:
Returns:

Handle with remove() method to cancel the event.

Type
Object

onBlur()

Called when the widget stops being "active" because focus moved to something outside of it, or the user clicked somewhere outside of it, or the widget was hidden.

Inherited From:
Source:

onFocus(evt)

Called when the widget becomes "active" because it or a widget inside of it either has focus, or has recently been clicked.

Parameters:
Name Type Description
evt Event

A focus event.

Inherited From:
Source:

<protected> own() → {Array.<Object>}

Track specified handles and remove/destroy them when this instance is destroyed, unless they were already removed/destroyed manually.

Inherited From:
Source:
Returns:

The array of specified handles, so you can do for example: var handle = this.own(on(...))[0];

Type
Array.<Object>

<protected> placeAt(reference, position) → {module:delite/Widget}

Place this widget somewhere in the dom, and allow chaining.

Parameters:
Name Type Argument Description
reference string | Element | DocumentFragment

Element, DocumentFragment, or id of Element to place this widget relative to.

position string | number <optional>

Numeric index or a string with the values:

  • number - place this widget as n'th child of reference node
  • "first" - place this widget as first child of reference node
  • "last" - place this widget as last child of reference node
  • "before" - place this widget as previous sibling of reference node
  • "after" - place this widget as next sibling of reference node
  • "replace" - replace specified reference node with this widget
  • "only" - replace all children of reference node with this widget
Inherited From:
Source:
Returns:

This widget, for chaining.

Type
module:delite/Widget
Examples
// create a Button with no srcNodeRef, and place it in the body:
var button = new Button({ label:"click" }).placeAt(document.body);
// place a new button as the first element of some div
var button = new Button({ label:"click" }).placeAt("wrapper","first");
// create a contentpane and add it to a TabContainer
var tc = document.getElementById("myTabs");
new ContentPane({ href:"foo.html", title:"Wow!" }).placeAt(tc)

<protected> postCreate()

Processing after the DOM fragment is created.

Called after the DOM fragment has been created, but not necessarily added to the document. Do not include any operations which rely on node dimensions or placement.

Inherited From:
Source:

<protected> preCreate()

Processing before buildRendering().

Inherited From:
Source:

<protected> processConstructorParameters()

Called after Object is created to process parameters passed to constructor.

Inherited From:
Source:

refreshRendering(newValues, oldValues)

Callback function to render UI upon property changes.

Parameters:
Name Type Description
newValues Object

The hash table of new property values, keyed by property names.

oldValues Object

The hash table of old property values, keyed by property names.

Inherited From:
Source:

<protected> setClassComponent(component, value, node)

Helper method to set a class (or classes) on a given node, removing the class (or classes) set by the previous call to setClassComponent() for the specified component and node. Used mainly by template.js to set classes without overwriting classes set by the user or other code (ex: CssState).

Parameters:
Name Type Argument Description
component string

Specifies the category.

value string

Class (or classes) to set.

node HTMLElement <optional>

The node to set the property on; defaults to widget root node.

Inherited From:
Source:

<protected> setOrRemoveAttribute(node, name, value)

Helper method to set/remove an attribute based on the given value:

  • If value is undefined, the attribute is removed. Useful for attributes like aria-valuenow.
  • If value is boolean, the attribute is set to "true" or "false". Useful for attributes like aria-selected.
  • If value is a number, it's converted to a string.
Parameters:
Name Type Description
node Element

The node to set the property on.

name string

Name of the property.

value string

Value of the property.

Inherited From:
Source:

startup()

Processing after the DOM fragment is added to the document.

Called after a widget and its children have been created and added to the page, and all related widgets have finished their create() cycle, up through postCreate().

Note that startup() may be called while the widget is still hidden, for example if the widget is inside a hidden deliteful/Dialog or an unselected tab of a deliteful/TabContainer. For widgets that need to do layout, it's best to put that layout code inside resize(), and then extend delite/LayoutWidget so that resize() is called when the widget is visible.

Inherited From:
Source: