Skip to content

Instantly share code, notes, and snippets.

@Zambonilli
Created March 17, 2014 21:29
Show Gist options
  • Save Zambonilli/9608773 to your computer and use it in GitHub Desktop.
Save Zambonilli/9608773 to your computer and use it in GitHub Desktop.
redraw perf w/short circuits
ft.redraw = function () {
var start = new Date();
//add the toggler to each row
ft.addRowToggle();
//bind the toggle selector click events
ft.bindToggleSelectors();
//set any cell classes defined for the columns
ft.setColumnClasses();
var $table = $(ft.table),
breakpointName = $table.data('breakpoint'),
hasBreakpointFired = ft.hasBreakpointColumn(breakpointName);
$table
.find('> tbody > tr:not(.' + cls.detail + ')').data('detail_created', false).end()
.find('> thead > tr:last-child > th')
.each(function () {
var data = ft.columns[$(this).index()], selector = '', first = true;
if (data.hide[breakpointName]){
$.each(data.matches, function (m, match) {
if (!first) {
selector += ', ';
}
var count = match + 1;
//selector += '> tbody > tr:not(.' + cls.detail + ') > td:nth-child(' + count + ')';
selector += '> tbody > td:nth-child(' + count + ')';
//selector += ', > tfoot > tr:not(.' + cls.detail + ') > td:nth-child(' + count + ')';
//selector += ', > colgroup > col:nth-child(' + count + ')';
first = false;
});
selector += ', > thead > tr[data-group-row="true"] > th[data-group="' + data.group + '"]';
var $column = $table.find(selector).add(this);
$column.hide();
}
/*if ($table.find('> thead > tr.footable-group-row').length === 1) {
var $groupcols = $table.find('> thead > tr:last-child > th[data-group="' + data.group + '"]:visible, > thead > tr:last-child > th[data-group="' + data.group + '"]:visible'),
$group = $table.find('> thead > tr.footable-group-row > th[data-group="' + data.group + '"], > thead > tr.footable-group-row > td[data-group="' + data.group + '"]'),
groupspan = 0;
$.each($groupcols, function () {
groupspan += parseInt($(this).attr('colspan') || 1, 10);
});
if (groupspan > 0) $group.attr('colspan', groupspan).show();
else $group.hide();
}*/
});
/*.end()
.find('> tbody > tr.' + cls.detailShow).each(function () {
ft.createOrUpdateDetailRow(this);
});*/
/*$table.find('> tbody > tr.' + cls.detailShow + ':visible').each(function () {
var $next = $(this).next();
if ($next.hasClass(cls.detail)) {
if (!hasBreakpointFired) $next.hide();
else $next.show();
}
});*/
// adding .footable-first-column and .footable-last-column to the first and last th and td of each row in order to allow
// for styling if the first or last column is hidden (which won't work using :first-child or :last-child)
/*$table.find('> thead > tr > th.footable-last-column, > tbody > tr > td.footable-last-column').removeClass('footable-last-column');
$table.find('> thead > tr > th.footable-first-column, > tbody > tr > td.footable-first-column').removeClass('footable-first-column');
$table.find('> thead > tr, > tbody > tr')
.find('> th:visible:last, > td:visible:last')
.addClass('footable-last-column')
.end()
.find('> th:visible:first, > td:visible:first')
.addClass('footable-first-column');*/
ft.raise(evt.redrawn);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment