UNPKG

3.02 kBJavaScriptView Raw
1/**
2 * @author zhixin wen <wenzhixin2010@gmail.com>
3 * https://github.com/wenzhixin/bootstrap-table/
4 * theme: https://github.com/jgthms/bulma/
5 */
6
7$.extend($.fn.bootstrapTable.defaults, {
8 classes: 'table is-bordered is-hoverable',
9 buttonsPrefix: '',
10 buttonsClass: 'button'
11})
12
13$.fn.bootstrapTable.theme = 'bulma'
14
15$.BootstrapTable = class extends $.BootstrapTable {
16 initConstants () {
17 super.initConstants()
18
19 this.constants.classes.buttonsGroup = 'buttons has-addons'
20 this.constants.classes.buttonsDropdown = 'button dropdown is-right'
21 this.constants.classes.input = 'input'
22 this.constants.classes.paginationDropdown = 'ui dropdown'
23 this.constants.classes.dropup = 'is-up'
24 this.constants.classes.dropdownActive = 'is-active'
25 this.constants.classes.paginationActive = 'is-current'
26 this.constants.classes.buttonActive = 'is-active'
27
28 this.constants.html.toolbarDropdown = ['<div class="dropdown-menu"><div class="dropdown-content">', '</div></div>']
29 this.constants.html.toolbarDropdownItem = '<label class="dropdown-item dropdown-item-marker">%s</label>'
30 this.constants.html.toolbarDropdownSeparator = '<li class="dropdown-divider"></li>'
31 this.constants.html.pageDropdown = ['<div class="dropdown-menu"><div class="dropdown-content">', '</div></div>']
32 this.constants.html.pageDropdownItem = '<a class="dropdown-item %s" href="#">%s</a>'
33 this.constants.html.dropdownCaret = '<span class="icon is-small"><i class="fas fa-angle-down" aria-hidden="true"></i></span>'
34 this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>']
35 this.constants.html.paginationItem = '<li><a class="page-item pagination-link%s" aria-label="%s" href="#">%s</a></li>'
36 this.constants.html.searchInput = '<p class="control"><input class="%s input-%s" type="text" placeholder="%s"></p>'
37 this.constants.html.inputGroup = '<div class="field has-addons has-addons-right">%s%s</div>'
38 this.constants.html.searchButton = '<p class="control"><button class="%s" type="button" name="search" title="%s">%s %s</button></p>'
39 this.constants.html.searchClearButton = '<p class="control"><button class="%s" type="button" name="clearSearch" title="%s">%s %s</button></p>'
40 }
41
42 initToolbar () {
43 super.initToolbar()
44 this.handleToolbar()
45 }
46
47 handleToolbar () {
48 if (this.$toolbar.find('.dropdown').length) {
49 this._initDropdown()
50 }
51 }
52
53 initPagination () {
54 super.initPagination()
55 if (this.options.pagination && !this.options.onlyInfoPagination) {
56 this._initDropdown()
57 }
58 }
59
60 _initDropdown () {
61 const $dropdowns = this.$container.find('.dropdown:not(.is-hoverable)')
62
63 $dropdowns.off('click').on('click', e => {
64 const $this = $(e.currentTarget)
65 e.stopPropagation()
66 $dropdowns.not($this).removeClass('is-active')
67 $this.toggleClass('is-active')
68 })
69
70 $(document).off('click.bs.dropdown.bulma').on('click.bs.dropdown.bulma', () => {
71 $dropdowns.removeClass('is-active')
72 })
73 }
74}