Permalink
Browse files

Style guide fixes for the index, contributing, and About jQuery artic…

…les. Fixes #270
  • Loading branch information...
1 parent 70d91de commit 1f48ad24078f1762d7fd966e51e6dbc657b899a7 @alimony alimony committed with ajpiano Mar 14, 2013
Showing with 89 additions and 91 deletions.
  1. +1 −1 CONTRIBUTING.md
  2. +7 −7 page/about-jquery/additional-support.md
  3. +64 −64 page/about-jquery/how-jquery-works.md
  4. +17 −19 page/index.html
View
@@ -7,7 +7,7 @@ customFields:
---
Depending on your level of experience with some of the workflows common to many
-open source projects, e.g., git/Github, the command line, and setting up a
+open source projects, e.g. git/GitHub, the command line, and setting up a
local development environment, contributing to this site may be a breeze or
come with a bit of a learning curve. If you fit into the former group, great!
Jump ahead to learn how to get started.
@@ -27,7 +27,7 @@ There are many subforums where you can discuss jQuery, ask questions, talk about
* [Developing jQuery Plugins](http://forum.jquery.com/developing-jquery-plugins)
* This forum covers development of jQuery plugins.
* [Developing jQuery UI](http://forum.jquery.com/developing-jquery-ui)
- * This is the place to discuss development of [jQuery UI](http://jqueryui.com/) itself - including bugs, new plugins, and how you can help.
+ * This is the place to discuss development of [jQuery UI](http://jqueryui.com/) itself including bugs, new plugins, and how you can help.
* All jQuery UI svn commits are posted to this list to facilitate feedback, discussion, and review.
* Also note that a lot of the development and planning of jQuery UI takes place on the [jQuery UI Development and Planning Wiki](http://wiki.jqueryui.com/).
* [Developing jQuery Mobile](http://forum.jquery.com/developing-jquery-mobile)
@@ -41,12 +41,12 @@ To ensure that you'll get a useful answer in no time, please consider the follow
* Ensure your markup is valid.
* Use Firebug/Developer Tools to see if you have an exception.
-* Use Firebug/Developer Tools to inspect the html classes, css. etc.
-* Try expected resulting html and css without javascript/jQuery and see if the problem could be isolated to those two.
+* Use Firebug/Developer Tools to inspect the HTML classes, CSS, etc.
+* Try expected resulting HTML and CSS without JavaScript/jQuery and see if the problem could be isolated to those two.
* Reduce to a minimal test case (keep removing things until the problem goes away, etc.)
-* Provide that test case as part of your mail. Either upload it somewhere or post it on jsbin.com.
+* Provide that test case as part of your mail. Either upload it somewhere or post it on [jsbin.com](http://jsbin.com/).
-In general, keep your question short and focused and provide only essential details - others can be added when required.
+In general, keep your question short and focused and provide only essential details others can be added when required.
### Mailing List Archives
@@ -71,8 +71,8 @@ The IRC Channel is best if you need quick help with any of the following:
* JavaScript
* jQuery syntax
-* problem solving
-* strange bugs.
+* Problem solving
+* Strange bugs
If your problem is more in-depth, we may ask you to post to the mailing list, or the bug tracker, so that we can help you in a more-suitable environment.
@@ -5,22 +5,22 @@ level: beginner
### jQuery: The Basics
This is a basic tutorial, designed to help you get started using jQuery. If you
-don't have a test page setup yet, start by creating the following HTML page:
+don't have a test page setup yet, start by creating the following HTML page:
```
<!doctype html>
<html>
- <head>
- <meta charset="utf-8">
- <title>Demo</title>
- </head>
- <body>
- <a href="http://jquery.com/">jQuery</a>
- <script src="jquery.js"></script>
- <script>
- // Your code goes here
- </script>
- </body>
+<head>
+ <meta charset="utf-8">
+ <title>Demo</title>
+</head>
+<body>
+ <a href="http://jquery.com/">jQuery</a>
+ <script src="jquery.js"></script>
+ <script>
+ // Your code goes here
+ </script>
+</body>
</html>
```
@@ -30,77 +30,77 @@ and store the `jquery.js` file in the same directory as your HTML file.
### Launching Code on Document Ready
-To ensure that their code runs after the browser finishes loading the document,
+To ensure that their code runs after the browser finishes loading the document,
many JavaScript programmers wrap their code in an `onload` function:
```
window.onload = function() {
- alert("welcome");
+ alert( "welcome" );
}
```
Unfortunately, the code doesn't run until all images are finished downloading, including banner ads.
-To run code as soon as the `document` is ready to be manipulated, jQuery has a statement
-known as the [ ready event ](http://api.jquery.com/ready):
+To run code as soon as the `document` is ready to be manipulated, jQuery has a statement
+known as the [ready event](http://api.jquery.com/ready):
```
-$( document ).ready( function() {
- // Your code here
+$( document ).ready(function() {
+ // Your code here
});
```
For example, inside the `ready` event, you can add a click handler to the link:
```
$( document ).ready(function() {
- $("a").click(function( event ) {
- alert("Thanks for visiting!");
- });
+ $( "a" ).click(function( event ) {
+ alert( "Thanks for visiting!" );
+ });
});
```
-Save your HTML file and reload the test page in your browser.
-Clicking the link should now first display an alert pop-up,
+Save your HTML file and reload the test page in your browser.
+Clicking the link should now first display an alert pop-up,
then continue with the default behavior of navigating to http://jquery.com.
-For `click` and most other [events](http://api.jquery.com/category/events/),
+For `click` and most other [events](http://api.jquery.com/category/events/),
you can prevent the default behavior by calling `event.preventDefault()` in the event handler:
```
$( document ).ready(function() {
- $("a").click(function( event ) {
- alert("As you can see, the link no longer took you to jquery.com");
- event.preventDefault();
- });
+ $( "a" ).click(function( event ) {
+ alert( "As you can see, the link no longer took you to jquery.com" );
+ event.preventDefault();
+ });
});
```
### Complete Example
The following example illustrates the click handling code discussed above,
embedded directly in the HTML `<body>`. Note that in practice,
-it is usually better to place your code in a separate JS file
+it is usually better to place your code in a separate JS file
and load it on the page with a `<script>` element's `src` attribute.
```
<!doctype html>
<html>
- <head>
- <meta charset="utf-8">
- <title>Demo</title>
- </head>
- <body>
- <a href="http://jquery.com/">jQuery</a>
- <script src="jquery.js"></script>
- <script>
- $( document ).ready(function() {
- $("a").click(function( event ) {
- alert("The link will no longer take you to jquery.com");
- event.preventDefault();
- });
- });
- </script>
- </body>
+<head>
+ <meta charset="utf-8">
+ <title>Demo</title>
+</head>
+<body>
+ <a href="http://jquery.com/">jQuery</a>
+ <script src="jquery.js"></script>
+ <script>
+ $( document ).ready(function() {
+ $( "a" ).click(function( event ) {
+ alert( "The link will no longer take you to jquery.com" );
+ event.preventDefault();
+ });
+ });
+ </script>
+</body>
</html>
```
@@ -114,24 +114,24 @@ First, add some style information into the `<head>` of the document, like this:
```
<style>
- a.test {
- font-weight: bold;
- }
+a.test {
+ font-weight: bold;
+}
</style>
```
Next, add the [addClass()](http://api.jquery.com/addClass) call to the script:
```
-$("a").addClass("test");
+$( "a" ).addClass( "test" );
```
All `a` elements are now bold.
To remove an existing `class`, use [removeClass()](http://api.jquery.com/removeClass):
```
-$("a").removeClass("test");
+$( "a" ).removeClass( "test" );
```
### Special Effects
@@ -141,9 +141,9 @@ to help you make your web sites stand out.
For example, if you create a click handler of:
```
-$("a").click(function( event ){
- event.preventDefault();
- $( this ).hide("slow");
+$( "a" ).click(function( event ){
+ event.preventDefault();
+ $( this ).hide( "slow" );
});
```
@@ -155,7 +155,7 @@ Unlike many other programming languages, JavaScript enables you to freely pass f
A *callback* is a function that is passed as an argument to another function and
is executed after its parent function has completed. Callbacks are special because
they patiently wait to execute until their parent finishes.
-Meanwhile, the browser can be executing other functions or doing all sorts of other work.
+Meanwhile, the browser can be executing other functions or doing all sorts of other work.
To use callbacks, it is important to know how to pass them into their parent function.
@@ -172,31 +172,31 @@ When [$.get](http://api.jquery.com/jQuery.get/) finishes getting the page `myhtm
### Callback *with* Arguments
-Executing callbacks with arguments can be tricky.
+Executing callbacks with arguments can be tricky.
#### Wrong
This code example will ***not*** work:
```
-$.get( "myhtmlpage.html", myCallBack(param1, param2) );
+$.get( "myhtmlpage.html", myCallBack( param1, param2 ) );
```
-The reason this fails is that the code executes `myCallBack( param1, param2 )` immediately
-and then passes the myCallBack's *return value* as the second parameter to `$.get`.
-We actually want to pass the function `myCallBack`, not `myCallBack( param1, param2)`'s return value
+The reason this fails is that the code executes `myCallBack( param1, param2 )` immediately
+and then passes myCallBack's *return value* as the second parameter to `$.get`.
+We actually want to pass the function `myCallBack`, not `myCallBack( param1, param2 )`'s return value
(which might or might not be a function). So, how to pass in `myCallBack` *and* include its arguments?
#### Right
To defer executing `myCallBack` with its parameters, you can use an anonymous function as a wrapper.
Note the use of `function() {`. The anonymous function does exactly one thing: calls
-`myCallBack`, with the values of `param1` and `param2`.
+`myCallBack`, with the values of `param1` and `param2`.
```
- $.get( "myhtmlpage.html", function() {
- myCallBack( param1, param2 );
- });
+$.get( "myhtmlpage.html", function() {
+ myCallBack( param1, param2 );
+});
```
When `$.get` finishes getting the page `myhtmlpage.html`, it executes the anonymous function,
-which executes `myCallBack( param1, param2 )`.
+which executes `myCallBack( param1, param2 )`.
View
@@ -1,26 +1,24 @@
<script>{
- "title": "jQuery Learning Site",
- "pageTemplate": "home.php",
- "customFields": [{ "key": "icon", "value": "home" }, { "key": "is_chapter", "value": 0 }]
+ "title": "jQuery Learning Site",
+ "pageTemplate": "home.php",
+ "customFields": [{ "key": "icon", "value": "home" }, { "key": "is_chapter", "value": 0 }]
}</script>
<div id="banner-secondary" class="large-banner">
- <h1>Learning Center</h1>
+ <h1>Learning Center</h1>
- <div class="row">
- <aside class="six columns" id="for-users">
- <h2>Users</h2>
- <p>
- There&rsquo;s a lot more to learn about building web sites and applications with jQuery than can fit in API documentation.
- If you&rsquo;re looking for explanations of the basics, workarounds for common problems, best practices, and how-tos, you&rsquo;re in the right place!</p>
- </p>
- </aside>
+ <div class="row">
- <aside class="six columns" id="for-authors">
- <h2>Authors</h2>
- <p>Too much good information is spread across corners of the web, languishing in blog and forum posts, often just out of the reach of
- people who need it, while the same questionable advice is duplicated across even more questionable sites. Help us stem the tide and educate today&apos;s &mdash; and tomorrow&rsquo;s &mdash; web developers.</p>
- </aside>
- </div>
+ <aside class="six columns" id="for-users">
+ <h2>Users</h2>
+ <p>There's a lot more to learn about building web sites and applications with jQuery than can fit in API documentation. If you're looking for explanations of the basics, workarounds for common problems, best practices, and how-tos, you're in the right place!</p>
+ </aside>
-</div>
+ <aside class="six columns" id="for-authors">
+ <h2>Authors</h2>
+ <p>Too much good information is spread across corners of the web, languishing in blog and forum posts, often just out of reach of people who need it, while the same questionable advice is duplicated across even more questionable sites. Help us stem the tide and educate today's — and tomorrow's — web developers.</p>
+ </aside>
+
+ </div>
+
+</div>

0 comments on commit 1f48ad2

Please sign in to comment.