examples.js 950 B

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