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

5 lines
8.0 KiB
JavaScript
Raw Normal View History

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