Add offense and defense support to lazy loading
This commit is contained in:
@@ -636,6 +636,8 @@ jQuery(document).ready(function($){
|
|||||||
$target = $(".sp-instance").eq(index).find(".sp-ajax-checklist ul");
|
$target = $(".sp-instance").eq(index).find(".sp-ajax-checklist ul");
|
||||||
if ( response.success ) {
|
if ( response.success ) {
|
||||||
$target.html("");
|
$target.html("");
|
||||||
|
i = 0;
|
||||||
|
if(-1 == response.data.sections) {
|
||||||
if(response.data.players.length) {
|
if(response.data.players.length) {
|
||||||
$target.eq(0).append("<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>");
|
$target.eq(0).append("<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>");
|
||||||
$(response.data.players).each(function( key, value ) {
|
$(response.data.players).each(function( key, value ) {
|
||||||
@@ -645,14 +647,38 @@ jQuery(document).ready(function($){
|
|||||||
} else {
|
} else {
|
||||||
$target.eq(0).html("<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_players\">" + localized_strings.show_all + "</a></li>");
|
$target.eq(0).html("<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_players\">" + localized_strings.show_all + "</a></li>");
|
||||||
}
|
}
|
||||||
if(response.data.staff.length) {
|
|
||||||
$target.eq(1).append("<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>");
|
|
||||||
$(response.data.staff).each(function( key, value ) {
|
|
||||||
$target.eq(1).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_staff[" + index + "][]\">" + value.post_title + "</li>");
|
|
||||||
});
|
|
||||||
$target.eq(1).append("<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_staffs\">" + localized_strings.show_all + "</a></li>");
|
|
||||||
} else {
|
} else {
|
||||||
$target.eq(1).html("<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_staffs\">" + localized_strings.show_all + "</a></li>");
|
if ( 1 == response.data.sections ) {
|
||||||
|
defense = i;
|
||||||
|
offense = i+1;
|
||||||
|
} else {
|
||||||
|
offense = i;
|
||||||
|
defense = i+1;
|
||||||
|
}
|
||||||
|
if(response.data.players.length) {
|
||||||
|
$target.eq(offense).append("<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>");
|
||||||
|
$target.eq(defense).append("<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>");
|
||||||
|
$(response.data.players).each(function( key, value ) {
|
||||||
|
$target.eq(offense).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_offense[" + index + "][]\">" + value.post_title + "</li>");
|
||||||
|
$target.eq(defense).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_defense[" + index + "][]\">" + value.post_title + "</li>");
|
||||||
|
});
|
||||||
|
$target.eq(offense).append("<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_offense\">" + localized_strings.show_all + "</a></li>");
|
||||||
|
$target.eq(defense).append("<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_defense\">" + localized_strings.show_all + "</a></li>");
|
||||||
|
} else {
|
||||||
|
$target.eq(offense).html("<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_offense\">" + localized_strings.show_all + "</a></li>");
|
||||||
|
$target.eq(defense).html("<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_defense\">" + localized_strings.show_all + "</a></li>");
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
if(response.data.staff.length) {
|
||||||
|
$target.eq(i).append("<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>");
|
||||||
|
$(response.data.staff).each(function( key, value ) {
|
||||||
|
$target.eq(i).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_staff[" + index + "][]\">" + value.post_title + "</li>");
|
||||||
|
});
|
||||||
|
$target.eq(i).append("<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_staffs\">" + localized_strings.show_all + "</a></li>");
|
||||||
|
} else {
|
||||||
|
$target.eq(i).html("<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_staffs\">" + localized_strings.show_all + "</a></li>");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$target.html("<li>" + localized_strings.no_results_found + "</li>");
|
$target.html("<li>" + localized_strings.no_results_found + "</li>");
|
||||||
@@ -679,20 +705,43 @@ jQuery(document).ready(function($){
|
|||||||
$target = $(".sp-instance").eq(index).find(".sp-ajax-checklist ul");
|
$target = $(".sp-instance").eq(index).find(".sp-ajax-checklist ul");
|
||||||
$target.find(".sp-ajax-show-all-container").hide();
|
$target.find(".sp-ajax-show-all-container").hide();
|
||||||
if ( response.success ) {
|
if ( response.success ) {
|
||||||
|
i = 0;
|
||||||
|
console.log(response.data.sections);
|
||||||
|
if ( -1 == response.data.sections ) {
|
||||||
if(response.data.players.length) {
|
if(response.data.players.length) {
|
||||||
$(response.data.players).each(function( key, value ) {
|
$(response.data.players).each(function( key, value ) {
|
||||||
if($target.find("input[value=" + value.ID + "]").length) return true;
|
//if($target.eq(i).find("input[value=" + value.ID + "]").length) return true;
|
||||||
$target.eq(0).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_player[" + index + "][]\">" + value.post_title + "</li>");
|
$target.eq(i).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_player[" + index + "][]\">" + value.post_title + "</li>");
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$target.eq(0).html("<li>" + localized_strings.no_results_found + "</li>");
|
$target.eq(i).html("<li>" + localized_strings.no_results_found + "</li>");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if(response.data.players.length) {
|
||||||
|
if ( 1 == response.data.sections ) {
|
||||||
|
defense = i;
|
||||||
|
offense = i+1;
|
||||||
|
} else {
|
||||||
|
offense = i;
|
||||||
|
defense = i+1;
|
||||||
|
}
|
||||||
|
$(response.data.players).each(function( key, value ) {
|
||||||
|
$target.eq(offense).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_offense[" + index + "][]\">" + value.post_title + "</li>");
|
||||||
|
$target.eq(defense).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_defense[" + index + "][]\">" + value.post_title + "</li>");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$target.eq(offense).html("<li>" + localized_strings.no_results_found + "</li>");
|
||||||
|
$target.eq(defense).html("<li>" + localized_strings.no_results_found + "</li>");
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
if(response.data.staff.length) {
|
if(response.data.staff.length) {
|
||||||
$(response.data.staff).each(function( key, value ) {
|
$(response.data.staff).each(function( key, value ) {
|
||||||
$target.eq(1).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_staff[" + index + "][]\">" + value.post_title + "</li>");
|
$target.eq(i).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_staff[" + index + "][]\">" + value.post_title + "</li>");
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$target.eq(1).html("<li>" + localized_strings.no_results_found + "</li>");
|
$target.eq(i).html("<li>" + localized_strings.no_results_found + "</li>");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$target.html("<li>" + localized_strings.no_results_found + "</li>");
|
$target.html("<li>" + localized_strings.no_results_found + "</li>");
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ class SportsPress_Lazy_Loading {
|
|||||||
|
|
||||||
$data['players'] = $players;
|
$data['players'] = $players;
|
||||||
$data['staff'] = $staff;
|
$data['staff'] = $staff;
|
||||||
|
$data['sections'] = get_option( 'sportspress_event_performance_sections', -1 );
|
||||||
|
|
||||||
wp_send_json_success( $data );
|
wp_send_json_success( $data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user