The X Toolkit API

X.loader

/**
* This object loads external files in an asynchronous fashion. In addition, the
* loading process is monitored and summarized to a total progress value.
*
* @constructor
* @extends X.base
*/
var l = new X.loader();
/**
* The className of this class.
*
* @type {string}
* @protected
*/
l._classname = $_CLASSNAME;
/**
* The 'dirty' flag of this object.
*
* @type {boolean}
* @protected
*/
l._dirty = $_DIRTY;
/**
* The uniqueId of this instance. Each class instance in XTK has a uniqueId.
*
* @type {number}
* @protected
*/
l._id = $_ID;
/**
* The hash map holding all the jobs and their status.
*
* @type {!goog.structs.Map}
* @protected
*/
l._jobs = $_JOBS;
/**
* The overall progress value in the range of 0 and 1.
*
* @type {!number}
* @protected
*/
l._progress = $_PROGRESS;
/**
* Get the className of this object.
*
* @return {string} The className of this object.
* @public
*/
var _classname = l.classname;
/**
* Get the id of this instance.
*
* @return {string} The className of this object.
* @public
*/
var _id = l.id;
/**
* Add a value to the overall progress value. The given value is normalized
* according to the number of current jobs. After adding the value, a
* X.event.ProgressEvent is fired to inform the progress bar.
*
* @param {!number} value The value to add.
*/
l.addProgress($VALUE);
/**
* Check if the given container is configured with a valid file format.
*
* @param {!X.base} container A container which has an X.file() attached.
* @return {!Array} An array holding the following information [filepath,
*         extension in uppercase without the '.', the associated but
*         uninstantiated parser for this file format, additional (optional)
*         flags which are passed to the parser, the response type]
* @throws {Error} An error, if the configured file format is not supported.
*/
var checkFileFormat = l.checkFileFormat($CONTAINER);
/**
* The complete callback which gets executed after successful parsing of a data
* stream. A X.event.ModifiedEvent is fired to inform the X.renderer that the
* loading was completed.
*
* @param {!X.event.ModifiedEvent} event The modified event holding container
*          and object.
*/
l.complete($EVENT);
/**
* Check if all loading is completed.
*
* @return {boolean} TRUE if all loading is completed, FALSE else wise.
*/
var completed = l.completed();
/**
* The failure callback which gets executed if anything goes wrong during
* downloading. It always throws an error.
*
* @param {!XMLHttpRequest} request The original XHR.
* @param {!X.base} container The container which has a X.file() attached.
* @param {!X.object} object The X.object which is the parent of the container
*          or equals it.
* @throws {Error} An error, stating that something went wrong.
*/
l.failed($REQUEST, $CONTAINER, $OBJECT);
/**
* Download a file associated to a container via Ajax. Callbacks are executed
* depending on the success of the request.
*
* @param {!X.base} container The container which has a X.file() attached.
* @param {!X.object} object The X.object which is the parent of the container
*          or equals it.
* @throws {Error} An error, if the given objects were invalid.
*/
l.load($CONTAINER, $OBJECT);
/**
* Trigger parsing of a data stream. This is the callback for successful
* downloading. A single-shot listener is configured for a X.event.ModifiedEvent
* which then triggers the complete callback.
*
* @param {?XMLHttpRequest} request The original XHR.
* @param {!X.base} container The container which has a X.file() attached.
* @param {!X.object} object The X.object which is the parent of the container
*          or equals it.
*/
l.parse($REQUEST, $CONTAINER, $OBJECT);
/**
* Supported data types by extension.
*
* @enum {Array}
*/
X.loader.extensions();


CONSTRUCTORS
X.loader

PROPERTIES
_classname
_dirty
_id
_jobs
_progress

GETTERS/SETTERS
classname
id

FUNCTIONS
addProgress
checkFileFormat
complete
completed
failed
load
parse

STATIC
extensions



SOURCECODE