Print Friendly

# Class YAHOO.widget.CalendarGroup

Package: | YAHOO.widget
Class: | CalendarGroup
Extends: | Object
Subclasses: | Calendar2up
Defined In: | calendar.js

YAHOO.widget.CalendarGroup is a special container class for YAHOO.widget.Calendar. This class facilitates the ability to have multi-page calendar views that share a single dataset and are dependent on each other. The calendar group instance will refer to each of its elements using a 0-based index. For example, to construct the placeholder for a calendar group widget with id "cal1" and containerId of "cal1Container", the markup would be as follows:

    <div id="cal1Container_0"></div>
    <div id="cal1Container_1"></div>

The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.

## Public Properties

Property | Defined By
--- | ---
| CSS_2UPCLOSE<static> : String | CalendarGroup
<static> CSS class representing the close icon for the 2-up calendar
| CSS_2UPTITLE<static> : String | CalendarGroup
<static> CSS class representing the title for the 2-up calendar
| CSS_CONTAINER<static> : String | CalendarGroup
<static> CSS class representing the container for the calendar
| CSS_MULTI_UP<static> : String | CalendarGroup
<static> CSS class representing the container for the calendar
| Locale : Object | CalendarGroup
The local object which contains the CalendarGroup's locale settings
| Options : Object | CalendarGroup
The local object which contains the CalendarGroup's options
| cfg : Number @default | CalendarGroup
The position of the year in a month/day/year date string @config MDY_YEAR_POSITION
| containerId : String | CalendarGroup
The unique id associated with the CalendarGroup container
| id : String | CalendarGroup
The unique id associated with the CalendarGroup
| oDomContainer : HTMLElement | CalendarGroup
The outer containing element for the CalendarGroup
| pages : YAHOO.widget.Calendar[] | CalendarGroup
The collection of Calendar pages contained within the CalendarGroup

## Public Methods

Method | Defined By
--- | ---
| CalendarGroup(`String id`, `String containerId`, `Object config`) | CalendarGroup
| addMonthRenderer(`Number month`, `Function fnRender`) : void | CalendarGroup
Adds a month to the render stack. The function reference passed to this method will be executed when a date cell matc...
| addMonths(`Number count`) : void | CalendarGroup
Adds the designated number of months to the current calendar month, and sets the current calendar page date to the ne...
| addRenderer(`String sDates`, `Function fnRender`) : void | CalendarGroup
Adds a renderer to the render stack. The function reference passed to this method will be executed when a date cell m...
| addWeekdayRenderer(`Number weekday`, `Function fnRender`) : void | CalendarGroup
Adds a weekday to the render stack. The function reference passed to this method will be executed when a date cell ma...
| addYears(`Number count`) : void | CalendarGroup
Adds the designated number of years to the current calendar, and sets the current calendar page date to the new month.
| callChildFunction(`String fnName`, `Array args`) : void | CalendarGroup
Calls a function within all child Calendars within this CalendarGroup.
| clear() : void | CalendarGroup
Clears the selected dates in the current calendar widget and sets the calendar to the current month and year.
| configPageDate(`String type`, `Object[] args`, `Object obj`) : void | CalendarGroup
The default Config handler for the "pagedate" property
| configPages(`String type`, `Object[] args`, `Object obj`) : void | CalendarGroup
The default Config handler for the "pages" property
| constructChild(`String id`, `String containerId`, `Object config`) : YAHOO.widget.Calendar | CalendarGroup
Constructs a child calendar. This method can be overridden if a subclassed version of the default calendar is to be u...
| delegateConfig(`String type`, `Object[] args`, `Object obj`) : void | CalendarGroup
Delegates a configuration property to the CustomEvents associated with the CalendarGroup's children
| deselect(`String/Date/Date[] date`) : Date[] | CalendarGroup
Deselects a date or a collection of dates on the current calendar. This method, by default, does not call the render ...
| deselectAll() : Date[] | CalendarGroup
Deselects all dates on the current calendar.
| deselectCell(`Number cellIndex`) : Date[] | CalendarGroup
Deselects a date on the current calendar by referencing the index of the cell that should be deselected. This method ...
| getSelectedDates() : An | CalendarGroup
Gets the list of currently selected dates from the calendar.
| init(`String id`, `String containerId`, `Object config`) : void | CalendarGroup
Initializes the calendar group. All subclasses must call this method in order for the group to be initialized properly.
| initEvents() : void | CalendarGroup
Initializes CalendarGroup's built-in CustomEvents
| nextMonth() : void | CalendarGroup
Navigates to the next month page in the calendar widget.
| nextYear() : void | CalendarGroup
Navigates to the next year in the currently selected month in the calendar widget.
| previousMonth() : void | CalendarGroup
Navigates to the previous month page in the calendar widget.
| previousYear() : void | CalendarGroup
Navigates to the previous year in the currently selected month in the calendar widget.
| render() : void | CalendarGroup
Calls the render function of all child calendars within the group.
| renderFooter() : void | CalendarGroup
Renders a footer for the 2-up calendar container. By default, this method is unimplemented.
| renderHeader() : void | CalendarGroup
Renders the header for the CalendarGroup.
| reset() : void | CalendarGroup
Resets the calendar widget to the originally selected month and year, and sets the calendar to the initial selection(s).
| select(`String/Date/Date[] date`) : Date[] | CalendarGroup
Selects a date or a collection of dates on the current calendar. This method, by default, does not call the render me...
| selectCell(`Number cellIndex`) : Date[] | CalendarGroup
Selects a date on the current calendar by referencing the index of the cell that should be selected. This method is u...
| setChildFunction(`String fnName`, `Function fn`) : void | CalendarGroup
Adds a function to all child Calendars within this CalendarGroup.
| setMonth(`Number month`) : void | CalendarGroup
Sets the calendar group's month explicitly. This month will be set into the first page of the multi-page calendar, an...
| setYear(`Number year`) : void | CalendarGroup
Sets the calendar group's year explicitly. This year will be set into the first page of the multi-page calendar, and ...
| subtractMonths(`Number count`) : void | CalendarGroup
Subtracts the designated number of months from the current calendar month, and sets the current calendar page date to...
| subtractYears(`Number count`) : void | CalendarGroup
Subtcats the designated number of years from the current calendar, and sets the current calendar page date to the new...
| toString() : String | CalendarGroup
Returns a string representation of the object.

