-
Notifications
You must be signed in to change notification settings - Fork 279
/
Copy pathhideOutput.js
62 lines (53 loc) · 2.09 KB
/
hideOutput.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
$(document).ready(function() {
// $chunks = $('.folded, .unfolded');
// var thisClass;
// $chunks.each(function () {
// $(this).find('img').unwrap('<p>');
// $(this).find('img').wrap('<pre class=\"plot\"></pre>');
// thisClass = $(this).attr('class');
// var word;
// if(thisClass === 'unfolded') {
// word = 'Hide';
// } else {
// word = 'Show';
// $('pre', this).find('code, img').toggle();
// }
// $('pre.r', this).append('<span class=\"showopt\">' + word + ' Source</span>');
// $('pre:not(.r)', this).has('code').append('<span class=\"showopt\">' + word + ' Output</span>');
// $('pre.plot', this).append('<span class=\"showopt\">' + word + ' Plot</span>');
// });
// $(".showopt").click(function() {
// var label = $(this).html();
// if(label.indexOf('Show') >= 0) {
// $(this).html(label.replace('Show', 'Hide'));
// } else {
// $(this).html(label.replace('Hide', 'Show'));
// }
// $(this).parent().find('code, img').slideToggle('fast', 'swing');
// });
// Copy Button
// $chunks = $('pre.sourceCode > code.sourceCode');
// $chunks.each(function(i, val) {
// $(this).prepend("<button class=\"download\"><i class=\"fa fa-download fa-2x\"></i></button>").click(function() {
// var $temp = $('<a />');
// $("body").append($temp);
// var content = $(this).clone().children("button").remove().end().text();
// $temp.attr({
// download: $(this).closest('div').attr('id') +'.R',
// href: "data:text/plain;charset=utf-8," + encodeURIComponent(content)
// })[0].click();
// $temp.remove();
// });
// });
// $chunks.each(function(i, val) {
//
// $(this).prepend("<button class=\"button copy\"><i class=\"fa fa-copy fa-2x\"></i></button>").click(function() {
// var $temp = $("<textarea>");
// $("body").append($temp);
// var content = $(this).clone().children("button").remove().end().text();
// $temp.val(content).select();
// document.execCommand("copy");
// $temp.remove();
// });
// });
});