Example #1
0
	done.addEventListener('click', function(e) {
		enable_status = (db.daylist(focus_date).length > 0);
		del.setEnabled(enable_status);
		edit.setEnabled(enable_status);
		done.setEnabled(false);

		// stop movability of tasks
		tasks_table.setMoving(false);

		// stop editability of tasks
		tasks_table.setEditing(false);
		tasks_table.setFocusable(true);
		tasks_table.addEventListener('delete', function(e) {
			db.del(e.rowData.id);
		});

		// use reorder() to save the order of possibly user adjusted tasks
		if (db.daycount(focus_date) > 1) {
			var reorderedTaskList = tasks_table.data[0];
			var taskIDList = new Array();
			for (var i = 0; i < reorderedTaskList.rowCount; i++) {
				var row = reorderedTaskList.rows[i];
				taskIDList.push(row.id);
			}
			db.reorder(taskIDList);
		}

		// reset swipe event listener
		self.addEventListener('swipe', swipeEvent);
	});
Example #2
0
	self.setScrollable = function(new_date) {
		tasks_table.setScrollable((db.daycount(new_date) > 7));
	};
Example #3
0
	self.setButtons = function(new_date) {
		var enable_status = (db.daycount(new_date) > 0);
		edit.setEnabled(enable_status);
		del.setEnabled(enable_status);
		done.setEnabled(false);
	};
Example #4
0
var calendar = function(yr, mo, syr, smo, sda, tyr, tmo, tda, sizes, _cb) {
	// yr,mo,da are selected day; tyr,tmo,tda are today
	//create main calendar view
	var mainView = Ti.UI.createView({
		layout : 'horizontal',
		width : sizes.CAL_W,
		height : 'auto',
		cb : _cb
	});

	// determine the cal data
	var isCurrentMonth = (yr == tyr && mo == tmo);
	var isSelectedMonth = (yr == syr && mo == smo);
	var daysInMonth = 32 - new Date(yr, mo, 32).getDate();
	var dayOfMonthToday = tda;
	var dayOfWeek = new Date(yr, mo, 1).getDay();
	var daysInLastMonth = 32 - new Date(yr, mo - 1, 32).getDate();
	var daysInNextMonth = (new Date(yr, mo, daysInMonth).getDay()) - 6;
	//set initial day of week number
	var dayNumber = daysInLastMonth - dayOfWeek + 1;
	//get last month's days
	for ( i = 0; i < dayOfWeek; i++) {
		mainView.add(new dayView({
			width: sizes.DAY_W,
			height: sizes.DAY_H,
			fontSize: sizes.DAY_TEXT,
			day : dayNumber,
			taskcount : db.daycount(new Date(yr, mo, dayNumber)),
			color : '#8e959f',
			current : 'no',
		}));
		dayNumber++;
	};
	// reset day number for current month
	dayNumber = 1;
	//get this month's days
	var oldDay = {};
	for ( i = 0; i < daysInMonth; i++) {
		var newDay = new dayView({
			day : dayNumber,
			width: sizes.DAY_W,
			height: sizes.DAY_H,
			fontSize: sizes.DAY_TEXT,
			taskcount : db.daycount(new Date(yr, mo, dayNumber)),
			color : util.CalendarWindowColor.CURRENTDATE_COLOR, //'#3a4756',
			current : 'yes',
		});
		mainView.add(newDay);
		// if this day is today, show it
		if (isCurrentMonth && tda == dayNumber) {
			//newDay.color = 'white';
			newDay.backgroundColor = util.CalendarWindowColor.CURRENTDATE_COLOR; //'#FFFFF000';
			oldDay = newDay;
		}
		// if this day is the chosen day, select it
		if (isSelectedMonth && dayNumber == sda)
			select(newDay);
		dayNumber++;
	}
	// reset day number for next month
	dayNumber = 1;
	//get remaining month's days
	for ( i = 0; i > daysInNextMonth; i--) {
		mainView.add(new dayView({
			width: sizes.DAY_W,
			height: sizes.DAY_H,
			fontSize: sizes.DAY_TEXT,
			day : dayNumber,
			taskcount : db.daycount(new Date(yr, mo, dayNumber)),
			color : '#8e959f',
			current : 'no',
		}));
		dayNumber++;
	}
	// day selection event listener
	mainView.addEventListener('click', function(e) {
		if (e.source.current == 'yes') {
			select(e.source);
			if (mainView.cb != null)
				mainView.cb(new Date(yr, mo, e.source.text));
		}
	});
	return mainView;

	// function to highlight selected day
	function select(dayView) {
		if (isCurrentMonth && oldDay.text == dayOfMonthToday) {
			//oldDay.color = 'white';
			oldDay.backgroundColor = util.CalendarWindowColor.CURRENTDATE_COLOR;			//'#FFFFF000';
			oldDay.borderColor = util.CalendarWindowColor.CURRENTDATE_COLOR;
		} else {
			//oldDay.color = '#3a4756';
			oldDay.backgroundColor = util.CalendarWindowColor.FOCUSDATE_COLOR;			//'#FFDCDCDF';
			oldDay.borderColor = util.CalendarWindowColor.FOCUSDATE_COLOR;
		}
		oldDay.backgroundPaddingLeft = 0;
		oldDay.backgroundPaddingBottom = 0;
		if (isCurrentMonth && dayView.text == dayOfMonthToday) {
			dayView.backgroundColor = util.CalendarWindowColor.OVERLAP_COLOR;			//'#FFFF00FF';
			dayView.borderColor = util.CalendarWindowColor.OVERLAP_COLOR;
		} else {
			dayView.backgroundColor = util.CalendarWindowColor.FOCUSDATE_COLOR;			//'#FFFF0000';
			dayView.borderColor = util.CalendarWindowColor.FOCUSDATE_COLOR;
		}
		// to fix the strange color bug we were having, reclicking the overlapping date should not result in a color change
		if (oldDay.text == dayView.text && dayView.backgroundColor == util.CalendarWindowColor.OVERLAP_COLOR){
			dayView.backgroundColor = util.CalendarWindowColor.OVERLAP_COLOR;			//'#FFFF00FF';
			dayView.borderColor = util.CalendarWindowColor.OVERLAP_COLOR;
			oldDay.backgroundColor = util.CalendarWindowColor.OVERLAP_COLOR;			//'#FFFF00FF';
			oldDay.borderColor = util.CalendarWindowColor.OVERLAP_COLOR;
		}
		dayView.backgroundPaddingLeft = 1;
		dayView.backgroundPaddingBottom = 1;
		//dayView.color = 'white';
		oldDay = dayView;
	};
};