1function handleFirstTab(e) { 2 if (e.keyCode === 9) { 3 document.body.classList.add('user-is-tabbing'); 4 5 window.removeEventListener('keydown', handleFirstTab); 6 window.addEventListener('mousedown', handleMouseDownOnce); 7 } 8} 9 10function handleMouseDownOnce() { 11 document.body.classList.remove('user-is-tabbing'); 12 13 window.removeEventListener('mousedown', handleMouseDownOnce); 14 window.addEventListener('keydown', handleFirstTab); 15} 16 17window.addEventListener('keydown', handleFirstTab); 18 19 20 21 var y = document.getElementsByTagName("table"); 22 var i; 23 for (i = 0; i < y.length; i++) { 24 y[i].setAttribute("tabindex", "0"); 25 // y[i].setAttribute("class","double-scrollz"); 26 } 27 28 29 30 31 32 33/* 34 * @name DoubleScroll 35 * @desc displays scroll bar on top and on the bottom of the div 36 * @requires jQuery 37 * 38 * @author Pawel Suwala - http://suwala.eu/ 39 * @author Antoine Vianey - http://www.astek.fr/ 40 * @version 0.5 (11-11-2015) 41 * 42 * Dual licensed under the MIT and GPL licenses: 43 * http://www.opensource.org/licenses/mit-license.php 44 * http://www.gnu.org/licenses/gpl.html 45 * 46 * Usage: 47 * https://github.com/avianey/jqDoubleScroll 48 */ 49 (function( $ ) { 50 51 jQuery.fn.doubleScroll = function(userOptions) { 52 53 // Default options 54 var options = { 55 contentElement: undefined, // Widest element, if not specified first child element will be used 56 scrollCss: { 57 'overflow-x': 'auto', 58 'overflow-y': 'hidden' 59 }, 60 contentCss: { 61 'overflow-x': 'auto', 62 'overflow-y': 'hidden' 63 }, 64 onlyIfScroll: true, // top scrollbar is not shown if the bottom one is not present 65 resetOnWindowResize: false, // recompute the top ScrollBar requirements when the window is resized 66 timeToWaitForResize: 30 // wait for the last update event (usefull when browser fire resize event constantly during ressing) 67 }; 68 69 $.extend(true, options, userOptions); 70 71 // do not modify 72 // internal stuff 73 $.extend(options, { 74 topScrollBarMarkup: '<div class="doubleScroll-scroll-wrapper" style="height: 20px;"><div class="doubleScroll-scroll" style="height: 20px;"></div></div>', 75 topScrollBarWrapperSelector: '.doubleScroll-scroll-wrapper', 76 topScrollBarInnerSelector: '.doubleScroll-scroll' 77 }); 78 79 var _showScrollBar = function($self, options) { 80 81 if (options.onlyIfScroll && $self.get(0).scrollWidth <= $self.width()) { 82 // content doesn't scroll 83 // remove any existing occurrence... 84 $self.prev(options.topScrollBarWrapperSelector).remove(); 85 return; 86 } 87 88 // add div that will act as an upper scroll only if not already added to the DOM 89 var $topScrollBar = $self.prev(options.topScrollBarWrapperSelector); 90 91 if ($topScrollBar.length == 0) { 92 93 // creating the scrollbar 94 // added before in the DOM 95 $topScrollBar = $(options.topScrollBarMarkup); 96 $self.before($topScrollBar); 97 98 // apply the css 99 $topScrollBar.css(options.scrollCss); 100 $self.css(options.contentCss); 101 102 // bind upper scroll to bottom scroll 103 $topScrollBar.bind('scroll.doubleScroll', function() { 104 $self.scrollLeft($topScrollBar.scrollLeft()); 105 }); 106 107 // bind bottom scroll to upper scroll 108 var selfScrollHandler = function() { 109 $topScrollBar.scrollLeft($self.scrollLeft()); 110 }; 111 $self.bind('scroll.doubleScroll', selfScrollHandler); 112 } 113 114 // find the content element (should be the widest one) 115 var $contentElement; 116 117 if (options.contentElement !== undefined && $self.find(options.contentElement).length !== 0) { 118 $contentElement = $self.find(options.contentElement); 119 } else { 120 $contentElement = $self.find('>:first-child'); 121 } 122 123 // set the width of the wrappers 124 $(options.topScrollBarInnerSelector, $topScrollBar).width($contentElement.outerWidth()); 125 $topScrollBar.width($self.width()); 126 $topScrollBar.scrollLeft($self.scrollLeft()); 127 128 } 129 130 return this.each(function() { 131 132 var $self = $(this); 133 134 _showScrollBar($self, options); 135 136 // bind the resize handler 137 // do it once 138 if (options.resetOnWindowResize) { 139 140 var id; 141 var handler = function(e) { 142 _showScrollBar($self, options); 143 }; 144 145 $(window).bind('resize.doubleScroll', function() { 146 // adding/removing/replacing the scrollbar might resize the window 147 // so the resizing flag will avoid the infinite loop here... 148 clearTimeout(id); 149 id = setTimeout(handler, options.timeToWaitForResize); 150 }); 151 152 } 153 154 }); 155 156 } 157 158}( jQuery )); 159 160 161 162 163 164 165 166
167 $(document).ready(function() { 168 $( "table" ).wrap( "<div class='double-scroll' style='width:100%;'></div>" ); 169 $('.double-scroll').doubleScroll({resetOnWindowResize: true}); 170 var m = "Data - " + $('head > title').text(); 171 $("table").attr("summary", m); 172 173 }); 174 175 176 177 178 179 180 181 182 183 184 185 186 187
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.