example.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. $(document).ready(function(){
  2. if (!$.jqplot._noCodeBlock) {
  3. $('script.code').each(function(index) {
  4. if ($('pre.code').eq(index).length ) {
  5. $('pre.code').eq(index).text($(this).html());
  6. }
  7. else {
  8. // var str = $(this).text();
  9. // $('div.jqplot-target').eq(index).after($('<pre class="code">'+str+'</pre>'));
  10. var pre = $('<pre class="code prettyprint brush: js"></pre>');
  11. $('div.jqplot-target').eq(index).after(pre);
  12. pre.text($(this).html());
  13. pre = null;
  14. }
  15. });
  16. $('script.common').each(function(index) {
  17. $('pre.common').eq(index).text($(this).html());
  18. });
  19. var elstr='';
  20. if ($('script.include, link.include').length > 0) {
  21. if ($('pre.include').length == 0) {
  22. var temp = [
  23. '<div class="code prettyprint include">',
  24. '<p class="text">The charts on this page depend on the following files:</p>',
  25. '<pre class="include prettyprint brush: html gutter: false"></pre>',
  26. '</div>'
  27. ];
  28. temp = $(temp.join('\n'));
  29. $('div#example-content').append(temp);
  30. temp = null;
  31. }
  32. $('script.include').each(function(index) {
  33. if (elstr !== '') {
  34. elstr += '\n';
  35. }
  36. elstr += '<script type="text/javascript" src="'+$(this).attr('src')+'"></script>';
  37. });
  38. $('link.include').each(function(index) {
  39. if (elstr !== '') {
  40. elstr += '\n';
  41. }
  42. elstr += '<link rel="stylesheet" type="text/css" hrf="'+$(this).attr('href')+'" />';
  43. })
  44. $('pre.include').text(elstr);
  45. }
  46. else {
  47. $('pre.include').remove();
  48. $('div.include').remove();
  49. }
  50. }
  51. if (!$.jqplot.use_excanvas) {
  52. $('div.jqplot-target').each(function(){
  53. var outerDiv = $(document.createElement('div'));
  54. var header = $(document.createElement('div'));
  55. var div = $(document.createElement('div'));
  56. outerDiv.append(header);
  57. outerDiv.append(div);
  58. outerDiv.addClass('jqplot-image-container');
  59. header.addClass('jqplot-image-container-header');
  60. div.addClass('jqplot-image-container-content');
  61. header.html('Right Click to Save Image As...');
  62. var close = $(document.createElement('a'));
  63. close.addClass('jqplot-image-container-close');
  64. close.html('Close');
  65. close.attr('href', '#');
  66. close.click(function() {
  67. $(this).parents('div.jqplot-image-container').hide(500);
  68. })
  69. header.append(close);
  70. $(this).after(outerDiv);
  71. outerDiv.hide();
  72. outerDiv = header = div = close = null;
  73. if (!$.jqplot._noToImageButton) {
  74. var btn = $(document.createElement('button'));
  75. btn.text('View Plot Image');
  76. btn.addClass('jqplot-image-button');
  77. btn.bind('click', {chart: $(this)}, function(evt) {
  78. var imgelem = evt.data.chart.jqplotToImageElem();
  79. var div = $(this).nextAll('div.jqplot-image-container').first();
  80. div.children('div.jqplot-image-container-content').empty();
  81. div.children('div.jqplot-image-container-content').append(imgelem);
  82. div.show(500);
  83. div = null;
  84. });
  85. $(this).after(btn);
  86. btn.after('<br />');
  87. btn = null;
  88. }
  89. });
  90. }
  91. SyntaxHighlighter.defaults['toolbar'] = true;
  92. SyntaxHighlighter.all();
  93. $(document).unload(function() {$('*').unbind(); });
  94. });