Yahoo! UI Library

imageloader  2.5.1

Yahoo! UI Library > imageloader > YAHOO.util.ImageLoader.group

Show Private Show Protected

Class YAHOO.util.ImageLoader.group

A group for images. A group can have one time limit and a series of triggers. Thus the images belonging to this group must share these constraints.

Constructor

YAHOO.util.ImageLoader.group ( trigEl , trigAct , timeout )
Parameters:
trigEl <String|HTMLElement> The HTML element id or reference to assign the trigger event to. Can be null for no trigger
trigAct <String> The type of event to assign to trigEl. Can be null for no trigger
timeout <Number> Timeout (time limit) length, in seconds. Can be undefined, or <= 0, for no time limit

Properties

_classImageEls - private Array

HTML elements having the class name that is associated with this group Elements are stored during the _foldCheck function and reused later during the fetch function. Gives a slight performance improvement when className and foldConditional are both used

_customTriggers - private Array

Collection of custom-event triggers for this group. Keeps track of each trigger's event object and event-listener-callback "fetch" function

_imgObjs - private Object

Collection of images registered with this group

_timeout - private Object

Timeout object to keep a handle on the time limit

_triggers - private Array

Collection of triggers for this group. Keeps track of each trigger's element, event, and event-listener-callback "fetch" function

className - String

Class name that will identify images belonging to the group. This class name will be removed from each element in order to fetch images. This class should have, in its CSS style definition, "background:none !important;"

foldConditional - Boolean

Flag to check if images are above the fold. If foldConditional is true, the group will check each of its image locations at page load. If any part of the image is within the client viewport, the image is displayed immediately

name - String

Name for the group. Only used to identify the group in logging statements

timeoutLen - Number

Timeout (time limit) length, in seconds

Methods

_fetchByClass

private void _fetchByClass ( )
Finds all elements in the Dom with the class name specified in the group. Removes the class from the element in order to let the style definitions trigger the image fetching
Returns: void

_foldCheck

private void _foldCheck ( )
Checks the position of each image in the group. If any part of the image is within the client viewport, shows the image immediately.
Returns: void

_getFetchTimeout

private Function _getFetchTimeout ( )
Returns the group's fetch method, with the proper closure, for use with setTimeout
Returns: Function
group's fetch method

_onloadTasks

private void _onloadTasks ( )
Setup to do in the window's onload Initiates time limit for group; executes the fold check for the images
Returns: void

addCustomTrigger

void addCustomTrigger ( event )
Adds a custom event trigger to the group.
Parameters:
event <Object> A YAHOO.util.CustomEvent object
Returns: void

addTrigger

void addTrigger ( trigEl , trigAct )
Adds a trigger to the group. Call this with the same style as YAHOO.util.Event.addListener
Parameters:
trigEl <String|HTMLElement> The HTML element id or reference to assign the trigger event to
trigAct <String> The type of event to assign to trigEl
Returns: void

fetch

void fetch ( )
Displays the images in the group
Returns: void

registerBgImage

Object registerBgImage ( domId , url )
Registers a background image with the group
Parameters:
domId <String> HTML DOM id of the image element
url <String> URL for the image
Returns: Object
bgImgObj that was registered, for modifying any attributes in the object

registerPngBgImage

Object registerPngBgImage ( domId , url , ailProps )
Registers an alpha-channel-type png background image with the group
Parameters:
domId <String> HTML DOM id of the image element
url <String> URL for the image
ailProps <Object> The AlphaImageLoader properties to be set for the image Valid properties are 'sizingMethod' and 'enabled'
Returns: Object
pngBgImgObj that was registered, for modifying any attributes in the object

registerSrcImage

Object registerSrcImage ( domId , url , width , height )
Registers a src image with the group
Parameters:
domId <String> HTML DOM id of the image element
url <String> URL for the image
width <Int> pixel width of the image - defaults to image's natural size
height <Int> pixel height of the image - defaults to image's natural size
Returns: Object
srcImgObj that was registered, for modifying any attributes in the object


Copyright © 2007 Yahoo! Inc. All rights reserved.