common.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. $(function () {
  2. $('h1').find('a')
  3. .attr('target', '_blank')
  4. .addClass('edit-page-link')
  5. .text('Edit on GitHub');
  6. // languages
  7. $('[data-language]').each(function (i) {
  8. var $this = $(this),
  9. language = $this.data('language');
  10. // default
  11. if (i === 0) {
  12. $this.addClass('active');
  13. }
  14. $this.find('a').attr('href', '/' + (language === 'en' ? '' : language));
  15. if (location.href.indexOf(language) !== -1) {
  16. $this.addClass('active').siblings().removeClass('active');
  17. $('.language').text($(this).text());
  18. }
  19. });
  20. // examples
  21. $('iframe[data-src]').each(function () {
  22. $(this).wrap('<div class="examples-parent"></div>').parent()
  23. .append('<button class="examples-button btn btn-primary btn-lg"><i class="glyphicon glyphicon-fire"></i> Start Example</button>');
  24. });
  25. $(document).on('click', 'button.examples-button', function () {
  26. var $iframe = $(this).prev();
  27. $iframe.attr('src', $iframe.data('src'));
  28. $(this).remove();
  29. });
  30. if (location.href.indexOf('documentation') > -1) {
  31. var query = {
  32. t: '',
  33. c: '',
  34. e: '',
  35. m: '',
  36. l: ''
  37. };
  38. $.each(location.search.substring(1).split('&'), function (i, t) {
  39. var arr = t.split('=');
  40. if (query.hasOwnProperty(arr[0])) {
  41. query[arr[0]] = arr[1];
  42. }
  43. });
  44. $.each(query, function (id, value) {
  45. $('#' + id).bootstrapTable({
  46. searchText: value
  47. });
  48. });
  49. }
  50. });