From patchwork Thu Oct 1 14:12:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Lespiau X-Patchwork-Id: 525016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A88FE140D16 for ; Fri, 2 Oct 2015 00:17:27 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 8EA751A0629 for ; Fri, 2 Oct 2015 00:17:27 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lists.ozlabs.org (Postfix) with ESMTP id 0E61B1A0522 for ; Fri, 2 Oct 2015 00:13:44 +1000 (AEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 01 Oct 2015 07:13:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,617,1437462000"; d="scan'208";a="817195449" Received: from unknown (HELO strange.ger.corp.intel.com) ([10.252.16.209]) by orsmga002.jf.intel.com with ESMTP; 01 Oct 2015 07:13:43 -0700 From: Damien Lespiau To: patchwork@lists.ozlabs.org Subject: [PATCH 25/49] package: Add the Sticky Table Header jQuery plugin Date: Thu, 1 Oct 2015 15:12:30 +0100 Message-Id: <1443708774-26996-26-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1443708774-26996-1-git-send-email-damien.lespiau@intel.com> References: <1443708774-26996-1-git-send-email-damien.lespiau@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Signed-off-by: Damien Lespiau Acked-by: Stephen Finucane --- htdocs/js/jquery.stickytableheaders.min.js | 1 + lib/packages/jquery/README | 19 ++++++++++++++----- lib/packages/jquery/jquery.stickytableheaders.min.js | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) create mode 120000 htdocs/js/jquery.stickytableheaders.min.js create mode 100644 lib/packages/jquery/jquery.stickytableheaders.min.js diff --git a/htdocs/js/jquery.stickytableheaders.min.js b/htdocs/js/jquery.stickytableheaders.min.js new file mode 120000 index 0000000..0c22fa9 --- /dev/null +++ b/htdocs/js/jquery.stickytableheaders.min.js @@ -0,0 +1 @@ +../../lib/packages/jquery/jquery.stickytableheaders.min.js \ No newline at end of file diff --git a/lib/packages/jquery/README b/lib/packages/jquery/README index 47d440b..990e29d 100644 --- a/lib/packages/jquery/README +++ b/lib/packages/jquery/README @@ -1,7 +1,16 @@ -This directory contains the jQuery Javascript library, and jQuery -Table Drag & Drop plugin. These are available from: +This directory contains the jQuery Javascript library, and jQuery plugins: - http://jquery.com/ - http://isocra.com/2008/02/table-drag-and-drop-jquery-plugin/ +jQuery: -Both are redistributable under the MIT license. + - http://jquery.com/ + - MIT license + +Table Drag & Drop plugin: + + - http://isocra.com/2008/02/table-drag-and-drop-jquery-plugin/ + - MIT license + +Sticky Table Headers: + + - https://github.com/jmosbech/StickyTableHeaders + - MIT license diff --git a/lib/packages/jquery/jquery.stickytableheaders.min.js b/lib/packages/jquery/jquery.stickytableheaders.min.js new file mode 100644 index 0000000..fa1fc32 --- /dev/null +++ b/lib/packages/jquery/jquery.stickytableheaders.min.js @@ -0,0 +1 @@ +(function(e,i){"use strict";function t(t,s){var d=this;d.$el=e(t),d.el=t,d.id=l++,d.$window=e(i),d.$document=e(document),d.$el.bind("destroyed",e.proxy(d.teardown,d)),d.$clonedHeader=null,d.$originalHeader=null,d.isSticky=!1,d.hasBeenSticky=!1,d.leftOffset=null,d.topOffset=null,d.init=function(){d.$el.each(function(){var i=e(this);i.css("padding",0),d.$originalHeader=e("thead:first",this),d.$clonedHeader=d.$originalHeader.clone(),i.trigger("clonedHeader."+o,[d.$clonedHeader]),d.$clonedHeader.addClass("tableFloatingHeader"),d.$clonedHeader.css("display","none"),d.$originalHeader.addClass("tableFloatingHeaderOriginal"),d.$originalHeader.after(d.$clonedHeader),d.$printStyle=e(''),e("head").append(d.$printStyle)}),d.setOptions(s),d.updateWidth(),d.toggleHeaders(),d.bind()},d.destroy=function(){d.$el.unbind("destroyed",d.teardown),d.teardown()},d.teardown=function(){d.isSticky&&d.$originalHeader.css("position","static"),e.removeData(d.el,"plugin_"+o),d.unbind(),d.$clonedHeader.remove(),d.$originalHeader.removeClass("tableFloatingHeaderOriginal"),d.$originalHeader.css("visibility","visible"),d.$printStyle.remove(),d.el=null,d.$el=null},d.bind=function(){d.$scrollableArea.on("scroll."+o,d.toggleHeaders),d.isWindowScrolling||(d.$window.on("scroll."+o+d.id,d.setPositionValues),d.$window.on("resize."+o+d.id,d.toggleHeaders)),d.$scrollableArea.on("resize."+o,d.toggleHeaders),d.$scrollableArea.on("resize."+o,d.updateWidth)},d.unbind=function(){d.$scrollableArea.off("."+o,d.toggleHeaders),d.isWindowScrolling||(d.$window.off("."+o+d.id,d.setPositionValues),d.$window.off("."+o+d.id,d.toggleHeaders)),d.$scrollableArea.off("."+o,d.updateWidth),d.$el.off("."+o),d.$el.find("*").off("."+o)},d.toggleHeaders=function(){d.$el&&d.$el.each(function(){var i,t=e(this),o=d.isWindowScrolling?isNaN(d.options.fixedOffset)?d.options.fixedOffset.outerHeight():d.options.fixedOffset:d.$scrollableArea.offset().top+(isNaN(d.options.fixedOffset)?0:d.options.fixedOffset),l=t.offset(),n=d.$scrollableArea.scrollTop()+o,s=d.$scrollableArea.scrollLeft(),a=d.isWindowScrolling?n>l.top:o>l.top,r=(d.isWindowScrolling?n:0)e||e+d.$window.height()>d.$document.height()||0>i||i+d.$window.width()>d.$document.width()||d.$originalHeader.css({top:d.topOffset-(d.isWindowScrolling?0:e),left:d.leftOffset-(d.isWindowScrolling?0:i)})},d.updateWidth=function(){if(d.isSticky){d.$originalHeaderCells||(d.$originalHeaderCells=e("th,td",d.$originalHeader)),d.$clonedHeaderCells||(d.$clonedHeaderCells=e("th,td",d.$clonedHeader));var i=d.getWidth(d.$clonedHeaderCells);d.setWidth(i,d.$clonedHeaderCells,d.$originalHeaderCells),d.$originalHeader.css("width",d.$clonedHeader.width())}},d.getWidth=function(t){var o=[];return t.each(function(t){var l,n=e(this);if("border-box"===n.css("box-sizing"))l=n.outerWidth();else{var s=e("th",d.$originalHeader);if("collapse"===s.css("border-collapse"))if(i.getComputedStyle)l=parseFloat(i.getComputedStyle(this,null).width);else{var a=parseFloat(n.css("padding-left")),r=parseFloat(n.css("padding-right")),c=parseFloat(n.css("border-width"));l=n.outerWidth()-a-r-c}else l=n.width()}o[t]=l}),o},d.setWidth=function(e,i,t){i.each(function(i){var o=e[i];t.eq(i).css({"min-width":o,"max-width":o})})},d.resetWidth=function(i,t){i.each(function(i){var o=e(this);t.eq(i).css({"min-width":o.css("min-width"),"max-width":o.css("max-width")})})},d.setOptions=function(t){d.options=e.extend({},n,t),d.$scrollableArea=e(d.options.scrollableArea),d.isWindowScrolling=d.$scrollableArea[0]===i},d.updateOptions=function(e){d.setOptions(e),d.unbind(),d.bind(),d.updateWidth(),d.toggleHeaders()},d.init()}var o="stickyTableHeaders",l=0,n={fixedOffset:0,leftOffset:0,scrollableArea:i};e.fn[o]=function(i){return this.each(function(){var l=e.data(this,"plugin_"+o);l?"string"==typeof i?l[i].apply(l):l.updateOptions(i):"destroy"!==i&&e.data(this,"plugin_"+o,new t(this,i))})}})(jQuery,window); \ No newline at end of file