bootstrap-table-jumpto.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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: false,
  9. exportOptions: {}
  10. });
  11. $.extend($.fn.bootstrapTable.locales, {
  12. formatJumpto: function () {
  13. return 'GO';
  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. this.showToolbar = this.options.showExport;
  21. _initPagination.apply(this, Array.prototype.slice.apply(arguments));
  22. if (this.options.showJumpto) {
  23. var that = this,
  24. $pageGroup = this.$pagination.find('ul.pagination'),
  25. $jumpto = $pageGroup.find('li.jumpto');
  26. if (!$jumpto.length) {
  27. $jumpto = $([
  28. '<li class="jumpto">',
  29. '<input type="text" class="form-control">',
  30. '<button class="btn' +
  31. sprintf(' btn-%s', this.options.buttonsClass) +
  32. sprintf(' btn-%s', this.options.iconSize) +
  33. '" title="' + this.options.formatJumpto() + '" ' +
  34. ' type="button">'+this.options.formatJumpto(),
  35. '</button>',
  36. '</li>'].join('')).appendTo($pageGroup);
  37. $jumpto.find('button').click(function () {
  38. that.selectPage(parseInt($jumpto.find('input').val()));
  39. });
  40. }
  41. }
  42. };
  43. })(jQuery);