Skip to content

Commit

Permalink
task trigger and classes added
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq1988 committed Mar 15, 2014
1 parent 14df049 commit dedde67
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion includes/html.php
Expand Up @@ -17,6 +17,7 @@
*/
function cpm_task_html( $task, $project_id, $list_id, $single = false ) {
$wrap_class = ( $task->completed == '1' ) ? 'cpm-task-complete' : 'cpm-task-uncomplete';
$status_class = ( $task->completed == '1' ) ? 'cpm-complete' : 'cpm-uncomplete';

ob_start();
?>
Expand All @@ -31,7 +32,7 @@ function cpm_task_html( $task, $project_id, $list_id, $single = false ) {
<?php } ?>
</span>

<input type="checkbox" <?php cpm_data_attr( array('single' => $single, 'list' => $list_id, 'project' => $project_id ) ); ?> value="<?php echo $task->ID; ?>" name="" <?php checked( $task->completed, '1' ); ?>>
<input type="checkbox" class="<?php echo $status_class; ?>" <?php cpm_data_attr( array('single' => $single, 'list' => $list_id, 'project' => $project_id ) ); ?> value="<?php echo $task->ID; ?>" name="" <?php checked( $task->completed, '1' ); ?>>

<span class="move"></span>
<span class="cpm-todo-content">
Expand Down
25 changes: 19 additions & 6 deletions js/task.js
Expand Up @@ -16,8 +16,8 @@
$('.cpm-single-task').on('click', '.cpm-todo-action a.cpm-todo-edit', this.toggleEditTodo);
$('.cpm-single-task').on('click', '.cpm-task-edit-form a.todo-cancel', this.toggleEditTodo);
$('.cpm-single-task').on('submit', '.cpm-task-edit-form form', this.updateTodo);
$('.cpm-single-task').on('click', '.cpm-task-uncomplete input[type=checkbox]', this.markDone);
$('.cpm-single-task').on('click', '.cpm-task-complete input[type=checkbox]', this.markUnDone);
$('.cpm-single-task').on('click', 'input[type=checkbox].cpm-uncomplete', this.markDone);
$('.cpm-single-task').on('click', 'input[type=checkbox].cpm-complete', this.markUnDone);
$('.cpm-single-task').on('click', 'a.cpm-todo-delete', this.deleteTodo);

//task done, undone, delete
Expand Down Expand Up @@ -125,10 +125,12 @@
action: 'cpm_task_complete',
'_wpnonce': CPM_Vars.nonce
};


$(document).trigger('cpm.markDone.before', [self]);

$.post(CPM_Vars.ajaxurl, data, function (res) {
res = JSON.parse(res);

$(document).trigger('cpm.markDone.after', [res,self]);
if(res.success === true ) {

if(list.length) {
Expand Down Expand Up @@ -162,7 +164,8 @@
'_wpnonce': CPM_Vars.nonce
};


$(document).trigger('cpm.markUnDone.before', [self]);

$.post(CPM_Vars.ajaxurl, data, function (res) {
res = JSON.parse(res);

Expand All @@ -181,6 +184,8 @@
singleWrap.html(res.content);
}
}

$(document).trigger('cpm.markUnDone.after', [res,self]);
});
},

Expand Down Expand Up @@ -209,6 +214,8 @@
} else {
alert('something went wrong!');
}

$(document).trigger('cpm.submitNewTodo.after',[res,self]);
});
} else {
alert('type something');
Expand All @@ -234,7 +241,9 @@
if( confirm(confirmMsg) ) {
$.post(CPM_Vars.ajaxurl, data, function (res) {
res = JSON.parse(res);


$(document).trigger('cpm.deleteTodo.after',[res,self]);

if(res.success) {
if(single !== '') {
location.href = res.list_url;
Expand Down Expand Up @@ -283,6 +292,8 @@
} else {
alert('something went wrong!');
}

$(document).trigger('cpm.updateTodo.after',[res,self]);
});
} else {
alert('type something');
Expand Down Expand Up @@ -355,6 +366,8 @@
self.closest('li').html(res.content);
$('.datepicker').datepicker();
}

$(document).trigger('cpm.updateList.after',[res,self]);
});
},

Expand Down

0 comments on commit dedde67

Please sign in to comment.