save sidebar settings when Update View; fix bugs

This commit is contained in:
Oliver Gorwits
2014-11-01 12:26:04 +00:00
parent e83bc2185f
commit a1b5b301db
4 changed files with 44 additions and 45 deletions

View File

@@ -8,6 +8,10 @@ function do_search (event, tab) {
// stop form from submitting normally
event.preventDefault();
// save current sidebar settings
var datatable = $(target).find('table').first().DataTable();
datatable.state.save();
// hide or show sidebars depending on previous state,
// and whether the sidebar contains any content (detected by TT)
if (has_sidebar[tab] == 0) {
@@ -50,7 +54,6 @@ function do_search (event, tab) {
scrollingTop: 40
,useAbsolutePositioning: false
});
global_inner_view_processing(tab);
inner_view_processing(tab);
}
);
@@ -103,38 +106,6 @@ function update_content(from, to) {
$(to_form).trigger("submit");
}
// called after every ajax, in case updating anything is required
function global_inner_view_processing(tab) {
// find the current tab's datatables object
// then update sidebar checkboxes to hook the datatables colvis
var table = $('#' + tab + '_pane').find('table').first();
var colvis = new $.fn.dataTable.ColVis( table );
var columns = colvis.s.dt.aoColumns;
if ( $.inArray( 'all', colvis.s.exclude ) === -1 ) {
for ( var i=0, iLen=columns.length ; i<iLen ; i++ ) {
if ( $.inArray( i, colvis.s.exclude ) === -1 ) {
var button = colvis.dom.buttons.shift();
$(button).find('label').addClass('checkbox');
$(button).find('input').attr('id', columns[i]["name"]);
$(button).find('input').attr('name', columns[i]["name"]);
var target = $('#' + columns[i]["name"]);
$(button).find('span').text( target.closest('label').text() );
$(button).find('input').first().prop('checked', target.prop('checked'));
// need to re-activate tooltips on new content
$(button).click(function() {
$("[rel=tooltip]").tooltip({live: true});
});
target.closest('li').replaceWith( button );
}
}
}
}
// handler for ajax navigation
if (window.History && window.History.enabled) {
var History = window.History;