From 339c2fd55425ac8d8233dfafb9a1e3275774b81a Mon Sep 17 00:00:00 2001 From: Matt Price Date: Wed, 6 May 2015 17:03:21 -0400 Subject: [PATCH 1/3] added sticky table header to all existing themes --- setup/theme-bigblow-local.setup | 21 ++++++++++--------- setup/theme-bigblow.setup | 2 ++ setup/theme-readtheorg-local.setup | 8 ++++--- setup/theme-readtheorg.setup | 1 + styles/bigblow/js/bigblow.js | 3 +++ .../lib/js/jquery.stickytableheaders.min.js | 1 + styles/lib/js/stickytableheaders-license.txt | 20 ++++++++++++++++++ styles/readtheorg/js/readtheorg.js | 3 +++ 8 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 styles/lib/js/jquery.stickytableheaders.min.js create mode 100644 styles/lib/js/stickytableheaders-license.txt diff --git a/setup/theme-bigblow-local.setup b/setup/theme-bigblow-local.setup index a38e86f..2180e7c 100755 --- a/setup/theme-bigblow-local.setup +++ b/setup/theme-bigblow-local.setup @@ -1,14 +1,15 @@ # -*- mode: org; -*- -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: diff --git a/setup/theme-bigblow.setup b/setup/theme-bigblow.setup index c61c079..1c4a847 100755 --- a/setup/theme-bigblow.setup +++ b/setup/theme-bigblow.setup @@ -12,3 +12,5 @@ #+HTML_HEAD: #+HTML_HEAD: #+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: diff --git a/setup/theme-readtheorg-local.setup b/setup/theme-readtheorg-local.setup index bffcf4d..ae810d6 100755 --- a/setup/theme-readtheorg-local.setup +++ b/setup/theme-readtheorg-local.setup @@ -1,8 +1,10 @@ # -*- mode: org; -*- -#+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: #+HTML_HEAD: #+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: + +#+HTML_HEAD: diff --git a/setup/theme-readtheorg.setup b/setup/theme-readtheorg.setup index 01c6a2d..504dc08 100755 --- a/setup/theme-readtheorg.setup +++ b/setup/theme-readtheorg.setup @@ -5,4 +5,5 @@ #+HTML_HEAD: #+HTML_HEAD: +#+HTML_HEAD: #+HTML_HEAD: diff --git a/styles/bigblow/js/bigblow.js b/styles/bigblow/js/bigblow.js index 2cf302c..58f22d9 100755 --- a/styles/bigblow/js/bigblow.js +++ b/styles/bigblow/js/bigblow.js @@ -178,6 +178,9 @@ $(document).ready(function() { // Initialize hideShow hsInit(); + + // add sticky headers to tables + $('table').stickyTableHeaders(); }); function copyToClipboard(text) diff --git a/styles/lib/js/jquery.stickytableheaders.min.js b/styles/lib/js/jquery.stickytableheaders.min.js new file mode 100644 index 0000000..6c17ea4 --- /dev/null +++ b/styles/lib/js/jquery.stickytableheaders.min.js @@ -0,0 +1 @@ +!function(a,b){"use strict";function c(c,g){var h=this;h.$el=a(c),h.el=c,h.id=e++,h.$window=a(b),h.$document=a(document),h.$el.bind("destroyed",a.proxy(h.teardown,h)),h.$clonedHeader=null,h.$originalHeader=null,h.isSticky=!1,h.hasBeenSticky=!1,h.leftOffset=null,h.topOffset=null,h.init=function(){h.$el.each(function(){var b=a(this);b.css("padding",0),h.$originalHeader=a("thead:first",this),h.$clonedHeader=h.$originalHeader.clone(),b.trigger("clonedHeader."+d,[h.$clonedHeader]),h.$clonedHeader.addClass("tableFloatingHeader"),h.$clonedHeader.css("display","none"),h.$originalHeader.addClass("tableFloatingHeaderOriginal"),h.$originalHeader.after(h.$clonedHeader),h.$printStyle=a(''),a("head").append(h.$printStyle)}),h.setOptions(g),h.updateWidth(),h.toggleHeaders(),h.bind()},h.destroy=function(){h.$el.unbind("destroyed",h.teardown),h.teardown()},h.teardown=function(){h.isSticky&&h.$originalHeader.css("position","static"),a.removeData(h.el,"plugin_"+d),h.unbind(),h.$clonedHeader.remove(),h.$originalHeader.removeClass("tableFloatingHeaderOriginal"),h.$originalHeader.css("visibility","visible"),h.$printStyle.remove(),h.el=null,h.$el=null},h.bind=function(){h.$scrollableArea.on("scroll."+d,h.toggleHeaders),h.isWindowScrolling||(h.$window.on("scroll."+d+h.id,h.setPositionValues),h.$window.on("resize."+d+h.id,h.toggleHeaders)),h.$scrollableArea.on("resize."+d,h.toggleHeaders),h.$scrollableArea.on("resize."+d,h.updateWidth)},h.unbind=function(){h.$scrollableArea.off("."+d,h.toggleHeaders),h.isWindowScrolling||(h.$window.off("."+d+h.id,h.setPositionValues),h.$window.off("."+d+h.id,h.toggleHeaders)),h.$scrollableArea.off("."+d,h.updateWidth)},h.toggleHeaders=function(){h.$el&&h.$el.each(function(){var b,c=a(this),d=h.isWindowScrolling?isNaN(h.options.fixedOffset)?h.options.fixedOffset.outerHeight():h.options.fixedOffset:h.$scrollableArea.offset().top+(isNaN(h.options.fixedOffset)?0:h.options.fixedOffset),e=c.offset(),f=h.$scrollableArea.scrollTop()+d,g=h.$scrollableArea.scrollLeft(),i=h.isWindowScrolling?f>e.top:d>e.top,j=(h.isWindowScrolling?f:0)a||a+h.$window.height()>h.$document.height()||0>b||b+h.$window.width()>h.$document.width()||h.$originalHeader.css({top:h.topOffset-(h.isWindowScrolling?0:a),left:h.leftOffset-(h.isWindowScrolling?0:b)})},h.updateWidth=function(){if(h.isSticky){h.$originalHeaderCells||(h.$originalHeaderCells=a("th,td",h.$originalHeader)),h.$clonedHeaderCells||(h.$clonedHeaderCells=a("th,td",h.$clonedHeader));var b=h.getWidth(h.$clonedHeaderCells);h.setWidth(b,h.$clonedHeaderCells,h.$originalHeaderCells),h.$originalHeader.css("width",h.$clonedHeader.width())}},h.getWidth=function(c){var d=[];return c.each(function(c){var e,f=a(this);if("border-box"===f.css("box-sizing"))e=f[0].getBoundingClientRect().width;else{var g=a("th",h.$originalHeader);if("collapse"===g.css("border-collapse"))if(b.getComputedStyle)e=parseFloat(b.getComputedStyle(this,null).width);else{var i=parseFloat(f.css("padding-left")),j=parseFloat(f.css("padding-right")),k=parseFloat(f.css("border-width"));e=f.outerWidth()-i-j-k}else e=f.width()}d[c]=e}),d},h.setWidth=function(a,b,c){b.each(function(b){var d=a[b];c.eq(b).css({"min-width":d,"max-width":d})})},h.resetWidth=function(b,c){b.each(function(b){var d=a(this);c.eq(b).css({"min-width":d.css("min-width"),"max-width":d.css("max-width")})})},h.setOptions=function(c){h.options=a.extend({},f,c),h.$scrollableArea=a(h.options.scrollableArea),h.isWindowScrolling=h.$scrollableArea[0]===b},h.updateOptions=function(a){h.setOptions(a),h.unbind(),h.bind(),h.updateWidth(),h.toggleHeaders()},h.init()}var d="stickyTableHeaders",e=0,f={fixedOffset:0,leftOffset:0,marginTop:0,scrollableArea:b};a.fn[d]=function(b){return this.each(function(){var e=a.data(this,"plugin_"+d);e?"string"==typeof b?e[b].apply(e):e.updateOptions(b):"destroy"!==b&&a.data(this,"plugin_"+d,new c(this,b))})}}(jQuery,window); \ No newline at end of file diff --git a/styles/lib/js/stickytableheaders-license.txt b/styles/lib/js/stickytableheaders-license.txt new file mode 100644 index 0000000..d3f756a --- /dev/null +++ b/styles/lib/js/stickytableheaders-license.txt @@ -0,0 +1,20 @@ +Copyright (c) 2011 Jonas Mosbech + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/styles/readtheorg/js/readtheorg.js b/styles/readtheorg/js/readtheorg.js index f9dbeed..951d93a 100755 --- a/styles/readtheorg/js/readtheorg.js +++ b/styles/readtheorg/js/readtheorg.js @@ -36,6 +36,9 @@ $( document ).ready(function() { // ScrollSpy also requires that we use // a Bootstrap nav component. $('body').scrollspy({target: '#text-table-of-contents'}); + + // add sticky table headers + $('table').stickyTableHeaders(); }); window.SphinxRtdTheme = (function (jquery) { From dffa04246bc658641a110ee0f6798c62071c876f Mon Sep 17 00:00:00 2001 From: Matt Price Date: Wed, 6 May 2015 17:06:05 -0400 Subject: [PATCH 2/3] reverted local paths to original local links --- setup/theme-bigblow-local.setup | 22 +++++++++++----------- setup/theme-readtheorg-local.setup | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/setup/theme-bigblow-local.setup b/setup/theme-bigblow-local.setup index 2180e7c..2488692 100755 --- a/setup/theme-bigblow-local.setup +++ b/setup/theme-bigblow-local.setup @@ -1,15 +1,15 @@ # -*- mode: org; -*- -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: diff --git a/setup/theme-readtheorg-local.setup b/setup/theme-readtheorg-local.setup index ae810d6..9bcde25 100755 --- a/setup/theme-readtheorg-local.setup +++ b/setup/theme-readtheorg-local.setup @@ -1,10 +1,10 @@ # -*- mode: org; -*- -#+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: #+HTML_HEAD: #+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: From 0465c4bd159d6527a056b084bc4e547ad261948e Mon Sep 17 00:00:00 2001 From: Matt Price Date: Wed, 6 May 2015 17:09:58 -0400 Subject: [PATCH 3/3] reverted local paths to original local links --- setup/theme-bigblow.setup | 1 - setup/theme-readtheorg.setup | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/setup/theme-bigblow.setup b/setup/theme-bigblow.setup index 1c4a847..fae5956 100755 --- a/setup/theme-bigblow.setup +++ b/setup/theme-bigblow.setup @@ -12,5 +12,4 @@ #+HTML_HEAD: #+HTML_HEAD: #+HTML_HEAD: -#+HTML_HEAD: #+HTML_HEAD: diff --git a/setup/theme-readtheorg.setup b/setup/theme-readtheorg.setup index 504dc08..b201fae 100755 --- a/setup/theme-readtheorg.setup +++ b/setup/theme-readtheorg.setup @@ -5,5 +5,5 @@ #+HTML_HEAD: #+HTML_HEAD: -#+HTML_HEAD: +#+HTML_HEAD: #+HTML_HEAD: