Skip to content

Instantly share code, notes, and snippets.

@h5y1m141
Created June 16, 2012 00:19
Show Gist options
  • Save h5y1m141/2939329 to your computer and use it in GitHub Desktop.
Save h5y1m141/2939329 to your computer and use it in GitHub Desktop.
var startYear = 2012;
var startMonth= 6;
var year = startYear;
var month = startMonth;
var title = year+ '年' + month +'月';
var calendarData = require('ui/calendarData');
var calendar = require('ui/weeklyCalendar');
var rows = calendarData.make(startYear,startMonth);
var calendarRow = calendar.make(rows);
var tableView = Ti.UI.createTableView({
backgroundColor:'#ededed',
separatorColor: '#999',
zIndex:2,
width:320,
left:0,
top:40
});
tableView.setData(calendarRow);
var win1 = Titanium.UI.createWindow();
var yearLabel = Ti.UI.createLabel({
text:title,
color:'#FFF'
});
var forwardBtn = Titanium.UI.createButton({
title:String.fromCharCode(0x25b6)
});
forwardBtn.addEventListener('click',function(e){
win1.remove(tableView);
if(month===12){
year++;
month=1;
}else{
month++;
}
barTitle.setText(year+ '年' + month +'月');
rows = calendarData.make(year,month);
calendarRow = calendar.make(rows);
tableView.setData(calendarRow);
win1.add(tableView);
});
var backBtn = Titanium.UI.createButton({
title:String.fromCharCode(0x25c0)
});
backBtn.addEventListener('click',function(e){
win1.remove(tableView);
if(month===1){
year--;
month=12;
}else{
month--;
}
barTitle.setText(year+ '年' + month +'月');
rows = calendarData.make(year,month);
calendarRow = calendar.make(rows);
tableView.setData(calendarRow);
win1.add(tableView);
});
var barTitle = Ti.UI.createLabel({
textAlign:1, //0:左揃え、 1:中央揃え、2:右揃え
text:title,
width:100,
color:'#FFF',
font:{
fontSize:14
}
});
var flexSpace = Titanium.UI.createButton({
systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});
var toolBar = Ti.UI.iOS.createToolbar({
items:[flexSpace,backBtn,barTitle,forwardBtn,flexSpace],
top:0,
left:0,
height:40,
zIndex:10
});
win1.add(toolBar);
win1.add(tableView);
win1.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment