Namespace: Firebolt

Firebolt

The Firebolt namespace object and selector function. Can also be referenced by the synonyms FB and $ (if $ has not already been defined).

Properties:
Name Type Description
fn Object

Alias for NodeCollection.prototype.

Source:

Methods

<static> _GET() → {Object.<String, String>}

Returns a PHP-style associative array (Object) of URL parameters and updates the global $_GET object at the same time.

Source:
See:
Returns:
Type
Object.<String, String>

<static> ajax(url, settings) → {XMLHttpRequest}

Perform an asynchronous HTTP (AJAX) request.
Parameters:
Name Type Argument Description
url String

A string containing the URL to which the request will be sent.

settings Object <optional>

A set of key-value pairs that configure the Ajax request. All settings are optional.

For more information on the settings parameter, see the next $.ajax section.

Source:
Returns:
Type
XMLHttpRequest

The XMLHttpRequest object this request is using (only for requests where the dataType is not "script").

<static> ajax(settings) → {XMLHttpRequest}

Perform an asynchronous HTTP (AJAX) request.
Parameters:
Name Type Argument Description
settings Object <optional>

A set of key-value pairs that configure the Ajax request. All settings are optional.

The settings object can be used to configure the AJAX request beyond the default functionality. Details for the settings provided by Firebolt's basic AJAX module are as follows:


async true
Type: Boolean
By default, all requests are sent asynchronously. If you need synchronous requests, set this option to false. Cross-domain requests requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.
beforeSend
Type: Function(XMLHttpRequest xhr, Object settings)
A pre-request callback function that can be used to modify the XMLHttpRequest object before it is sent. Use this to set custom headers, etc. The XMLHttpRequest and settings objects are passed as arguments. Returning false in the beforeSend function will cancel the request.
cache true, false for dataType 'script'
Type: Boolean
If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_=[TIMESTAMP]" to the GET parameters. The parameter is not needed for other types of requests.
complete
Type: Function(XMLHttpRequest xhr, String textStatus)
A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed two arguments: The XMLHttpRequest object and a string categorizing the status of the request ("success", "nocontent", "error", "timeout", "abort", or "parsererror").
contentType 'application/x-www-form-urlencoded; charset=UTF-8'
Type: String
When sending data to the server, use this content type. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding. Note: For cross-domain requests, setting the content type to anything other than "application/x-www-form-urlencoded", "multipart/form-data", or "text/plain" will trigger the browser to send a preflight OPTIONS request to the server.
crossDomain false for same-domain requests, true for cross-domain requests
Type: Boolean
If you wish to force a cross-domain request on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain. Note: this setting essentially does nothing if dataType is anything other than "script".
data
Type: String, Object, or Array
Data to be sent to the server. It is appended to the URL for all non-POST requests and sent in the body of the request for POST requests. If it is a plain object or array, it is converted to a query string. How Firebolt serializes data to a query string is determined by the traditional setting (described below). Note: only plain objects and true arrays are serialized. Firebolt will attempt to send any other object (e.g. FormData) as-is.
dataType Intelligent Guess (xml, json, script, or html)
Type: String
The type of data that you're expecting back from the server. If none is specified, Firebolt will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, JSON will yield a JavaScript object, script will execute the script, and anything else will be returned as a string). The available types (and the result passed as the first argument to the success callback) are:
  • "xml": Returns an XML document.
  • "html": Returns HTML as plain text.
  • "script": Evaluates the response as JavaScript and returns it as plain text. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the cache option is set to true. Note: This will turn all request types into GETs for cross-domain requests.
  • "json": Evaluates the response as JSON and returns a JavaScript object. The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. For example, an empty response will cause an error; the server should return a response of null or {} instead.
  • "text": A plain text string.

