UNPKG

slickgrid

Version:

A lightning fast JavaScript grid/spreadsheet

9 lines 2.52 kB
/** * SlickGrid v3.0.2 * (c) 2009-present Michael Leibman * homepage: http://github.com/mleibman/slickgrid * license: MIT * date: 2022-11-14 * file: ./plugins/slick.resizer.js */ "use strict";!function(G){G.extend(!0,window,{Slick:{Plugins:{Resizer:function(e,n){var d,s,o,r,u,a,h,g,f,c,l=180,w=300,m=20,t=this,z=!1,v={bottomPadding:20,applyResizeToContainer:!1,minHeight:180,minWidth:300,rightPadding:0},R={};function p(i){R=G.extend(!0,{},v,R,i)}function C(e){void 0===g&&void 0===g.offset()||(y(0,e,null),G(window).on("resize.grid."+u,function(i){t.onGridBeforeResize.notify({grid:o},i,t),z||(y(0,e,i),y(0,e,i))}))}function b(){t.onGridBeforeResize.unsubscribe(),t.onGridAfterResize.unsubscribe(),G(window).off("resize.grid."+u)}function y(e,n,t){if(e=e||0,"function"==typeof Promise)return new Promise(function(i){0<e?(clearTimeout(h),h=setTimeout(function(){i(P(n,t))},e)):i(P(n,t))});0<e?(clearTimeout(h),h=setTimeout(function(){P(n,t)},e)):P(n,t)}function P(i,e){i=function(i){var e=function(){var i,e,n,t,o,r;return window&&void 0!==f&&void 0!==g&&void 0!==g.offset()?(r=R&&void 0!==R.bottomPadding?R.bottomPadding:m,e=i=0,"container"===R.calculateAvailableSizeBy?i=f.height()||0:(i=window.innerHeight||0,e=void 0!==(o=g.offset())?o.top:0),o=i-e-r,i=f.width()||window.innerWidth||0,e=R&&R.maxHeight||void 0,r=R&&void 0!==R.minHeight?R.minHeight:l,n=R&&R.maxWidth||void 0,t=R&&void 0!==R.minWidth?R.minWidth:w,(o=o)<r&&(o=r),e&&e<o&&(o=e),(r=R&&R.rightPadding?i-R.rightPadding:i)<t&&(r=t),n&&n<r&&(r=n),{height:d||o,width:s||r}):null}();if((i||e)&&g&&0<g.length)try{var n=(i&&i.height?i:e).height,t=(i&&i.width?i:e).width;r.autoHeight||(g.height(n),R.gridContainer&&R.applyResizeToContainer&&c.height(n)),g.width(t),R.gridContainer&&R.applyResizeToContainer&&c.width(t),null===new RegExp("MSIE [6-8]").exec(navigator.userAgent)&&o&&o.resizeCanvas&&o.resizeCanvas(),r&&r.enableAutoSizeColumns&&o.autosizeColumns&&u&&(0<G("."+u).length||0<G(g).length)&&o.autosizeColumns(),a={height:n,width:t}}catch(i){b()}return a}(i);return t.onGridAfterResize.notify({grid:o,dimensions:i},e,t),i}G.extend(this,{init:function(i){p(e),r=(o=i).getOptions(),u=o.getUID(),g=G(o.getContainerNode()),f=G(R.container),R.gridContainer&&(c=G(R.gridContainer)),n&&(d=n.height,s=n.width),r&&C()},destroy:b,pluginName:"Resizer",bindAutoResizeDataGrid:C,getLastResizeDimensions:function(){return a},pauseResizer:function(i){z=i},resizeGrid:y,setOptions:p,onGridAfterResize:new Slick.Event,onGridBeforeResize:new Slick.Event})}}}})}(jQuery);