Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Move error page js into script tag #8723

Merged
merged 1 commit into from

6 participants

@goshakkk

No description provided.

@vijaydev
Collaborator

:+1:

...tion_dispatch/middleware/templates/rescues/layout.erb
@@ -114,6 +114,28 @@
a:visited { color: #666; }
a:hover { color: #C52F24; }
</style>
+
+ <script>
+ toggle = function(id) {
+ s = document.getElementById(id).style;

Can you use var at least here? s doesn't need to be global.

@goshakkk
goshakkk added a note

Sorry, fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@acapilleri acapilleri commented on the diff
...tion_dispatch/middleware/templates/rescues/layout.erb
@@ -114,6 +114,28 @@
a:visited { color: #666; }
a:hover { color: #C52F24; }
</style>
+
+ <script>

add type="text/javascript", it is HTML4/XHTML1 require

@goshakkk
goshakkk added a note

I think <!DOCTYPE html> clearly states it is HTML5 document, and omitting type in it is allowed. (Look also at <style> tag—no type as well.)

@steveklabnik Collaborator

Rails is HTML5.

and HTML5 is Rails... :+1: anywa you're right, it has no sense for an error page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@guilleiguaran

Let's do this!

@guilleiguaran guilleiguaran merged commit 7019858 into rails:master
@goshakkk

Thanks for merging :)

@goshakkk goshakkk deleted the goshakkk:refactor-error-page branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 3, 2013
  1. @goshakkk
This page is out of date. Refresh to see the latest.
View
6 actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
@@ -1,6 +1,6 @@
<% unless @exception.blamed_files.blank? %>
<% if (hide = @exception.blamed_files.length > 8) %>
- <a href="#" onclick="s = document.getElementById('blame_trace').style; s.display = s.display == 'none' ? 'block' : 'none'; return false;">Toggle blamed files</a>
+ <a href="#" onclick="toggleTrace()">Toggle blamed files</a>
<% end %>
<pre id="blame_trace" <%='style="display:none"' if hide %>><code><%=h @exception.describe_blame %></code></pre>
<% end %>
@@ -21,12 +21,12 @@
<p><b>Parameters</b>:</p> <pre><%=h request_dump %></pre>
<div class="details">
- <div class="summary"><a href="#" onclick="s = document.getElementById('session_dump').style; s.display = s.display == 'none' ? 'block' : 'none'; return false;">Toggle session dump</a></div>
+ <div class="summary"><a href="#" onclick="toggleSessionDump()">Toggle session dump</a></div>
<div id="session_dump" style="display:none"><pre><%= debug_hash @request.session %></pre></div>
</div>
<div class="details">
- <div class="summary"><a href="#" onclick="s = document.getElementById('env_dump').style; s.display = s.display == 'none' ? 'block' : 'none'; return false;">Toggle env dump</a></div>
+ <div class="summary"><a href="#" onclick="toggleEnvDump()">Toggle env dump</a></div>
<div id="env_dump" style="display:none"><pre><%= debug_hash @request.env.slice(*@request.class::ENV_METHODS) %></pre></div>
</div>
View
4 actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb
@@ -12,8 +12,8 @@
<div id="traces">
<% names.each do |name| %>
<%
- show = "document.getElementById('#{name.gsub(/\s/, '-')}').style.display='block';"
- hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub(/\s/, '-')}').style.display='none';"}
+ show = "show('#{name.gsub(/\s/, '-')}');"
+ hide = (names - [name]).collect {|hide_name| "hide('#{hide_name.gsub(/\s/, '-')}');"}
%>
<a href="#" onclick="<%= hide.join %><%= show %>; return false;"><%= name %></a> <%= '|' unless names.last == name %>
<% end %>
View
22 actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb
@@ -114,6 +114,28 @@
a:visited { color: #666; }
a:hover { color: #C52F24; }
</style>
+
+ <script>

add type="text/javascript", it is HTML4/XHTML1 require

@goshakkk
goshakkk added a note

I think <!DOCTYPE html> clearly states it is HTML5 document, and omitting type in it is allowed. (Look also at <style> tag—no type as well.)

@steveklabnik Collaborator

Rails is HTML5.

and HTML5 is Rails... :+1: anywa you're right, it has no sense for an error page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ var toggle = function(id) {
+ var s = document.getElementById(id).style;
+ s.display = s.display == 'none' ? 'block' : 'none';
+ }
+ var show = function(id) {
+ document.getElementById(id).style.display = 'block';
+ }
+ var hide = function(id) {
+ document.getElementById(id).style.display = 'none';
+ }
+ var toggleTrace = function() {
+ toggle('blame_trace');
+ }
+ var toggleSessionDump = function() {
+ toggle('session_dump');
+ }
+ var toggleEnvDump = function() {
+ toggle('env_dump');
+ }
+ </script>
</head>
<body>
Something went wrong with that request. Please try again.