bootstrap-table-materialize.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.toolbarDropdown = ['<ul id="toolbar-columns-id" class="dropdown-content">', '</ul>']
  34. this.constants.html.toolbarDropdownItem = '<li><label>%s</label></li>'
  35. this.constants.html.toolbarDropdownSeperator = '<li class="divider" tabindex="-1"></li>'
  36. this.constants.html.pageDropdown = ['<ul id="pagination-list-id" class="dropdown-content">', '</ul>']
  37. this.constants.html.pageDropdownItem = '<li><a class="%s" href="#">%s</a></li>'
  38. this.constants.html.dropdownCaret = '<i class="material-icons">arrow_drop_down</i>'
  39. this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>']
  40. this.constants.html.paginationItem = '<li class="waves-effect page-item%s" aria-label="%s"><a href="#">%s</a></li>'
  41. this.constants.html.icon = '<i class="%s">%s</i>'
  42. }
  43. initToolbar () {
  44. super.initToolbar()
  45. this.handleToolbar()
  46. }
  47. handleToolbar () {
  48. if (this.$toolbar.find('.dropdown-toggle').length) {
  49. this.$toolbar.find('.dropdown-toggle').each((i, el) => {
  50. $(el).attr('data-target', $(el).next().attr('id'))
  51. .dropdown({
  52. alignment: 'right',
  53. constrainWidth: false,
  54. closeOnClick: false
  55. })
  56. })
  57. }
  58. }
  59. initPagination () {
  60. super.initPagination()
  61. if (this.options.pagination && !this.options.onlyInfoPagination) {
  62. this.$pagination.find('.dropdown-toggle')
  63. .attr('data-target', this.$pagination.find('.dropdown-content').attr('id'))
  64. .dropdown()
  65. }
  66. }
  67. }