From f6e923f308467aa37e011fa942cfbc5c579a142e Mon Sep 17 00:00:00 2001 From: zhaoshuxue Date: Sat, 20 Jan 2018 14:13:11 +0800 Subject: [PATCH] 1 --- src/extensions/page-jump/README.md | 26 ++++ .../page-jump/bootstrap-table-pagejump.css | 49 ++++++++ .../page-jump/bootstrap-table-pagejump.js | 57 +++++++++ src/extensions/page-jump/demo.png | Bin 0 -> 2439 bytes src/extensions/page-jump/index.html | 113 ++++++++++++++++++ src/locale/bootstrap-table-zh-CN.js | 3 + 6 files changed, 248 insertions(+) create mode 100644 src/extensions/page-jump/README.md create mode 100644 src/extensions/page-jump/bootstrap-table-pagejump.css create mode 100644 src/extensions/page-jump/bootstrap-table-pagejump.js create mode 100644 src/extensions/page-jump/demo.png create mode 100644 src/extensions/page-jump/index.html diff --git a/src/extensions/page-jump/README.md b/src/extensions/page-jump/README.md new file mode 100644 index 0000000000..a48ae2bb48 --- /dev/null +++ b/src/extensions/page-jump/README.md @@ -0,0 +1,26 @@ +# Table Page Jump + +## Usage + +```html + + +``` + +## Options + +### paginationShowPageGo + +* type: Boolean +* description: Set true to enable show 'Page Jump'. +* default: `false` + +## Language + +``` + +``` + +## ex + +![](demo.png) diff --git a/src/extensions/page-jump/bootstrap-table-pagejump.css b/src/extensions/page-jump/bootstrap-table-pagejump.css new file mode 100644 index 0000000000..511d2e38a3 --- /dev/null +++ b/src/extensions/page-jump/bootstrap-table-pagejump.css @@ -0,0 +1,49 @@ +.pagination-jump { + margin: 0; +} + +.pagination-jump { + display: inline-block; + padding-left: 1px; + border-radius: 4px; +} + +.pagination-jump>li { + display: inline; +} + +.pagination-jump>li>a, .pagination-jump>li>input, .pagination-jump>li>span { + position: relative; + float: left; + margin-left: -1px; + line-height: 1.42857143; + color: #337ab7; + text-decoration: none; + background-color: #fff; +} + +.pagination-jump>li>a { + padding: 6px 12px; + border: 1px solid #ddd; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; +} + +.pagination-jump>li>input { + padding: 6px 0px; + border: 1px solid #ddd; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; + width: 36px; + text-align: center; +} + +.pagination-jump>li>span{ + padding: 6px 3px 6px 12px; +} + + +.pagination-jump>li>.jump-go { + margin-left: 0; + padding: 6px; +} \ No newline at end of file diff --git a/src/extensions/page-jump/bootstrap-table-pagejump.js b/src/extensions/page-jump/bootstrap-table-pagejump.js new file mode 100644 index 0000000000..74b741faf7 --- /dev/null +++ b/src/extensions/page-jump/bootstrap-table-pagejump.js @@ -0,0 +1,57 @@ +/** + * @author zhaoshuxue + * extensions: https://github.com/zhaoshuxue/bootstrap-table/src/extensions/page-jump + */ + +(function ($) { + 'use strict'; + $.extend($.fn.bootstrapTable.defaults, { + // 默认不显示 + paginationShowPageGo: false + }); + + $.extend($.fn.bootstrapTable.locales, { + pageGo: function () { + return 'Page Jump'; + } + }); + $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales); + + var BootstrapTable = $.fn.bootstrapTable.Constructor, + _initPagination = BootstrapTable.prototype.initPagination; + + BootstrapTable.prototype.initPagination = function() { + _initPagination.apply(this, Array.prototype.slice.apply(arguments)); + if(this.options.paginationShowPageGo){ + var html = []; + + html.push( + ''); + this.$pagination.find('ul.pagination').after(html.join('')); + + this.$pagination.find('.page-go').off('click').on('click', $.proxy(this.onPageGo, this)); + this.$pagination.find('.page-input').off('keyup').on('keyup', function(){ + this.value = this.value.length == 1 ? this.value.replace(/[^1-9]/g,'') : this.value.replace(/\D/g,''); + }); + } + }; + + BootstrapTable.prototype.onPageGo = function (event) { + // var $this = $(event.currentTarget); + var $toPage=this.$pagination.find('.page-input'); + + if (this.options.pageNumber === +$toPage.val()) { + return false; + } + this.selectPage(+$toPage.val()); + // this.options.pageNumber = +$toPage.val(); + + // this.updatePagination(event); + // $this.prev().find('input').val(this.options.pageNumber); + return false; + }; +})(jQuery); diff --git a/src/extensions/page-jump/demo.png b/src/extensions/page-jump/demo.png new file mode 100644 index 0000000000000000000000000000000000000000..c98d3c71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dGEwU!ihgFii5?eU zox6`EEW(Y(g`UY*H=%X5$H}SMBSl9TT55x8dqEh>uTnS+xgbbu=h|rszsUDn_Hhbi z*MT&vhN`7`<|F!!YjVW~@3WknGb7UHMEGwlvn?$(HP^xT$fH@Uf|~H17(9th(l1pf z#FYDyy?6|jdy?w*ah*s zJ_TC?&>QoSIV!Hgi|<67(?!+x6BbPsGfeQT;U zR=fjmOZq}?EigaEt~c^Oc&7vFKxMFZ+eW*5aBh@o_T+`E&R|Q{y@`KtLw9oDjoh2P zE`Ap7ooThs;)R^1VLdR@6>5qbxG(%9Z(m%=f^PZS#;d|Oe`(HaR~qj&6%(Una_2&H zgmMbsD~N3l`V{MW`;#JKf!ftSm(_gXmo%)Gs4d$j=Cxr{gv}QrE?R?F z39##C>@Wl5WbeT`Cpznx;3?_xnKF1%9bfNv=SXjfn|tHkJ9t~ngQ{&6vzWAI)$1g> zFR4xNZsn*VC1bLSRaxid)E(zlmRrsR29bO=R4?Jl`6gPb3E@) zLd(F9H`m5I)omdvTgaqEobIM}o6-rVnwCnALwSjKzy7|y6c>7uXkm2egH0KQtrvcl zm)-s9$#_)2jDPI)`N_!qe{)>vYjyGZ%eCTBn@@4Mo4pH=NCX?vC7pf?tdz2Dc+V&y z@^Mv{C)h&F%73=?&=k$#Z94P)-;wjDBmDRCTjoG%*^&zBtx65QK8mC1{0s{J3jc73 zrTNW{jm6`}ZIHMlw1&z1qnEZiM`Zkmb^QN}C + + + + DEMO + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/src/locale/bootstrap-table-zh-CN.js b/src/locale/bootstrap-table-zh-CN.js index 874f340a3a..c0c819923d 100644 --- a/src/locale/bootstrap-table-zh-CN.js +++ b/src/locale/bootstrap-table-zh-CN.js @@ -38,6 +38,9 @@ }, formatClearFilters: function () { return '清空过滤'; + }, + pageGo: function () { + return '跳转到'; } };