diff --git a/README.md b/README.md index 9e1ea3ee..91d52487 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,19 @@ If you would like to contribute, please... View the [complete change log here](https://github.com/Mottie/tablesorter/wiki/Changes). +#### Version 2.29.6 (2018-02-25) + +* Docs: + * Fix theme selector. + * `pager.page` is zero-based. See [issue #1516](https://github.com/Mottie/tablesorter/issues/1516). +* Resizable: + * Don't save 'auto' table width. Closes [issue #1514](https://github.com/Mottie/tablesorter/issues/1514). +* Scroller: + * Adjust spacing for jQuery UI themes. See [issue #1506](https://github.com/Mottie/tablesorter/issues/1506). +* StickyHeaders: + * Allow nested tables in sticky header. See [Stack Overflow](https://stackoverflow.com/q/48793036/145346). + * Include nested tables inside a scrolling element. Fixes [issue #1512](https://github.com/Mottie/tablesorter/issues/1512). + #### Version 2.29.5 (2018-01-30) * Docs: @@ -115,7 +128,7 @@ View the [complete change log here](https://github.com/Mottie/tablesorter/wiki/C * Fix linting issue. * Fix version numbering. * Parser: - * Add radio parser. See [issue #1502(https://github.com/Mottie/tablesorter/issues/1502). + * Add radio parser. See [issue #1502](https://github.com/Mottie/tablesorter/issues/1502). #### Version 2.29.4 (2018-01-18) @@ -127,12 +140,3 @@ View the [complete change log here](https://github.com/Mottie/tablesorter/wiki/C * Fix select2 issue. Closes [issue #1497](https://github.com/Mottie/tablesorter/issues/1497). * Meta: * Change date format in file comments to "YYYY-MM-DD". - -#### Version 2.29.3 (2018-01-10) - -* Docs: - * Update Bootstrap to v4-beta.3. - * Add scroller widget incompatibilities section. - * Add pager size all setting. -* Parser: - * Network parsers now return a text value. Fixes [issue #1494](https://github.com/Mottie/tablesorter/issues/1494). diff --git a/dist/js/jquery.tablesorter.combined.js b/dist/js/jquery.tablesorter.combined.js index b06cac7a..254e937f 100644 --- a/dist/js/jquery.tablesorter.combined.js +++ b/dist/js/jquery.tablesorter.combined.js @@ -1,4 +1,4 @@ -/*! tablesorter (FORK) - updated 2018-01-30 (v2.29.5)*/ +/*! tablesorter (FORK) - updated 2018-02-25 (v2.29.6)*/ /* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */ (function(factory) { if (typeof define === 'function' && define.amd) { @@ -10,7 +10,7 @@ } }(function(jQuery) { -/*! TableSorter (FORK) v2.29.5 *//* +/*! TableSorter (FORK) v2.29.6 *//* * Client-side table sorting with ease! * @requires jQuery v1.2.6+ * @@ -34,7 +34,7 @@ 'use strict'; var ts = $.tablesorter = { - version : '2.29.5', + version : '2.29.6', parsers : [], widgets : [], @@ -5327,7 +5327,7 @@ var index, len, $t, $table = c.$table, // add position: relative to attach element, hopefully it won't cause trouble. - $attach = $(wo.stickyHeaders_attachTo), + $attach = $(wo.stickyHeaders_attachTo || wo.stickyHeaders_appendTo), namespace = c.namespace + 'stickyheaders ', // element to watch for the scroll event $yScroll = $(wo.stickyHeaders_yScroll || wo.stickyHeaders_attachTo || window), @@ -5387,7 +5387,10 @@ }); } }, - getLeftPosition = function() { + getLeftPosition = function(yWindow) { + if (yWindow === false && $nestedSticky.length) { + return $table.position().left; + } return $attach.length ? parseInt($attach.css('padding-left'), 10) || 0 : $table.offset().left - parseInt($table.css('margin-left'), 10) - $(window).scrollLeft(); @@ -5408,9 +5411,11 @@ offset = $table.offset(), stickyOffset = getStickyOffset(c, wo), yWindow = $.isWindow( $yScroll[0] ), // $.isWindow needs jQuery 1.4.3 - attachTop = $attach.length ? - ( yWindow ? $yScroll.scrollTop() : $yScroll.offset().top ) : - $yScroll.scrollTop(), + yScroll = yWindow ? + $yScroll.scrollTop() : + // use parent sticky position if nested AND inside of a scrollable element - see #1512 + $nestedSticky.length ? parseInt($nestedSticky[0].style.top, 10) : $yScroll.offset().top, + attachTop = $attach.length ? yScroll : $yScroll.scrollTop(), captionHeight = wo.stickyHeaders_includeCaption ? 0 : $table.children( 'caption' ).height() || 0, scrollTop = attachTop + stickyOffset + nestedStickyTop - captionHeight, tableHeight = $table.height() - ($stickyWrap.height() + ($tfoot.height() || 0)) - captionHeight, @@ -5424,12 +5429,14 @@ cssSettings.top = yWindow ? scrollTop - $attach.offset().top : $attach.scrollTop(); } // adjust when scrolling horizontally - fixes issue #143 - tmp = getLeftPosition(); + tmp = getLeftPosition(yWindow); if (tmp !== parseInt($stickyWrap.css('left'), 10)) { needsUpdating = true; cssSettings.left = tmp; } - cssSettings.top = ( cssSettings.top || 0 ) + stickyOffset + nestedStickyTop; + cssSettings.top = ( cssSettings.top || 0 ) + + // If nested AND inside of a scrollable element, only add parent sticky height + (!yWindow && $nestedSticky.length ? $nestedSticky.height() : stickyOffset + nestedStickyTop); if (needsUpdating) { $stickyWrap .removeClass( ts.css.stickyVis + ' ' + ts.css.stickyHide ) @@ -5450,8 +5457,8 @@ if ($stickyTable.attr('id')) { $stickyTable[0].id += wo.stickyHeaders_cloneId; } // clear out cloned table, except for sticky header // include caption & filter row (fixes #126 & #249) - don't remove cells to get correct cell indexing - $stickyTable.find('thead:gt(0), tr.sticky-false').hide(); - $stickyTable.find('tbody, tfoot').remove(); + $stickyTable.find('> thead:gt(0), tr.sticky-false').hide(); + $stickyTable.find('> tbody, > tfoot').remove(); $stickyTable.find('caption').toggle(wo.stickyHeaders_includeCaption); // issue #172 - find td/th in sticky header $stickyCells = $stickyThead.children().children(); @@ -5483,7 +5490,6 @@ c.onRenderHeader.apply( $t.eq( index ), [ index, c, $stickyTable ] ); } } - // make it sticky! $xScroll.add($yScroll) .unbind( ('scroll resize '.split(' ').join( namespace )).replace(/\s+/g, ' ') ) @@ -5554,7 +5560,7 @@ })(jQuery, window); -/*! Widget: resizable - updated 12/13/2017 (v2.29.1) */ +/*! Widget: resizable - updated 2018-02-14 (v2.29.6) */ /*jshint browser:true, jquery:true, unused:false */ ;(function ($, window) { 'use strict'; @@ -5945,7 +5951,7 @@ if ( vars.overflow && vars.tableWidth ) { ts.resizable.setWidth( c.$table, vars.tableWidth, true ); if ( vars.useStorage ) { - ts.storage( table, 'tablesorter-table-resized-width', 'auto' ); + ts.storage( table, 'tablesorter-table-resized-width', vars.tableWidth ); } } for ( index = 0; index < c.columns; index++ ) { @@ -5961,7 +5967,7 @@ // reset stickyHeader widths c.$table.triggerHandler( 'stickyHeadersUpdate' ); if ( ts.storage && !refreshing ) { - ts.storage( this, ts.css.resizableStorage, {} ); + ts.storage( this, ts.css.resizableStorage, [] ); } } }); diff --git a/dist/js/jquery.tablesorter.combined.min.js b/dist/js/jquery.tablesorter.combined.min.js index 58ac04e9..45dbff80 100644 --- a/dist/js/jquery.tablesorter.combined.min.js +++ b/dist/js/jquery.tablesorter.combined.min.js @@ -1,2 +1,2 @@ -/*! tablesorter (FORK) - updated 2018-01-30 (v2.29.5)*/ -!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&"object"==typeof module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){return function(t){"use strict";var r=t.tablesorter={version:"2.29.5",parsers:[],widgets:[],defaults:{theme:"default",widthFixed:!1,showProcessing:!1,headerTemplate:"{content}",onRenderTemplate:null,onRenderHeader:null,cancelSelection:!0,tabIndex:!0,dateFormat:"mmddyyyy",sortMultiSortKey:"shiftKey",sortResetKey:"ctrlKey",usNumberFormat:!0,delayInit:!1,serverSideSorting:!1,resort:!0,headers:{},ignoreCase:!0,sortForce:null,sortList:[],sortAppend:null,sortStable:!1,sortInitialOrder:"asc",sortLocaleCompare:!1,sortReset:!1,sortRestart:!1,emptyTo:"bottom",stringTo:"max",duplicateSpan:!0,textExtraction:"basic",textAttribute:"data-text",textSorter:null,numberSorter:null,initWidgets:!0,widgetClass:"widget-{name}",widgets:[],widgetOptions:{zebra:["even","odd"]},initialized:null,tableClass:"",cssAsc:"",cssDesc:"",cssNone:"",cssHeader:"",cssHeaderRow:"",cssProcessing:"",cssChildRow:"tablesorter-childRow",cssInfoBlock:"tablesorter-infoOnly",cssNoSort:"tablesorter-noSort",cssIgnoreRow:"tablesorter-ignoreRow",cssIcon:"tablesorter-icon",cssIconNone:"",cssIconAsc:"",cssIconDesc:"",cssIconDisabled:"",pointerClick:"click",pointerDown:"mousedown",pointerUp:"mouseup",selectorHeaders:"> thead th, > thead td",selectorSort:"th, td",selectorRemove:".remove-me",debug:!1,headerList:[],empties:{},strings:{},parsers:[],globalize:0,imgAttr:0},css:{table:"tablesorter",cssHasChild:"tablesorter-hasChildRow",childRow:"tablesorter-childRow",colgroup:"tablesorter-colgroup",header:"tablesorter-header",headerRow:"tablesorter-headerRow",headerIn:"tablesorter-header-inner",icon:"tablesorter-icon",processing:"tablesorter-processing",sortAsc:"tablesorter-headerAsc",sortDesc:"tablesorter-headerDesc",sortNone:"tablesorter-headerUnSorted"},language:{sortAsc:"Ascending sort applied, ",sortDesc:"Descending sort applied, ",sortNone:"No sort applied, ",sortDisabled:"sorting is disabled",nextAsc:"activate to apply an ascending sort",nextDesc:"activate to apply a descending sort",nextNone:"activate to remove the sort"},regex:{templateContent:/\{content\}/g,templateIcon:/\{icon\}/g,templateName:/\{name\}/i,spaces:/\s+/g,nonWord:/\W/g,formElements:/(input|select|button|textarea)/i,chunk:/(^([+\-]?(?:\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,chunks:/(^\\0|\\0$)/,hex:/^0x[0-9a-f]+$/i,comma:/,/g,digitNonUS:/[\s|\.]/g,digitNegativeTest:/^\s*\([.\d]+\)/,digitNegativeReplace:/^\s*\(([.\d]+)\)/,digitTest:/^[\-+(]?\d+[)]?$/,digitReplace:/[,.'"\s]/g},string:{max:1,min:-1,emptymin:1,emptymax:-1,zero:0,none:0,"null":0,top:!0,bottom:!1},keyCodes:{enter:13},dates:{},instanceMethods:{},setup:function(e,a){if(e&&e.tHead&&0!==e.tBodies.length&&!0!==e.hasInitialized){var i="",s=t(e),o=t.metadata;e.hasInitialized=!1,e.isProcessing=!0,e.config=a,t.data(e,"tablesorter",a),a.debug&&(console[console.group?"group":"log"]("Initializing tablesorter v"+r.version),t.data(e,"startoveralltimer",new Date)),a.supportsDataObject=function(e){return e[0]=parseInt(e[0],10),e[0]>1||1===e[0]&&parseInt(e[1],10)>=4}(t.fn.jquery.split(".")),a.emptyTo=a.emptyTo.toLowerCase(),a.stringTo=a.stringTo.toLowerCase(),a.last={sortList:[],clickedIndex:-1},/tablesorter\-/.test(s.attr("class"))||(i=""!==a.theme?" tablesorter-"+a.theme:""),a.namespace?a.namespace="."+a.namespace.replace(r.regex.nonWord,""):a.namespace=".tablesorter"+Math.random().toString(16).slice(2),a.table=e,a.$table=s.addClass(r.css.table+" "+a.tableClass+i+" "+a.namespace.slice(1)).attr("role","grid"),a.$headers=s.find(a.selectorHeaders),a.$table.children().children("tr").attr("role","row"),a.$tbodies=s.children("tbody:not(."+a.cssInfoBlock+")").attr({"aria-live":"polite","aria-relevant":"all"}),a.$table.children("caption").length&&((i=a.$table.children("caption")[0]).id||(i.id=a.namespace.slice(1)+"caption"),a.$table.attr("aria-labelledby",i.id)),a.widgetInit={},a.textExtraction=a.$table.attr("data-text-extraction")||a.textExtraction||"basic",r.buildHeaders(a),r.fixColumnWidth(e),r.addWidgetFromClass(e),r.applyWidgetOptions(e),r.setupParsers(a),a.totalRows=0,r.validateOptions(a),a.delayInit||r.buildCache(a),r.bindEvents(e,a.$headers,!0),r.bindMethods(a),a.supportsDataObject&&void 0!==s.data().sortlist?a.sortList=s.data().sortlist:o&&s.metadata()&&s.metadata().sortlist&&(a.sortList=s.metadata().sortlist),r.applyWidget(e,!0),a.sortList.length>0?r.sortOn(a,a.sortList,{},!a.initWidgets):(r.setHeadersCss(a),a.initWidgets&&r.applyWidget(e,!1)),a.showProcessing&&s.unbind("sortBegin"+a.namespace+" sortEnd"+a.namespace).bind("sortBegin"+a.namespace+" sortEnd"+a.namespace,function(t){clearTimeout(a.timerProcessing),r.isProcessing(e),"sortBegin"===t.type&&(a.timerProcessing=setTimeout(function(){r.isProcessing(e,!0)},500))}),e.hasInitialized=!0,e.isProcessing=!1,a.debug&&(console.log("Overall initialization time:"+r.benchmark(t.data(e,"startoveralltimer"))),a.debug&&console.groupEnd&&console.groupEnd()),s.triggerHandler("tablesorter-initialized",e),"function"==typeof a.initialized&&a.initialized(e)}else a.debug&&(e.hasInitialized?console.warn("Stopping initialization. Tablesorter has already been initialized"):console.error("Stopping initialization! No table, thead or tbody",e))},bindMethods:function(e){var a=e.$table,i=e.namespace,s="sortReset update updateRows updateAll updateHeaders addRows updateCell updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave ".split(" ").join(i+" ");a.unbind(s.replace(r.regex.spaces," ")).bind("sortReset"+i,function(e,t){e.stopPropagation(),r.sortReset(this.config,function(e){e.isApplyingWidgets?setTimeout(function(){r.applyWidget(e,"",t)},100):r.applyWidget(e,"",t)})}).bind("updateAll"+i,function(e,t,a){e.stopPropagation(),r.updateAll(this.config,t,a)}).bind("update"+i+" updateRows"+i,function(e,t,a){e.stopPropagation(),r.update(this.config,t,a)}).bind("updateHeaders"+i,function(e,t){e.stopPropagation(),r.updateHeaders(this.config,t)}).bind("updateCell"+i,function(e,t,a,i){e.stopPropagation(),r.updateCell(this.config,t,a,i)}).bind("addRows"+i,function(e,t,a,i){e.stopPropagation(),r.addRows(this.config,t,a,i)}).bind("updateComplete"+i,function(){this.isUpdating=!1}).bind("sorton"+i,function(e,t,a,i){e.stopPropagation(),r.sortOn(this.config,t,a,i)}).bind("appendCache"+i,function(e,a,i){e.stopPropagation(),r.appendCache(this.config,i),t.isFunction(a)&&a(this)}).bind("updateCache"+i,function(e,t,a){e.stopPropagation(),r.updateCache(this.config,t,a)}).bind("applyWidgetId"+i,function(e,t){e.stopPropagation(),r.applyWidgetId(this,t)}).bind("applyWidgets"+i,function(e,t){e.stopPropagation(),r.applyWidget(this,!1,t)}).bind("refreshWidgets"+i,function(e,t,a){e.stopPropagation(),r.refreshWidgets(this,t,a)}).bind("removeWidget"+i,function(e,t,a){e.stopPropagation(),r.removeWidget(this,t,a)}).bind("destroy"+i,function(e,t,a){e.stopPropagation(),r.destroy(this,t,a)}).bind("resetToLoadState"+i,function(a){a.stopPropagation(),r.removeWidget(this,!0,!1);var i=t.extend(!0,{},e.originalSettings);(e=t.extend(!0,{},r.defaults,i)).originalSettings=i,this.hasInitialized=!1,r.setup(this,e)})},bindEvents:function(e,a,i){var s,o=(e=t(e)[0]).config,n=o.namespace,l=null;!0!==i&&(a.addClass(n.slice(1)+"_extra_headers"),(s=r.getClosest(a,"table")).length&&"TABLE"===s[0].nodeName&&s[0]!==e&&t(s[0]).addClass(n.slice(1)+"_extra_table")),s=(o.pointerDown+" "+o.pointerUp+" "+o.pointerClick+" sort keyup ").replace(r.regex.spaces," ").split(" ").join(n+" "),a.find(o.selectorSort).add(a.filter(o.selectorSort)).unbind(s).bind(s,function(e,i){var s,n,d,c=t(e.target),f=" "+e.type+" ";if(!(1!==(e.which||e.button)&&!f.match(" "+o.pointerClick+" | sort | keyup ")||" keyup "===f&&e.which!==r.keyCodes.enter||f.match(" "+o.pointerClick+" ")&&void 0!==e.which||f.match(" "+o.pointerUp+" ")&&l!==e.target&&!0!==i)){if(f.match(" "+o.pointerDown+" "))return l=e.target,void("1"===(d=c.jquery.split("."))[0]&&d[1]<4&&e.preventDefault());if(l=null,r.regex.formElements.test(e.target.nodeName)||c.hasClass(o.cssNoSort)||c.parents("."+o.cssNoSort).length>0||c.parents("button").length>0)return!o.cancelSelection;o.delayInit&&r.isEmptyObject(o.cache)&&r.buildCache(o),s=r.getClosest(t(this),"."+r.css.header),d=a.index(s),o.last.clickedIndex=d<0?s.attr("data-column"):d,(n=o.$headers[o.last.clickedIndex])&&!n.sortDisabled&&r.initSort(o,n,e)}}),o.cancelSelection&&a.attr("unselectable","on").bind("selectstart",!1).css({"user-select":"none",MozUserSelect:"none"})},buildHeaders:function(e){var a,i,s,o;for(e.headerList=[],e.headerContent=[],e.sortVars=[],e.debug&&(s=new Date),e.columns=r.computeColumnIndex(e.$table.children("thead, tfoot").children("tr")),i=e.cssIcon?'':"",e.$headers=t(t.map(e.$table.find(e.selectorHeaders),function(a,s){var o,n,l,d,c,f=t(a);if(!r.getClosest(f,"tr").hasClass(e.cssIgnoreRow))return/(th|td)/i.test(a.nodeName)||(c=r.getClosest(f,"th, td"),f.attr("data-column",c.attr("data-column"))),o=r.getColumnData(e.table,e.headers,s,!0),e.headerContent[s]=f.html(),""===e.headerTemplate||f.find("."+r.css.headerIn).length||(d=e.headerTemplate.replace(r.regex.templateContent,f.html()).replace(r.regex.templateIcon,f.find("."+r.css.icon).length?"":i),e.onRenderTemplate&&(n=e.onRenderTemplate.apply(f,[s,d]))&&"string"==typeof n&&(d=n),f.html('