From 8d68bb7a57dbb20b3a81f39c69640b04ed6b4d87 Mon Sep 17 00:00:00 2001
From: snipe <snipe@snipe.net>
Date: Tue, 24 Oct 2017 05:22:26 -0700
Subject: [PATCH] Sticky headers for bootstrap tables

---
 public/css/bootstrap-tables-sticky-header.css | Bin 0 -> 411 bytes
 public/css/dist/all.css                       | Bin 247865 -> 248066 bytes
 .../views/partials/bootstrap-table.blade.php  |  27 +++++++++++++++++-
 webpack.mix.js                                |   3 +-
 4 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 public/css/bootstrap-tables-sticky-header.css

diff --git a/public/css/bootstrap-tables-sticky-header.css b/public/css/bootstrap-tables-sticky-header.css
new file mode 100644
index 0000000000000000000000000000000000000000..521a8b04d6e9c1ff09120dd32012f7c33977445d
GIT binary patch
literal 411
zcmdPb(&Exma7ZjI$;dBKD9g-CPR%P($jQ%8uz_;)a&sKga}zUj^pf*)?LdmlQj3Z+
z^Yg3}$_(`k^bEMP6f#Om3W}}t_0uy;GD?#`3iZn}^Qv<4GxU@4^Gk|LiV_QSOA?cE
zQuVpC6oN}Kld~%oGEx&$Qi~MQ@{1JE6me<kb8+dVWmf1GLzGr?DJUo?6yz6YmVhlz
z%dALEu?7oP>1O7oq*hod7#bK@bJe0~D*;)d0MVS3n4FznlwX>cVx^#*mX-!mi$!rs
zh7MLytF+9b;u78DjLe)An2GsCDXB%eIjLzSRtg3X*Cav2iZatPFa(qGOG@%{trQFk
cDin(Ib23vDlv7hvQS~LJWR@0#O{?Vs0I@lQnE(I)

literal 0
HcmV?d00001

diff --git a/public/css/dist/all.css b/public/css/dist/all.css
index 7f8ab24dfa27837a7c9ea38d6b82c74ea6df2a1c..dbe1278a8a3be44d080727e08082b6a6366ad066 100644
GIT binary patch
delta 154
zcmdlvfxl@Ie?tpn3)2?n)-7CVnH9RlC7H?DmD4Z0W|a1-)kBCVlw_nPrc@^-CTFJ?
z<(KBASShEarD3X2D9O;l(55i`Vlt!5^wlSs_@{q($;2^v)_Wnr)YMe#r2L|k)FR!Y
V#FWg^;^~gZm}R!l-NHOa7yuwLJRSf5

delta 26
icmZpg#J_U_e?tpn3)2?n)-BVSelbaGPut2oM;HK%UJ57x

diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php
index cb2ab5cc4..30020b083 100644
--- a/resources/views/partials/bootstrap-table.blade.php
+++ b/resources/views/partials/bootstrap-table.blade.php
@@ -11,10 +11,28 @@
 <script src="{{ asset('js/jspdf.plugin.autotable.js') }}"></script>
 <script src="{{ asset('js/extensions/export/jquery.base64.js') }}"></script>
 <script src="{{ asset('js/extensions/toolbar/bootstrap-table-toolbar.js') }}"></script>
+<script src="{{ asset('js/extensions/sticky-header/bootstrap-table-sticky-header.js') }}"></script>
 @endif
 
 <script nonce="{{ csrf_token() }}">
-$('.snipe-table').bootstrapTable({
+
+    var $table = $('.snipe-table');
+    $(function () {
+        buildTable($table, 20, 50);
+    });
+    function buildTable($el) {
+        var stickyHeaderOffsetY = 0;
+
+        if ( $('.navbar-fixed-top').css('height') ) {
+            stickyHeaderOffsetY = +$('.navbar-fixed-top').css('height').replace('px','');
+        }
+        if ( $('.navbar-fixed-top').css('margin-bottom') ) {
+            stickyHeaderOffsetY += +$('.navbar-fixed-top').css('margin-bottom').replace('px','');
+        }
+
+
+
+$('.snipe-table').bootstrapTable('destroy').bootstrapTable({
         classes: 'table table-responsive table-no-bordered',
         undefinedText: '',
         iconsPrefix: 'fa',
@@ -38,6 +56,11 @@ $('.snipe-table').bootstrapTable({
         cookie: true,
         cookieExpire: '2y',
         showExport: true,
+
+    stickyHeader: true,
+    stickyHeaderOffsetY: stickyHeaderOffsetY + 'px',
+
+
         @if (isset($showFooter))
             showFooter: true,
         @endif
@@ -101,6 +124,8 @@ $('.snipe-table').bootstrapTable({
         },
 
     });
+    }
+
 
 
     function dateRowCheckStyle(value) {
diff --git a/webpack.mix.js b/webpack.mix.js
index 5be691fdd..5d51c488c 100644
--- a/webpack.mix.js
+++ b/webpack.mix.js
@@ -23,7 +23,8 @@ mix.styles([
     'resources/assets/css/font-awesome/font-awesome.min.css',
     './bower_components/iCheck/skins/minimal/minimal.css',
     './node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.standalone.css',
-    'public/css/overrides.css',
+    'public/css/bootstrap-tables-sticky-header.css',
+    'public/css/overrides.css'
 ], 'public/css/dist/all.css');
 
 mix.js(
-- 
GitLab