Add inline result editing
This commit is contained in:
@@ -60,8 +60,8 @@
|
||||
content: "\f504";
|
||||
}
|
||||
|
||||
.fixed .column-sp_team .result,
|
||||
.sp-calendar-table .result {
|
||||
.fixed .column-sp_team .sp-result,
|
||||
.sp-calendar-table .sp-result {
|
||||
background: #888;
|
||||
color: #fff;
|
||||
font-size: 11px;
|
||||
@@ -77,11 +77,16 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.fixed .column-sp_team .result:hover,
|
||||
.sp-calendar-table .result:hover {
|
||||
.fixed .column-sp_team .sp-result:hover,
|
||||
.sp-calendar-table .sp-result:hover {
|
||||
background: #2ea2cc;
|
||||
}
|
||||
|
||||
.fixed .column-sp_team .sp-edit-result {
|
||||
font-size: 11px;
|
||||
line-height: 1.4em;
|
||||
}
|
||||
|
||||
.fixed .column-sp_format,
|
||||
.fixed .column-sp_icon,
|
||||
.fixed .column-sp_number {
|
||||
|
||||
@@ -547,6 +547,60 @@ jQuery(document).ready(function($){
|
||||
});
|
||||
$(".sp-date-selector select").trigger("change");
|
||||
|
||||
// Edit inline results
|
||||
$("#the-list").on("click", ".sp-result, .sp-edit-results", function(){
|
||||
team = $(this).data("team");
|
||||
$column = $(this).closest(".column-sp_team");
|
||||
$column.find(".sp-result, .sp-row-actions").hide();
|
||||
$column.find(".sp-edit-result, .sp-inline-edit-save").show();
|
||||
if ( team != undefined ) {
|
||||
$column.find(".sp-edit-result[data-team='"+team+"']").select();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// Cancel inline results
|
||||
$("#the-list").on("click", ".sp-inline-edit-save .cancel", function(){
|
||||
$column = $(this).closest(".column-sp_team");
|
||||
$column.find(".sp-edit-result, .sp-inline-edit-save").hide();
|
||||
$column.find(".sp-result, .sp-row-actions").show();
|
||||
return false;
|
||||
});
|
||||
|
||||
// Save inline results
|
||||
$("#the-list").on("click", ".sp-inline-edit-save .save", function(){
|
||||
$column = $(this).closest(".column-sp_team");
|
||||
results = [];
|
||||
$column.find(".sp-edit-result").each(function() {
|
||||
team = {};
|
||||
team.id = $(this).data("team");
|
||||
team.key = $(this).data("key");
|
||||
team.result = $(this).val();
|
||||
results.push( team );
|
||||
});
|
||||
$.post( ajaxurl, {
|
||||
action: "sp-save-inline-results",
|
||||
post_id: $column.find("input[name='sp_post_id']").val(),
|
||||
results: results,
|
||||
nonce: $("#sp-inline-nonce").val()
|
||||
}, function(response) {
|
||||
$column.find(".sp-edit-result").each(function() {
|
||||
$column.find(".sp-result[data-team='"+$(this).data("team")+"']").html($(this).val());
|
||||
});
|
||||
$column.find(".sp-edit-result, .sp-inline-edit-save").hide();
|
||||
$column.find(".sp-result, .sp-row-actions").show();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
// Override inline form submission
|
||||
$("#the-list").on("keypress", ".sp-edit-result", function(e) {
|
||||
if ( e.which == 13 ) {
|
||||
$(this).closest(".column-sp_team").find(".sp-inline-edit-save .save").trigger("click");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Fitvids
|
||||
$(".sp-fitvids").fitVids();
|
||||
});
|
||||
Reference in New Issue
Block a user