Skip to content

Commit c530474

Browse files
committed
fix #1090, support tooltip on page button and able to custom them
1 parent e185529 commit c530474

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

src/BootstrapTable.js

+12
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,10 @@ class BootstrapTable extends Component {
10071007
nextPage={ options.nextPage || Const.NEXT_PAGE }
10081008
firstPage={ options.firstPage || Const.FIRST_PAGE }
10091009
lastPage={ options.lastPage || Const.LAST_PAGE }
1010+
prePageTitle={ options.prePageTitle || Const.PRE_PAGE_TITLE }
1011+
nextPageTitle={ options.nextPageTitle || Const.NEXT_PAGE_TITLE }
1012+
firstPageTitle={ options.firstPageTitle || Const.FIRST_PAGE_TITLE }
1013+
lastPageTitle={ options.lastPageTitle || Const.LAST_PAGE_TITLE }
10101014
hideSizePerPage={ options.hideSizePerPage }
10111015
sizePerPageDropDown={ options.sizePerPageDropDown }
10121016
paginationPanel={ options.paginationPanel }
@@ -1338,6 +1342,10 @@ BootstrapTable.propTypes = {
13381342
nextPage: PropTypes.string,
13391343
firstPage: PropTypes.string,
13401344
lastPage: PropTypes.string,
1345+
prePageTitle: PropTypes.string,
1346+
nextPageTitle: PropTypes.string,
1347+
firstPageTitle: PropTypes.string,
1348+
lastPageTitle: PropTypes.string,
13411349
searchDelayTime: PropTypes.number,
13421350
exportCSVText: PropTypes.string,
13431351
insertText: PropTypes.string,
@@ -1474,6 +1482,10 @@ BootstrapTable.defaultProps = {
14741482
nextPage: Const.NEXT_PAGE,
14751483
firstPage: Const.FIRST_PAGE,
14761484
lastPage: Const.LAST_PAGE,
1485+
prePageTitle: Const.PRE_PAGE_TITLE,
1486+
nextPageTitle: Const.NEXT_PAGE_TITLE,
1487+
firstPageTitle: Const.FIRST_PAGE_TITLE,
1488+
lastPageTitle: Const.LAST_PAGE_TITLE,
14771489
pageStartIndex: undefined,
14781490
searchDelayTime: undefined,
14791491
exportCSVText: Const.EXPORT_CSV_TEXT,

src/Const.js

+4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ const CONST_VAR = {
33
SORT_ASC: 'asc',
44
SIZE_PER_PAGE: 10,
55
NEXT_PAGE: '>',
6+
NEXT_PAGE_TITLE: 'next page',
67
LAST_PAGE: '>>',
8+
LAST_PAGE_TITLE: 'last page',
79
PRE_PAGE: '<',
10+
PRE_PAGE_TITLE: 'previous page',
811
FIRST_PAGE: '<<',
12+
FIRST_PAGE_TITLE: 'first page',
913
PAGE_START_INDEX: 1,
1014
ROW_SELECT_BG_COLOR: '',
1115
ROW_SELECT_NONE: 'none',

src/pagination/PageButton.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ class PageButton extends Component {
2020
'page-item': true
2121
});
2222
return (
23-
<li className={ classes }>
23+
<li className={ classes } title={ this.props.title }>
2424
<a href='#' onClick={ this.pageBtnClick } className='page-link'>{ this.props.children }</a>
2525
</li>
2626
);
2727
}
2828
}
2929
PageButton.propTypes = {
30+
title: PropTypes.string,
3031
changePage: PropTypes.func,
3132
active: PropTypes.bool,
3233
disable: PropTypes.bool,

src/pagination/PaginationList.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,21 @@ class PaginationList extends Component {
203203
const isDisabled = (isStart(page, this.props) || isEnd(page, this.props)) ?
204204
true :
205205
false;
206+
let title = page + '';
207+
208+
if (page === this.props.nextPage) {
209+
title = this.props.nextPageTitle;
210+
} else if (page === this.props.prePage) {
211+
title = this.props.prePageTitle;
212+
} else if (page === this.props.firstPage) {
213+
title = this.props.firstPageTitle;
214+
} else if (page === this.props.lastPage) {
215+
title = this.props.lastPageTitle;
216+
}
217+
206218
return (
207219
<PageButton key={ page }
220+
title={ title }
208221
changePage={ this.changePage }
209222
active={ isActive }
210223
disable={ isDisabled }>
@@ -281,7 +294,11 @@ PaginationList.propTypes = {
281294
alwaysShowAllBtns: PropTypes.bool,
282295
withFirstAndLast: PropTypes.bool,
283296
sizePerPageDropDown: PropTypes.func,
284-
paginationPanel: PropTypes.func
297+
paginationPanel: PropTypes.func,
298+
prePageTitle: PropTypes.string,
299+
nextPageTitle: PropTypes.string,
300+
firstPageTitle: PropTypes.string,
301+
lastPageTitle: PropTypes.string
285302
};
286303

287304
PaginationList.defaultProps = {

0 commit comments

Comments
 (0)