- // deal with sorting if was set on this page for this tab already
- var tabId = $(this).closest('div.tab-pane').attr('id');
- if( typeof(history.state.order) !== 'undefined' && typeof(history.state.order[tabId]) !== 'undefined' ) {
- // we will use the list of one or more table columns associated with this header to find the right element
- // see sortable_columns as it is passed to render_pane in the various tab .erbs (e.g. _show_jobs_and_pipelines.html.erb)
- var strippedColumns = history.state.order[tabId].replace(/\s|asc|desc/g,'');
- var sortDirection = history.state.order[tabId].split(" ")[1].replace(/,/,'');
- $columnHeader = $(this).closest('table').find('[data-sort-order="'+ strippedColumns +'"]');
- setColumnSort( $(this), $columnHeader, sortDirection );
- } else {
- // otherwise just reset the sort icons
- $(this).trigger('sortIcons');
+ // deal with sorting if there is any, and if it was set on this page for this tab already
+ if( $('th[data-sort-order]').length ) {
+ var tabId = $(this).closest('div.tab-pane').attr('id');
+ if( hasHTML5History() && history.state !== undefined && history.state !== null && history.state.order !== undefined && history.state.order[tabId] !== undefined ) {
+ // we will use the list of one or more table columns associated with this header to find the right element
+ // see sortable_columns as it is passed to render_pane in the various tab .erbs (e.g. _show_jobs_and_pipelines.html.erb)
+ var strippedColumns = history.state.order[tabId].replace(/\s|\basc\b|\bdesc\b/g,'');
+ var sortDirection = history.state.order[tabId].split(" ")[1].replace(/,/,'');
+ $columnHeader = $(this).closest('table').find('[data-sort-order="'+ strippedColumns +'"]');
+ setColumnSort( $(this), $columnHeader, sortDirection );
+ } else {
+ // otherwise just reset the sort icons
+ $(this).trigger('sort-icons');
+ }