## Public Events

Event | Defined By
--- | ---
| beforeDeselectEvent : () | CalendarGroup
Fired before a selection is made
| beforeRenderEvent : () | CalendarGroup
Fired before the Calendar is rendered
| beforeSelectEvent : () | CalendarGroup
Fired before a selection is made
| changePageEvent : () | CalendarGroup
Fired when the Calendar page is changed
| clearEvent : () | CalendarGroup
Fired when the Calendar is cleared
| deselectEvent : (`Array Array`) | CalendarGroup
Fired when a selection is made
| renderEvent : () | CalendarGroup
Fired when the Calendar is rendered
| resetEvent : () | CalendarGroup
Fired when the Calendar is reset
| selectEvent : (`Array Array`) | CalendarGroup
Fired when a selection is made

## Property Details

### CSS_2UPCLOSE<static>

`public String CSS_2UPCLOSE<static>`
<static> CSS class representing the close icon for the 2-up calendar
This property is defined by CalendarGroup.

### CSS_2UPTITLE<static>

`public String CSS_2UPTITLE<static>`
<static> CSS class representing the title for the 2-up calendar
This property is defined by CalendarGroup.

### CSS_CONTAINER<static>

`public String CSS_CONTAINER<static>`
<static> CSS class representing the container for the calendar
This property is defined by CalendarGroup.

### CSS_MULTI_UP<static>

`public String CSS_MULTI_UP<static>`
<static> CSS class representing the container for the calendar
This property is defined by CalendarGroup.

### Locale

`public Object Locale`
The local object which contains the CalendarGroup's locale settings
This property is defined by CalendarGroup.

### Options

`public Object Options`
The local object which contains the CalendarGroup's options
This property is defined by CalendarGroup.

### cfg

`public Number @default cfg`
The position of the year in a month/day/year date string @config MDY_YEAR_POSITION
This property is defined by CalendarGroup.

### containerId

`public String containerId`
The unique id associated with the CalendarGroup container
This property is defined by CalendarGroup.

### id

`public String id`
The unique id associated with the CalendarGroup
This property is defined by CalendarGroup.

### oDomContainer

`public HTMLElement oDomContainer`
The outer containing element for the CalendarGroup
This property is defined by CalendarGroup.

