/*! Widget: scroller - updated 10/31/2015 (v2.24.0) */
/*
Copyright (C) 2011 T. Connell & Associates, Inc.
Dual-licensed under the MIT and GPL licenses
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.
Resizable scroller widget for the jQuery tablesorter plugin
Version 2.0 - modified by Rob Garrison 4/12/2013;
updated 3/5/2015 (v2.22.2) with lots of help from TheSin-
Requires jQuery v1.7+
Requires the tablesorter plugin, v2.8+, available at http://mottie.github.com/tablesorter/docs/
Usage:
$(function() {
$('table.tablesorter').tablesorter({
widgets: ['zebra', 'scroller'],
widgetOptions : {
scroller_height : 300, // height of scroll window
scroller_jumpToHeader : true, // header snap to browser top when scrolling the tbody
scroller_upAfterSort : true, // scroll tbody to top after sorting
scroller_fixedColumns : 0 // set number of fixed columns
}
});
});
Website: www.tconnell.com
*/
/*jshint browser:true, jquery:true, unused:false */
!function(a,b){"use strict";var c=a.tablesorter,d=c.css;a.extend(c.css,{scrollerWrap:"tablesorter-scroller",scrollerHeader:"tablesorter-scroller-header",scrollerTable:"tablesorter-scroller-table",scrollerFooter:"tablesorter-scroller-footer",scrollerFixed:"tablesorter-scroller-fixed",scrollerFixedPanel:"tablesorter-scroller-fixed-panel",scrollerHasFix:"tablesorter-scroller-has-fixed-columns",scrollerHideColumn:"tablesorter-scroller-hidden-column",scrollerHideElement:"tablesorter-scroller-hidden",scrollerSpacerRow:"tablesorter-scroller-spacer",scrollerBarSpacer:"tablesorter-scroller-bar-spacer",scrollerAddedHeight:"tablesorter-scroller-added-height",scrollerHack:"tablesorter-scroller-scrollbar-hack",
// class name on table cannot start with 'tablesorter-' or the
// suffix 'scroller-rtl' will match as a theme name
scrollerRtl:"ts-scroller-rtl"}),c.addWidget({id:"scroller",priority:60,// run after the filter widget
options:{scroller_height:300,
// pop table header into view while scrolling up the page
scroller_jumpToHeader:!0,
// scroll tbody to top after sorting
scroller_upAfterSort:!0,
// set number of fixed columns
scroller_fixedColumns:0,
// add hover highlighting to the fixed column (disable if it causes slowing)
scroller_rowHighlight:"hover",
// add a fixed column overlay for styling
scroller_addFixedOverlay:!1,
// In tablesorter v2.19.0 the scroll bar width is auto-detected
// add a value here to override the auto-detected setting
scroller_barWidth:null},format:function(a,b,d){b.isScrolling||
// initialize here instead of in widget init to give the
// filter widget time to finish building the filter row
c.scroller.setup(b,d)},remove:function(a,b,d){c.scroller.remove(b,d)}}),/* Add window resizeEnd event (also used by columnSelector widget) */
c.window_resize=function(){c.timer_resize&&clearTimeout(c.timer_resize),c.timer_resize=setTimeout(function(){a(b).trigger("resizeEnd")},250)},
// Add extra scroller css
a(function(){var b="";a(b).appendTo("body")}),c.scroller={
// Ugh.. Firefox misbehaves, so it needs to be detected
isFirefox:navigator.userAgent.toLowerCase().indexOf("firefox")>-1,
// old IE needs a wrap to hide the fixed column scrollbar; http://stackoverflow.com/a/24408672/145346
isOldIE:document.all&&!b.atob,isIE:document.all&&!b.atob||navigator.appVersion.indexOf("Trident/")>0,
// http://stackoverflow.com/questions/7944460/detect-safari-browser - needed to position scrolling body
// when the table is set up in RTL direction
isSafari:navigator.userAgent.toLowerCase().indexOf("safari")>-1&&-1===navigator.userAgent.toLowerCase().indexOf("chrome"),hasScrollBar:function(a,b){return b?a.get(0).scrollWidth>a.width():a.get(0).scrollHeight>a.height()},setWidth:function(a,b){a.css({width:b,"min-width":b,"max-width":b})},
// modified from http://davidwalsh.name/detect-scrollbar-width
getBarWidth:function(){var b=a("
").css({position:"absolute",top:"-9999px",left:0,width:"100px",height:"100px",overflow:"scroll",visibility:"hidden"}).appendTo("body"),c=b[0],d=c.offsetWidth-c.clientWidth;return b.remove(),d},setup:function(e,f){var g,h,i,j,k,l,m,n,o,p=a(b),q=c.scroller,r=e.namespace+"tsscroller",s=a(),
// c.namespace contains a unique tablesorter ID, per table
t=e.namespace.slice(1)+"tsscroller",u=e.$table;
// force config.widthFixed option - this helps maintain proper alignment across cloned tables
e.widthFixed=!0,f.scroller_calcWidths=[],f.scroller_saved=[0,0],f.scroller_isBusy=!0,
// set scrollbar width to one of the following (1) explicitly set scroller_barWidth option,
// (2) detected scrollbar width or (3) fallback of 15px
null!==f.scroller_barWidth?f.scroller_barSetWidth=f.scroller_barWidth:(o=q.getBarWidth(),f.scroller_barSetWidth=null!==o?o:15),g=f.scroller_height||300,i=a('
'+u.children("thead")[0].outerHTML+"
"),f.scroller_$header=i.addClass(e.namespace.slice(1)+"_extra_table"),j=u.children("tfoot"),j.length&&(s=a('
').addClass(e.namespace.slice(1)+"_extra_table").append(j.clone(!0)).wrap(''),l=s.children("tfoot").eq(0).children("tr").children()),f.scroller_$footer=s,u.wrap('
').before(i).find("."+d.filterRow).addClass(d.filterRowHide),f.scroller_$container=u.parent(),s.length&&u.after(s.parent()),k=i.wrap('').find("."+d.header),u.wrap('
'),m=u.parent(),c.bindEvents(e.table,k),u.hasClass("hasFilters")&&c.filter.bindSearch(u,i.find("."+d.filter)),u.find("thead").addClass(d.scrollerHideElement),h=m.parent().height(),m.off("scroll"+r).on("scroll"+r,function(){if(f.scroller_jumpToHeader){var b=p.scrollTop()-i.offset().top;0!==a(this).scrollTop()&&h>b&&b>0&&p.scrollTop(i.offset().top)}i.parent().add(s.parent()).scrollLeft(a(this).scrollLeft())}),n=((c.hasWidget(e.table,"filter")?"filterEnd":"tablesorter-initialized updateComplete")+" sortEnd pagerComplete columnUpdate ").split(" ").join(r+" "),u.off(r).on("sortEnd filterEnd".split(" ").join(r+" "),function(a){"sortEnd"===a.type&&f.scroller_upAfterSort?m.animate({scrollTop:0},"fast"):f.scroller_fixedColumns&&setTimeout(function(){m.scrollTop(f.scroller_saved[1]).scrollLeft(f.scroller_saved[0]),q.updateFixed(e,f)},0)}).on("setFixedColumnSize"+r,function(a,b){var c=f.scroller_$container;"undefined"==typeof b||isNaN(b)||(f.scroller_fixedColumns=parseInt(b,10)),q.removeFixed(e,f),b=f.scroller_fixedColumns,b>0&&b
0&&q.updateFixed(e,f),q.resize(e,f))}),p.off("resize resizeEnd ".split(" ").join(r+" ")).on("resize"+r,c.window_resize).on("resizeEnd"+r,function(){p.off("resize"+r,c.window_resize),q.resize(e,f),p.on("resize"+r,c.window_resize),m.trigger("scroll"+r)}),e.isScrolling=!0,q.updateFixed(e,f),e.table.hasInitialized&&e.isScrolling&&setTimeout(function(){c.scroller.resize(e,f)},50)},resize:function(e,f){if(!f.scroller_isBusy){var g,h,i,j,k,l,m=c.scroller,n=f.scroller_$container,o=e.$table,p=o.parent(),q=f.scroller_$header,r=f.scroller_$footer,s=e.namespace.slice(1)+"tsscroller",
// Hide other scrollers so we can resize
t=a("div."+d.scrollerWrap+'[id!="'+s+'"]').addClass(d.scrollerHideElement),u='';for(f.scroller_calcWidths=[],
// Remove fixed so we get proper widths and heights
m.removeFixed(e,f),n.find("."+d.scrollerSpacerRow).remove(),
// remove ts added colgroups
n.find("."+c.css.colgroup).remove(),
// show original table elements to get proper alignment
o.find("."+d.scrollerHideElement).removeClass(d.scrollerHideElement),h=parseInt(o.css("border-left-width"),10),j=e.$headerIndexed,g=0;g',f.scroller_calcWidths[g]=i;u+="
",e.$tbodies.eq(0).prepend(u),// tbody
q.children("thead").append(u),r.children("tfoot").append(u),
// include colgroup or alignment is off
c.fixColumnWidth(e.table),u=e.$table.children("colgroup")[0].outerHTML,q.prepend(u),r.prepend(u),l=p.parent().innerWidth()-(m.hasScrollBar(p)?f.scroller_barSetWidth:0),p.width(l),l=(m.hasScrollBar(p)?f.scroller_barSetWidth:0)+h,i=p.innerWidth()-l,q.parent().add(r.parent()).width(i),p.width(i+l),
// hide original table thead
o.children("thead").addClass(d.scrollerHideElement),
// update fixed column sizes
m.updateFixed(e,f),t.removeClass(d.scrollerHideElement),
// restore scrollTop - fixes #926
p.scrollTop(f.scroller_saved[1]),f.scroller_$container.find("."+d.scrollerFixed).find("."+d.scrollerTable).scrollTop(f.scroller_saved[1]),
// update resizable widget handles
setTimeout(function(){e.$table.trigger("resizableUpdate")},100)}},
// Add fixed (frozen) columns (Do not call directly, use updateFixed)
setupFixed:function(a,b){var e,f,g,h,i,j,k,l=a.$table,m=b.scroller_$container,n=b.scroller_fixedColumns;for(j=m.addClass(d.scrollerHasFix).clone().addClass(d.scrollerFixed).removeClass(d.scrollerWrap).attr("id",""),b.scroller_addFixedOverlay&&j.append('