1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | $.extend($.fn.bootstrapTable.defaults, {
|
8 | classes: 'table hover',
|
9 | buttonsPrefix: '',
|
10 | buttonsClass: 'button'
|
11 | })
|
12 |
|
13 | $.fn.bootstrapTable.theme = 'foundation'
|
14 |
|
15 | $.BootstrapTable = class extends $.BootstrapTable {
|
16 | initConstants () {
|
17 | super.initConstants()
|
18 |
|
19 | this.constants.classes.buttonsGroup = 'button-group'
|
20 | this.constants.classes.buttonsDropdown = 'dropdown-container'
|
21 | this.constants.classes.paginationDropdown = ''
|
22 | this.constants.classes.dropdownActive = 'is-active'
|
23 | this.constants.classes.paginationActive = 'current'
|
24 | this.constants.classes.buttonActive = 'success'
|
25 |
|
26 | this.constants.html.toolbarDropdown = ['<ul class="dropdown-pane" id="toolbar-columns-id" data-dropdown><ul class="vertical menu">', '</ul></div>']
|
27 | this.constants.html.toolbarDropdownItem = '<li><label class="dropdown-item">%s</label></li>'
|
28 | this.constants.html.toolbarDropdownSeparator = '<li><hr></li>'
|
29 | this.constants.html.pageDropdown = ['<div class="dropdown-pane" id="pagination-list-id" data-dropdown><ul class="vertical menu">', '</ul></div>']
|
30 | this.constants.html.pageDropdownItem = '<li class="dropdown-item %s"><a href="#">%s</a></li>'
|
31 | this.constants.html.dropdownCaret = '<i class="fa fa-angle-down"></i>'
|
32 | this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>']
|
33 | this.constants.html.paginationItem = '<li><a class="page-item%s" aria-label="%s" href="#">%s</a></li>'
|
34 | this.constants.html.inputGroup = '<div class="input-group">%s <div class="input-group-button">%s</div></div>'
|
35 | this.constants.html.searchInput = '<input class="%s input-%s input-group-field" type="text" placeholder="%s">'
|
36 | }
|
37 |
|
38 | initToolbar () {
|
39 | super.initToolbar()
|
40 | this.handleToolbar()
|
41 | }
|
42 |
|
43 | handleToolbar () {
|
44 | if (this.$toolbar.find('.dropdown-toggle').length) {
|
45 | this.$toolbar.find('.dropdown-toggle').each((i, el) => {
|
46 | $(el).attr('data-toggle', $(el).next().attr('id'))
|
47 | const $pane = $(el).next()
|
48 | .attr('data-position', 'bottom')
|
49 | .attr('data-alignment', 'right')
|
50 | new window.Foundation.Dropdown($pane)
|
51 | })
|
52 |
|
53 | this._initDropdown()
|
54 | }
|
55 | }
|
56 |
|
57 | initPagination () {
|
58 | super.initPagination()
|
59 |
|
60 | if (this.options.pagination && !this.options.onlyInfoPagination) {
|
61 | const $el = this.$pagination.find('.dropdown-toggle')
|
62 | $el.attr('data-toggle', $el.next().attr('id'))
|
63 |
|
64 | const $pane = this.$pagination.find('.dropdown-pane')
|
65 | .attr('data-position', 'top')
|
66 | .attr('data-alignment', 'left')
|
67 | new window.Foundation.Dropdown($pane)
|
68 |
|
69 | this._initDropdown()
|
70 | }
|
71 | }
|
72 |
|
73 | _initDropdown () {
|
74 | const $dropdowns = this.$container.find('.dropdown-toggle')
|
75 |
|
76 | $dropdowns.off('click').on('click', e => {
|
77 | const $this = $(e.currentTarget)
|
78 | e.stopPropagation()
|
79 | $dropdowns.not($this).next().foundation('close')
|
80 | $this.next().foundation('toggle')
|
81 | })
|
82 |
|
83 | $(document).off('click.bs.dropdown.foundation').on('click.bs.dropdown.foundation', () => {
|
84 | $dropdowns.next().foundation('close')
|
85 | })
|
86 | }
|
87 | }
|