bootstrap-table-resizable.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * @author: Dennis Hernández
  3. * @webSite: http://djhvscf.github.io/Blog
  4. * @version: v1.0.0
  5. */
  6. (function ($) {
  7. 'use strict';
  8. var initResizable = function (el) {
  9. var that = el;
  10. //Deletes the plugin to re-create it
  11. $(el.$el).colResizable({disable: true});
  12. //Creates the plugin
  13. $(el.$el).colResizable({
  14. liveDrag: that.options.liveDrag,
  15. fixed: that.options.fixed,
  16. headerOnly: that.options.headerOnly,
  17. minWidth: that.options.minWidth,
  18. hoverCursor: that.options.hoverCursor,
  19. dragCursor: that.options.dragCursor,
  20. onResize: that.options.onResizableResize,
  21. onDrag: that.options.onResizableDrag
  22. });
  23. };
  24. $.extend($.fn.bootstrapTable.defaults, {
  25. resizable: false,
  26. liveDrag: false,
  27. fixed: true,
  28. headerOnly: false,
  29. minWidth: 15,
  30. hoverCursor: 'e-resize',
  31. dragCursor: 'e-resize',
  32. onResizableResize: function (e) {
  33. return false;
  34. },
  35. onResizableDrag: function (e) {
  36. return false;
  37. }
  38. });
  39. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  40. _init = BootstrapTable.prototype.init,
  41. _toggleColumn = BootstrapTable.prototype.toggleColumn,
  42. _toggleView = BootstrapTable.prototype.toggleView;
  43. BootstrapTable.prototype.init = function () {
  44. _init.apply(this, Array.prototype.slice.apply(arguments));
  45. if (this.options.resizable) {
  46. initResizable(this);
  47. }
  48. };
  49. BootstrapTable.prototype.toggleColumn = function () {
  50. _toggleColumn.apply(this, Array.prototype.slice.apply(arguments));
  51. if (this.options.resizable) {
  52. initResizable(this);
  53. }
  54. };
  55. BootstrapTable.prototype.toggleView = function () {
  56. _toggleView.apply(this, Array.prototype.slice.apply(arguments));
  57. if (this.options.resizable) {
  58. if (this.options.cardView) {
  59. //Deletes the plugin
  60. $(this.$el).colResizable({disable: true});
  61. return;
  62. }
  63. initResizable(this);
  64. }
  65. };
  66. })(jQuery);