### pages

`public YAHOO.widget.Calendar[] pages`
The collection of Calendar pages contained within the CalendarGroup
This property is defined by CalendarGroup.

## Constructor Details

### CalendarGroup

`public function CalendarGroup(`String id`, `String containerId`, `Object config`)`
Parameters:

- `id` : String
  The id of the table element that will represent the calendar widget
- `containerId` : String
  The id of the container div element that will wrap the calendar table
- `config` : Object
  The configuration object containing the Calendar's arguments

## Method Details

### addMonthRenderer

`public function addMonthRenderer(`Number month`, `Function fnRender`)`
Adds a month to the render stack. The function reference passed to this method will be executed when a date cell matches the month passed to this method.
Parameters:

- `month` : Number
  The month (1-12) to associate with this renderer
- `fnRender` : Function
  The function executed to render cells that match the render rules for this renderer.

Returns:

- `void`

This method is defined by CalendarGroup.

### addMonths

`public function addMonths(`Number count`)`
Adds the designated number of months to the current calendar month, and sets the current calendar page date to the new month.
Parameters:

- `count` : Number
  The number of months to add to the current calendar

Returns:

- `void`

This method is defined by CalendarGroup.

### addRenderer

`public function addRenderer(`String sDates`, `Function fnRender`)`
Adds a renderer to the render stack. The function reference passed to this method will be executed when a date cell matches the conditions specified in the date string for this renderer.
Parameters:

- `sDates` : String
  A date string to associate with the specified renderer. Valid formats include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005)
- `fnRender` : Function
  The function executed to render cells that match the render rules for this renderer.

Returns:

- `void`

This method is defined by CalendarGroup.

### addWeekdayRenderer

`public function addWeekdayRenderer(`Number weekday`, `Function fnRender`)`
Adds a weekday to the render stack. The function reference passed to this method will be executed when a date cell matches the weekday passed to this method.
Parameters:

- `weekday` : Number
  The weekday (0-6) to associate with this renderer
- `fnRender` : Function
  The function executed to render cells that match the render rules for this renderer.

Returns:

- `void`

This method is defined by CalendarGroup.

### addYears

`public function addYears(`Number count`)`
Adds the designated number of years to the current calendar, and sets the current calendar page date to the new month.
Parameters:

- `count` : Number
  The number of years to add to the current calendar

Returns:

- `void`

This method is defined by CalendarGroup.

### callChildFunction

`public function callChildFunction(`String fnName`, `Array args`)`
Calls a function within all child Calendars within this CalendarGroup.
Parameters:

- `fnName` : String
  The name of the function
- `args` : Array
  The arguments to pass to the function

Returns:

- `void`

This method is defined by CalendarGroup.

### clear

`public function clear()`
Clears the selected dates in the current calendar widget and sets the calendar to the current month and year.
Parameters:

- None.

Returns:

- `void`

This method is defined by CalendarGroup.

### configPageDate

`public function configPageDate(`String type`, `Object[] args`, `Object obj`)`
The default Config handler for the "pagedate" property
Parameters:

- `type` : String
  The CustomEvent type (usually the property name)
- `args` : Object[]
  The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- `obj` : Object
  The scope object. For configuration handlers, this will usually equal the owner.

Returns:

- `void`

This method is defined by CalendarGroup.

### configPages

`public function configPages(`String type`, `Object[] args`, `Object obj`)`
The default Config handler for the "pages" property
Parameters:

- `type` : String
  The CustomEvent type (usually the property name)
- `args` : Object[]
  The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- `obj` : Object
  The scope object. For configuration handlers, this will usually equal the owner.

Returns:

- `void`

This method is defined by CalendarGroup.

### constructChild

`public function constructChild(`String id`, `String containerId`, `Object config`)`
Constructs a child calendar. This method can be overridden if a subclassed version of the default calendar is to be used.
Parameters:

- `id` : String
  The id of the table element that will represent the calendar widget
- `containerId` : String
  The id of the container div element that will wrap the calendar table
- `config` : Object
  The configuration object containing the Calendar's arguments

Returns:

- `YAHOO.widget.Calendar`
  The YAHOO.widget.Calendar instance that is constructed

This method is defined by CalendarGroup.

### delegateConfig

