From 55380f7ef87c19e9c5b5e2d594211bfc1c5ff489 Mon Sep 17 00:00:00 2001 From: Dimas Begunoff Date: Thu, 4 Mar 2010 12:02:44 -0800 Subject: [PATCH] initial commit --- README | 0 demo.html | 277 +++++++++++++++++++++++++++++++++++++++++ jquery.tablescroll.css | 32 +++++ jquery.tablescroll.js | 154 +++++++++++++++++++++++ 4 files changed, 463 insertions(+) create mode 100644 README create mode 100644 demo.html create mode 100644 jquery.tablescroll.css create mode 100644 jquery.tablescroll.js diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/demo.html b/demo.html new file mode 100644 index 0000000..ba00745 --- /dev/null +++ b/demo.html @@ -0,0 +1,277 @@ + + + + + + Demo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
citystate codeziplatitudelongitudecounty
HoltsvilleNY0050140.8152-73.0455Suffolk
HoltsvilleNY0054440.8152-73.0455Suffolk
AdjuntasPR0060118.1788-66.7516Adjuntas
AguadaPR0060218.381389-67.188611Aguada
AguadillaPR0060318.4554-67.1308Aguadilla
AguadillaPR0060418.4812-67.1467Aguadilla
AguadillaPR0060518.429444-67.154444Aguadilla
MaricaoPR0060618.182778-66.980278Maricao
AnascoPR0061018.284722-67.14Anasco
AngelesPR0061118.286944-66.799722Utuado
AreciboPR0061218.4389-66.6924Arecibo
AreciboPR0061318.1399-66.6344Arecibo
AreciboPR0061418.1399-66.6344Arecibo
BajaderoPR0061618.428611-66.683611Arecibo
BarcelonetaPR0061718.4525-66.538889Barceloneta
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StateTotal Sales TaxState Sales TaxLocal Sales TaxMerch Sales TaxTotal Sales TaxState Sales TaxLocal Sales TaxMerch Sales Tax
IL$1,364.27$712.05$211.11$416.87$1,364.27$712.05$211.11$416.87
IN$1,364.27$712.05$211.11$416.87$1,364.27$712.05$211.11$416.87
KS$1,364.27$712.05$211.11$416.87$1,364.27$712.05$211.11$416.87
NJ$1,364.27$712.05$211.11$416.87$1,364.27$712.05$211.11$416.87
NY$1,364.27$712.05$211.11$416.87$1,364.27$712.05$211.11$416.87
FL$1,364.27$712.05$211.11$416.87$1,364.27$712.05$211.11$416.87
CA$1,364.27$712.05$211.11$416.87$1,364.27$712.05$211.11$416.87
 $1,364.27$712.05$211.11$416.87$1,364.27$712.05$211.11$416.87
