This widget container is used to showcase some child widgets combined on one basis. The allowed child widget is ``aps/Tile``.
Table of contents
UX1 only
aps/Carousel
is a container used to present multiple child widgets in a horizontal line. The child widgets can
be only aps/Tile. In a case not all tiles can be shown on a page due to the
gridSize limitation,
the scrolling controls allow scrolling the tiles horizontally grouping all tiles into pages.
The currentPage
property presents the number of the currently displayed page starting from 1
.
Child tiles can be defined using one of the two ways:
Create a data store that defines a number of children and their properties.
In this case, it is necessary to
define only one aps/Tile
widget as a template. The actual number of child tiles in the carousel will be as many
as the size of the data store array. The properties of the tiles are synced with the data store as defined in the
template aps/Tile
. This method is illustrated in the Examples.
Define every child tile separately with its own properties.
The getCurrentTiles
method returns an array of objects presenting the properties of the tiles displayed on the
current page:
When a data store is used in the carousel, every returned element in the array contains the full set of properties.
In the other case, a returned element contains only the title of the corresponding tile.
This is a simple carousel illustrating the horizontal scrolling of the tiles. You can play with the data store
to change the number of tiles or to change the gridSize
property in the aps/Tile
definition.
require(["dojox/mvc/at", "aps/load", "aps/Memory", "aps/ready!"],
function(at, load, Memory) {
"use strict";
var serviceData = [{
title: "Mainstream cloud service",
serviceDescription: "The most suitable for mainstream assignment."
}, {
title: "Light cloud service",
serviceDescription: "The most suitable for mass assignment and free distribution."
}, {
title: "High level cloud service",
serviceDescription: "Cloud service with almost all options."
}, {
title: "Top level cloud service",
serviceDescription: "VIP cloud service with all possible options."
}];
var serviceStore = new Memory({
data: serviceData
});
load(["aps/Carousel", {
title: "Welcome to the newest cloud services!",
description: "The most effective service and efficient ownership.",
currentPage: 1,
store: serviceStore
},
[
["aps/Tile", {
title: at("rel:", "title"),
gridSize: "md-4",
state: 'inactive',
serviceDescription: at("rel:", "serviceDescription")
}]
]
]);
});
The following demo shows the use of the getCurrentTiles
method triggered by
the watch method in the moment, when the carousel is scrolled.
require([
"dijit/registry",
"dojox/mvc/at",
"dojox/mvc/getStateful",
"aps/load",
"aps/Memory",
"aps/ready!"
], function(registry, at, GetStateful, load, Memory) {
"use strict";
var serviceData = [{
title: "Mainstream cloud service",
serviceDescription: "The most suitable for mainstream assignment."
}, {
title: "Light cloud service",
serviceDescription: "The most suitable for mass assignment and free distribution."
}, {
title: "High level cloud service",
serviceDescription: "Cloud service with almost all options."
}, {
title: "Top level cloud service",
serviceDescription: "VIP cloud service with all possible options."
}];
var serviceStore = new Memory({
data: serviceData
});
var displayedDataModel = new GetStateful({
data: []
});
function updateDisplay(name, oldVal, newVal) {
console.log("Handler started - updateDisplay");
//var data = registry.byId("myCarousel").getCurrentTiles();
//displayedDataModel.set("data", data);
}
load([
["aps/Carousel", {
id: "myCarousel",
title: "Welcome to the newest cloud services!",
description: "The most effective service and efficient ownership.",
currentPage: 0,
store: serviceStore
},
[
["aps/Tile", {
title: at("rel:", "title"),
gridSize: "md-4",
state: 'inactive',
serviceDescription: at("rel:", "serviceDescription")
}]
]
],
["aps/WidgetList", {
id: "currentData",
title: "Current data on the page:",
children: at(displayedDataModel, "data")
},
[
["aps/Panel", [
["aps/FieldSet", [
["aps/Output", {
value: at("rel:", "title")
}],
["aps/Output", {
value: at("rel:", "serviceDescription")
}]
]]
]]
]
]
]).then(function() {
registry.byId("myCarousel").watch("currentPage", updateDisplay);
});
});
PROPERTY |
TYPE |
DEFAULT |
DESCRIPTION |
---|---|---|---|
number |
1 |
The number of the current page in the carousel. |
|
string |
“” |
Text under the header of the Carousel and over the content of the Carousel. |
|
boolean |
false |
Specifies if the widget will respond to user input. |
|
boolean |
false |
If it is true the widget’s id will be extended. |
|
string |
undefined |
This specifies the widget width that is relevant only for widgets inside Container, FieldSet, or Tiles. |
|
boolean |
false |
If the widget is busy then this property is true. |
|
string |
“” |
Text that is shown as a label if the widget is placed inside a aps/FieldSet. |
|
aps/store |
null |
An instance of the “aps/Store” model, from which to fetch data. |
|
string |
“” |
Text that is shown in the header of the Carousel. |
|
boolean |
true |
If this property value is set to true, then the widget is visible. |
The number of the current page in the carousel. If currentPage < 1 the cuurent page will be the first one. If currentPage more than the last page number the cuurent page will be the last one. Default value: 1.
Text under the header of the Carousel and over the content of the Carousel. Default value: “”.
If it is true the widget’s id will be extended. It can be useful when some widgets (e.g. aps/Tiles) use the same store with defined id-s. Default value: false.
This specifies the widget width that is relevant only for widgets inside Container, FieldSet, or Tiles. In other cases it will be ignored.
gridSize string contains few options with number values (from 1 to 12) separated by spaces, which specify the grid size of the widget in different layouts:
- md - desktop
- xs - phone
For example, gridSize: “md-4 xs-2”.
All values below 1, e.g. “md-0”, will be replaced with the empty string (“”), values above 12, e.g. “md-14”, will be reduced to 12 (“md-12”).
Default value: undefined.
Text that is shown as a label if the widget is placed inside a aps/FieldSet.
Default value: “”.
An instance of the “aps/Store” model, from which to fetch data. Default value: null.
Text that is shown in the header of the Carousel. Default value: “”.
If this property value is set to true, then the widget is visible.
Default value: true.
METHOD |
RETURN |
DESCRIPTION |
---|---|---|
undefined
|
Adds a given widget to the list |
|
object
|
Sets the isBusy property to false |
|
undefined
|
Destroys this widget |
|
aps/_containerbase
function
|
Focusing the focusable child |
|
any
|
Get a property of the Stateful instance |
|
array
|
Returns all direct children of this widget, i |
|
array
|
Returns an array of current tiles in the carousel |
|
array
|
Discover and return all parents of the widget |
|
dijit/_widgetbase
function
|
Place this widget somewhere in the DOM based on standard dojo/dom-construct::place() conventions |
|
undefined
|
Refreshes a page |
|
undefined
|
Remove all children in the widget |
|
undefined
|
Removes the passed widget instance from this widget and destroys it |
|
undefined
|
Resets the widget |
|
object
function
|
Set a property of the Stateful instance |
|
boolean
|
Called by oninit, onblur, and onkeypress |
Adds a given widget to the list. Inserts the DOM node of a specified widget as a child to the container DOM node and possibly does other processing (such as layout).
Return: undefined
ARGUMENT |
TYPE |
DESCRIPTION |
---|---|---|
|
Widget
|
Child widget |
|
Number
String
|
Child position in the parent node |
Destroys this widget. Will also destroy any resources (including widgets) registered via this.own(). This method will also destroy internal widgets such as those created from a template.
Return: undefined
Get a property of the Stateful instance. Get a named property of the Stateful object. The property may potentially be retrieved via a getter method in subclasses.
In the base class, this just retrieves the object’s property.
Return: any
Returns all direct children of this widget, i.e. all widgets underneath this.containerNode whose parent is this widget. Note that it returns not all descendetns, but only the direct children. Analogous to Node.childNodes, except containing widgets rather than DOMNodes.
The result intentionally excludes internally created widgets (a.k.a. supporting widgets) outside of this.containerNode.
Note the returned array is a simple array. The application code should not assume existence of methods like forEach().
Return: array
Returns an array of current tiles in the carousel. Returns an array of objects. Every object contains properties of the appropriate active tile in the carousel.
Return: array
Place this widget somewhere in the DOM based on standard dojo/dom-construct::place() conventions. A convenience function providing a simple shorthand mechanism to put an existing (or newly created) widget somewhere in the DOM, and allow chaining.
Return: dijit/_widgetbase function
Removes the passed widget instance from this widget and destroys it. You can also pass in an integer indicating the index within the container to remove (ie, removeChild(5) removes the sixth widget).
Return: undefined
ARGUMENT |
TYPE |
DESCRIPTION |
---|---|---|
|
Widget
Int
|
Child widget or index |
Set a property of the Stateful instance. Sets named properties of the stateful object and notifies the watchers of the property. A programmatic setter may be defined in subclasses.
Return: object function
Called by oninit, onblur, and onkeypress. Show missing or invalid messages if appropriate, and highlight textbox field.
Return: boolean
EVENT |
RETURN |
DESCRIPTION |
---|---|---|
undefined
|
The method is called when a user clicks on the widget |
The method is called when a user clicks on the widget.