import Ember from 'ember'; export default Ember.Component.extend({ didInsertElement() { this._super(); Ember.run.scheduleOnce('afterRender', this, function() { /* * adding floatThead jQuery plugin to poll table * https://mkoryak.github.io/floatThead/ * * top: * Offset from the top of the `window` where the floating header will * 'stick' when scrolling down * Since we are adding a browser horizontal scrollbar on top, scrollingTop * has to be set to height of horizontal scrollbar which depends on * used browser */ Ember.$('.user-selections-table').floatThead({ position: 'absolute', top: this.getScrollbarHeight }); /* * fix width calculation error caused by bootstrap glyphicon on webkit */ Ember.$('.glyphicon').css('width', '14px'); /* * scrollbar on top of table */ const topScrollbarInner = Ember.$('
') .css('width', Ember.$('.user-selections-table').width()) .css('height', '1px'); const topScrollbarOuter = Ember.$('') .addClass('top-scrollbar') .css('width', '100%') .css('overflow-x', 'scroll') .css('overflow-y', 'hidden') .css('position', 'relative') .css('z-index', '1002'); Ember.$('.table-scroll').before( topScrollbarOuter.append(topScrollbarInner) ); /* * scrollbar on top of table for thead */ const topScrollbarInnerThead = Ember.$('') .css('width', Ember.$('.user-selections-table').width()) .css('height', '1px'); const topScrollbarOuterThead = Ember.$('') .addClass('top-scrollbar-floatThead') .css('width', Ember.$('.table-scroll').outerWidth()) .css('overflow-x', 'scroll') .css('overflow-y', 'hidden') .css('position', 'fixed') .css('top', '-1px') .css('z-index', '1002') .css('margin-left', `${(Ember.$('.table-scroll').outerWidth() - Ember.$('.table-scroll').width()) / 2 * (-1)}px`) .css('margin-right', `${(Ember.$('.table-scroll').outerWidth() - Ember.$('.table-scroll').width()) / 2 * (-1)}px`); Ember.$('.table-scroll').prepend( topScrollbarOuterThead.append(topScrollbarInnerThead).hide() ); // add listener to resize scrollbars if window get resized Ember.$(window).resize(this.resizeScrollbars); /* * bind scroll event on all scrollbars */ Ember.$('.table-scroll').scroll(function() { Ember.$('.top-scrollbar').scrollLeft(Ember.$('.table-scroll').scrollLeft()); Ember.$('.top-scrollbar-floatThead').scrollLeft(Ember.$('.table-scroll').scrollLeft()); }); Ember.$('.top-scrollbar').scroll(function() { Ember.$('.table-scroll').scrollLeft(Ember.$('.top-scrollbar').scrollLeft()); Ember.$('.top-scrollbar-floatThead').scrollLeft(Ember.$('.top-scrollbar').scrollLeft()); }); Ember.$('.top-scrollbar-floatThead').scroll(function() { Ember.$('.table-scroll').scrollLeft(Ember.$('.top-scrollbar-floatThead').scrollLeft()); Ember.$('.top-scrollbar').scrollLeft(Ember.$('.top-scrollbar-floatThead').scrollLeft()); }); /* * show inner scrollbar only, if header is fixed */ Ember.$(window).scroll(Ember.$.proxy(this.updateScrollbarTopVisibility, this)); }); }, /* * calculates horizontal scrollbar height depending on current browser */ getScrollbarHeight() { const wideScrollWtml = Ember.$('