bootstrap-table-materialize.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * @author zhixin wen <wenzhixin2010@gmail.com>
  3. * https://github.com/wenzhixin/bootstrap-table/
  4. * theme: https://github.com/jgthms/bulma/
  5. */
  6. $.extend($.fn.bootstrapTable.defaults, {
  7. classes: 'table highlight',
  8. buttonsPrefix: '',
  9. buttonsClass: 'waves-effect waves-light btn',
  10. iconsPrefix: 'material-icons',
  11. icons: {
  12. paginationSwitchDown: 'grid_on',
  13. paginationSwitchUp: 'grid_off',
  14. refresh: 'refresh',
  15. toggleOff: 'tablet',
  16. toggleOn: 'tablet_android',
  17. columns: 'view_list',
  18. detailOpen: 'add',
  19. detailClose: 'remove',
  20. fullscreen: 'fullscreen'
  21. }
  22. })
  23. $.fn.bootstrapTable.theme = 'materialize'
  24. $.BootstrapTable = class extends $.BootstrapTable {
  25. initConstants () {
  26. super.initConstants()
  27. this.constants.classes.buttonsGroup = ''
  28. this.constants.classes.buttonsDropdown = ''
  29. this.constants.classes.input = 'input-field'
  30. this.constants.classes.input = ''
  31. this.constants.classes.paginationDropdown = ''
  32. this.constants.classes.buttonActive = 'green'
  33. this.constants.html.toobarDropdow = ['<ul id="toolbar-columns-id" class="dropdown-content">', '</ul>']
  34. this.constants.html.toobarDropdowItem = '<li><label>%s</label></li>'
  35. this.constants.html.pageDropdown = ['<ul id="pagination-list-id" class="dropdown-content">', '</ul>']
  36. this.constants.html.pageDropdownItem = '<li><a class="%s" href="#">%s</a></li>'
  37. this.constants.html.dropdownCaret = '<i class="material-icons">arrow_drop_down</i>'
  38. this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>']
  39. this.constants.html.paginationItem = '<li class="waves-effect page-item%s"><a href="#">%s</a></li>'
  40. this.constants.html.icon = '<i class="%s">%s</i>'
  41. }
  42. initToolbar () {
  43. super.initToolbar()
  44. this.handleToolbar()
  45. }
  46. handleToolbar () {
  47. if (this.$toolbar.find('.dropdown-toggle').length) {
  48. this.$toolbar.find('.dropdown-toggle').each((i, el) => {
  49. $(el).attr('data-target', $(el).next().attr('id'))
  50. .dropdown({
  51. alignment: 'right',
  52. constrainWidth: false,
  53. closeOnClick: false
  54. })
  55. })
  56. }
  57. }
  58. initPagination () {
  59. super.initPagination()
  60. if (this.options.pagination && !this.options.onlyInfoPagination) {
  61. this.$pagination.find('.dropdown-toggle')
  62. .attr('data-target', this.$pagination.find('.dropdown-content').attr('id'))
  63. .dropdown()
  64. }
  65. }
  66. }