`public function delegateConfig(`String type`, `Object[] args`, `Object obj`)`
Delegates a configuration property to the CustomEvents associated with the CalendarGroup's children
Parameters:

- `type` : String
  The CustomEvent type (usually the property name)
- `args` : Object[]
  The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- `obj` : Object
  The scope object. For configuration handlers, this will usually equal the owner.

Returns:

- `void`

This method is defined by CalendarGroup.

### deselect

`public function deselect(`String/Date/Date[] date`)`
Deselects a date or a collection of dates on the current calendar. This method, by default, does not call the render method explicitly. Once deselection has completed, render must be called for the changes to be reflected visually.
Parameters:

- `date` : String/Date/Date[]
  The date string of dates to deselect in the current calendar. Valid formats are individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006). Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). This method can also take a JavaScript Date object or an array of Date objects.

Returns:

- `Date[]`
  Array of JavaScript Date objects representing all individual dates that are currently selected.

This method is defined by CalendarGroup.

### deselectAll

`public function deselectAll()`
Deselects all dates on the current calendar.
Parameters:

- None.

Returns:

- `Date[]`
  Array of JavaScript Date objects representing all individual dates that are currently selected. Assuming that this function executes properly, the return value should be an empty array. However, the empty array is returned for the sake of being able to check the selection status of the calendar.

This method is defined by CalendarGroup.

### deselectCell

`public function deselectCell(`Number cellIndex`)`
Deselects a date on the current calendar by referencing the index of the cell that should be deselected. This method is used to easily deselect a single cell (usually with a mouse click) without having to do a full render. The selected style is removed from the cell directly.
Parameters:

- `cellIndex` : Number
  The index of the cell to deselect in the current calendar.

Returns:

- `Date[]`
  Array of JavaScript Date objects representing all individual dates that are currently selected.

This method is defined by CalendarGroup.

### getSelectedDates

`public function getSelectedDates()`
Gets the list of currently selected dates from the calendar.
Parameters:

- None.

Returns:

- `An`
  array of currently selected JavaScript Date objects.

This method is defined by CalendarGroup.

### init

`public function init(`String id`, `String containerId`, `Object config`)`
Initializes the calendar group. All subclasses must call this method in order for the group to be initialized properly.
Parameters:

- `id` : String
  The id of the table element that will represent the calendar widget
- `containerId` : String
  The id of the container div element that will wrap the calendar table
- `config` : Object
  The configuration object containing the Calendar's arguments

Returns:

- `void`

This method is defined by CalendarGroup.

### initEvents

`public function initEvents()`
Initializes CalendarGroup's built-in CustomEvents
Parameters:

- None.

Returns:

- `void`

This method is defined by CalendarGroup.

### nextMonth

`public function nextMonth()`
Navigates to the next month page in the calendar widget.
Parameters:

- None.

Returns:

- `void`

This method is defined by CalendarGroup.

### nextYear

`public function nextYear()`
Navigates to the next year in the currently selected month in the calendar widget.
Parameters:

- None.

Returns:

- `void`

This method is defined by CalendarGroup.

### previousMonth

`public function previousMonth()`
Navigates to the previous month page in the calendar widget.
Parameters:

- None.

Returns:

- `void`

This method is defined by CalendarGroup.

### previousYear

`public function previousYear()`
Navigates to the previous year in the currently selected month in the calendar widget.
Parameters:

- None.

Returns:

- `void`

This method is defined by CalendarGroup.

### render

`public function render()`
Calls the render function of all child calendars within the group.
Parameters:

- None.

Returns:

- `void`

This method is defined by CalendarGroup.

### renderFooter

`public function renderFooter()`
Renders a footer for the 2-up calendar container. By default, this method is unimplemented.
Parameters:

- None.

Returns:

- `void`

This method is defined by CalendarGroup.

### renderHeader

`public function renderHeader()`
Renders the header for the CalendarGroup.
Parameters:

- None.

Returns:

- `void`

This method is defined by CalendarGroup.

### reset

`public function reset()`
Resets the calendar widget to the originally selected month and year, and sets the calendar to the initial selection(s).
Parameters:

- None.

Returns:

- `void`

This method is defined by CalendarGroup.

### select

`public function select(`String/Date/Date[] date`)`
Selects a date or a collection of dates on the current calendar. This method, by default, does not call the render method explicitly. Once selection has completed, render must be called for the changes to be reflected visually.
Parameters:

