+ }).
+ on('shown.bs.tab', 'a[data-toggle="tab"]', function(event) {
+ $(event.target.getAttribute('href') + ' [data-infinite-scroller]').
+ trigger('scroll');
+ }).
+ on('click', 'th[data-sort-order]', function() {
+ var direction = $(this).data('sort-order-direction');
+ // reverse the current direction, or do ascending if none
+ if( direction === undefined || direction === 'desc' ) {
+ direction = 'asc';
+ } else {
+ direction = 'desc';
+ }
+
+ var $container = $(this).closest('table').find('[data-infinite-content-params-attr]');
+
+ var order = setColumnSort( $container, $(this), direction );
+
+ // put it in the browser history state if browser allows it
+ if( hasHTML5History() ) {
+ var tabId = $(this).closest('div.tab-pane').attr('id');
+ var state = history.state || {};
+ if( state.order === undefined ) {
+ state.order = {};
+ }
+ state.order[tabId] = order;
+ history.replaceState( state, null, null );
+ }
+
+ $container.trigger('refresh-content');
+ }).
+ on('sort-icons', function() {
+ // set or reset the icon next to each sortable column header according to the current direction attribute
+ $('th[data-sort-order]').each(function() {
+ $(this).find('i').remove();
+ var direction = $(this).data('sort-order-direction');
+ if( direction !== undefined ) {
+ $(this).append('<i class="fa fa-sort-' + direction + '"/>');
+ } else {
+ $(this).append('<i class="fa fa-sort"/>');
+ }
+ });