bootstrap-table-resizable.min.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * @author: Dennis Hernández
  3. * @webSite: http://djhvscf.github.io/Blog
  4. * @version: v2.0.0
  5. */
  6. const isInit = that => that.$el.data('resizableColumns') !== undefined
  7. const initResizable = that => {
  8. if (
  9. that.options.resizable &&
  10. !that.options.cardView &&
  11. !isInit(that) &&
  12. that.$el.is(':visible')
  13. ) {
  14. that.$el.resizableColumns({
  15. store: window.store
  16. })
  17. }
  18. }
  19. const destroy = that => {
  20. if (isInit(that)) {
  21. that.$el.data('resizableColumns').destroy()
  22. }
  23. }
  24. const reInitResizable = that => {
  25. destroy(that)
  26. initResizable(that)
  27. }
  28. $.extend($.fn.bootstrapTable.defaults, {
  29. resizable: false
  30. })
  31. $.BootstrapTable = class extends $.BootstrapTable {
  32. initBody (...args) {
  33. super.initBody(...args)
  34. this.$el.off('column-switch.bs.table page-change.bs.table')
  35. .on('column-switch.bs.table page-change.bs.table', () => {
  36. reInitResizable(this)
  37. })
  38. }
  39. toggleView (...args) {
  40. super.toggleView(...args)
  41. if (this.options.resizable && this.options.cardView) {
  42. // Destroy the plugin
  43. destroy(this)
  44. }
  45. }
  46. resetView (...args) {
  47. super.resetView(...args)
  48. if (this.options.resizable) {
  49. // because in fitHeader function, we use setTimeout(func, 100);
  50. setTimeout(() => {
  51. initResizable(this)
  52. }, 100)
  53. }
  54. }
  55. }