- `date` : String/Date/Date[]
  The date string of dates to select in the current calendar. Valid formats are individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006). Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). This method can also take a JavaScript Date object or an array of Date objects.

Returns:

- `Date[]`
  Array of JavaScript Date objects representing all individual dates that are currently selected.

This method is defined by CalendarGroup.

### selectCell

`public function selectCell(`Number cellIndex`)`
Selects a date on the current calendar by referencing the index of the cell that should be selected. This method is used to easily select a single cell (usually with a mouse click) without having to do a full render. The selected style is applied to the cell directly.
Parameters:

- `cellIndex` : Number
  The index of the cell to select in the current calendar.

Returns:

- `Date[]`
  Array of JavaScript Date objects representing all individual dates that are currently selected.

This method is defined by CalendarGroup.

### setChildFunction

`public function setChildFunction(`String fnName`, `Function fn`)`
Adds a function to all child Calendars within this CalendarGroup.
Parameters:

- `fnName` : String
  The name of the function
- `fn` : Function
  The function to apply to each Calendar page object

Returns:

- `void`

This method is defined by CalendarGroup.

### setMonth

`public function setMonth(`Number month`)`
Sets the calendar group's month explicitly. This month will be set into the first page of the multi-page calendar, and all other months will be iterated appropriately.
Parameters:

- `month` : Number
  The numeric month, from 0 (January) to 11 (December)

Returns:

- `void`

This method is defined by CalendarGroup.

### setYear

`public function setYear(`Number year`)`
Sets the calendar group's year explicitly. This year will be set into the first page of the multi-page calendar, and all other months will be iterated appropriately.
Parameters:

- `year` : Number
  The numeric 4-digit year

Returns:

- `void`

This method is defined by CalendarGroup.

### subtractMonths

`public function subtractMonths(`Number count`)`
Subtracts the designated number of months from the current calendar month, and sets the current calendar page date to the new month.
Parameters:

- `count` : Number
  The number of months to subtract from the current calendar

Returns:

- `void`

This method is defined by CalendarGroup.

### subtractYears

`public function subtractYears(`Number count`)`
Subtcats the designated number of years from the current calendar, and sets the current calendar page date to the new month.
Parameters:

- `count` : Number
  The number of years to subtract from the current calendar

Returns:

- `void`

This method is defined by CalendarGroup.

### toString

`public function toString()`
Returns a string representation of the object.
Parameters:

- None.

Returns:

- `String`
  A string representation of the CalendarGroup object.

This method is defined by CalendarGroup.

## Event Details

### beforeDeselectEvent

`public event beforeDeselectEvent`
Fired before a selection is made
Subscribers will be called with the following parameters:

- None.

This event is defined by CalendarGroup.

### beforeRenderEvent

`public event beforeRenderEvent`
Fired before the Calendar is rendered
Subscribers will be called with the following parameters:

- None.

This event is defined by CalendarGroup.

### beforeSelectEvent

`public event beforeSelectEvent`
Fired before a selection is made
Subscribers will be called with the following parameters:

- None.

This event is defined by CalendarGroup.

### changePageEvent

`public event changePageEvent`
Fired when the Calendar page is changed
Subscribers will be called with the following parameters:

- None.

This event is defined by CalendarGroup.

### clearEvent

`public event clearEvent`
Fired when the Calendar is cleared
Subscribers will be called with the following parameters:

- None.

This event is defined by CalendarGroup.

### deselectEvent

`public event deselectEvent`
Fired when a selection is made
Subscribers will be called with the following parameters:

- `Array` : Array
  of Date field arrays in the format [YYYY, MM, DD].

This event is defined by CalendarGroup.

### renderEvent

`public event renderEvent`
Fired when the Calendar is rendered
Subscribers will be called with the following parameters:

- None.

This event is defined by CalendarGroup.

### resetEvent

`public event resetEvent`
Fired when the Calendar is reset
Subscribers will be called with the following parameters:

- None.

This event is defined by CalendarGroup.

### selectEvent

`public event selectEvent`
Fired when a selection is made
Subscribers will be called with the following parameters:

- `Array` : Array
  of Date field arrays in the format [YYYY, MM, DD].

This event is defined by CalendarGroup.

Copyright © 2006 Jack Slocum. All rights reserved.