diff --git a/src/doc/footer.inc b/src/doc/footer.inc index f32f2fd443f8e..b5eb589eb5398 100644 --- a/src/doc/footer.inc +++ b/src/doc/footer.inc @@ -5,5 +5,4 @@ or the MIT license, at your opt
This file may not be copied, modified, or distributed except according to those terms.
- diff --git a/src/librustdoc/html/static/playpen.js b/src/librustdoc/html/static/playpen.js index 06b3c4e42d633..ff947d93fca16 100644 --- a/src/librustdoc/html/static/playpen.js +++ b/src/librustdoc/html/static/playpen.js @@ -1,4 +1,4 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -11,17 +11,37 @@ /*jslint browser: true, es5: true */ /*globals $: true, rootPath: true */ -(function() { - if (window.playgroundUrl) { - $('pre.rust').hover(function() { - var a = $('').text('⇱').attr('class', 'test-arrow'); - var code = $(this).prev(".rusttest").text(); - a.attr('href', window.playgroundUrl + '?code=' + - encodeURIComponent(code)); - a.attr('target', '_blank'); - $(this).append(a); - }, function() { - $(this).find('a.test-arrow').remove(); - }); +document.addEventListener('DOMContentLoaded', function() { + if (!window.playgroundUrl) { + return; } -}()); + + var elements = document.querySelectorAll('pre.rust'); + + Array.prototype.forEach.call(elements, function(el) { + el.onmouseover = function(e) { + if (el.contains(e.relatedTarget)) { + return; + } + + var a = document.createElement('a'); + a.textContent = '⇱'; + a.setAttribute('class', 'test-arrow'); + + var code = el.previousElementSibling.textContent; + a.setAttribute('href', window.playgroundUrl + '?code=' + + encodeURIComponent(code)); + a.setAttribute('target', '_blank'); + + el.appendChild(a); + }; + + el.onmouseout = function(e) { + if (el.contains(e.relatedTarget)) { + return; + } + + el.removeChild(el.querySelectorAll('a.test-arrow')[0]); + }; + }); +}); diff --git a/src/rustbook/build.rs b/src/rustbook/build.rs index 5ffb9b007d041..a7a6ed3bfe749 100644 --- a/src/rustbook/build.rs +++ b/src/rustbook/build.rs @@ -1,4 +1,4 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -158,10 +158,7 @@ fn render(book: &Book, tgt: &Path) -> CliResult<()> { // create index.html from the root README try!(fs::copy(&tgt.join("README.html"), &tgt.join("index.html"))); - // Copy some js for playpen - let mut jquery = try!(File::create(tgt.join("jquery.js"))); - let js = include_bytes!("../librustdoc/html/static/jquery-2.1.0.min.js"); - try!(jquery.write_all(js)); + // Copy js for playpen let mut playpen = try!(File::create(tgt.join("playpen.js"))); let js = include_bytes!("../librustdoc/html/static/playpen.js"); try!(playpen.write_all(js)); diff --git a/src/rustbook/javascript.rs b/src/rustbook/javascript.rs index 26303d13b6cfc..f33b79cc1888f 100644 --- a/src/rustbook/javascript.rs +++ b/src/rustbook/javascript.rs @@ -71,6 +71,5 @@ document.addEventListener("DOMContentLoaded", function(event) { }); - "#;