examples.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. $(function() {
  2. 'use strict';
  3. $('.bs-example').each(function() {
  4. var source = $('<div></div>').text($(this).html()).html(),
  5. sources = source.split('\n'),
  6. codes = [],
  7. spaces = 0;
  8. try {
  9. $.each(sources, function(i, text) {
  10. if (!$.trim(text)) {
  11. i > 0 && codes.push('');
  12. return;
  13. }
  14. if (!spaces) {
  15. spaces = text.match(/(^\s+)/)[1].length;
  16. }
  17. codes.push(text.substring(spaces));
  18. });
  19. $(this).next().find('code').html(codes.join('\n'));
  20. } catch (e) {
  21. $(this).next().remove();
  22. }
  23. });
  24. $('#i18n').change(function() {
  25. $.getScript('../src/locale/bootstrap-table-' + $(this).val() + '.js', function() {
  26. $('#table-pagination').bootstrapTable('destroy').bootstrapTable();
  27. });
  28. });
  29. $(window).resize(function () {
  30. $('table[data-toggle="table"]').bootstrapTable('resetView');
  31. });
  32. });