Skip to content
Browse files

Removing prototype and just using vanilla js

  • Loading branch information...
1 parent d78e3fe commit 6193be26ce49bc24d67eb97f2f5f49c86f9f6bb7 @mikel mikel committed with jeremy Mar 3, 2010
Showing with 17 additions and 17 deletions.
  1. +17 −17 railties/lib/generators/rails/app/templates/public/index.html
View
34 railties/lib/generators/rails/app/templates/public/index.html
@@ -181,27 +181,27 @@
}
</style>
- <script type="text/javascript" src="javascripts/prototype.js"></script>
- <script type="text/javascript" src="javascripts/effects.js"></script>
<script type="text/javascript">
function about() {
- if (Element.empty('about-content')) {
- new Ajax.Updater('about-content', 'rails/info/properties', {
- method: 'get',
- onFailure: function() {Element.classNames('about-content').add('failure')},
- onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
- });
- } else {
- new Effect[Element.visible('about-content') ?
- 'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
- }
+ info = document.getElementById('about-content');
+ if (window.XMLHttpRequest)
+ { xhr = new XMLHttpRequest(); }
+ else
+ { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
+ xhr.open("GET","rails/info/properties",false);
+ xhr.send("");
+ info.innerHTML = xhr.responseText;
+ info.style.display = 'block'
+ }
+
+ function prepend() {
+ search = document.getElementById('search-text');
+ text = search.value;
+ search.value = 'site:rubyonrails.org ' + text;
}
window.onload = function() {
- $('search-text').value = '';
- $('search').onsubmit = function() {
- $('search-text').value = 'site:rubyonrails.org ' + $F('search-text');
- }
+ document.getElementById('search-text').value = '';
}
</script>
</head>
@@ -210,7 +210,7 @@
<div id="sidebar">
<ul id="sidebar-items">
<li>
- <form id="search" action="http://www.google.com/search" method="get">
+ <form id="search" action="http://www.google.com/search" method="get" onSubmit="prepend();">
<input type="hidden" name="hl" value="en" />
<input type="text" id="search-text" name="q" value="site:rubyonrails.org " />
<input type="submit" value="Search" /> the Rails site

2 comments on commit 6193be2

@yfeldblum

I like this, in the name of unobtrusive-javascript and javascript-framework-agnosticism. While I like prototype.js, I also like the consistent direction rails 3 is taking. One question, though - why add an onSubmit attribute rather than attach the handler from within the window.onload handler?

@jeremy
Ruby on Rails member
jeremy commented on 6193be2 Mar 3, 2010

yfeldblum, this is only for the Welcome to Rails page you get when you generate a new app. Since the app may use any javascript library, we can't really rely on any one of them. Do feel free to tweak this page to improve it and submit a patch!

Please sign in to comment.
Something went wrong with that request. Please try again.