ActiveBagContent

Source: ActiveBagContent.js:45

This class packs a collection of ActiveBoxContent objects and provides methods to access
and manage it. The two main members of ActiveBagContent are the Shaper, responsible for
determining the position and shape of each ActiveBox, and the BoxBase (field style),
provider of a common visual style.


Constructor

new ActiveBagContent( id?: string, ncw: number, nch: number, ): ActiveBagContent

ActiveBagContent constructor

Parameters

  • id (string, optional) — An optional text tag identifying this ActiveBagContent
  • ncw (number) — In grid-based distributions, number of columns.
  • nch (number) — In grid-based distributions, number of rows.

Instance Methods

setProperties( $xml: external:jQuery, mediaBag: module:bags/MediaBag.MediaBag, )

Loads the object settings from a specific JQuery XML element

Parameters

getAttributes(): object

Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.

Returns

  • object

setAttributes( data: object, mediaBag: module:bags/MediaBag.MediaBag, ): module:boxes/ActiveBagContent.ActiveBagContent

Reads the properties of this ActiveBagContent from a data object

Parameters

Returns

prepareMedia(playStation: module:JClicPlayer.JClicPlayer)

Prepares the media content of all elements

Parameters

getTotalWidth(): number

Gets the estimated total width of this content bag

Returns

  • number

getTotalHeight(): number

Gets the estimated total height of this bag

Returns

  • number

getNumCells(): number

Gets the total number of cells of this bag

Returns

  • number

isEmpty(): boolean

Checks if the bag is empty

Returns

  • boolean

getShaper(): module:shapers/Shaper.Shaper

Retrieves the Shaper of this bag, creating a new one if it was null

Returns

getBoxBase(): module:boxes/BoxBase.BoxBase

Retrieves the BoxBase of this bag, creating a new one if it was null

Returns

addActiveBoxContent( ab: module:boxes/ActiveBoxContent.ActiveBoxContent, )

Adds a new ActiveBoxContent to this bag

Parameters

getActiveBoxContent( i: number, ): module:boxes/ActiveBoxContent.ActiveBoxContent

Gets the nth ActiveBoxContent in cells

Parameters

  • i (number) — The index of the content to be retrieved

Returns

getActiveBoxContentWith( id: number, item: number, ): module:boxes/ActiveBoxContent.ActiveBoxContent

Finds the ActiveBoxContent with specific id and item values

Parameters

  • id (number)
  • item (number)

Returns

setImgContent( mb: module:bags/MediaBag.MediaBag, sh: module:shapers/Shaper.Shaper, roundSizes: boolean, )

Sets the content of the cells based on a image spliced by a shaper

Parameters

setTextContent( txt: Array.<string>, setNcw: number, setNch: number, )

Sets the content of this bag based on an array of strings

Parameters

  • txt (Array.<string>) — The array of strings to be used as content.
  • setNcw (number) — Number of columns
  • setNch (number) — Number of rows

setIds(ids: Array.<number>)

Sets id values to a all the ActiveBoxContent elements of his bag.

Parameters

  • ids (Array.<number>) — Array of numeric identifiers

setCellsAttribute(key: string, value: any)

Sets value to the key attribute of all cells

Parameters

  • key (string) — The key where the value will be stored
  • value (any) — The supplied value. Can be of any type.

avoidAllIdsNull(maxId: number)

Cheks if the id values of all ActiveBoxContent objects are -1 and, if true,
sets new ids to them, with values between 0 and maxId

Parameters

  • maxId (number) — The maximum value of identifiers

Instance Fields

id: string

The global identifier of this object: primary, secondary...

image: string

The name of the image file used as a common image of this bag

img: external:HTMLImageElement

The built image object

animatedGifFile: string

Name of the img source when is an animated GIF

ncw: number

Number of columns when cells are distributed in a grid

nch: number

Number of rows when cells are distributed in a grid

w: number

Optimal cell width

h: number

Optimal cell height

border: boolean

Whether the cells must have a border or not

style: module:boxes/BoxBase.BoxBase

The BoxBase used for this bag of cell contents

shaper: module:shapers/Shaper.Shaper

The Shaper used to define the specific shape of each cell

backgroundContent: module:boxes/ActiveBoxContent.ActiveBoxContent

An optional ActiveBoxContent object with background settings.

cells: Array.<module:boxes/ActiveBoxContent.ActiveBoxContent>

The main Array of ActiveBoxContent objects

defaultIdValue: number

The default value to be assigned at the 'id' field of children

ids: string

Used in special cases where all cells have empty content with only numeric identifiers