Skip to content

Commit 346aeed

Browse files
authored
Merge pull request #16287 from uberbrady/better_hover_titles
Fixes: [sc-28423] Better tooltips on lists, Bootstrap style
2 parents 84a2937 + 2d1e9b2 commit 346aeed

File tree

2 files changed

+86
-58
lines changed

2 files changed

+86
-58
lines changed

app/Presenters/AssetPresenter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static function dataTableLayout()
2121
[
2222
'field' => 'checkbox',
2323
'checkbox' => true,
24+
'titleTooltip' => 'Toggle Select All' //FIXME - translate.
2425
], [
2526
'field' => 'id',
2627
'searchable' => false,

resources/views/partials/bootstrap-table.blade.php

Lines changed: 85 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -39,66 +39,93 @@
3939
return htmlData
4040
}
4141
$(this).bootstrapTable({
42-
classes: 'table table-responsive table-no-bordered',
43-
ajaxOptions: {
44-
headers: {
45-
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
46-
}
47-
},
48-
// reorderableColumns: true,
49-
stickyHeader: true,
50-
stickyHeaderOffsetLeft: parseInt($('body').css('padding-left'), 10),
51-
stickyHeaderOffsetRight: parseInt($('body').css('padding-right'), 10),
52-
undefinedText: '',
53-
iconsPrefix: 'fa',
54-
cookieStorage: '{{ config('session.bs_table_storage') }}',
55-
cookie: true,
56-
cookieExpire: '2y',
57-
showColumnsToggleAll: true,
58-
minimumCountColumns: 2,
59-
mobileResponsive: true,
60-
maintainSelected: true,
61-
trimOnSearch: false,
62-
showSearchClearButton: true,
63-
addrbar: {{ (config('session.bs_table_addrbar') == 'true') ? 'true' : 'false'}}, // deeplink search phrases, sorting, etc
64-
paginationFirstText: "{{ trans('general.first') }}",
65-
paginationLastText: "{{ trans('general.last') }}",
66-
paginationPreText: "{{ trans('general.previous') }}",
67-
paginationNextText: "{{ trans('general.next') }}",
68-
pageList: ['10','20', '30','50','100','150','200'{!! ((config('app.max_results') > 200) ? ",'500'" : '') !!}{!! ((config('app.max_results') > 500) ? ",'".config('app.max_results')."'" : '') !!}],
69-
pageSize: {{ (($snipeSettings->per_page!='') && ($snipeSettings->per_page > 0)) ? $snipeSettings->per_page : 20 }},
70-
paginationVAlign: 'both',
71-
queryParams: function (params) {
72-
var newParams = {};
73-
for(var i in params) {
74-
if(!keyBlocked(i)) { // only send the field if it's not in blockedFields
75-
newParams[i] = params[i];
42+
classes: 'table table-responsive table-no-bordered',
43+
ajaxOptions: {
44+
headers: {
45+
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
46+
}
47+
},
48+
// reorderableColumns: true,
49+
stickyHeader: true,
50+
stickyHeaderOffsetLeft: parseInt($('body').css('padding-left'), 10),
51+
stickyHeaderOffsetRight: parseInt($('body').css('padding-right'), 10),
52+
undefinedText: '',
53+
iconsPrefix: 'fa',
54+
cookieStorage: '{{ config('session.bs_table_storage') }}',
55+
cookie: true,
56+
cookieExpire: '2y',
57+
showColumnsToggleAll: true,
58+
minimumCountColumns: 2,
59+
mobileResponsive: true,
60+
maintainSelected: true,
61+
trimOnSearch: false,
62+
showSearchClearButton: true,
63+
addrbar: {{ (config('session.bs_table_addrbar') == 'true') ? 'true' : 'false'}}, // deeplink search phrases, sorting, etc
64+
paginationFirstText: "{{ trans('general.first') }}",
65+
paginationLastText: "{{ trans('general.last') }}",
66+
paginationPreText: "{{ trans('general.previous') }}",
67+
paginationNextText: "{{ trans('general.next') }}",
68+
pageList: ['10', '20', '30', '50', '100', '150', '200'{!! ((config('app.max_results') > 200) ? ",'500'" : '') !!}{!! ((config('app.max_results') > 500) ? ",'".config('app.max_results')."'" : '') !!}],
69+
pageSize: {{ (($snipeSettings->per_page!='') && ($snipeSettings->per_page > 0)) ? $snipeSettings->per_page : 20 }},
70+
paginationVAlign: 'both',
71+
queryParams: function (params) {
72+
var newParams = {};
73+
for (var i in params) {
74+
if (!keyBlocked(i)) { // only send the field if it's not in blockedFields
75+
newParams[i] = params[i];
76+
}
7677
}
78+
return newParams;
79+
},
80+
formatLoadingMessage: function () {
81+
return '<h2><x-icon type="spinner" /> {{ trans('general.loading') }} </h2>';
82+
},
83+
icons: {
84+
advancedSearchIcon: 'fas fa-search-plus',
85+
paginationSwitchDown: 'fa-caret-square-o-down',
86+
paginationSwitchUp: 'fa-caret-square-o-up',
87+
fullscreen: 'fa-expand',
88+
columns: 'fa-columns',
89+
refresh: 'fas fa-sync-alt',
90+
export: 'fa-download',
91+
clearSearch: 'fa-times'
92+
},
93+
locale: '{{ app()->getLocale() }}',
94+
exportOptions: export_options,
95+
exportTypes: ['xlsx', 'excel', 'csv', 'pdf', 'json', 'xml', 'txt', 'sql', 'doc'],
96+
onLoadSuccess: function () { // possible 'fixme'? this might be for contents, not for headers?
97+
$('[data-tooltip="true"]').tooltip(); // Needed to attach tooltips after ajax call
98+
},
99+
onPostHeader: function () {
100+
var lookup = {};
101+
var lookup_initialized = false;
102+
var ths = $('th');
103+
ths.each(function (index, element) {
104+
th = $(element);
105+
//only populate the lookup table once; don't need to keep doing it.
106+
if (!lookup_initialized) {
107+
// th -> tr -> thead -> table
108+
var table = th.parent().parent().parent()
109+
var column_data = table.data('columns')
110+
for (var column in column_data) {
111+
lookup[column_data[column].field] = column_data[column].titleTooltip;
112+
}
113+
lookup_initialized = true
114+
}
115+
116+
field = th.data('field'); // find fieldname this column refers to
117+
title = lookup[field];
118+
if (title) {
119+
th.attr('data-toggle', 'tooltip');
120+
th.attr('data-placement', 'top');
121+
// th.attr('title', title) //this causes 'double-titles' which looks gross
122+
th.tooltip({container: 'body', title: title});
123+
}
124+
})
125+
},
126+
formatNoMatches: function () {
127+
return '{{ trans('table.no_matching_records') }}';
77128
}
78-
return newParams;
79-
},
80-
formatLoadingMessage: function () {
81-
return '<h2><x-icon type="spinner" /> {{ trans('general.loading') }} </h2>';
82-
},
83-
icons: {
84-
advancedSearchIcon: 'fas fa-search-plus',
85-
paginationSwitchDown: 'fa-caret-square-o-down',
86-
paginationSwitchUp: 'fa-caret-square-o-up',
87-
fullscreen: 'fa-expand',
88-
columns: 'fa-columns',
89-
refresh: 'fas fa-sync-alt',
90-
export: 'fa-download',
91-
clearSearch: 'fa-times'
92-
},
93-
locale: '{{ app()->getLocale() }}',
94-
exportOptions: export_options,
95-
exportTypes: ['xlsx', 'excel', 'csv', 'pdf','json', 'xml', 'txt', 'sql', 'doc' ],
96-
onLoadSuccess: function () {
97-
$('[data-tooltip="true"]').tooltip(); // Needed to attach tooltips after ajax call
98-
},
99-
formatNoMatches: function () {
100-
return '{{ trans('table.no_matching_records') }}';
101-
}
102129
103130
});
104131

0 commit comments

Comments
 (0)