-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathsimple.js
122 lines (108 loc) · 4.55 KB
/
simple.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* @preserve Copyright (c) 2013 British Broadcasting Corporation
* (http://www.bbc.co.uk) and TAL Contributors (1)
*
* (1) TAL Contributors are listed in the AUTHORS file and at
* https://github.com/bbc/TAL/AUTHORS - please extend this file,
* not this notice.
*
* @license Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* All rights reserved
* Please contact us for an alternative licence
*/
define(
"sampleapp/appui/components/simple",
[
"antie/widgets/component",
"antie/widgets/button",
"antie/widgets/label",
"antie/widgets/verticallist",
"antie/widgets/carousel",
"antie/datasource",
"sampleapp/appui/formatters/simpleformatter",
"sampleapp/appui/datasources/simplefeed"
],
function (Component, Button, Label, VerticalList, Carousel, DataSource, SimpleFormatter, SimpleFeed) {
// All components extend Component
return Component.extend({
init: function init () {
var self, helloWorldLabel, welcomeLabel, carouselButtonLabel, verticalListMenu;
self = this;
// It is important to call the constructor of the superclass
init.base.call(this, "simplecomponent");
// Add the labels to the component
helloWorldLabel = new Label("helloWorldLabel", "Hello World");
this.appendChildWidget(helloWorldLabel);
welcomeLabel = new Label("welcomeLabel", "Welcome to your first TAL application!");
this.appendChildWidget(welcomeLabel);
var newCarouselButton = this._createCarouselButton();
var playerButton = new Button();
playerButton.addEventListener("select", function(evt){
self.getCurrentApplication().pushComponent("maincontainer", "sampleapp/appui/components/simplevideocomponent");
});
playerButton.appendChildWidget(new Label("Simple Video Player Example"));
var horizontalProgressButton = new Button();
horizontalProgressButton.appendChildWidget(new Label("Horizontal Progress Bar Example"));
horizontalProgressButton.addEventListener("select", function(evt) {
self.getCurrentApplication().pushComponent("maincontainer", "sampleapp/appui/components/horizontalprogresscomponent");
});
// Create a vertical list and append the buttons to navigate within the list
verticalListMenu = new VerticalList("mainMenuList");
verticalListMenu.appendChildWidget(newCarouselButton);
verticalListMenu.appendChildWidget(playerButton);
verticalListMenu.appendChildWidget(horizontalProgressButton);
this.appendChildWidget(verticalListMenu);
// calls Application.ready() the first time the component is shown
// the callback removes itself once it's fired to avoid multiple calls.
this.addEventListener("aftershow", function appReady(evt) {
self.getCurrentApplication().ready();
self.removeEventListener('aftershow', appReady);
});
},
_createCarouselButton: function () {
var self = this;
function carouselExampleSelected() {
self.getCurrentApplication().pushComponent(
"maincontainer",
"sampleapp/appui/components/carouselcomponent",
self._getCarouselConfig()
);
}
var button = new Button('carouselButton');
button.appendChildWidget(new Label("Carousel Example"));
button.addEventListener('select', carouselExampleSelected);
return button;
},
_getCarouselConfig: function () {
return {
description: "Carousel example, LEFT and RIGHT to navigate, SELECT to go back",
dataSource: new DataSource(null, new SimpleFeed(), 'loadData'),
formatter: new SimpleFormatter(),
orientation: Carousel.orientations.HORIZONTAL,
carouselId: 'verticalCullingCarousel',
animOptions: {
skipAnim: false
},
alignment: {
normalisedAlignPoint: 0.5,
normalisedWidgetAlignPoint: 0.5
},
initialItem: 4,
type: "CULLING",
lengths: 264
};
}
});
}
);