bootstrap-table-foundation.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * @author zhixin wen <wenzhixin2010@gmail.com>
  3. * https://github.com/wenzhixin/bootstrap-table/
  4. * theme: https://github.com/zurb/foundation-sites
  5. */
  6. $.extend($.fn.bootstrapTable.defaults, {
  7. classes: 'table hover',
  8. buttonsPrefix: '',
  9. buttonsClass: 'button'
  10. })
  11. $.BootstrapTable = class extends $.BootstrapTable {
  12. initConstants () {
  13. super.initConstants()
  14. this.constants.theme = 'foundation'
  15. this.constants.classes.buttonsGroup = 'button-group'
  16. this.constants.classes.buttonsDropdown = 'dropdown-container'
  17. this.constants.classes.paginationDropdown = ''
  18. this.constants.classes.dropdownActive = 'is-active'
  19. this.constants.classes.paginationActive = 'current'
  20. this.constants.html.toobarDropdow = ['<ul class="dropdown-pane" id="toolbar-dropdown" data-dropdown><ul class="vertical menu">', '</ul></div>']
  21. this.constants.html.toobarDropdowItem = '<li><label class="dropdown-item">%s</label></li>'
  22. this.constants.html.pageDropdown = ['<ul class="dropdown-pane" id="page-list-dropdown" data-dropdown><ul class="vertical menu">', '</ul></ul>']
  23. this.constants.html.pageDropdownItem = '<li class="dropdown-item %s"><a href="#">%s</a></li>'
  24. this.constants.html.dropdownCaret = '<i class="fa fa-angle-down"></i>'
  25. this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>'],
  26. this.constants.html.paginationItem = '<li><a class="page-item%s" href="#">%s</a></li>'
  27. }
  28. initToolbar () {
  29. super.initToolbar()
  30. if (this.options.showColumns) {
  31. this.$toolbar.find('.keep-open')
  32. .attr('data-toggle', 'toolbar-dropdown')
  33. const $pane = this.$toolbar.find('.dropdown-pane')
  34. .attr('data-position', 'bottom')
  35. .attr('data-alignment', 'right')
  36. new window.Foundation.Dropdown($pane)
  37. this._initDropdown()
  38. }
  39. }
  40. initPagination () {
  41. super.initPagination()
  42. if (this.options.pagination && !this.options.onlyInfoPagination) {
  43. this.$pagination.find('.dropdown-toggle')
  44. .attr('data-toggle', 'page-list-dropdown')
  45. const $pane = this.$pagination.find('.dropdown-pane')
  46. .attr('data-position', 'top')
  47. .attr('data-alignment', 'left')
  48. new window.Foundation.Dropdown($pane)
  49. }
  50. }
  51. _initDropdown ($el) {
  52. const $dropdowns = this.$container.find('.dropdown-container')
  53. $dropdowns.off('click').on('click', e => {
  54. e.stopPropagation()
  55. $dropdowns.find('.dropdown-pane').foundation('toggle')
  56. })
  57. $(document).off('click.bs.dropdown.foundation').on('click.bs.dropdown.foundation', () => {
  58. $dropdowns.find('.dropdown-pane').foundation('close')
  59. })
  60. }
  61. }