From bf1b1e976b8315f67f82e324e6d3bc3d0b353fd5 Mon Sep 17 00:00:00 2001 From: Joseph Pecoraro Date: Fri, 29 May 2009 18:35:55 -0400 Subject: Semi-fix for Firefox code Copy and Paste The underlieing problem is that Firefox ignores the css 'white-space:pre' rule when actually copying and pasting. This Javascript turns newlines into
tags inside the code containers. This will run in Safari, Opera, Chrome, Webkit, etc. gracefully. This will not run in IE due to IE not having the methods needed. A permanent solution would be at the Markdown level in such a way that the highlighter still runs on the output with brake tags. --- railties/guides/files/javascripts/guides.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'railties/guides/files') diff --git a/railties/guides/files/javascripts/guides.js b/railties/guides/files/javascripts/guides.js index 81fc07e799..14bad4beb9 100755 --- a/railties/guides/files/javascripts/guides.js +++ b/railties/guides/files/javascripts/guides.js @@ -1,8 +1,17 @@ function guideMenu(){ - if (document.getElementById('guides').style.display == "none") { document.getElementById('guides').style.display = "block"; } else { document.getElementById('guides').style.display = "none"; } } + +// Fix Copy+Paste of Code blocks in Firefox 3 +if ( window.addEventListener && document.getElementsByClassName ) { + window.addEventListener('load', function() { + var list = document.getElementsByClassName('code_container'); + for (var i=0, len=list.length; i'); + } + }, false); +} -- cgit v1.2.3