-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.js
43 lines (32 loc) · 1.17 KB
/
index.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
var moment = require('alloy/moment');
var currentMonth = moment();
function doPrevMonth() {
var widget;
// Remove current month calendar.
$.calendar.remove($.calendar.children[0]);
// Create previous month calendar and add view
currentMonth.subtract('months', 1);
widget = Alloy.createWidget('jp.co.mountposition.calendar', 'widget', {period: currentMonth});
$.calendar.add(widget.getView());
// Get calendar displayed (moment object)
Ti.API.info(widget.calendarMonth());
}
function doNextMonth() {
var widget;
$.calendar.remove($.calendar.children[0]);
// Create next month calendar and add view
currentMonth.add('months', 1);
widget = Alloy.createWidget('jp.co.mountposition.calendar', 'widget', {period: currentMonth});
$.calendar.add(widget.getView());
Ti.API.info(widget.calendarMonth());
}
// You can select tile
$.current.select(18);
// You can add image
$.current.setImage(16, '/images/cafe.jpg');
// To handle the click event, set the listener to the parent View.
$.calendar.on('click', function(e) {
// You can get selectedDate. (moment object)
var selectedDate = $.current.selectedDate();
});
$.index.open();