tablesorter/dist/js/widgets/widget-resizable.min.js

2 lines
7.8 KiB
JavaScript
Raw Normal View History

2018-04-26 20:25:54 +00:00
/*! Widget: resizable - updated 2018-03-26 (v2.30.2) */
!function(e,t){"use strict";var s=e.tablesorter||{};e.extend(s.css,{resizableContainer:"tablesorter-resizable-container",resizableHandle:"tablesorter-resizable-handle",resizableNoSelect:"tablesorter-disableSelection",resizableStorage:"tablesorter-resizable"}),e(function(){var t="<style>body."+s.css.resizableNoSelect+" { -ms-user-select: none; -moz-user-select: -moz-none;-khtml-user-select: none; -webkit-user-select: none; user-select: none; }."+s.css.resizableContainer+" { position: relative; height: 1px; }."+s.css.resizableHandle+" { position: absolute; display: inline-block; width: 8px;top: 1px; cursor: ew-resize; z-index: 3; user-select: none; -moz-user-select: none; }</style>";e("head").append(t)}),s.resizable={init:function(t,a){if(!t.$table.hasClass("hasResizable")){t.$table.addClass("hasResizable");var i,r,l,o,n=t.$table,d=n.parent(),b=parseInt(n.css("margin-top"),10),c=a.resizable_vars={useStorage:s.storage&&!1!==a.resizable,$wrap:d,mouseXPosition:0,$target:null,$next:null,overflow:"auto"===d.css("overflow")||"scroll"===d.css("overflow")||"auto"===d.css("overflow-x")||"scroll"===d.css("overflow-x"),storedSizes:[]};for(s.resizableReset(t.table,!0),c.tableWidth=n.width(),c.fullWidth=Math.abs(d.width()-c.tableWidth)<20,c.useStorage&&c.overflow&&(s.storage(t.table,"tablesorter-table-original-css-width",c.tableWidth),o=s.storage(t.table,"tablesorter-table-resized-width")||"auto",s.resizable.setWidth(n,o,!0)),a.resizable_vars.storedSizes=l=(c.useStorage?s.storage(t.table,s.css.resizableStorage):[])||[],s.resizable.setWidths(t,a,l),s.resizable.updateStoredSizes(t,a),a.$resizable_container=e('<div class="'+s.css.resizableContainer+'">').css({top:b}).insertBefore(n),r=0;r<t.columns;r++)i=t.$headerIndexed[r],o=s.getColumnData(t.table,t.headers,r),"false"===s.getData(i,o,"resizable")||e('<div class="'+s.css.resizableHandle+'">').appendTo(a.$resizable_container).attr({"data-column":r,unselectable:"on"}).data("header",i).bind("selectstart",!1);s.resizable.bindings(t,a)}},updateStoredSizes:function(e,t){var s,a,i=e.columns,r=t.resizable_vars;for(r.storedSizes=[],s=0;s<i;s++)a=e.$headerIndexed[s],r.storedSizes[s]=a.is(":visible")?a.width():0},setWidth:function(e,t,s){e.css({width:t,"min-width":s?t:"","max-width":s?t:""})},setWidths:function(t,a,i){var r,l,o=a.resizable_vars,n=e(t.namespace+"_extra_headers"),d=t.$table.children("colgroup").children("col");if((i=i||o.storedSizes||[]).length){for(r=0;r<t.columns;r++)s.resizable.setWidth(t.$headerIndexed[r],i[r],o.overflow),n.length&&(l=n.eq(r).add(d.eq(r)),s.resizable.setWidth(l,i[r],o.overflow));(l=e(t.namespace+"_extra_table")).length&&!s.hasWidget(t.table,"scroller")&&s.resizable.setWidth(l,t.$table.outerWidth(),o.overflow)}},setHandlePosition:function(t,a){var i,r=t.$table.height(),l=a.$resizable_container.children(),o=Math.floor(l.width()/2);s.hasWidget(t.table,"scroller")&&(r=0,t.$table.closest("."+s.css.scrollerWrap).children().each(function(){var t=e(this);r+=t.filter('[style*="height"]').length?t.height():t.children("table").height()})),!a.resizable_includeFooter&&t.$table.children("tfoot").length&&(r-=t.$table.children("tfoot").height()),i=parseFloat(e.fn.jquery)>=3.3?0:t.$table.position().left,l.each(function(){var l=e(this),n=parseInt(l.attr("data-column"),10),d=t.columns-1,b=l.data("header");b&&(!b.is(":visible")||!a.resizable_addLastColumn&&s.resizable.checkVisibleColumns(t,n)?l.hide():(n<d||n===d&&a.resizable_addLastColumn)&&l.css({display:"inline-block",height:r,left:b.position().left-i+b.outerWidth()-o}))})},checkVisibleColumns:function(e,t){var s,a=0;for(s=t+1;s<e.columns;s++)a+=e.$headerIndexed[s].is(":visible")?1:0;return 0===a},toggleTextSelection:function(t,a,i){var r=t.namespace+"tsresize";a.resizable_vars.disabled=i,e("body").toggleClass(s.css.resizableNoSelect,i),i?e("body").attr("unselectable","on").bind("selectstart"+r,!1):e("body").removeAttr("unselectable").unbind("selectstart"+r)},bindings:function(a,i){var r=a.namespace+"tsresize";i.$resizable_container.children().bind("mousedown",function(t){var r,l=i.resizable_vars,o=e(a.namespace+"_extra_headers"