bootstrap-table-jumpto.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @author Jay <jwang@dizsoft.com>
  3. */
  4. (function ($) {
  5. 'use strict';
  6. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  7. $.extend($.fn.bootstrapTable.defaults, {
  8. showJumpto:true,
  9. exportOptions: {}
  10. });
  11. $.extend($.fn.bootstrapTable.locales, {
  12. formatJumpto: function () {
  13. return '跳转';
  14. }
  15. });
  16. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  17. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  18. _initPagination = BootstrapTable.prototype.initPagination;
  19. BootstrapTable.prototype.initPagination = function () {
  20. _initPagination.apply(this, Array.prototype.slice.apply(arguments));
  21. if (this.options.showJumpto) {
  22. var that = this,
  23. $pageGroup = this.$pagination.find('ul.pagination'),
  24. $jumpto = $pageGroup.find('li.jumpto');
  25. if (!$jumpto.length) {
  26. $jumpto = $([
  27. '<li class="jumpto">',
  28. '<input type="text" class="form-control">',
  29. '<button ' +
  30. ' title="' + this.options.formatJumpto() + '" ' +
  31. ' type="button" style="height:30px;width: 50px;border-radius: 0.25rem;color: #fff;border: 1px solid transparent;;background-color: #1d7ad9;line-height:1;">'+this.options.formatJumpto(),
  32. '</button>',
  33. '</li>'].join('')).appendTo($pageGroup);
  34. $jumpto.find('button').click(function () {
  35. that.selectPage(parseInt($jumpto.find('input').val()));
  36. });
  37. }
  38. }
  39. };
  40. })(jQuery);