Improve stats table filters
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
// Switch tabs
|
||||
// Tab switcher
|
||||
$('.sp-tab-panel').siblings('.sp-tab-bar').find('a').click(function() {
|
||||
$(this).closest('li').removeClass('wp-tab').addClass('wp-tab-active').siblings().removeClass('wp-tab-active').addClass('wp-tab').closest('.wp-tab-bar').siblings($(this).attr('href')).show().siblings('.wp-tab-panel').hide();
|
||||
return false;
|
||||
});
|
||||
|
||||
// Filter tabs
|
||||
// Tab filter
|
||||
$('.sp-tab-panel').siblings('.sp-tab-select').find('select').change(function() {
|
||||
var val = $(this).val();
|
||||
$(this).closest('.sp-tab-select').siblings('.sp-tab-panel').find('.sp-post').hide(0, function() {
|
||||
@@ -17,37 +17,44 @@ jQuery(document).ready(function($){
|
||||
});
|
||||
});
|
||||
|
||||
// Activate tab filters
|
||||
// Trigger tab filter
|
||||
$('.sp-tab-panel').siblings('.sp-tab-select').find('select').change();
|
||||
|
||||
// Data table checkboxes
|
||||
$('.sp-data-table tr input[type=checkbox]').change(function() {
|
||||
$el = $(this).closest('tr').find('input[type=text], input[type=number]');
|
||||
$el.prop('readonly', $(this).prop('checked'));
|
||||
if($(this).prop('checked')) {
|
||||
$el.each(function() {
|
||||
$(this).val($(this).attr('placeholder'));
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
// Uncheck auto to edit
|
||||
$('.sp-data-table tr input[type=text], .sp-data-table tr input[type=text]').click(function() {
|
||||
$el = $(this).closest('tr').find('input[type=checkbox]');
|
||||
if($el.size()) {
|
||||
$el.prop('checked', false).change();
|
||||
}
|
||||
})
|
||||
|
||||
// Activate checkboxes
|
||||
$('.sp-data-table tr input[type=checkbox]').change();
|
||||
|
||||
// Change title
|
||||
$('.sp-title-generator select').change(function() {
|
||||
// Title changer
|
||||
$('input[name=post_title]').on('updateTitle', function() {
|
||||
title = $('.sp-title-generator select[value!=0]').map(function(){
|
||||
return $(this).find(':selected').html().replace(/&[^;]+;/g, '');
|
||||
}).get().join(' vs ');
|
||||
$('input[name=post_title]').val(title);
|
||||
$(this).val(title);
|
||||
});
|
||||
|
||||
// Activate title changer
|
||||
$('.sp-title-generator select').change(function() {
|
||||
$('input[name=post_title]').trigger('updateTitle');
|
||||
});
|
||||
|
||||
// Total stats calculator
|
||||
$('.sp-stats-table').on('updateTotals', function() {
|
||||
$self = $(this);
|
||||
$self.find('.sp-total input').each(function(i) {
|
||||
var sum = 0;
|
||||
$self.find('.sp-post').each(function() {
|
||||
$el = $($(this).find('input')[i]);
|
||||
if($el.val() != '')
|
||||
if($.isNumeric($el.val())) sum += parseInt($el.val(), 10);
|
||||
else
|
||||
sum += parseInt($el.attr('placeholder'), 10);
|
||||
});
|
||||
$(this).attr('placeholder', sum);
|
||||
});
|
||||
});
|
||||
|
||||
// Activate total stats calculator
|
||||
$('.sp-stats-table .sp-post input').on('keyup', function() {
|
||||
$(this).closest('.sp-stats-table').trigger('updateTotals');
|
||||
});
|
||||
|
||||
// Trigger total stats calculator
|
||||
$('.sp-stats-table').trigger('updateTotals');
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user