Show:

F2.ContainerConfig Class

An object containing configuration information for the container

Methods

Name Description
xhr (
  • url
  • appConfigs
  • success
  • error
  • complete
)

Allows the container to fully override how the AppManifest request is made inside of F2.

xhr.dataType (
  • url
  • appConfigs
)

Allows the container to override the request data type (JSON or JSONP) that is used for the request

xhr.type (
  • url
  • appConfigs
)

Allows the container to override the request method that is used.

xhr.url (
  • url
  • appConfigs
)

Allows the container to override the url that is used to request an app's F2.F2.AppManifest

Properties

Name Description
debugMode

True to enable debug mode in F2.js. Adds additional logging, resource cache busting, etc.

loadScripts

Allows the container to override the script loader which requests dependencies defined in the F2.AppManifest.

loadStyles

Allows the container to override the stylesheet loader which requests dependencies defined in the F2.AppManifest.

locale

The default language and region specification for this container represented as an IETF-defined standard language tag, e.g. "en-us" or "de-de". This value is passed to each app registered as containerLocale.

scriptErrorTimeout

Milliseconds before F2 fires callback on script resource load errors. Due to issue with the way Internet Explorer attaches load events to script elements, the error event doesn't fire.

xhr

Allows the container to override individual parts of the AppManifest request. See properties and methods with the xhr. prefix.

Methods

xhr (
  • url
  • appConfigs
  • success
  • error
  • complete
)

Allows the container to fully override how the AppManifest request is made inside of F2.

Parameters:

  • url String

    The manifest url

  • appConfigs Array

    An array of F2.AppConfig objects

  • success Function

    The function to be called if the request succeeds

  • error Function

    The function to be called if the request fails

  • complete Function

    The function to be called when the request finishes (after success and error callbacks have been executed)

Returns:

XMLHttpRequest:

The XMLHttpRequest object

Example:

F2.init({          xhr: function(url, appConfigs,successCallback, errorCallback, completeCallback) {           var jsonpCallback = F2.Constants.JSONP_CALLBACK + appConfigs[0].appId, // Unique function name var fetchUrl = url + '?params=' + F2.stringify(appConfigs.apps, F2.appConfigReplacer);           var fetchFunc = fetchJsonp(fetchUrl, {                           timeout: 3000,                           jsonpCallbackFunction: jsonpCallback                           });            fetchFunc.then(function(response) {                           return response.json();                       })                       .then(function(data) {                        successCallback(data);                        completeCallback();                   })                   .catch(function(error) {                       F2.log('Failed to load app(s)', error.toString());                       errorCallback();                   });          }      });


xhr.dataType (
  • url
  • appConfigs
)

Allows the container to override the request data type (JSON or JSONP) that is used for the request

Parameters:

  • url String

    The manifest url

  • appConfigs Array

    An array of F2.AppConfig objects

Returns:

String:

The request data type that should be used

Example:

F2.init({
	                                        xhr: {
	                                            dataType: function(url) {
	                                                return F2.isLocalRequest(url) ? 'json' : 'jsonp';
	                                            },
	                                            type: function(url) {
	                                                return F2.isLocalRequest(url) ? 'POST' : 'GET';
	                                            }
	                                        }
	                                    });

xhr.type (
  • url
  • appConfigs
)

Allows the container to override the request method that is used.

Parameters:

  • url String

    The manifest url

  • appConfigs Array

    An array of F2.AppConfig objects

Returns:

String:

The request method that should be used

Example:

F2.init({
	                                        xhr: {
	                                            dataType: function(url) {
	                                                return F2.isLocalRequest(url) ? 'json' : 'jsonp';
	                                            },
	                                            type: function(url) {
	                                                return F2.isLocalRequest(url) ? 'POST' : 'GET';
	                                            }
	                                        }
	                                    });

xhr.url (
  • url
  • appConfigs
)

Allows the container to override the url that is used to request an app's F2.F2.AppManifest

Parameters:

  • url String

    The manifest url

  • appConfigs Array

    An array of F2.AppConfig objects

Returns:

String:

The url that should be used for the request

Example:

F2.init({
	                                        xhr: {
	                                            url: function(url, appConfigs) {
	                                                return 'http://example.com/proxy.php?url=' + encocdeURIComponent(url);
	                                            }
	                                        }
	                                    });

Properties

debugMode Bool

True to enable debug mode in F2.js. Adds additional logging, resource cache busting, etc.

Default: false


loadScripts Function

Allows the container to override the script loader which requests dependencies defined in the F2.AppManifest.

Example:

F2.init({
	                                            loadScripts: function(scripts,inlines,callback){
	                                                //load scripts using $.load() for each script or require(scripts)
	                                                callback();
	                                            }
	                                    });

loadStyles Function

Allows the container to override the stylesheet loader which requests dependencies defined in the F2.AppManifest.

Example:

F2.init({
	                                            loadStyles: function(styles,callback){
	                                                //load styles using $.load() for each stylesheet or another method
	                                                callback();
	                                            }
	                                    });

locale String

Defined in src\classes\containerConfig.js:16

Available since 1.4.0

The default language and region specification for this container represented as an IETF-defined standard language tag, e.g. "en-us" or "de-de". This value is passed to each app registered as containerLocale.

Default: null


scriptErrorTimeout Milliseconds

Milliseconds before F2 fires callback on script resource load errors. Due to issue with the way Internet Explorer attaches load events to script elements, the error event doesn't fire.

Default: 7000 (7 seconds)


xhr Object

Allows the container to override individual parts of the AppManifest request. See properties and methods with the xhr. prefix.

Example:

F2.init({
	                                        xhr: {
	                                            url: function(url, appConfigs) {
	                                                return 'http://example.com/proxy.php?url=' + encocdeURIComponent(url);
	                                            }
	                                        }
	                                    });