+
+ + + + + + + + \ No newline at end of file diff --git a/jquery.tablescroll.css b/jquery.tablescroll.css new file mode 100644 index 0000000..d6617a8 --- /dev/null +++ b/jquery.tablescroll.css @@ -0,0 +1,32 @@ +.tablescroll +{ font: 12px normal Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif; background-color:#fff; } + +.tablescroll td, +.tablescroll_wrapper, +.tablescroll_head, +.tablescroll_foot +{ border:1px solid #ccc; } + +.tablescroll td +{ padding:3px 5px; } + +.tablescroll_wrapper +{ border-left:0; } + +.tablescroll_head +{ font-size:11px; font-weight:bold; background-color:#eee; border-left:0; border-top:0; margin-bottom:3px; } + +.tablescroll thead td +{ border-right:0; border-bottom:0; } + +.tablescroll tbody td +{ border-right:0; border-bottom:0; } + +.tablescroll tbody tr.first td +{ border-top:0; } + +.tablescroll_foot +{ font-weight:bold; background-color:#eee; border-left:0; border-top:0; margin-top:3px; } + +.tablescroll tfoot td +{ border-right:0; border-bottom:0; } \ No newline at end of file diff --git a/jquery.tablescroll.js b/jquery.tablescroll.js new file mode 100644 index 0000000..a0d52e9 --- /dev/null +++ b/jquery.tablescroll.js @@ -0,0 +1,154 @@ +/* + +Copyright (c) 2009 Dimas Begunoff, http://www.farinspace.com + +Licensed under the MIT license +http://en.wikipedia.org/wiki/MIT_License + +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. + +*/ + +;(function($){ + + var scrollbarWidth = 0; + + // http://jdsharp.us/jQuery/minute/calculate-scrollbar-width.php + function getScrollbarWidth() + { + if (scrollbarWidth) return scrollbarWidth; + var div = $('
'); + $('body').append(div); + var w1 = $('div', div).innerWidth(); + div.css('overflow-y', 'auto'); + var w2 = $('div', div).innerWidth(); + $(div).remove(); + scrollbarWidth = (w1 - w2); + return scrollbarWidth; + } + + $.fn.tableScroll = function(options) + { + var settings = $.extend({},$.fn.tableScroll.defaults,options); + + settings.scrollbarWidth = getScrollbarWidth(); + + this.each(function() + { + var flush = settings.flush; + + var tb = $(this).addClass('tablescroll_body'); + + var wrapper = $('
').insertBefore(tb).append(tb); + + // check for a predefined container + if (!wrapper.parent('div').hasClass(settings.containerClass)) + { + $('
').addClass(settings.containerClass).insertBefore(wrapper).append(wrapper); + } + + var width = settings.width ? settings.width : tb.outerWidth(); + + wrapper.css + ({ + 'width': (width+settings.scrollbarWidth)+'px', + 'height': settings.height+'px', + 'overflow': 'auto' + }); + + tb.css('width',width+'px'); + + // using wrap does not put wrapper in the DOM right + // away making it unavailable for use during runtime + // tb.wrap(wrapper); + + // possible speed enhancements + var has_thead = $('thead',tb).length ? true : false ; + var has_tfoot = $('tfoot',tb).length ? true : false ; + var thead_tr_first = $('thead tr:first',tb); + var tbody_tr_first = $('tbody tr:first',tb); + var tfoot_tr_first = $('tfoot tr:first',tb); + + // remember width of last cell + var w = 0; + + $('th, td',thead_tr_first).each(function(i) + { + w = $(this).width(); + + $('th:eq('+i+'), td:eq('+i+')',thead_tr_first).css('width',w+'px'); + $('th:eq('+i+'), td:eq('+i+')',tbody_tr_first).css('width',w+'px'); + if (has_tfoot) $('th:eq('+i+'), td:eq('+i+')',tfoot_tr_first).css('width',w+'px'); + }); + + if (has_thead) + { + var tbh = $('
').insertBefore(wrapper).prepend($('thead',tb)); + } + + if (has_tfoot) + { + var tbf = $('
').insertAfter(wrapper).prepend($('tfoot',tb)); + } + + if (tb.outerHeight() <= settings.height) + { + wrapper.css('height','auto'); + flush = false; + } + + if (tbh != undefined) + { + tbh.css('width',width+'px'); + + if (flush) + { + $('tr:first th:last, tr:first td:last',tbh).css('width',(w+settings.scrollbarWidth)+'px'); + tbh.css('width',wrapper.outerWidth() + 'px'); + } + } + + if (tbf != undefined) + { + tbf.css('width',width+'px'); + + if (flush) + { + $('tr:first th:last, tr:first td:last',tbf).css('width',(w+settings.scrollbarWidth)+'px'); + tbf.css('width',wrapper.outerWidth() + 'px'); + } + } + }); + + return this; + }; + + // public + $.fn.tableScroll.defaults = + { + flush: true, // makes the last thead and tbody column flush with the scrollbar + width: null, // width of the table (head, body and foot), null defaults to the tables natural width + height: 100, // height of the scrollable area + containerClass: 'tablescroll' // the plugin wraps the table in a div with this css class + }; + +})(jQuery);