error
Type: Function(XMLHttpRequest xhr, String textStatus[, Exception error])
A function to be called if the request fails. The function receives three arguments: The XMLHttpRequest object, a string describing the type of error that occurred, and an optional exception object, if one occurred. Possible values for the second argument are "timeout", "error", "abort", and "parsererror".
headers {}
Type: Object
An object of header key-value pairs to send along with requests using the XMLHttpRequest transport.
isLocal depends on current location protocol
Type: Boolean
Allow the current environment to be recognized as "local," (e.g. the filesystem), even if Firebolt does not recognize it as such by default. The following protocols are currently recognized as local: file, *-extension, and widget. If the isLocal setting needs modification, it is recommended to do so once in the $.ajaxSetup() method.
mimeType
Type: String
A mime type to override the XMLHttpRequest mime type.
password
Type: String
A password to be sent with the XMLHttpRequest in response to a HTTP access authentication request.
scriptCharset
Type: String
Only applies when the "script" transport is used (e.g., cross-domain requests with "script" dataType and "GET" type). Sets the charset attribute on the script tag used in the request. Used when the character set on the local page is not the same as the one on the remote script.
success
Type: Function(* data, String textStatus, XMLHttpRequest xhr)
A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, a string describing the status, and the XMLHttpRequest object. Possible values for the second argument are "success", and "nocontent".
timeout
Type: Number
Set a timeout (in milliseconds) for the request. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax() call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. The XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. Note:, cross-domain "script" requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period.
traditional false
Type: Boolean
Set this to true if you wish to use the traditional style of param serialization.
type 'GET'
Type: String
The type of request to make (e.g. "POST", "GET", "PUT", "HEAD", "DELETE"). The string should be in ALL CAPS.
url the current page
Type: String
A string containing the URL to which the request is sent.
username
Type: String
A username to be sent with the XMLHttpRequest in response to a HTTP access authentication request.
xhrFields
Type: Object
An object of fieldName-fieldValue pairs to set on the XMLHttpRequest object. For example, you can use it to set withCredentials to true for cross-domain requests if needed.
$.ajax({
  url: a_cross_domain_url,
  xhrFields: {
    withCredentials: true
  }
});

To get even more AJAX features (such as JSONP support), use the Firebolt AJAX extension.

Source:
Returns:
Type
XMLHttpRequest

The XMLHttpRequest object this request is using (only for requests where the dataType is not "script").

<static> ajaxSetup(options)

Sets default values for future Ajax requests. Use of this function is not recommended.

Parameters:
Name Type Description
options Object

A set of key-value pairs that configure the default Ajax settings. All options are optional.

Source:

<static> data(object) → {Object}

Gets the object's stored data object.

Regarding HTML5 data-* attributes: This method does NOT retrieve the data-* attributes unless the .data() method has already retrieved them.

Parameters:
Name Type Description
object Object

An object. This can be anything that has Object in its prototype chain.

Source:
Returns:
Type
Object

The object's stored data object.

<static> data(object, key) → {*}

Get the value at the named data store for the object as set by Firebolt.data(key, value).

Regarding HTML5 data-* attributes: This method does NOT retrieve the data-* attributes unless the .data() method has already retrieved them.

Parameters:
Name Type Description
object Object

An object. This can be anything that has Object in its prototype chain.

key String

The name of the stored data.

Source:
Returns:
Type
*

The value of the stored data.

<static> data(object, key, value) → {Object}

Stores arbitrary data associated with the object.

Note: When setting data properties, Firebolt will camelize dashed key names. For example, when setting data with the key foo-bar, Firebolt will add the data to the element's stored data object with the key fooBar.

Parameters:
Name Type Description
object Object

An object. This can be anything that has Object in its prototype chain.

key String

A string naming the data to set.

value *

Any arbitrary data to store.

Source:
Returns:
Type
Object

The passed in object.

<static> data(object, data) → {Object}

Stores arbitrary data associated with the object.

Note: When setting data properties, Firebolt will camelize dashed key names. For example, when setting data with the key foo-bar, Firebolt will add the data to the element's stored data object with the key fooBar.

Parameters:
Name Type Description
object Object

An object. This can be anything that has Object in its prototype chain.

data Object

An object of key-value pairs to add to the object's stored data.

Source:
Returns:
Type
Object

The passed in object.

<static> elem(tagName, attributes) → {Element}

Creates a new element with the specified tag name and attributes (optional).
Partially an alias of document.createElement().

Parameters:
Name Type Argument Description
tagName String
attributes Object <optional>

The JSON-formatted attributes that the element should have once constructed.

Source:
Returns:
Type
Element

<static> extend(deep, target, objectN) → {Object}

Merge the contents of one or more objects into the first object.
Parameters:
Name Type Argument Description
deep Boolean <optional>

If true, the merge becomes recursive (performs a deep copy).

target Object

The object that will receive the new properties.

objectN Object <repeatable>

One or more objects whose properties will be added to the target object.

Warning: Providing false for the deep argument is not supported.

Source:
Returns:
Type
Object

The target object.

<static> frag(content) → {DocumentFragment}

Creates a new DocumentFragment and (optionally) appends the passed in content to it.

Parameters:
Name Type Argument Description
content String | Node | Array.<Node> <optional>
<repeatable>

One or more HTML strings, nodes, or collections of nodes to append to the fragment.

Source:
Returns:
Type
DocumentFragment

The newly created document fragment.

<static> get(url, data, success(data, textStatus, xhr), dataType)

Load data from the server using a HTTP GET request.

Parameters:
Name Type Argument Description
url String

A string containing the URL to which the request will be sent.

