(Go Back) Choose State To Move From
') {
return;
}
var self = this;
function addTask(task, action) {
var taskInfo = task + " " + action;
var taskItem = $('
if (action === 'complete') {
taskItem.addClass('complete');
}
else {
taskItem.addClass('incomplete');
}
taskItem.on('click', function () {
self._onTaskClick(taskInfo);
});
self._taskList.append(taskItem);
}
var taskList = this._taskList;
taskList.html('');
for (var i = 0; i < tasks.length; i++) {
var task = tasks[i];
var action = actions[i];
addTask(task, action);
}
};
TaskList.prototype._onTaskClick = function (taskInfo) {
var task = taskInfo.split(' ')[0];
var action = taskInfo.split(' ')[1];
if (action === 'complete') {
this._taskList.find('#' + taskInfo).removeClass('complete').addClass('incomplete');
this._taskList.find('#' + taskInfo + ' .action').text('incomplete');
}
else {
this._taskList.find('#' + taskInfo).removeClass('incomplete').addClass('complete');
this._taskList.find('#' + taskInfo + ' .action').text('complete');
}
};
TaskList.prototype.show = function () {
this._taskList.show();
};
TaskList.prototype.hide = function () {
this._taskList.hide();
};
return TaskList;
});