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