data String | Object <optional>

A string or object that is sent to the server with the request as a query string.

success(data, textStatus, xhr) function <optional>

A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.

dataType String <optional>

The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).

Source:

<static> getJSON(url, data, success(data, textStatus, xhr))

Load JSON-encoded data from the server using a HTTP GET request.

Parameters:
Name Type Argument Description
url String

A string containing the URL to which the request will be sent.

data String | Object <optional>

A string or object that is sent to the server with the request as a query string.

success(data, textStatus, xhr) function <optional>

A callback function that is executed if the request succeeds.

Source:

<static> getScript(url, success(data, textStatus, xhr))

Load a JavaScript file from the server using a HTTP GET request, then execute it.

Parameters:
Name Type Argument Description
url String

A string containing the URL to which the request will be sent.

success(data, textStatus, xhr) function <optional>

A callback function that is executed if the request succeeds.

Source:

<static> globalEval(code)

Executes some JavaScript code globally.

Parameters:
Name Type Description
code String

The JavaScript code to execute.

Source:

<static> hasData(object) → {Boolean}

Determines if the object has any Firebolt data associated with it.

Parameters:
Name Type Description
object Object

An object. This can be anything that has Object in its prototype chain.

Source:
Returns:
Type
Boolean

true if the object has stored Firebolt data; else false.

<static> isEmpty(value) → {Boolean}

Determines if the passed in value is considered empty. The value is considered empty if it is one of the following:

  • null
  • undefined
  • a zero-length string, array, NodeList, HTMLCollection, or NodeCollection
  • an empty object (if the value has the "Object" class and Firebolt.isEmptyObject returns true)
Parameters:
Name Type Description
value *

The value to be tested.

Source:
Returns:
Type
Boolean
  • true if the object is deemed empty, false otherwise.

<static> isEmptyObject(object) → {Boolean}

Determines if an object is empty (contains no enumerable properties).

Parameters:
Name Type Description
object Object

The object to be tested.

Source:
Returns:
Type
Boolean

<static> isPlainObject(obj)

Determines if a variable is a plain object.

Parameters:
Name Type Description
obj *

The item to test.

Source:

<static> param(obj, traditional) → {String}

Creates a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
Unlike jQuery, arrays will be serialized like objects when traditional is not true, with the indices of the array becoming the keys of the query string parameters.

Parameters:
Name Type Description
obj Array | Object

An array or object to serialize.

traditional Boolean

A Boolean indicating whether to perform a traditional "shallow" serialization.

Source:
Returns:
Type
String

The serialized string representation of the array or object.

<static> parseHTML(html, context, single) → {NodeCollection|Node}

Parses a string into an array of DOM nodes.

Note: <script> elements created with this function will not have their code executed. If you desire this functionality, create a <script> with Firebolt.elem, set its textContent property to the script string you want to execute, then add the element to the document.

Parameters:
Name Type Argument Default Description
html String

HTML string to be parsed.

context Document <optional>
document

A DOM Document to serve as the context in which the nodes will be created.

single Boolean <optional>

If truthy, returns only a single Node instead of a NodeCollection. If this parameter is specified, you must also pass in a value for context (but it can just be falsy to use the default value).

Source:
Returns:
Type
NodeCollection | Node

The collection of created nodes (or single Node if single was truthy).

<static> post(url, data, success(data, textStatus, xhr), dataType)

Load data from the server using a HTTP POST request.

Parameters:
Name Type Argument Description
url String

A string containing the URL to which the request will be sent.

data String | Object <optional>

A string or object that is sent to the server with the request.

success(data, textStatus, xhr) function <optional>

A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.

dataType String <optional>

The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).

Source:

<static> ready(callback)

Specify a function to execute when the DOM is fully loaded.
Executes the function immediately (synchronously) if the DOM has already finished loading.

Parameters:
Name Type Description
callback function

A function to execute once the DOM has been loaded.

Source:

<static> removeData(object, name)

Removes a previously stored piece of Firebolt data from an object.
When called without any arguments, all data is removed.

Parameters:
Name Type Argument Description
object Object

An object. This can be anything that has Object in its prototype chain.

name String <optional>

The name of the data to remove.

Source:

<static> removeData(object, list)

Removes previously stored Firebolt data from an object.
When called without any arguments, all data is removed.

Parameters:
Name Type Argument Description
object Object

An object. This can be anything that has Object in its prototype chain.

list Array | String <optional>

An array or space-separated string naming the pieces of data to remove.

Source:

<static> text(text) → {TextNode}

Creates a TextNode from the provided string.

Parameters:
Name Type Description
text String

The string used to construct the TextNode.

Source:
Returns:
Type
TextNode