-// 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.
//
/*jslint browser: true, es5: true */
/*globals $: true, rootPath: true */
-(function() {
- if (window.playgroundUrl) {
- $('pre.rust').hover(function() {
- var a = $('<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]);
+ };
+ });
+});
-// 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.
//
// 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));